@splinetool/loader 0.9.152 → 0.9.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +1 -1
- package/build/SplineLoader.js +1 -1
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -1083,7 +1083,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
1083
1083
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
1084
1084
|
}
|
|
1085
1085
|
`),u&&c.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),s?c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${s.result} );`):c.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=c.join(`
|
|
1086
|
-
`)}return t}};var KA=require("three");function fm(o,e){switch(o.type){case"fresnel":return dw(o,e);case"gradient":return pw(o);case"depth":return fw(o);case"normal":return mw(o);case"noise":return hw(o,e);case"rainbow":return gw(o);case"toon":return yw(o,e);case"outline":return xw(o,e);case"transmission":return vw(o,e);case"color":return uw(o,e)}}function cw(o){return{type:o.type}}function Et(o){let{alpha:e,mode:A}=o;return{...cw(o),alpha:e,mode:A}}function uw(o,e){return{...Et(o),color:ae(o.color,e)}}function dw(o,e){let{bias:A,scale:t,intensity:r,factor:n,color:i}=o;return{...Et(o),color:ae(i,e),bias:A,scale:t,intensity:r,factor:n}}function pw(o){let{gradientType:e,smooth:A,colors:t,steps:r,angle:n,offset:i,morph:a}=o;return{...Et(o),gradientType:e,smooth:A,colors:t.map(l=>new KA.Vector4(l[0],l[1],l[2],l[3])),num:t.length,steps:r,offset:new KA.Vector2(...i),morph:new KA.Vector2(...a),angle:n}}function fw(o){let{gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:u,smooth:s}=o;return{...Et(o),gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:new KA.Vector3(...i),direction:a?new KA.Vector3(...a):new KA.Vector3(1,0,0),colors:l.map(c=>c!==void 0?new KA.Vector4(c[0],c[1],c[2],c[3]):new KA.Vector4(0,0,0,0)),steps:u.slice(0,l.length),smooth:s}}function mw(o){let{cnormal:e}=o;return{...Et(o),cnormal:new KA.Vector3(e[0],e[1],e[2])}}function hw(o,e){return{...Et(o),scale:o.scale,move:o.move,fA:new KA.Vector2(...o.fA),fB:new KA.Vector2(...o.fB),size:new KA.Vector3(...o.size),distortion:new KA.Vector2(...o.distortion),colorA:ae(o.colorA,e),colorB:ae(o.colorB,e),colorC:ae(o.colorC,e),colorD:ae(o.colorD,e),noiseType:o.noiseType}}function gw(o){return{...Et(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new KA.Vector3(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new KA.Vector3(...o.offset)}}function yw(o,e){return{...Et(o),positioning:o.positioning,colors:o.colors.map(A=>new KA.Vector4(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new KA.Vector3(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:ae(o.shadowColor,e),offset:new KA.Vector3(...o.offset)}}function xw(o,e){return{...Et(o),outlineColor:ae(o.outlineColor,e),contourColor:ae(o.contourColor,e),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:o.contourDirection,positionalLines:o.positionalLines,compensation:o.compensation}}function vw(o,e){return{...Et(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var Tr=class extends re{};var hm=require("three");var da=require("three");var ua=class{constructor(e=1e3*10){this.timeout=e;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...e){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),A=this.head.next;for(;A.time<e-this.timeout;)this.dispose(A.src,A.data),this.cache.delete(A.src),A=A.next,A.prev=this.head,this.head.next=A;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}load(e){let A=Date.now(),t=this.cache.get(e);return t===void 0?(t={data:this.create(e),src:e,time:A,next:null,prev:null},this.cache.set(e,t)):(t.time=A,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var $l=class extends ua{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,A){URL.revokeObjectURL(A)}},_l;function mm(o){return typeof o=="string"?o:(_l||(_l=new $l),_l.load(o))}var Qr=class{constructor(e,A){this.data=e;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.dispose(),this.loaded=!1;let A=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let n of r){let i=this[n];i&&(i.image=this.img,i.needsUpdate=!0)}this.onImageLoad&&this.onImageLoad()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,this.img.muted=!0,this.img.pause(),typeof e!="string"){var t=new FileReader;t.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{t.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=A}else this.img=new Image,this.img.src=mm(e),this.img.onload=A}getTexture(e){let A=this[e];if(A)return A;{let t;return this.isVideo?t=new da.VideoTexture(this.img,void 0,e,e):t=new da.Texture(this.img,void 0,e,e),this.loaded&&(t.needsUpdate=!0),this[e]=t,t}}dispose(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}};1e3,1001,1002;var Dt=class extends Qr{};var Nr=class extends GA{};var Ac={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},ec={depth:["colors"]};function bw(o,e,A){let t=Ac[o.type],r=ec[o.type];if(r!==void 0){let n=o.color;if(r.includes(e)){let i=n[e]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return t!==void 0?t.includes(e):!1}function tc(o,e,A){let t=A.uniforms[`f${A.id}_texture`];if(!t)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=e.image(i),l=t;l instanceof Dt||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=e.video(i),l=t;l instanceof Dt||l.image.dispose(),l.image=a}if("wrapping"in n){let i=t;i.wrap=n.wrapping}if("repeat"in n||"offset"in n){let i="mat",a=A.uniforms[`f${A.id}_${i}`];"repeat"in n&&(a.repeat=n.repeat),"offset"in n&&(a.offset=n.offset),a.updateMatrix()}return r}function gm(o,e,A,t){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(rc(n,A,t)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=t.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof Nr))switch(r=r||bw(A,n,i),a.constructor){case OA:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof Tr?a.value=new re(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case At:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof Tr?a.value=new re(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case ce:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case me:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case De:{tc(i,e,A);break}case ct:{a.value=i.map(l=>new hm.Vector4(...l));break}default:{a.value=i;break}}}return r}var oc=class extends lA{constructor(A,t,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,t){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(oc.Nodes.matcap);A.require("normal"),A.requires.normal=!0;let n=[];return n.push(this.texture.generate(A,"t")),n.push("normal"),n.push(this.alpha.build(A,"f")),n.push(this.mode.build(A,"i")),n.push(this.calpha),A.format(r+"("+n.join(",")+")",this.getType(A),t)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),t)}},gi=oc;gi.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
|
|
1086
|
+
`)}return t}};var KA=require("three");function fm(o,e){switch(o.type){case"fresnel":return dw(o,e);case"gradient":return pw(o);case"depth":return fw(o);case"normal":return mw(o);case"noise":return hw(o,e);case"rainbow":return gw(o);case"toon":return yw(o,e);case"outline":return xw(o,e);case"transmission":return vw(o,e);case"color":return uw(o,e)}}function cw(o){return{type:o.type}}function Et(o){let{alpha:e,mode:A}=o;return{...cw(o),alpha:e,mode:A}}function uw(o,e){return{...Et(o),color:ae(o.color,e)}}function dw(o,e){let{bias:A,scale:t,intensity:r,factor:n,color:i}=o;return{...Et(o),color:ae(i,e),bias:A,scale:t,intensity:r,factor:n}}function pw(o){let{gradientType:e,smooth:A,colors:t,steps:r,angle:n,offset:i,morph:a}=o;return{...Et(o),gradientType:e,smooth:A,colors:t.map(l=>new KA.Vector4(l[0],l[1],l[2],l[3])),num:t.length,steps:r,offset:new KA.Vector2(...i),morph:new KA.Vector2(...a),angle:n}}function fw(o){let{gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:u,smooth:s}=o;return{...Et(o),gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:new KA.Vector3(...i),direction:a?new KA.Vector3(...a):new KA.Vector3(1,0,0),colors:l.map(c=>c!==void 0?new KA.Vector4(c[0],c[1],c[2],c[3]):new KA.Vector4(0,0,0,0)),steps:u.slice(0,l.length),smooth:s}}function mw(o){let{cnormal:e}=o;return{...Et(o),cnormal:new KA.Vector3(e[0],e[1],e[2])}}function hw(o,e){return{...Et(o),scale:o.scale,move:o.move,fA:new KA.Vector2(...o.fA),fB:new KA.Vector2(...o.fB),size:new KA.Vector3(...o.size),distortion:new KA.Vector2(...o.distortion),colorA:ae(o.colorA,e),colorB:ae(o.colorB,e),colorC:ae(o.colorC,e),colorD:ae(o.colorD,e),noiseType:o.noiseType}}function gw(o){return{...Et(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new KA.Vector3(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new KA.Vector3(...o.offset)}}function yw(o,e){return{...Et(o),positioning:o.positioning,colors:o.colors.map(A=>new KA.Vector4(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new KA.Vector3(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:ae(o.shadowColor,e),offset:new KA.Vector3(...o.offset)}}function xw(o,e){return{...Et(o),outlineColor:ae(o.outlineColor,e),contourColor:ae(o.contourColor,e),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:o.contourDirection,positionalLines:o.positionalLines,compensation:o.compensation}}function vw(o,e){return{...Et(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var Tr=class extends re{};var hm=require("three");var da=require("three");var ua=class{constructor(e=1e3*10){this.timeout=e;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...e){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),A=this.head.next;for(;A.time<e-this.timeout;)this.dispose(A.src,A.data),this.cache.delete(A.src),A=A.next,A.prev=this.head,this.head.next=A;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}load(e){let A=Date.now(),t=this.cache.get(e);return t===void 0?(t={data:this.create(e),src:e,time:A,next:null,prev:null},this.cache.set(e,t)):(t.time=A,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var $l=class extends ua{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,A){URL.revokeObjectURL(A)}},_l;function mm(o){return typeof o=="string"?o:(_l||(_l=new $l),_l.load(o))}var Qr=class{constructor(e,A){this.data=e;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.dispose(),this.loaded=!1;let A=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let n of r){let i=this[n];i&&(i.image=this.img,i.needsUpdate=!0)}this.onImageLoad&&this.onImageLoad()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,this.img.autoplay=!0,this.img.muted=!0,this.img.pause(),typeof e!="string"){var t=new FileReader;t.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{t.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=A}else this.img=new Image,this.img.src=mm(e),this.img.onload=A}getTexture(e){let A=this[e];if(A)return A;{let t;return this.isVideo?t=new da.VideoTexture(this.img,void 0,e,e):t=new da.Texture(this.img,void 0,e,e),this.loaded&&(t.needsUpdate=!0),this[e]=t,t}}dispose(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}};1e3,1001,1002;var Dt=class extends Qr{};var Nr=class extends GA{};var Ac={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},ec={depth:["colors"]};function bw(o,e,A){let t=Ac[o.type],r=ec[o.type];if(r!==void 0){let n=o.color;if(r.includes(e)){let i=n[e]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return t!==void 0?t.includes(e):!1}function tc(o,e,A){let t=A.uniforms[`f${A.id}_texture`];if(!t)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=e.image(i),l=t;l instanceof Dt||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=e.video(i),l=t;l instanceof Dt||l.image.dispose(),l.image=a}if("wrapping"in n){let i=t;i.wrap=n.wrapping}if("repeat"in n||"offset"in n){let i="mat",a=A.uniforms[`f${A.id}_${i}`];"repeat"in n&&(a.repeat=n.repeat),"offset"in n&&(a.offset=n.offset),a.updateMatrix()}return r}function gm(o,e,A,t){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(rc(n,A,t)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=t.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof Nr))switch(r=r||bw(A,n,i),a.constructor){case OA:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof Tr?a.value=new re(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case At:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof Tr?a.value=new re(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case ce:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case me:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case De:{tc(i,e,A);break}case ct:{a.value=i.map(l=>new hm.Vector4(...l));break}default:{a.value=i;break}}}return r}var oc=class extends lA{constructor(A,t,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,t){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(oc.Nodes.matcap);A.require("normal"),A.requires.normal=!0;let n=[];return n.push(this.texture.generate(A,"t")),n.push("normal"),n.push(this.alpha.build(A,"f")),n.push(this.mode.build(A,"i")),n.push(this.calpha),A.format(r+"("+n.join(",")+")",this.getType(A),t)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),t)}},gi=oc;gi.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
|
|
1087
1087
|
vec3 viewDir = normalize( vViewPosition );
|
|
1088
1088
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
1089
1089
|
vec3 y = cross( viewDir, x );
|
package/build/SplineLoader.js
CHANGED
|
@@ -1083,7 +1083,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
1083
1083
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
1084
1084
|
}
|
|
1085
1085
|
`),u&&c.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),s?c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${s.result} );`):c.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=c.join(`
|
|
1086
|
-
`)}return t}};import{Vector2 as Jn,Vector3 as jt,Vector4 as Ws}from"three";function vm(o,e){switch(o.type){case"fresnel":return QS(o,e);case"gradient":return YS(o);case"depth":return XS(o);case"normal":return KS(o);case"noise":return ZS(o,e);case"rainbow":return JS(o);case"toon":return _S(o,e);case"outline":return $S(o,e);case"transmission":return AT(o,e);case"color":return qS(o,e)}}function WS(o){return{type:o.type}}function xt(o){let{alpha:e,mode:A}=o;return{...WS(o),alpha:e,mode:A}}function qS(o,e){return{...xt(o),color:KA(o.color,e)}}function QS(o,e){let{bias:A,scale:t,intensity:r,factor:n,color:i}=o;return{...xt(o),color:KA(i,e),bias:A,scale:t,intensity:r,factor:n}}function YS(o){let{gradientType:e,smooth:A,colors:t,steps:r,angle:n,offset:i,morph:a}=o;return{...xt(o),gradientType:e,smooth:A,colors:t.map(l=>new Ws(l[0],l[1],l[2],l[3])),num:t.length,steps:r,offset:new Jn(...i),morph:new Jn(...a),angle:n}}function XS(o){let{gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:u,smooth:s}=o;return{...xt(o),gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:new jt(...i),direction:a?new jt(...a):new jt(1,0,0),colors:l.map(c=>c!==void 0?new Ws(c[0],c[1],c[2],c[3]):new Ws(0,0,0,0)),steps:u.slice(0,l.length),smooth:s}}function KS(o){let{cnormal:e}=o;return{...xt(o),cnormal:new jt(e[0],e[1],e[2])}}function ZS(o,e){return{...xt(o),scale:o.scale,move:o.move,fA:new Jn(...o.fA),fB:new Jn(...o.fB),size:new jt(...o.size),distortion:new Jn(...o.distortion),colorA:KA(o.colorA,e),colorB:KA(o.colorB,e),colorC:KA(o.colorC,e),colorD:KA(o.colorD,e),noiseType:o.noiseType}}function JS(o){return{...xt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new jt(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new jt(...o.offset)}}function _S(o,e){return{...xt(o),positioning:o.positioning,colors:o.colors.map(A=>new Ws(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new jt(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:KA(o.shadowColor,e),offset:new jt(...o.offset)}}function $S(o,e){return{...xt(o),outlineColor:KA(o.outlineColor,e),contourColor:KA(o.contourColor,e),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:o.contourDirection,positionalLines:o.positionalLines,compensation:o.compensation}}function AT(o,e){return{...xt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var cr=class extends qA{};import{Vector4 as rT}from"three";import{VideoTexture as eT,Texture as tT}from"three";var qs=class{constructor(e=1e3*10){this.timeout=e;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...e){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),A=this.head.next;for(;A.time<e-this.timeout;)this.dispose(A.src,A.data),this.cache.delete(A.src),A=A.next,A.prev=this.head,this.head.next=A;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}load(e){let A=Date.now(),t=this.cache.get(e);return t===void 0?(t={data:this.create(e),src:e,time:A,next:null,prev:null},this.cache.set(e,t)):(t.time=A,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Xl=class extends qs{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,A){URL.revokeObjectURL(A)}},Yl;function bm(o){return typeof o=="string"?o:(Yl||(Yl=new Xl),Yl.load(o))}var Or=class{constructor(e,A){this.data=e;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.dispose(),this.loaded=!1;let A=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let n of r){let i=this[n];i&&(i.image=this.img,i.needsUpdate=!0)}this.onImageLoad&&this.onImageLoad()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,this.img.muted=!0,this.img.pause(),typeof e!="string"){var t=new FileReader;t.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{t.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=A}else this.img=new Image,this.img.src=bm(e),this.img.onload=A}getTexture(e){let A=this[e];if(A)return A;{let t;return this.isVideo?t=new eT(this.img,void 0,e,e):t=new tT(this.img,void 0,e,e),this.loaded&&(t.needsUpdate=!0),this[e]=t,t}}dispose(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}};1e3,1001,1002;var vt=class extends Or{};var ur=class extends LA{};var Kl={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},Zl={depth:["colors"]};function oT(o,e,A){let t=Kl[o.type],r=Zl[o.type];if(r!==void 0){let n=o.color;if(r.includes(e)){let i=n[e]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return t!==void 0?t.includes(e):!1}function Jl(o,e,A){let t=A.uniforms[`f${A.id}_texture`];if(!t)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=e.image(i),l=t;l instanceof vt||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=e.video(i),l=t;l instanceof vt||l.image.dispose(),l.image=a}if("wrapping"in n){let i=t;i.wrap=n.wrapping}if("repeat"in n||"offset"in n){let i="mat",a=A.uniforms[`f${A.id}_${i}`];"repeat"in n&&(a.repeat=n.repeat),"offset"in n&&(a.offset=n.offset),a.updateMatrix()}return r}function wm(o,e,A,t){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(_l(n,A,t)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=t.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof ur))switch(r=r||oT(A,n,i),a.constructor){case TA:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof cr?a.value=new qA(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case ze:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof cr?a.value=new qA(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case _A:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case te:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case ve:{Jl(i,e,A);break}case Ze:{a.value=i.map(l=>new rT(...l));break}default:{a.value=i;break}}}return r}var $l=class extends aA{constructor(A,t,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,t){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include($l.Nodes.matcap);A.require("normal"),A.requires.normal=!0;let n=[];return n.push(this.texture.generate(A,"t")),n.push("normal"),n.push(this.alpha.build(A,"f")),n.push(this.mode.build(A,"i")),n.push(this.calpha),A.format(r+"("+n.join(",")+")",this.getType(A),t)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),t)}},_n=$l;_n.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
|
|
1086
|
+
`)}return t}};import{Vector2 as Jn,Vector3 as jt,Vector4 as Ws}from"three";function vm(o,e){switch(o.type){case"fresnel":return QS(o,e);case"gradient":return YS(o);case"depth":return XS(o);case"normal":return KS(o);case"noise":return ZS(o,e);case"rainbow":return JS(o);case"toon":return _S(o,e);case"outline":return $S(o,e);case"transmission":return AT(o,e);case"color":return qS(o,e)}}function WS(o){return{type:o.type}}function xt(o){let{alpha:e,mode:A}=o;return{...WS(o),alpha:e,mode:A}}function qS(o,e){return{...xt(o),color:KA(o.color,e)}}function QS(o,e){let{bias:A,scale:t,intensity:r,factor:n,color:i}=o;return{...xt(o),color:KA(i,e),bias:A,scale:t,intensity:r,factor:n}}function YS(o){let{gradientType:e,smooth:A,colors:t,steps:r,angle:n,offset:i,morph:a}=o;return{...xt(o),gradientType:e,smooth:A,colors:t.map(l=>new Ws(l[0],l[1],l[2],l[3])),num:t.length,steps:r,offset:new Jn(...i),morph:new Jn(...a),angle:n}}function XS(o){let{gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:u,smooth:s}=o;return{...xt(o),gradientType:e,near:A,far:t,isVector:r,isWorldSpace:n,origin:new jt(...i),direction:a?new jt(...a):new jt(1,0,0),colors:l.map(c=>c!==void 0?new Ws(c[0],c[1],c[2],c[3]):new Ws(0,0,0,0)),steps:u.slice(0,l.length),smooth:s}}function KS(o){let{cnormal:e}=o;return{...xt(o),cnormal:new jt(e[0],e[1],e[2])}}function ZS(o,e){return{...xt(o),scale:o.scale,move:o.move,fA:new Jn(...o.fA),fB:new Jn(...o.fB),size:new jt(...o.size),distortion:new Jn(...o.distortion),colorA:KA(o.colorA,e),colorB:KA(o.colorB,e),colorC:KA(o.colorC,e),colorD:KA(o.colorD,e),noiseType:o.noiseType}}function JS(o){return{...xt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new jt(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new jt(...o.offset)}}function _S(o,e){return{...xt(o),positioning:o.positioning,colors:o.colors.map(A=>new Ws(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new jt(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:KA(o.shadowColor,e),offset:new jt(...o.offset)}}function $S(o,e){return{...xt(o),outlineColor:KA(o.outlineColor,e),contourColor:KA(o.contourColor,e),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:o.contourDirection,positionalLines:o.positionalLines,compensation:o.compensation}}function AT(o,e){return{...xt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var cr=class extends qA{};import{Vector4 as rT}from"three";import{VideoTexture as eT,Texture as tT}from"three";var qs=class{constructor(e=1e3*10){this.timeout=e;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...e){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),A=this.head.next;for(;A.time<e-this.timeout;)this.dispose(A.src,A.data),this.cache.delete(A.src),A=A.next,A.prev=this.head,this.head.next=A;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}load(e){let A=Date.now(),t=this.cache.get(e);return t===void 0?(t={data:this.create(e),src:e,time:A,next:null,prev:null},this.cache.set(e,t)):(t.time=A,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Xl=class extends qs{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,A){URL.revokeObjectURL(A)}},Yl;function bm(o){return typeof o=="string"?o:(Yl||(Yl=new Xl),Yl.load(o))}var Or=class{constructor(e,A){this.data=e;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.dispose(),this.loaded=!1;let A=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let n of r){let i=this[n];i&&(i.image=this.img,i.needsUpdate=!0)}this.onImageLoad&&this.onImageLoad()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,this.img.autoplay=!0,this.img.muted=!0,this.img.pause(),typeof e!="string"){var t=new FileReader;t.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{t.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=A}else this.img=new Image,this.img.src=bm(e),this.img.onload=A}getTexture(e){let A=this[e];if(A)return A;{let t;return this.isVideo?t=new eT(this.img,void 0,e,e):t=new tT(this.img,void 0,e,e),this.loaded&&(t.needsUpdate=!0),this[e]=t,t}}dispose(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}};1e3,1001,1002;var vt=class extends Or{};var ur=class extends LA{};var Kl={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},Zl={depth:["colors"]};function oT(o,e,A){let t=Kl[o.type],r=Zl[o.type];if(r!==void 0){let n=o.color;if(r.includes(e)){let i=n[e]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return t!==void 0?t.includes(e):!1}function Jl(o,e,A){let t=A.uniforms[`f${A.id}_texture`];if(!t)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=e.image(i),l=t;l instanceof vt||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=e.video(i),l=t;l instanceof vt||l.image.dispose(),l.image=a}if("wrapping"in n){let i=t;i.wrap=n.wrapping}if("repeat"in n||"offset"in n){let i="mat",a=A.uniforms[`f${A.id}_${i}`];"repeat"in n&&(a.repeat=n.repeat),"offset"in n&&(a.offset=n.offset),a.updateMatrix()}return r}function wm(o,e,A,t){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(_l(n,A,t)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=t.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof ur))switch(r=r||oT(A,n,i),a.constructor){case TA:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof cr?a.value=new qA(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case ze:if(typeof i=="string"){let l=e.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof cr?a.value=new qA(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case _A:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case te:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case ve:{Jl(i,e,A);break}case Ze:{a.value=i.map(l=>new rT(...l));break}default:{a.value=i;break}}}return r}var $l=class extends aA{constructor(A,t,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,t){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include($l.Nodes.matcap);A.require("normal"),A.requires.normal=!0;let n=[];return n.push(this.texture.generate(A,"t")),n.push("normal"),n.push(this.alpha.build(A,"f")),n.push(this.mode.build(A,"i")),n.push(this.calpha),A.format(r+"("+n.join(",")+")",this.getType(A),t)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),t)}},_n=$l;_n.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
|
|
1087
1087
|
vec3 viewDir = normalize( vViewPosition );
|
|
1088
1088
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
1089
1089
|
vec3 y = cross( viewDir, x );
|