@splinetool/loader 1.9.63 → 1.9.65

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.
@@ -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(i){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${n.proxy.fileId}/external-api/request?uuidexternalapi=${n.proxy.proxyId}`;let u;a!==void 0?u=a:n.method==="POST"&&n.body&&(u=Vl(JSON.parse(n.body),r)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else n.integration?.type==="OpenAI"?t=a:n.method==="POST"&&n.body&&(t=Vl(JSON.parse(n.body),r));let s=await fetch(o,{method:i?"GET":n.method,headers:i?void 0:bM(n),signal:e.signal,body:t});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(n.integration?.type==="OpenAI"){let l=await s.json();return i&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return i&&(l=l.response),l}}var ub=(n,r)=>{if(typeof n=="string"){let e=r.getVariable(n);if(e)return ub(e,r)}return kn.isBoolean(n)?kn.getDisplayedValue(n).toLowerCase():kn.getDisplayedValue(n)},Vl=(n,r)=>n.map((e,t)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(t>0?`
16
16
  `:"")+Vl(e.children,r);if(e.type==="variable"){let o=r.getVariable(e.variableId);if(o!==void 0)return ub(o,r)}}return""}).join("");var OM=new Me.Matrix4,CM=new Me.Matrix4;function TM(n,r,e){let t=[new Me.Vector3,new Me.Vector3,new Me.Vector3],o=[new Me.Vector3,new Me.Vector3,new Me.Vector3];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,a)=>{let s=o[a],l=Me.MathUtils.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new Me.Matrix4().makeBasis(t[0],t[1],t[2])}var db=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=r?.shapeData??Za.create({parameters:tf}).userData.shape;return{path:n.path??Da.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Cu,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new $f(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Me.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},$f=class extends Me.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)||!lb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let F=0;F<c;F++){let k=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);u.push(e[k].clone()),p.push(t[k].clone())}let d=(F,k,H)=>{u[F]=u[F].clone().lerp(u[k],H),p[F]=TM(p[F],p[k],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,d(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let F=u.length-1;u[F].copy(u[0]),p[F].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:C,vertices:A}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new qn(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,M=0;C.sort((F,k)=>F.start-k.start),C.forEach(F=>{F.verticesStart=E,F.verticesCount=F.continuous.reduce((k,H,q)=>k+(q===0||!H?2:1),0),M+=F.verticesCount,E=M});let N=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=uo({windingRule:$e.ODD,elementType:St.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=zf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(C.forEach(F=>{this._extrudeRegion(F,A,p,u,B,W,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,W,B,p[0],u[0],!1),this._closeEnd(_,N+R,W,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 q=U;q<U+g;q++)B.uvs[q*2+1]=1e-4;let F=W.length;W.push(...D.getIndex().array.map(q=>q+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 k=W.length;W.push(...D.getIndex().array.map(q=>q+U)),this.setAttribute("position",new Me.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(B.uvs,2)),this.setIndex(W);let H=OM;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(CM.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(F,k)}else this.setAttribute("position",new Me.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Me.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Me.BufferAttribute(B.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=Wu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.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 t=[],o=e.length,i=this.inputs.path.isClosed,a=new Me.Vector3,s=new Me.Vector3,l=new Me.Vector3,c=new Me.Vector3,u=new Me.Vector3(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=i?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=i?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(),C=O.clone().add(S).normalize();l.copy(C),y===0&&(C.equals(u)||C.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(C).normalize(),g=C.clone().cross(A).normalize();u.copy(g),c.copy(A),y===0&&(a.copy(g),s.copy(C));let D=new Me.Matrix4().makeBasis(A,g,C);t.push(D)}let p=i?s:l,d=i?a:new Me.Vector3(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return t;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<t.length;y++){let b=new Me.Matrix4().makeRotationZ(h*y/t.length);t[y].multiply(b)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Me.Matrix4,p=new Me.Matrix4;return e.forEach((d,f)=>{let h=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(Me.MathUtils.lerp(a,a+s,h)*Me.MathUtils.DEG2RAD);let m=Me.MathUtils.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=$e.ODD){let o=this.inputs.shapeData,i=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=uo({windingRule:t,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=_l}let l;try{l=uo({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Vf}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 C=v,A=O-1,g=v+1,D=o.roundedCurves.length;do{let E=C-v,M=s.vertices[A*2+0],N=s.vertices[A*2+1],_=s.vertices[C*2+0],R=s.vertices[C*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-M,W=R-N,F=Math.sqrt(B*B+W*W);B/=F,W/=F;let k=_-V,H=R-U,q=Math.sqrt(k*k+H*H);k/=q,H/=q,S.normals[E*2+0]=-H,S.normals[E*2+1]=k;let re=s.vertexIndices[C];if(Array.isArray(re))S.continuous[E]=!1;else{let[ee,Y]=o.getCurveIndexFromVertexId(re-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let te=Y===1?ee+1:ee-1;te=(te+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[ee].getTangent(Y),Q=o.roundedCurves[te].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[A,C,g]=[C,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,l=t*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,l){let c=new Me.Vector3,u=new Me.Vector3,p=new Me.Vector3,d=new Me.Vector3,f=new Me.Vector2;o.forEach((m,y)=>{let b=i[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(t[O+0],t[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(t[S+0],t[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(t[S+0],t[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,C=y+O,A=b+O,g=b+v;e.isHole?s.push(S,A,C,S,g,A):s.push(S,C,A,S,A,g),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new Me.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Me.Vector3,d=new Me.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(i,t+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+t,b=f[m+(l?1:2)]+t,v=f[m+(l?2:1)]+t;o.push(y,b,v)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new Me.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=t*m,b=o*m;y<b;y+=m){if(y===t)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(i[3]*s+i[7]*l+i[11]*c+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*c+i[12])*u,f[y+1]=(i[1]*s+i[5]*l+i[9]*c+i[13])*u,f[y+2]=(i[2]*s+i[6]*l+i[10]*c+i[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,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};var Di=require("three"),pb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function fb(){let n=new Di.BufferGeometry;return n.setAttribute("position",new Di.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Di.BufferAttribute(new Uint16Array([]),1)),n}var IM=fb().attributes,MM=12,EM=1,_i=class extends Di.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,IM),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:c,textTransform:u}=e,p=kn.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,f=NM(e,t,d),{shapes:h,charWidths:m,charCoords:y}=t.generateShapes(f,e),b=(typeof o=="number"?o:1)*.5,v=(typeof i=="number"?i:1)*.5,w=h.map(C=>new Xe().fromShape(C,!0));this.vectorShapes=w;let O=w.map(C=>wr.create({shape:C,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?$e.NONZERO:$e.ODD,subdivisions:this.isLowResolution&&a>0?EM:MM}})),S=O.length?(0,pb.mergeBufferGeometries)(O):fb();S.translate(-b,v,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([C,A])=>{this.setAttribute(C,A)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=tr(new Di.BufferGeometry,_i.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}})}get text(){return this.userData.parameters.text??""}};function NM(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
17
17
  `?(t[t.length-1]+=o,o="",i===`
18
- `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var st=require("three");var mb,sd=new Promise(n=>{mb=n}),hb=!1;var ad;function yb(){if(hb)return;if(ad)return ad;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.63/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});mb(l),hb=!0}return ad=n(),ad}var gb=require("three");var DM=["font"];function fn(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Zp(p)&&!DM.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Zp(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=Xe.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new gb.BufferGeometryLoader().parse(i),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(i.type==="SubdivGeometry"){let c=new _t(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new _i(i,r);if(i.type==="InputGeometry")return new _i(i,r);if(i.type==="UIGeometry")return ts.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Xf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Na.defaultData(),100,100);s.shape=c,l=Xf(s)}return l}var xb=require("three"),_M=new xb.Matrix4;function zl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=_M.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var ld=new st.Box3,os=new st.Vector3,Pe;sd.then(n=>{Pe=n});var bb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vb=new Uint32Array([0,1,2,3]),Sb=new Uint8Array([4]),_t=class extends st.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Ln.div(t,o);this.subdividedGeometry&&zl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&zl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(os.fromArray(i));let s=os.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,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=_t.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new st.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(_t.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new st.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;ld.setFromBufferAttribute(t),ld.getCenter(o),e.boundingSphere.radius=o.distanceTo(ld.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ld.getSize(os);let i={width:os.x,height:os.y,depth:os.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Pe.free_bvh(t),Pe.free_subdivision_surface(t));try{a=_t.allocate(e,i)}catch(u){console.error(u,e),a=_t.allocate({positionWASM:bb,indexWASM:vb,verticesPerFaceWASM:Sb},i)}if(Pe.set_destination_refinement_level(a,0),s=_t.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=_t.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=_t.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,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 i=e.shape!==void 0||e.path!==void 0?t.geometry:fn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Zf(i.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}=Jf(s,u,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=bb,i=vb,a=Sb);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,f=i.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=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let O;e?.scaleBaked?.some(C=>C!==1)&&(O=new st.Matrix4().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,t,o,i,a){let s=a?Pe.get_mesh_data2(e,t?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,t?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new st.BufferGeometry;if(O.setIndex(new st.Uint32BufferAttribute(w,1)),O.setAttribute("position",new st.Float32BufferAttribute(f,3)),O.setAttribute("normal",new st.Float32BufferAttribute(m,3)),t){O.setAttribute("faceMap",new st.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new st.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new st.BufferGeometry;h.setAttribute("position",new st.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 st.BufferAttribute(m,3)),h.setIndex(new st.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(i),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Pe.set_destination_refinement_level(e,t);let a=o?Pe.get_topological_data2(e,i?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,i?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var wb=["getX","getY","getZ"];function Zf(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[wb[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[wb[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var cd=new st.Vector3,Yf=new st.Vector3,Kf=new st.Vector3,Qf=new st.Vector3;function Jf(n,r,e,t){let o=[],i=[];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]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){cd.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Yf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Kf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Qf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),Yf.sub(cd).normalize(),Kf.sub(cd).normalize(),Qf.sub(cd).normalize();let l=Yf.cross(Kf).dot(Qf);Math.abs(l)>.005||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[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),i.push(u,u)}return{indices:o,verticesPerFace:i}}var Hr={};fm(Hr,{calcBoolean:()=>VM,calcBooleanTopological:()=>BM,freeMeshSet:()=>kM,getMeshSet:()=>zM,hasOpenEdges:()=>GM,transformMeshSet:()=>FM});var RM,Pb=new Promise(n=>{RM=n});var Gl=require("three");var Ue,ns;Pb.then(n=>Ue=n);function LM(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Zf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Jf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function Ob(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Ue._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ue.HEAPU32.buffer,i,r):new Float32Array(Ue.HEAPF32.buffer,i,r)).set(n,0),i}function Cb(n){switch(n){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function BM(n,r){ns===void 0&&(ns=Ue.init_csg());let e=Ob(n),t=Ue.csg_calc_topological(ns,e,n.length,Cb(r));Ue._free(e);let o=6,i=Ue.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Ue.HEAPU32[i[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[i[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[i[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function VM(n,r,e,t){ns===void 0&&(ns=Ue.init_csg());let o=Ob(n),i=Ue.csg_calc(ns,o,n.length,t,Cb(r));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.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=Ue.HEAPF32.subarray((i>>2)+5,(i>>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},Ue.free_mesh_data(i),h}function zM(n,r,e){if(Ue===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let b=n.userData;i=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+i);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:t,faceIndices:o,nFaces:i}=LM(n,r,e));let a=t.length,s=o.length,l=t.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=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,i);return Ue._free(f),y}function GM(n){return Ue.has_open_edges(n)}function FM(n,r){Ue.transform_csg_mesh(n,r.elements)}function kM(n){Ue.free_csg_mesh(n)}var UM={ConeGeometry:mx,CubeGeometry:yx,CylinderGeometry:hx,DodecahedronGeometry:xx,EllipseGeometry:Za,HelixGeometry:jx,IcosahedronGeometry:Wx,LatheGeometry:qx,NonParametricGeometry:Kx,PolygonGeometry:od,PyramidGeometry:Qx,RectangleGeometry:ts,SphereGeometry:Zx,PlaneGeometry:eb,BackdropGeometry:tb,StarGeometry:nd,TextFrameGeometry:ob,TorusGeometry:nb,TorusKnotGeometry:ab,TriangleGeometry:sb,PathGeometry:db,VectorGeometry:wr},Xf=n=>UM[n.type].create(n);function is(n){return n!==null&&"booleanOp"in n}var as=class extends Ha(ud.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ud.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!is(this.parent)&&this.visible,is(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),is(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof as&&(e.freeBooleanPointer(),is(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&is(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),is(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var dd=new ss.Box3;function Fl(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),f=n.getY(p),h=n.getZ(p);d<i&&(i=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}dd.min.set(i,a,s),dd.max.set(l,c,u),dd.getCenter(t),dd.getSize(o).multiplyScalar(.5)}var jM=new ss.BufferGeometry,HM=new ss.MeshBasicMaterial,Ut=class extends as{constructor(r,e){super(jM,HM),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Fl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bn=require("three");var Br=require("three");var Xb=require("three");var hn=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(hn.uuidContext===null)throw new Error("plz startContext");hn.uuidContext===hn.globalContext?this.uuid="_gid"+hn.uuidContext.nodeContextUuid++:this.uuid="_uid"+hn.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===hn.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),this.uuidContext=null}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},rt=hn;rt.globalContext={nodeContextUuid:0},rt.uuidContext=hn.globalContext;var yo=require("three");var kl=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var eh=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},jt=new eh;var th=require("three");var Tb=require("three"),be=class extends rt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=Tb.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,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var ot=class extends be{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var wt=class extends ot{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof th.Vector2?e:new th.Vector2(e,t)}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,t,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var rh=require("three");var or=class extends ot{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof rh.Vector3?e:new rh.Vector3(e,t,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,t,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var Ab=require("three"),Ht=class extends Ab.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Pr=class extends ot{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,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var WM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ib=/[a-z_0-9]+/gi,J=class extends be{constructor(e,t,o,i,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,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,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=Ib.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&&jt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=jt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||jt.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&&jt.contains(m)&&e.include(jt.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=WM.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Ib);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 qM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,oh=class extends be{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||oh.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=qM.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,t){if(t==="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),t)}generate(e,t,o,i,a){return e.format(this.name,this.getType(e),t)}},qe=oh;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var $M=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var st=require("three");var mb,sd=new Promise(n=>{mb=n}),hb=!1;var ad;function yb(){if(hb)return;if(ad)return ad;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.65/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});mb(l),hb=!0}return ad=n(),ad}var gb=require("three");var DM=["font"];function fn(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Zp(p)&&!DM.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Zp(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=Xe.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new gb.BufferGeometryLoader().parse(i),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(i.type==="SubdivGeometry"){let c=new _t(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new _i(i,r);if(i.type==="InputGeometry")return new _i(i,r);if(i.type==="UIGeometry")return ts.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Xf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Na.defaultData(),100,100);s.shape=c,l=Xf(s)}return l}var xb=require("three"),_M=new xb.Matrix4;function zl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=_M.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var ld=new st.Box3,os=new st.Vector3,Pe;sd.then(n=>{Pe=n});var bb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),vb=new Uint32Array([0,1,2,3]),Sb=new Uint8Array([4]),_t=class extends st.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Ln.div(t,o);this.subdividedGeometry&&zl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&zl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(os.fromArray(i));let s=os.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,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=_t.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new st.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(_t.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new st.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;ld.setFromBufferAttribute(t),ld.getCenter(o),e.boundingSphere.radius=o.distanceTo(ld.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ld.getSize(os);let i={width:os.x,height:os.y,depth:os.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Pe.free_bvh(t),Pe.free_subdivision_surface(t));try{a=_t.allocate(e,i)}catch(u){console.error(u,e),a=_t.allocate({positionWASM:bb,indexWASM:vb,verticesPerFaceWASM:Sb},i)}if(Pe.set_destination_refinement_level(a,0),s=_t.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=_t.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=_t.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,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 i=e.shape!==void 0||e.path!==void 0?t.geometry:fn(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Zf(i.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}=Jf(s,u,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=bb,i=vb,a=Sb);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,f=i.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=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let O;e?.scaleBaked?.some(C=>C!==1)&&(O=new st.Matrix4().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,t,o,i,a){let s=a?Pe.get_mesh_data2(e,t?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,t?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new st.BufferGeometry;if(O.setIndex(new st.Uint32BufferAttribute(w,1)),O.setAttribute("position",new st.Float32BufferAttribute(f,3)),O.setAttribute("normal",new st.Float32BufferAttribute(m,3)),t){O.setAttribute("faceMap",new st.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new st.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new st.BufferGeometry;h.setAttribute("position",new st.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 st.BufferAttribute(m,3)),h.setIndex(new st.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(i),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Pe.set_destination_refinement_level(e,t);let a=o?Pe.get_topological_data2(e,i?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,i?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var wb=["getX","getY","getZ"];function Zf(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[wb[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[wb[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var cd=new st.Vector3,Yf=new st.Vector3,Kf=new st.Vector3,Qf=new st.Vector3;function Jf(n,r,e,t){let o=[],i=[];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]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){cd.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Yf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Kf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Qf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),Yf.sub(cd).normalize(),Kf.sub(cd).normalize(),Qf.sub(cd).normalize();let l=Yf.cross(Kf).dot(Qf);Math.abs(l)>.005||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[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),i.push(u,u)}return{indices:o,verticesPerFace:i}}var Hr={};fm(Hr,{calcBoolean:()=>VM,calcBooleanTopological:()=>BM,freeMeshSet:()=>kM,getMeshSet:()=>zM,hasOpenEdges:()=>GM,transformMeshSet:()=>FM});var RM,Pb=new Promise(n=>{RM=n});var Gl=require("three");var Ue,ns;Pb.then(n=>Ue=n);function LM(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Zf(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Jf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function Ob(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Ue._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ue.HEAPU32.buffer,i,r):new Float32Array(Ue.HEAPF32.buffer,i,r)).set(n,0),i}function Cb(n){switch(n){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function BM(n,r){ns===void 0&&(ns=Ue.init_csg());let e=Ob(n),t=Ue.csg_calc_topological(ns,e,n.length,Cb(r));Ue._free(e);let o=6,i=Ue.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Ue.HEAPU32[i[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[i[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[i[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function VM(n,r,e,t){ns===void 0&&(ns=Ue.init_csg());let o=Ob(n),i=Ue.csg_calc(ns,o,n.length,t,Cb(r));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.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=Ue.HEAPF32.subarray((i>>2)+5,(i>>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},Ue.free_mesh_data(i),h}function zM(n,r,e){if(Ue===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let b=n.userData;i=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+i);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:t,faceIndices:o,nFaces:i}=LM(n,r,e));let a=t.length,s=o.length,l=t.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=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,i);return Ue._free(f),y}function GM(n){return Ue.has_open_edges(n)}function FM(n,r){Ue.transform_csg_mesh(n,r.elements)}function kM(n){Ue.free_csg_mesh(n)}var UM={ConeGeometry:mx,CubeGeometry:yx,CylinderGeometry:hx,DodecahedronGeometry:xx,EllipseGeometry:Za,HelixGeometry:jx,IcosahedronGeometry:Wx,LatheGeometry:qx,NonParametricGeometry:Kx,PolygonGeometry:od,PyramidGeometry:Qx,RectangleGeometry:ts,SphereGeometry:Zx,PlaneGeometry:eb,BackdropGeometry:tb,StarGeometry:nd,TextFrameGeometry:ob,TorusGeometry:nb,TorusKnotGeometry:ab,TriangleGeometry:sb,PathGeometry:db,VectorGeometry:wr},Xf=n=>UM[n.type].create(n);function is(n){return n!==null&&"booleanOp"in n}var as=class extends Ha(ud.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ud.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!is(this.parent)&&this.visible,is(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Hr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),is(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof as&&(e.freeBooleanPointer(),is(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&is(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),is(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var dd=new ss.Box3;function Fl(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),f=n.getY(p),h=n.getZ(p);d<i&&(i=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}dd.min.set(i,a,s),dd.max.set(l,c,u),dd.getCenter(t),dd.getSize(o).multiplyScalar(.5)}var jM=new ss.BufferGeometry,HM=new ss.MeshBasicMaterial,Ut=class extends as{constructor(r,e){super(jM,HM),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Fl(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bn=require("three");var Br=require("three");var Xb=require("three");var hn=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(hn.uuidContext===null)throw new Error("plz startContext");hn.uuidContext===hn.globalContext?this.uuid="_gid"+hn.uuidContext.nodeContextUuid++:this.uuid="_uid"+hn.uuidContext.nodeContextUuid++,this.type=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===hn.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),this.uuidContext=null}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},rt=hn;rt.globalContext={nodeContextUuid:0},rt.uuidContext=hn.globalContext;var yo=require("three");var kl=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var eh=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},jt=new eh;var th=require("three");var Tb=require("three"),be=class extends rt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=Tb.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,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var ot=class extends be{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var wt=class extends ot{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof th.Vector2?e:new th.Vector2(e,t)}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,t,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var rh=require("three");var or=class extends ot{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof rh.Vector3?e:new rh.Vector3(e,t,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,t,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var Ab=require("three"),Ht=class extends Ab.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Pr=class extends ot{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,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var WM=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ib=/[a-z_0-9]+/gi,J=class extends be{constructor(e,t,o,i,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,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,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=Ib.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&&jt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=jt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||jt.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&&jt.contains(m)&&e.include(jt.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=WM.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Ib);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 qM=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,oh=class extends be{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||oh.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=qM.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,t){if(t==="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),t)}generate(e,t,o,i,a){return e.format(this.name,this.getType(e),t)}},qe=oh;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var $M=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),XM=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ls=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 t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=$M.exec(e);if(t){let o=t[2],i;for(;i=XM.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var cs=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};jt.addKeyword("uv",function(){return new cs});jt.addKeyword("uv2",function(){return new cs(1)});var pd=require("three");var Ri=class extends be{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Ri.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case pd.LinearEncoding:return["Linear"];case pd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=Ri.Nodes[this.method],s=e.include(a);if(s===Ri.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=Ri.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Ri.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},hr=Ri;hr.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,t])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Mt,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new go(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2)};for(let n of Object.values(De))n.isRenderGlobal=!0;var Hb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.63/build/ui.wasm"};var mn=class extends rt{constructor(){super("basic");this.nodeType="Basic";this.color=new Je(Nt),this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.previousModelViewMatrix=new nr,this.previouseProjectionMatrix=new nr}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(gd.UniformsUtils.merge([gd.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(`
1876
+ }`,[e,t])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Mt,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new go(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2)};for(let n of Object.values(De))n.isRenderGlobal=!0;var Hb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.65/build/ui.wasm"};var mn=class extends rt{constructor(){super("basic");this.nodeType="Basic";this.color=new Je(Nt),this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.previousModelViewMatrix=new nr,this.previouseProjectionMatrix=new nr}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(gd.UniformsUtils.merge([gd.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 i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4674,4 +4674,4 @@ void main() {
4674
4674
  A = exp(A) * vColor.a;
4675
4675
  gl_FragColor = vec4(color.rgb, A);
4676
4676
  gVelocity = vec4(0.0); // so it is ignored by TAA
4677
- }`,i={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:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let t=new Ce.BufferGeometry;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Ce.BufferAttribute(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(t),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(i=>i.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,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Ce.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.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(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,i.x,i.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,i.x,i.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);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]=tS(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:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){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(t,o),this.material.uniforms.orthoZoom.value=i,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 oS,rm=new Promise(n=>{oS=n}),rS=!1;var pp;function om(){if(rS)return;if(pp)return pp;async function n(){let e=await import("./gaussian-splat-compression.js");oS(e),rS=!0}return pp=n(),pp}var nS;rm.then(n=>nS=n);var vc=class{constructor(r={}){wo(this,"updateView",function(){let r=new xr.Matrix4,e=[],t=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),i=new xr.Vector3,a=new xr.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(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.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=r.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 xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new xr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new xr.Vector3().fromArray(r.position)),r.orientation&&(r.orientation=new xr.Quaternion().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.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 t=e.map(a=>new nS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new xr.Vector3,o=new xr.Quaternion,i=!1,a=1,s,l){this.splatMesh=hi.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),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(r){this.sortWorker=eS(r),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(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var VE=new eo.MeshBasicMaterial;VE.wireframe=!0;var iS=new eo.Vector3,fp=class extends eo.Scene{constructor(e,t){super();this.data=e;this.sharedAssets=t;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 ai("jflkdsafjasdifjaslk",{...Nu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...rn.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Z1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Q1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Zr&&(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 t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Mc(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)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===Vn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Zr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Zr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof $i&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Zr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.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(t=>{this.toExpandCloner.add(t)})}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,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),ii(i)&&uc(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.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 di&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),uc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ii(o)&&(o.freeBooleanPointer(),i instanceof Ar&&i.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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),ii(o)&&(o.invalidateUpstreamBooleanData(),uc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Ar&&i.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 t of this.children)t instanceof Zr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{W1(a,t,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof $i||l instanceof Zr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,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,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof vn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ze.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=Nn(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Pn&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=Nn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Lu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof Pn&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),tp(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Pn&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!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(ii(s)||dc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),xc(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((ii(a)||dc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),xc(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)ze.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ze.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ze.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();uc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)cn.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ze.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=ip(e,t,l);return c instanceof di&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new eo.Box3;return o.setFromPoints(t),o.getCenter(iS),iS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ut)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Cr&&e(t.material[o]);else t.material instanceof Cr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof vn&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new vc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var aS=require("three/examples/jsm/loaders/DRACOLoader.js");var mi;function sS(){return mi||(mi=new aS.DRACOLoader,mi.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),mi.decoderPending}async function zE(n){if(mi){let r={attributeIDs:mi.defaultAttributeIDs,attributeTypes:mi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await mi.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function lS(n,r){let[e,t]=Gp(xu.deserialize(new Uint8Array(n)));return Vu(e),r&&r(e),t.result().data}function cS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function uS(n){for(let r of n){let e=await zE(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}var GE=require("three"),FE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function dS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Sc=require("three");function pS(n){let r=new Set;return n.traverse(e=>{if(e instanceof Tr)if(Ct(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(kE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Sc.Color,specularColor:new Sc.Color});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},Sc.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=jb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else UE(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function kE(n){return n.getLayersOfType("transmission").length>0}function UE(n){let r=0;for(let e of n.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&&(r+=(1-r)*o.value)}}return r<1}function fS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function hS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}var mS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function yS(n){let r=[];return n.traverse(e=>{e instanceof oi&&r.push(e)}),r.forEach(e=>{let t=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&&dS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Ut&&a.unshift(t.geometry),a.length){let s=(0,mS.mergeBufferGeometries)(a);t instanceof Ut&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:dv})}),n}function gS(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function xS(n){Object.values(n.shared.materials).forEach(r=>{nm(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?nm(e.material):"materials"in e&&e.materials.forEach(t=>{nm(t)})})}function nm(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var wS=al(vS(),1);var SS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hp=class extends mp.Loader{load(r,e,t,o=console.error){let i=new mp.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(SS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(SS),i.load(r,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)}},t,o)}async parse(r){let e=await lS(r,xS),t=cS(e);e.version&&(0,wS.default)(e.version,"1.9.63")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&sS(),yv(e)&&yb(),Tv(e)&&tv(),a1(e)&&o1(),dp(e)&&om()].filter(Boolean)),t.length&&await uS(t);let o=!1,i=new Ui(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new fp(e.scene,i);dp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=yS(a),a=pS(a),a=fS(a),a=hS(a),a=gS(a),a}};
4677
+ }`,i={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:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let t=new Ce.BufferGeometry;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new Ce.BufferAttribute(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(t),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(i=>i.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,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Ce.Vector2(4096,1024);for(;i.x*i.y*2<o*6;)i.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(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,i.x,i.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,i.x,i.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);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]=tS(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:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){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(t,o),this.material.uniforms.orthoZoom.value=i,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 oS,rm=new Promise(n=>{oS=n}),rS=!1;var pp;function om(){if(rS)return;if(pp)return pp;async function n(){let e=await import("./gaussian-splat-compression.js");oS(e),rS=!0}return pp=n(),pp}var nS;rm.then(n=>nS=n);var vc=class{constructor(r={}){wo(this,"updateView",function(){let r=new xr.Matrix4,e=[],t=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),i=new xr.Vector3,a=new xr.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(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.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=r.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 xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new xr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new xr.Vector3().fromArray(r.position)),r.orientation&&(r.orientation=new xr.Quaternion().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.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 t=e.map(a=>new nS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new xr.Vector3,o=new xr.Quaternion,i=!1,a=1,s,l){this.splatMesh=hi.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),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(r){this.sortWorker=eS(r),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(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var VE=new eo.MeshBasicMaterial;VE.wireframe=!0;var iS=new eo.Vector3,fp=class extends eo.Scene{constructor(e,t){super();this.data=e;this.sharedAssets=t;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 ai("jflkdsafjasdifjaslk",{...Nu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...rn.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Z1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Q1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Zr&&(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 t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Mc(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)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===Vn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Zr&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Zr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof $i&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Zr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.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(t=>{this.toExpandCloner.add(t)})}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,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),ii(i)&&uc(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.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 di&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),uc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ii(o)&&(o.freeBooleanPointer(),i instanceof Ar&&i.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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),ii(o)&&(o.invalidateUpstreamBooleanData(),uc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Ar&&i.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 t of this.children)t instanceof Zr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{W1(a,t,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof $i||l instanceof Zr)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,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,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof vn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ze.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=Nn(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Pn&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=Nn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Lu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof Pn&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),tp(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Pn&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!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(ii(s)||dc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),xc(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((ii(a)||dc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),xc(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)ze.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ze.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ze.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();uc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)cn.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ze.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=ip(e,t,l);return c instanceof di&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new eo.Box3;return o.setFromPoints(t),o.getCenter(iS),iS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ut)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Cr&&e(t.material[o]);else t.material instanceof Cr&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof vn&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new vc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var aS=require("three/examples/jsm/loaders/DRACOLoader.js");var mi;function sS(){return mi||(mi=new aS.DRACOLoader,mi.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),mi.decoderPending}async function zE(n){if(mi){let r={attributeIDs:mi.defaultAttributeIDs,attributeTypes:mi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await mi.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function lS(n,r){let[e,t]=Gp(xu.deserialize(new Uint8Array(n)));return Vu(e),r&&r(e),t.result().data}function cS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function uS(n){for(let r of n){let e=await zE(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}var GE=require("three"),FE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function dS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Sc=require("three");function pS(n){let r=new Set;return n.traverse(e=>{if(e instanceof Tr)if(Ct(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(kE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Sc.Color,specularColor:new Sc.Color});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},Sc.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=jb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else UE(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function kE(n){return n.getLayersOfType("transmission").length>0}function UE(n){let r=0;for(let e of n.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&&(r+=(1-r)*o.value)}}return r<1}function fS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function hS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}var mS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function yS(n){let r=[];return n.traverse(e=>{e instanceof oi&&r.push(e)}),r.forEach(e=>{let t=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&&dS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Ut&&a.unshift(t.geometry),a.length){let s=(0,mS.mergeBufferGeometries)(a);t instanceof Ut&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:dv})}),n}function gS(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function xS(n){Object.values(n.shared.materials).forEach(r=>{nm(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?nm(e.material):"materials"in e&&e.materials.forEach(t=>{nm(t)})})}function nm(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var wS=al(vS(),1);var SS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hp=class extends mp.Loader{load(r,e,t,o=console.error){let i=new mp.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(SS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(SS),i.load(r,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)}},t,o)}async parse(r){let e=await lS(r,xS),t=cS(e);e.version&&(0,wS.default)(e.version,"1.9.65")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&sS(),yv(e)&&yb(),Tv(e)&&tv(),a1(e)&&o1(),dp(e)&&om()].filter(Boolean)),t.length&&await uS(t);let o=!1,i=new Ui(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new fp(e.scene,i);dp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=yS(a),a=pS(a),a=fS(a),a=hS(a),a=gS(a),a}};
@@ -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(i){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${n.proxy.fileId}/external-api/request?uuidexternalapi=${n.proxy.proxyId}`;let u;a!==void 0?u=a:n.method==="POST"&&n.body&&(u=pl(JSON.parse(n.body),r)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else n.integration?.type==="OpenAI"?t=a:n.method==="POST"&&n.body&&(t=pl(JSON.parse(n.body),r));let s=await fetch(o,{method:i?"GET":n.method,headers:i?void 0:Z3(n),signal:e.signal,body:t});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(n.integration?.type==="OpenAI"){let l=await s.json();return i&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return i&&(l=l.response),l}}var Ob=(n,r)=>{if(typeof n=="string"){let e=r.getVariable(n);if(e)return Ob(e,r)}return vn.isBoolean(n)?vn.getDisplayedValue(n).toLowerCase():vn.getDisplayedValue(n)},pl=(n,r)=>n.map((e,t)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(t>0?`
16
16
  `:"")+pl(e.children,r);if(e.type==="variable"){let o=r.getVariable(e.variableId);if(o!==void 0)return Ob(o,r)}}return""}).join("");var nE=new li,iE=new li;function aE(n,r,e){let t=[new Dt,new Dt,new Dt],o=[new Dt,new Dt,new Dt];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,a)=>{let s=o[a],l=Gu.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new li().makeBasis(t[0],t[1],t[2])}var Ab=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=r?.shapeData??Na.create({parameters:Dp}).userData.shape;return{path:n.path??da.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Kc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new zf(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Tb,{userData:{...n,type:"PathGeometry"}})}},zf=class extends Tb{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)||!wb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let F=0;F<c;F++){let k=this.inputs.path.isClosed?(F+s)%e.length:Math.min(F+s,e.length-1);u.push(e[k].clone()),p.push(t[k].clone())}let d=(F,k,H)=>{u[F]=u[F].clone().lerp(u[k],H),p[F]=aE(p[F],p[k],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,d(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let F=u.length-1;u[F].copy(u[0]),p[F].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:C,vertices:A}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new On(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,M=0;C.sort((F,k)=>F.start-k.start),C.forEach(F=>{F.verticesStart=E,F.verticesCount=F.continuous.reduce((k,H,q)=>k+(q===0||!H?2:1),0),M+=F.verticesCount,E=M});let N=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=kr({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Pf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},W=[];if(C.forEach(F=>{this._extrudeRegion(F,A,p,u,B,W,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,W,B,p[0],u[0],!1),this._closeEnd(_,N+R,W,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 q=U;q<U+g;q++)B.uvs[q*2+1]=1e-4;let F=W.length;W.push(...D.getIndex().array.map(q=>q+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 k=W.length;W.push(...D.getIndex().array.map(q=>q+U)),this.setAttribute("position",new Ba(B.positions,3)),this.setAttribute("normal",new Ba(B.normals,3)),this.setAttribute("uv",new Ba(B.uvs,2)),this.setIndex(W);let H=nE;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(iE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(F,k)}else this.setAttribute("position",new Ba(B.positions,3)),this.setAttribute("normal",new Ba(B.normals,3)),this.setAttribute("uv",new Ba(B.uvs,2)),this.setIndex(W)}_extractPathPoints(){let t=gu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.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 t=[],o=e.length,i=this.inputs.path.isClosed,a=new Dt,s=new Dt,l=new Dt,c=new Dt,u=new Dt(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=i?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=i?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(),C=O.clone().add(S).normalize();l.copy(C),y===0&&(C.equals(u)||C.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(C).normalize(),g=C.clone().cross(A).normalize();u.copy(g),c.copy(A),y===0&&(a.copy(g),s.copy(C));let D=new li().makeBasis(A,g,C);t.push(D)}let p=i?s:l,d=i?a:new Dt(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return t;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<t.length;y++){let b=new li().makeRotationZ(h*y/t.length);t[y].multiply(b)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new li,p=new li;return e.forEach((d,f)=>{let h=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));u.makeRotationZ(Gu.lerp(a,a+s,h)*Gu.DEG2RAD);let m=Gu.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,t=Fe.ODD){let o=this.inputs.shapeData,i=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=kr({windingRule:t,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=sl}let l;try{l=kr({windingRule:Fe.ODD,elementType:st.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 C=v,A=O-1,g=v+1,D=o.roundedCurves.length;do{let E=C-v,M=s.vertices[A*2+0],N=s.vertices[A*2+1],_=s.vertices[C*2+0],R=s.vertices[C*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-M,W=R-N,F=Math.sqrt(B*B+W*W);B/=F,W/=F;let k=_-V,H=R-U,q=Math.sqrt(k*k+H*H);k/=q,H/=q,S.normals[E*2+0]=-H,S.normals[E*2+1]=k;let re=s.vertexIndices[C];if(Array.isArray(re))S.continuous[E]=!1;else{let[ee,Y]=o.getCurveIndexFromVertexId(re-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let te=Y===1?ee+1:ee-1;te=(te+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[ee].getTangent(Y),Q=o.roundedCurves[te].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[A,C,g]=[C,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,l=t*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,l){let c=new Dt,u=new Dt,p=new Dt,d=new Dt,f=new Cb;o.forEach((m,y)=>{let b=i[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(t[O+0],t[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(t[S+0],t[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(t[S+0],t[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,C=y+O,A=b+O,g=b+v;e.isHole?s.push(S,A,C,S,g,A):s.push(S,C,A,S,A,g),v++}}}_closeEnd(e,t,o,i,a,s,l){let c=e.vertexCount,u=new Dt(0,0,l?-1:1).applyMatrix4(a),p=new Dt,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(i,t+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+t,b=f[m+(l?1:2)]+t,v=f[m+(l?2:1)]+t;o.push(y,b,v)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new oE().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=t*m,b=o*m;y<b;y+=m){if(y===t)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(i[3]*s+i[7]*l+i[11]*c+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*c+i[12])*u,f[y+1]=(i[1]*s+i[5]*l+i[9]*c+i[13])*u,f[y+2]=(i[2]*s+i[6]*l+i[10]*c+i[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,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Ib,BufferGeometry as Gf}from"three";import{mergeBufferGeometries as lE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Mb(){let n=new Gf;return n.setAttribute("position",new Ib(new Float32Array([]),3)),n.setIndex(new Ib(new Uint16Array([]),1)),n}var cE=Mb().attributes,uE=12,dE=1,ci=class extends Gf{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,cE),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:c,textTransform:u}=e,p=vn.getDisplayedValue(c),d=u===2?p.toUpperCase():u===3?p.toLowerCase():p,f=pE(e,t,d),{shapes:h,charWidths:m,charCoords:y}=t.generateShapes(f,e),b=(typeof o=="number"?o:1)*.5,v=(typeof i=="number"?i:1)*.5,w=h.map(C=>new ke().fromShape(C,!0));this.vectorShapes=w;let O=w.map(C=>er.create({shape:C,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?Fe.NONZERO:Fe.ODD,subdivisions:this.isLowResolution&&a>0?dE:uE}})),S=O.length?lE(O):Mb();S.translate(-b,v,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([C,A])=>{this.setAttribute(C,A)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=Bt(new Gf,ci.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}})}get text(){return this.userData.parameters.text??""}};function pE(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
17
17
  `?(t[t.length-1]+=o,o="",i===`
18
- `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}import{BufferGeometry as kf,BufferAttribute as _b,Uint32BufferAttribute as Uf,Float32BufferAttribute as jf,Matrix4 as gE,Vector3 as hl,Sphere as xE,Box3 as bE,BoxGeometry as vE}from"three";var Nb,ku=new Promise(n=>{Nb=n}),Eb=!1;var Fu;function Db(){if(Eb)return;if(Fu)return Fu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.63/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Nb(l),Eb=!0}return Fu=n(),Fu}import{BufferGeometryLoader as fE}from"three";var hE=["font"];function jo(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Mp(p)&&!hE.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Mp(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=ke.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fE().parse(i),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(i.type==="SubdivGeometry"){let c=new gt(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new ci(i,r);if(i.type==="InputGeometry")return new ci(i,r);if(i.type==="UIGeometry")return La.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Ff(s)}catch(c){console.error(c)}if(!l){let c=ke.createFromState(ua.defaultData(),100,100);s.shape=c,l=Ff(s)}return l}import{Matrix4 as mE}from"three";var yE=new mE;function fl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=yE.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Uu=new bE,Va=new hl,Se;ku.then(n=>{Se=n});var Rb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Lb=new Uint32Array([0,1,2,3]),Bb=new Uint8Array([4]),gt=class extends kf{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=hn.div(t,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Va.fromArray(i));let s=Va.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,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=gt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new xE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Uu.setFromBufferAttribute(t),Uu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Uu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Uu.getSize(Va);let i={width:Va.x,height:Va.y,depth:Va.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=gt.allocate(e,i)}catch(u){console.error(u,e),a=gt.allocate({positionWASM:Rb,indexWASM:Lb,verticesPerFaceWASM:Bb},i)}if(Se.set_destination_refinement_level(a,0),s=gt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=gt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=gt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,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 i=e.shape!==void 0||e.path!==void 0?t.geometry:jo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(i.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,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Rb,i=Lb,a=Bb);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,f=i.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=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let O;e?.scaleBaked?.some(C=>C!==1)&&(O=new gE().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,t,o,i,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new kf;if(O.setIndex(new Uf(w,1)),O.setAttribute("position",new jf(f,3)),O.setAttribute("normal",new jf(m,3)),t){O.setAttribute("faceMap",new Uf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new _b(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new kf;h.setAttribute("position",new jf(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 _b(m,3)),h.setIndex(new Uf(f,1)),Se.free_wireframe_data_for_base_level(i),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,i?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,i?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Vb=["getX","getY","getZ"];function $f(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[Vb[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[Vb[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var ju=new hl,Hf=new hl,Wf=new hl,qf=new hl;function Xf(n,r,e,t){let o=[],i=[];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]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){ju.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Hf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Wf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),qf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[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||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[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),i.push(u,u)}return{indices:o,verticesPerFace:i}}var Sr={};Sw(Sr,{calcBoolean:()=>CE,calcBooleanTopological:()=>OE,freeMeshSet:()=>ME,getMeshSet:()=>TE,hasOpenEdges:()=>AE,transformMeshSet:()=>IE});var SE,zb=new Promise(n=>{SE=n});import{Float32BufferAttribute as Gb,Sphere as wE}from"three";var Be,za;zb.then(n=>Be=n);function PE(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=$f(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Xf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function Fb(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Be._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Be.HEAPU32.buffer,i,r):new Float32Array(Be.HEAPF32.buffer,i,r)).set(n,0),i}function kb(n){switch(n){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function OE(n,r){za===void 0&&(za=Be.init_csg());let e=Fb(n),t=Be.csg_calc_topological(za,e,n.length,kb(r));Be._free(e);let o=6,i=Be.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Be.HEAPU32[i[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[i[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[i[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function CE(n,r,e,t){za===void 0&&(za=Be.init_csg());let o=Fb(n),i=Be.csg_calc(za,o,n.length,t,kb(r));Be._free(o);let a=5,s=Be.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Gb(p,3)),e.setAttribute("normal",new Gb(f,3));let m=Be.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new wE),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},Be.free_mesh_data(i),h}function TE(n,r,e){if(Be===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let b=n.userData;i=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+i);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:t,faceIndices:o,nFaces:i}=PE(n,r,e));let a=t.length,s=o.length,l=t.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=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,i);return Be._free(f),y}function AE(n){return Be.has_open_edges(n)}function IE(n,r){Be.transform_csg_mesh(n,r.elements)}function ME(n){Be.free_csg_mesh(n)}var EE={ConeGeometry:wx,CubeGeometry:Px,CylinderGeometry:Sx,DodecahedronGeometry:Ox,EllipseGeometry:Na,HelixGeometry:eb,IcosahedronGeometry:tb,LatheGeometry:rb,NonParametricGeometry:pb,PolygonGeometry:Bu,PyramidGeometry:fb,RectangleGeometry:La,SphereGeometry:mb,PlaneGeometry:yb,BackdropGeometry:gb,StarGeometry:Vu,TextFrameGeometry:xb,TorusGeometry:bb,TorusKnotGeometry:vb,TriangleGeometry:Sb,PathGeometry:Ab,VectorGeometry:er},Ff=n=>EE[n.type].create(n);function Ga(n){return n!==null&&"booleanOp"in n}var Fa=class extends Pa(DE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new NE}updateVisible(e){super.updateVisible(e),this.visible=!Ga(this.parent)&&this.visible,Ga(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ga(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Fa&&(e.freeBooleanPointer(),Ga(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ga(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ga(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Hu=new _E;function ml(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),f=n.getY(p),h=n.getZ(p);d<i&&(i=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Hu.min.set(i,a,s),Hu.max.set(l,c,u),Hu.getCenter(t),Hu.getSize(o).multiplyScalar(.5)}var BE=new RE,VE=new LE,Ct=class extends Fa{constructor(r,e){super(BE,VE),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ml(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as pD,Matrix4 as fD,Sphere as Vv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Bv,MathUtils as wh,Vector3 as Ph}from"three";import{ShaderMaterial as LN}from"three";var Ho=class{constructor(r){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=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),this.uuidContext=null}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},qe=Ho;qe.globalContext={nodeContextUuid:0},qe.uuidContext=Ho.globalContext;import{CubeReflectionMapping as XE,CubeRefractionMapping as YE,CubeUVReflectionMapping as KE,LinearEncoding as Qb,sRGBEncoding as QE}from"three";var yl=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Tt=new Yf;import{Vector2 as Ub}from"three";import{MathUtils as zE}from"three";var ge=class extends qe{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=zE.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,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var $e=class extends ge{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var lt=class extends $e{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Ub?e:new Ub(e,t)}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,t,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as jb}from"three";var Gt=class extends $e{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof jb?e:new jb(e,t,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,t,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as GE}from"three";var At=class extends GE{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var tr=class extends $e{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,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var FE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Hb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,t,o,i,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,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,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=Hb.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&&Tt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Tt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Tt.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&&Tt.contains(m)&&e.include(Tt.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=FE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Hb);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 kE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends ge{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=kE.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,t){if(t==="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),t)}generate(e,t,o,i,a){return e.format(this.name,this.getType(e),t)}},Ge=Kf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var UE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}import{BufferGeometry as kf,BufferAttribute as _b,Uint32BufferAttribute as Uf,Float32BufferAttribute as jf,Matrix4 as gE,Vector3 as hl,Sphere as xE,Box3 as bE,BoxGeometry as vE}from"three";var Nb,ku=new Promise(n=>{Nb=n}),Eb=!1;var Fu;function Db(){if(Eb)return;if(Fu)return Fu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.65/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});Nb(l),Eb=!0}return Fu=n(),Fu}import{BufferGeometryLoader as fE}from"three";var hE=["font"];function jo(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let c of a){let u=i;for(let p of c)u=u[p];for(o in u){let p=u[o];Mp(p)&&!hE.includes(o)&&(u[o]=r.getVariable(p,[t.uuid,"geometry",...c,o]),Mp(u[o])&&(u[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let c=ke.createFromState(i.shape,i.width,i.height);s.shape=c}else if(i.type==="NonParametricGeometry"){if(i.data.groups&&i.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fE().parse(i),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(i.type==="SubdivGeometry"){let c=new gt(i,e);return c.data=n,c}else{if(i.type==="TextGeometry")return new ci(i,r);if(i.type==="InputGeometry")return new ci(i,r);if(i.type==="UIGeometry")return La.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Ff(s)}catch(c){console.error(c)}if(!l){let c=ke.createFromState(ua.defaultData(),100,100);s.shape=c,l=Ff(s)}return l}import{Matrix4 as mE}from"three";var yE=new mE;function fl(n,r,e,t){let o=n.position.array,i=n.normal.array,a=yE.makeScale(r,e,t).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=r,o[u+1]*=e,o[u+2]*=t,s=i[u],l=i[u+1],c=i[u+2],i[u]=a[0]*s+a[4]*l+a[8]*c,i[u+1]=a[1]*s+a[5]*l+a[9]*c,i[u+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Uu=new bE,Va=new hl,Se;ku.then(n=>{Se=n});var Rb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Lb=new Uint32Array([0,1,2,3]),Bb=new Uint8Array([4]),gt=class extends kf{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=hn.div(t,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Va.fromArray(i));let s=Va.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,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=gt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(gt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new xE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Uu.setFromBufferAttribute(t),Uu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Uu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Uu.getSize(Va);let i={width:Va.x,height:Va.y,depth:Va.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),t&&(Se.free_bvh(t),Se.free_subdivision_surface(t));try{a=gt.allocate(e,i)}catch(u){console.error(u,e),a=gt.allocate({positionWASM:Rb,indexWASM:Lb,verticesPerFaceWASM:Bb},i)}if(Se.set_destination_refinement_level(a,0),s=gt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=gt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=gt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,t,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 i=e.shape!==void 0||e.path!==void 0?t.geometry:jo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(i.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,i,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=Rb,i=Lb,a=Bb);let c=o.length,u=i.length,p=a.length,d=o.length+s.length+l.length,f=i.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=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let O;e?.scaleBaked?.some(C=>C!==1)&&(O=new gE().makeScale(...e.scaleBaked)),t&&(O?O.premultiply(t):O=t);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,t,o,i,a){let s=a?Se.get_mesh_data2(e,t?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,t?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,i===void 0){let O=new kf;if(O.setIndex(new Uf(w,1)),O.setAttribute("position",new jf(f,3)),O.setAttribute("normal",new jf(m,3)),t){O.setAttribute("faceMap",new Uf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new _b(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(t===void 0){let h=new kf;h.setAttribute("position",new jf(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 _b(m,3)),h.setIndex(new Uf(f,1)),Se.free_wireframe_data_for_base_level(i),h}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||Se.set_destination_refinement_level(e,t);let a=o?Se.get_topological_data2(e,i?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,i?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Vb=["getX","getY","getZ"];function $f(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let c=0;c<t;c++){let u=r?r.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(n[Vb[d]](u)*s)},`;if(p in e)i.push(e[p]);else{for(let d=0;d<3;d++)a.push(n[Vb[d]](u));e[p]=o,i.push(o),o++}}let l=[];for(let c=0;c<i.length;c+=3)i[c]===i[c+1]||i[c]===i[c+2]||i[c+1]===i[c+2]||l.push(i[c],i[c+1],i[c+2]);return{positions:a,triIndices:l}}var ju=new hl,Hf=new hl,Wf=new hl,qf=new hl;function Xf(n,r,e,t){let o=[],i=[];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]);n.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),o.push(p++);return i.push(p),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&l++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&l++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&l++,l===3)break}if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){ju.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Hf.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Wf.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),qf.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[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||t&&t.some((c,u)=>u%2===1?!1:s>=t[u]&&s<t[u+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<n.length;p+=3,d++)n[p+2]===0&&(l.push(d),u++),n[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),i.push(u,u)}return{indices:o,verticesPerFace:i}}var Sr={};Sw(Sr,{calcBoolean:()=>CE,calcBooleanTopological:()=>OE,freeMeshSet:()=>ME,getMeshSet:()=>TE,hasOpenEdges:()=>AE,transformMeshSet:()=>IE});var SE,zb=new Promise(n=>{SE=n});import{Float32BufferAttribute as Gb,Sphere as wE}from"three";var Be,za;zb.then(n=>Be=n);function PE(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=$f(n.getAttribute("position"),o),s;if(r&&e){let{indices:l,verticesPerFace:c}=Xf(i,a,n);s=c.length,t=[];for(let u=0,p=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[p++])}}else{let l=a.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=a[c++],t[u++]=a[c++],t[u++]=a[c++]}return{positions:i,faceIndices:t,nFaces:s}}function Fb(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=Be._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Be.HEAPU32.buffer,i,r):new Float32Array(Be.HEAPF32.buffer,i,r)).set(n,0),i}function kb(n){switch(n){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+n)}}function OE(n,r){za===void 0&&(za=Be.init_csg());let e=Fb(n),t=Be.csg_calc_topological(za,e,n.length,kb(r));Be._free(e);let o=6,i=Be.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,l=Be.HEAPU32[i[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[i[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[i[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(t),{positions:c,indices:p,verticesPerFace:f}}function CE(n,r,e,t){za===void 0&&(za=Be.init_csg());let o=Fb(n),i=Be.csg_calc(za,o,n.length,t,kb(r));Be._free(o);let a=5,s=Be.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Gb(p,3)),e.setAttribute("normal",new Gb(f,3));let m=Be.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new wE),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},Be.free_mesh_data(i),h}function TE(n,r,e){if(Be===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let b=n.userData;i=b.verticesPerFace.length,t=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+i);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:t,faceIndices:o,nFaces:i}=PE(n,r,e));let a=t.length,s=o.length,l=t.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=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(t,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,i);return Be._free(f),y}function AE(n){return Be.has_open_edges(n)}function IE(n,r){Be.transform_csg_mesh(n,r.elements)}function ME(n){Be.free_csg_mesh(n)}var EE={ConeGeometry:wx,CubeGeometry:Px,CylinderGeometry:Sx,DodecahedronGeometry:Ox,EllipseGeometry:Na,HelixGeometry:eb,IcosahedronGeometry:tb,LatheGeometry:rb,NonParametricGeometry:pb,PolygonGeometry:Bu,PyramidGeometry:fb,RectangleGeometry:La,SphereGeometry:mb,PlaneGeometry:yb,BackdropGeometry:gb,StarGeometry:Vu,TextFrameGeometry:xb,TorusGeometry:bb,TorusKnotGeometry:vb,TriangleGeometry:Sb,PathGeometry:Ab,VectorGeometry:er},Ff=n=>EE[n.type].create(n);function Ga(n){return n!==null&&"booleanOp"in n}var Fa=class extends Pa(DE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new NE}updateVisible(e){super.updateVisible(e),this.visible=!Ga(this.parent)&&this.visible,Ga(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ga(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Fa&&(e.freeBooleanPointer(),Ga(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ga(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ga(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Hu=new _E;function ml(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=r;p<e;p++){let d=n.getX(p),f=n.getY(p),h=n.getZ(p);d<i&&(i=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Hu.min.set(i,a,s),Hu.max.set(l,c,u),Hu.getCenter(t),Hu.getSize(o).multiplyScalar(.5)}var BE=new RE,VE=new LE,Ct=class extends Fa{constructor(r,e){super(BE,VE),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ml(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as pD,Matrix4 as fD,Sphere as Vv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Bv,MathUtils as wh,Vector3 as Ph}from"three";import{ShaderMaterial as LN}from"three";var Ho=class{constructor(r){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=r,this.name=""}static startContext(r){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=r:console.error("Can't start context twice")}static endContext(r){this.uuidContext!==r&&console.error("Can't end context twice"),this.uuidContext=null}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,a){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},qe=Ho;qe.globalContext={nodeContextUuid:0},qe.uuidContext=Ho.globalContext;import{CubeReflectionMapping as XE,CubeRefractionMapping as YE,CubeUVReflectionMapping as KE,LinearEncoding as Qb,sRGBEncoding as QE}from"three";var yl=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},Tt=new Yf;import{Vector2 as Ub}from"three";import{MathUtils as zE}from"three";var ge=class extends qe{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=zE.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,t),this.generate(e,t,o)):super.build(e,t,o);if(a)return s.name=s.name||super.build(e,t,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,t);{c=super.generate(e,t,o,s.output,i);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var $e=class extends ge{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,t)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,t))}};var lt=class extends $e{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Ub?e:new Ub(e,t)}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,t,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as jb}from"three";var Gt=class extends $e{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof jb?e:new jb(e,t,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,t,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as GE}from"three";var At=class extends GE{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var tr=class extends $e{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,t,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var FE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Hb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,t,o,i,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,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,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=Hb.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&&Tt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=Tt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||Tt.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&&Tt.contains(m)&&e.include(Tt.get(m))}return t==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=FE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Hb);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 kE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends ge{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,a){this.src=e||"";let s,l,c="",u=kE.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,t){if(t==="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),t)}generate(e,t,o,i,a){return e.format(this.name,this.getType(e),t)}},Ge=Kf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var UE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),jE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ka=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 t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=UE.exec(e);if(t){let o=t[2],i;for(;i=jE.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ua=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};Tt.addKeyword("uv",function(){return new Ua});Tt.addKeyword("uv2",function(){return new Ua(1)});import{LinearEncoding as HE,sRGBEncoding as WE}from"three";var ui=class extends ge{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??ui.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case HE:return["Linear"];case WE:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=ui.Nodes[this.method],s=e.include(a);if(s===ui.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=ui.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=ui.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Xt=ui;Xt.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,t])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ft,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new jr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let n of Object.values(Ae))n.isRenderGlobal=!0;var iv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.63/build/ui.wasm"};var Wo=class extends qe{constructor(){super("basic");this.nodeType="Basic";this.color=new He(mt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(sN.merge([aN.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(`
1876
+ }`,[e,t])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ft,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new jr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let n of Object.values(Ae))n.isRenderGlobal=!0;var iv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.65/build/ui.wasm"};var Wo=class extends qe{constructor(){super("basic");this.nodeType="Basic";this.color=new He(mt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(sN.merge([aN.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 i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4674,4 +4674,4 @@ void main() {
4674
4674
  A = exp(A) * vColor.a;
4675
4675
  gl_FragColor = vec4(color.rgb, A);
4676
4676
  gVelocity = vec4(0.0); // so it is ignored by TAA
4677
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Hn},viewport:{type:"v2",value:new Hn},basisViewport:{type:"v2",value:new Hn},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hn(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hn(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:nL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let t=new YR;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new XR(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new rL().copy(t),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.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,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Hn(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Hn(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=QR.toHalfFloat(this.covariances[h]);s=new Ud(l,i.x,i.y,ES,eL)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Ud(l,i.x,i.y,ES,MS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);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]=IS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=kd(this.centers[y]),c[b+2]=kd(this.centers[y+1]),c[b+3]=kd(this.centers[y+2])}let u=new Ud(c,a.x,a.y,aL,lL);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 Ud(d,p,1,iL,MS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){this.splatCount>0&&(jd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(jd),this.material.uniforms.basisViewport.value.set(2/jd.x,2/jd.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=i,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 DS,um=new Promise(n=>{DS=n}),NS=!1;var Wd;function dm(){if(NS)return;if(Wd)return Wd;async function n(){let e=await import("./gaussian-splat-compression.js");DS(e),NS=!0}return Wd=n(),Wd}var LS;um.then(n=>LS=n);var Wl=class{constructor(r={}){Kr(this,"updateView",function(){let r=new _S,e=[],t=new Es(0,0,-1),o=new Es(0,0,-1),i=new Es,a=new Es;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(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.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=r.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 _S().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new cL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new Es().fromArray(r.position)),r.orientation&&(r.orientation=new RS().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.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 t=e.map(a=>new LS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new Es,o=new RS,i=!1,a=1,s,l){this.splatMesh=Wn.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),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(r){this.sortWorker=AS(r),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(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var yL=new hL;yL.wireframe=!0;var BS=new dL,qd=class extends uL{constructor(e,t){super();this.data=e;this.sharedAssets=t;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 Fd;this.invisibleObjects=new Bn("jflkdsafjasdifjaslk",{...ru.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Ir("fdasfa",{..._o.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=CS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=OS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Ir&&(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 t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>ec(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)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===yn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Ir&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Ir&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Ti&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Ir&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.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(t=>{this.toExpandCloner.add(t)})}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,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Rl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.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 kn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Rl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof ir&&i.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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Rl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof ir&&i.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 t of this.children)t instanceof Ir&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{fS(a,t,o,{scene:this,shared:i}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof Ti||l instanceof Ir)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,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,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof Qo&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{De.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=un(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Jl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof en&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=un(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of au.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof en&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Nd(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof en&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!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(Ln(s)||Ll(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Ul(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Ll(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Ul(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)De.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)De.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)De.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Rl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Go.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)De.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=Ld(e,t,l);return c instanceof kn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new fL;return o.setFromPoints(t),o.getCenter(BS),BS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ct)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof or&&e(t.material[o]);else t.material instanceof or&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof Qo&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Wl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function VS(){return qn||(qn=new gL,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function xL(n){if(qn){let r={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function zS(n,r){let[e,t]=yp(jc.deserialize(new Uint8Array(n)));return cu(e),r&&r(e),t.result().data}function GS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function FS(n){for(let r of n){let e=await xL(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as Zme}from"three";import{mergeBufferGeometries as tye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function kS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}import{Color as US,ShaderLib as bL}from"three";function jS(n){let r=new Set;return n.traverse(e=>{if(e instanceof nr)if(dt(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new US,specularColor:new US});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},bL.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.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 SL(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function vL(n){return n.getLayersOfType("transmission").length>0}function SL(n){let r=0;for(let e of n.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&&(r+=(1-r)*o.value)}}return r<1}function HS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function WS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function qS(n){let r=[];return n.traverse(e=>{e instanceof Rn&&r.push(e)}),r.forEach(e=>{let t=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&&kS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Ct&&a.unshift(t.geometry),a.length){let s=wL(a);t instanceof Ct&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Ev})}),n}function $S(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function XS(n){Object.values(n.shared.materials).forEach(r=>{pm(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?pm(e.material):"materials"in e&&e.materials.forEach(t=>{pm(t)})})}function pm(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var ZS=_s(KS(),1);var QS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",fm=class extends OL{load(r,e,t,o=console.error){let i=new PL(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(QS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(QS),i.load(r,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)}},t,o)}async parse(r){let e=await zS(r,XS),t=GS(e);e.version&&(0,ZS.default)(e.version,"1.9.63")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&VS(),zv(e)&&Db(),Xv(e)&&bv(),N1(e)&&I1(),Hd(e)&&dm()].filter(Boolean)),t.length&&await FS(t);let o=!1,i=new bi(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new qd(e.scene,i);Hd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=qS(a),a=jS(a),a=HS(a),a=WS(a),a=$S(a),a}};export{fm as default};
4677
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Hn},viewport:{type:"v2",value:new Hn},basisViewport:{type:"v2",value:new Hn},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hn(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hn(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:i,vertexShader:t,fragmentShader:o,transparent:!0,alphaTest:1,blending:nL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let t=new YR;t.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new XR(o,3);t.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new rL().copy(t),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.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,t=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(i.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Hn(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Hn(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=QR.toHalfFloat(this.covariances[h]);s=new Ud(l,i.x,i.y,ES,eL)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Ud(l,i.x,i.y,ES,MS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);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]=IS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=kd(this.centers[y]),c[b+2]=kd(this.centers[y+1]),c[b+3]=kd(this.centers[y+2])}let u=new Ud(c,a.x,a.y,aL,lL);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 Ud(d,p,1,iL,MS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,o,i){this.splatCount>0&&(jd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(jd),this.material.uniforms.basisViewport.value.set(2/jd.x,2/jd.y),this.material.uniforms.focal.value.set(t,o),this.material.uniforms.orthoZoom.value=i,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 DS,um=new Promise(n=>{DS=n}),NS=!1;var Wd;function dm(){if(NS)return;if(Wd)return Wd;async function n(){let e=await import("./gaussian-splat-compression.js");DS(e),NS=!0}return Wd=n(),Wd}var LS;um.then(n=>LS=n);var Wl=class{constructor(r={}){Kr(this,"updateView",function(){let r=new _S,e=[],t=new Es(0,0,-1),o=new Es(0,0,-1),i=new Es,a=new Es;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(t)<=.95&&(d=!0),a.copy(l.position).sub(i).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,i.copy(l.position),t.copy(o),r.copy(l.matrixWorld).invert(),r.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:r.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=r.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 _S().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(r,e){let t=new cL;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(r.getSize(t),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(r={}){this.activePage=this.scene.activePage,r.position&&(r.position=new Es().fromArray(r.position)),r.orientation&&(r.orientation=new RS().fromArray(r.orientation)),r.halfPrecisionCovariances=!!r.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 t=e.map(a=>new LS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of t)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(t,o,r.position,r.orientation,r.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let r=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)r.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let r=!1;return this.splatEntries.forEach((e,t)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[t][i]===void 0?(r=!0,this.cropsArray[t][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[t][i][a][c])?(r=!0,this.cropsArray[t][i][a]=s):s!==this.cropsArray[t][i]?.[a]&&(r=!0,this.cropsArray[t][i][a]=s)})}),e.data.crops.length!==this.cropsArray[t]?.length&&(this.cropsArray[t].length=e.data.crops.length,r=!0)}),r}setupSplatMesh(r,e,t=new Es,o=new RS,i=!1,a=1,s,l){this.splatMesh=Wn.buildMesh(r,e,i,a,s,l),this.splatMesh.position.copy(t),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(r){this.sortWorker=AS(r),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(r,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(r,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var yL=new hL;yL.wireframe=!0;var BS=new dL,qd=class extends uL{constructor(e,t){super();this.data=e;this.sharedAssets=t;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 Fd;this.invisibleObjects=new Bn("jflkdsafjasdifjaslk",{...ru.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Ir("fdasfa",{..._o.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=CS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=OS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Ir&&(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 t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>ec(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)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===yn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Ir&&t.uiScene){let o=t.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Ir&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(o=>{t===void 0&&o instanceof Ti&&(t=o.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Ir&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.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(t=>{this.toExpandCloner.add(t)})}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,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){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 i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Rl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.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 kn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Rl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof ir&&i.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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Rl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof ir&&i.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 t of this.children)t instanceof Ir&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{fS(a,t,o,{scene:this,shared:i}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,o,i,a,s=[]){e.updateEntityByOp(t,o,i,a),this.traverseEntity(l=>{(l instanceof Ti||l instanceof Ir)&&(s.includes(l.frameId??"")||l.frameId===t)&&l.updateEntity2DByOp(t,o,i,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,t){let o=Object.entries(t.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{i instanceof Qo&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{De.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,l){if(e){let c=i.find(e);c&&c!==i&&a.forInstancesRec(u=>{u.data=un(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Jl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,t);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...t,l.id],"object",o,i,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...t,l.id,"ifActions"],o,i,a,s),this.rewriteActions(l.data.elseActions,[...t,l.id,"elseActions"],o,i,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof en&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=un(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of au.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof en&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Nd(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof en&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(t===!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(Ln(s)||Ll(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Ul(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Ll(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Ul(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)De.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)De.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)De.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,t).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Rl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Go.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)De.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,a,s){let l={scene:this,shared:s},c=Ld(e,t,l);return c instanceof kn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,i.add(c),i.children.splice(a,0,i.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(t,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;t.push(...u.vertices)}let o=new fL;return o.setFromPoints(t),o.getCenter(BS),BS}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ct)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof or&&e(t.material[o]);else t.material instanceof or&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof Qo&&i.setViewplaneSize(e,t,o)})}initializeSplatViewer(){this.splatViewer=new Wl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function VS(){return qn||(qn=new gL,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function xL(n){if(qn){let r={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function zS(n,r){let[e,t]=yp(jc.deserialize(new Uint8Array(n)));return cu(e),r&&r(e),t.result().data}function GS(n){let r=[];return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&t.geometry.data.draco!==void 0&&r.push(t)}),r}async function FS(n){for(let r of n){let e=await xL(r.geometry.data.draco);if(e){let t=r.geometry.data;e.index&&(t.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:i,array:a,itemSize:s})=>{o[i]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),t.attributes=o,t.draco=void 0}}}import{Mesh as Zme}from"three";import{mergeBufferGeometries as tye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function kS(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}import{Color as US,ShaderLib as bL}from"three";function jS(n){let r=new Set;return n.traverse(e=>{if(e instanceof nr)if(dt(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new US,specularColor:new US});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},bL.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.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 SL(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function vL(n){return n.getLayersOfType("transmission").length>0}function SL(n){let r=0;for(let e of n.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&&(r+=(1-r)*o.value)}}return r<1}function HS(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function WS(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let a=t;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function qS(n){let r=[];return n.traverse(e=>{e instanceof Rn&&r.push(e)}),r.forEach(e=>{let t=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&&kS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof Ct&&a.unshift(t.geometry),a.length){let s=wL(a);t instanceof Ct&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Ev})}),n}function $S(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function XS(n){Object.values(n.shared.materials).forEach(r=>{pm(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?pm(e.material):"materials"in e&&e.materials.forEach(t=>{pm(t)})})}function pm(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var ZS=_s(KS(),1);var QS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",fm=class extends OL{load(r,e,t,o=console.error){let i=new PL(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(QS+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(QS),i.load(r,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)}},t,o)}async parse(r){let e=await zS(r,XS),t=GS(e);e.version&&(0,ZS.default)(e.version,"1.9.65")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([t.length&&VS(),zv(e)&&Db(),Xv(e)&&bv(),N1(e)&&I1(),Hd(e)&&dm()].filter(Boolean)),t.length&&await FS(t);let o=!1,i=new bi(e.shared,{},o);Object.values(i.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new qd(e.scene,i);Hd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=qS(a),a=jS(a),a=HS(a),a=WS(a),a=$S(a),a}};export{fm as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/loader",
3
- "version": "1.9.63",
3
+ "version": "1.9.65",
4
4
  "description": "Spline is a collaborative design platform for creating production-ready interactive experiences in multiple dimensions. © 2024 Spline, Inc.",
5
5
  "keywords": [
6
6
  "spline",