@splinetool/loader 1.10.75 → 1.10.76
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: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
|
|
|
15
15
|
}`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=Dl(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=Dl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:dI(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 nb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return nb(e,t)}return Vi.isBoolean(i)?Vi.getDisplayedValue(i).toLowerCase():Vi.getDisplayedValue(i)},Dl=(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
|
`:"")+Dl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return nb(o,t)}}return""}).join("");var yI=new Ie.Matrix4,gI=new Ie.Matrix4;function xI(i,t,e){let r=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3],o=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Ie.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ie.Matrix4().makeBasis(r[0],r[1],r[2])}var ab=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??Ya.create({parameters:$p}).userData.shape;return{path:i.path??Ia.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...gu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Ff(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ie.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Ff=class extends Ie.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ob(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(r[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=xI(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new Ui(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=co({windingRule:$e.ODD,elementType:St.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Nf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,p[0],u[0],!1),this._closeEnd(_,N+R,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=yI;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(gI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=Vu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ie.Vector3,s=new Ie.Vector3,l=new Ie.Vector3,c=new Ie.Vector3,u=new Ie.Vector3(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new Ie.Matrix4().makeBasis(M,g,T);r.push(D)}let p=n?s:l,d=n?a:new Ie.Vector3(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return r;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let b=new Ie.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(b)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ie.Matrix4,p=new Ie.Matrix4;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ie.MathUtils.lerp(a,a+s,h)*Ie.MathUtils.DEG2RAD);let m=Ie.MathUtils.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,r=$e.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=co({windingRule:r,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Ml}let l;try{l=co({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Ef}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Ie.Vector3,u=new Ie.Vector3,p=new Ie.Vector3,d=new Ie.Vector3,f=new Ie.Vector2;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ie.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Ie.Vector3,d=new Ie.Vector2;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,b=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,b,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ie.Matrix3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=r*m,b=o*m;y<b;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};var In=require("three"),sb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function lb(){let i=new In.BufferGeometry;return i.setAttribute("position",new In.BufferAttribute(new Float32Array([]),3)),i.setIndex(new In.BufferAttribute(new Uint16Array([]),1)),i}var vI=lb().attributes,SI=12,wI=1,En=class extends In.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,vI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=Vi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=PI(e,o,f,r),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new Xe().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>wr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?$e.NONZERO:$e.ODD,subdivisions:this.isLowResolution&&s>0?wI:SI}})),T=S.length?(0,sb.mergeBufferGeometries)(S):lb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ft(new In.BufferGeometry,En.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 PI(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 ub,Ju=new Promise(i=>{ub=i}),cb=!1;var Zu;function db(i){if(cb)return;if(Zu)return Zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.75/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});ub(c),cb=!0}return Zu=t(),Zu}var pb=require("three");var OI=["font"];function Lo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Hp(p)&&!OI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Hp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new pb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new En(n,t);if(n.type==="InputGeometry")return new En(n,t);if(n.type==="UIGeometry")return Za.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=jf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Ma.defaultData(),100,100);s.shape=c,l=jf(s)}return l}var fb=require("three"),TI=new fb.Matrix4;function _l(i,t,e,r){let o=i.position.array,n=i.normal.array,a=TI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ed=new lt.Box3,es=new lt.Vector3,Pe;Ju.then(i=>{Pe=i});var hb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),mb=new Uint32Array([0,1,2,3]),yb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ni.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&_l(this.subdividedGeometry.attributes,...n),this.originalGeometry&&_l(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(es.fromArray(n));let s=es.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ed.setFromBufferAttribute(r),ed.getCenter(o),e.boundingSphere.radius=o.distanceTo(ed.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ed.getSize(es);let n={width:es.x,height:es.y,depth:es.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:hb,indexWASM:mb,verticesPerFaceWASM:yb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Lo(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}=Wf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=qf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=hb,n=mb,a=yb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var gb=["getX","getY","getZ"];function Wf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[gb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[gb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var td=new lt.Vector3,Uf=new lt.Vector3,kf=new lt.Vector3,Hf=new lt.Vector3;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 d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){td.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Uf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),kf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Hf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Uf.sub(td).normalize(),kf.sub(td).normalize(),Hf.sub(td).normalize();let l=Uf.cross(kf).dot(Hf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Wr={};sm(Wr,{calcBoolean:()=>II,calcBooleanTopological:()=>MI,freeMeshSet:()=>_I,getMeshSet:()=>EI,hasOpenEdges:()=>NI,transformMeshSet:()=>DI});var CI,xb=new Promise(i=>{CI=i});var Rl=require("three");var Ue,ts;xb.then(i=>Ue=i);function AI(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}=Wf(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,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function bb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function vb(i){switch(i){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function MI(i,t){ts===void 0&&(ts=Ue.init_csg());let e=bb(i),r=Ue.csg_calc_topological(ts,e,i.length,vb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function II(i,t,e,r){ts===void 0&&(ts=Ue.init_csg());let o=bb(i),n=Ue.csg_calc(ts,o,i.length,r,vb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Rl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Rl.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ue.free_mesh_data(n),h}function EI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=AI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,n);return Ue._free(f),y}function NI(i){return Ue.has_open_edges(i)}function DI(i,t){Ue.transform_csg_mesh(i,t.elements)}function _I(i){Ue.free_csg_mesh(i)}var RI={ConeGeometry:ux,CubeGeometry:dx,CylinderGeometry:cx,DodecahedronGeometry:fx,EllipseGeometry:Ya,HelixGeometry:zx,IcosahedronGeometry:Fx,LatheGeometry:jx,NonParametricGeometry:Wx,PolygonGeometry:Yu,PyramidGeometry:qx,RectangleGeometry:Za,SphereGeometry:$x,PlaneGeometry:Yx,BackdropGeometry:Kx,StarGeometry:Ku,TextFrameGeometry:Zx,TorusGeometry:Jx,TorusKnotGeometry:tb,TriangleGeometry:rb,PathGeometry:ab,VectorGeometry:wr},jf=i=>RI[i.type].create(i);function rs(i){return i!==null&&"booleanOp"in i}var os=class extends ja(rd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new rd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!rs(this.parent)&&this.visible,rs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof os&&(e.freeBooleanPointer(),rs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&rs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),rs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var od=new is.Box3;function Ll(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}od.min.set(n,a,s),od.max.set(l,c,u),od.getCenter(r),od.getSize(o).multiplyScalar(.5)}var LI=new is.BufferGeometry,BI=new is.MeshBasicMaterial,Wt=class extends os{constructor(t,e){super(LI,BI),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?Ll(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var mi=require("three");var Br=require("three");var Ub=require("three");var di=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(di.uuidContext===null)throw new Error("plz startContext");di.uuidContext===di.globalContext?this.uuid="_gid"+di.uuidContext.nodeContextUuid++:this.uuid="_uid"+di.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===di.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=di;ot.globalContext={nodeContextUuid:0},ot.uuidContext=di.globalContext;var mo=require("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 $f=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new $f;var Xf=require("three");var Sb=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=Sb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Xf.Vector2?e:new Xf.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 Yf=require("three");var or=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Yf.Vector3?e:new Yf.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 Pr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var VI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,wb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=wb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=qt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=VI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(wb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var zI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=zI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Kf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var GI=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 ub,Ju=new Promise(i=>{ub=i}),cb=!1;var Zu;function db(i){if(cb)return;if(Zu)return Zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.76/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});ub(c),cb=!0}return Zu=t(),Zu}var pb=require("three");var OI=["font"];function Lo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Hp(p)&&!OI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Hp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new pb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new En(n,t);if(n.type==="InputGeometry")return new En(n,t);if(n.type==="UIGeometry")return Za.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=jf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Ma.defaultData(),100,100);s.shape=c,l=jf(s)}return l}var fb=require("three"),TI=new fb.Matrix4;function _l(i,t,e,r){let o=i.position.array,n=i.normal.array,a=TI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ed=new lt.Box3,es=new lt.Vector3,Pe;Ju.then(i=>{Pe=i});var hb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),mb=new Uint32Array([0,1,2,3]),yb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ni.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&_l(this.subdividedGeometry.attributes,...n),this.originalGeometry&&_l(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(es.fromArray(n));let s=es.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ed.setFromBufferAttribute(r),ed.getCenter(o),e.boundingSphere.radius=o.distanceTo(ed.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ed.getSize(es);let n={width:es.x,height:es.y,depth:es.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:hb,indexWASM:mb,verticesPerFaceWASM:yb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Lo(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}=Wf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=qf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=hb,n=mb,a=yb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var gb=["getX","getY","getZ"];function Wf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[gb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[gb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var td=new lt.Vector3,Uf=new lt.Vector3,kf=new lt.Vector3,Hf=new lt.Vector3;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 d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){td.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Uf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),kf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Hf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Uf.sub(td).normalize(),kf.sub(td).normalize(),Hf.sub(td).normalize();let l=Uf.cross(kf).dot(Hf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Wr={};sm(Wr,{calcBoolean:()=>II,calcBooleanTopological:()=>MI,freeMeshSet:()=>_I,getMeshSet:()=>EI,hasOpenEdges:()=>NI,transformMeshSet:()=>DI});var CI,xb=new Promise(i=>{CI=i});var Rl=require("three");var Ue,ts;xb.then(i=>Ue=i);function AI(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}=Wf(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,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function bb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function vb(i){switch(i){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function MI(i,t){ts===void 0&&(ts=Ue.init_csg());let e=bb(i),r=Ue.csg_calc_topological(ts,e,i.length,vb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function II(i,t,e,r){ts===void 0&&(ts=Ue.init_csg());let o=bb(i),n=Ue.csg_calc(ts,o,i.length,r,vb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Rl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Rl.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ue.free_mesh_data(n),h}function EI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=AI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,n);return Ue._free(f),y}function NI(i){return Ue.has_open_edges(i)}function DI(i,t){Ue.transform_csg_mesh(i,t.elements)}function _I(i){Ue.free_csg_mesh(i)}var RI={ConeGeometry:ux,CubeGeometry:dx,CylinderGeometry:cx,DodecahedronGeometry:fx,EllipseGeometry:Ya,HelixGeometry:zx,IcosahedronGeometry:Fx,LatheGeometry:jx,NonParametricGeometry:Wx,PolygonGeometry:Yu,PyramidGeometry:qx,RectangleGeometry:Za,SphereGeometry:$x,PlaneGeometry:Yx,BackdropGeometry:Kx,StarGeometry:Ku,TextFrameGeometry:Zx,TorusGeometry:Jx,TorusKnotGeometry:tb,TriangleGeometry:rb,PathGeometry:ab,VectorGeometry:wr},jf=i=>RI[i.type].create(i);function rs(i){return i!==null&&"booleanOp"in i}var os=class extends ja(rd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new rd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!rs(this.parent)&&this.visible,rs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof os&&(e.freeBooleanPointer(),rs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&rs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),rs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var od=new is.Box3;function Ll(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}od.min.set(n,a,s),od.max.set(l,c,u),od.getCenter(r),od.getSize(o).multiplyScalar(.5)}var LI=new is.BufferGeometry,BI=new is.MeshBasicMaterial,Wt=class extends os{constructor(t,e){super(LI,BI),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?Ll(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var mi=require("three");var Br=require("three");var Ub=require("three");var di=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(di.uuidContext===null)throw new Error("plz startContext");di.uuidContext===di.globalContext?this.uuid="_gid"+di.uuidContext.nodeContextUuid++:this.uuid="_uid"+di.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===di.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=di;ot.globalContext={nodeContextUuid:0},ot.uuidContext=di.globalContext;var mo=require("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 $f=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new $f;var Xf=require("three");var Sb=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=Sb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Xf.Vector2?e:new Xf.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 Yf=require("three");var or=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Yf.Vector3?e:new Yf.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 Pr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var VI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,wb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=wb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=qt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=VI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(wb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var zI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Kf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=zI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Kf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var GI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),FI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ns=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=GI.exec(e);if(r){let o=r[2],n;for(;n=FI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var as=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};qt.addKeyword("uv",function(){return new as});qt.addKeyword("uv2",function(){return new as(1)});var id=require("three");var Nn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Nn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case id.LinearEncoding:return["Linear"];case id.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=Nn.Nodes[this.method],s=e.include(a);if(s===Nn.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=Nn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Nn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},hr=Nn;hr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Et,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new yo(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2)};for(let i of Object.values(De))i.isRenderGlobal=!0;var zb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.
|
|
1876
|
+
}`,[e,r])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Et,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new yo(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2)};for(let i of Object.values(De))i.isRenderGlobal=!0;var zb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.76/build/ui.wasm"};var pi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Dt),this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(cd.UniformsUtils.merge([cd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
|
|
1877
1877
|
`));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
|
|
1878
1878
|
#include <skinbase_vertex>
|
|
1879
1879
|
#include <skinnormal_vertex>
|
|
@@ -4376,4 +4376,4 @@ void main() {
|
|
|
4376
4376
|
A = exp(A) * vColor.a;
|
|
4377
4377
|
gl_FragColor = vec4(color.rgb, A);
|
|
4378
4378
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
4379
|
-
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=q1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=tp(this.centers[y]),c[b+2]=tp(this.centers[y+1]),c[b+3]=tp(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(d,p,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(rp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(rp),this.material.uniforms.basisViewport.value.set(2/rp.x,2/rp.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 X1,Kh=new Promise(i=>{X1=i}),$1=!1;var ip;function Qh(){if($1)return;if(ip)return ip;async function i(){let e=await import("./gaussian-splat-compression.js");X1(e),$1=!0}return ip=i(),ip}var Y1;Kh.then(i=>Y1=i);var pc=class{constructor(t={}){yn(this,"updateView",function(){let t=new xr.Matrix4,e=[],r=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),n=new xr.Vector3,a=new xr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new xr.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 xr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new xr.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 Y1.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 xr.Vector3,o=new xr.Quaternion,n=!1,a=1,s,l){this.splatMesh=un.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=W1(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 PE=new eo.MeshBasicMaterial;PE.wireframe=!0;var K1=new eo.Vector3,np=class extends eo.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 ep;this.invisibleObjects=new tn("jflkdsafjasdifjaslk",{...Pu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...ti.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=k1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=U1(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 Zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let 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)=>Sc(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===_i)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 Zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Hn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),en(n)&&rc(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 sn&&(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),rc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),en(o)&&(o.freeBooleanPointer(),n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Hs&&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()),en(o)&&(o.invalidateUpstreamBooleanData(),rc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Zr&&(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{B1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Hn||l instanceof Zr)&&(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 yi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...vc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof bi&&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=Ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Au.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 bi&&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 bi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(en(s)||oc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),uc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((en(a)||oc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),uc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();rc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)si.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Qd(e,r,l);return c instanceof sn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let 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 eo.Box3;return o.setFromPoints(r),o.getCenter(K1),K1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Tr&&e(r.material[o]);else r.material instanceof Tr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof yi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new pc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Q1=require("three/examples/jsm/loaders/DRACOLoader.js");var dn;function Z1(i){return dn||(dn=new Q1.DRACOLoader,dn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function OE(i){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await dn.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 J1(i,t){let[e,r]=Np(uu.deserialize(new Uint8Array(i)));return Iu(e),t&&t(e),r.result().data}function eS(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 tS(i){for(let t of i){let e=await OE(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 TE=require("three"),CE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function rS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var fc=require("three");function oS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Cr)if(Tt(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(AE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new fc.Color,specularColor:new fc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fc.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=Vb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else ME(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function AE(i){return i.getLayersOfType("transmission").length>0}function ME(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 iS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function nS(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 aS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function sS(i){let t=[];return i.traverse(e=>{e instanceof Zi&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&rS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,aS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:rv})}),i}function lS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function cS(i){Object.values(i.shared.materials).forEach(t=>{Zh(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?Zh(e.material):"materials"in e&&e.materials.forEach(r=>{Zh(r)})})}function Zh(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 fS=tl(dS(),1);var pS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ap=class extends sp.Loader{load(t,e,r,o=console.error){let n=new sp.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 J1(t,cS),r=eS(e);e.version&&(0,fS.default)(e.version,"1.10.75")>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&&Z1(),sv(e)&&db(),gv(e)&&Yb(),Qv(e)&&Xv(),op(e)&&Qh()].filter(Boolean)),r.length&&await tS(r);let o=!1,n=new Gn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new np(e.scene,n);op(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=sS(a),a=oS(a),a=iS(a),a=nS(a),a=lS(a),a}};
|
|
4379
|
+
}`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=q1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=tp(this.centers[y]),c[b+2]=tp(this.centers[y+1]),c[b+3]=tp(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(d,p,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(rp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(rp),this.material.uniforms.basisViewport.value.set(2/rp.x,2/rp.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 X1,Kh=new Promise(i=>{X1=i}),$1=!1;var ip;function Qh(){if($1)return;if(ip)return ip;async function i(){let e=await import("./gaussian-splat-compression.js");X1(e),$1=!0}return ip=i(),ip}var Y1;Kh.then(i=>Y1=i);var pc=class{constructor(t={}){yn(this,"updateView",function(){let t=new xr.Matrix4,e=[],r=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),n=new xr.Vector3,a=new xr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new xr.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 xr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new xr.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 Y1.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 xr.Vector3,o=new xr.Quaternion,n=!1,a=1,s,l){this.splatMesh=un.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=W1(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 PE=new eo.MeshBasicMaterial;PE.wireframe=!0;var K1=new eo.Vector3,np=class extends eo.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 ep;this.invisibleObjects=new tn("jflkdsafjasdifjaslk",{...Pu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...ti.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=k1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=U1(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 Zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let 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)=>Sc(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===_i)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 Zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Hn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),en(n)&&rc(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 sn&&(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),rc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),en(o)&&(o.freeBooleanPointer(),n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Hs&&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()),en(o)&&(o.invalidateUpstreamBooleanData(),rc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Zr&&(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{B1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Hn||l instanceof Zr)&&(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 yi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...vc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof bi&&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=Ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Au.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 bi&&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 bi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(en(s)||oc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),uc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((en(a)||oc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),uc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();rc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)si.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Qd(e,r,l);return c instanceof sn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let 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 eo.Box3;return o.setFromPoints(r),o.getCenter(K1),K1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Tr&&e(r.material[o]);else r.material instanceof Tr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof yi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new pc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Q1=require("three/examples/jsm/loaders/DRACOLoader.js");var dn;function Z1(i){return dn||(dn=new Q1.DRACOLoader,dn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function OE(i){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await dn.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 J1(i,t){let[e,r]=Np(uu.deserialize(new Uint8Array(i)));return Iu(e),t&&t(e),r.result().data}function eS(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 tS(i){for(let t of i){let e=await OE(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 TE=require("three"),CE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function rS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var fc=require("three");function oS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Cr)if(Tt(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(AE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new fc.Color,specularColor:new fc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fc.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=Vb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else ME(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function AE(i){return i.getLayersOfType("transmission").length>0}function ME(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 iS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function nS(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 aS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function sS(i){let t=[];return i.traverse(e=>{e instanceof Zi&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&rS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,aS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:rv})}),i}function lS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function cS(i){Object.values(i.shared.materials).forEach(t=>{Zh(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?Zh(e.material):"materials"in e&&e.materials.forEach(r=>{Zh(r)})})}function Zh(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 fS=tl(dS(),1);var pS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ap=class extends sp.Loader{load(t,e,r,o=console.error){let n=new sp.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 J1(t,cS),r=eS(e);e.version&&(0,fS.default)(e.version,"1.10.76")>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&&Z1(),sv(e)&&db(),gv(e)&&Yb(),Qv(e)&&Xv(),op(e)&&Qh()].filter(Boolean)),r.length&&await tS(r);let o=!1,n=new Gn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new np(e.scene,n);op(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=sS(a),a=oS(a),a=iS(a),a=nS(a),a=lS(a),a}};
|
package/build/SplineLoader.js
CHANGED
|
@@ -15,7 +15,7 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
|
|
|
15
15
|
}`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=sl(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=sl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:W3(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 xb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return xb(e,t)}return yi.isBoolean(i)?yi.getDisplayedValue(i).toLowerCase():yi.getDisplayedValue(i)},sl=(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
|
`:"")+sl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return xb(o,t)}}return""}).join("");var Q3=new nn,Z3=new nn;function J3(i,t,e){let r=[new _t,new _t,new _t],o=[new _t,new _t,new _t];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Nu.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new nn().makeBasis(r[0],r[1],r[2])}var Sb=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??Ma.create({parameters:Op}).userData.shape;return{path:i.path??la.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Uc,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Nf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new vb,{userData:{...i,type:"PathGeometry"}})}},Nf=class extends vb{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)||!yb(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(r[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=J3(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new vi(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=Fr({windingRule:Fe.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=yf}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,p[0],u[0],!1),this._closeEnd(_,N+R,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q);let H=Q3;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(Z3.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new _a(B.positions,3)),this.setAttribute("normal",new _a(B.normals,3)),this.setAttribute("uv",new _a(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=cu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new _t,s=new _t,l=new _t,c=new _t,u=new _t(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new nn().makeBasis(M,g,T);r.push(D)}let p=n?s:l,d=n?a:new _t(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return r;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let b=new nn().makeRotationZ(h*y/r.length);r[y].multiply(b)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new nn,p=new nn;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Nu.lerp(a,a+s,h)*Nu.DEG2RAD);let m=Nu.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,r=Fe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=Fr({windingRule:r,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=rl}let l;try{l=Fr({windingRule:Fe.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=mf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new _t,u=new _t,p=new _t,d=new _t,f=new bb;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new _t(0,0,l?-1:1).applyMatrix4(a),p=new _t,d=new bb;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,b=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,b,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new K3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=r*m,b=o*m;y<b;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as wb,BufferGeometry as Df}from"three";import{mergeBufferGeometries as tE}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Pb(){let i=new Df;return i.setAttribute("position",new wb(new Float32Array([]),3)),i.setIndex(new wb(new Uint16Array([]),1)),i}var rE=Pb().attributes,oE=12,iE=1,an=class extends Df{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,rE),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=yi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=nE(e,o,f,r),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new je().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>er.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Fe.NONZERO:Fe.ODD,subdivisions:this.isLowResolution&&s>0?iE:oE}})),T=S.length?tE(S):Pb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Pt(new Df,an.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 nE(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 Rf,BufferAttribute as Ab,Uint32BufferAttribute as Lf,Float32BufferAttribute as Bf,Matrix4 as uE,Vector3 as cl,Sphere as dE,Box3 as pE,BoxGeometry as fE}from"three";var Tb,_u=new Promise(i=>{Tb=i}),Ob=!1;var Du;function Cb(i){if(Ob)return;if(Du)return Du;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.75/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});Tb(c),Ob=!0}return Du=t(),Du}import{BufferGeometryLoader as aE}from"three";var sE=["font"];function uo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Sp(p)&&!sE.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Sp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new aE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new xt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new an(n,t);if(n.type==="InputGeometry")return new an(n,t);if(n.type==="UIGeometry")return Da.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=_f(s)}catch(c){console.error(c)}if(!l){let c=je.createFromState(sa.defaultData(),100,100);s.shape=c,l=_f(s)}return l}import{Matrix4 as lE}from"three";var cE=new lE;function ll(i,t,e,r){let o=i.position.array,n=i.normal.array,a=cE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Ru=new pE,Ra=new cl,Se;_u.then(i=>{Se=i});var Mb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ib=new Uint32Array([0,1,2,3]),Eb=new Uint8Array([4]),xt=class extends Rf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=ui.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&ll(this.subdividedGeometry.attributes,...n),this.originalGeometry&&ll(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(Ra.fromArray(n));let s=Ra.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new fE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new dE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Ru.setFromBufferAttribute(r),Ru.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ru.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ru.getSize(Ra);let n={width:Ra.x,height:Ra.y,depth:Ra.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Se.free_bvh(r),Se.free_subdivision_surface(r));try{a=xt.allocate(e,n)}catch(u){console.error(u,e),a=xt.allocate({positionWASM:Mb,indexWASM:Ib,verticesPerFaceWASM:Eb},n)}if(Se.set_destination_refinement_level(a,0),s=xt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=xt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=xt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:uo(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}=Ff(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=jf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Mb,n=Ib,a=Eb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new uE().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Se.get_mesh_data2(e,r?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,r?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new Rf;if(O.setIndex(new Lf(w,1)),O.setAttribute("position",new Bf(f,3)),O.setAttribute("normal",new Bf(m,3)),r){O.setAttribute("faceMap",new Lf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Ab(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new Rf;h.setAttribute("position",new Bf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ab(m,3)),h.setIndex(new Lf(f,1)),Se.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Se.set_destination_refinement_level(e,r);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Nb=["getX","getY","getZ"];function Ff(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[Nb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Nb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Lu=new cl,Vf=new cl,zf=new cl,Gf=new cl;function jf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Lu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Vf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),zf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Gf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Vf.sub(Lu).normalize(),zf.sub(Lu).normalize(),Gf.sub(Lu).normalize();let l=Vf.cross(zf).dot(Gf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var wr={};pw(wr,{calcBoolean:()=>xE,calcBooleanTopological:()=>gE,freeMeshSet:()=>wE,getMeshSet:()=>bE,hasOpenEdges:()=>vE,transformMeshSet:()=>SE});var hE,Db=new Promise(i=>{hE=i});import{Float32BufferAttribute as _b,Sphere as mE}from"three";var Be,La;Db.then(i=>Be=i);function yE(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}=Ff(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=jf(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Rb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,t):new Float32Array(Be.HEAPF32.buffer,n,t)).set(i,0),n}function Lb(i){switch(i){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function gE(i,t){La===void 0&&(La=Be.init_csg());let e=Rb(i),r=Be.csg_calc_topological(La,e,i.length,Lb(t));Be._free(e);let o=6,n=Be.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function xE(i,t,e,r){La===void 0&&(La=Be.init_csg());let o=Rb(i),n=Be.csg_calc(La,o,i.length,r,Lb(t));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new _b(p,3)),e.setAttribute("normal",new _b(f,3));let m=Be.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},Be.free_mesh_data(n),h}function bE(i,t,e){if(Be===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=yE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,n);return Be._free(f),y}function vE(i){return Be.has_open_edges(i)}function SE(i,t){Be.transform_csg_mesh(i,t.elements)}function wE(i){Be.free_csg_mesh(i)}var PE={ConeGeometry:yx,CubeGeometry:gx,CylinderGeometry:mx,DodecahedronGeometry:xx,EllipseGeometry:Ma,HelixGeometry:Xx,IcosahedronGeometry:Yx,LatheGeometry:Kx,NonParametricGeometry:ab,PolygonGeometry:Mu,PyramidGeometry:sb,RectangleGeometry:Da,SphereGeometry:cb,PlaneGeometry:ub,BackdropGeometry:db,StarGeometry:Iu,TextFrameGeometry:pb,TorusGeometry:fb,TorusKnotGeometry:hb,TriangleGeometry:mb,PathGeometry:Sb,VectorGeometry:er},_f=i=>PE[i.type].create(i);function Ba(i){return i!==null&&"booleanOp"in i}var Va=class extends va(TE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new OE}updateVisible(e){super.updateVisible(e),this.visible=!Ba(this.parent)&&this.visible,Ba(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ba(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Va&&(e.freeBooleanPointer(),Ba(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Bu=new CE;function ul(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Bu.min.set(n,a,s),Bu.max.set(l,c,u),Bu.getCenter(r),Bu.getSize(o).multiplyScalar(.5)}var IE=new AE,EE=new ME,Mt=class extends Va{constructor(t,e){super(IE,EE),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?ul(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 ZN,Matrix4 as JN,Sphere as Mv,Vector3 as eD}from"three";import{BufferAttribute as YN,Float32BufferAttribute as Av,MathUtils as yh,Vector3 as gh}from"three";import{ShaderMaterial as AN}from"three";var Uo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Uo.uuidContext===null)throw new Error("plz startContext");Uo.uuidContext===Uo.globalContext?this.uuid="_gid"+Uo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Uo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Uo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},$e=Uo;$e.globalContext={nodeContextUuid:0},$e.uuidContext=Uo.globalContext;import{CubeReflectionMapping as FE,CubeRefractionMapping as jE,CubeUVReflectionMapping as UE,LinearEncoding as Wb,sRGBEncoding as kE}from"three";var dl=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 Uf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},It=new Uf;import{Vector2 as Bb}from"three";import{MathUtils as NE}from"three";var ge=class extends $e{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=NE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var lt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Bb?e:new Bb(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 Vb}from"three";var Gt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Vb?e:new Vb(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 tr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ct?e:new Ct(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var DE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,zb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=zb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&It.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=It.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||It.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&It.contains(m)&&e.include(It.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=DE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(zb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var _E=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,kf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=_E.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Ge=kf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var RE=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 Rf,BufferAttribute as Ab,Uint32BufferAttribute as Lf,Float32BufferAttribute as Bf,Matrix4 as uE,Vector3 as cl,Sphere as dE,Box3 as pE,BoxGeometry as fE}from"three";var Tb,_u=new Promise(i=>{Tb=i}),Ob=!1;var Du;function Cb(i){if(Ob)return;if(Du)return Du;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.76/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});Tb(c),Ob=!0}return Du=t(),Du}import{BufferGeometryLoader as aE}from"three";var sE=["font"];function uo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Sp(p)&&!sE.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Sp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=je.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new aE().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new xt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new an(n,t);if(n.type==="InputGeometry")return new an(n,t);if(n.type==="UIGeometry")return Da.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=_f(s)}catch(c){console.error(c)}if(!l){let c=je.createFromState(sa.defaultData(),100,100);s.shape=c,l=_f(s)}return l}import{Matrix4 as lE}from"three";var cE=new lE;function ll(i,t,e,r){let o=i.position.array,n=i.normal.array,a=cE.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Ru=new pE,Ra=new cl,Se;_u.then(i=>{Se=i});var Mb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ib=new Uint32Array([0,1,2,3]),Eb=new Uint8Array([4]),xt=class extends Rf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=ui.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&ll(this.subdividedGeometry.attributes,...n),this.originalGeometry&&ll(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(Ra.fromArray(n));let s=Ra.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=xt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new fE(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(xt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new dE,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Ru.setFromBufferAttribute(r),Ru.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ru.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ru.getSize(Ra);let n={width:Ra.x,height:Ra.y,depth:Ra.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Se.free_bvh(r),Se.free_subdivision_surface(r));try{a=xt.allocate(e,n)}catch(u){console.error(u,e),a=xt.allocate({positionWASM:Mb,indexWASM:Ib,verticesPerFaceWASM:Eb},n)}if(Se.set_destination_refinement_level(a,0),s=xt.buildLevel(a,!0,c),e.subdivisions>0)try{Se.set_destination_refinement_level(a,e.subdivisions),l=xt.buildLevel(a,!1,c)}catch{try{Se.set_destination_refinement_level(a,e.subdivisions-1),l=xt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:uo(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}=Ff(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=jf(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=Mb,n=Ib,a=Eb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Se._malloc(h),v=new Float32Array(Se.HEAPF32.buffer,b,d),w=new Uint32Array(Se.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new uE().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Se.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Se.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Se._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Se.get_mesh_data2(e,r?Se.Level.CONTROL:Se.Level.REFINED,o,a.elements):Se.get_mesh_data(e,r?Se.Level.CONTROL:Se.Level.REFINED,o),l=8,c=Se.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Se.HEAPU32[c[p]>>2],f=Se.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Se.HEAPU32[c[p]>>2],m=Se.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Se.HEAPU32[c[p]>>2],b=Se.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Se.HEAPU32[c[p]>>2],w=Se.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new Rf;if(O.setIndex(new Lf(w,1)),O.setAttribute("position",new Bf(f,3)),O.setAttribute("normal",new Bf(m,3)),r){O.setAttribute("faceMap",new Lf(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new Ab(S,4))}return Se.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Se.free_mesh_data(s)}static freeSubdivPointer(e){Se.free_bvh(e),Se.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Se.get_wireframe_data_for_base_level(e),a=4,s=Se.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Se.HEAPU32[s[c]>>2],p=Se.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Se.HEAPU32[s[c]>>2],f=Se.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new Rf;h.setAttribute("position",new Bf(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new Ab(m,3)),h.setIndex(new Lf(f,1)),Se.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Se.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Se.set_destination_refinement_level(e,r);let a=o?Se.get_topological_data2(e,n?Se.Level.CONTROL:Se.Level.REFINED,o.elements):Se.get_topological_data(e,n?Se.Level.CONTROL:Se.Level.REFINED),s=6,l=Se.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Se.HEAPU32[l[u]>>2],d=new Float32Array(Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Se.HEAPU32[l[u]>>2],h=new Uint32Array(Se.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Se.HEAPU32[l[u]>>2],y=new Uint8Array(Se.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Se.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var Nb=["getX","getY","getZ"];function Ff(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[Nb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[Nb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var Lu=new cl,Vf=new cl,zf=new cl,Gf=new cl;function jf(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Lu.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Vf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),zf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Gf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Vf.sub(Lu).normalize(),zf.sub(Lu).normalize(),Gf.sub(Lu).normalize();let l=Vf.cross(zf).dot(Gf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var wr={};pw(wr,{calcBoolean:()=>xE,calcBooleanTopological:()=>gE,freeMeshSet:()=>wE,getMeshSet:()=>bE,hasOpenEdges:()=>vE,transformMeshSet:()=>SE});var hE,Db=new Promise(i=>{hE=i});import{Float32BufferAttribute as _b,Sphere as mE}from"three";var Be,La;Db.then(i=>Be=i);function yE(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}=Ff(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=jf(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function Rb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Be._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Be.HEAPU32.buffer,n,t):new Float32Array(Be.HEAPF32.buffer,n,t)).set(i,0),n}function Lb(i){switch(i){case 0:return Be.OP.UNION;case 1:return Be.OP.INTERSECTION;case 2:return Be.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function gE(i,t){La===void 0&&(La=Be.init_csg());let e=Rb(i),r=Be.csg_calc_topological(La,e,i.length,Lb(t));Be._free(e);let o=6,n=Be.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Be.HEAPU32[n[s]>>2],c=new Float32Array(Be.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Be.HEAPU32[n[s]>>2],p=new Uint32Array(Be.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Be.HEAPU32[n[s]>>2],f=new Uint8Array(Be.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Be.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function xE(i,t,e,r){La===void 0&&(La=Be.init_csg());let o=Rb(i),n=Be.csg_calc(La,o,i.length,r,Lb(t));Be._free(o);let a=5,s=Be.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Be.HEAPU32[s[c]>>2],p=Be.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Be.HEAPU32[s[c]>>2],f=Be.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new _b(p,3)),e.setAttribute("normal",new _b(f,3));let m=Be.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},Be.free_mesh_data(n),h}function bE(i,t,e){if(Be===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=yE(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Be._malloc(u),h=new Float32Array(Be.HEAPF32.buffer,f,l),m=new Uint32Array(Be.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Be.get_csg_mesh(f,a,f+p,s,n);return Be._free(f),y}function vE(i){return Be.has_open_edges(i)}function SE(i,t){Be.transform_csg_mesh(i,t.elements)}function wE(i){Be.free_csg_mesh(i)}var PE={ConeGeometry:yx,CubeGeometry:gx,CylinderGeometry:mx,DodecahedronGeometry:xx,EllipseGeometry:Ma,HelixGeometry:Xx,IcosahedronGeometry:Yx,LatheGeometry:Kx,NonParametricGeometry:ab,PolygonGeometry:Mu,PyramidGeometry:sb,RectangleGeometry:Da,SphereGeometry:cb,PlaneGeometry:ub,BackdropGeometry:db,StarGeometry:Iu,TextFrameGeometry:pb,TorusGeometry:fb,TorusKnotGeometry:hb,TriangleGeometry:mb,PathGeometry:Sb,VectorGeometry:er},_f=i=>PE[i.type].create(i);function Ba(i){return i!==null&&"booleanOp"in i}var Va=class extends va(TE){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new OE}updateVisible(e){super.updateVisible(e),this.visible=!Ba(this.parent)&&this.visible,Ba(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ba(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Va&&(e.freeBooleanPointer(),Ba(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ba(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Bu=new CE;function ul(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}Bu.min.set(n,a,s),Bu.max.set(l,c,u),Bu.getCenter(r),Bu.getSize(o).multiplyScalar(.5)}var IE=new AE,EE=new ME,Mt=class extends Va{constructor(t,e){super(IE,EE),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?ul(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 ZN,Matrix4 as JN,Sphere as Mv,Vector3 as eD}from"three";import{BufferAttribute as YN,Float32BufferAttribute as Av,MathUtils as yh,Vector3 as gh}from"three";import{ShaderMaterial as AN}from"three";var Uo=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Uo.uuidContext===null)throw new Error("plz startContext");Uo.uuidContext===Uo.globalContext?this.uuid="_gid"+Uo.uuidContext.nodeContextUuid++:this.uuid="_uid"+Uo.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Uo.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},$e=Uo;$e.globalContext={nodeContextUuid:0},$e.uuidContext=Uo.globalContext;import{CubeReflectionMapping as FE,CubeRefractionMapping as jE,CubeUVReflectionMapping as UE,LinearEncoding as Wb,sRGBEncoding as kE}from"three";var dl=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 Uf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},It=new Uf;import{Vector2 as Bb}from"three";import{MathUtils as NE}from"three";var ge=class extends $e{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=NE.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ge{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var lt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Bb?e:new Bb(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 Vb}from"three";var Gt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Vb?e:new Vb(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 tr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ct?e:new Ct(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var DE=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,zb=/[a-z_0-9]+/gi,J=class extends ge{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=zb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&It.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=It.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||It.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&It.contains(m)&&e.include(It.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=DE.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(zb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var _E=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,kf=class extends ge{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||kf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=_E.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},Ge=kf;Ge.PI="PI",Ge.PI2="PI2",Ge.RECIPROCAL_PI="RECIPROCAL_PI",Ge.RECIPROCAL_PI2="RECIPROCAL_PI2",Ge.LOG2="LOG2",Ge.EPSILON="EPSILON";var RE=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
19
19
|
)*?)}`,"gim"),LE=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),za=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=RE.exec(e);if(r){let o=r[2],n;for(;n=LE.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ga=class extends ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};It.addKeyword("uv",function(){return new Ga});It.addKeyword("uv2",function(){return new Ga(1)});import{LinearEncoding as BE,sRGBEncoding as VE}from"three";var sn=class extends ge{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??sn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case BE:return["Linear"];case VE:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=sn.Nodes[this.method],s=e.include(a);if(s===sn.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=sn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=sn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Xt=sn;Xt.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
20
20
|
`)),sRGBToLinear:new J(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
21
21
|
`)),LinearTosRGB:new J(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1873
1873
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1874
1874
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1875
1875
|
return displaced_position;
|
|
1876
|
-
}`,[e,r])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ht,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new Ur(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var Jb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.
|
|
1876
|
+
}`,[e,r])}}();var Ae={normalRenderTarget:new Yt,normalRenderTargetDepth:new Yt,transmissionRenderTarget:new Yt,aspectRatio:new lt,transmissionSize:new lt(2048,2048),transmissionRenderTargetDepth:new Yt,aoRenderTarget:new Yt,aoEnabled:new ht,pixelRatioNode:new se(1),resolution:new lt,penumbraSize:new Ur(5,.5),frameIndex:new Re(0),transmissionLod:new Re(2)};for(let i of Object.values(Ae))i.isRenderGlobal=!0;var Jb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.76/build/ui.wasm"};var ko=class extends $e{constructor(){super("basic");this.nodeType="Basic";this.color=new We(yt),this.shadingAlpha=new se(1),this.shadingBlend=new Re(0),this.previousModelViewMatrix=new Ft,this.previouseProjectionMatrix=new Ft}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ae.frameIndex}),e.mergeUniform({resolution:Ae.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(JE.merge([ZE.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 Gi},viewport:{type:"v2",value:new Gi},basisViewport:{type:"v2",value:new Gi},debugColor:{type:"v3",value:new BR},covariancesTextureSize:{type:"v2",value:new Gi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Gi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new $R({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:HR,depthTest:!0,depthWrite:!1,side:zR})}static buildGeomtery(e){let r=new LR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new RR(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 UR().copy(r),s=new Uint32Array(e),l=new jR(s,1,!1);return l.setUsage(GR),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 Gi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Gi(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]=VR.toHalfFloat(this.covariances[h]);s=new Rd(l,n.x,n.y,SS,FR)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Rd(l,n.x,n.y,SS,vS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=bS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=_d(this.centers[y]),c[b+2]=_d(this.centers[y+1]),c[b+3]=_d(this.centers[y+2])}let u=new Rd(c,a.x,a.y,qR,XR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Rd(d,p,1,WR,vS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Ld.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ld),this.material.uniforms.basisViewport.value.set(2/Ld.x,2/Ld.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 PS,im=new Promise(i=>{PS=i}),wS=!1;var Vd;function nm(){if(wS)return;if(Vd)return Vd;async function i(){let e=await import("./gaussian-splat-compression.js");PS(e),wS=!0}return Vd=i(),Vd}var CS;im.then(i=>CS=i);var Vl=class{constructor(t={}){qi(this,"updateView",function(){let t=new OS,e=[],r=new Ts(0,0,-1),o=new Ts(0,0,-1),n=new Ts,a=new Ts;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new OS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new YR;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 Ts().fromArray(t.position)),t.orientation&&(t.orientation=new TS().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 CS.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 Ts,o=new TS,n=!1,a=1,s,l){this.splatMesh=Fi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=xS(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 rL=new eL;rL.wireframe=!0;var AS=new QR,zd=class extends KR{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 Dd;this.invisibleObjects=new Ni("jflkdsafjasdifjaslk",{...Xc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Mr("fdasfa",{...Do.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=yS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=mS(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 Mr&&(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)=>ql(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===pi)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 Mr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Mr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Mr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Ei(n)&&Cl(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 Bi&&(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),Cl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ei(o)&&(o.freeBooleanPointer(),n instanceof nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof bs&&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()),Ei(o)&&(o.invalidateUpstreamBooleanData(),Cl(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 Mr&&(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{iS(a,r,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Pn||l instanceof Mr)&&(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 Xo&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{De.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Wl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Qo&&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=ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Zc.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 Qo&&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),Pd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Qo&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(Ei(s)||Al(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Rl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Rl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)De.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)De.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)De.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Cl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)zo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)De.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Ad(e,r,l);return c instanceof Bi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new ZR().fromArray(m)),h=new tL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new JR;return o.setFromPoints(r),o.getCenter(AS),AS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Mt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof or&&e(r.material[o]);else r.material instanceof or&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Xo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Vl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as oL}from"three/examples/jsm/loaders/DRACOLoader.js";var ji;function MS(i){return ji||(ji=new oL,ji.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ji.decoderPending}async function iL(i){if(ji){let t={attributeIDs:ji.defaultAttributeIDs,attributeTypes:ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ji.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 IS(i,t){let[e,r]=lp(Lc.deserialize(new Uint8Array(i)));return tu(e),t&&t(e),r.result().data}function ES(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 NS(i){for(let t of i){let e=await iL(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 yme}from"three";import{mergeBufferGeometries as bme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function DS(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 _S,ShaderLib as nL}from"three";function RS(i){let t=new Set;return i.traverse(e=>{if(e instanceof ir)if(dt(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(aL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new _S,specularColor:new _S});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},nL.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=Zb(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 aL(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 LS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function BS(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 lL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function VS(i){let t=[];return i.traverse(e=>{e instanceof Ii&&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&&DS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Mt&&a.unshift(r.geometry),a.length){let s=lL(a);r instanceof Mt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Sv})}),i}function zS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function GS(i){Object.values(i.shared.materials).forEach(t=>{am(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?am(e.material):"materials"in e&&e.materials.forEach(r=>{am(r)})})}function am(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var kS=Ms(jS(),1);var US="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",sm=class extends uL{load(t,e,r,o=console.error){let n=new cL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(US+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(US),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 IS(t,GS),r=ES(e);e.version&&(0,kS.default)(e.version,"1.10.75")>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&&MS(),Iv(e)&&Cb(),Gv(e)&&fv(),w1(e)&&b1(),Bd(e)&&nm()].filter(Boolean)),r.length&&await NS(r);let o=!1,n=new yn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new zd(e.scene,n);Bd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=VS(a),a=RS(a),a=LS(a),a=BS(a),a=zS(a),a}};export{sm 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 Gi},viewport:{type:"v2",value:new Gi},basisViewport:{type:"v2",value:new Gi},debugColor:{type:"v3",value:new BR},covariancesTextureSize:{type:"v2",value:new Gi(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Gi(1024,1024)},orthoZoom:{type:"f",value:-1}};return new $R({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:HR,depthTest:!0,depthWrite:!1,side:zR})}static buildGeomtery(e){let r=new LR;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new RR(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 UR().copy(r),s=new Uint32Array(e),l=new jR(s,1,!1);return l.setUsage(GR),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 Gi(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Gi(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]=VR.toHalfFloat(this.covariances[h]);s=new Rd(l,n.x,n.y,SS,FR)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Rd(l,n.x,n.y,SS,vS);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=bS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=_d(this.centers[y]),c[b+2]=_d(this.centers[y+1]),c[b+3]=_d(this.centers[y+2])}let u=new Rd(c,a.x,a.y,qR,XR);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Rd(d,p,1,WR,vS);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(Ld.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Ld),this.material.uniforms.basisViewport.value.set(2/Ld.x,2/Ld.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 PS,im=new Promise(i=>{PS=i}),wS=!1;var Vd;function nm(){if(wS)return;if(Vd)return Vd;async function i(){let e=await import("./gaussian-splat-compression.js");PS(e),wS=!0}return Vd=i(),Vd}var CS;im.then(i=>CS=i);var Vl=class{constructor(t={}){qi(this,"updateView",function(){let t=new OS,e=[],r=new Ts(0,0,-1),o=new Ts(0,0,-1),n=new Ts,a=new Ts;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new OS().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new YR;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 Ts().fromArray(t.position)),t.orientation&&(t.orientation=new TS().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 CS.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 Ts,o=new TS,n=!1,a=1,s,l){this.splatMesh=Fi.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=xS(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 rL=new eL;rL.wireframe=!0;var AS=new QR,zd=class extends KR{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 Dd;this.invisibleObjects=new Ni("jflkdsafjasdifjaslk",{...Xc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Mr("fdasfa",{...Do.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=yS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=mS(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 Mr&&(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)=>ql(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===pi)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 Mr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Mr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Mr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),Ei(n)&&Cl(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 Bi&&(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),Cl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ei(o)&&(o.freeBooleanPointer(),n instanceof nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof bs&&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()),Ei(o)&&(o.invalidateUpstreamBooleanData(),Cl(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 Mr&&(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{iS(a,r,o,{scene:this,shared:n}),a instanceof et&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Pn||l instanceof Mr)&&(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 Xo&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{De.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...Wl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=Ze.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Qo&&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=ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Zc.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 Qo&&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),Pd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Qo&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(Ei(s)||Al(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Rl(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;De.is(a)&&(a.visible||s?.object.data.visible)&&((Ei(a)||Al(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Rl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)De.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)De.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)De.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof et&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();Cl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)zo.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)De.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Ad(e,r,l);return c instanceof Bi&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof et&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof et&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new ZR().fromArray(m)),h=new tL(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new JR;return o.setFromPoints(r),o.getCenter(AS),AS}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Mt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof or&&e(r.material[o]);else r.material instanceof or&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Xo&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Vl({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};import{DRACOLoader as oL}from"three/examples/jsm/loaders/DRACOLoader.js";var ji;function MS(i){return ji||(ji=new oL,ji.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ji.decoderPending}async function iL(i){if(ji){let t={attributeIDs:ji.defaultAttributeIDs,attributeTypes:ji.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ji.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 IS(i,t){let[e,r]=lp(Lc.deserialize(new Uint8Array(i)));return tu(e),t&&t(e),r.result().data}function ES(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 NS(i){for(let t of i){let e=await iL(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 yme}from"three";import{mergeBufferGeometries as bme}from"three/examples/jsm/utils/BufferGeometryUtils.js";function DS(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 _S,ShaderLib as nL}from"three";function RS(i){let t=new Set;return i.traverse(e=>{if(e instanceof ir)if(dt(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(aL(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new _S,specularColor:new _S});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},nL.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=Zb(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 aL(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 LS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function BS(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 lL}from"three/examples/jsm/utils/BufferGeometryUtils.js";function VS(i){let t=[];return i.traverse(e=>{e instanceof Ii&&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&&DS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Mt&&a.unshift(r.geometry),a.length){let s=lL(a);r instanceof Mt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:Sv})}),i}function zS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function GS(i){Object.values(i.shared.materials).forEach(t=>{am(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?am(e.material):"materials"in e&&e.materials.forEach(r=>{am(r)})})}function am(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var kS=Ms(jS(),1);var US="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",sm=class extends uL{load(t,e,r,o=console.error){let n=new cL(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(US+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(US),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 IS(t,GS),r=ES(e);e.version&&(0,kS.default)(e.version,"1.10.76")>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&&MS(),Iv(e)&&Cb(),Gv(e)&&fv(),w1(e)&&b1(),Bd(e)&&nm()].filter(Boolean)),r.length&&await NS(r);let o=!1,n=new yn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new zd(e.scene,n);Bd(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=VS(a),a=RS(a),a=LS(a),a=BS(a),a=zS(a),a}};export{sm as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splinetool/loader",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.76",
|
|
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",
|