@splinetool/loader 1.11.6 → 1.11.9
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 +4 -4
- package/build/SplineLoader.js +4 -4
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -15,7 +15,7 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
|
|
|
15
15
|
}`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=Vl(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=Vl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:xI(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var fb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return fb(e,t)}return ji.isBoolean(i)?ji.getDisplayedValue(i).toLowerCase():ji.getDisplayedValue(i)},Vl=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
|
|
16
16
|
`:"")+Vl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return fb(o,t)}}return""}).join("");var PI=new Ne.Matrix4,OI=new Ne.Matrix4;function TI(i,t,e){let r=[new Ne.Vector3,new Ne.Vector3,new Ne.Vector3],o=[new Ne.Vector3,new Ne.Vector3,new Ne.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Ne.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ne.Matrix4().makeBasis(r[0],r[1],r[2])}var hb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Ja.create({parameters:tf}).userData.shape;return{path:i.path??La.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Pu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Xf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ne.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Xf=class extends Ne.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!db(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(r[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=TI(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new qi(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let N=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=N,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,N=I});let E=I*c,_,L=0;if(this._isOpenEnded()&&w==="flat"){try{_=po({windingRule:Xe.ODD,elementType:wt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Gf}L=_.vertexCount}let V=E+2*L+g*2,U=E+2*L,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,E,q,B,p[0],u[0],!1),this._closeEnd(_,E+L,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ne.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ne.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ne.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=PI;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(OI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ne.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ne.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ne.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=ku(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ne.Vector3,s=new Ne.Vector3,l=new Ne.Vector3,c=new Ne.Vector3,u=new Ne.Vector3(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new Ne.Matrix4().makeBasis(M,g,T);r.push(D)}let p=n?s:l,d=n?a:new Ne.Vector3(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return r;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let b=new Ne.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(b)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ne.Matrix4,p=new Ne.Matrix4;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ne.MathUtils.lerp(a,a+s,h)*Ne.MathUtils.DEG2RAD);let m=Ne.MathUtils.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,r=Xe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=po({windingRule:r,elementType:wt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=_l}let l;try{l=po({windingRule:Xe.ODD,elementType:wt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=zf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let N=T-v,I=s.vertices[M*2+0],E=s.vertices[M*2+1],_=s.vertices[T*2+0],L=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=L-E,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=L-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[N*2+0]=-H,S.normals[N*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[N]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[N]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[N]=Z.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Ne.Vector3,u=new Ne.Vector3,p=new Ne.Vector3,d=new Ne.Vector3,f=new Ne.Vector2;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ne.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Ne.Vector3,d=new Ne.Vector2;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,b=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,b,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ne.Matrix3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=r*m,b=o*m;y<b;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};var Ln=require("three"),mb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function yb(){let i=new Ln.BufferGeometry;return i.setAttribute("position",new Ln.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Ln.BufferAttribute(new Uint16Array([]),1)),i}var AI=yb().attributes,MI=12,II=1,Rn=class extends Ln.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,AI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=ji.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=NI(e,o,f,r),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new Ye().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>Pr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Xe.NONZERO:Xe.ODD,subdivisions:this.isLowResolution&&s>0?II:MI}})),T=S.length?(0,mb.mergeBufferGeometries)(S):yb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=jt(new Ln.BufferGeometry,Rn.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function NI(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
|
|
17
17
|
`?(n[n.length-1]+=a,a="",s===`
|
|
18
|
-
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var xb,nd=new Promise(i=>{xb=i}),gb=!1;var id;function bb(i){if(gb)return;if(id)return id;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.11.6/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});xb(c),gb=!0}return id=t(),id}var vb=require("three");var EI=["font"];function Vo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Zp(p)&&!EI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Zp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new vb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Rn(n,t);if(n.type==="InputGeometry")return new Rn(n,t);if(n.type==="UIGeometry")return rs.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Yf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(_a.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Yf(s)}return l}var Sb=require("three"),DI=new Sb.Matrix4;function zl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=DI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ad=new lt.Box3,is=new lt.Vector3,Oe;nd.then(i=>{Oe=i});var wb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Pb=new Uint32Array([0,1,2,3]),Ob=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ri.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&zl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&zl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(is.fromArray(n));let s=is.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ad.setFromBufferAttribute(r),ad.getCenter(o),e.boundingSphere.radius=o.distanceTo(ad.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ad.getSize(is);let n={width:is.x,height:is.y,depth:is.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:wb,indexWASM:Pb,verticesPerFaceWASM:Ob},n)}if(Oe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Vo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Jf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=eh(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=wb,n=Pb,a=Ob);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Oe._malloc(h),v=new Float32Array(Oe.HEAPF32.buffer,b,d),w=new Uint32Array(Oe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Oe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Oe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Oe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Oe.HEAPU32[c[p]>>2],f=Oe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Oe.HEAPU32[c[p]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Oe.HEAPU32[c[p]>>2],b=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Oe.HEAPU32[c[p]>>2],w=Oe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],p=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Oe.HEAPU32[l[u]>>2],d=new Float32Array(Oe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Tb=["getX","getY","getZ"];function Jf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[Tb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Tb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var sd=new lt.Vector3,Kf=new lt.Vector3,Qf=new lt.Vector3,Zf=new lt.Vector3;function eh(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){sd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Kf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Qf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Zf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Kf.sub(sd).normalize(),Qf.sub(sd).normalize(),Zf.sub(sd).normalize();let l=Kf.cross(Qf).dot(Zf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var $r={};mm($r,{calcBoolean:()=>BI,calcBooleanTopological:()=>RI,freeMeshSet:()=>FI,getMeshSet:()=>VI,hasOpenEdges:()=>zI,transformMeshSet:()=>GI});var _I,Cb=new Promise(i=>{_I=i});var Gl=require("three");var ke,ns;Cb.then(i=>ke=i);function LI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Jf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=eh(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Ab(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function Mb(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function RI(i,t){ns===void 0&&(ns=ke.init_csg());let e=Ab(i),r=ke.csg_calc_topological(ns,e,i.length,Mb(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],p=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function BI(i,t,e,r){ns===void 0&&(ns=ke.init_csg());let o=Ab(i),n=ke.csg_calc(ns,o,i.length,r,Mb(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],p=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Gl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Gl.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Gl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function VI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=LI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+p,s,n);return ke._free(f),y}function zI(i){return ke.has_open_edges(i)}function GI(i,t){ke.transform_csg_mesh(i,t.elements)}function FI(i){ke.free_csg_mesh(i)}var jI={ConeGeometry:x0,CubeGeometry:b0,CylinderGeometry:g0,DodecahedronGeometry:S0,EllipseGeometry:Ja,HelixGeometry:q0,IcosahedronGeometry:X0,LatheGeometry:Y0,NonParametricGeometry:J0,PolygonGeometry:td,PyramidGeometry:eb,RectangleGeometry:rs,SphereGeometry:tb,PlaneGeometry:ob,BackdropGeometry:ib,StarGeometry:rd,TextFrameGeometry:ab,TorusGeometry:sb,TorusKnotGeometry:cb,TriangleGeometry:ub,PathGeometry:hb,VectorGeometry:Pr},Yf=i=>jI[i.type].create(i);function as(i){return i!==null&&"booleanOp"in i}var ss=class extends Wa(ld.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ld.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!as(this.parent)&&this.visible,as(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&($r.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),as(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ss&&(e.freeBooleanPointer(),as(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&as(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),as(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var cd=new ls.Box3;function Fl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}cd.min.set(n,a,s),cd.max.set(l,c,u),cd.getCenter(r),cd.getSize(o).multiplyScalar(.5)}var UI=new ls.BufferGeometry,kI=new ls.MeshBasicMaterial,qt=class extends ss{constructor(t,e){super(UI,kI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Fl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var bi=require("three");var zr=require("three");var Pd=require("three");var hi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(hi.uuidContext===null)throw new Error("plz startContext");hi.uuidContext===hi.globalContext?this.uuid="_gid"+hi.uuidContext.nodeContextUuid++:this.uuid="_uid"+hi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===hi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=hi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=hi.globalContext;var go=require("three");var jl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var th=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},$t=new th;var rh=require("three");var Ib=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Ib.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var Pt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof rh.Vector2?e:new rh.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var oh=require("three");var ir=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof oh.Vector3?e:new oh.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Or=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ht?e:new Ht(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var HI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Nb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Nb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&$t.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=$t.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||$t.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$t.contains(m)&&e.include($t.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=HI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Nb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var WI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ih=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ih.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=WI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=ih;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var qI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
18
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var xb,nd=new Promise(i=>{xb=i}),gb=!1;var id;function bb(i){if(gb)return;if(id)return id;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.11.9/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});xb(c),gb=!0}return id=t(),id}var vb=require("three");var EI=["font"];function Vo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Zp(p)&&!EI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Zp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new vb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Rn(n,t);if(n.type==="InputGeometry")return new Rn(n,t);if(n.type==="UIGeometry")return rs.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Yf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(_a.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Yf(s)}return l}var Sb=require("three"),DI=new Sb.Matrix4;function zl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=DI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ad=new lt.Box3,is=new lt.Vector3,Oe;nd.then(i=>{Oe=i});var wb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Pb=new Uint32Array([0,1,2,3]),Ob=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ri.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&zl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&zl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(is.fromArray(n));let s=is.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ad.setFromBufferAttribute(r),ad.getCenter(o),e.boundingSphere.radius=o.distanceTo(ad.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ad.getSize(is);let n={width:is.x,height:is.y,depth:is.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:wb,indexWASM:Pb,verticesPerFaceWASM:Ob},n)}if(Oe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Vo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Jf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=eh(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=wb,n=Pb,a=Ob);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Oe._malloc(h),v=new Float32Array(Oe.HEAPF32.buffer,b,d),w=new Uint32Array(Oe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Oe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Oe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Oe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Oe.HEAPU32[c[p]>>2],f=Oe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Oe.HEAPU32[c[p]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Oe.HEAPU32[c[p]>>2],b=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Oe.HEAPU32[c[p]>>2],w=Oe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],p=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Oe.HEAPU32[l[u]>>2],d=new Float32Array(Oe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Tb=["getX","getY","getZ"];function Jf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[Tb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Tb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var sd=new lt.Vector3,Kf=new lt.Vector3,Qf=new lt.Vector3,Zf=new lt.Vector3;function eh(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){sd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Kf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Qf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Zf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Kf.sub(sd).normalize(),Qf.sub(sd).normalize(),Zf.sub(sd).normalize();let l=Kf.cross(Qf).dot(Zf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var $r={};mm($r,{calcBoolean:()=>BI,calcBooleanTopological:()=>RI,freeMeshSet:()=>FI,getMeshSet:()=>VI,hasOpenEdges:()=>zI,transformMeshSet:()=>GI});var _I,Cb=new Promise(i=>{_I=i});var Gl=require("three");var ke,ns;Cb.then(i=>ke=i);function LI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Jf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=eh(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Ab(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function Mb(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function RI(i,t){ns===void 0&&(ns=ke.init_csg());let e=Ab(i),r=ke.csg_calc_topological(ns,e,i.length,Mb(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],p=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function BI(i,t,e,r){ns===void 0&&(ns=ke.init_csg());let o=Ab(i),n=ke.csg_calc(ns,o,i.length,r,Mb(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],p=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Gl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Gl.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Gl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function VI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=LI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+p,s,n);return ke._free(f),y}function zI(i){return ke.has_open_edges(i)}function GI(i,t){ke.transform_csg_mesh(i,t.elements)}function FI(i){ke.free_csg_mesh(i)}var jI={ConeGeometry:x0,CubeGeometry:b0,CylinderGeometry:g0,DodecahedronGeometry:S0,EllipseGeometry:Ja,HelixGeometry:q0,IcosahedronGeometry:X0,LatheGeometry:Y0,NonParametricGeometry:J0,PolygonGeometry:td,PyramidGeometry:eb,RectangleGeometry:rs,SphereGeometry:tb,PlaneGeometry:ob,BackdropGeometry:ib,StarGeometry:rd,TextFrameGeometry:ab,TorusGeometry:sb,TorusKnotGeometry:cb,TriangleGeometry:ub,PathGeometry:hb,VectorGeometry:Pr},Yf=i=>jI[i.type].create(i);function as(i){return i!==null&&"booleanOp"in i}var ss=class extends Wa(ld.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ld.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!as(this.parent)&&this.visible,as(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&($r.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),as(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ss&&(e.freeBooleanPointer(),as(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&as(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),as(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var cd=new ls.Box3;function Fl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}cd.min.set(n,a,s),cd.max.set(l,c,u),cd.getCenter(r),cd.getSize(o).multiplyScalar(.5)}var UI=new ls.BufferGeometry,kI=new ls.MeshBasicMaterial,qt=class extends ss{constructor(t,e){super(UI,kI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Fl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var bi=require("three");var zr=require("three");var Pd=require("three");var hi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(hi.uuidContext===null)throw new Error("plz startContext");hi.uuidContext===hi.globalContext?this.uuid="_gid"+hi.uuidContext.nodeContextUuid++:this.uuid="_uid"+hi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===hi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=hi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=hi.globalContext;var go=require("three");var jl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var th=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},$t=new th;var rh=require("three");var Ib=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Ib.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var Pt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof rh.Vector2?e:new rh.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var oh=require("three");var ir=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof oh.Vector3?e:new oh.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Or=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ht?e:new Ht(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var HI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Nb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Nb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&$t.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=$t.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||$t.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$t.contains(m)&&e.include($t.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=HI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Nb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var WI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ih=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ih.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=WI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=ih;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var qI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),$I=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),cs=class extends be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=qI.exec(e);if(r){let o=r[2],n;for(;n=$I.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var us=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};$t.addKeyword("uv",function(){return new us});$t.addKeyword("uv2",function(){return new us(1)});var ud=require("three");var Bn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Bn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ud.LinearEncoding:return["Linear"];case ud.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=Bn.Nodes[this.method],s=e.include(a);if(s===Bn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=Bn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Bn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},mr=Bn;mr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var _e={normalRenderTarget:new yr,normalRenderTargetDepth:new yr,transmissionRenderTarget:new yr,aspectRatio:new Pt,transmissionSize:new Pt(2048,2048),transmissionRenderTargetDepth:new yr,aoRenderTarget:new yr,aoEnabled:new Ot,pixelRatioNode:new se(1),resolution:new Pt,penumbraSize:new xo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Ot(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var qb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.11.
|
|
1876
|
+
}`,[e,r])}}();var _e={normalRenderTarget:new yr,normalRenderTargetDepth:new yr,transmissionRenderTarget:new yr,aspectRatio:new Pt,transmissionSize:new Pt(2048,2048),transmissionRenderTargetDepth:new yr,aoRenderTarget:new yr,aoEnabled:new Ot,pixelRatioNode:new se(1),resolution:new Pt,penumbraSize:new xo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Ot(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var qb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.11.9/build/ui.wasm"};var mi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(_t),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new nr,this.previouseProjectionMatrix=new nr}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(md.UniformsUtils.merge([md.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
|
|
1877
1877
|
`));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
|
|
1878
1878
|
#include <skinbase_vertex>
|
|
1879
1879
|
#include <skinnormal_vertex>
|
|
@@ -2282,7 +2282,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2282
2282
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
|
|
2283
2283
|
}
|
|
2284
2284
|
`),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
|
|
2285
|
-
`)}return r}};var bd=require("three");var yd=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){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var bh=class extends yd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},xh;function $b(i){return typeof i=="string"?i:(xh||(xh=new bh),xh.load(i))}var gd=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},xd=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Ns=class extends gd{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=$b(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new bd.VideoTexture(this.img,void 0,e,e):a=new bd.Texture(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Br=class extends Ns{};var ft=require("three");function ar(i,t){return t.color(i)}function Xb(i,t){switch(i.type){case"fresnel":return e3(i,t);case"gradient":return t3(i,t);case"depth":return r3(i,t);case"normal":return o3(i,t);case"noise":return i3(i,t);case"rainbow":return n3(i,t);case"toon":return a3(i,t);case"outline":return s3(i,t);case"transmission":return l3(i,t);case"color":return JI(i,t);case"pattern":return c3(i,t)}}function ZI(i){return{type:i.type}}function vo(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...ZI(i),alpha:n,mode:r,isMask:o}}function JI(i,t){return{...vo(i,t),color:ar(i.color,t)}}function e3(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...vo(i,t),color:ar(a,t),bias:e,scale:r,intensity:o,factor:n}}function t3(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...vo(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ft.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new ft.Vector2(...s),morph:new ft.Vector2(...l),angle:a}}function r3(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...vo(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new ft.Vector3(...s),direction:l?new ft.Vector3(...l):new ft.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new ft.Vector4(d[0],d[1],d[2],d[3]):new ft.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function o3(i,t){let{cnormal:e}=i;return{...vo(i,t),cnormal:new ft.Vector3(e[0],e[1],e[2])}}function i3(i,t){return{...vo(i,t),scale:i.scale,move:i.move,fA:new ft.Vector2(...i.fA),fB:new ft.Vector2(...i.fB),size:new ft.Vector3(...i.size),distortion:new ft.Vector2(...i.distortion),colorA:ar(i.colorA,t),colorB:ar(i.colorB,t),colorC:ar(i.colorC,t),colorD:ar(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function n3(i,t){return{...vo(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ft.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ft.Vector3(...i.offset)}}function a3(i,t){return{...vo(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ft.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ft.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:ar(i.shadowColor,t),offset:new ft.Vector3(...i.offset)}}function s3(i,t){return{...vo(i,t),outlineColor:ar(i.outlineColor,t),contourColor:ar(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ft.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function l3(i,t){return{...vo(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function c3(i,t){return{...vo(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new ft.Vector2(...i.offset),colorA:ar(i.colorA,t),colorB:ar(i.colorB,t),frequency:new ft.Vector2(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new ft.Vector2(...i.vertical),horizontal:new ft.Vector2(...i.horizontal),sides:i.sides}}var Qi=class extends Ht{};var vd=require("three");var u3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},d3={depth:["colors"]};function p3(i,t,e){if(t==="isMask")return!0;let r=u3[i.type],o=d3[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function vh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Zl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof Br||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Br||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Pe(n.rotation??0,t)??0)*vd.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if("repeat"in n){let l=n.repeat;vh(e.data.texture.repeat,l)&&(o=!0),s.repeat=Es(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;vh(e.data.texture.offset,l)&&(o=!0),s.offset=Es(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||vh(l,c))&&(o=!0),s.rotation=Pe(c,t)??0}s.updateMatrix()}return o}function Yb(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(Sh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Yi))switch(o=o||p3(e,n,a),s.constructor){case et:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Qi?s.value=new Ht(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Or:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Qi?s.value=new Ht(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case Pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case ir:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case yr:{Zl(a,t,e);break}case bo:{s.value=a.map(l=>new vd.Vector4(...l));break}default:{s.value=a;break}}}return o}var Ji=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Pe=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Zi=(i,t)=>(i||(i=new ct.Vector3),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i.z=Pe(i.z,t)??0,i),gi=(i,t)=>(i||(i=new ct.Vector2),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i),Es=(i,t)=>{let e=i.map(r=>Pe(r,t)??0);return[e[0],e[1]]},en=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)Sh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return gr.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new zn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new fd(n),l=new hd(Es(r.texture.repeat,o),Es(r.texture.offset,o),Pe(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new je(r.projection??0),p=new je(["x","y","z"].indexOf(r.axis)??0),d=new je(r.side??0),f=new Pt(r.size?new ct.Vector2(...Es(r.size,o)):new ct.Vector2(100,100)),h=new se(r.blending??0),m=new se(Ji(r.alpha,o)),y=new je(r.mode??0),b=new Ot(r.isMask??!1),v=new Ki(a,s,c,u,p,d,f,h,l,m,y,b),w=new Qe(v.calpha,"f");return new gt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new zn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ji(r.alpha,o)),l=new je(r.mode??0),c=new Ot(r.isMask??!1),u=new se((Pe(r.texture.rotation??0,o)??0)*ct.MathUtils.DEG2RAD),p=new Ss(a,s,l,c,u),d=new Qe(p.calpha,"f");return new gt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new ir(new ct.Vector3(...r.offset.map(b=>Pe(b,o)??0))),a=new se(Pe(r.scale,o)??10),s=new se(Pe(r.intensity,o)??8),l=new se(Pe(r.movement,o)??1),c=new je(r.noiseType??0),u=new je(r.voronoiStyle??0),p=new se(Pe(r.smoothness,o)??.5),d=new se(Pe(r.seed,o)??0),f=new se(Pe(r.highCut,o)??1),h=new se(Pe(r.lowCut,o)??0),m=new je(Pe(r.quality,o)??1),y=new Ms(s,l,n,u,p,d,f,h,m,a,c);return new Jl(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return m3(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let p=s[c];if(typeof u=="string"||typeof u=="number"&&typeof p=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Yb(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Zl(o.props,r.shared,this)||n:!0;return n}dispose(){if(f3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Br||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},gt=class extends en{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Jl=class extends en{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},gr=class extends en{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ji(o.alpha,n)),l=new je(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ji(o.alphaOverride,n)),p;if(!o.visible)a=new mi,p={};else if(o.category==="lambert"){a=new ql;let d=new et(n.color(o.emissive)??0),f=new Ot(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new Ql;let d=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Yl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Ot(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Xl;let d=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Ot(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new gr(e,r,o,a,p,n)}get category(){return this.node.category}};function f3(i){let t=i instanceof en?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Xr(i){return{alpha:new se(i.alpha??1),mode:new je(i.mode??0),isMask:new Ot(i.isMask??!1)}}function h3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??_t),a=Xr(r),s=new Gn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new et(r.color??16777215),a=new se(Pe(r.bias,o)??.1),s=new se(Pe(r.scale,o)??1),l=new se(Pe(r.intensity,o)??2),c=new se(Pe(r.factor,o)??1),u=Xr(r),p=new Hl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Qe(p.calpha,"f");return new gt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(Pe(r.filmThickness,o)??30),a=new se(Pe(r.movement,o)??0),s=new ir(Zi(r.wavelengths,o)),l=new se(Pe(r.noiseStrength,o)??0),c=new se(Pe(r.noiseScale,o)??1),u=new ir(Zi(r.offset,o)),p=Xr(r),d=new Ts(n,a,s,l,c,u,p.alpha,p.isMask),f=new Qe(d.calpha,"f");return new gt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(Pe(r.thickness??10,o)),a=new se(Pe(r.ior??1.5,o)),s=new se(Pe(r.roughness??.5,o)),l=_e.transmissionSize,c=_e.transmissionRenderTarget,u=_e.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new Pt(d/p,1):new Pt(1,p/d),h=Xr(r),m=new As(n,a,s,l,c,u,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new je(r.positioning??0),a;r.colors?a=new bo(r.colors.length,r.colors):(a=new bo(10,new ct.Vector4(0,0,0,1)),a.value[1]=new ct.Vector4(1,1,1,1));let s;r.steps?s=new xo(r.steps.length,r.steps):(s=new xo(10,1),s.value[0]=0);let l=new ir(Zi(r.source??new ct.Vector3(0,0,0),o)),c=new Ot(r.isWorldSpace??!0),u=new se(Pe(r.noiseStrength??0,o)),p=new se(Pe(r.noiseScale??1,o)),d=new Or(r.shadowColor),f=new ir(Zi(r.offset??new ct.Vector3(0,0,0),o)),h=Xr(r),m=new Cs(n,a,s,l,c,u,p,d,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new et(r.outlineColor??16777215),a=new et(r.contourColor??16777215),s=new se(Pe(r.outlineWidth??.1,o)),l=new se(Pe(r.contourWidth??.1,o)),c=new se(Pe(r.outlineThreshold??.1,o)),u=new se(Pe(r.contourThreshold??.1,o)),p=new se(Pe(r.outlineSmoothing??.1,o)),d=new se(Pe(r.contourFrequency??.1,o)),f=new ir(Zi(r.contourDirection??new ct.Vector3(0,1,0),o)),h=new Ot(r.positionalLines??!1),m=new Ot(r.compensation??!0),y=_e.normalRenderTarget,b=_e.normalRenderTargetDepth,v=_e.pixelRatioNode,w=_e.resolution,O=Xr(r),S=new Ps(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Qe(S.calpha,"f");return new gt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new je(r.gradientType??0),a=new Ot(r.smooth??!1),s=new se(Pe(r.near,o)??50),l=new se(Pe(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new ir(Zi(r.origin,o)),d=new ir(Zi(r.direction,o)),f;r.colors?f=new bo(r.colors.length,r.colors):(f=new bo(2,new ct.Vector4(0,0,0,1)),f.value[1]=new ct.Vector4(1,1,1,1));let h;r.steps?h=new xo(r.steps.length,r.steps):(h=new xo(2,1),h.value[0]=0);let m=Xr(r),y=new bs(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Qe(y.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(Pe(r.scale,o)??1),a=new ir(Zi(r.size??new ct.Vector3(100,100,100),o)),s=new se(Pe(r.move,o)??1),l=new Pt(gi(r.fA??new ct.Vector2(1.7,9.2),o)),c=new Pt(gi(r.fB??new ct.Vector2(8.3,2.8),o)),u=new Pt(gi(r.distortion??new ct.Vector2(1,1),o)),p=new Or(r.colorA),d=new Or(r.colorB),f=new Or(r.colorC),h=new Or(r.colorD),m=new je(r.noiseType??0),y=new je(r.voronoiStyle??0),b=new se(Pe(r.highCut,o)??1),v=new se(Pe(r.lowCut,o)??0),w=new se(Pe(r.smoothness,o)??.5),O=new se(Pe(r.seed,o)??.5),S=new je(r.quality??1),T=Xr(r),M=new ws(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Qe(M.calpha,"f");return new gt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new ir(r.cnormal??new ct.Vector3(1,1,1)),a=Xr(r),s=new ys(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new je(r.gradientType??0),a=new Ot(r.smooth??!1),s;r.colors?s=new bo(r.colors.length,r.colors):(s=new bo(10,new ct.Vector4(0,0,0,1)),s.value[1]=new ct.Vector4(1,1,1,1));let l;r.steps?l=new xo(r.steps.length,r.steps):(l=new xo(10,1),l.value[0]=0);let c=new Pt(gi(r.offset??new ct.Vector2(0,0),o)),u=new Pt(gi(r.morph??new ct.Vector2(0,0),o)),p=new se(Pe(r.angle??0,o)),d=Xr(r),f=new vs(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Qe(f.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new je(r.style??0),a=new je(r.projection??0),s=new je(["x","y","z"].indexOf(r.axis)??0),l=new se(Pe(r.blending??0,o)),c=new Pt(gi(r.offset,o)),u=new Or(r.colorA),p=new Or(r.colorB),d=new Pt(gi(r.frequency??new ct.Vector2(10,10),o)),f=new se(Pe(r.size??.5,o)),h=new se(Pe(r.variation??0,o)),m=new se(Pe(r.smoothness??.5,o)),y=new se(Pe(r.zigzag??0,o)),b=new se(Pe(r.rotation??0,o)),v=new Pt(gi(r.vertical??new ct.Vector2(0,1),o)),w=new Pt(gi(r.horizontal??new ct.Vector2(0,1),o)),O=new je(r.sides??6),S=Xr(r),T=new Os(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Qe(T.calpha,"f");return new gt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new et(1,0,0,1),a=Xr(r),s=new Gn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function m3(i,t,e,r){let o=Xb(e,r);return h3(e,i,t,o,r)}function Sh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Pe(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ji(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function Cr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Sd(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var Ar=class extends Pd.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},wd=class extends Ar{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},jn=class extends Ar{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,ot.startContext(this),this.reset0(e,r),ot.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new wd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){ot.startContext(this),(this.data!==e||o)&&this.reset0(e,r),ot.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??kt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>en.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Sd(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Sd(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);if(s?.hasValue(a))if(a==="alpha")this.transparent=Sd(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof Pd.Texture){let p=l[c],d;typeof p=="number"?d=Number(r):p.isVector2&&(d=p.toArray(),u==="x"?d[0]=Number(r):u==="y"&&(d[1]=Number(r))),Zl({[c]:d},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"]),o.data.type==="displace"?o.data.displacementType==="noise"?Cr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):Cr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?Cr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?Cr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?Cr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?Cr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?Cr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?Cr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?Cr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?Cr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(Cr([],["size"],o.data,o.id,e.shared,this.uuid),Cr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?Cr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&Cr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof gr),this.lightLayer===void 0&&(this.lightLayer=new gr(0,"",{...zt.defaultData("light","phong"),visible:!1},new mi,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof gr);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof gt&&s.color instanceof Ki&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(ot.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=Sd(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ji(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ji(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);ot.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof gt?r.color.mask=void 0:r instanceof gr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof gt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof gr?n.node.mask=new Jt(r.color,r.alpha,Jt.MUL):n instanceof gt&&(n.isMask.value||(n.color.mask=new Jt(r.color,r.alpha,Jt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof gt),r=this.layers.findIndex(o=>o instanceof gr);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof gt){if(a.isMask.value)continue;o=new ms(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof gr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof gt){if(n.isMask.value)continue;e=new ms(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Jl);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Jt(r,e[o].position,Jt.ADD),r=new Jt(r,new se(.5).setReadonly(!0),Jt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new fs;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof gt){let r=e.params.texture;if(r instanceof zn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Ar.prototype,{properties:{get:function(){return this.fragment.properties}}});var Un=class extends jn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Kb=new Map;function Qb(i){if(typeof i=="string")return i;let t=Kb.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},Kb.set(i,t)),t.url}var y3,Zb=new Promise(i=>{y3=i});var Jb;Zb.then(i=>Jb=i);var kn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:Qb(t),format:"wav"},this.sound=new Jb.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Xt=require("three"),Od=class{constructor(){this.type="ShapePath";this.color=new Xt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Xt.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,N=v.y,I=(T-S)*(M-D)-(N-D)*(w-S),E=(O-w)*(M-D)-(g-M)*(w-S),_=(N-D)*(O-w)-(T-S)*(g-M),L=I/_,V=E/_;if(_===0&&I!==0||L<=0||L>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+L*(O-w)).toPrecision(10),B=+(M+L*(g-M)).toPrecision(10);return{x:U,y:B,t:L}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new Xt.Vector2(D.x,D.y)))}}return v}function s(m,y,b){let v=new Xt.Vector2;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new Xt.Vector2;m.boundingBox.getCenter(O);let S=[new Xt.Vector2(b,O.y),new Xt.Vector2(v,O.y)],T=s(S,m.boundingBox,y);T.sort((E,_)=>E.point.x-_.point.x);let M=[],g=[];T.forEach(E=>{E.identifier===m.identifier?M.push(E):g.push(E)});let D=M[0].point.x,N=[],I=0;for(;I<g.length&&g[I].point.x<D;)N.length>0&&N[N.length-1]===g[I].identifier?N.pop():N.push(g[I].identifier),I++;if(N.push(m.identifier),w==="evenodd"){let E=N.length%2===0,_=N[N.length-2];return{identifier:m.identifier,isHole:E,for:_}}else if(w==="nonzero"){let E=!0,_=null,L=null;for(let V=0;V<N.length;V++){let U=N[V];y[U]&&(E?(L=y[U].isCW,E=!1,_=U):L!==y[U].isCW&&(L=y[U].isCW,E=!0))}return{identifier:m.identifier,isHole:E,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:Xt.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new Xt.Box2(new Xt.Vector2(O,v),new Xt.Vector2(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new Xt.Shape;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new Xt.Path;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var wh=!1,tv,Ph=new Promise(i=>{tv=i}),ev=!1;var Td;function rv(){if(wh=!0,ev)return;if(Td)return Td;async function i(){let e=await import("./opentype.js");tv(e),ev=!0}return Td=i(),Td}var ec=class{async load(t,e,r=()=>{}){let{load:o}=await Ph;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await Ph;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function g3(i){return await(await fetch(i)).arrayBuffer()}var x3=new ec;async function Oh(i){let t,e,r=!1;if(i.url?(t=await g3(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(wh){let o=await x3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var Ds=require("three");function b3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var Cd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=Oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(b3(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2285
|
+
`)}return r}};var bd=require("three");var yd=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){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var bh=class extends yd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},xh;function $b(i){return typeof i=="string"?i:(xh||(xh=new bh),xh.load(i))}var gd=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},xd=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Ns=class extends gd{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=$b(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new bd.VideoTexture(this.img,void 0,e,e):a=new bd.Texture(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Br=class extends Ns{};var ft=require("three");function ar(i,t){return t.color(i)}function Xb(i,t){switch(i.type){case"fresnel":return e3(i,t);case"gradient":return t3(i,t);case"depth":return r3(i,t);case"normal":return o3(i,t);case"noise":return i3(i,t);case"rainbow":return n3(i,t);case"toon":return a3(i,t);case"outline":return s3(i,t);case"transmission":return l3(i,t);case"color":return JI(i,t);case"pattern":return c3(i,t)}}function ZI(i){return{type:i.type}}function vo(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...ZI(i),alpha:n,mode:r,isMask:o}}function JI(i,t){return{...vo(i,t),color:ar(i.color,t)}}function e3(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...vo(i,t),color:ar(a,t),bias:e,scale:r,intensity:o,factor:n}}function t3(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...vo(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ft.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new ft.Vector2(...s),morph:new ft.Vector2(...l),angle:a}}function r3(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...vo(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new ft.Vector3(...s),direction:l?new ft.Vector3(...l):new ft.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new ft.Vector4(d[0],d[1],d[2],d[3]):new ft.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function o3(i,t){let{cnormal:e}=i;return{...vo(i,t),cnormal:new ft.Vector3(e[0],e[1],e[2])}}function i3(i,t){return{...vo(i,t),scale:i.scale,move:i.move,fA:new ft.Vector2(...i.fA),fB:new ft.Vector2(...i.fB),size:new ft.Vector3(...i.size),distortion:new ft.Vector2(...i.distortion),colorA:ar(i.colorA,t),colorB:ar(i.colorB,t),colorC:ar(i.colorC,t),colorD:ar(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function n3(i,t){return{...vo(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ft.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ft.Vector3(...i.offset)}}function a3(i,t){return{...vo(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ft.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ft.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:ar(i.shadowColor,t),offset:new ft.Vector3(...i.offset)}}function s3(i,t){return{...vo(i,t),outlineColor:ar(i.outlineColor,t),contourColor:ar(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ft.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function l3(i,t){return{...vo(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function c3(i,t){return{...vo(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new ft.Vector2(...i.offset),colorA:ar(i.colorA,t),colorB:ar(i.colorB,t),frequency:new ft.Vector2(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new ft.Vector2(...i.vertical),horizontal:new ft.Vector2(...i.horizontal),sides:i.sides}}var Qi=class extends Ht{};var vd=require("three");var u3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},d3={depth:["colors"]};function p3(i,t,e){if(t==="isMask")return!0;let r=u3[i.type],o=d3[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function vh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Zl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof Br||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Br||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Pe(n.rotation??0,t)??0)*vd.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;vh(e.data.texture.repeat,l)&&(o=!0),s.repeat=Es(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;vh(e.data.texture.offset,l)&&(o=!0),s.offset=Es(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||vh(l,c))&&(o=!0),s.rotation=Pe(c,t)??0}s.updateMatrix()}return o}function Yb(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(Sh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Yi))switch(o=o||p3(e,n,a),s.constructor){case et:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Qi?s.value=new Ht(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Or:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Qi?s.value=new Ht(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case Pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case ir:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case yr:{Zl(a,t,e);break}case bo:{s.value=a.map(l=>new vd.Vector4(...l));break}default:{s.value=a;break}}}return o}var Ji=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Pe=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Zi=(i,t)=>(i||(i=new ct.Vector3),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i.z=Pe(i.z,t)??0,i),gi=(i,t)=>(i||(i=new ct.Vector2),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i),Es=(i,t)=>{let e=i.map(r=>Pe(r,t)??0);return[e[0],e[1]]},en=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)Sh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return gr.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new zn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new fd(n),l=new hd(Es(r.texture.repeat,o),Es(r.texture.offset,o),Pe(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new je(r.projection??0),p=new je(["x","y","z"].indexOf(r.axis)??0),d=new je(r.side??0),f=new Pt(r.size?new ct.Vector2(...Es(r.size,o)):new ct.Vector2(100,100)),h=new se(r.blending??0),m=new se(Ji(r.alpha,o)),y=new je(r.mode??0),b=new Ot(r.isMask??!1),v=new Ki(a,s,c,u,p,d,f,h,l,m,y,b),w=new Qe(v.calpha,"f");return new gt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new zn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ji(r.alpha,o)),l=new je(r.mode??0),c=new Ot(r.isMask??!1),u=new se((Pe(r.texture.rotation??0,o)??0)*ct.MathUtils.DEG2RAD),p=new Ss(a,s,l,c,u),d=new Qe(p.calpha,"f");return new gt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new ir(new ct.Vector3(...r.offset.map(b=>Pe(b,o)??0))),a=new se(Pe(r.scale,o)??10),s=new se(Pe(r.intensity,o)??8),l=new se(Pe(r.movement,o)??1),c=new je(r.noiseType??0),u=new je(r.voronoiStyle??0),p=new se(Pe(r.smoothness,o)??.5),d=new se(Pe(r.seed,o)??0),f=new se(Pe(r.highCut,o)??1),h=new se(Pe(r.lowCut,o)??0),m=new je(Pe(r.quality,o)??1),y=new Ms(s,l,n,u,p,d,f,h,m,a,c);return new Jl(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return m3(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let p=s[c];if(typeof u=="string"||typeof u=="number"&&typeof p=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Yb(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Zl(o.props,r.shared,this)||n:!0;return n}dispose(){if(f3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Br||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},gt=class extends en{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Jl=class extends en{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},gr=class extends en{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ji(o.alpha,n)),l=new je(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ji(o.alphaOverride,n)),p;if(!o.visible)a=new mi,p={};else if(o.category==="lambert"){a=new ql;let d=new et(n.color(o.emissive)??0),f=new Ot(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new Ql;let d=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Yl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Ot(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Xl;let d=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Ot(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new gr(e,r,o,a,p,n)}get category(){return this.node.category}};function f3(i){let t=i instanceof en?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Xr(i){return{alpha:new se(i.alpha??1),mode:new je(i.mode??0),isMask:new Ot(i.isMask??!1)}}function h3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??_t),a=Xr(r),s=new Gn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new et(r.color??16777215),a=new se(Pe(r.bias,o)??.1),s=new se(Pe(r.scale,o)??1),l=new se(Pe(r.intensity,o)??2),c=new se(Pe(r.factor,o)??1),u=Xr(r),p=new Hl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Qe(p.calpha,"f");return new gt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(Pe(r.filmThickness,o)??30),a=new se(Pe(r.movement,o)??0),s=new ir(Zi(r.wavelengths,o)),l=new se(Pe(r.noiseStrength,o)??0),c=new se(Pe(r.noiseScale,o)??1),u=new ir(Zi(r.offset,o)),p=Xr(r),d=new Ts(n,a,s,l,c,u,p.alpha,p.isMask),f=new Qe(d.calpha,"f");return new gt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(Pe(r.thickness??10,o)),a=new se(Pe(r.ior??1.5,o)),s=new se(Pe(r.roughness??.5,o)),l=_e.transmissionSize,c=_e.transmissionRenderTarget,u=_e.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new Pt(d/p,1):new Pt(1,p/d),h=Xr(r),m=new As(n,a,s,l,c,u,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new je(r.positioning??0),a;r.colors?a=new bo(r.colors.length,r.colors):(a=new bo(10,new ct.Vector4(0,0,0,1)),a.value[1]=new ct.Vector4(1,1,1,1));let s;r.steps?s=new xo(r.steps.length,r.steps):(s=new xo(10,1),s.value[0]=0);let l=new ir(Zi(r.source??new ct.Vector3(0,0,0),o)),c=new Ot(r.isWorldSpace??!0),u=new se(Pe(r.noiseStrength??0,o)),p=new se(Pe(r.noiseScale??1,o)),d=new Or(r.shadowColor),f=new ir(Zi(r.offset??new ct.Vector3(0,0,0),o)),h=Xr(r),m=new Cs(n,a,s,l,c,u,p,d,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new et(r.outlineColor??16777215),a=new et(r.contourColor??16777215),s=new se(Pe(r.outlineWidth??.1,o)),l=new se(Pe(r.contourWidth??.1,o)),c=new se(Pe(r.outlineThreshold??.1,o)),u=new se(Pe(r.contourThreshold??.1,o)),p=new se(Pe(r.outlineSmoothing??.1,o)),d=new se(Pe(r.contourFrequency??.1,o)),f=new ir(Zi(r.contourDirection??new ct.Vector3(0,1,0),o)),h=new Ot(r.positionalLines??!1),m=new Ot(r.compensation??!0),y=_e.normalRenderTarget,b=_e.normalRenderTargetDepth,v=_e.pixelRatioNode,w=_e.resolution,O=Xr(r),S=new Ps(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Qe(S.calpha,"f");return new gt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new je(r.gradientType??0),a=new Ot(r.smooth??!1),s=new se(Pe(r.near,o)??50),l=new se(Pe(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new ir(Zi(r.origin,o)),d=new ir(Zi(r.direction,o)),f;r.colors?f=new bo(r.colors.length,r.colors):(f=new bo(2,new ct.Vector4(0,0,0,1)),f.value[1]=new ct.Vector4(1,1,1,1));let h;r.steps?h=new xo(r.steps.length,r.steps):(h=new xo(2,1),h.value[0]=0);let m=Xr(r),y=new bs(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Qe(y.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(Pe(r.scale,o)??1),a=new ir(Zi(r.size??new ct.Vector3(100,100,100),o)),s=new se(Pe(r.move,o)??1),l=new Pt(gi(r.fA??new ct.Vector2(1.7,9.2),o)),c=new Pt(gi(r.fB??new ct.Vector2(8.3,2.8),o)),u=new Pt(gi(r.distortion??new ct.Vector2(1,1),o)),p=new Or(r.colorA),d=new Or(r.colorB),f=new Or(r.colorC),h=new Or(r.colorD),m=new je(r.noiseType??0),y=new je(r.voronoiStyle??0),b=new se(Pe(r.highCut,o)??1),v=new se(Pe(r.lowCut,o)??0),w=new se(Pe(r.smoothness,o)??.5),O=new se(Pe(r.seed,o)??.5),S=new je(r.quality??1),T=Xr(r),M=new ws(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Qe(M.calpha,"f");return new gt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new ir(r.cnormal??new ct.Vector3(1,1,1)),a=Xr(r),s=new ys(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new je(r.gradientType??0),a=new Ot(r.smooth??!1),s;r.colors?s=new bo(r.colors.length,r.colors):(s=new bo(10,new ct.Vector4(0,0,0,1)),s.value[1]=new ct.Vector4(1,1,1,1));let l;r.steps?l=new xo(r.steps.length,r.steps):(l=new xo(10,1),l.value[0]=0);let c=new Pt(gi(r.offset??new ct.Vector2(0,0),o)),u=new Pt(gi(r.morph??new ct.Vector2(0,0),o)),p=new se(Pe(r.angle??0,o)),d=Xr(r),f=new vs(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Qe(f.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new je(r.style??0),a=new je(r.projection??0),s=new je(["x","y","z"].indexOf(r.axis)??0),l=new se(Pe(r.blending??0,o)),c=new Pt(gi(r.offset,o)),u=new Or(r.colorA),p=new Or(r.colorB),d=new Pt(gi(r.frequency??new ct.Vector2(10,10),o)),f=new se(Pe(r.size??.5,o)),h=new se(Pe(r.variation??0,o)),m=new se(Pe(r.smoothness??.5,o)),y=new se(Pe(r.zigzag??0,o)),b=new se(Pe(r.rotation??0,o)),v=new Pt(gi(r.vertical??new ct.Vector2(0,1),o)),w=new Pt(gi(r.horizontal??new ct.Vector2(0,1),o)),O=new je(r.sides??6),S=Xr(r),T=new Os(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Qe(T.calpha,"f");return new gt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new et(1,0,0,1),a=Xr(r),s=new Gn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function m3(i,t,e,r){let o=Xb(e,r);return h3(e,i,t,o,r)}function Sh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Pe(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ji(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function Cr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Sd(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var Ar=class extends Pd.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},wd=class extends Ar{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},jn=class extends Ar{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,ot.startContext(this),this.reset0(e,r),ot.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new wd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){ot.startContext(this),(this.data!==e||o)&&this.reset0(e,r),ot.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??kt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>en.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Sd(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Sd(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);if(s?.hasValue(a))if(a==="alpha")this.transparent=Sd(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof Pd.Texture){let p=l[c],d;typeof p=="number"?d=Number(r):p.isVector2&&(d=p.toArray(),u==="x"?d[0]=Number(r):u==="y"&&(d[1]=Number(r))),Zl({[c]:d},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"]),o.data.type==="displace"?o.data.displacementType==="noise"?Cr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):Cr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?Cr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?Cr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?Cr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?Cr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?Cr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?Cr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?Cr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?Cr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(Cr([],["size"],o.data,o.id,e.shared,this.uuid),Cr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?Cr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&Cr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof gr),this.lightLayer===void 0&&(this.lightLayer=new gr(0,"",{...zt.defaultData("light","phong"),visible:!1},new mi,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof gr);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof gt&&s.color instanceof Ki&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(ot.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=Sd(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ji(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ji(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);ot.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof gt?r.color.mask=void 0:r instanceof gr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof gt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof gr?n.node.mask=new Jt(r.color,r.alpha,Jt.MUL):n instanceof gt&&(n.isMask.value||(n.color.mask=new Jt(r.color,r.alpha,Jt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof gt),r=this.layers.findIndex(o=>o instanceof gr);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof gt){if(a.isMask.value)continue;o=new ms(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof gr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof gt){if(n.isMask.value)continue;e=new ms(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Jl);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Jt(r,e[o].position,Jt.ADD),r=new Jt(r,new se(.5).setReadonly(!0),Jt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new fs;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof gt){let r=e.params.texture;if(r instanceof zn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Ar.prototype,{properties:{get:function(){return this.fragment.properties}}});var Un=class extends jn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Kb=new Map;function Qb(i){if(typeof i=="string")return i;let t=Kb.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},Kb.set(i,t)),t.url}var y3,Zb=new Promise(i=>{y3=i});var Jb;Zb.then(i=>Jb=i);var kn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:Qb(t),format:"wav"},this.sound=new Jb.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Xt=require("three"),Od=class{constructor(){this.type="ShapePath";this.color=new Xt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Xt.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,N=v.y,I=(T-S)*(M-D)-(N-D)*(w-S),E=(O-w)*(M-D)-(g-M)*(w-S),_=(N-D)*(O-w)-(T-S)*(g-M),L=I/_,V=E/_;if(_===0&&I!==0||L<=0||L>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+L*(O-w)).toPrecision(10),B=+(M+L*(g-M)).toPrecision(10);return{x:U,y:B,t:L}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new Xt.Vector2(D.x,D.y)))}}return v}function s(m,y,b){let v=new Xt.Vector2;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new Xt.Vector2;m.boundingBox.getCenter(O);let S=[new Xt.Vector2(b,O.y),new Xt.Vector2(v,O.y)],T=s(S,m.boundingBox,y);T.sort((E,_)=>E.point.x-_.point.x);let M=[],g=[];T.forEach(E=>{E.identifier===m.identifier?M.push(E):g.push(E)});let D=M[0].point.x,N=[],I=0;for(;I<g.length&&g[I].point.x<D;)N.length>0&&N[N.length-1]===g[I].identifier?N.pop():N.push(g[I].identifier),I++;if(N.push(m.identifier),w==="evenodd"){let E=N.length%2===0,_=N[N.length-2];return{identifier:m.identifier,isHole:E,for:_}}else if(w==="nonzero"){let E=!0,_=null,L=null;for(let V=0;V<N.length;V++){let U=N[V];y[U]&&(E?(L=y[U].isCW,E=!1,_=U):L!==y[U].isCW&&(L=y[U].isCW,E=!0))}return{identifier:m.identifier,isHole:E,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:Xt.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new Xt.Box2(new Xt.Vector2(O,v),new Xt.Vector2(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new Xt.Shape;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new Xt.Path;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var wh=!1,tv,Ph=new Promise(i=>{tv=i}),ev=!1;var Td;function rv(){if(wh=!0,ev)return;if(Td)return Td;async function i(){let e=await import("./opentype.js");tv(e),ev=!0}return Td=i(),Td}var ec=class{async load(t,e,r=()=>{}){let{load:o}=await Ph;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await Ph;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function g3(i){return await(await fetch(i)).arrayBuffer()}var x3=new ec;async function Oh(i){let t,e,r=!1;if(i.url?(t=await g3(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(wh){let o=await x3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var Ds=require("three");function b3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var Cd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=Oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(b3(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2286
2286
|
`,e),p=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],u),f=this.getLineInitialOffsetY(a,t.length,c,n,e.verticalAlign),h=[],m=t.map(v=>[]),y=t.map(v=>[]);for(let v=0;v<t.length;v++){let w=t[v],O={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,O)}catch(N){console.warn(N)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(N){console.warn(N)}let M=this.computeSpaceWidthForLine(t,v,e,r),g=0,D=S[0];D&&e.horizontalAlign===2&&D.leftSideBearing!==void 0&&(d-=D.leftSideBearing*n),this.font?.forEachGlyph(w,d,f,e.fontSize,O,(N,I,E,_,L)=>{let V=N.index===0?`
|
|
2287
2287
|
`:N.unicode?String.fromCharCode(N.unicode):void 0,U=T[g],B=0;if(V===`
|
|
2288
2288
|
`)B=p;else if(V===" ")B=M;else{let q=this.createPath(N,n,I,E,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[v].push([I,E]),m[v].push(B);else{let q=U.replacements.map(W=>(o.glyphs.get(W).advanceWidth??0)*n),j=q.reduce((W,ee)=>W+=ee,0),F=q.map(W=>W/j),H=I;for(let W=0;W<F.length;W++){let ee=B*F[W];y[v].push([H,E]),m[v].push(ee),H+=ee}}g++}),f-=a}let b=[];for(let v=0,w=h.length;v<w;v++)b.push(...h[v].toShapes());return{shapes:b,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,n){return(r===3||r===2)&&o.indexOf(`
|
|
@@ -4376,4 +4376,4 @@ void main() {
|
|
|
4376
4376
|
A = exp(A) * vColor.a;
|
|
4377
4377
|
gl_FragColor = vec4(color.rgb, A);
|
|
4378
4378
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
4379
|
-
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=J1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=cp(this.centers[y]),c[b+2]=cp(this.centers[y+1]),c[b+3]=cp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(d,p,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(up.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(up),this.material.uniforms.basisViewport.value.set(2/up.x,2/up.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var tS,im=new Promise(i=>{tS=i}),eS=!1;var pp;function nm(){if(eS)return;if(pp)return pp;async function i(){let e=await import("./gaussian-splat-compression.js");tS(e),eS=!0}return pp=i(),pp}var rS;im.then(i=>rS=i);var xc=class{constructor(t={}){Sn(this,"updateView",function(){let t=new br.Matrix4,e=[],r=new br.Vector3(0,0,-1),o=new br.Vector3(0,0,-1),n=new br.Vector3,a=new br.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new br.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new br.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new br.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new br.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new rS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new br.Vector3,o=new br.Quaternion,n=!1,a=1,s,l){this.splatMesh=mn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=Z1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var NN=new ro.MeshBasicMaterial;NN.wireframe=!0;var oS=new ro.Vector3,fp=class extends ro.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new lp;this.invisibleObjects=new sn("jflkdsafjasdifjaslk",{...Iu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new eo("fdasfa",{...oi.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=K1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Y1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof eo&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Ac(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Vi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof eo&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof eo&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Yn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof eo&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),an(n)&&lc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof pn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),lc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),an(o)&&(o.freeBooleanPointer(),n instanceof Ir&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ys&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),an(o)&&(o.invalidateUpstreamBooleanData(),lc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ir&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof eo&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{k1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Yn||l instanceof eo)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof vi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ei(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Cc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=dt.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Pi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ei(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of _u.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Pi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),tp(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Pi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(an(s)||cc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),yc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((an(a)||cc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),yc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();lc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ui.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=np(e,r,l);return c instanceof pn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ht&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new ro.Matrix4().fromArray(m)),h=new ro.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new ro.Box3;return o.setFromPoints(r),o.getCenter(oS),oS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof qt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ar&&e(r.material[o]);else r.material instanceof Ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof vi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new xc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var iS=require("three/examples/jsm/loaders/DRACOLoader.js");var yn;function nS(i){return yn||(yn=new iS.DRACOLoader,yn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),yn.decoderPending}async function EN(i){if(yn){let t={attributeIDs:yn.defaultAttributeIDs,attributeTypes:yn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await yn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function aS(i,t){let[e,r]=Gp(yu.deserialize(new Uint8Array(i)));return Ru(e),t&&t(e),r.result().data}function sS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function lS(i){for(let t of i){let e=await EN(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var DN=require("three"),_N=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var bc=require("three");function uS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Mr)if(At(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(LN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new bc.Color,specularColor:new bc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Wb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else RN(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function LN(i){return i.getLayersOfType("transmission").length>0}function RN(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function dS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function pS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var fS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function hS(i){let t=[];return i.traverse(e=>{e instanceof on&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&cS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof qt&&a.unshift(r.geometry),a.length){let s=(0,fS.mergeBufferGeometries)(a);r instanceof qt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:cv})}),i}function mS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function yS(i){Object.values(i.shared.materials).forEach(t=>{am(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?am(e.material):"materials"in e&&e.materials.forEach(r=>{am(r)})})}function am(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var vS=al(xS(),1);var bS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hp=class extends mp.Loader{load(t,e,r,o=console.error){let n=new mp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(bS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(bS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await aS(t,yS),r=sS(e);e.version&&(0,vS.default)(e.version,"1.11.6")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&nS(),hv(e)&&bb(),Ov(e)&&rv(),i1(e)&&t1(),dp(e)&&nm()].filter(Boolean)),r.length&&await lS(r);let o=!1,n=new Hn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new fp(e.scene,n);dp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=hS(a),a=uS(a),a=dS(a),a=pS(a),a=mS(a),a}};
|
|
4379
|
+
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=J1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=cp(this.centers[y]),c[b+2]=cp(this.centers[y+1]),c[b+3]=cp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(d,p,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(up.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(up),this.material.uniforms.basisViewport.value.set(2/up.x,2/up.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var tS,im=new Promise(i=>{tS=i}),eS=!1;var pp;function nm(){if(eS)return;if(pp)return pp;async function i(){let e=await import("./gaussian-splat-compression.js");tS(e),eS=!0}return pp=i(),pp}var rS;im.then(i=>rS=i);var xc=class{constructor(t={}){Sn(this,"updateView",function(){let t=new br.Matrix4,e=[],r=new br.Vector3(0,0,-1),o=new br.Vector3(0,0,-1),n=new br.Vector3,a=new br.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new br.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new br.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new br.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new br.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new rS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new br.Vector3,o=new br.Quaternion,n=!1,a=1,s,l){this.splatMesh=mn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=Z1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var NN=new ro.MeshBasicMaterial;NN.wireframe=!0;var oS=new ro.Vector3,fp=class extends ro.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new lp;this.invisibleObjects=new sn("jflkdsafjasdifjaslk",{...Iu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new eo("fdasfa",{...oi.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=K1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Y1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof eo&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Ac(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Vi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof eo&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof eo&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Yn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof eo&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),an(n)&&lc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof pn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),lc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),an(o)&&(o.freeBooleanPointer(),n instanceof Ir&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ys&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),an(o)&&(o.invalidateUpstreamBooleanData(),lc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ir&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof eo&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{k1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Yn||l instanceof eo)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof vi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ei(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Cc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=dt.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Pi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ei(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of _u.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Pi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),tp(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Pi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(an(s)||cc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),yc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((an(a)||cc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),yc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();lc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ui.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=np(e,r,l);return c instanceof pn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ht&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new ro.Matrix4().fromArray(m)),h=new ro.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new ro.Box3;return o.setFromPoints(r),o.getCenter(oS),oS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof qt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ar&&e(r.material[o]);else r.material instanceof Ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof vi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new xc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var iS=require("three/examples/jsm/loaders/DRACOLoader.js");var yn;function nS(i){return yn||(yn=new iS.DRACOLoader,yn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),yn.decoderPending}async function EN(i){if(yn){let t={attributeIDs:yn.defaultAttributeIDs,attributeTypes:yn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await yn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function aS(i,t){let[e,r]=Gp(yu.deserialize(new Uint8Array(i)));return Ru(e),t&&t(e),r.result().data}function sS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function lS(i){for(let t of i){let e=await EN(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var DN=require("three"),_N=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var bc=require("three");function uS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Mr)if(At(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(LN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new bc.Color,specularColor:new bc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Wb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else RN(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function LN(i){return i.getLayersOfType("transmission").length>0}function RN(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function dS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function pS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var fS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function hS(i){let t=[];return i.traverse(e=>{e instanceof on&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&cS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof qt&&a.unshift(r.geometry),a.length){let s=(0,fS.mergeBufferGeometries)(a);r instanceof qt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:cv})}),i}function mS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function yS(i){Object.values(i.shared.materials).forEach(t=>{am(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?am(e.material):"materials"in e&&e.materials.forEach(r=>{am(r)})})}function am(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var vS=al(xS(),1);var bS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hp=class extends mp.Loader{load(t,e,r,o=console.error){let n=new mp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(bS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(bS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await aS(t,yS),r=sS(e);e.version&&(0,vS.default)(e.version,"1.11.9")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&nS(),hv(e)&&bb(),Ov(e)&&rv(),i1(e)&&t1(),dp(e)&&nm()].filter(Boolean)),r.length&&await lS(r);let o=!1,n=new Hn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new fp(e.scene,n);dp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=hS(a),a=uS(a),a=dS(a),a=pS(a),a=mS(a),a}};
|
package/build/SplineLoader.js
CHANGED
|
@@ -15,7 +15,7 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
|
|
|
15
15
|
}`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=pl(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=pl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:Z3(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var Tb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return Tb(e,t)}return bi.isBoolean(i)?bi.getDisplayedValue(i).toLowerCase():bi.getDisplayedValue(i)},pl=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
|
|
16
16
|
`:"")+pl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return Tb(o,t)}}return""}).join("");var iN=new cn,nN=new cn;function aN(i,t,e){let r=[new Lt,new Lt,new Lt],o=[new Lt,new Lt,new Lt];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Vu.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new cn().makeBasis(r[0],r[1],r[2])}var Mb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Da.create({parameters:Ep}).userData.shape;return{path:i.path??fa.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Xc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new zf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ab,{userData:{...i,type:"PathGeometry"}})}},zf=class extends Ab{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Pb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(r[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=aN(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new Pi(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let N=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=N,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,N=I});let E=I*c,_,L=0;if(this._isOpenEnded()&&w==="flat"){try{_=Ur({windingRule:je.ODD,elementType:lt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Pf}L=_.vertexCount}let V=E+2*L+g*2,U=E+2*L,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,E,q,B,p[0],u[0],!1),this._closeEnd(_,E+L,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Va(B.positions,3)),this.setAttribute("normal",new Va(B.normals,3)),this.setAttribute("uv",new Va(B.uvs,2)),this.setIndex(q);let H=iN;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(nN.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Va(B.positions,3)),this.setAttribute("normal",new Va(B.normals,3)),this.setAttribute("uv",new Va(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=mu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Lt,s=new Lt,l=new Lt,c=new Lt,u=new Lt(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new cn().makeBasis(M,g,T);r.push(D)}let p=n?s:l,d=n?a:new Lt(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return r;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let b=new cn().makeRotationZ(h*y/r.length);r[y].multiply(b)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new cn,p=new cn;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Vu.lerp(a,a+s,h)*Vu.DEG2RAD);let m=Vu.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=Ur({windingRule:r,elementType:lt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=sl}let l;try{l=Ur({windingRule:je.ODD,elementType:lt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=wf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let N=T-v,I=s.vertices[M*2+0],E=s.vertices[M*2+1],_=s.vertices[T*2+0],L=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=L-E,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=L-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[N*2+0]=-H,S.normals[N*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[N]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[N]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[N]=Z.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Lt,u=new Lt,p=new Lt,d=new Lt,f=new Cb;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Lt(0,0,l?-1:1).applyMatrix4(a),p=new Lt,d=new Cb;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,b=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,b,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new oN().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=r*m,b=o*m;y<b;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Ib,BufferGeometry as Gf}from"three";import{mergeBufferGeometries as lN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Nb(){let i=new Gf;return i.setAttribute("position",new Ib(new Float32Array([]),3)),i.setIndex(new Ib(new Uint16Array([]),1)),i}var cN=Nb().attributes,uN=12,dN=1,un=class extends Gf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,cN),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=bi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=pN(e,o,f,r),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new Ue().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>tr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&s>0?dN:uN}})),T=S.length?lN(S):Nb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ot(new Gf,un.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function pN(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
|
|
17
17
|
`?(n[n.length-1]+=a,a="",s===`
|
|
18
|
-
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as jf,BufferAttribute as Lb,Uint32BufferAttribute as Uf,Float32BufferAttribute as kf,Matrix4 as gN,Vector3 as hl,Sphere as xN,Box3 as bN,BoxGeometry as vN}from"three";var Db,Gu=new Promise(i=>{Db=i}),Eb=!1;var zu;function _b(i){if(Eb)return;if(zu)return zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.11.6/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Db(c),Eb=!0}return zu=t(),zu}import{BufferGeometryLoader as fN}from"three";var hN=["font"];function fo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Mp(p)&&!hN.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Mp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fN().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new bt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new un(n,t);if(n.type==="InputGeometry")return new un(n,t);if(n.type==="UIGeometry")return Ba.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Ff(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(pa.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Ff(s)}return l}import{Matrix4 as mN}from"three";var yN=new mN;function fl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=yN.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Fu=new bN,za=new hl,we;Gu.then(i=>{we=i});var Rb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Bb=new Uint32Array([0,1,2,3]),Vb=new Uint8Array([4]),bt=class extends jf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=fi.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&fl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(za.fromArray(n));let s=za.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vN(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new xN,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Fu.setFromBufferAttribute(r),Fu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Fu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fu.getSize(za);let n={width:za.x,height:za.y,depth:za.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=bt.allocate(e,n)}catch(u){console.error(u,e),a=bt.allocate({positionWASM:Rb,indexWASM:Bb,verticesPerFaceWASM:Vb},n)}if(we.set_destination_refinement_level(a,0),s=bt.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=bt.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=bt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:fo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=Xf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Rb,n=Bb,a=Vb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=we._malloc(h),v=new Float32Array(we.HEAPF32.buffer,b,d),w=new Uint32Array(we.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new gN().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?we.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):we.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return we._free(b),S}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=we.HEAPU32[c[p]>>2],f=we.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=we.HEAPU32[c[p]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=we.HEAPU32[c[p]>>2],b=we.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=we.HEAPU32[c[p]>>2],w=we.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new jf;if(O.setIndex(new Uf(w,1)),O.setAttribute("position",new kf(f,3)),O.setAttribute("normal",new kf(m,3)),r){O.setAttribute("faceMap",new Uf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Lb(S,4))}return we.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],p=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new jf;h.setAttribute("position",new kf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Lb(m,3)),h.setIndex(new Uf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=we.HEAPU32[l[u]>>2],d=new Float32Array(we.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var zb=["getX","getY","getZ"];function $f(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[zb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[zb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var ju=new hl,Hf=new hl,Wf=new hl,qf=new hl;function Xf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){ju.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Hf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Wf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),qf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Hf.sub(ju).normalize(),Wf.sub(ju).normalize(),qf.sub(ju).normalize();let l=Hf.cross(Wf).dot(qf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Or={};bw(Or,{calcBoolean:()=>TN,calcBooleanTopological:()=>ON,freeMeshSet:()=>IN,getMeshSet:()=>CN,hasOpenEdges:()=>AN,transformMeshSet:()=>MN});var SN,Gb=new Promise(i=>{SN=i});import{Float32BufferAttribute as Fb,Sphere as wN}from"three";var Ve,Ga;Gb.then(i=>Ve=i);function PN(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=$f(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Xf(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function jb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Ub(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function ON(i,t){Ga===void 0&&(Ga=Ve.init_csg());let e=jb(i),r=Ve.csg_calc_topological(Ga,e,i.length,Ub(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],p=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function TN(i,t,e,r){Ga===void 0&&(Ga=Ve.init_csg());let o=jb(i),n=Ve.csg_calc(Ga,o,i.length,r,Ub(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],p=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Fb(p,3)),e.setAttribute("normal",new Fb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new wN),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function CN(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=PN(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+p,s,n);return Ve._free(f),y}function AN(i){return Ve.has_open_edges(i)}function MN(i,t){Ve.transform_csg_mesh(i,t.elements)}function IN(i){Ve.free_csg_mesh(i)}var NN={ConeGeometry:P0,CubeGeometry:O0,CylinderGeometry:w0,DodecahedronGeometry:T0,EllipseGeometry:Da,HelixGeometry:tb,IcosahedronGeometry:rb,LatheGeometry:ob,NonParametricGeometry:fb,PolygonGeometry:Lu,PyramidGeometry:hb,RectangleGeometry:Ba,SphereGeometry:yb,PlaneGeometry:gb,BackdropGeometry:xb,StarGeometry:Ru,TextFrameGeometry:bb,TorusGeometry:vb,TorusKnotGeometry:Sb,TriangleGeometry:wb,PathGeometry:Mb,VectorGeometry:tr},Ff=i=>NN[i.type].create(i);function Fa(i){return i!==null&&"booleanOp"in i}var ja=class extends Oa(DN){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new EN}updateVisible(e){super.updateVisible(e),this.visible=!Fa(this.parent)&&this.visible,Fa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Or.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ja&&(e.freeBooleanPointer(),Fa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Fa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Fa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Uu=new _N;function ml(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Uu.min.set(n,a,s),Uu.max.set(l,c,u),Uu.getCenter(r),Uu.getSize(o).multiplyScalar(.5)}var BN=new LN,VN=new RN,It=class extends ja{constructor(t,e){super(BN,VN),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as aD,Matrix4 as sD,Sphere as Rv,Vector3 as lD}from"three";import{BufferAttribute as oD,Float32BufferAttribute as Lv,MathUtils as Ph,Vector3 as Oh}from"three";import{ShaderMaterial as LE,Texture as RE}from"three";var Ho=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ho.uuidContext===null)throw new Error("plz startContext");Ho.uuidContext===Ho.globalContext?this.uuid="_gid"+Ho.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ho.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Ho;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Ho.globalContext;import{CubeReflectionMapping as $N,CubeRefractionMapping as XN,CubeUVReflectionMapping as YN,LinearEncoding as Zb,sRGBEncoding as KN}from"three";var yl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Yf;import{Vector2 as kb}from"three";import{MathUtils as zN}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=zN.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ct=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof kb?e:new kb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Hb}from"three";var Ft=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Hb?e:new Hb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var rr=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof At?e:new At(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var GN=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Wb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Wb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Nt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=GN.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Wb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var FN=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=FN.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=Kf;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var jN=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
18
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as jf,BufferAttribute as Lb,Uint32BufferAttribute as Uf,Float32BufferAttribute as kf,Matrix4 as gN,Vector3 as hl,Sphere as xN,Box3 as bN,BoxGeometry as vN}from"three";var Db,Gu=new Promise(i=>{Db=i}),Eb=!1;var zu;function _b(i){if(Eb)return;if(zu)return zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.11.9/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Db(c),Eb=!0}return zu=t(),zu}import{BufferGeometryLoader as fN}from"three";var hN=["font"];function fo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Mp(p)&&!hN.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Mp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fN().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new bt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new un(n,t);if(n.type==="InputGeometry")return new un(n,t);if(n.type==="UIGeometry")return Ba.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Ff(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ue.createFromState(pa.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Ff(s)}return l}import{Matrix4 as mN}from"three";var yN=new mN;function fl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=yN.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Fu=new bN,za=new hl,we;Gu.then(i=>{we=i});var Rb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Bb=new Uint32Array([0,1,2,3]),Vb=new Uint8Array([4]),bt=class extends jf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=fi.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&fl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(za.fromArray(n));let s=za.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vN(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new xN,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Fu.setFromBufferAttribute(r),Fu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Fu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fu.getSize(za);let n={width:za.x,height:za.y,depth:za.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=bt.allocate(e,n)}catch(u){console.error(u,e),a=bt.allocate({positionWASM:Rb,indexWASM:Bb,verticesPerFaceWASM:Vb},n)}if(we.set_destination_refinement_level(a,0),s=bt.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=bt.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=bt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:fo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=Xf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Rb,n=Bb,a=Vb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=we._malloc(h),v=new Float32Array(we.HEAPF32.buffer,b,d),w=new Uint32Array(we.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new gN().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?we.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):we.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return we._free(b),S}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=we.HEAPU32[c[p]>>2],f=we.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=we.HEAPU32[c[p]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=we.HEAPU32[c[p]>>2],b=we.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=we.HEAPU32[c[p]>>2],w=we.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new jf;if(O.setIndex(new Uf(w,1)),O.setAttribute("position",new kf(f,3)),O.setAttribute("normal",new kf(m,3)),r){O.setAttribute("faceMap",new Uf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Lb(S,4))}return we.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],p=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new jf;h.setAttribute("position",new kf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Lb(m,3)),h.setIndex(new Uf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=we.HEAPU32[l[u]>>2],d=new Float32Array(we.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var zb=["getX","getY","getZ"];function $f(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[zb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[zb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var ju=new hl,Hf=new hl,Wf=new hl,qf=new hl;function Xf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){ju.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Hf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Wf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),qf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Hf.sub(ju).normalize(),Wf.sub(ju).normalize(),qf.sub(ju).normalize();let l=Hf.cross(Wf).dot(qf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Or={};bw(Or,{calcBoolean:()=>TN,calcBooleanTopological:()=>ON,freeMeshSet:()=>IN,getMeshSet:()=>CN,hasOpenEdges:()=>AN,transformMeshSet:()=>MN});var SN,Gb=new Promise(i=>{SN=i});import{Float32BufferAttribute as Fb,Sphere as wN}from"three";var Ve,Ga;Gb.then(i=>Ve=i);function PN(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=$f(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Xf(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function jb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function Ub(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function ON(i,t){Ga===void 0&&(Ga=Ve.init_csg());let e=jb(i),r=Ve.csg_calc_topological(Ga,e,i.length,Ub(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],p=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function TN(i,t,e,r){Ga===void 0&&(Ga=Ve.init_csg());let o=jb(i),n=Ve.csg_calc(Ga,o,i.length,r,Ub(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],p=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Fb(p,3)),e.setAttribute("normal",new Fb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new wN),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function CN(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=PN(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+p,s,n);return Ve._free(f),y}function AN(i){return Ve.has_open_edges(i)}function MN(i,t){Ve.transform_csg_mesh(i,t.elements)}function IN(i){Ve.free_csg_mesh(i)}var NN={ConeGeometry:P0,CubeGeometry:O0,CylinderGeometry:w0,DodecahedronGeometry:T0,EllipseGeometry:Da,HelixGeometry:tb,IcosahedronGeometry:rb,LatheGeometry:ob,NonParametricGeometry:fb,PolygonGeometry:Lu,PyramidGeometry:hb,RectangleGeometry:Ba,SphereGeometry:yb,PlaneGeometry:gb,BackdropGeometry:xb,StarGeometry:Ru,TextFrameGeometry:bb,TorusGeometry:vb,TorusKnotGeometry:Sb,TriangleGeometry:wb,PathGeometry:Mb,VectorGeometry:tr},Ff=i=>NN[i.type].create(i);function Fa(i){return i!==null&&"booleanOp"in i}var ja=class extends Oa(DN){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new EN}updateVisible(e){super.updateVisible(e),this.visible=!Fa(this.parent)&&this.visible,Fa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Or.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ja&&(e.freeBooleanPointer(),Fa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Fa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Fa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Uu=new _N;function ml(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Uu.min.set(n,a,s),Uu.max.set(l,c,u),Uu.getCenter(r),Uu.getSize(o).multiplyScalar(.5)}var BN=new LN,VN=new RN,It=class extends ja{constructor(t,e){super(BN,VN),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as aD,Matrix4 as sD,Sphere as Rv,Vector3 as lD}from"three";import{BufferAttribute as oD,Float32BufferAttribute as Lv,MathUtils as Ph,Vector3 as Oh}from"three";import{ShaderMaterial as LE,Texture as RE}from"three";var Ho=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ho.uuidContext===null)throw new Error("plz startContext");Ho.uuidContext===Ho.globalContext?this.uuid="_gid"+Ho.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ho.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Ho;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Ho.globalContext;import{CubeReflectionMapping as $N,CubeRefractionMapping as XN,CubeUVReflectionMapping as YN,LinearEncoding as Zb,sRGBEncoding as KN}from"three";var yl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Yf;import{Vector2 as kb}from"three";import{MathUtils as zN}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=zN.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ct=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof kb?e:new kb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Hb}from"three";var Ft=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Hb?e:new Hb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var rr=class extends Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof At?e:new At(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var GN=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Wb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Wb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Nt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=GN.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Wb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var FN=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=FN.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=Kf;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var jN=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),UN=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ua=class extends ge{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=jN.exec(e);if(r){let o=r[2],n;for(;n=UN.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ka=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};Nt.addKeyword("uv",function(){return new ka});Nt.addKeyword("uv2",function(){return new ka(1)});import{LinearEncoding as kN,sRGBEncoding as HN}from"three";var dn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??dn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case kN:return["Linear"];case HN:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=dn.Nodes[this.method],s=e.include(a);if(s===dn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=dn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=dn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Yt=dn;Yt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var Me={normalRenderTarget:new Kt,normalRenderTargetDepth:new Kt,transmissionRenderTarget:new Kt,aspectRatio:new ct,transmissionSize:new ct(2048,2048),transmissionRenderTargetDepth:new Kt,aoRenderTarget:new Kt,aoEnabled:new ut,pixelRatioNode:new se(1),resolution:new ct,penumbraSize:new Hr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2),taaEnabled:new ut(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var av={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.11.
|
|
1876
|
+
}`,[e,r])}}();var Me={normalRenderTarget:new Kt,normalRenderTargetDepth:new Kt,transmissionRenderTarget:new Kt,aspectRatio:new ct,transmissionSize:new ct(2048,2048),transmissionRenderTargetDepth:new Kt,aoRenderTarget:new Kt,aoEnabled:new ut,pixelRatioNode:new se(1),resolution:new ct,penumbraSize:new Hr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2),taaEnabled:new ut(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var av={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.11.9/build/ui.wasm"};var Wo=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(gt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new jt,this.previouseProjectionMatrix=new jt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Me.frameIndex}),e.mergeUniform({resolution:Me.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(aE.merge([nE.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
|
|
1877
1877
|
`));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
|
|
1878
1878
|
#include <skinbase_vertex>
|
|
1879
1879
|
#include <skinnormal_vertex>
|
|
@@ -2282,7 +2282,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2282
2282
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
|
|
2283
2283
|
}
|
|
2284
2284
|
`),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
|
|
2285
|
-
`)}return r}};import{VideoTexture as dE,Texture as pE}from"three";var $u=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){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var uh=class extends $u{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},ch;function uv(i){return typeof i=="string"?i:(ch||(ch=new uh),ch.load(i))}var Xu=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Yu=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var ls=class extends Xu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=uv(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new dE(this.img,void 0,e,e):a=new pE(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var hr=class extends ls{};import{Vector2 as $o,Vector3 as go,Vector4 as Ku}from"three";function Ut(i,t){return t.color(i)}function dv(i,t){switch(i.type){case"fresnel":return mE(i,t);case"gradient":return yE(i,t);case"depth":return gE(i,t);case"normal":return xE(i,t);case"noise":return bE(i,t);case"rainbow":return vE(i,t);case"toon":return SE(i,t);case"outline":return wE(i,t);case"transmission":return PE(i,t);case"color":return hE(i,t);case"pattern":return OE(i,t)}}function fE(i){return{type:i.type}}function qr(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...fE(i),alpha:n,mode:r,isMask:o}}function hE(i,t){return{...qr(i,t),color:Ut(i.color,t)}}function mE(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...qr(i,t),color:Ut(a,t),bias:e,scale:r,intensity:o,factor:n}}function yE(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...qr(i,t),gradientType:e,smooth:r,colors:o.map(c=>new Ku(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new $o(...s),morph:new $o(...l),angle:a}}function gE(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...qr(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new go(...s),direction:l?new go(...l):new go(1,0,0),colors:c.map(d=>d!==void 0?new Ku(d[0],d[1],d[2],d[3]):new Ku(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function xE(i,t){let{cnormal:e}=i;return{...qr(i,t),cnormal:new go(e[0],e[1],e[2])}}function bE(i,t){return{...qr(i,t),scale:i.scale,move:i.move,fA:new $o(...i.fA),fB:new $o(...i.fB),size:new go(...i.size),distortion:new $o(...i.distortion),colorA:Ut(i.colorA,t),colorB:Ut(i.colorB,t),colorC:Ut(i.colorC,t),colorD:Ut(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function vE(i,t){return{...qr(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new go(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new go(...i.offset)}}function SE(i,t){return{...qr(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Ku(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new go(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:Ut(i.shadowColor,t),offset:new go(...i.offset)}}function wE(i,t){return{...qr(i,t),outlineColor:Ut(i.outlineColor,t),contourColor:Ut(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new go(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function PE(i,t){return{...qr(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function OE(i,t){return{...qr(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new $o(...i.offset),colorA:Ut(i.colorA,t),colorB:Ut(i.colorB,t),frequency:new $o(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new $o(...i.vertical),horizontal:new $o(...i.horizontal),sides:i.sides}}var Ai=class extends At{};import{MathUtils as TE,Vector4 as CE}from"three";var AE={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},ME={depth:["colors"]};function IE(i,t,e){if(t==="isMask")return!0;let r=AE[i.type],o=ME[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function dh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Pl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof hr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof hr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Se(n.rotation??0,t)??0)*TE.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if("repeat"in n){let l=n.repeat;dh(e.data.texture.repeat,l)&&(o=!0),s.repeat=cs(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;dh(e.data.texture.offset,l)&&(o=!0),s.offset=cs(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||dh(l,c))&&(o=!0),s.rotation=Se(c,t)??0}s.updateMatrix()}return o}function pv(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(ph(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Ti))switch(o=o||IE(e,n,a),s.constructor){case qe:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Ai?s.value=new At(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case rr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Ai?s.value=new At(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case ct:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Ft:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Kt:{Pl(a,t,e);break}case Wr:{s.value=a.map(l=>new CE(...l));break}default:{s.value=a;break}}}return o}var Ii=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Se=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Mi=(i,t)=>(i||(i=new yn),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i.z=Se(i.z,t)??0,i),Xo=(i,t)=>(i||(i=new $r),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i),cs=(i,t)=>{let e=i.map(r=>Se(r,t)??0);return[e[0],e[1]]},Ni=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)ph(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Qt.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new Wu(n),l=new qu(cs(r.texture.repeat,o),cs(r.texture.offset,o),Se(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new Re(r.projection??0),p=new Re(["x","y","z"].indexOf(r.axis)??0),d=new Re(r.side??0),f=new ct(r.size?new $r(...cs(r.size,o)):new $r(100,100)),h=new se(r.blending??0),m=new se(Ii(r.alpha,o)),y=new Re(r.mode??0),b=new ut(r.isMask??!1),v=new Ci(a,s,c,u,p,d,f,h,l,m,y,b),w=new ke(v.calpha,"f");return new it(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ii(r.alpha,o)),l=new Re(r.mode??0),c=new ut(r.isMask??!1),u=new se((Se(r.texture.rotation??0,o)??0)*NE.DEG2RAD),p=new es(a,s,l,c,u),d=new ke(p.calpha,"f");return new it(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new Ft(new yn(...r.offset.map(b=>Se(b,o)??0))),a=new se(Se(r.scale,o)??10),s=new se(Se(r.intensity,o)??8),l=new se(Se(r.movement,o)??1),c=new Re(r.noiseType??0),u=new Re(r.voronoiStyle??0),p=new se(Se(r.smoothness,o)??.5),d=new se(Se(r.seed,o)??0),f=new se(Se(r.highCut,o)??1),h=new se(Se(r.lowCut,o)??0),m=new Re(Se(r.quality,o)??1),y=new ss(s,l,n,u,p,d,f,h,m,a,c);return new Ol(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return _E(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let p=s[c];if(typeof u=="string"||typeof u=="number"&&typeof p=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):pv(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Pl(o.props,r.shared,this)||n:!0;return n}dispose(){if(EE(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof hr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},it=class extends Ni{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Ol=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},Qt=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ii(o.alpha,n)),l=new Re(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ii(o.alphaOverride,n)),p;if(!o.visible)a=new Wo,p={};else if(o.category==="lambert"){a=new bl;let d=new qe(n.color(o.emissive)??0),f=new ut(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new wl;let d=new se(o.shininess??30),f=new qe(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Sl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new ut(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new vl;let d=new se(o.shininess??30),f=new qe(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new ut(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Qt(e,r,o,a,p,n)}get category(){return this.node.category}};function EE(i){let t=i instanceof Ni?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Tr(i){return{alpha:new se(i.alpha??1),mode:new Re(i.mode??0),isMask:new ut(i.isMask??!1)}}function DE(i,t,e,r,o){switch(i.type){case"color":{let n=new qe(r.color??gt),a=Tr(r),s=new hn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new qe(r.color??16777215),a=new se(Se(r.bias,o)??.1),s=new se(Se(r.scale,o)??1),l=new se(Se(r.intensity,o)??2),c=new se(Se(r.factor,o)??1),u=Tr(r),p=new xl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new ke(p.calpha,"f");return new it(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(Se(r.filmThickness,o)??30),a=new se(Se(r.movement,o)??0),s=new Ft(Mi(r.wavelengths,o)),l=new se(Se(r.noiseStrength,o)??0),c=new se(Se(r.noiseScale,o)??1),u=new Ft(Mi(r.offset,o)),p=Tr(r),d=new is(n,a,s,l,c,u,p.alpha,p.isMask),f=new ke(d.calpha,"f");return new it(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(Se(r.thickness??10,o)),a=new se(Se(r.ior??1.5,o)),s=new se(Se(r.roughness??.5,o)),l=Me.transmissionSize,c=Me.transmissionRenderTarget,u=Me.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new ct(d/p,1):new ct(1,p/d),h=Tr(r),m=new as(n,a,s,l,c,u,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Re(r.positioning??0),a;r.colors?a=new Wr(r.colors.length,r.colors):(a=new Wr(10,new us(0,0,0,1)),a.value[1]=new us(1,1,1,1));let s;r.steps?s=new Hr(r.steps.length,r.steps):(s=new Hr(10,1),s.value[0]=0);let l=new Ft(Mi(r.source??new yn(0,0,0),o)),c=new ut(r.isWorldSpace??!0),u=new se(Se(r.noiseStrength??0,o)),p=new se(Se(r.noiseScale??1,o)),d=new rr(r.shadowColor),f=new Ft(Mi(r.offset??new yn(0,0,0),o)),h=Tr(r),m=new ns(n,a,s,l,c,u,p,d,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new qe(r.outlineColor??16777215),a=new qe(r.contourColor??16777215),s=new se(Se(r.outlineWidth??.1,o)),l=new se(Se(r.contourWidth??.1,o)),c=new se(Se(r.outlineThreshold??.1,o)),u=new se(Se(r.contourThreshold??.1,o)),p=new se(Se(r.outlineSmoothing??.1,o)),d=new se(Se(r.contourFrequency??.1,o)),f=new Ft(Mi(r.contourDirection??new yn(0,1,0),o)),h=new ut(r.positionalLines??!1),m=new ut(r.compensation??!0),y=Me.normalRenderTarget,b=Me.normalRenderTargetDepth,v=Me.pixelRatioNode,w=Me.resolution,O=Tr(r),S=new rs(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new ke(S.calpha,"f");return new it(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Re(r.gradientType??0),a=new ut(r.smooth??!1),s=new se(Se(r.near,o)??50),l=new se(Se(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new Ft(Mi(r.origin,o)),d=new Ft(Mi(r.direction,o)),f;r.colors?f=new Wr(r.colors.length,r.colors):(f=new Wr(2,new us(0,0,0,1)),f.value[1]=new us(1,1,1,1));let h;r.steps?h=new Hr(r.steps.length,r.steps):(h=new Hr(2,1),h.value[0]=0);let m=Tr(r),y=new Za(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new ke(y.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(Se(r.scale,o)??1),a=new Ft(Mi(r.size??new yn(100,100,100),o)),s=new se(Se(r.move,o)??1),l=new ct(Xo(r.fA??new $r(1.7,9.2),o)),c=new ct(Xo(r.fB??new $r(8.3,2.8),o)),u=new ct(Xo(r.distortion??new $r(1,1),o)),p=new rr(r.colorA),d=new rr(r.colorB),f=new rr(r.colorC),h=new rr(r.colorD),m=new Re(r.noiseType??0),y=new Re(r.voronoiStyle??0),b=new se(Se(r.highCut,o)??1),v=new se(Se(r.lowCut,o)??0),w=new se(Se(r.smoothness,o)??.5),O=new se(Se(r.seed,o)??.5),S=new Re(r.quality??1),T=Tr(r),M=new ts(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new ke(M.calpha,"f");return new it(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new Ft(r.cnormal??new yn(1,1,1)),a=Tr(r),s=new Ya(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Re(r.gradientType??0),a=new ut(r.smooth??!1),s;r.colors?s=new Wr(r.colors.length,r.colors):(s=new Wr(10,new us(0,0,0,1)),s.value[1]=new us(1,1,1,1));let l;r.steps?l=new Hr(r.steps.length,r.steps):(l=new Hr(10,1),l.value[0]=0);let c=new ct(Xo(r.offset??new $r(0,0),o)),u=new ct(Xo(r.morph??new $r(0,0),o)),p=new se(Se(r.angle??0,o)),d=Tr(r),f=new Ja(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new ke(f.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Re(r.style??0),a=new Re(r.projection??0),s=new Re(["x","y","z"].indexOf(r.axis)??0),l=new se(Se(r.blending??0,o)),c=new ct(Xo(r.offset,o)),u=new rr(r.colorA),p=new rr(r.colorB),d=new ct(Xo(r.frequency??new $r(10,10),o)),f=new se(Se(r.size??.5,o)),h=new se(Se(r.variation??0,o)),m=new se(Se(r.smoothness??.5,o)),y=new se(Se(r.zigzag??0,o)),b=new se(Se(r.rotation??0,o)),v=new ct(Xo(r.vertical??new $r(0,1),o)),w=new ct(Xo(r.horizontal??new $r(0,1),o)),O=new Re(r.sides??6),S=Tr(r),T=new os(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new ke(T.calpha,"f");return new it(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new qe(1,0,0,1),a=Tr(r),s=new hn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function _E(i,t,e,r){let o=dv(e,r);return DE(e,i,t,o,r)}function ph(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Se(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ii(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function ir(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Qu(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var nr=class extends LE{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Zu=class extends nr{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},gn=class extends nr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,Xe.startContext(this),this.reset0(e,r),Xe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new Zu(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){Xe.startContext(this),(this.data!==e||o)&&this.reset0(e,r),Xe.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??Ct.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ni.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Qu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Qu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);if(s?.hasValue(a))if(a==="alpha")this.transparent=Qu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof RE){let p=l[c],d;typeof p=="number"?d=Number(r):p.isVector2&&(d=p.toArray(),u==="x"?d[0]=Number(r):u==="y"&&(d[1]=Number(r))),Pl({[c]:d},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"]),o.data.type==="displace"?o.data.displacementType==="noise"?ir(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):ir(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?ir(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?ir(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?ir(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?ir(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?ir(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?ir(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?ir(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?ir(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(ir([],["size"],o.data,o.id,e.shared,this.uuid),ir(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?ir(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&ir(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof Qt),this.lightLayer===void 0&&(this.lightLayer=new Qt(0,"",{...St.defaultData("light","phong"),visible:!1},new Wo,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Qt);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof it&&s.color instanceof Ci&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(Xe.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=Qu(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ii(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ii(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);Xe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof it?r.color.mask=void 0:r instanceof Qt&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof it&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Qt?n.node.mask=new Rt(r.color,r.alpha,Rt.MUL):n instanceof it&&(n.isMask.value||(n.color.mask=new Rt(r.color,r.alpha,Rt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof it),r=this.layers.findIndex(o=>o instanceof Qt);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof it){if(a.isMask.value)continue;o=new Xa(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof Qt);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof it){if(n.isMask.value)continue;e=new Xa(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Ol);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Rt(r,e[o].position,Rt.ADD),r=new Rt(r,new se(.5).setReadonly(!0),Rt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new qa;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof it){let r=e.params.texture;if(r instanceof fn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(nr.prototype,{properties:{get:function(){return this.fragment.properties}}});var xn=class extends gn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var fv=new Map;function hv(i){if(typeof i=="string")return i;let t=fv.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},fv.set(i,t)),t.url}var BE,mv=new Promise(i=>{BE=i});var yv;mv.then(i=>yv=i);var bn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:hv(t),format:"wav"},this.sound=new yv.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as VE,Vector2 as vn,Path as gv,Shape as zE,ShapeUtils as GE,Color as FE}from"three";var Ju=class{constructor(){this.type="ShapePath";this.color=new FE;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new gv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,N=v.y,I=(T-S)*(M-D)-(N-D)*(w-S),E=(O-w)*(M-D)-(g-M)*(w-S),_=(N-D)*(O-w)-(T-S)*(g-M),L=I/_,V=E/_;if(_===0&&I!==0||L<=0||L>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+L*(O-w)).toPrecision(10),B=+(M+L*(g-M)).toPrecision(10);return{x:U,y:B,t:L}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new vn(D.x,D.y)))}}return v}function s(m,y,b){let v=new vn;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new vn;m.boundingBox.getCenter(O);let S=[new vn(b,O.y),new vn(v,O.y)],T=s(S,m.boundingBox,y);T.sort((E,_)=>E.point.x-_.point.x);let M=[],g=[];T.forEach(E=>{E.identifier===m.identifier?M.push(E):g.push(E)});let D=M[0].point.x,N=[],I=0;for(;I<g.length&&g[I].point.x<D;)N.length>0&&N[N.length-1]===g[I].identifier?N.pop():N.push(g[I].identifier),I++;if(N.push(m.identifier),w==="evenodd"){let E=N.length%2===0,_=N[N.length-2];return{identifier:m.identifier,isHole:E,for:_}}else if(w==="nonzero"){let E=!0,_=null,L=null;for(let V=0;V<N.length;V++){let U=N[V];y[U]&&(E?(L=y[U].isCW,E=!1,_=U):L!==y[U].isCW&&(L=y[U].isCW,E=!0))}return{identifier:m.identifier,isHole:E,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:GE.isClockWise(y),identifier:c++,boundingBox:new VE(new vn(O,v),new vn(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new zE;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new gv;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var fh=!1,bv,hh=new Promise(i=>{bv=i}),xv=!1;var ed;function vv(){if(fh=!0,xv)return;if(ed)return ed;async function i(){let e=await import("./opentype.js");bv(e),xv=!0}return ed=i(),ed}var Tl=class{async load(t,e,r=()=>{}){let{load:o}=await hh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await hh;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function jE(i){return await(await fetch(i)).arrayBuffer()}var UE=new Tl;async function mh(i){let t,e,r=!1;if(i.url?(t=await jE(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(fh){let o=await UE.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as kE,LineCurve as HE,QuadraticBezierCurve as WE}from"three";function qE(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var td=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=mh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=mh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(qE(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2285
|
+
`)}return r}};import{VideoTexture as dE,Texture as pE}from"three";var $u=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){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var uh=class extends $u{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},ch;function uv(i){return typeof i=="string"?i:(ch||(ch=new uh),ch.load(i))}var Xu=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Yu=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var ls=class extends Xu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=uv(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new dE(this.img,void 0,e,e):a=new pE(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var hr=class extends ls{};import{Vector2 as $o,Vector3 as go,Vector4 as Ku}from"three";function Ut(i,t){return t.color(i)}function dv(i,t){switch(i.type){case"fresnel":return mE(i,t);case"gradient":return yE(i,t);case"depth":return gE(i,t);case"normal":return xE(i,t);case"noise":return bE(i,t);case"rainbow":return vE(i,t);case"toon":return SE(i,t);case"outline":return wE(i,t);case"transmission":return PE(i,t);case"color":return hE(i,t);case"pattern":return OE(i,t)}}function fE(i){return{type:i.type}}function qr(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...fE(i),alpha:n,mode:r,isMask:o}}function hE(i,t){return{...qr(i,t),color:Ut(i.color,t)}}function mE(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...qr(i,t),color:Ut(a,t),bias:e,scale:r,intensity:o,factor:n}}function yE(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...qr(i,t),gradientType:e,smooth:r,colors:o.map(c=>new Ku(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new $o(...s),morph:new $o(...l),angle:a}}function gE(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...qr(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new go(...s),direction:l?new go(...l):new go(1,0,0),colors:c.map(d=>d!==void 0?new Ku(d[0],d[1],d[2],d[3]):new Ku(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function xE(i,t){let{cnormal:e}=i;return{...qr(i,t),cnormal:new go(e[0],e[1],e[2])}}function bE(i,t){return{...qr(i,t),scale:i.scale,move:i.move,fA:new $o(...i.fA),fB:new $o(...i.fB),size:new go(...i.size),distortion:new $o(...i.distortion),colorA:Ut(i.colorA,t),colorB:Ut(i.colorB,t),colorC:Ut(i.colorC,t),colorD:Ut(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function vE(i,t){return{...qr(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new go(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new go(...i.offset)}}function SE(i,t){return{...qr(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Ku(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new go(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:Ut(i.shadowColor,t),offset:new go(...i.offset)}}function wE(i,t){return{...qr(i,t),outlineColor:Ut(i.outlineColor,t),contourColor:Ut(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new go(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function PE(i,t){return{...qr(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function OE(i,t){return{...qr(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new $o(...i.offset),colorA:Ut(i.colorA,t),colorB:Ut(i.colorB,t),frequency:new $o(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new $o(...i.vertical),horizontal:new $o(...i.horizontal),sides:i.sides}}var Ai=class extends At{};import{MathUtils as TE,Vector4 as CE}from"three";var AE={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},ME={depth:["colors"]};function IE(i,t,e){if(t==="isMask")return!0;let r=AE[i.type],o=ME[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function dh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function Pl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof hr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof hr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(Se(n.rotation??0,t)??0)*TE.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;dh(e.data.texture.repeat,l)&&(o=!0),s.repeat=cs(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;dh(e.data.texture.offset,l)&&(o=!0),s.offset=cs(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||dh(l,c))&&(o=!0),s.rotation=Se(c,t)??0}s.updateMatrix()}return o}function pv(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(ph(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Ti))switch(o=o||IE(e,n,a),s.constructor){case qe:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Ai?s.value=new At(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case rr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Ai?s.value=new At(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case ct:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Ft:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case Kt:{Pl(a,t,e);break}case Wr:{s.value=a.map(l=>new CE(...l));break}default:{s.value=a;break}}}return o}var Ii=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Se=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Mi=(i,t)=>(i||(i=new yn),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i.z=Se(i.z,t)??0,i),Xo=(i,t)=>(i||(i=new $r),i.x=Se(i.x,t)??0,i.y=Se(i.y,t)??0,i),cs=(i,t)=>{let e=i.map(r=>Se(r,t)??0);return[e[0],e[1]]},Ni=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)ph(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Qt.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new Wu(n),l=new qu(cs(r.texture.repeat,o),cs(r.texture.offset,o),Se(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new Re(r.projection??0),p=new Re(["x","y","z"].indexOf(r.axis)??0),d=new Re(r.side??0),f=new ct(r.size?new $r(...cs(r.size,o)):new $r(100,100)),h=new se(r.blending??0),m=new se(Ii(r.alpha,o)),y=new Re(r.mode??0),b=new ut(r.isMask??!1),v=new Ci(a,s,c,u,p,d,f,h,l,m,y,b),w=new ke(v.calpha,"f");return new it(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Ii(r.alpha,o)),l=new Re(r.mode??0),c=new ut(r.isMask??!1),u=new se((Se(r.texture.rotation??0,o)??0)*NE.DEG2RAD),p=new es(a,s,l,c,u),d=new ke(p.calpha,"f");return new it(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new Ft(new yn(...r.offset.map(b=>Se(b,o)??0))),a=new se(Se(r.scale,o)??10),s=new se(Se(r.intensity,o)??8),l=new se(Se(r.movement,o)??1),c=new Re(r.noiseType??0),u=new Re(r.voronoiStyle??0),p=new se(Se(r.smoothness,o)??.5),d=new se(Se(r.seed,o)??0),f=new se(Se(r.highCut,o)??1),h=new se(Se(r.lowCut,o)??0),m=new Re(Se(r.quality,o)??1),y=new ss(s,l,n,u,p,d,f,h,m,a,c);return new Ol(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return _E(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let p=s[c];if(typeof u=="string"||typeof u=="number"&&typeof p=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):pv(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Pl(o.props,r.shared,this)||n:!0;return n}dispose(){if(EE(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof hr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},it=class extends Ni{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},Ol=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},Qt=class extends Ni{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Ii(o.alpha,n)),l=new Re(o.mode),c=new se(o.bumpMapIntensity),u=new se(Ii(o.alphaOverride,n)),p;if(!o.visible)a=new Wo,p={};else if(o.category==="lambert"){a=new bl;let d=new qe(n.color(o.emissive)??0),f=new ut(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new wl;let d=new se(o.shininess??30),f=new qe(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Sl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new ut(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new vl;let d=new se(o.shininess??30),f=new qe(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new ut(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new Qt(e,r,o,a,p,n)}get category(){return this.node.category}};function EE(i){let t=i instanceof Ni?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Tr(i){return{alpha:new se(i.alpha??1),mode:new Re(i.mode??0),isMask:new ut(i.isMask??!1)}}function DE(i,t,e,r,o){switch(i.type){case"color":{let n=new qe(r.color??gt),a=Tr(r),s=new hn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new qe(r.color??16777215),a=new se(Se(r.bias,o)??.1),s=new se(Se(r.scale,o)??1),l=new se(Se(r.intensity,o)??2),c=new se(Se(r.factor,o)??1),u=Tr(r),p=new xl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new ke(p.calpha,"f");return new it(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(Se(r.filmThickness,o)??30),a=new se(Se(r.movement,o)??0),s=new Ft(Mi(r.wavelengths,o)),l=new se(Se(r.noiseStrength,o)??0),c=new se(Se(r.noiseScale,o)??1),u=new Ft(Mi(r.offset,o)),p=Tr(r),d=new is(n,a,s,l,c,u,p.alpha,p.isMask),f=new ke(d.calpha,"f");return new it(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(Se(r.thickness??10,o)),a=new se(Se(r.ior??1.5,o)),s=new se(Se(r.roughness??.5,o)),l=Me.transmissionSize,c=Me.transmissionRenderTarget,u=Me.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new ct(d/p,1):new ct(1,p/d),h=Tr(r),m=new as(n,a,s,l,c,u,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Re(r.positioning??0),a;r.colors?a=new Wr(r.colors.length,r.colors):(a=new Wr(10,new us(0,0,0,1)),a.value[1]=new us(1,1,1,1));let s;r.steps?s=new Hr(r.steps.length,r.steps):(s=new Hr(10,1),s.value[0]=0);let l=new Ft(Mi(r.source??new yn(0,0,0),o)),c=new ut(r.isWorldSpace??!0),u=new se(Se(r.noiseStrength??0,o)),p=new se(Se(r.noiseScale??1,o)),d=new rr(r.shadowColor),f=new Ft(Mi(r.offset??new yn(0,0,0),o)),h=Tr(r),m=new ns(n,a,s,l,c,u,p,d,f,h.alpha),y=new ke(m.calpha,"f");return new it(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new qe(r.outlineColor??16777215),a=new qe(r.contourColor??16777215),s=new se(Se(r.outlineWidth??.1,o)),l=new se(Se(r.contourWidth??.1,o)),c=new se(Se(r.outlineThreshold??.1,o)),u=new se(Se(r.contourThreshold??.1,o)),p=new se(Se(r.outlineSmoothing??.1,o)),d=new se(Se(r.contourFrequency??.1,o)),f=new Ft(Mi(r.contourDirection??new yn(0,1,0),o)),h=new ut(r.positionalLines??!1),m=new ut(r.compensation??!0),y=Me.normalRenderTarget,b=Me.normalRenderTargetDepth,v=Me.pixelRatioNode,w=Me.resolution,O=Tr(r),S=new rs(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new ke(S.calpha,"f");return new it(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Re(r.gradientType??0),a=new ut(r.smooth??!1),s=new se(Se(r.near,o)??50),l=new se(Se(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new Ft(Mi(r.origin,o)),d=new Ft(Mi(r.direction,o)),f;r.colors?f=new Wr(r.colors.length,r.colors):(f=new Wr(2,new us(0,0,0,1)),f.value[1]=new us(1,1,1,1));let h;r.steps?h=new Hr(r.steps.length,r.steps):(h=new Hr(2,1),h.value[0]=0);let m=Tr(r),y=new Za(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new ke(y.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(Se(r.scale,o)??1),a=new Ft(Mi(r.size??new yn(100,100,100),o)),s=new se(Se(r.move,o)??1),l=new ct(Xo(r.fA??new $r(1.7,9.2),o)),c=new ct(Xo(r.fB??new $r(8.3,2.8),o)),u=new ct(Xo(r.distortion??new $r(1,1),o)),p=new rr(r.colorA),d=new rr(r.colorB),f=new rr(r.colorC),h=new rr(r.colorD),m=new Re(r.noiseType??0),y=new Re(r.voronoiStyle??0),b=new se(Se(r.highCut,o)??1),v=new se(Se(r.lowCut,o)??0),w=new se(Se(r.smoothness,o)??.5),O=new se(Se(r.seed,o)??.5),S=new Re(r.quality??1),T=Tr(r),M=new ts(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new ke(M.calpha,"f");return new it(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new Ft(r.cnormal??new yn(1,1,1)),a=Tr(r),s=new Ya(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Re(r.gradientType??0),a=new ut(r.smooth??!1),s;r.colors?s=new Wr(r.colors.length,r.colors):(s=new Wr(10,new us(0,0,0,1)),s.value[1]=new us(1,1,1,1));let l;r.steps?l=new Hr(r.steps.length,r.steps):(l=new Hr(10,1),l.value[0]=0);let c=new ct(Xo(r.offset??new $r(0,0),o)),u=new ct(Xo(r.morph??new $r(0,0),o)),p=new se(Se(r.angle??0,o)),d=Tr(r),f=new Ja(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new ke(f.calpha,"f");return new it(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Re(r.style??0),a=new Re(r.projection??0),s=new Re(["x","y","z"].indexOf(r.axis)??0),l=new se(Se(r.blending??0,o)),c=new ct(Xo(r.offset,o)),u=new rr(r.colorA),p=new rr(r.colorB),d=new ct(Xo(r.frequency??new $r(10,10),o)),f=new se(Se(r.size??.5,o)),h=new se(Se(r.variation??0,o)),m=new se(Se(r.smoothness??.5,o)),y=new se(Se(r.zigzag??0,o)),b=new se(Se(r.rotation??0,o)),v=new ct(Xo(r.vertical??new $r(0,1),o)),w=new ct(Xo(r.horizontal??new $r(0,1),o)),O=new Re(r.sides??6),S=Tr(r),T=new os(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new ke(T.calpha,"f");return new it(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new qe(1,0,0,1),a=Tr(r),s=new hn(n,a.alpha),l=new ke(s.calpha,"f");return new it(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function _E(i,t,e,r){let o=dv(e,r);return DE(e,i,t,o,r)}function ph(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Se(e.intensity,r)??1)*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Ii(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function ir(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Qu(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var nr=class extends LE{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Zu=class extends nr{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},gn=class extends nr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,Xe.startContext(this),this.reset0(e,r),Xe.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new Zu(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){Xe.startContext(this),(this.data!==e||o)&&this.reset0(e,r),Xe.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??Ct.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Ni.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Qu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Qu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);if(s?.hasValue(a))if(a==="alpha")this.transparent=Qu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof RE){let p=l[c],d;typeof p=="number"?d=Number(r):p.isVector2&&(d=p.toArray(),u==="x"?d[0]=Number(r):u==="y"&&(d[1]=Number(r))),Pl({[c]:d},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):s.setValue(a,r)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"]),o.data.type==="displace"?o.data.displacementType==="noise"?ir(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):ir(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?ir(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?ir(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?ir(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?ir(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?ir(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?ir(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?ir(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?ir(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(ir([],["size"],o.data,o.id,e.shared,this.uuid),ir(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?ir(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&ir(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof Qt),this.lightLayer===void 0&&(this.lightLayer=new Qt(0,"",{...St.defaultData("light","phong"),visible:!1},new Wo,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof Qt);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof it&&s.color instanceof Ci&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(Xe.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=Qu(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Ii(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Ii(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);Xe.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof it?r.color.mask=void 0:r instanceof Qt&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof it&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof Qt?n.node.mask=new Rt(r.color,r.alpha,Rt.MUL):n instanceof it&&(n.isMask.value||(n.color.mask=new Rt(r.color,r.alpha,Rt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof it),r=this.layers.findIndex(o=>o instanceof Qt);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof it){if(a.isMask.value)continue;o=new Xa(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof Qt);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof it){if(n.isMask.value)continue;e=new Xa(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Ol);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Rt(r,e[o].position,Rt.ADD),r=new Rt(r,new se(.5).setReadonly(!0),Rt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new qa;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof it){let r=e.params.texture;if(r instanceof fn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(nr.prototype,{properties:{get:function(){return this.fragment.properties}}});var xn=class extends gn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var fv=new Map;function hv(i){if(typeof i=="string")return i;let t=fv.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},fv.set(i,t)),t.url}var BE,mv=new Promise(i=>{BE=i});var yv;mv.then(i=>yv=i);var bn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:hv(t),format:"wav"},this.sound=new yv.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as VE,Vector2 as vn,Path as gv,Shape as zE,ShapeUtils as GE,Color as FE}from"three";var Ju=class{constructor(){this.type="ShapePath";this.color=new FE;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new gv,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,N=v.y,I=(T-S)*(M-D)-(N-D)*(w-S),E=(O-w)*(M-D)-(g-M)*(w-S),_=(N-D)*(O-w)-(T-S)*(g-M),L=I/_,V=E/_;if(_===0&&I!==0||L<=0||L>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+L*(O-w)).toPrecision(10),B=+(M+L*(g-M)).toPrecision(10);return{x:U,y:B,t:L}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new vn(D.x,D.y)))}}return v}function s(m,y,b){let v=new vn;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new vn;m.boundingBox.getCenter(O);let S=[new vn(b,O.y),new vn(v,O.y)],T=s(S,m.boundingBox,y);T.sort((E,_)=>E.point.x-_.point.x);let M=[],g=[];T.forEach(E=>{E.identifier===m.identifier?M.push(E):g.push(E)});let D=M[0].point.x,N=[],I=0;for(;I<g.length&&g[I].point.x<D;)N.length>0&&N[N.length-1]===g[I].identifier?N.pop():N.push(g[I].identifier),I++;if(N.push(m.identifier),w==="evenodd"){let E=N.length%2===0,_=N[N.length-2];return{identifier:m.identifier,isHole:E,for:_}}else if(w==="nonzero"){let E=!0,_=null,L=null;for(let V=0;V<N.length;V++){let U=N[V];y[U]&&(E?(L=y[U].isCW,E=!1,_=U):L!==y[U].isCW&&(L=y[U].isCW,E=!0))}return{identifier:m.identifier,isHole:E,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:GE.isClockWise(y),identifier:c++,boundingBox:new VE(new vn(O,v),new vn(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new zE;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new gv;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var fh=!1,bv,hh=new Promise(i=>{bv=i}),xv=!1;var ed;function vv(){if(fh=!0,xv)return;if(ed)return ed;async function i(){let e=await import("./opentype.js");bv(e),xv=!0}return ed=i(),ed}var Tl=class{async load(t,e,r=()=>{}){let{load:o}=await hh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await hh;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function jE(i){return await(await fetch(i)).arrayBuffer()}var UE=new Tl;async function mh(i){let t,e,r=!1;if(i.url?(t=await jE(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(fh){let o=await UE.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as kE,LineCurve as HE,QuadraticBezierCurve as WE}from"three";function qE(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var td=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=mh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=mh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(qE(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
2286
2286
|
`,e),p=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],u),f=this.getLineInitialOffsetY(a,t.length,c,n,e.verticalAlign),h=[],m=t.map(v=>[]),y=t.map(v=>[]);for(let v=0;v<t.length;v++){let w=t[v],O={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,O)}catch(N){console.warn(N)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(N){console.warn(N)}let M=this.computeSpaceWidthForLine(t,v,e,r),g=0,D=S[0];D&&e.horizontalAlign===2&&D.leftSideBearing!==void 0&&(d-=D.leftSideBearing*n),this.font?.forEachGlyph(w,d,f,e.fontSize,O,(N,I,E,_,L)=>{let V=N.index===0?`
|
|
2287
2287
|
`:N.unicode?String.fromCharCode(N.unicode):void 0,U=T[g],B=0;if(V===`
|
|
2288
2288
|
`)B=p;else if(V===" ")B=M;else{let q=this.createPath(N,n,I,E,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[v].push([I,E]),m[v].push(B);else{let q=U.replacements.map(W=>(o.glyphs.get(W).advanceWidth??0)*n),j=q.reduce((W,ee)=>W+=ee,0),F=q.map(W=>W/j),H=I;for(let W=0;W<F.length;W++){let ee=B*F[W];y[v].push([H,E]),m[v].push(ee),H+=ee}}g++}),f-=a}let b=[];for(let v=0,w=h.length;v<w;v++)b.push(...h[v].toShapes());return{shapes:b,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,n){return(r===3||r===2)&&o.indexOf(`
|
|
@@ -4376,4 +4376,4 @@ void main() {
|
|
|
4376
4376
|
A = exp(A) * vColor.a;
|
|
4377
4377
|
gl_FragColor = vec4(color.rgb, A);
|
|
4378
4378
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
4379
|
-
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ki},viewport:{type:"v2",value:new ki},basisViewport:{type:"v2",value:new ki},debugColor:{type:"v3",value:new HL},covariancesTextureSize:{type:"v2",value:new ki(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ki(1024,1024)},orthoZoom:{type:"f",value:-1}};return new tR({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ZL,depthTest:!0,depthWrite:!1,side:qL})}static buildGeomtery(e){let r=new kL;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new UL(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new KL().copy(r),s=new Uint32Array(e),l=new YL(s,1,!1);return l.setUsage($L),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new ki(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new ki(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=WL.toHalfFloat(this.covariances[h]);s=new jd(l,n.x,n.y,MS,XL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new jd(l,n.x,n.y,MS,AS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=CS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=Fd(this.centers[y]),c[b+2]=Fd(this.centers[y+1]),c[b+3]=Fd(this.centers[y+2])}let u=new jd(c,a.x,a.y,eR,rR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new jd(d,p,1,JL,AS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Ud.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ud),this.material.uniforms.basisViewport.value.set(2/Ud.x,2/Ud.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var NS,dm=new Promise(i=>{NS=i}),IS=!1;var Hd;function pm(){if(IS)return;if(Hd)return Hd;async function i(){let e=await import("./gaussian-splat-compression.js");NS(e),IS=!0}return Hd=i(),Hd}var _S;dm.then(i=>_S=i);var kl=class{constructor(t={}){Ki(this,"updateView",function(){let t=new ES,e=[],r=new Ns(0,0,-1),o=new Ns(0,0,-1),n=new Ns,a=new Ns;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new ES().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new oR;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Ns().fromArray(t.position)),t.orientation&&(t.orientation=new DS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new _S.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Ns,o=new DS,n=!1,a=1,s,l){this.splatMesh=Hi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=TS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var uR=new lR;uR.wireframe=!0;var LS=new nR,Wd=class extends iR{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Gd;this.invisibleObjects=new Ri("jflkdsafjasdifjaslk",{...eu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{..._o.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=PS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=wS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Zl(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===mi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Mn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Dl(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof Fi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Dl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof sr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Os&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Dl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof sr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{dS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Mn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Qo&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ci(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ql(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Je.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ei&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ci(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of iu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ei&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Nd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ei&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(Li(s)||_l(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Fl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||_l(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Fl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Dl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Fo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Ld(e,r,l);return c instanceof Fi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof tt&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new aR().fromArray(m)),h=new cR(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new sR;return o.setFromPoints(r),o.getCenter(LS),LS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof nr&&e(r.material[o]);else r.material instanceof nr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Qo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new kl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as dR}from"three/examples/jsm/loaders/DRACOLoader.js";var Wi;function RS(i){return Wi||(Wi=new dR,Wi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wi.decoderPending}async function pR(i){if(Wi){let t={attributeIDs:Wi.defaultAttributeIDs,attributeTypes:Wi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Wi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function BS(i,t){let[e,r]=mp(jc.deserialize(new Uint8Array(i)));return su(e),t&&t(e),r.result().data}function VS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function zS(i){for(let t of i){let e=await pR(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as $me}from"three";import{mergeBufferGeometries as Kme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function GS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as FS,ShaderLib as fR}from"three";function jS(i){let t=new Set;return i.traverse(e=>{if(e instanceof ar)if(ft(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(hR(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new FS,specularColor:new FS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fR.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=nv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else mR(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function hR(i){return i.getLayersOfType("transmission").length>0}function mR(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function US(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function kS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as yR}from"three/examples/jsm/utils/BufferGeometryUtils.js";function HS(i){let t=[];return i.traverse(e=>{e instanceof _i&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&GS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=yR(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Mv})}),i}function WS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function qS(i){Object.values(i.shared.materials).forEach(t=>{fm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?fm(e.material):"materials"in e&&e.materials.forEach(r=>{fm(r)})})}function fm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var KS=_s(XS(),1);var YS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hm=class extends xR{load(t,e,r,o=console.error){let n=new gR(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(YS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(YS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await BS(t,qS),r=VS(e);e.version&&(0,KS.default)(e.version,"1.11.6")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&RS(),Bv(e)&&_b(),qv(e)&&vv(),I1(e)&&C1(),kd(e)&&pm()].filter(Boolean)),r.length&&await zS(r);let o=!1,n=new Sn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Wd(e.scene,n);kd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=HS(a),a=jS(a),a=US(a),a=kS(a),a=WS(a),a}};export{hm as default};
|
|
4379
|
+
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ki},viewport:{type:"v2",value:new ki},basisViewport:{type:"v2",value:new ki},debugColor:{type:"v3",value:new HL},covariancesTextureSize:{type:"v2",value:new ki(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ki(1024,1024)},orthoZoom:{type:"f",value:-1}};return new tR({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:ZL,depthTest:!0,depthWrite:!1,side:qL})}static buildGeomtery(e){let r=new kL;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new UL(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new KL().copy(r),s=new Uint32Array(e),l=new YL(s,1,!1);return l.setUsage($L),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new ki(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new ki(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=WL.toHalfFloat(this.covariances[h]);s=new jd(l,n.x,n.y,MS,XL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new jd(l,n.x,n.y,MS,AS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=CS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=Fd(this.centers[y]),c[b+2]=Fd(this.centers[y+1]),c[b+3]=Fd(this.centers[y+2])}let u=new jd(c,a.x,a.y,eR,rR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new jd(d,p,1,JL,AS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Ud.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ud),this.material.uniforms.basisViewport.value.set(2/Ud.x,2/Ud.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var NS,dm=new Promise(i=>{NS=i}),IS=!1;var Hd;function pm(){if(IS)return;if(Hd)return Hd;async function i(){let e=await import("./gaussian-splat-compression.js");NS(e),IS=!0}return Hd=i(),Hd}var _S;dm.then(i=>_S=i);var kl=class{constructor(t={}){Ki(this,"updateView",function(){let t=new ES,e=[],r=new Ns(0,0,-1),o=new Ns(0,0,-1),n=new Ns,a=new Ns;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new ES().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new oR;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Ns().fromArray(t.position)),t.orientation&&(t.orientation=new DS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new _S.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Ns,o=new DS,n=!1,a=1,s,l){this.splatMesh=Hi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=TS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var uR=new lR;uR.wireframe=!0;var LS=new nR,Wd=class extends iR{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Gd;this.invisibleObjects=new Ri("jflkdsafjasdifjaslk",{...eu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{..._o.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=PS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=wS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Zl(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===mi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Mn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Dl(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof Fi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Dl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof sr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Os&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Dl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof sr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{dS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Mn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Qo&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ci(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ql(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Je.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ei&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=ci(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of iu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof ei&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Nd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ei&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(Li(s)||_l(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Fl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||_l(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Fl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Dl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Fo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Ld(e,r,l);return c instanceof Fi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof tt&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new aR().fromArray(m)),h=new cR(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new sR;return o.setFromPoints(r),o.getCenter(LS),LS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof It)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof nr&&e(r.material[o]);else r.material instanceof nr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Qo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new kl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as dR}from"three/examples/jsm/loaders/DRACOLoader.js";var Wi;function RS(i){return Wi||(Wi=new dR,Wi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wi.decoderPending}async function pR(i){if(Wi){let t={attributeIDs:Wi.defaultAttributeIDs,attributeTypes:Wi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Wi.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function BS(i,t){let[e,r]=mp(jc.deserialize(new Uint8Array(i)));return su(e),t&&t(e),r.result().data}function VS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function zS(i){for(let t of i){let e=await pR(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as $me}from"three";import{mergeBufferGeometries as Kme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function GS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as FS,ShaderLib as fR}from"three";function jS(i){let t=new Set;return i.traverse(e=>{if(e instanceof ar)if(ft(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(hR(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new FS,specularColor:new FS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fR.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=nv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else mR(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function hR(i){return i.getLayersOfType("transmission").length>0}function mR(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function US(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function kS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as yR}from"three/examples/jsm/utils/BufferGeometryUtils.js";function HS(i){let t=[];return i.traverse(e=>{e instanceof _i&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&GS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof It&&a.unshift(r.geometry),a.length){let s=yR(a);r instanceof It&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Mv})}),i}function WS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function qS(i){Object.values(i.shared.materials).forEach(t=>{fm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?fm(e.material):"materials"in e&&e.materials.forEach(r=>{fm(r)})})}function fm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var KS=_s(XS(),1);var YS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hm=class extends xR{load(t,e,r,o=console.error){let n=new gR(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(YS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(YS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await BS(t,qS),r=VS(e);e.version&&(0,KS.default)(e.version,"1.11.9")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&RS(),Bv(e)&&_b(),qv(e)&&vv(),I1(e)&&C1(),kd(e)&&pm()].filter(Boolean)),r.length&&await zS(r);let o=!1,n=new Sn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Wd(e.scene,n);kd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=HS(a),a=jS(a),a=US(a),a=kS(a),a=WS(a),a}};export{hm as default};
|
package/package.json
CHANGED