Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

troika-three-utils

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-three-utils - npm Package Compare versions

Comparing version 0.47.0 to 0.47.2

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [0.47.2](https://github.com/protectwise/troika/compare/v0.47.1...v0.47.2) (2023-05-15)
### Bug Fixes
* **troika-three-utils:** pass renderer argument to base material's onBeforeCompile ([3a23a8e](https://github.com/protectwise/troika/commit/3a23a8eb72275e37d42085cb6a2fd4e704224e9d))
* **troika-three-utils:** vertexTransform now handles MAP_UV token introduced in Three r152 ([d8c32ed](https://github.com/protectwise/troika/commit/d8c32ed93920633455e078283b0c3dbc058fb7c1))
# [0.47.0](https://github.com/protectwise/troika/compare/v0.46.3...v0.47.0) (2022-12-15)

@@ -8,0 +20,0 @@

20

dist/troika-three-utils.esm.js

@@ -62,3 +62,3 @@ import { ShaderChunk, UniformsUtils, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, ShaderLib, Matrix4, Vector3, Mesh, CylinderGeometry, Vector2, MeshStandardMaterial, DoubleSide } from 'three';

for (let prop in source) {
if (source.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
target[prop] = source[prop];

@@ -162,4 +162,4 @@ }

// the renderer switches to this material's program
const onBeforeCompile = function (shaderInfo) {
baseMaterial.onBeforeCompile.call(this, shaderInfo);
const onBeforeCompile = function (shaderInfo, renderer) {
baseMaterial.onBeforeCompile.call(this, shaderInfo, renderer);

@@ -170,3 +170,3 @@ // Upgrade the shaders, caching the result by incoming source code

if (!upgradedShaders) {
const upgraded = upgradeShaders(shaderInfo, options, optionsKey);
const upgraded = upgradeShaders(this, shaderInfo, options, optionsKey);
upgradedShaders = SHADER_UPGRADE_CACHE[cacheKey] = upgraded;

@@ -327,3 +327,3 @@ }

function upgradeShaders({vertexShader, fragmentShader}, options, key) {
function upgradeShaders(material, {vertexShader, fragmentShader}, options, key) {
let {

@@ -416,2 +416,8 @@ vertexDefs,

});
// Three r152 introduced the MAP_UV token, replace it too if it's pointing to the main 'uv'
// Perhaps the other textures too going forward?
if (!(material.map && material.map.channel > 0)) {
vertexShader = vertexShader.replace(/\bMAP_UV\b/g, `troika_uv_${key}`);
}
}

@@ -717,3 +723,3 @@

onBeforeRender(shaderInfo) {
onBeforeRender() {
const {uniforms} = this.material;

@@ -729,3 +735,3 @@ const {pointA, controlA, controlB, pointB, radius, dashArray, dashOffset} = this;

raycast(raycaster, intersects) {
raycast(/*raycaster, intersects*/) {
// TODO - just fail for now

@@ -732,0 +738,0 @@ }

@@ -66,3 +66,3 @@ (function (global, factory) {

for (let prop in source) {
if (source.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
target[prop] = source[prop];

@@ -166,4 +166,4 @@ }

// the renderer switches to this material's program
const onBeforeCompile = function (shaderInfo) {
baseMaterial.onBeforeCompile.call(this, shaderInfo);
const onBeforeCompile = function (shaderInfo, renderer) {
baseMaterial.onBeforeCompile.call(this, shaderInfo, renderer);

@@ -174,3 +174,3 @@ // Upgrade the shaders, caching the result by incoming source code

if (!upgradedShaders) {
const upgraded = upgradeShaders(shaderInfo, options, optionsKey);
const upgraded = upgradeShaders(this, shaderInfo, options, optionsKey);
upgradedShaders = SHADER_UPGRADE_CACHE[cacheKey] = upgraded;

@@ -331,3 +331,3 @@ }

function upgradeShaders({vertexShader, fragmentShader}, options, key) {
function upgradeShaders(material, {vertexShader, fragmentShader}, options, key) {
let {

@@ -420,2 +420,8 @@ vertexDefs,

});
// Three r152 introduced the MAP_UV token, replace it too if it's pointing to the main 'uv'
// Perhaps the other textures too going forward?
if (!(material.map && material.map.channel > 0)) {
vertexShader = vertexShader.replace(/\bMAP_UV\b/g, `troika_uv_${key}`);
}
}

@@ -721,3 +727,3 @@

onBeforeRender(shaderInfo) {
onBeforeRender() {
const {uniforms} = this.material;

@@ -733,3 +739,3 @@ const {pointA, controlA, controlB, pointB, radius, dashArray, dashOffset} = this;

raycast(raycaster, intersects) {
raycast(/*raycaster, intersects*/) {
// TODO - just fail for now

@@ -736,0 +742,0 @@ }

@@ -1,36 +0,36 @@

'use strict';(function(f,d){"object"===typeof exports&&"undefined"!==typeof module?d(exports,require("three")):"function"===typeof define&&define.amd?define(["exports","three"],d):(f="undefined"!==typeof globalThis?globalThis:f||self,d(f.troika_three_utils={},f.THREE))})(this,function(f,d){function q(a){return a.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,function(a,g){return(g=d.ShaderChunk[g])?q(g):a})}function l(a,b){let g=C(b),c=n.get(a);c||n.set(a,c=Object.create(null));if(c[g])return new c[g];
let t=`_onBeforeCompile${g}`,f=function(h){a.onBeforeCompile.call(this,h);const c=this.customProgramCacheKey()+"|"+h.vertexShader+"|"+h.fragmentShader;var d=v[c];d||(d=D(h,b,g),d=v[c]=d);h.vertexShader=d.vertexShader;h.fragmentShader=d.fragmentShader;k(h.uniforms,this.uniforms);b.timeUniform&&(h.uniforms[b.timeUniform]={get value(){return Date.now()-E}});if(this[t])this[t](h)},u=function(){return m(b.chained?a:a.clone())},m=function(h){const c=Object.create(h,F);Object.defineProperty(c,"baseMaterial",
{value:a});Object.defineProperty(c,"id",{value:G++});{var d=4294967295*Math.random()|0;let a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()|0;d=(e[d&255]+e[d>>8&255]+e[d>>16&255]+e[d>>24&255]+"-"+e[a&255]+e[a>>8&255]+"-"+e[a>>16&15|64]+e[a>>24&255]+"-"+e[b&63|128]+e[b>>8&255]+"-"+e[b>>16&255]+e[b>>24&255]+e[c&255]+e[c>>8&255]+e[c>>16&255]+e[c>>24&255]).toUpperCase()}c.uuid=d;c.uniforms=k({},h.uniforms,b.uniforms);c.defines=k({},h.defines,b.defines);c.defines[`TROIKA_DERIVED_MATERIAL_${g}`]=
"";c.extensions=k({},h.extensions,b.extensions);c._listeners=void 0;return c},F={constructor:{value:u},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return a.customProgramCacheKey()+"|"+g}},onBeforeCompile:{get(){return f},set(a){this[t]=a}},copy:{writable:!0,configurable:!0,value:function(b){a.copy.call(this,b);a.isShaderMaterial||a.isDerivedMaterial||(k(this.extensions,b.extensions),k(this.defines,b.defines),k(this.uniforms,d.UniformsUtils.clone(b.uniforms)));
return this}},clone:{writable:!0,configurable:!0,value:function(){const b=new a.constructor;return m(b).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;c||(c=this._depthMaterial=l(a.isDerivedMaterial?a.getDepthMaterial():new d.MeshDepthMaterial({depthPacking:d.RGBADepthPacking}),b),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms);return c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;c||
(c=this._distanceMaterial=l(a.isDerivedMaterial?a.getDistanceMaterial():new d.MeshDistanceMaterial,b),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms);return c}},dispose:{writable:!0,configurable:!0,value(){const {_depthMaterial:b,_distanceMaterial:c}=this;b&&b.dispose();c&&c.dispose();a.dispose.call(this)}}};c[g]=u;return new u}function D({vertexShader:a,fragmentShader:b},d,c){let {vertexDefs:g,vertexMainIntro:e,vertexMainOutro:f,vertexTransform:m,fragmentDefs:k,fragmentMainIntro:h,fragmentMainOutro:p,
fragmentColorTransform:l,customRewriter:r,timeUniform:n}=d;g=g||"";e=e||"";f=f||"";k=k||"";h=h||"";p=p||"";if(m||r)a=q(a);if(l||r)b=b.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"),b=q(b);r&&(b=r({vertexShader:a,fragmentShader:b}),a=b.vertexShader,b=b.fragmentShader);if(l){let a=[];b=b.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,b=>{a.push(b);return""});p=`${l}\n${a.join("\n")}\n${p}`}n&&
(d=`\nuniform float ${n};\n`,g=d+g,k=d+k);m&&(g=`${g}
void troikaVertexTransform${c}(inout vec3 position, inout vec3 normal, inout vec2 uv) {
${m}
'use strict';(function(h,c){"object"===typeof exports&&"undefined"!==typeof module?c(exports,require("three")):"function"===typeof define&&define.amd?define(["exports","three"],c):(h="undefined"!==typeof globalThis?globalThis:h||self,c(h.troika_three_utils={},h.THREE))})(this,function(h,c){function q(a){return a.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,function(a,k){return(k=c.ShaderChunk[k])?q(k):a})}function m(a,b){let k=D(b),e=n.get(a);e||n.set(a,e=Object.create(null));if(e[k])return new e[k];
let g=`_onBeforeCompile${k}`,h=function(d,e){a.onBeforeCompile.call(this,d,e);e=this.customProgramCacheKey()+"|"+d.vertexShader+"|"+d.fragmentShader;var c=v[e];c||(c=E(this,d,b,k),c=v[e]=c);d.vertexShader=c.vertexShader;d.fragmentShader=c.fragmentShader;l(d.uniforms,this.uniforms);b.timeUniform&&(d.uniforms[b.timeUniform]={get value(){return Date.now()-F}});if(this[g])this[g](d)},t=function(){return w(b.chained?a:a.clone())},w=function(d){const c=Object.create(d,G);Object.defineProperty(c,"baseMaterial",
{value:a});Object.defineProperty(c,"id",{value:H++});{var e=4294967295*Math.random()|0;let a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,d=4294967295*Math.random()|0;e=(f[e&255]+f[e>>8&255]+f[e>>16&255]+f[e>>24&255]+"-"+f[a&255]+f[a>>8&255]+"-"+f[a>>16&15|64]+f[a>>24&255]+"-"+f[b&63|128]+f[b>>8&255]+"-"+f[b>>16&255]+f[b>>24&255]+f[d&255]+f[d>>8&255]+f[d>>16&255]+f[d>>24&255]).toUpperCase()}c.uuid=e;c.uniforms=l({},d.uniforms,b.uniforms);c.defines=l({},d.defines,b.defines);c.defines[`TROIKA_DERIVED_MATERIAL_${k}`]=
"";c.extensions=l({},d.extensions,b.extensions);c._listeners=void 0;return c},G={constructor:{value:t},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return a.customProgramCacheKey()+"|"+k}},onBeforeCompile:{get(){return h},set(a){this[g]=a}},copy:{writable:!0,configurable:!0,value:function(b){a.copy.call(this,b);a.isShaderMaterial||a.isDerivedMaterial||(l(this.extensions,b.extensions),l(this.defines,b.defines),l(this.uniforms,c.UniformsUtils.clone(b.uniforms)));
return this}},clone:{writable:!0,configurable:!0,value:function(){const b=new a.constructor;return w(b).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let d=this._depthMaterial;d||(d=this._depthMaterial=m(a.isDerivedMaterial?a.getDepthMaterial():new c.MeshDepthMaterial({depthPacking:c.RGBADepthPacking}),b),d.defines.IS_DEPTH_MATERIAL="",d.uniforms=this.uniforms);return d}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let d=this._distanceMaterial;d||
(d=this._distanceMaterial=m(a.isDerivedMaterial?a.getDistanceMaterial():new c.MeshDistanceMaterial,b),d.defines.IS_DISTANCE_MATERIAL="",d.uniforms=this.uniforms);return d}},dispose:{writable:!0,configurable:!0,value(){const {_depthMaterial:b,_distanceMaterial:c}=this;b&&b.dispose();c&&c.dispose();a.dispose.call(this)}}};e[k]=t;return new t}function E(a,{vertexShader:b,fragmentShader:c},e,g){let {vertexDefs:k,vertexMainIntro:f,vertexMainOutro:h,vertexTransform:l,fragmentDefs:d,fragmentMainIntro:m,
fragmentMainOutro:p,fragmentColorTransform:u,customRewriter:r,timeUniform:n}=e;k=k||"";f=f||"";h=h||"";d=d||"";m=m||"";p=p||"";if(l||r)b=q(b);if(u||r)c=c.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"),c=q(c);r&&(c=r({vertexShader:b,fragmentShader:c}),b=c.vertexShader,c=c.fragmentShader);if(u){let a=[];c=c.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,b=>{a.push(b);return""});p=
`${u}\n${a.join("\n")}\n${p}`}n&&(e=`\nuniform float ${n};\n`,k=e+k,d=e+d);l&&(k=`${k}
void troikaVertexTransform${g}(inout vec3 position, inout vec3 normal, inout vec2 uv) {
${l}
}
`,e=`
troika_position_${c} = vec3(position);
troika_normal_${c} = vec3(normal);
troika_uv_${c} = vec2(uv);
troikaVertexTransform${c}(troika_position_${c}, troika_normal_${c}, troika_uv_${c});
${e}
`,a=`vec3 troika_position_${c};
vec3 troika_normal_${c};
vec2 troika_uv_${c};
${a}
`.replace(/\b(position|normal|uv)\b/g,(a,b,d,g)=>/\battribute\s+vec[23]\s+$/.test(g.substr(0,d))?b:`troika_${b}_${c}`));a=w(a,c,g,e,f);b=w(b,c,k,h,p);return{vertexShader:a,fragmentShader:b}}function w(a,b,d,c,e){if(c||e||d)a=a.replace(x,`
${d}
`,f=`
troika_position_${g} = vec3(position);
troika_normal_${g} = vec3(normal);
troika_uv_${g} = vec2(uv);
troikaVertexTransform${g}(troika_position_${g}, troika_normal_${g}, troika_uv_${g});
${f}
`,b=`vec3 troika_position_${g};
vec3 troika_normal_${g};
vec2 troika_uv_${g};
${b}
`.replace(/\b(position|normal|uv)\b/g,(a,b,c,e)=>/\battribute\s+vec[23]\s+$/.test(e.substr(0,c))?b:`troika_${b}_${g}`),a.map&&0<a.map.channel||(b=b.replace(/\bMAP_UV\b/g,`troika_uv_${g}`)));b=x(b,g,k,f,h);c=x(c,g,d,m,p);return{vertexShader:b,fragmentShader:c}}function x(a,b,c,e,g){if(e||g||c)a=a.replace(y,`
${c}
void troikaOrigMain${b}() {`),a+=`
void main() {
${c}
${e}
troikaOrigMain${b}();
${e}
}`;return a}function H(a,b){return"uniforms"===a?void 0:"function"===typeof b?b.toString():b}function C(a){a=JSON.stringify(a,H);let b=y.get(a);null==b&&y.set(a,b=++I);return b}let x=/\bvoid\s+main\s*\(\s*\)\s*{/g,e=[];for(let a=0;256>a;a++)e[a]=(16>a?"0":"")+a.toString(16);let k=Object.assign||function(){let a=arguments[0];for(let b=1,d=arguments.length;b<d;b++){let c=arguments[b];if(c)for(let b in c)c.hasOwnProperty(b)&&(a[b]=c[b])}return a},E=Date.now(),n=new WeakMap,v=new Map,G=1E10,I=0,y=new Map,
J={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},z=null,A=new d.MeshStandardMaterial({color:16777215,side:d.DoubleSide});class B extends d.Mesh{static getGeometry(){return z||
(z=(new d.CylinderGeometry(1,1,1,6,64)).translate(0,.5,0))}constructor(){super(B.getGeometry(),A);this.pointA=new d.Vector3;this.controlA=new d.Vector3;this.controlB=new d.Vector3;this.pointB=new d.Vector3;this.radius=.01;this.dashArray=new d.Vector2;this.dashOffset=0;this.frustumCulled=!1}get material(){let a=this._derivedMaterial,b=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=A.clone());a&&a.baseMaterial===b||(a=this._derivedMaterial=l(b,{chained:!0,uniforms:{pointA:{value:new d.Vector3},
controlA:{value:new d.Vector3},controlB:{value:new d.Vector3},pointB:{value:new d.Vector3},radius:{value:.01},dashing:{value:new d.Vector3}},vertexDefs:"\nuniform vec3 pointA;\nuniform vec3 controlA;\nuniform vec3 controlB;\nuniform vec3 pointB;\nuniform float radius;\nvarying float bezierT;\n\nvec3 cubicBezier(vec3 p1, vec3 c1, vec3 c2, vec3 p2, float t) {\n float t2 = 1.0 - t;\n float b0 = t2 * t2 * t2;\n float b1 = 3.0 * t * t2 * t2;\n float b2 = 3.0 * t * t * t2;\n float b3 = t * t * t;\n return b0 * p1 + b1 * c1 + b2 * c2 + b3 * p2;\n}\n\nvec3 cubicBezierDerivative(vec3 p1, vec3 c1, vec3 c2, vec3 p2, float t) {\n float t2 = 1.0 - t;\n return -3.0 * p1 * t2 * t2 +\n c1 * (3.0 * t2 * t2 - 6.0 * t2 * t) +\n c2 * (6.0 * t2 * t - 3.0 * t * t) +\n 3.0 * p2 * t * t;\n}\n",
${g}
}`;return a}function I(a,b){return"uniforms"===a?void 0:"function"===typeof b?b.toString():b}function D(a){a=JSON.stringify(a,I);let b=z.get(a);null==b&&z.set(a,b=++J);return b}let y=/\bvoid\s+main\s*\(\s*\)\s*{/g,f=[];for(let a=0;256>a;a++)f[a]=(16>a?"0":"")+a.toString(16);let l=Object.assign||function(){let a=arguments[0];for(let b=1,c=arguments.length;b<c;b++){let c=arguments[b];if(c)for(let b in c)Object.prototype.hasOwnProperty.call(c,b)&&(a[b]=c[b])}return a},F=Date.now(),n=new WeakMap,v=new Map,
H=1E10,J=0,z=new Map,K={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},A=null,B=new c.MeshStandardMaterial({color:16777215,side:c.DoubleSide});
class C extends c.Mesh{static getGeometry(){return A||(A=(new c.CylinderGeometry(1,1,1,6,64)).translate(0,.5,0))}constructor(){super(C.getGeometry(),B);this.pointA=new c.Vector3;this.controlA=new c.Vector3;this.controlB=new c.Vector3;this.pointB=new c.Vector3;this.radius=.01;this.dashArray=new c.Vector2;this.dashOffset=0;this.frustumCulled=!1}get material(){let a=this._derivedMaterial,b=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=B.clone());a&&a.baseMaterial===b||(a=this._derivedMaterial=
m(b,{chained:!0,uniforms:{pointA:{value:new c.Vector3},controlA:{value:new c.Vector3},controlB:{value:new c.Vector3},pointB:{value:new c.Vector3},radius:{value:.01},dashing:{value:new c.Vector3}},vertexDefs:"\nuniform vec3 pointA;\nuniform vec3 controlA;\nuniform vec3 controlB;\nuniform vec3 pointB;\nuniform float radius;\nvarying float bezierT;\n\nvec3 cubicBezier(vec3 p1, vec3 c1, vec3 c2, vec3 p2, float t) {\n float t2 = 1.0 - t;\n float b0 = t2 * t2 * t2;\n float b1 = 3.0 * t * t2 * t2;\n float b2 = 3.0 * t * t * t2;\n float b3 = t * t * t;\n return b0 * p1 + b1 * c1 + b2 * c2 + b3 * p2;\n}\n\nvec3 cubicBezierDerivative(vec3 p1, vec3 c1, vec3 c2, vec3 p2, float t) {\n float t2 = 1.0 - t;\n return -3.0 * p1 * t2 * t2 +\n c1 * (3.0 * t2 * t2 - 6.0 * t2 * t) +\n c2 * (6.0 * t2 * t - 3.0 * t * t) +\n 3.0 * p2 * t * t;\n}\n",
vertexTransform:'\nfloat t = position.y;\nbezierT = t;\nvec3 bezierCenterPos = cubicBezier(pointA, controlA, controlB, pointB, t);\nvec3 bezierDir = normalize(cubicBezierDerivative(pointA, controlA, controlB, pointB, t));\n\n// Make "sideways" always perpendicular to the camera ray; this ensures that any twists\n// in the cylinder occur where you won\'t see them: \nvec3 viewDirection = normalMatrix * vec3(0.0, 0.0, 1.0);\nif (bezierDir == viewDirection) {\n bezierDir = normalize(cubicBezierDerivative(pointA, controlA, controlB, pointB, t == 1.0 ? t - 0.0001 : t + 0.0001));\n}\nvec3 sideways = normalize(cross(bezierDir, viewDirection));\nvec3 upish = normalize(cross(sideways, bezierDir));\n\n// Build a matrix for transforming this disc in the cylinder:\nmat4 discTx;\ndiscTx[0].xyz = sideways * radius;\ndiscTx[1].xyz = bezierDir * radius;\ndiscTx[2].xyz = upish * radius;\ndiscTx[3].xyz = bezierCenterPos;\ndiscTx[3][3] = 1.0;\n\n// Apply transform, ignoring original y\nposition = (discTx * vec4(position.x, 0.0, position.z, 1.0)).xyz;\nnormal = normalize(mat3(discTx) * normal);\n',
fragmentDefs:"\nuniform vec3 dashing;\nvarying float bezierT;\n",fragmentMainIntro:"\nif (dashing.x + dashing.y > 0.0) {\n float dashFrac = mod(bezierT - dashing.z, dashing.x + dashing.y);\n if (dashFrac > dashing.x) {\n discard;\n }\n}\n"}),b.addEventListener("dispose",function c(){b.removeEventListener("dispose",c);a.dispose()}));return a}set material(a){this._baseMaterial=a}get customDepthMaterial(){return this.material.getDepthMaterial()}get customDistanceMaterial(){return this.material.getDistanceMaterial()}onBeforeRender(a){({uniforms:a}=
this.material);let {pointA:b,controlA:d,controlB:c,pointB:e,radius:f,dashArray:k,dashOffset:l}=this;a.pointA.value.copy(b);a.controlA.value.copy(d);a.controlB.value.copy(c);a.pointB.value.copy(e);a.radius.value=f;a.dashing.value.set(k.x,k.y,l||0)}raycast(a,b){}}f.BezierMesh=B;f.createDerivedMaterial=l;f.expandShaderIncludes=q;f.getShaderUniformTypes=function(a){let b=/\buniform\s+(int|float|vec[234]|mat[34])\s+([A-Za-z_][\w]*)/g,d=Object.create(null),c;for(;null!==(c=b.exec(a));)d[c[2]]=c[1];return d};
f.getShadersForMaterial=function(a){let b=J[a.type];return b?d.ShaderLib[b]:a};f.invertMatrix4=function(a,b=new d.Matrix4){"function"===typeof b.invert?b.copy(a).invert():b.getInverse(a);return b};f.voidMainRegExp=x;Object.defineProperty(f,"__esModule",{value:!0})})
fragmentDefs:"\nuniform vec3 dashing;\nvarying float bezierT;\n",fragmentMainIntro:"\nif (dashing.x + dashing.y > 0.0) {\n float dashFrac = mod(bezierT - dashing.z, dashing.x + dashing.y);\n if (dashFrac > dashing.x) {\n discard;\n }\n}\n"}),b.addEventListener("dispose",function e(){b.removeEventListener("dispose",e);a.dispose()}));return a}set material(a){this._baseMaterial=a}get customDepthMaterial(){return this.material.getDepthMaterial()}get customDistanceMaterial(){return this.material.getDistanceMaterial()}onBeforeRender(){let {uniforms:a}=
this.material,{pointA:b,controlA:c,controlB:e,pointB:g,radius:f,dashArray:h,dashOffset:l}=this;a.pointA.value.copy(b);a.controlA.value.copy(c);a.controlB.value.copy(e);a.pointB.value.copy(g);a.radius.value=f;a.dashing.value.set(h.x,h.y,l||0)}raycast(){}}h.BezierMesh=C;h.createDerivedMaterial=m;h.expandShaderIncludes=q;h.getShaderUniformTypes=function(a){let b=/\buniform\s+(int|float|vec[234]|mat[34])\s+([A-Za-z_][\w]*)/g,c=Object.create(null),e;for(;null!==(e=b.exec(a));)c[e[2]]=e[1];return c};h.getShadersForMaterial=
function(a){let b=K[a.type];return b?c.ShaderLib[b]:a};h.invertMatrix4=function(a,b=new c.Matrix4){"function"===typeof b.invert?b.copy(a).invert():b.getInverse(a);return b};h.voidMainRegExp=y;Object.defineProperty(h,"__esModule",{value:!0})})
{
"name": "troika-three-utils",
"version": "0.47.0",
"version": "0.47.2",
"description": "Various utilities related to Three.js",

@@ -19,3 +19,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>",

},
"gitHead": "f20187dfa6a07de046b4e6a3948e75483b8e2ee5"
"gitHead": "27cb013dd98d1b3e47d42dcc2787313949525572"
}

@@ -89,3 +89,3 @@ import { CylinderGeometry, DoubleSide, Mesh, MeshStandardMaterial, Vector2, Vector3 } from 'three'

onBeforeRender(shaderInfo) {
onBeforeRender() {
const {uniforms} = this.material

@@ -101,3 +101,3 @@ const {pointA, controlA, controlB, pointB, radius, dashArray, dashOffset} = this

raycast(raycaster, intersects) {
raycast(/*raycaster, intersects*/) {
// TODO - just fail for now

@@ -104,0 +104,0 @@ }

import { createDerivedMaterial } from './DerivedMaterial.js'
import { Vector2, Vector3 } from 'three'
import { Vector3 } from 'three'

@@ -4,0 +4,0 @@ /*

@@ -13,3 +13,3 @@ import { voidMainRegExp } from './voidMainRegExp.js'

for (let prop in source) {
if (source.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
target[prop] = source[prop]

@@ -113,4 +113,4 @@ }

// the renderer switches to this material's program
const onBeforeCompile = function (shaderInfo) {
baseMaterial.onBeforeCompile.call(this, shaderInfo)
const onBeforeCompile = function (shaderInfo, renderer) {
baseMaterial.onBeforeCompile.call(this, shaderInfo, renderer)

@@ -121,3 +121,3 @@ // Upgrade the shaders, caching the result by incoming source code

if (!upgradedShaders) {
const upgraded = upgradeShaders(shaderInfo, options, optionsKey)
const upgraded = upgradeShaders(this, shaderInfo, options, optionsKey)
upgradedShaders = SHADER_UPGRADE_CACHE[cacheKey] = upgraded

@@ -278,3 +278,3 @@ }

function upgradeShaders({vertexShader, fragmentShader}, options, key) {
function upgradeShaders(material, {vertexShader, fragmentShader}, options, key) {
let {

@@ -367,2 +367,8 @@ vertexDefs,

})
// Three r152 introduced the MAP_UV token, replace it too if it's pointing to the main 'uv'
// Perhaps the other textures too going forward?
if (!(material.map && material.map.channel > 0)) {
vertexShader = vertexShader.replace(/\bMAP_UV\b/g, `troika_uv_${key}`);
}
}

@@ -369,0 +375,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc