@splinetool/loader 1.12.34 → 1.12.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +3 -3
- package/build/SplineLoader.js +3 -3
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.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=Fl(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=Fl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:PI(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 gb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return gb(e,t)}return Ui.isBoolean(i)?Ui.getDisplayedValue(i).toLowerCase():Ui.getDisplayedValue(i)},Fl=(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
|
`:"")+Fl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return gb(o,t)}}return""}).join("");var MI=new Ee.Matrix4,II=new Ee.Matrix4;function EI(i,t,e){let r=[new Ee.Vector3,new Ee.Vector3,new Ee.Vector3],o=[new Ee.Vector3,new Ee.Vector3,new Ee.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=Ee.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ee.Matrix4().makeBasis(r[0],r[1],r[2])}var xb=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??ts.create({parameters:{...In,width:typeof In.width=="number"?In.width:100,height:typeof In.height=="number"?In.height:100}}).userData.shape;return{path:i.path??Ba.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Cu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Kf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ee.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Kf=class extends Ee.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)||!mb(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]=EI(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:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new $i(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=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),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=fo({windingRule:Xe.ODD,elementType:Pt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=jf}R=_.vertexCount}let V=D+2*R+x*2,U=D+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,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=MI;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(II.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=qu(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ee.Vector3,s=new Ee.Vector3,l=new Ee.Vector3,c=new Ee.Vector3,u=new Ee.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new Ee.Matrix4().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Ee.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 g=new Ee.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ee.Matrix4,d=new Ee.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(Ee.MathUtils.lerp(a,a+s,h)*Ee.MathUtils.DEG2RAD);let m=Ee.MathUtils.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=Xe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=fo({windingRule:r,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Bl}let l;try{l=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Ff}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],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}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 g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,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+N)%N;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),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+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 Ee.Vector3,u=new Ee.Vector3,d=new Ee.Vector3,p=new Ee.Vector3,f=new Ee.Vector2;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),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:P-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,b,d,p,f),b++,!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:P+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,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ee.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Ee.Vector3,p=new Ee.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,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ee.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,g=o*m;y<g;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 Bn=require("three"),bb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function vb(){let i=new Bn.BufferGeometry;return i.setAttribute("position",new Bn.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Bn.BufferAttribute(new Uint16Array([]),1)),i}var DI=vb().attributes,_I=12,RI=1,Vn=class extends Bn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,DI),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=Ui.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=LI(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ye().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>Tr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Xe.NONZERO:Xe.ODD,subdivisions:this.isLowResolution&&s>0?RI:_I}})),T=S.length?(0,bb.mergeBufferGeometries)(S):vb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ht(new Bn.BufferGeometry,Vn.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 LI(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 wb,ld=new Promise(i=>{wb=i}),Sb=!1;var sd;function Pb(i){if(Sb)return;if(sd)return sd;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.34/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});wb(c),Sb=!0}return sd=t(),sd}var Ob=require("three");var BI=["font"];function zo(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];tf(d)&&!BI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),tf(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new Ob.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 zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return is.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Qf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(La.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Qf(s)}return l}var Tb=require("three"),VI=new Tb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=VI.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 cd=new lt.Box3,as=new lt.Vector3,Oe;ld.then(i=>{Oe=i});var Cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ab=new Uint32Array([0,1,2,3]),Mb=new Uint8Array([4]),zt=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.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(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(as.fromArray(n));let s=as.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}=zt.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&&(zt.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;cd.setFromBufferAttribute(r),cd.getCenter(o),e.boundingSphere.radius=o.distanceTo(cd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),cd.getSize(as);let n={width:as.x,height:as.y,depth:as.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Cb,indexWASM:Ab,verticesPerFaceWASM:Mb},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.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:zo(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}=th(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}=rh(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=Cb,n=Ab,a=Mb);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=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.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,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Ib=["getX","getY","getZ"];function th(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[Ib[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Ib[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 ud=new lt.Vector3,Zf=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3;function rh(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]){ud.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Zf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Jf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),eh.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Zf.sub(ud).normalize(),Jf.sub(ud).normalize(),eh.sub(ud).normalize();let l=Zf.cross(Jf).dot(eh),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 Xr={};gm(Xr,{calcBoolean:()=>jI,calcBooleanTopological:()=>FI,freeMeshSet:()=>WI,getMeshSet:()=>UI,hasOpenEdges:()=>kI,transformMeshSet:()=>HI});var zI,Eb=new Promise(i=>{zI=i});var Ul=require("three");var ke,ss;Eb.then(i=>ke=i);function GI(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}=th(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=rh(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 Nb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function Db(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function FI(i,t){ss===void 0&&(ss=ke.init_csg());let e=Nb(i),r=ke.csg_calc_topological(ss,e,i.length,Db(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function jI(i,t,e,r){ss===void 0&&(ss=ke.init_csg());let o=Nb(i),n=ke.csg_calc(ss,o,i.length,r,Db(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function UI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=GI(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=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function kI(i){return ke.has_open_edges(i)}function HI(i,t){ke.transform_csg_mesh(i,t.elements)}function WI(i){ke.free_csg_mesh(i)}var qI={ConeGeometry:wx,CubeGeometry:Px,CylinderGeometry:Sx,DodecahedronGeometry:Tx,EllipseGeometry:ts,HelixGeometry:Kx,IcosahedronGeometry:Zx,LatheGeometry:Jx,NonParametricGeometry:ob,PolygonGeometry:id,PyramidGeometry:ib,RectangleGeometry:is,SphereGeometry:nb,PlaneGeometry:sb,BackdropGeometry:lb,StarGeometry:nd,TextFrameGeometry:ub,TorusGeometry:db,TorusKnotGeometry:fb,TriangleGeometry:hb,PathGeometry:xb,VectorGeometry:Tr},Qf=i=>qI[i.type].create(i);function ls(i){return i!==null&&"booleanOp"in i}var cs=class extends $a(dd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new dd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!ls(this.parent)&&this.visible,ls(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ls(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof cs&&(e.freeBooleanPointer(),ls(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ls(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ls(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var pd=new us.Box3;function kl(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)}pd.min.set(n,a,s),pd.max.set(l,c,u),pd.getCenter(r),pd.getSize(o).multiplyScalar(.5)}var $I=new us.BufferGeometry,XI=new us.MeshBasicMaterial,Xt=class extends cs{constructor(t,e){super($I,XI),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?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Cd=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.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=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=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 oh=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}},Yt=new oh;var ih=require("three");var _b=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=_b.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 Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof ih.Vector2?e:new ih.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 nh=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof nh.Vector3?e:new nh.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 Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof qt?e:new qt(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 YI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rb=/[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=Rb.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&&Yt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Yt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Yt.getKeyword(f,e),g.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&&Yt.contains(m)&&e.include(Yt.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=YI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Rb);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 KI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ah=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ah.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=KI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=ah;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var QI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
18
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var wb,ld=new Promise(i=>{wb=i}),Sb=!1;var sd;function Pb(i){if(Sb)return;if(sd)return sd;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.35/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});wb(c),Sb=!0}return sd=t(),sd}var Ob=require("three");var BI=["font"];function zo(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];tf(d)&&!BI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),tf(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ye.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new Ob.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 zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return is.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Qf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(La.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Qf(s)}return l}var Tb=require("three"),VI=new Tb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=VI.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 cd=new lt.Box3,as=new lt.Vector3,Oe;ld.then(i=>{Oe=i});var Cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ab=new Uint32Array([0,1,2,3]),Mb=new Uint8Array([4]),zt=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.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(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(as.fromArray(n));let s=as.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}=zt.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&&(zt.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;cd.setFromBufferAttribute(r),cd.getCenter(o),e.boundingSphere.radius=o.distanceTo(cd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),cd.getSize(as);let n={width:as.x,height:as.y,depth:as.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Cb,indexWASM:Ab,verticesPerFaceWASM:Mb},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.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:zo(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}=th(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}=rh(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=Cb,n=Ab,a=Mb);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=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.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,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Ib=["getX","getY","getZ"];function th(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[Ib[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Ib[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 ud=new lt.Vector3,Zf=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3;function rh(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]){ud.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Zf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Jf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),eh.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Zf.sub(ud).normalize(),Jf.sub(ud).normalize(),eh.sub(ud).normalize();let l=Zf.cross(Jf).dot(eh),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 Xr={};gm(Xr,{calcBoolean:()=>jI,calcBooleanTopological:()=>FI,freeMeshSet:()=>WI,getMeshSet:()=>UI,hasOpenEdges:()=>kI,transformMeshSet:()=>HI});var zI,Eb=new Promise(i=>{zI=i});var Ul=require("three");var ke,ss;Eb.then(i=>ke=i);function GI(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}=th(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=rh(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 Nb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function Db(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function FI(i,t){ss===void 0&&(ss=ke.init_csg());let e=Nb(i),r=ke.csg_calc_topological(ss,e,i.length,Db(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function jI(i,t,e,r){ss===void 0&&(ss=ke.init_csg());let o=Nb(i),n=ke.csg_calc(ss,o,i.length,r,Db(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ke.free_mesh_data(n),h}function UI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=GI(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=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function kI(i){return ke.has_open_edges(i)}function HI(i,t){ke.transform_csg_mesh(i,t.elements)}function WI(i){ke.free_csg_mesh(i)}var qI={ConeGeometry:wx,CubeGeometry:Px,CylinderGeometry:Sx,DodecahedronGeometry:Tx,EllipseGeometry:ts,HelixGeometry:Kx,IcosahedronGeometry:Zx,LatheGeometry:Jx,NonParametricGeometry:ob,PolygonGeometry:id,PyramidGeometry:ib,RectangleGeometry:is,SphereGeometry:nb,PlaneGeometry:sb,BackdropGeometry:lb,StarGeometry:nd,TextFrameGeometry:ub,TorusGeometry:db,TorusKnotGeometry:fb,TriangleGeometry:hb,PathGeometry:xb,VectorGeometry:Tr},Qf=i=>qI[i.type].create(i);function ls(i){return i!==null&&"booleanOp"in i}var cs=class extends $a(dd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new dd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!ls(this.parent)&&this.visible,ls(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ls(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof cs&&(e.freeBooleanPointer(),ls(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ls(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ls(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var pd=new us.Box3;function kl(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)}pd.min.set(n,a,s),pd.max.set(l,c,u),pd.getCenter(r),pd.getSize(o).multiplyScalar(.5)}var $I=new us.BufferGeometry,XI=new us.MeshBasicMaterial,Xt=class extends cs{constructor(t,e){super($I,XI),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?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Cd=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.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=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=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 oh=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}},Yt=new oh;var ih=require("three");var _b=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=_b.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 Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof ih.Vector2?e:new ih.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 nh=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof nh.Vector3?e:new nh.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 Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof qt?e:new qt(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 YI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rb=/[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=Rb.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&&Yt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Yt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Yt.getKeyword(f,e),g.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&&Yt.contains(m)&&e.include(Yt.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=YI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Rb);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 KI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ah=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ah.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=KI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},$e=ah;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var QI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),ZI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ds=class extends be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=QI.exec(e);if(r){let o=r[2],n;for(;n=ZI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ps=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)}};Yt.addKeyword("uv",function(){return new ps});Yt.addKeyword("uv2",function(){return new ps(1)});var fd=require("three");var zn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??zn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case fd.LinearEncoding:return["Linear"];case fd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=zn.Nodes[this.method],s=e.include(a);if(s===zn.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=zn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=zn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},yr=zn;yr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Kb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.
|
|
1876
|
+
}`,[e,r])}}();var _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Kb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.35/build/ui.wasm"};var yi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Bt),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new sr,this.previouseProjectionMatrix=new sr}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(xd.UniformsUtils.merge([xd.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 Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=oS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=pp(this.centers[y]),c[g+2]=pp(this.centers[y+1]),c[g+3]=pp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let 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 Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data: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&&(fp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fp),this.material.uniforms.basisViewport.value.set(2/fp.x,2/fp.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var nS,am=new Promise(i=>{nS=i}),iS=!1;var mp;function sm(){if(iS)return;if(mp)return mp;async function i(){let e=await import("./gaussian-splat-compression.js");nS(e),iS=!0}return mp=i(),mp}var aS;am.then(i=>aS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.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 vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.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 vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.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 aS.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 vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.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=rS(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 LE=new oo.MeshBasicMaterial;LE.wireframe=!0;var sS=new oo.Vector3,yp=class extends oo.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 dp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ii.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=eS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=J1(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 to&&(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)=>Ec(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===zi)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 to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&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 to&&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(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),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(),sn(n)&&dc(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 fn&&(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),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&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()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&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 to&&(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{$1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Qn||l instanceof to)&&(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 Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[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 Oi&&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=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.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 Oi&&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),ip(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=lp(e,r,l);return c instanceof fn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.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 oo.Box3;return o.setFromPoints(r),o.getCenter(sS),sS}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 Xt)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 Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var lS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function cS(i){return gn||(gn=new lS.DRACOLoader,gn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function BE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 uS(i,t){let[e,r]=Up(bu.deserialize(new Uint8Array(i)));return zu(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 pS(i){for(let t of i){let e=await BE(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 VE=require("three"),zE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function fS(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 wc=require("three");function hS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(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(GE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.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=Yb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else FE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function GE(i){return i.getLayersOfType("transmission").length>0}function FE(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 mS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function yS(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 gS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function xS(i){let t=[];return i.traverse(e=>{e instanceof nn&&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&&fS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Xt&&a.unshift(r.geometry),a.length){let s=(0,gS.mergeBufferGeometries)(a);r instanceof Xt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:fv})}),i}function bS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function vS(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 OS=ll(wS(),1);var PS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gp=class extends xp.Loader{load(t,e,r,o=console.error){let n=new xp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(PS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(PS),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 uS(t,vS),r=dS(e);e.version&&(0,OS.default)(e.version,"1.12.34")>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&&cS(),xv(e)&&Pb(),Mv(e)&&av(),l1(e)&&n1(),hp(e)&&sm()].filter(Boolean)),r.length&&await pS(r);let o=!1,n=new qn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new yp(e.scene,n);hp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=xS(a),a=hS(a),a=mS(a),a=yS(a),a=bS(a),a}};
|
|
4379
|
+
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;c[g]=oS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=pp(this.centers[y]),c[g+2]=pp(this.centers[y+1]),c[g+3]=pp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let 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 Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data: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&&(fp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fp),this.material.uniforms.basisViewport.value.set(2/fp.x,2/fp.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var nS,am=new Promise(i=>{nS=i}),iS=!1;var mp;function sm(){if(iS)return;if(mp)return mp;async function i(){let e=await import("./gaussian-splat-compression.js");nS(e),iS=!0}return mp=i(),mp}var aS;am.then(i=>aS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.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 vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.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 vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.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 aS.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 vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.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=rS(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 LE=new oo.MeshBasicMaterial;LE.wireframe=!0;var sS=new oo.Vector3,yp=class extends oo.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 dp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ii.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=eS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=J1(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 to&&(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)=>Ec(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===zi)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 to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&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 to&&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(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),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(),sn(n)&&dc(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 fn&&(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),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&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()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&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 to&&(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{$1(a,r,o,{scene:this,shared:n}),a instanceof ht&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Qn||l instanceof to)&&(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 Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[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 Oi&&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=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.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 Oi&&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),ip(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Ge.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(Ge.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=lp(e,r,l);return c instanceof fn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ht&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.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 oo.Box3;return o.setFromPoints(r),o.getCenter(sS),sS}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 Xt)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 Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var lS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function cS(i){return gn||(gn=new lS.DRACOLoader,gn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function BE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 uS(i,t){let[e,r]=Up(bu.deserialize(new Uint8Array(i)));return zu(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 pS(i){for(let t of i){let e=await BE(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 VE=require("three"),zE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function fS(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 wc=require("three");function hS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(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(GE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.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=Yb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else FE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function GE(i){return i.getLayersOfType("transmission").length>0}function FE(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 mS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function yS(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 gS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function xS(i){let t=[];return i.traverse(e=>{e instanceof nn&&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&&fS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Xt&&a.unshift(r.geometry),a.length){let s=(0,gS.mergeBufferGeometries)(a);r instanceof Xt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:fv})}),i}function bS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function vS(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 OS=ll(wS(),1);var PS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gp=class extends xp.Loader{load(t,e,r,o=console.error){let n=new xp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(PS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(PS),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 uS(t,vS),r=dS(e);e.version&&(0,OS.default)(e.version,"1.12.35")>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&&cS(),xv(e)&&Pb(),Mv(e)&&av(),l1(e)&&n1(),hp(e)&&sm()].filter(Boolean)),r.length&&await pS(r);let o=!1,n=new qn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new yp(e.scene,n);hp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=xS(a),a=hS(a),a=mS(a),a=yS(a),a=bS(a),a}};
|
package/build/SplineLoader.js
CHANGED
|
@@ -15,7 +15,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.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=ml(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=ml(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:iE(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 Eb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return Eb(e,t)}return vi.isBoolean(i)?vi.getDisplayedValue(i).toLowerCase():vi.getDisplayedValue(i)},ml=(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
|
`:"")+ml(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return Eb(o,t)}}return""}).join("");var uE=new pn,dE=new pn;function pE(i,t,e){let r=[new Lt,new Lt,new Lt],o=[new Lt,new Lt,new Lt];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Fu.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new pn().makeBasis(r[0],r[1],r[2])}var _b=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??La.create({parameters:{...nn,width:typeof nn.width=="number"?nn.width:100,height:typeof nn.height=="number"?nn.height:100}}).userData.shape;return{path:i.path??ya.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Qc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new jf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Db,{userData:{...i,type:"PathGeometry"}})}},jf=class extends Db{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)||!Mb(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]=pE(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:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new Oi(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=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),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=Hr({windingRule:je.ODD,elementType:ct.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Cf}R=_.vertexCount}let V=D+2*R+x*2,U=D+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,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Fa(B.positions,3)),this.setAttribute("normal",new Fa(B.normals,3)),this.setAttribute("uv",new Fa(B.uvs,2)),this.setIndex(q);let H=uE;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(dE.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Fa(B.positions,3)),this.setAttribute("normal",new Fa(B.normals,3)),this.setAttribute("uv",new Fa(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=xu(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Lt,s=new Lt,l=new Lt,c=new Lt,u=new Lt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new pn().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Lt(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 g=new pn().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new pn,d=new pn;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(Fu.lerp(a,a+s,h)*Fu.DEG2RAD);let m=Fu.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=Hr({windingRule:r,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=ul}let l;try{l=Hr({windingRule:je.ODD,elementType:ct.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Tf}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],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}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 g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,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+N)%N;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),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Lt,u=new Lt,d=new Lt,p=new Lt,f=new Nb;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),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:P-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,b,d,p,f),b++,!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:P+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,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Lt(0,0,l?-1:1).applyMatrix4(a),d=new Lt,p=new Nb;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,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new cE().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,g=o*m;y<g;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 Rb,BufferGeometry as Uf}from"three";import{mergeBufferGeometries as hE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Lb(){let i=new Uf;return i.setAttribute("position",new Rb(new Float32Array([]),3)),i.setIndex(new Rb(new Uint16Array([]),1)),i}var mE=Lb().attributes,yE=12,gE=1,fn=class extends Uf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,mE),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=vi.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=xE(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ue().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>rr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&s>0?gE:yE}})),T=S.length?hE(S):Lb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ct(new Uf,fn.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 xE(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 Hf,BufferAttribute as Gb,Uint32BufferAttribute as Wf,Float32BufferAttribute as qf,Matrix4 as PE,Vector3 as gl,Sphere as OE,Box3 as TE,BoxGeometry as CE}from"three";var Vb,Uu=new Promise(i=>{Vb=i}),Bb=!1;var ju;function zb(i){if(Bb)return;if(ju)return ju;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.34/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});Vb(c),Bb=!0}return ju=t(),ju}import{BufferGeometryLoader as bE}from"three";var vE=["font"];function ho(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];Np(d)&&!vE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Np(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new bE().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 St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Ga.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=Ue.createFromState(ma.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=kf(s)}return l}import{Matrix4 as SE}from"three";var wE=new SE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=wE.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 ku=new TE,ja=new gl,we;Uu.then(i=>{we=i});var Fb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),jb=new Uint32Array([0,1,2,3]),Ub=new Uint8Array([4]),St=class extends Hf{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.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(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(ja.fromArray(n));let s=ja.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}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new CE(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&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new OE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ku.setFromBufferAttribute(r),ku.getCenter(o),e.boundingSphere.radius=o.distanceTo(ku.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ku.getSize(ja);let n={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:Fb,indexWASM:jb,verticesPerFaceWASM:Ub},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.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:ho(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}=Kf(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}=Qf(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=Fb,n=jb,a=Ub);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=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new PE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Hf;if(P.setIndex(new Wf(w,1)),P.setAttribute("position",new qf(f,3)),P.setAttribute("normal",new qf(m,3)),r){P.setAttribute("faceMap",new Wf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new Gb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Hf;h.setAttribute("position",new qf(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Gb(m,3)),h.setIndex(new Wf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var kb=["getX","getY","getZ"];function Kf(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[kb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[kb[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 Hu=new gl,$f=new gl,Xf=new gl,Yf=new gl;function Qf(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]){Hu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),$f.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Xf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Yf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),$f.sub(Hu).normalize(),Xf.sub(Hu).normalize(),Yf.sub(Hu).normalize();let l=$f.cross(Xf).dot(Yf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 Tr={};Ow(Tr,{calcBoolean:()=>NE,calcBooleanTopological:()=>EE,freeMeshSet:()=>LE,getMeshSet:()=>DE,hasOpenEdges:()=>_E,transformMeshSet:()=>RE});var AE,Hb=new Promise(i=>{AE=i});import{Float32BufferAttribute as Wb,Sphere as ME}from"three";var Ve,Ua;Hb.then(i=>Ve=i);function IE(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}=Kf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Qf(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 qb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function $b(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function EE(i,t){Ua===void 0&&(Ua=Ve.init_csg());let e=qb(i),r=Ve.csg_calc_topological(Ua,e,i.length,$b(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NE(i,t,e,r){Ua===void 0&&(Ua=Ve.init_csg());let o=qb(i),n=Ve.csg_calc(Ua,o,i.length,r,$b(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Wb(d,3)),e.setAttribute("normal",new Wb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ME),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function DE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=IE(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=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function _E(i){return Ve.has_open_edges(i)}function RE(i,t){Ve.transform_csg_mesh(i,t.elements)}function LE(i){Ve.free_csg_mesh(i)}var BE={ConeGeometry:Mx,CubeGeometry:Ix,CylinderGeometry:Ax,DodecahedronGeometry:Ex,EllipseGeometry:La,HelixGeometry:ab,IcosahedronGeometry:sb,LatheGeometry:lb,NonParametricGeometry:xb,PolygonGeometry:Vu,PyramidGeometry:bb,RectangleGeometry:Ga,SphereGeometry:Sb,PlaneGeometry:wb,BackdropGeometry:Pb,StarGeometry:zu,TextFrameGeometry:Ob,TorusGeometry:Tb,TorusKnotGeometry:Cb,TriangleGeometry:Ab,PathGeometry:_b,VectorGeometry:rr},kf=i=>BE[i.type].create(i);function ka(i){return i!==null&&"booleanOp"in i}var Ha=class extends Aa(zE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new VE}updateVisible(e){super.updateVisible(e),this.visible=!ka(this.parent)&&this.visible,ka(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Tr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ka(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ha&&(e.freeBooleanPointer(),ka(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ka(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ka(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Wu=new GE;function xl(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)}Wu.min.set(n,a,s),Wu.max.set(l,c,u),Wu.getCenter(r),Wu.getSize(o).multiplyScalar(.5)}var UE=new FE,kE=new jE,Et=class extends Ha{constructor(t,e){super(UE,kE),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?xl(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 pD,Matrix4 as fD,Sphere as Fv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Gv,MathUtils as Ch,Vector3 as Ah}from"three";import{ShaderMaterial as FN,Texture as jN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as JE,CubeRefractionMapping as eN,CubeUVReflectionMapping as tN,LinearEncoding as ov,sRGBEncoding as rN}from"three";var bl=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 Zf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Zf;import{Vector2 as Xb}from"three";import{MathUtils as HE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Xb?e:new Xb(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 Yb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Yb?e:new Yb(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 Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Mt?e:new Mt(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 WE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Kb=/[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=Kb.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&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),g.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&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=WE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Kb);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 qE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Jf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Jf.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=qE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=Jf;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var $E=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 Hf,BufferAttribute as Gb,Uint32BufferAttribute as Wf,Float32BufferAttribute as qf,Matrix4 as PE,Vector3 as gl,Sphere as OE,Box3 as TE,BoxGeometry as CE}from"three";var Vb,Uu=new Promise(i=>{Vb=i}),Bb=!1;var ju;function zb(i){if(Bb)return;if(ju)return ju;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.35/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});Vb(c),Bb=!0}return ju=t(),ju}import{BufferGeometryLoader as bE}from"three";var vE=["font"];function ho(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];Np(d)&&!vE.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),Np(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Ue.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new bE().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 St(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new fn(n,t);if(n.type==="InputGeometry")return new fn(n,t);if(n.type==="UIGeometry")return Ga.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=Ue.createFromState(ma.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=kf(s)}return l}import{Matrix4 as SE}from"three";var wE=new SE;function yl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=wE.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 ku=new TE,ja=new gl,we;Uu.then(i=>{we=i});var Fb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),jb=new Uint32Array([0,1,2,3]),Ub=new Uint8Array([4]),St=class extends Hf{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.map(l=>typeof l=="number"?l:1),n=hi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&yl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&yl(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(ja.fromArray(n));let s=ja.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}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new CE(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&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new OE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ku.setFromBufferAttribute(r),ku.getCenter(o),e.boundingSphere.radius=o.distanceTo(ku.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ku.getSize(ja);let n={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=St.allocate(e,n)}catch(u){console.error(u,e),a=St.allocate({positionWASM:Fb,indexWASM:jb,verticesPerFaceWASM:Ub},n)}if(we.set_destination_refinement_level(a,0),s=St.buildLevel(a,!0,c),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=St.buildLevel(a,!1,c)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=St.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:ho(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}=Kf(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}=Qf(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=Fb,n=jb,a=Ub);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=we._malloc(h),g=new Float32Array(we.HEAPF32.buffer,y,p),b=new Uint32Array(we.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new PE().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?we.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):we.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(y),P}static buildLevel(e,r,o,n,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,c=we.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=we.HEAPU32[c[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=we.HEAPU32[c[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=we.HEAPU32[c[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=we.HEAPU32[c[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new Hf;if(P.setIndex(new Wf(w,1)),P.setAttribute("position",new qf(f,3)),P.setAttribute("normal",new qf(m,3)),r){P.setAttribute("faceMap",new Wf(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new Gb(S,4))}return we.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=we.HEAPU32[s[c]>>2],d=we.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new Hf;h.setAttribute("position",new qf(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Gb(m,3)),h.setIndex(new Wf(f,1)),we.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,n?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,n?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=we.HEAPU32[l[u]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=we.HEAPU32[l[u]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=we.HEAPU32[l[u]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var kb=["getX","getY","getZ"];function Kf(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[kb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[kb[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 Hu=new gl,$f=new gl,Xf=new gl,Yf=new gl;function Qf(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]){Hu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),$f.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Xf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Yf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),$f.sub(Hu).normalize(),Xf.sub(Hu).normalize(),Yf.sub(Hu).normalize();let l=$f.cross(Xf).dot(Yf),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 Tr={};Ow(Tr,{calcBoolean:()=>NE,calcBooleanTopological:()=>EE,freeMeshSet:()=>LE,getMeshSet:()=>DE,hasOpenEdges:()=>_E,transformMeshSet:()=>RE});var AE,Hb=new Promise(i=>{AE=i});import{Float32BufferAttribute as Wb,Sphere as ME}from"three";var Ve,Ua;Hb.then(i=>Ve=i);function IE(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}=Kf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=Qf(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 qb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ve._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ve.HEAPU32.buffer,n,t):new Float32Array(Ve.HEAPF32.buffer,n,t)).set(i,0),n}function $b(i){switch(i){case 0:return Ve.OP.UNION;case 1:return Ve.OP.INTERSECTION;case 2:return Ve.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function EE(i,t){Ua===void 0&&(Ua=Ve.init_csg());let e=qb(i),r=Ve.csg_calc_topological(Ua,e,i.length,$b(t));Ve._free(e);let o=6,n=Ve.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ve.HEAPU32[n[s]>>2],c=new Float32Array(Ve.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ve.HEAPU32[n[s]>>2],d=new Uint32Array(Ve.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=Ve.HEAPU32[n[s]>>2],f=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ve.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function NE(i,t,e,r){Ua===void 0&&(Ua=Ve.init_csg());let o=qb(i),n=Ve.csg_calc(Ua,o,i.length,r,$b(t));Ve._free(o);let a=5,s=Ve.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ve.HEAPU32[s[c]>>2],d=Ve.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Ve.HEAPU32[s[c]>>2],f=Ve.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Wb(d,3)),e.setAttribute("normal",new Wb(f,3));let m=Ve.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ME),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ve.free_mesh_data(n),h}function DE(i,t,e){if(Ve===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=IE(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=Ve._malloc(u),h=new Float32Array(Ve.HEAPF32.buffer,f,l),m=new Uint32Array(Ve.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=Ve.get_csg_mesh(f,a,f+d,s,n);return Ve._free(f),y}function _E(i){return Ve.has_open_edges(i)}function RE(i,t){Ve.transform_csg_mesh(i,t.elements)}function LE(i){Ve.free_csg_mesh(i)}var BE={ConeGeometry:Mx,CubeGeometry:Ix,CylinderGeometry:Ax,DodecahedronGeometry:Ex,EllipseGeometry:La,HelixGeometry:ab,IcosahedronGeometry:sb,LatheGeometry:lb,NonParametricGeometry:xb,PolygonGeometry:Vu,PyramidGeometry:bb,RectangleGeometry:Ga,SphereGeometry:Sb,PlaneGeometry:wb,BackdropGeometry:Pb,StarGeometry:zu,TextFrameGeometry:Ob,TorusGeometry:Tb,TorusKnotGeometry:Cb,TriangleGeometry:Ab,PathGeometry:_b,VectorGeometry:rr},kf=i=>BE[i.type].create(i);function ka(i){return i!==null&&"booleanOp"in i}var Ha=class extends Aa(zE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new VE}updateVisible(e){super.updateVisible(e),this.visible=!ka(this.parent)&&this.visible,ka(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Tr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ka(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ha&&(e.freeBooleanPointer(),ka(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ka(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ka(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Wu=new GE;function xl(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)}Wu.min.set(n,a,s),Wu.max.set(l,c,u),Wu.getCenter(r),Wu.getSize(o).multiplyScalar(.5)}var UE=new FE,kE=new jE,Et=class extends Ha{constructor(t,e){super(UE,kE),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?xl(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 pD,Matrix4 as fD,Sphere as Fv,Vector3 as hD}from"three";import{BufferAttribute as cD,Float32BufferAttribute as Gv,MathUtils as Ch,Vector3 as Ah}from"three";import{ShaderMaterial as FN,Texture as jN}from"three";var Wo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Wo.uuidContext===null)throw new Error("plz startContext");Wo.uuidContext===Wo.globalContext?this.uuid="_gid"+Wo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Wo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Wo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},Xe=Wo;Xe.globalContext={nodeContextUuid:0},Xe.uuidContext=Wo.globalContext;import{CubeReflectionMapping as JE,CubeRefractionMapping as eN,CubeUVReflectionMapping as tN,LinearEncoding as ov,sRGBEncoding as rN}from"three";var bl=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 Zf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Nt=new Zf;import{Vector2 as Xb}from"three";import{MathUtils as HE}from"three";var ge=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Ye=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var ut=class extends Ye{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Xb?e:new Xb(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 Yb}from"three";var jt=class extends Ye{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Yb?e:new Yb(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 Ye{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Mt?e:new Mt(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 WE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Kb=/[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=Kb.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&&Nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Nt.getKeyword(f,e),g.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&&Nt.contains(m)&&e.include(Nt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=WE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Kb);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 qE=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Jf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Jf.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=qE.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Fe=Jf;Fe.PI="PI",Fe.PI2="PI2",Fe.RECIPROCAL_PI="RECIPROCAL_PI",Fe.RECIPROCAL_PI2="RECIPROCAL_PI2",Fe.LOG2="LOG2",Fe.EPSILON="EPSILON";var $E=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),XE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Wa=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=$E.exec(e);if(r){let o=r[2],n;for(;n=XE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var qa=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};Nt.addKeyword("uv",function(){return new qa});Nt.addKeyword("uv2",function(){return new qa(1)});import{LinearEncoding as YE,sRGBEncoding as KE}from"three";var hn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??hn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case YE:return["Linear"];case KE:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=hn.Nodes[this.method],s=e.include(a);if(s===hn.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=hn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=hn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Kt=hn;Kt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new qr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var dv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.
|
|
1876
|
+
}`,[e,r])}}();var Me={normalRenderTarget:new Qt,normalRenderTargetDepth:new Qt,transmissionRenderTarget:new Qt,aspectRatio:new ut,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Qt,aoRenderTarget:new Qt,aoEnabled:new dt,pixelRatioNode:new se(1),resolution:new ut,penumbraSize:new qr(5,.5),frameIndex:new Le(0),transmissionLod:new Le(2),taaEnabled:new dt(!0)};for(let i of Object.values(Me))i.isRenderGlobal=!0;var dv={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.35/build/ui.wasm"};var qo=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new qe(bt),this.shadingAlpha=new se(1),this.shadingBlend=new Le(0),this.previousModelViewMatrix=new Ut,this.previouseProjectionMatrix=new Ut}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Me.frameIndex}),e.mergeUniform({resolution:Me.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(pN.merge([dN.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 Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:iL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let r=new YR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new XR(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 rL().copy(r),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(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 Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(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]=QR.toHalfFloat(this.covariances[h]);s=new Hd(l,n.x,n.y,_S,eL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Hd(l,n.x,n.y,_S,DS);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,g=h*4;c[g]=NS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=kd(this.centers[y]),c[g+2]=kd(this.centers[y+1]),c[g+3]=kd(this.centers[y+2])}let u=new Hd(c,a.x,a.y,aL,lL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let 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 Hd(p,d,1,nL,DS);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&&(Wd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Wd),this.material.uniforms.basisViewport.value.set(2/Wd.x,2/Wd.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 LS,hm=new Promise(i=>{LS=i}),RS=!1;var $d;function mm(){if(RS)return;if($d)return $d;async function i(){let e=await import("./gaussian-splat-compression.js");LS(e),RS=!0}return $d=i(),$d}var zS;hm.then(i=>zS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new BS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;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 BS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new cL;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 _s().fromArray(t.position)),t.orientation&&(t.orientation=new VS().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 zS.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 _s,o=new VS,n=!1,a=1,s,l){this.splatMesh=Wi.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=ES(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 yL=new hL;yL.wireframe=!0;var GS=new dL,Xd=class extends uL{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 Ud;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{...Ro.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=MS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=AS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>tc(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===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Nn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(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 ji&&(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),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{yS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Nn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ec(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[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 ti&&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=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.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 ti&&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),_d(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Vd(e,r,l);return c instanceof ji&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(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 fL;return o.setFromPoints(r),o.getCenter(GS),GS}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 Et)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function FS(i){return qi||(qi=new gL,qi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function xL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.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 jS(i,t){let[e,r]=xp(Hc.deserialize(new Uint8Array(i)));return uu(e),t&&t(e),r.result().data}function US(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 kS(i){for(let t of i){let e=await xL(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 Jme}from"three";import{mergeBufferGeometries as rye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function HS(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 WS,ShaderLib as bL}from"three";function qS(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(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(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new WS,specularColor:new WS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bL.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=uv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else SL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function vL(i){return i.getLayersOfType("transmission").length>0}function SL(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 $S(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function XS(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 wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function YS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&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&&HS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Et&&a.unshift(r.geometry),a.length){let s=wL(a);r instanceof Et&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:_v})}),i}function KS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function QS(i){Object.values(i.shared.materials).forEach(t=>{ym(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?ym(e.material):"materials"in e&&e.materials.forEach(r=>{ym(r)})})}function ym(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 tw=Bs(JS(),1);var ew="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gm=class extends OL{load(t,e,r,o=console.error){let n=new PL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(ew+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(ew),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 jS(t,QS),r=US(e);e.version&&(0,tw.default)(e.version,"1.12.34")>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&&FS(),jv(e)&&zb(),Qv(e)&&Tv(),R1(e)&&N1(),qd(e)&&mm()].filter(Boolean)),r.length&&await kS(r);let o=!1,n=new On(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Xd(e.scene,n);qd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=YS(a),a=qS(a),a=$S(a),a=XS(a),a=KS(a),a}};export{gm 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 Hi},viewport:{type:"v2",value:new Hi},basisViewport:{type:"v2",value:new Hi},debugColor:{type:"v3",value:new KR},covariancesTextureSize:{type:"v2",value:new Hi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Hi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new sL({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:iL,depthTest:!0,depthWrite:!1,side:ZR})}static buildGeomtery(e){let r=new YR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new XR(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 rL().copy(r),s=new Uint32Array(e),l=new tL(s,1,!1);return l.setUsage(JR),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(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 Hi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Hi(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]=QR.toHalfFloat(this.covariances[h]);s=new Hd(l,n.x,n.y,_S,eL)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Hd(l,n.x,n.y,_S,DS);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,g=h*4;c[g]=NS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=kd(this.centers[y]),c[g+2]=kd(this.centers[y+1]),c[g+3]=kd(this.centers[y+2])}let u=new Hd(c,a.x,a.y,aL,lL);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let 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 Hd(p,d,1,nL,DS);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&&(Wd.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Wd),this.material.uniforms.basisViewport.value.set(2/Wd.x,2/Wd.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 LS,hm=new Promise(i=>{LS=i}),RS=!1;var $d;function mm(){if(RS)return;if($d)return $d;async function i(){let e=await import("./gaussian-splat-compression.js");LS(e),RS=!0}return $d=i(),$d}var zS;hm.then(i=>zS=i);var ql=class{constructor(t={}){Qi(this,"updateView",function(){let t=new BS,e=[],r=new _s(0,0,-1),o=new _s(0,0,-1),n=new _s,a=new _s;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 BS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new cL;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 _s().fromArray(t.position)),t.orientation&&(t.orientation=new VS().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 zS.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 _s,o=new VS,n=!1,a=1,s,l){this.splatMesh=Wi.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=ES(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 yL=new hL;yL.wireframe=!0;var GS=new dL,Xd=class extends uL{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 Ud;this.invisibleObjects=new Bi("jflkdsafjasdifjaslk",{...ou.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Nr("fdasfa",{...Ro.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=MS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=AS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Nr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>tc(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===yi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Nr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Nn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Nr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Li(n)&&Ll(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 ji&&(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),Ll(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Li(o)&&(o.freeBooleanPointer(),n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof As&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Li(o)&&(o.invalidateUpstreamBooleanData(),Ll(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof lr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Nr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{yS(a,r,o,{scene:this,shared:n}),a instanceof tt&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Nn||l instanceof Nr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof Zo&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){_e.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{_e.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ui(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...ec(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=Je.zoom(p,r);g[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 ti&&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=ui(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of su.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 ti&&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),_d(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof ti&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)_e.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(_e.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(Li(s)||Bl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),kl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;_e.is(a)&&(a.visible||s?.object.data.visible)&&((Li(a)||Bl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),kl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)_e.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)_e.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)_e.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof tt&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Ll(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)jo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)_e.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Vd(e,r,l);return c instanceof ji&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof tt&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let d=u.dataPatched;if(u instanceof tt&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new pL().fromArray(m)),h=new mL(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 fL;return o.setFromPoints(r),o.getCenter(GS),GS}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 Et)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof ar&&e(r.material[o]);else r.material instanceof ar&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Zo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new ql({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as gL}from"three/examples/jsm/loaders/DRACOLoader.js";var qi;function FS(i){return qi||(qi=new gL,qi.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qi.decoderPending}async function xL(i){if(qi){let t={attributeIDs:qi.defaultAttributeIDs,attributeTypes:qi.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qi.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 jS(i,t){let[e,r]=xp(Hc.deserialize(new Uint8Array(i)));return uu(e),t&&t(e),r.result().data}function US(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 kS(i){for(let t of i){let e=await xL(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 Jme}from"three";import{mergeBufferGeometries as rye}from"three/examples/jsm/utils/BufferGeometryUtils.js";function HS(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 WS,ShaderLib as bL}from"three";function qS(i){let t=new Set;return i.traverse(e=>{if(e instanceof sr)if(ht(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(vL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new WS,specularColor:new WS});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},bL.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=uv(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else SL(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function vL(i){return i.getLayersOfType("transmission").length>0}function SL(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 $S(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function XS(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 wL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function YS(i){let t=[];return i.traverse(e=>{e instanceof Ri&&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&&HS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Et&&a.unshift(r.geometry),a.length){let s=wL(a);r instanceof Et&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:_v})}),i}function KS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function QS(i){Object.values(i.shared.materials).forEach(t=>{ym(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?ym(e.material):"materials"in e&&e.materials.forEach(r=>{ym(r)})})}function ym(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 tw=Bs(JS(),1);var ew="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gm=class extends OL{load(t,e,r,o=console.error){let n=new PL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(ew+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(ew),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 jS(t,QS),r=US(e);e.version&&(0,tw.default)(e.version,"1.12.35")>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&&FS(),jv(e)&&zb(),Qv(e)&&Tv(),R1(e)&&N1(),qd(e)&&mm()].filter(Boolean)),r.length&&await kS(r);let o=!1,n=new On(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Xd(e.scene,n);qd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=YS(a),a=qS(a),a=$S(a),a=XS(a),a=KS(a),a}};export{gm as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splinetool/loader",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.35",
|
|
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",
|