@splinetool/loader 0.9.165 → 0.9.166

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.
@@ -1083,7 +1083,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1083
1083
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1084
1084
 
1085
1085
  return normal;
1086
- }`)}}();var _A=require("three");function Oe(o,t){return t.color(o)}function bm(o,t){switch(o.type){case"fresnel":return Zw(o,t);case"gradient":return Jw(o);case"depth":return _w(o);case"normal":return $w(o);case"noise":return A1(o,t);case"rainbow":return e1(o);case"toon":return t1(o,t);case"outline":return r1(o,t);case"transmission":return o1(o,t);case"color":return Kw(o,t)}}function Xw(o){return{type:o.type}}function Mt(o){let{alpha:t,mode:A}=o;return{...Xw(o),alpha:t,mode:A}}function Kw(o,t){return{...Mt(o),color:Oe(o.color,t)}}function Zw(o,t){let{bias:A,scale:e,intensity:r,factor:n,color:i}=o;return{...Mt(o),color:Oe(i,t),bias:A,scale:e,intensity:r,factor:n}}function Jw(o){let{gradientType:t,smooth:A,colors:e,steps:r,angle:n,offset:i,morph:a}=o;return{...Mt(o),gradientType:t,smooth:A,colors:e.map(l=>new _A.Vector4(l[0],l[1],l[2],l[3])),num:e.length,steps:r,offset:new _A.Vector2(...i),morph:new _A.Vector2(...a),angle:n}}function _w(o){let{gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:d,smooth:s}=o;return{...Mt(o),gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:new _A.Vector3(...i),direction:a?new _A.Vector3(...a):new _A.Vector3(1,0,0),colors:l.map(c=>c!==void 0?new _A.Vector4(c[0],c[1],c[2],c[3]):new _A.Vector4(0,0,0,0)),steps:d.slice(0,l.length),smooth:s}}function $w(o){let{cnormal:t}=o;return{...Mt(o),cnormal:new _A.Vector3(t[0],t[1],t[2])}}function A1(o,t){return{...Mt(o),scale:o.scale,move:o.move,fA:new _A.Vector2(...o.fA),fB:new _A.Vector2(...o.fB),size:new _A.Vector3(...o.size),distortion:new _A.Vector2(...o.distortion),colorA:Oe(o.colorA,t),colorB:Oe(o.colorB,t),colorC:Oe(o.colorC,t),colorD:Oe(o.colorD,t),noiseType:o.noiseType}}function e1(o){return{...Mt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new _A.Vector3(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new _A.Vector3(...o.offset)}}function t1(o,t){return{...Mt(o),positioning:o.positioning,colors:o.colors.map(A=>new _A.Vector4(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new _A.Vector3(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:Oe(o.shadowColor,t),offset:new _A.Vector3(...o.offset)}}function r1(o,t){return{...Mt(o),outlineColor:Oe(o.outlineColor,t),contourColor:Oe(o.contourColor,t),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 o1(o,t){return{...Mt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var xr=class extends oe{};var wm=require("three");var ha=require("three");var ma=class{constructor(t=1e3*10){this.timeout=t;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(...t){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),A=this.head.next;for(;A.time<t-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(t){let A=Date.now(),e=this.cache.get(t);return e===void 0?(e={data:this.create(t),src:t,time:A,next:null,prev:null},this.cache.set(t,e)):(e.time=A,e.prev.next=e.next,e.next.prev=e.prev),e.prev=this.tail.prev,e.next=this.tail,this.tail.prev.next=e,this.tail.prev=e,this.scheduleCleanup(),e.data}};var nc=class extends ma{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,A){URL.revokeObjectURL(A)}},oc;function Sm(o){return typeof o=="string"?o:(oc||(oc=new nc),oc.load(o))}var Wr=class{constructor(t,A){this.data=t;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=t.type=="video",this.updateSrc(t.data)}async updateSrc(t){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,typeof t!="string"){var e=new FileReader;e.readAsDataURL(new Blob([t],{type:"video/mp4"}));let r;await new Promise(n=>{e.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{A()}}else this.img=new Image,this.img.src=Sm(t),this.img.onload=A}getTexture(t){let A=this[t];if(A)return A;{let e;return this.isVideo?e=new ha.VideoTexture(this.img,void 0,t,t):e=new ha.Texture(this.img,void 0,t,t),this.loaded&&(e.needsUpdate=!0),this[t]=e,e}}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 $e=class extends Wr{};var vr=class extends RA{};var ic={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},sc={depth:["colors"]};function n1(o,t,A){let e=ic[o.type],r=sc[o.type];if(r!==void 0){let n=o.color;if(r.includes(t)){let i=n[t]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return e!==void 0?e.includes(t):!1}function ac(o,t,A){let e=A.uniforms[`f${A.id}_texture`];if(!e)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=t.image(i),l=e;l instanceof $e||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=t.video(i),l=e;l instanceof $e||l.image.dispose(),l.image=a}if("wrapping"in n){let i=e;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 Tm(o,t,A,e){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(lc(n,A,e)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=e.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof vr))switch(r=r||n1(A,n,i),a.constructor){case IA:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof xr?a.value=new oe(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case _e:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof xr?a.value=new oe(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case ue:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case ye:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Re:{ac(i,t,A);break}case mt:{a.value=i.map(l=>new wm.Vector4(...l));break}default:{a.value=i;break}}}return r}var cc=class extends lA{constructor(A,e,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=e,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,e){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(cc.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),e)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),e)}},Si=cc;Si.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
1086
+ }`)}}();var _A=require("three");function Oe(o,t){return t.color(o)}function bm(o,t){switch(o.type){case"fresnel":return Zw(o,t);case"gradient":return Jw(o);case"depth":return _w(o);case"normal":return $w(o);case"noise":return A1(o,t);case"rainbow":return e1(o);case"toon":return t1(o,t);case"outline":return r1(o,t);case"transmission":return o1(o,t);case"color":return Kw(o,t)}}function Xw(o){return{type:o.type}}function Mt(o){let{alpha:t,mode:A}=o;return{...Xw(o),alpha:t,mode:A}}function Kw(o,t){return{...Mt(o),color:Oe(o.color,t)}}function Zw(o,t){let{bias:A,scale:e,intensity:r,factor:n,color:i}=o;return{...Mt(o),color:Oe(i,t),bias:A,scale:e,intensity:r,factor:n}}function Jw(o){let{gradientType:t,smooth:A,colors:e,steps:r,angle:n,offset:i,morph:a}=o;return{...Mt(o),gradientType:t,smooth:A,colors:e.map(l=>new _A.Vector4(l[0],l[1],l[2],l[3])),num:e.length,steps:r,offset:new _A.Vector2(...i),morph:new _A.Vector2(...a),angle:n}}function _w(o){let{gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:d,smooth:s}=o;return{...Mt(o),gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:new _A.Vector3(...i),direction:a?new _A.Vector3(...a):new _A.Vector3(1,0,0),colors:l.map(c=>c!==void 0?new _A.Vector4(c[0],c[1],c[2],c[3]):new _A.Vector4(0,0,0,0)),steps:d.slice(0,l.length),smooth:s}}function $w(o){let{cnormal:t}=o;return{...Mt(o),cnormal:new _A.Vector3(t[0],t[1],t[2])}}function A1(o,t){return{...Mt(o),scale:o.scale,move:o.move,fA:new _A.Vector2(...o.fA),fB:new _A.Vector2(...o.fB),size:new _A.Vector3(...o.size),distortion:new _A.Vector2(...o.distortion),colorA:Oe(o.colorA,t),colorB:Oe(o.colorB,t),colorC:Oe(o.colorC,t),colorD:Oe(o.colorD,t),noiseType:o.noiseType}}function e1(o){return{...Mt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new _A.Vector3(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new _A.Vector3(...o.offset)}}function t1(o,t){return{...Mt(o),positioning:o.positioning,colors:o.colors.map(A=>new _A.Vector4(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new _A.Vector3(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:Oe(o.shadowColor,t),offset:new _A.Vector3(...o.offset)}}function r1(o,t){return{...Mt(o),outlineColor:Oe(o.outlineColor,t),contourColor:Oe(o.contourColor,t),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 o1(o,t){return{...Mt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var xr=class extends oe{};var wm=require("three");var ha=require("three");var ma=class{constructor(t=1e3*10){this.timeout=t;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(...t){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),A=this.head.next;for(;A.time<t-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(t){let A=Date.now(),e=this.cache.get(t);return e===void 0?(e={data:this.create(t),src:t,time:A,next:null,prev:null},this.cache.set(t,e)):(e.time=A,e.prev.next=e.next,e.next.prev=e.prev),e.prev=this.tail.prev,e.next=this.tail,this.tail.prev.next=e,this.tail.prev=e,this.scheduleCleanup(),e.data}};var nc=class extends ma{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,A){URL.revokeObjectURL(A)}},oc;function Sm(o){return typeof o=="string"?o:(oc||(oc=new nc),oc.load(o))}var Wr=class{constructor(t,A){this.data=t;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=t.type=="video",this.updateSrc(t.data)}async updateSrc(t){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,typeof t!="string"){var e=new FileReader;e.readAsDataURL(new Blob([t],{type:"video/mp4"}));let r;await new Promise(n=>{e.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{A()}}else this.img=new Image,this.img.src=Sm(t),this.img.onload=A}getTexture(t){let A=this[t];if(A)return A;{let e;return this.isVideo?e=new ha.VideoTexture(this.img,void 0,t,t):e=new ha.Texture(this.img,void 0,t,t),this.loaded&&(e.needsUpdate=!0),this[t]=e,e}}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 $e=class extends Wr{};var vr=class extends RA{};var ic={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},sc={depth:["colors"]};function n1(o,t,A){let e=ic[o.type],r=sc[o.type];if(r!==void 0){let n=o.color;if(r.includes(t)){let i=n[t]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return e!==void 0?e.includes(t):!1}function ac(o,t,A){let e=A.uniforms[`f${A.id}_texture`];if(!e)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=t.image(i),l=e;l instanceof $e||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=t.video(i),l=e;l instanceof $e||l.image.dispose(),l.image=a}if("wrapping"in n){let i=e;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 Tm(o,t,A,e){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(lc(n,A,e)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=e.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof vr))switch(r=r||n1(A,n,i),a.constructor){case IA:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof xr?a.value=new oe(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case _e:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof xr?a.value=new oe(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case ue:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case ye:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Re:{ac(i,t,A);break}case mt:{a.value=i.map(l=>new wm.Vector4(...l));break}default:{a.value=i;break}}}return r}var cc=class extends lA{constructor(A,e,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=e,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,e){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(cc.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),e)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),e)}},Si=cc;Si.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 );
@@ -1083,7 +1083,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1083
1083
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1084
1084
 
1085
1085
  return normal;
1086
- }`)}}();import{Vector2 as ri,Vector3 as Rt,Vector4 as Ks}from"three";function pe(o,t){return t.color(o)}function Tm(o,t){switch(o.type){case"fresnel":return hT(o,t);case"gradient":return yT(o);case"depth":return gT(o);case"normal":return xT(o);case"noise":return vT(o,t);case"rainbow":return bT(o);case"toon":return ST(o,t);case"outline":return wT(o,t);case"transmission":return TT(o,t);case"color":return mT(o,t)}}function fT(o){return{type:o.type}}function gt(o){let{alpha:t,mode:A}=o;return{...fT(o),alpha:t,mode:A}}function mT(o,t){return{...gt(o),color:pe(o.color,t)}}function hT(o,t){let{bias:A,scale:e,intensity:r,factor:n,color:i}=o;return{...gt(o),color:pe(i,t),bias:A,scale:e,intensity:r,factor:n}}function yT(o){let{gradientType:t,smooth:A,colors:e,steps:r,angle:n,offset:i,morph:a}=o;return{...gt(o),gradientType:t,smooth:A,colors:e.map(l=>new Ks(l[0],l[1],l[2],l[3])),num:e.length,steps:r,offset:new ri(...i),morph:new ri(...a),angle:n}}function gT(o){let{gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:d,smooth:s}=o;return{...gt(o),gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:new Rt(...i),direction:a?new Rt(...a):new Rt(1,0,0),colors:l.map(c=>c!==void 0?new Ks(c[0],c[1],c[2],c[3]):new Ks(0,0,0,0)),steps:d.slice(0,l.length),smooth:s}}function xT(o){let{cnormal:t}=o;return{...gt(o),cnormal:new Rt(t[0],t[1],t[2])}}function vT(o,t){return{...gt(o),scale:o.scale,move:o.move,fA:new ri(...o.fA),fB:new ri(...o.fB),size:new Rt(...o.size),distortion:new ri(...o.distortion),colorA:pe(o.colorA,t),colorB:pe(o.colorB,t),colorC:pe(o.colorC,t),colorD:pe(o.colorD,t),noiseType:o.noiseType}}function bT(o){return{...gt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new Rt(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new Rt(...o.offset)}}function ST(o,t){return{...gt(o),positioning:o.positioning,colors:o.colors.map(A=>new Ks(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new Rt(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:pe(o.shadowColor,t),offset:new Rt(...o.offset)}}function wT(o,t){return{...gt(o),outlineColor:pe(o.outlineColor,t),contourColor:pe(o.contourColor,t),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 TT(o,t){return{...gt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var ir=class extends QA{};import{Vector4 as NT}from"three";import{VideoTexture as OT,Texture as PT}from"three";var Zs=class{constructor(t=1e3*10){this.timeout=t;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(...t){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),A=this.head.next;for(;A.time<t-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(t){let A=Date.now(),e=this.cache.get(t);return e===void 0?(e={data:this.create(t),src:t,time:A,next:null,prev:null},this.cache.set(t,e)):(e.time=A,e.prev.next=e.next,e.next.prev=e.prev),e.prev=this.tail.prev,e.next=this.tail,this.tail.prev.next=e,this.tail.prev=e,this.scheduleCleanup(),e.data}};var Ac=class extends Zs{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,A){URL.revokeObjectURL(A)}},$l;function Om(o){return typeof o=="string"?o:($l||($l=new Ac),$l.load(o))}var Ir=class{constructor(t,A){this.data=t;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=t.type=="video",this.updateSrc(t.data)}async updateSrc(t){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,typeof t!="string"){var e=new FileReader;e.readAsDataURL(new Blob([t],{type:"video/mp4"}));let r;await new Promise(n=>{e.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{A()}}else this.img=new Image,this.img.src=Om(t),this.img.onload=A}getTexture(t){let A=this[t];if(A)return A;{let e;return this.isVideo?e=new OT(this.img,void 0,t,t):e=new PT(this.img,void 0,t,t),this.loaded&&(e.needsUpdate=!0),this[t]=e,e}}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 ze=class extends Ir{};var sr=class extends LA{};var ec={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},tc={depth:["colors"]};function IT(o,t,A){let e=ec[o.type],r=tc[o.type];if(r!==void 0){let n=o.color;if(r.includes(t)){let i=n[t]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return e!==void 0?e.includes(t):!1}function rc(o,t,A){let e=A.uniforms[`f${A.id}_texture`];if(!e)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=t.image(i),l=e;l instanceof ze||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=t.video(i),l=e;l instanceof ze||l.image.dispose(),l.image=a}if("wrapping"in n){let i=e;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 Pm(o,t,A,e){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(oc(n,A,e)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=e.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof sr))switch(r=r||IT(A,n,i),a.constructor){case TA:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof ir?a.value=new QA(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case je:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof ir?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 Ae:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case ne:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Se:{rc(i,t,A);break}case At:{a.value=i.map(l=>new NT(...l));break}default:{a.value=i;break}}}return r}var nc=class extends aA{constructor(A,e,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=e,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,e){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(nc.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),e)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),e)}},oi=nc;oi.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
1086
+ }`)}}();import{Vector2 as ri,Vector3 as Rt,Vector4 as Ks}from"three";function pe(o,t){return t.color(o)}function Tm(o,t){switch(o.type){case"fresnel":return hT(o,t);case"gradient":return yT(o);case"depth":return gT(o);case"normal":return xT(o);case"noise":return vT(o,t);case"rainbow":return bT(o);case"toon":return ST(o,t);case"outline":return wT(o,t);case"transmission":return TT(o,t);case"color":return mT(o,t)}}function fT(o){return{type:o.type}}function gt(o){let{alpha:t,mode:A}=o;return{...fT(o),alpha:t,mode:A}}function mT(o,t){return{...gt(o),color:pe(o.color,t)}}function hT(o,t){let{bias:A,scale:e,intensity:r,factor:n,color:i}=o;return{...gt(o),color:pe(i,t),bias:A,scale:e,intensity:r,factor:n}}function yT(o){let{gradientType:t,smooth:A,colors:e,steps:r,angle:n,offset:i,morph:a}=o;return{...gt(o),gradientType:t,smooth:A,colors:e.map(l=>new Ks(l[0],l[1],l[2],l[3])),num:e.length,steps:r,offset:new ri(...i),morph:new ri(...a),angle:n}}function gT(o){let{gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:i,direction:a,colors:l,steps:d,smooth:s}=o;return{...gt(o),gradientType:t,near:A,far:e,isVector:r,isWorldSpace:n,origin:new Rt(...i),direction:a?new Rt(...a):new Rt(1,0,0),colors:l.map(c=>c!==void 0?new Ks(c[0],c[1],c[2],c[3]):new Ks(0,0,0,0)),steps:d.slice(0,l.length),smooth:s}}function xT(o){let{cnormal:t}=o;return{...gt(o),cnormal:new Rt(t[0],t[1],t[2])}}function vT(o,t){return{...gt(o),scale:o.scale,move:o.move,fA:new ri(...o.fA),fB:new ri(...o.fB),size:new Rt(...o.size),distortion:new ri(...o.distortion),colorA:pe(o.colorA,t),colorB:pe(o.colorB,t),colorC:pe(o.colorC,t),colorD:pe(o.colorD,t),noiseType:o.noiseType}}function bT(o){return{...gt(o),filmThickness:o.filmThickness,movement:o.movement,wavelengths:new Rt(...o.wavelengths),noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,offset:new Rt(...o.offset)}}function ST(o,t){return{...gt(o),positioning:o.positioning,colors:o.colors.map(A=>new Ks(A[0],A[1],A[2],A[3])),num:o.colors.length,steps:o.steps,source:new Rt(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:pe(o.shadowColor,t),offset:new Rt(...o.offset)}}function wT(o,t){return{...gt(o),outlineColor:pe(o.outlineColor,t),contourColor:pe(o.contourColor,t),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 TT(o,t){return{...gt(o),thickness:o.thickness,ior:o.ior,roughness:o.roughness}}var ir=class extends QA{};import{Vector4 as NT}from"three";import{VideoTexture as OT,Texture as PT}from"three";var Zs=class{constructor(t=1e3*10){this.timeout=t;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(...t){}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),A=this.head.next;for(;A.time<t-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(t){let A=Date.now(),e=this.cache.get(t);return e===void 0?(e={data:this.create(t),src:t,time:A,next:null,prev:null},this.cache.set(t,e)):(e.time=A,e.prev.next=e.next,e.next.prev=e.prev),e.prev=this.tail.prev,e.next=this.tail,this.tail.prev.next=e,this.tail.prev=e,this.scheduleCleanup(),e.data}};var Ac=class extends Zs{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,A){URL.revokeObjectURL(A)}},$l;function Om(o){return typeof o=="string"?o:($l||($l=new Ac),$l.load(o))}var Ir=class{constructor(t,A){this.data=t;this.onImageLoad=A;this.loaded=!1;this.isVideo=!1;this.isVideo=t.type=="video",this.updateSrc(t.data)}async updateSrc(t){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,typeof t!="string"){var e=new FileReader;e.readAsDataURL(new Blob([t],{type:"video/mp4"}));let r;await new Promise(n=>{e.onloadend=i=>{r=i.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{A()}}else this.img=new Image,this.img.src=Om(t),this.img.onload=A}getTexture(t){let A=this[t];if(A)return A;{let e;return this.isVideo?e=new OT(this.img,void 0,t,t):e=new PT(this.img,void 0,t,t),this.loaded&&(e.needsUpdate=!0),this[t]=e,e}}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 ze=class extends Ir{};var sr=class extends LA{};var ec={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},tc={depth:["colors"]};function IT(o,t,A){let e=ec[o.type],r=tc[o.type];if(r!==void 0){let n=o.color;if(r.includes(t)){let i=n[t]?.value?.length;if(i!==void 0&&i!==A.length)return!0}}return e!==void 0?e.includes(t):!1}function rc(o,t,A){let e=A.uniforms[`f${A.id}_texture`];if(!e)return!1;let r=!1,n=o;if("image"in n){let i=n.image,a=t.image(i),l=e;l instanceof ze||l.image.dispose(),l.image=a}if("video"in n){let i=n.video,a=t.video(i),l=e;l instanceof ze||l.image.dispose(),l.image=a}if("wrapping"in n){let i=e;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 Pm(o,t,A,e){let r=!1;for(let[n,i]of Object.entries(o)){if(!n||i===void 0)continue;if(oc(n,A,e)){n==="visible"&&A.type==="light"&&(r=!0);continue}A.visible=e.visible;let a=A.uniforms[`f${A.id}_${n}`];if(!!a&&!(a instanceof sr))switch(r=r||IT(A,n,i),a.constructor){case TA:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof ir?a.value=new QA(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case je:if(typeof i=="string"){let l=t.getColor(i);l&&(a.value=l);break}else{let l=i;a.value instanceof ir?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 Ae:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]);break}case ne:{let l=i;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Se:{rc(i,t,A);break}case At:{a.value=i.map(l=>new NT(...l));break}default:{a.value=i;break}}}return r}var nc=class extends aA{constructor(A,e,r){super("v3");this.nodeType="Matcap";this.texture=A,this.alpha=e,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,e){if(A.isShader("fragment")){A.addFragmentVariable(this.calpha,"float");let r=A.include(nc.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),e)}else return console.warn("MatcapNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.getType(A),e)}},oi=nc;oi.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/loader",
3
- "version": "0.9.165",
3
+ "version": "0.9.166",
4
4
  "type": "module",
5
5
  "main": "./build/SplineLoader.js",
6
6
  "module": "./build/SplineLoader.js",