@splinetool/loader 1.10.96 → 1.10.97

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: ${p.d}`);let x=[p.x,p.y];return x.distance=p.d,x.distance}functio
15
15
  }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=_l(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=_l(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:fI(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var sb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return sb(e,t)}return Gi.isBoolean(i)?Gi.getDisplayedValue(i).toLowerCase():Gi.getDisplayedValue(i)},_l=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
16
16
  `:"")+_l(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return sb(o,t)}}return""}).join("");var xI=new Ie.Matrix4,bI=new Ie.Matrix4;function vI(i,t,e){let r=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3],o=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Ie.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ie.Matrix4().makeBasis(r[0],r[1],r[2])}var lb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Ka.create({parameters:Yp}).userData.shape;return{path:i.path??Na.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...xu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Uf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ie.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Uf=class extends Ie.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)||!nb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],d=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=vI(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:x,bevelSides:v}=this.inputs.parameters.extrusion,w=x>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new Hi(this.inputs.shapeData,2*x,x,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*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{_=_f}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)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,d[0],u[0],!1),this._closeEnd(_,N+R,q,B,d[d.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=xI;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(bI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=zu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ie.Vector3,s=new Ie.Vector3,l=new Ie.Vector3,c=new Ie.Vector3,u=new Ie.Vector3(0,1,0);for(let y=0;y<o;y++){let x=e[y],v;y===0?v=n?e[e.length-2]:x.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:x.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=x.clone().sub(v).normalize(),S=w.clone().sub(x).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new Ie.Matrix4().makeBasis(M,g,T);r.push(D)}let d=n?s:l,p=n?a:new Ie.Vector3(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let x=new Ie.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(x)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ie.Matrix4,d=new Ie.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ie.MathUtils.lerp(a,a+s,h)*Ie.MathUtils.DEG2RAD);let m=Ie.MathUtils.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=$e.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),x=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];x.push(w,O)}return x}),s;try{s=uo({windingRule:r,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Il}let l;try{l=uo({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Df}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],x=m%2===0?s.vertexCount:0;s.elements.push(y+x)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],x=s.vertexCount;s.vertexIndices.push(y+x)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let x=m*2,v=s.vertices[x+0],w=s.vertices[x+1];v<u&&(u=v),v>d&&(d=v),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,x=m*2,v=s.elements[x+0],w=s.elements[x+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Ie.Vector3,u=new Ie.Vector3,d=new Ie.Vector3,p=new Ie.Vector3,f=new Ie.Vector2;o.forEach((m,y)=>{let x=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),d.copy(c).applyMatrix4(m).add(x),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,d,p,f),v++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,v,d,p,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,x=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=x+O,g=x+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ie.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Ie.Vector3,p=new Ie.Vector2;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,x=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,x,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ie.Matrix3().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,x=o*m;y<x;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};var Nn=require("three"),cb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ub(){let i=new Nn.BufferGeometry;return i.setAttribute("position",new Nn.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Nn.BufferAttribute(new Uint16Array([]),1)),i}var wI=ub().attributes,PI=12,OI=1,Dn=class extends Nn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,wI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:d}=e,p=Gi.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=TI(e,o,f,r),{shapes:m,charWidths:y,charCoords:x}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new Xe().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>Pr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?$e.NONZERO:$e.ODD,subdivisions:this.isLowResolution&&s>0?OI:PI}})),T=S.length?(0,cb.mergeBufferGeometries)(S):ub();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=x,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ft(new Nn.BufferGeometry,Dn.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function TI(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var pb,ed=new Promise(i=>{pb=i}),db=!1;var Ju;function fb(i){if(db)return;if(Ju)return Ju;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.96/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});pb(c),db=!0}return Ju=t(),Ju}var hb=require("three");var CI=["font"];function Bo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];qp(d)&&!CI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),qp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new hb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Dn(n,t);if(n.type==="InputGeometry")return new Dn(n,t);if(n.type==="UIGeometry")return Ja.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=kf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Xe.createFromState(Ea.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=kf(s)}return l}var mb=require("three"),AI=new mb.Matrix4;function Rl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=AI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var td=new lt.Box3,ts=new lt.Vector3,Pe;ed.then(i=>{Pe=i});var yb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),gb=new Uint32Array([0,1,2,3]),xb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=_i.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&Rl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&Rl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(ts.fromArray(n));let s=ts.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;td.setFromBufferAttribute(r),td.getCenter(o),e.boundingSphere.radius=o.distanceTo(td.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),td.getSize(ts);let n={width:ts.x,height:ts.y,depth:ts.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:yb,indexWASM:gb,verticesPerFaceWASM:xb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Bo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Xf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=yb,n=gb,a=xb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,x=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,x,p),w=new Uint32Array(Pe.HEAPU32.buffer,x+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,O.elements):Pe.alloc_subdivision_surface(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Pe._free(x),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Pe.HEAPU32[c[d]>>2],f=Pe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Pe.HEAPU32[c[d]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Pe.HEAPU32[c[d]>>2],x=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let v=Pe.HEAPU32[c[d]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[d]);if(d++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(x,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],d=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,x=d.length;y<x;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?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,d=Pe.HEAPU32[l[u]>>2],p=new Float32Array(Pe.HEAPF32.subarray(d>>2,(d>>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:p,indices:h,verticesPerFace:y}}};var bb=["getX","getY","getZ"];function $f(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[bb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[bb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var rd=new lt.Vector3,Hf=new lt.Vector3,Wf=new lt.Vector3,qf=new lt.Vector3;function Xf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){rd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Hf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Wf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),qf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Hf.sub(rd).normalize(),Wf.sub(rd).normalize(),qf.sub(rd).normalize();let l=Hf.cross(Wf).dot(qf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var qr={};cm(qr,{calcBoolean:()=>NI,calcBooleanTopological:()=>EI,freeMeshSet:()=>LI,getMeshSet:()=>DI,hasOpenEdges:()=>_I,transformMeshSet:()=>RI});var MI,vb=new Promise(i=>{MI=i});var Ll=require("three");var Ue,rs;vb.then(i=>Ue=i);function II(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=$f(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Xf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Sb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function wb(i){switch(i){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 "+i)}}function EI(i,t){rs===void 0&&(rs=Ue.init_csg());let e=Sb(i),r=Ue.csg_calc_topological(rs,e,i.length,wb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NI(i,t,e,r){rs===void 0&&(rs=Ue.init_csg());let o=Sb(i),n=Ue.csg_calc(rs,o,i.length,r,wb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],d=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ll.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ll.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ll.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(n),h}function DI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let x=i.userData;n=x.verticesPerFace.length,r=x.positions,o=Array(x.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<x.verticesPerFace.length;v++){o[O++]=x.verticesPerFace[v];for(let S=0;S<x.verticesPerFace[v];S++)o[O++]=x.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=II(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+d,s,n);return Ue._free(f),y}function _I(i){return Ue.has_open_edges(i)}function RI(i,t){Ue.transform_csg_mesh(i,t.elements)}function LI(i){Ue.free_csg_mesh(i)}var BI={ConeGeometry:px,CubeGeometry:fx,CylinderGeometry:dx,DodecahedronGeometry:mx,EllipseGeometry:Ka,HelixGeometry:Fx,IcosahedronGeometry:Ux,LatheGeometry:kx,NonParametricGeometry:$x,PolygonGeometry:Ku,PyramidGeometry:Xx,RectangleGeometry:Ja,SphereGeometry:Yx,PlaneGeometry:Qx,BackdropGeometry:Zx,StarGeometry:Qu,TextFrameGeometry:eb,TorusGeometry:tb,TorusKnotGeometry:ob,TriangleGeometry:ib,PathGeometry:lb,VectorGeometry:Pr},kf=i=>BI[i.type].create(i);function os(i){return i!==null&&"booleanOp"in i}var is=class extends Ua(od.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new od.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!os(this.parent)&&this.visible,os(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(qr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),os(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof is&&(e.freeBooleanPointer(),os(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&os(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),os(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var id=new ns.Box3;function Bl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}id.min.set(n,a,s),id.max.set(l,c,u),id.getCenter(r),id.getSize(o).multiplyScalar(.5)}var VI=new ns.BufferGeometry,zI=new ns.MeshBasicMaterial,Wt=class extends is{constructor(t,e){super(VI,zI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Bl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var gi=require("three");var Vr=require("three");var Hb=require("three");var fi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(fi.uuidContext===null)throw new Error("plz startContext");fi.uuidContext===fi.globalContext?this.uuid="_gid"+fi.uuidContext.nodeContextUuid++:this.uuid="_uid"+fi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===fi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=fi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=fi.globalContext;var yo=require("three");var Vl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new Yf;var Kf=require("three");var Pb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Pb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Kf.Vector2?e:new Kf.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var Qf=require("three");var ir=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Qf.Vector3?e:new Qf.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Or=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var GI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ob=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Ob.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let x=qt.getKeywordData(f);x.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),x.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=GI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Ob);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var FI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Zf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Zf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=FI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Zf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var jI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var pb,ed=new Promise(i=>{pb=i}),db=!1;var Ju;function fb(i){if(db)return;if(Ju)return Ju;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.97/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});pb(c),db=!0}return Ju=t(),Ju}var hb=require("three");var CI=["font"];function Bo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];qp(d)&&!CI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),qp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new hb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Dn(n,t);if(n.type==="InputGeometry")return new Dn(n,t);if(n.type==="UIGeometry")return Ja.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=kf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Xe.createFromState(Ea.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=kf(s)}return l}var mb=require("three"),AI=new mb.Matrix4;function Rl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=AI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var td=new lt.Box3,ts=new lt.Vector3,Pe;ed.then(i=>{Pe=i});var yb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),gb=new Uint32Array([0,1,2,3]),xb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=_i.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&Rl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&Rl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(ts.fromArray(n));let s=ts.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;td.setFromBufferAttribute(r),td.getCenter(o),e.boundingSphere.radius=o.distanceTo(td.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),td.getSize(ts);let n={width:ts.x,height:ts.y,depth:ts.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:yb,indexWASM:gb,verticesPerFaceWASM:xb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Bo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=$f(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=Xf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=yb,n=gb,a=xb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,x=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,x,p),w=new Uint32Array(Pe.HEAPU32.buffer,x+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,O.elements):Pe.alloc_subdivision_surface(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Pe._free(x),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Pe.HEAPU32[c[d]>>2],f=Pe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Pe.HEAPU32[c[d]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Pe.HEAPU32[c[d]>>2],x=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let v=Pe.HEAPU32[c[d]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[d]);if(d++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(x,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],d=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,x=d.length;y<x;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?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,d=Pe.HEAPU32[l[u]>>2],p=new Float32Array(Pe.HEAPF32.subarray(d>>2,(d>>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:p,indices:h,verticesPerFace:y}}};var bb=["getX","getY","getZ"];function $f(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[bb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[bb[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var rd=new lt.Vector3,Hf=new lt.Vector3,Wf=new lt.Vector3,qf=new lt.Vector3;function Xf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){rd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Hf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Wf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),qf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Hf.sub(rd).normalize(),Wf.sub(rd).normalize(),qf.sub(rd).normalize();let l=Hf.cross(Wf).dot(qf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var qr={};cm(qr,{calcBoolean:()=>NI,calcBooleanTopological:()=>EI,freeMeshSet:()=>LI,getMeshSet:()=>DI,hasOpenEdges:()=>_I,transformMeshSet:()=>RI});var MI,vb=new Promise(i=>{MI=i});var Ll=require("three");var Ue,rs;vb.then(i=>Ue=i);function II(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=$f(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Xf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Sb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function wb(i){switch(i){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 "+i)}}function EI(i,t){rs===void 0&&(rs=Ue.init_csg());let e=Sb(i),r=Ue.csg_calc_topological(rs,e,i.length,wb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NI(i,t,e,r){rs===void 0&&(rs=Ue.init_csg());let o=Sb(i),n=Ue.csg_calc(rs,o,i.length,r,wb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],d=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ll.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ll.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ll.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(n),h}function DI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let x=i.userData;n=x.verticesPerFace.length,r=x.positions,o=Array(x.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<x.verticesPerFace.length;v++){o[O++]=x.verticesPerFace[v];for(let S=0;S<x.verticesPerFace[v];S++)o[O++]=x.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=II(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+d,s,n);return Ue._free(f),y}function _I(i){return Ue.has_open_edges(i)}function RI(i,t){Ue.transform_csg_mesh(i,t.elements)}function LI(i){Ue.free_csg_mesh(i)}var BI={ConeGeometry:px,CubeGeometry:fx,CylinderGeometry:dx,DodecahedronGeometry:mx,EllipseGeometry:Ka,HelixGeometry:Fx,IcosahedronGeometry:Ux,LatheGeometry:kx,NonParametricGeometry:$x,PolygonGeometry:Ku,PyramidGeometry:Xx,RectangleGeometry:Ja,SphereGeometry:Yx,PlaneGeometry:Qx,BackdropGeometry:Zx,StarGeometry:Qu,TextFrameGeometry:eb,TorusGeometry:tb,TorusKnotGeometry:ob,TriangleGeometry:ib,PathGeometry:lb,VectorGeometry:Pr},kf=i=>BI[i.type].create(i);function os(i){return i!==null&&"booleanOp"in i}var is=class extends Ua(od.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new od.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!os(this.parent)&&this.visible,os(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(qr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),os(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof is&&(e.freeBooleanPointer(),os(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&os(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),os(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var id=new ns.Box3;function Bl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}id.min.set(n,a,s),id.max.set(l,c,u),id.getCenter(r),id.getSize(o).multiplyScalar(.5)}var VI=new ns.BufferGeometry,zI=new ns.MeshBasicMaterial,Wt=class extends is{constructor(t,e){super(VI,zI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Bl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var gi=require("three");var Vr=require("three");var Hb=require("three");var fi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(fi.uuidContext===null)throw new Error("plz startContext");fi.uuidContext===fi.globalContext?this.uuid="_gid"+fi.uuidContext.nodeContextUuid++:this.uuid="_uid"+fi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===fi.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=fi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=fi.globalContext;var yo=require("three");var Vl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Yf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new Yf;var Kf=require("three");var Pb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=Pb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Kf.Vector2?e:new Kf.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var Qf=require("three");var ir=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Qf.Vector3?e:new Qf.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Or=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var GI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ob=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Ob.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let x=qt.getKeywordData(f);x.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),x.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=GI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Ob);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var FI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Zf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Zf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=FI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Zf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var jI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),UI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),as=class extends be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=jI.exec(e);if(r){let o=r[2],n;for(;n=UI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ss=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};qt.addKeyword("uv",function(){return new ss});qt.addKeyword("uv2",function(){return new ss(1)});var nd=require("three");var _n=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??_n.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case nd.LinearEncoding:return["Linear"];case nd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=_n.Nodes[this.method],s=e.include(a);if(s===_n.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=_n.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=_n.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},mr=_n;mr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
21
  `)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,r])}}();var De={normalRenderTarget:new yr,normalRenderTargetDepth:new yr,transmissionRenderTarget:new yr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new yr,aoRenderTarget:new yr,aoEnabled:new Pt,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new go(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2),taaEnabled:new Pt(!0)};for(let i of Object.values(De))i.isRenderGlobal=!0;var Fb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.96/build/ui.wasm"};var hi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Dt),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 r;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(ud.UniformsUtils.merge([ud.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,r])}}();var De={normalRenderTarget:new yr,normalRenderTargetDepth:new yr,transmissionRenderTarget:new yr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new yr,aoRenderTarget:new yr,aoEnabled:new Pt,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new go(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2),taaEnabled:new Pt(!0)};for(let i of Object.values(De))i.isRenderGlobal=!0;var Fb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.97/build/ui.wasm"};var hi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Dt),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 r;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(ud.UniformsUtils.merge([ud.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,x=h*4;c[x]=X1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[x+1]=op(this.centers[y]),c[x+2]=op(this.centers[y+1]),c[x+3]=op(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(p,d,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(ip.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(ip),this.material.uniforms.basisViewport.value.set(2/ip.x,2/ip.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var K1,Zh=new Promise(i=>{K1=i}),Y1=!1;var ap;function Jh(){if(Y1)return;if(ap)return ap;async function i(){let e=await import("./gaussian-splat-compression.js");K1(e),Y1=!0}return ap=i(),ap}var Q1;Zh.then(i=>Q1=i);var fc=class{constructor(t={}){xn(this,"updateView",function(){let t=new br.Matrix4,e=[],r=new br.Vector3(0,0,-1),o=new br.Vector3(0,0,-1),n=new br.Vector3,a=new br.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new br.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new br.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new br.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new br.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new Q1.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new br.Vector3,o=new br.Quaternion,n=!1,a=1,s,l){this.splatMesh=pn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=$1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var TE=new to.MeshBasicMaterial;TE.wireframe=!0;var Z1=new to.Vector3,sp=class extends to.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new rp;this.invisibleObjects=new on("jflkdsafjasdifjaslk",{...Ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Jr("fdasfa",{...ri.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=W1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=H1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Jr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>wc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Li)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Jr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Jr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof qn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Jr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),rn(n)&&oc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof cn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),oc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),rn(o)&&(o.freeBooleanPointer(),n instanceof Mr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ws&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),rn(o)&&(o.invalidateUpstreamBooleanData(),oc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Mr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Jr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{z1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof qn||l instanceof Jr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof xi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ii(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Sc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,x=ut.zoom(p,r);x[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Si&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ii(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Mu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Si&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Yd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Si&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(rn(s)||ic(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),dc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((rn(a)||ic(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),dc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){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 n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();oc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ci.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Jd(e,r,l);return c instanceof cn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new to.Matrix4().fromArray(m)),h=new to.Skeleton(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new to.Box3;return o.setFromPoints(r),o.getCenter(Z1),Z1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Cr&&e(r.material[o]);else r.material instanceof Cr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof xi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new fc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var J1=require("three/examples/jsm/loaders/DRACOLoader.js");var fn;function eS(i){return fn||(fn=new J1.DRACOLoader,fn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fn.decoderPending}async function CE(i){if(fn){let t={attributeIDs:fn.defaultAttributeIDs,attributeTypes:fn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await fn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function tS(i,t){let[e,r]=_p(du.deserialize(new Uint8Array(i)));return Eu(e),t&&t(e),r.result().data}function rS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function oS(i){for(let t of i){let e=await CE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var AE=require("three"),ME=require("three/examples/jsm/utils/BufferGeometryUtils.js");function iS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var hc=require("three");function nS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Ar)if(Ct(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(IE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new hc.Color,specularColor:new hc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},hc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Gb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else EE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function IE(i){return i.getLayersOfType("transmission").length>0}function EE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function aS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function sS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var lS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cS(i){let t=[];return i.traverse(e=>{e instanceof en&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&iS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,lS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:iv})}),i}function uS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function dS(i){Object.values(i.shared.materials).forEach(t=>{em(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?em(e.material):"materials"in e&&e.materials.forEach(r=>{em(r)})})}function em(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var mS=rl(fS(),1);var hS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",lp=class extends cp.Loader{load(t,e,r,o=console.error){let n=new cp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(hS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(hS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await tS(t,dS),r=rS(e);e.version&&(0,mS.default)(e.version,"1.10.96")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&eS(),cv(e)&&fb(),bv(e)&&Qb(),Jv(e)&&Kv(),np(e)&&Jh()].filter(Boolean)),r.length&&await oS(r);let o=!1,n=new jn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new sp(e.scene,n);np(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=cS(a),a=nS(a),a=aS(a),a=sS(a),a=uS(a),a}};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,x=h*4;c[x]=X1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[x+1]=op(this.centers[y]),c[x+2]=op(this.centers[y+1]),c[x+3]=op(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(p,d,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(ip.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(ip),this.material.uniforms.basisViewport.value.set(2/ip.x,2/ip.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var K1,Zh=new Promise(i=>{K1=i}),Y1=!1;var ap;function Jh(){if(Y1)return;if(ap)return ap;async function i(){let e=await import("./gaussian-splat-compression.js");K1(e),Y1=!0}return ap=i(),ap}var Q1;Zh.then(i=>Q1=i);var fc=class{constructor(t={}){xn(this,"updateView",function(){let t=new br.Matrix4,e=[],r=new br.Vector3(0,0,-1),o=new br.Vector3(0,0,-1),n=new br.Vector3,a=new br.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new br.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new br.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new br.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new br.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new Q1.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new br.Vector3,o=new br.Quaternion,n=!1,a=1,s,l){this.splatMesh=pn.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=$1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var TE=new to.MeshBasicMaterial;TE.wireframe=!0;var Z1=new to.Vector3,sp=class extends to.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new rp;this.invisibleObjects=new on("jflkdsafjasdifjaslk",{...Ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Jr("fdasfa",{...ri.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=W1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=H1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Jr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>wc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Li)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Jr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Jr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof qn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Jr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),rn(n)&&oc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof cn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),oc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),rn(o)&&(o.freeBooleanPointer(),n instanceof Mr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ws&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),rn(o)&&(o.invalidateUpstreamBooleanData(),oc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Mr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Jr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{z1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof qn||l instanceof Jr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof xi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ii(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Sc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,x=ut.zoom(p,r);x[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Si&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ii(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Mu.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Si&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Yd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Si&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(rn(s)||ic(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),dc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((rn(a)||ic(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),dc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){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 n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();oc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ci.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Jd(e,r,l);return c instanceof cn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new to.Matrix4().fromArray(m)),h=new to.Skeleton(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new to.Box3;return o.setFromPoints(r),o.getCenter(Z1),Z1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Cr&&e(r.material[o]);else r.material instanceof Cr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof xi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new fc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var J1=require("three/examples/jsm/loaders/DRACOLoader.js");var fn;function eS(i){return fn||(fn=new J1.DRACOLoader,fn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fn.decoderPending}async function CE(i){if(fn){let t={attributeIDs:fn.defaultAttributeIDs,attributeTypes:fn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await fn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function tS(i,t){let[e,r]=_p(du.deserialize(new Uint8Array(i)));return Eu(e),t&&t(e),r.result().data}function rS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function oS(i){for(let t of i){let e=await CE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var AE=require("three"),ME=require("three/examples/jsm/utils/BufferGeometryUtils.js");function iS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var hc=require("three");function nS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Ar)if(Ct(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(IE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new hc.Color,specularColor:new hc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},hc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Gb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else EE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function IE(i){return i.getLayersOfType("transmission").length>0}function EE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function aS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function sS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var lS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cS(i){let t=[];return i.traverse(e=>{e instanceof en&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&iS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,lS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:iv})}),i}function uS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function dS(i){Object.values(i.shared.materials).forEach(t=>{em(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?em(e.material):"materials"in e&&e.materials.forEach(r=>{em(r)})})}function em(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var mS=rl(fS(),1);var hS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",lp=class extends cp.Loader{load(t,e,r,o=console.error){let n=new cp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(hS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(hS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await tS(t,dS),r=rS(e);e.version&&(0,mS.default)(e.version,"1.10.97")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&eS(),cv(e)&&fb(),bv(e)&&Qb(),Jv(e)&&Kv(),np(e)&&Jh()].filter(Boolean)),r.length&&await oS(r);let o=!1,n=new jn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new sp(e.scene,n);np(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=cS(a),a=nS(a),a=aS(a),a=sS(a),a=uS(a),a}};
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let x=[p.x,p.y];return x.distance=p.d,x.distance}functio
15
15
  }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=ll(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=ll(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:$3(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var vb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return vb(e,t)}return xi.isBoolean(i)?xi.getDisplayedValue(i).toLowerCase():xi.getDisplayedValue(i)},ll=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
16
16
  `:"")+ll(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return vb(o,t)}}return""}).join("");var J3=new sn,eE=new sn;function tE(i,t,e){let r=[new _t,new _t,new _t],o=[new _t,new _t,new _t];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Du.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new sn().makeBasis(r[0],r[1],r[2])}var Pb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Ia.create({parameters:Cp}).userData.shape;return{path:i.path??ua.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...kc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new _f(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new wb,{userData:{...i,type:"PathGeometry"}})}},_f=class extends wb{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)||!xb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],d=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=tE(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:x,bevelSides:v}=this.inputs.parameters.extrusion,w=x>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new wi(this.inputs.shapeData,2*x,x,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=jr({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=xf}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)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,d[0],u[0],!1),this._closeEnd(_,N+R,q,B,d[d.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ra(B.positions,3)),this.setAttribute("normal",new Ra(B.normals,3)),this.setAttribute("uv",new Ra(B.uvs,2)),this.setIndex(q);let H=J3;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(eE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ra(B.positions,3)),this.setAttribute("normal",new Ra(B.normals,3)),this.setAttribute("uv",new Ra(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=uu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new _t,s=new _t,l=new _t,c=new _t,u=new _t(0,1,0);for(let y=0;y<o;y++){let x=e[y],v;y===0?v=n?e[e.length-2]:x.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:x.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=x.clone().sub(v).normalize(),S=w.clone().sub(x).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new sn().makeBasis(M,g,T);r.push(D)}let d=n?s:l,p=n?a:new _t(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let x=new sn().makeRotationZ(h*y/r.length);r[y].multiply(x)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new sn,d=new sn;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Du.lerp(a,a+s,h)*Du.DEG2RAD);let m=Du.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=Fe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),x=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];x.push(w,O)}return x}),s;try{s=jr({windingRule:r,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=ol}let l;try{l=jr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=gf}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],x=m%2===0?s.vertexCount:0;s.elements.push(y+x)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],x=s.vertexCount;s.vertexIndices.push(y+x)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let x=m*2,v=s.vertices[x+0],w=s.vertices[x+1];v<u&&(u=v),v>d&&(d=v),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,x=m*2,v=s.elements[x+0],w=s.elements[x+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new _t,u=new _t,d=new _t,p=new _t,f=new Sb;o.forEach((m,y)=>{let x=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),d.copy(c).applyMatrix4(m).add(x),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,d,p,f),v++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,v,d,p,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,x=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=x+O,g=x+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new _t(0,0,l?-1:1).applyMatrix4(a),d=new _t,p=new Sb;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,x=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,x,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Z3().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,x=o*m;y<x;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as Ob,BufferGeometry as Rf}from"three";import{mergeBufferGeometries as oE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Tb(){let i=new Rf;return i.setAttribute("position",new Ob(new Float32Array([]),3)),i.setIndex(new Ob(new Uint16Array([]),1)),i}var iE=Tb().attributes,nE=12,aE=1,ln=class extends Rf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,iE),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:d}=e,p=xi.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=sE(e,o,f,r),{shapes:m,charWidths:y,charCoords:x}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new je().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>tr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Fe.NONZERO:Fe.ODD,subdivisions:this.isLowResolution&&s>0?aE:nE}})),T=S.length?oE(S):Tb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=x,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Pt(new Rf,ln.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function sE(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as Bf,BufferAttribute as Ib,Uint32BufferAttribute as Vf,Float32BufferAttribute as zf,Matrix4 as pE,Vector3 as ul,Sphere as fE,Box3 as hE,BoxGeometry as mE}from"three";var Ab,Ru=new Promise(i=>{Ab=i}),Cb=!1;var _u;function Mb(i){if(Cb)return;if(_u)return _u;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.96/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Ab(c),Cb=!0}return _u=t(),_u}import{BufferGeometryLoader as lE}from"three";var cE=["font"];function po(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];Pp(d)&&!cE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Pp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new lE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new xt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new ln(n,t);if(n.type==="InputGeometry")return new ln(n,t);if(n.type==="UIGeometry")return _a.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Lf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=je.createFromState(ca.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Lf(s)}return l}import{Matrix4 as uE}from"three";var dE=new uE;function cl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=dE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Lu=new hE,La=new ul,Se;Ru.then(i=>{Se=i});var Eb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Nb=new Uint32Array([0,1,2,3]),Db=new Uint8Array([4]),xt=class extends Bf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=pi.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&cl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&cl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(La.fromArray(n));let s=La.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(La);let n={width:La.x,height:La.y,depth:La.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Se.free_bvh(r),Se.free_subdivision_surface(r));try{a=xt.allocate(e,n)}catch(u){console.error(u,e),a=xt.allocate({positionWASM:Eb,indexWASM:Nb,verticesPerFaceWASM:Db},n)}if(Se.set_destination_refinement_level(a,0),s=xt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=xt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=xt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:po(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Uf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=kf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Eb,n=Nb,a=Db);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,x=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,x,p),w=new Uint32Array(Se.HEAPU32.buffer,x+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new pE().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Se.alloc_subdivision_surface2(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,O.elements):Se.alloc_subdivision_surface(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Se._free(x),S}static buildLevel(e,r,o,n,a){let s=a?Se.get_mesh_data2(e,r?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,r?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Se.HEAPU32[c[d]>>2],f=Se.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Se.HEAPU32[c[d]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Se.HEAPU32[c[d]>>2],x=Se.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let v=Se.HEAPU32[c[d]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[d]);if(d++,n===void 0){let O=new Bf;if(O.setIndex(new Vf(w,1)),O.setAttribute("position",new zf(f,3)),O.setAttribute("normal",new zf(m,3)),r){O.setAttribute("faceMap",new Vf(x,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Ib(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],d=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Bf;h.setAttribute("position",new zf(d,3));let m=new Float32Array(d.length);for(let y=0,x=d.length;y<x;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ib(m,3)),h.setIndex(new Vf(f,1)),Se.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Se.set_destination_refinement_level(e,r);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?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,d=Se.HEAPU32[l[u]>>2],p=new Float32Array(Se.HEAPF32.subarray(d>>2,(d>>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:p,indices:h,verticesPerFace:y}}};var _b=["getX","getY","getZ"];function Uf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[_b[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[_b[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Bu=new ul,Gf=new ul,Ff=new ul,jf=new ul;function kf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Bu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Gf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Ff.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),jf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Gf.sub(Bu).normalize(),Ff.sub(Bu).normalize(),jf.sub(Bu).normalize();let l=Gf.cross(Ff).dot(jf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Pr={};hw(Pr,{calcBoolean:()=>vE,calcBooleanTopological:()=>bE,freeMeshSet:()=>OE,getMeshSet:()=>SE,hasOpenEdges:()=>wE,transformMeshSet:()=>PE});var yE,Rb=new Promise(i=>{yE=i});import{Float32BufferAttribute as Lb,Sphere as gE}from"three";var Be,Ba;Rb.then(i=>Be=i);function xE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Uf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=kf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Bb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,t):new Float32Array(Be.HEAPF32.buffer,n,t)).set(i,0),n}function Vb(i){switch(i){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 "+i)}}function bE(i,t){Ba===void 0&&(Ba=Be.init_csg());let e=Bb(i),r=Be.csg_calc_topological(Ba,e,i.length,Vb(t));Be._free(e);let o=6,n=Be.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],d=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Be.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function vE(i,t,e,r){Ba===void 0&&(Ba=Be.init_csg());let o=Bb(i),n=Be.csg_calc(Ba,o,i.length,r,Vb(t));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],d=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Lb(d,3)),e.setAttribute("normal",new Lb(f,3));let m=Be.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new gE),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(n),h}function SE(i,t,e){if(Be===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let x=i.userData;n=x.verticesPerFace.length,r=x.positions,o=Array(x.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<x.verticesPerFace.length;v++){o[O++]=x.verticesPerFace[v];for(let S=0;S<x.verticesPerFace[v];S++)o[O++]=x.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=xE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+d,s,n);return Be._free(f),y}function wE(i){return Be.has_open_edges(i)}function PE(i,t){Be.transform_csg_mesh(i,t.elements)}function OE(i){Be.free_csg_mesh(i)}var TE={ConeGeometry:xx,CubeGeometry:bx,CylinderGeometry:gx,DodecahedronGeometry:vx,EllipseGeometry:Ia,HelixGeometry:Kx,IcosahedronGeometry:Qx,LatheGeometry:Zx,NonParametricGeometry:lb,PolygonGeometry:Iu,PyramidGeometry:cb,RectangleGeometry:_a,SphereGeometry:db,PlaneGeometry:pb,BackdropGeometry:fb,StarGeometry:Eu,TextFrameGeometry:hb,TorusGeometry:mb,TorusKnotGeometry:yb,TriangleGeometry:gb,PathGeometry:Pb,VectorGeometry:tr},Lf=i=>TE[i.type].create(i);function Va(i){return i!==null&&"booleanOp"in i}var za=class extends Sa(AE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new CE}updateVisible(e){super.updateVisible(e),this.visible=!Va(this.parent)&&this.visible,Va(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Pr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Va(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof za&&(e.freeBooleanPointer(),Va(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Va(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Va(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new ME;function dl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}Vu.min.set(n,a,s),Vu.max.set(l,c,u),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var NE=new IE,DE=new EE,Mt=class extends za{constructor(t,e){super(NE,DE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?dl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as eD,Matrix4 as tD,Sphere as Ev,Vector3 as rD}from"three";import{BufferAttribute as QN,Float32BufferAttribute as Iv,MathUtils as xh,Vector3 as bh}from"three";import{ShaderMaterial as IN}from"three";var Ho=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ho.uuidContext===null)throw new Error("plz startContext");Ho.uuidContext===Ho.globalContext?this.uuid="_gid"+Ho.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ho.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},$e=Ho;$e.globalContext={nodeContextUuid:0},$e.uuidContext=Ho.globalContext;import{CubeReflectionMapping as UE,CubeRefractionMapping as kE,CubeUVReflectionMapping as HE,LinearEncoding as $b,sRGBEncoding as WE}from"three";var pl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Hf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},It=new Hf;import{Vector2 as zb}from"three";import{MathUtils as _E}from"three";var ge=class extends $e{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=_E.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var lt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof zb?e:new zb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Gb}from"three";var Ft=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Gb?e:new Gb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var rr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ct?e:new Ct(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var RE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Fb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Fb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&It.containsKeyword(f)){let y=this.keywords[f];if(!y){let x=It.getKeywordData(f);x.cache&&(y=e.keywords[f]),y=y||It.getKeyword(f,e),x.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&It.contains(m)&&e.include(It.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=RE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Fb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var LE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Wf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Wf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=LE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Ge=Wf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var BE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}import{BufferGeometry as Bf,BufferAttribute as Ib,Uint32BufferAttribute as Vf,Float32BufferAttribute as zf,Matrix4 as pE,Vector3 as ul,Sphere as fE,Box3 as hE,BoxGeometry as mE}from"three";var Ab,Ru=new Promise(i=>{Ab=i}),Cb=!1;var _u;function Mb(i){if(Cb)return;if(_u)return _u;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.97/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});Ab(c),Cb=!0}return _u=t(),_u}import{BufferGeometryLoader as lE}from"three";var cE=["font"];function po(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let d of c)u=u[d];for(o in u){let d=u[o];Pp(d)&&!cE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Pp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new lE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new xt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new ln(n,t);if(n.type==="InputGeometry")return new ln(n,t);if(n.type==="UIGeometry")return _a.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Lf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=je.createFromState(ca.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Lf(s)}return l}import{Matrix4 as uE}from"three";var dE=new uE;function cl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=dE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Lu=new hE,La=new ul,Se;Ru.then(i=>{Se=i});var Eb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Nb=new Uint32Array([0,1,2,3]),Db=new Uint8Array([4]),xt=class extends Bf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=pi.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&cl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&cl(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(La.fromArray(n));let s=La.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(La);let n={width:La.x,height:La.y,depth:La.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Se.free_bvh(r),Se.free_subdivision_surface(r));try{a=xt.allocate(e,n)}catch(u){console.error(u,e),a=xt.allocate({positionWASM:Eb,indexWASM:Nb,verticesPerFaceWASM:Db},n)}if(Se.set_destination_refinement_level(a,0),s=xt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=xt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=xt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:po(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=Uf(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=kf(s,u,n,d),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Eb,n=Nb,a=Db);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,x=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,x,p),w=new Uint32Array(Se.HEAPU32.buffer,x+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new pE().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Se.alloc_subdivision_surface2(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,O.elements):Se.alloc_subdivision_surface(x,c,x+m,u,x+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Se._free(x),S}static buildLevel(e,r,o,n,a){let s=a?Se.get_mesh_data2(e,r?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,r?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Se.HEAPU32[c[d]>>2],f=Se.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Se.HEAPU32[c[d]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Se.HEAPU32[c[d]>>2],x=Se.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let v=Se.HEAPU32[c[d]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[d]);if(d++,n===void 0){let O=new Bf;if(O.setIndex(new Vf(w,1)),O.setAttribute("position",new zf(f,3)),O.setAttribute("normal",new zf(m,3)),r){O.setAttribute("faceMap",new Vf(x,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Ib(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],d=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Bf;h.setAttribute("position",new zf(d,3));let m=new Float32Array(d.length);for(let y=0,x=d.length;y<x;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ib(m,3)),h.setIndex(new Vf(f,1)),Se.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Se.set_destination_refinement_level(e,r);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?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,d=Se.HEAPU32[l[u]>>2],p=new Float32Array(Se.HEAPF32.subarray(d>>2,(d>>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:p,indices:h,verticesPerFace:y}}};var _b=["getX","getY","getZ"];function Uf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,d="";for(let p=0;p<3;p++)d+=`${~~(i[_b[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[_b[p]](u));e[d]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Bu=new ul,Gf=new ul,Ff=new ul,jf=new ul;function kf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Bu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Gf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Ff.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),jf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Gf.sub(Bu).normalize(),Ff.sub(Bu).normalize(),jf.sub(Bu).normalize();let l=Gf.cross(Ff).dot(jf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Pr={};hw(Pr,{calcBoolean:()=>vE,calcBooleanTopological:()=>bE,freeMeshSet:()=>OE,getMeshSet:()=>SE,hasOpenEdges:()=>wE,transformMeshSet:()=>PE});var yE,Rb=new Promise(i=>{yE=i});import{Float32BufferAttribute as Lb,Sphere as gE}from"three";var Be,Ba;Rb.then(i=>Be=i);function xE(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=Uf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=kf(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Bb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,t):new Float32Array(Be.HEAPF32.buffer,n,t)).set(i,0),n}function Vb(i){switch(i){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 "+i)}}function bE(i,t){Ba===void 0&&(Ba=Be.init_csg());let e=Bb(i),r=Be.csg_calc_topological(Ba,e,i.length,Vb(t));Be._free(e);let o=6,n=Be.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],d=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Be.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function vE(i,t,e,r){Ba===void 0&&(Ba=Be.init_csg());let o=Bb(i),n=Be.csg_calc(Ba,o,i.length,r,Vb(t));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],d=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Lb(d,3)),e.setAttribute("normal",new Lb(f,3));let m=Be.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new gE),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(n),h}function SE(i,t,e){if(Be===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let x=i.userData;n=x.verticesPerFace.length,r=x.positions,o=Array(x.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<x.verticesPerFace.length;v++){o[O++]=x.verticesPerFace[v];for(let S=0;S<x.verticesPerFace[v];S++)o[O++]=x.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=xE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+d,s,n);return Be._free(f),y}function wE(i){return Be.has_open_edges(i)}function PE(i,t){Be.transform_csg_mesh(i,t.elements)}function OE(i){Be.free_csg_mesh(i)}var TE={ConeGeometry:xx,CubeGeometry:bx,CylinderGeometry:gx,DodecahedronGeometry:vx,EllipseGeometry:Ia,HelixGeometry:Kx,IcosahedronGeometry:Qx,LatheGeometry:Zx,NonParametricGeometry:lb,PolygonGeometry:Iu,PyramidGeometry:cb,RectangleGeometry:_a,SphereGeometry:db,PlaneGeometry:pb,BackdropGeometry:fb,StarGeometry:Eu,TextFrameGeometry:hb,TorusGeometry:mb,TorusKnotGeometry:yb,TriangleGeometry:gb,PathGeometry:Pb,VectorGeometry:tr},Lf=i=>TE[i.type].create(i);function Va(i){return i!==null&&"booleanOp"in i}var za=class extends Sa(AE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new CE}updateVisible(e){super.updateVisible(e),this.visible=!Va(this.parent)&&this.visible,Va(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Pr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Va(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof za&&(e.freeBooleanPointer(),Va(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Va(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Va(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new ME;function dl(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}Vu.min.set(n,a,s),Vu.max.set(l,c,u),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var NE=new IE,DE=new EE,Mt=class extends za{constructor(t,e){super(NE,DE),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?dl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as eD,Matrix4 as tD,Sphere as Ev,Vector3 as rD}from"three";import{BufferAttribute as QN,Float32BufferAttribute as Iv,MathUtils as xh,Vector3 as bh}from"three";import{ShaderMaterial as IN}from"three";var Ho=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ho.uuidContext===null)throw new Error("plz startContext");Ho.uuidContext===Ho.globalContext?this.uuid="_gid"+Ho.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ho.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ho.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},$e=Ho;$e.globalContext={nodeContextUuid:0},$e.uuidContext=Ho.globalContext;import{CubeReflectionMapping as UE,CubeRefractionMapping as kE,CubeUVReflectionMapping as HE,LinearEncoding as $b,sRGBEncoding as WE}from"three";var pl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Hf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},It=new Hf;import{Vector2 as zb}from"three";import{MathUtils as _E}from"three";var ge=class extends $e{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=_E.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var lt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof zb?e:new zb(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as Gb}from"three";var Ft=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Gb?e:new Gb(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var rr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ct?e:new Ct(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var RE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Fb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Fb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&It.containsKeyword(f)){let y=this.keywords[f];if(!y){let x=It.getKeywordData(f);x.cache&&(y=e.keywords[f]),y=y||It.getKeyword(f,e),x.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&It.contains(m)&&e.include(It.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=RE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Fb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var LE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Wf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Wf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=LE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Ge=Wf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var BE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),VE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ga=class extends ge{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=BE.exec(e);if(r){let o=r[2],n;for(;n=VE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Fa=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};It.addKeyword("uv",function(){return new Fa});It.addKeyword("uv2",function(){return new Fa(1)});import{LinearEncoding as zE,sRGBEncoding as GE}from"three";var cn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??cn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case zE:return["Linear"];case GE:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=cn.Nodes[this.method],s=e.include(a);if(s===cn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=cn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=cn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Yt=cn;Yt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
21
  `)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,r])}}();var Ae={normalRenderTarget:new Kt,normalRenderTargetDepth:new Kt,transmissionRenderTarget:new Kt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Kt,aoRenderTarget:new Kt,aoEnabled:new ct,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new kr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2),taaEnabled:new ct(!0)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var tv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.96/build/ui.wasm"};var Wo=class extends $e{constructor(){super("basic");this.nodeType="Basic";this.color=new We(yt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new jt,this.previouseProjectionMatrix=new jt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(tN.merge([eN.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,r])}}();var Ae={normalRenderTarget:new Kt,normalRenderTargetDepth:new Kt,transmissionRenderTarget:new Kt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Kt,aoRenderTarget:new Kt,aoEnabled:new ct,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new kr(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2),taaEnabled:new ct(!0)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var tv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.97/build/ui.wasm"};var Wo=class extends $e{constructor(){super("basic");this.nodeType="Basic";this.color=new We(yt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new jt,this.previouseProjectionMatrix=new jt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(tN.merge([eN.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ji},viewport:{type:"v2",value:new ji},basisViewport:{type:"v2",value:new ji},debugColor:{type:"v3",value:new zR},covariancesTextureSize:{type:"v2",value:new ji(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ji(1024,1024)},orthoZoom:{type:"f",value:-1}};return new YR({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:qR,depthTest:!0,depthWrite:!1,side:FR})}static buildGeomtery(e){let r=new VR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new BR(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new HR().copy(r),s=new Uint32Array(e),l=new kR(s,1,!1);return l.setUsage(jR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new ji(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new ji(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=GR.toHalfFloat(this.covariances[h]);s=new Bd(l,n.x,n.y,PS,UR)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Bd(l,n.x,n.y,PS,wS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,x=h*4;c[x]=SS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[x+1]=Ld(this.centers[y]),c[x+2]=Ld(this.centers[y+1]),c[x+3]=Ld(this.centers[y+2])}let u=new Bd(c,a.x,a.y,XR,KR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Bd(p,d,1,$R,wS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Vd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Vd),this.material.uniforms.basisViewport.value.set(2/Vd.x,2/Vd.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var TS,am=new Promise(i=>{TS=i}),OS=!1;var Gd;function sm(){if(OS)return;if(Gd)return Gd;async function i(){let e=await import("./gaussian-splat-compression.js");TS(e),OS=!0}return Gd=i(),Gd}var MS;am.then(i=>MS=i);var zl=class{constructor(t={}){Xi(this,"updateView",function(){let t=new CS,e=[],r=new Cs(0,0,-1),o=new Cs(0,0,-1),n=new Cs,a=new Cs;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new CS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new QR;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Cs().fromArray(t.position)),t.orientation&&(t.orientation=new AS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new MS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Cs,o=new AS,n=!1,a=1,s,l){this.splatMesh=Ui.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=vS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var iL=new rL;iL.wireframe=!0;var IS=new JR,Fd=class extends ZR{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Rd;this.invisibleObjects=new _i("jflkdsafjasdifjaslk",{...Yc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Ir("fdasfa",{..._o.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=xS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=gS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof 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 r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>$l(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===hi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Ir&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Ir&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Tn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Ir&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Di(n)&&Al(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof zi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Al(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Di(o)&&(o.freeBooleanPointer(),n instanceof ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof vs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Di(o)&&(o.invalidateUpstreamBooleanData(),Al(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Ir&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{aS(a,r,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Tn||l instanceof Ir)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Ko&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{De.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=li(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ql(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,x=Ze.zoom(p,r);x[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Jo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=li(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Jc.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Jo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Td(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Jo&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Di(s)||Ml(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Ll(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Di(a)||Ml(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Ll(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)De.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)De.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)De.is(r)&&r.traverseEntity(e)}updateFont(e,r){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 n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Al(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Fo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)De.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Id(e,r,l);return c instanceof zi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof et&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new eL().fromArray(m)),h=new oL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new tL;return o.setFromPoints(r),o.getCenter(IS),IS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Mt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ir&&e(r.material[o]);else r.material instanceof ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Ko&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new zl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as nL}from"three/examples/jsm/loaders/DRACOLoader.js";var ki;function ES(i){return ki||(ki=new nL,ki.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ki.decoderPending}async function aL(i){if(ki){let t={attributeIDs:ki.defaultAttributeIDs,attributeTypes:ki.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ki.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function NS(i,t){let[e,r]=up(Bc.deserialize(new Uint8Array(i)));return ru(e),t&&t(e),r.result().data}function DS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function _S(i){for(let t of i){let e=await aL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as Pme}from"three";import{mergeBufferGeometries as Cme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function RS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as LS,ShaderLib as sL}from"three";function BS(i){let t=new Set;return i.traverse(e=>{if(e instanceof nr)if(pt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(lL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new LS,specularColor:new LS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},sL.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=ev(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else cL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function lL(i){return i.getLayersOfType("transmission").length>0}function cL(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function VS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function zS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as uL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function GS(i){let t=[];return i.traverse(e=>{e instanceof Ni&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&RS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Mt&&a.unshift(r.geometry),a.length){let s=uL(a);r instanceof Mt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Pv})}),i}function FS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function jS(i){Object.values(i.shared.materials).forEach(t=>{lm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?lm(e.material):"materials"in e&&e.materials.forEach(r=>{lm(r)})})}function lm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var WS=Is(kS(),1);var HS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",cm=class extends pL{load(t,e,r,o=console.error){let n=new dL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(HS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(HS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await NS(t,jS),r=DS(e);e.version&&(0,WS.default)(e.version,"1.10.96")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&ES(),Nv(e)&&Mb(),jv(e)&&mv(),O1(e)&&S1(),zd(e)&&sm()].filter(Boolean)),r.length&&await _S(r);let o=!1,n=new xn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Fd(e.scene,n);zd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=GS(a),a=BS(a),a=VS(a),a=zS(a),a=FS(a),a}};export{cm as default};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ji},viewport:{type:"v2",value:new ji},basisViewport:{type:"v2",value:new ji},debugColor:{type:"v3",value:new zR},covariancesTextureSize:{type:"v2",value:new ji(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ji(1024,1024)},orthoZoom:{type:"f",value:-1}};return new YR({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:qR,depthTest:!0,depthWrite:!1,side:FR})}static buildGeomtery(e){let r=new VR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new BR(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new HR().copy(r),s=new Uint32Array(e),l=new kR(s,1,!1);return l.setUsage(jR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new ji(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new ji(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=GR.toHalfFloat(this.covariances[h]);s=new Bd(l,n.x,n.y,PS,UR)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Bd(l,n.x,n.y,PS,wS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,x=h*4;c[x]=SS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[x+1]=Ld(this.centers[y]),c[x+2]=Ld(this.centers[y+1]),c[x+3]=Ld(this.centers[y+2])}let u=new Bd(c,a.x,a.y,XR,KR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Bd(p,d,1,$R,wS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Vd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Vd),this.material.uniforms.basisViewport.value.set(2/Vd.x,2/Vd.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var TS,am=new Promise(i=>{TS=i}),OS=!1;var Gd;function sm(){if(OS)return;if(Gd)return Gd;async function i(){let e=await import("./gaussian-splat-compression.js");TS(e),OS=!0}return Gd=i(),Gd}var MS;am.then(i=>MS=i);var zl=class{constructor(t={}){Xi(this,"updateView",function(){let t=new CS,e=[],r=new Cs(0,0,-1),o=new Cs(0,0,-1),n=new Cs,a=new Cs;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new CS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new QR;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Cs().fromArray(t.position)),t.orientation&&(t.orientation=new AS().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new MS.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Cs,o=new AS,n=!1,a=1,s,l){this.splatMesh=Ui.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=vS(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var iL=new rL;iL.wireframe=!0;var IS=new JR,Fd=class extends ZR{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Rd;this.invisibleObjects=new _i("jflkdsafjasdifjaslk",{...Yc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Ir("fdasfa",{..._o.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=xS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=gS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof 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 r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>$l(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===hi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Ir&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Ir&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Tn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Ir&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Di(n)&&Al(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof zi&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Al(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Di(o)&&(o.freeBooleanPointer(),n instanceof ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof vs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Di(o)&&(o.invalidateUpstreamBooleanData(),Al(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Ir&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{aS(a,r,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Tn||l instanceof Ir)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Ko&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{De.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=li(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ql(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,x=Ze.zoom(p,r);x[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Jo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=li(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Jc.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof Jo&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Td(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Jo&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Di(s)||Ml(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Ll(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Di(a)||Ml(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Ll(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)De.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)De.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)De.is(r)&&r.traverseEntity(e)}updateFont(e,r){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 n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Al(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Fo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)De.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Id(e,r,l);return c instanceof zi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof et&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new eL().fromArray(m)),h=new oL(p,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new tL;return o.setFromPoints(r),o.getCenter(IS),IS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Mt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ir&&e(r.material[o]);else r.material instanceof ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Ko&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new zl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as nL}from"three/examples/jsm/loaders/DRACOLoader.js";var ki;function ES(i){return ki||(ki=new nL,ki.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ki.decoderPending}async function aL(i){if(ki){let t={attributeIDs:ki.defaultAttributeIDs,attributeTypes:ki.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ki.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function NS(i,t){let[e,r]=up(Bc.deserialize(new Uint8Array(i)));return ru(e),t&&t(e),r.result().data}function DS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function _S(i){for(let t of i){let e=await aL(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}import{Mesh as Pme}from"three";import{mergeBufferGeometries as Cme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function RS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as LS,ShaderLib as sL}from"three";function BS(i){let t=new Set;return i.traverse(e=>{if(e instanceof nr)if(pt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(lL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new LS,specularColor:new LS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},sL.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=ev(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else cL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function lL(i){return i.getLayersOfType("transmission").length>0}function cL(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function VS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function zS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as uL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function GS(i){let t=[];return i.traverse(e=>{e instanceof Ni&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&RS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Mt&&a.unshift(r.geometry),a.length){let s=uL(a);r instanceof Mt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Pv})}),i}function FS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function jS(i){Object.values(i.shared.materials).forEach(t=>{lm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?lm(e.material):"materials"in e&&e.materials.forEach(r=>{lm(r)})})}function lm(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var WS=Is(kS(),1);var HS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",cm=class extends pL{load(t,e,r,o=console.error){let n=new dL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(HS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(HS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await NS(t,jS),r=DS(e);e.version&&(0,WS.default)(e.version,"1.10.97")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&ES(),Nv(e)&&Mb(),jv(e)&&mv(),O1(e)&&S1(),zd(e)&&sm()].filter(Boolean)),r.length&&await _S(r);let o=!1,n=new xn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Fd(e.scene,n);zd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=GS(a),a=BS(a),a=VS(a),a=zS(a),a=FS(a),a}};export{cm as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/loader",
3
- "version": "1.10.96",
3
+ "version": "1.10.97",
4
4
  "description": "Spline is a collaborative design platform for creating production-ready interactive experiences in multiple dimensions. © 2025 Spline, Inc.",
5
5
  "keywords": [
6
6
  "spline",