@splinetool/loader 0.9.183 → 0.9.185
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 +1 -1
- package/build/SplineLoader.js +1 -1
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -1335,4 +1335,4 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
1335
1335
|
`,A),d=A.horizontalAlign===1?l:0,s=this.computeSpaceWidthForLine(t,0,A),c=this.getLineInitialOffsetX(i[0],a,A.horizontalAlign,t[0],l),u=this.getLineInitialOffsetY(n,t.length,A.height,r,A.verticalAlign),p=[],f=t.map(x=>[]),m=t.map(x=>[]),h;for(let x=0;x<t.length;x++){let S=t[x],v={features:{liga:!0}},b=[];try{b=e.stringToGlyphs(S,v)}catch(w){console.warn(w)}c=this.getLineInitialOffsetX(i[x],a,A.horizontalAlign,S,l);let P=[];try{P=this.reverseLigaturesTable(e,S,b)}catch(w){console.warn(w)}s=this.computeSpaceWidthForLine(t,x,A);for(let w=0;w<b.length;w++){let g=b[w],N=g.index===0?`
|
|
1336
1336
|
`:g.unicode?String.fromCharCode(g.unicode):void 0,O=P[w],C=0,T=0;w===0&&A.horizontalAlign===2&&g.leftSideBearing!==void 0&&(T=-g.leftSideBearing*r),h&&(C=e.getKerningValue(g,h)*r),c+=T+C;let L=0;if(N===`
|
|
1337
1337
|
`)L=d;else if(N===" ")L=s;else{let M=this.createPath(g,r,c,u,A);M&&(L=M.offsetX-(C+T),p.push(M.path))}if(O.replacements.length===1)m[x].push([c,u]),f[x].push(L);else{let M=O.replacements.map(nA=>(e.glyphs.get(nA).advanceWidth??0)*r),U=M.reduce((nA,k)=>nA+=k,0),X=M.map(nA=>nA/U),eA=c;for(let nA=0;nA<X.length;nA++){let k=L*X[nA];m[x].push([eA,u]),f[x].push(k),eA+=k}}c+=L,h=g}u-=n}let y=[];for(let x=0,S=p.length;x<S;x++)y.push(...p[x].toShapes());return{shapes:y,charWidths:f,lineWidths:i,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,A,e,r,n){return(e===3||e===2)&&r.indexOf(`
|
|
1338
|
-
`)>=0&&(t-=n),e===3?A*.5-t*.5:e===2?A-t:0}getLineInitialOffsetY(t,A,e,r,n){let i=A*t,a=Math.abs(this.ascender-this.descender)*r,l=t-a,d=-this.ascender*r-l/2;return n===3?-(e-i-d):n===2?-(e*.5-i*.5-d):d}createPath(t,A,e,r,n){let i=t.getPath(e,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new wa,l=(t.advanceWidth??1)*A;if(t)for(let d of i.commands){let s=a.currentPath?.currentPoint;if(!(s&&d.type!=="Z"&&s.x===d.x&&-s.y===d.y))switch(d.type){case"M":a.moveTo(d.x,-d.y);break;case"L":a.lineTo(d.x,-d.y);break;case"Q":a.quadraticCurveTo(d.x1,-d.y1,d.x,-d.y);break;case"C":a.bezierCurveTo(d.x1,-d.y1,d.x2,-d.y2,d.x,-d.y);break}}return a.subPaths.forEach(d=>{let s=x1(d.curves);s!==void 0&&d.currentPoint.distanceTo(s)>0&&d.lineTo(s.x,s.y)}),{offsetX:l+n.fontSize*n.letterSpacing,path:a}}getCharWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}getTextWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}computeSpaceWidthForLine(t,A,e){let r=this.getCharWidth(" ",e),n=t[A];if(n){let i=this.countSpaces(n.trimEnd());if(e.horizontalAlign===4&&A<t.length-1&&i){let a=e.width,l=this.getTextWidth(n,e);return(a-(l-i*r))/i}}return r}countSpaces(t){return(t.match(/ /g)||[]).length}};function x1(o){if(o.length){let t=o[0];if(t instanceof fn.LineCurve)return t.v1;if(t instanceof fn.CubicBezierCurve||t instanceof fn.QuadraticBezierCurve)return t.v0}}var gc=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,A){let e=this.objects.get(t);return e===void 0?(e=this.createObject(t,A),this.objects.set(t,e)):e.isShared=!0,e}mutateIfUnique(t,A){let e=this.objects.get(t);if(e&&e.isShared!==!0)return this.objects.delete(t),this.objects.set(A,e),e}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,A){let e=this.objects.get(t);A===e?this.unreachable.delete(t):cr&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Ii=class extends gc{constructor(A){super();this.flatShading=A}disposeObject(A){A.dispose()}createObject(A,e){let r=Wr(A,e,this.flatShading);return r.computeBoundingSphere(),r}};var km={find(o){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(o){},addPendingUpdateCloner(o){}};var xc=class extends ga{constructor(A){super();this.shared=A}create(A){return new un(A,this.shared)}},Jr=class{constructor(t,A={}){this.geometryCache=new Ii(!0);this.geometryCache2=new Ii(!1);this.imageHolderCache=new xc(this);this.thisContext={scene:km,shared:this};this.deletedMaterial=new Kr(Ee.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new $e(Qs.emptyImage,this);this.deletedVideo=new $e(co.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(A.images)for(let[e,r]of Object.entries(A.images))this.addImage(e,r);if(A.videos)for(let[e,r]of Object.entries(A.videos))this.addVideo(e,r);if(A.audios)for(let[e,r]of Object.entries(A.audios))this.addAudio(e,r.data);this.reset(t)}setRequestRender(t){this._requestRender=t}reset(t){for(let[A,e]of Object.entries(t.images))this.addImage(A,e);for(let[A,e]of Object.entries(t.videos))this.addVideo(A,e);for(let[A,e]of Object.entries(t.colors))this.addColor(A,e);for(let[A,e]of Object.entries(t.materials))this.addMaterial(A,new Kr(e,this.thisContext));for(let[A,e]of Object.entries(t.audios))this.addAudio(A,e.data);for(let[A,e]of Object.entries(t.fonts))this.addFont(A,e);this.penumbraSize=t.penumbraSize}addMaterial(t,A){A.uuid=t,this.materials[t]=A}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let A=this.materials[t];return A}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new pn(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,A){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(A.data),!0):(this.images[t]=new $e(A,this),!1)}deleteImage(t){let A=this.images[t];A&&(A.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,A){return this.videos[t]?(this.videos[t].updateSrc(A.data),!0):(this.videos[t]=new $e(A,this),!1)}deleteVideo(t){let A=this.videos[t];A&&(A.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,A){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in A?this.colors[t].setRGBA(A.r,A.g,A.b,A.a):this.colors[t].setRGBA(A.r,A.g,A.b,1),!0):("a"in A?this.colors[t]=new Sr(A.r,A.g,A.b,A.a):this.colors[t]=new Sr(A.r,A.g,A.b,1),!1)}updateColor(t,A){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let e=this.colors[t];return this.colors[t].r=A.r??e.r,this.colors[t].g=A.g??e.g,this.colors[t].b=A.b??e.b,this.colors[t].a=A.a??e.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let A;if(typeof t=="string"){let e=this.getColor(t);e?A=e:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),A=new ne(0,0,0,0))}else return"a"in t?new ne(t.r,t.g,t.b,t.a):new ne(t.r,t.g,t.b,1);return A}addAudio(t,A){this.audios[t]=A}getAudio(t){let A=this.audios[t];if(A instanceof Zr)return A;{let e=new Zr({src:A});return this.audios[t]=e,e}}deleteAudio(t){let A=this.audios[t];A&&(A instanceof Zr&&A.dispose(),delete this.audios[t])}addFont(t,A){this.fonts[t]=new Ta(A),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(A=>this.deleteMaterial(A)),this._requestRender=void 0,Object.values(this.audios).forEach(A=>{A instanceof Zr&&A.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},Hm=new Jr(xs.emptyData());var ht=class extends he{updateByPatchedOp(A,e,r){if(super.updateByPatchedOp(A,e,r),Fc(A.path,["materials"])!==null&&A.type===0&&Array.isArray(this.material))for(let[n,i]of Object.entries(A.props)){let a=r.shared.material(i);this.material[Number(n)]=a}else if(vt(A.path,["material"])&&this.material instanceof je)"material"in e&&typeof e.material!="string"&&this.material.updateByOp(fe.drop(A,1),e.material,r);else if(vt(A.path,["materials","*"])&&Array.isArray(this.material)){let n=A.path[1];if("materials"in e&&n<this.material.length){let i=e.materials[n];typeof i!="string"&&this.material[n].updateByOp(fe.drop(A,2),i,r)}}}updateState(A,e){super.updateState(A,e),A.castShadow!==void 0&&(this.castShadow=A.castShadow),A.receiveShadow!==void 0&&(this.receiveShadow=A.receiveShadow);let r=this.dataPatched;if(A.geometry?.type!=="NonParametricGeometry"&&"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene?.markNeedsUpdateRendererDirty()),A.geometry?.type==="NonParametricGeometry"&&("materials"in A&&A.materials!==void 0?(this.disposeMaterial(),this.material=A.materials.map(n=>e.shared.material(n).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene?.markNeedsUpdateRendererDirty()):"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene?.markNeedsUpdateRendererDirty())),A.flatShading!==void 0||A.wireframe!==void 0||A.side!==void 0)if(Array.isArray(this.material))for(let n=0;n<this.material.length;n++)this.material[n]=this.material[n].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe)}disposeMaterial(){this.material&&gs(this.material).forEach(A=>{A instanceof je&&(A instanceof Kr||A.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Wm=require("three");var Pe=class extends ht{constructor(A,e,r){super(A,e);this.data=e;this.localGeometry=void 0}chooseGeoemtryCache(A){return A.geometryCache}markGeometryAsReachable(A){this.geometryCreateDeleyed instanceof Wm.BufferGeometry&&this.chooseGeoemtryCache(A).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Jr){let A=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(A);this.geometryCreateDeleyed=e.get(this.dataPatched.geometry,A)}return this.geometryCreateDeleyed}set geometry(A){this.localGeometry=A}get is2DAndNoDepth(){let A=this.dataPatched.geometry;return Dn.is2DParametricMesh(A.type)&&A.depth===0}get is2DType(){return Dn.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),vt(A.path,["geometry"])&&this.updateByPatchedOpGeometry(fe.drop(A,1),e.geometry,r)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(A,e){this.invalidateDownstreamBooleanData();let r=this.data.geometry.type;if(r==="NonParametricGeometry"||r==="SubdivGeometry"){let n=A;if(this.localGeometry===void 0){let s={...this.data.geometry,...n};this.localGeometry=Wr(s,e,this.data.flatShading)}let i,a,l;n.scaleBaked?[i,a,l]=n.scaleBaked:{width:i,height:a,depth:l}=n;let d=this.localGeometry.userData;d.sxPrev!==void 0&&ei(this.localGeometry.attributes,i/d.sxPrev,a/d.syPrev,l/d.szPrev),d.sxPrev=i,d.syPrev=a,d.szPrev=l}else{let n={...this.data.geometry,...A};this.localGeometry?.dispose(),this.localGeometry=Wr(n,e,this.data.flatShading)}}refreshAttachedCloners(A){for(let e of this.attachedSurfaceCloners)A.scene.addPendingUpdateCloner(e.object)}createGeometryDelayed(A){this.geometryCreateDeleyed=A.shared,this.refreshAttachedCloners(A)}updateByPatchedOpGeometry(A,e,r){let n=!1;A.type===0&&A.path.length===0&&Fn(["scaleBaked"],Object.keys(A.props))&&this.geometryCreateDeleyed instanceof JA&&this.chooseGeoemtryCache(r.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,A.props.scaleBaked),this.refreshAttachedCloners(r)),n||(r.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(r)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(A,e){this.createGeometryDelayed(e)}updateState(A,e){A.geometry!==void 0&&this.updateGeometryOnStateUpdate(A.geometry,e),super.updateState(A,e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;this.is2DType?A.set(0,0,r.depth*.5):A.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}};function v1(o){if(o.geometry.attributes.extrudeNormal||!o.geometry.attributes.position||!o.geometry.attributes.normal)return;let t=new Map,A=o.geometry.attributes.position.array,e=o.geometry.attributes.normal.array,r=new Float32Array(A.length);for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=new Ye.Vector3(e[n],e[n+1],e[n+2]);t.has(i)?t.get(i)?.normals.push(a):t.set(i,{normals:[a],result:new Ye.Vector3})}t.forEach((n,i)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=t.get(i)?.result;a&&(r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z)}o.geometry.setAttribute("extrudeNormal",new Ye.Float32BufferAttribute(r,3))}function b1(o){if(o.geometry.attributes.extrudeNormals||!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=new Ye.Vector3;for(let r=0;r<t.length;r+=3)e.set(t[r],t[r+1],t[r+2]).normalize(),A[r]=e.x,A[r+1]=e.y,A[r+2]=e.z;o.geometry.setAttribute("extrudeNormal",new Ye.Float32BufferAttribute(A,3))}function mn(o){if(Array.isArray(o.material)){for(let t of o.material)if(t.getLayersOfType("outline").length===0)return}else if(!(o.material instanceof je)||o.material.getLayersOfType("outline").length===0)return;o instanceof Pe&&o.is2DAndNoDepth?b1(o):v1(o)}function hn(o){if(!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=parseInt(o.uuid.replace(/\D/g,"")),r=[Ye.MathUtils.seededRandom(e),Ye.MathUtils.seededRandom(e+1e4),Ye.MathUtils.seededRandom(e+2e4)];for(let n=0;n<t.length;n++)A[n]=r[n%3];o.geometry.setAttribute("randomColor",new Ye.BufferAttribute(A,3))}var S1;$o.then(o=>{S1=o});var Rt=new Jt.Box3,Li=new Jt.Vector3;var _r=class extends Pe{constructor(A,e,r){super(A,e,r);this.data=e;this.hiddenMatrixOld=new Jt.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(A){return this.dataPatched.flatShading?A.geometryCache:A.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;A.copy(this.originalGeometryNew.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}createGeometryByControls(A){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:r,subdividedGeometry:n,subdivPointer:i}=JA.build(A,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=i,r!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=r),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,mn(this),hn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(A,e){if(super.updateState(A,e),A.flatShading!==void 0){let r=this.material;this.material=r.getFlavor(!1,r.side,r.wireframe),this.smoothShading=!A.flatShading,this.createGeometryDelayed(e)}}updateMesh(A=!1){JA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&JA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=JA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=JA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(A,e){let r=this.localGeometry;this.localGeometry=this.originalGeometryNew,he.prototype.raycast.call(this,A,e),this.localGeometry=r}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new Jt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let e=A.attributes.position,r=A.boundingSphere.center;Rt.setFromBufferAttribute(e),Rt.getCenter(r),A.boundingSphere.radius=r.distanceTo(Rt.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Rt.getSize(Li),this.hasNonUniformScale&&Li.divide(this.scale);let n={width:Li.x,height:Li.y,depth:Li.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(A){let e=this.originalGeometry;Rt.min.set(A[0],A[2],A[4]),Rt.max.set(A[1],A[3],A[5]),this.hasNonUniformScale&&(Rt.min.applyMatrix4(this.shearScaleInv),Rt.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new Jt.Sphere);let r=e.boundingSphere.center;Rt.getCenter(r),e.boundingSphere.radius=r.distanceTo(Rt.max)}freeSubdivPointer(){this.subdivPointer&&(JA.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(A,e,r){super.updateByPatchedOpGeometry(A,e,r),this.localGeometry&&this.createGeometryByControls(e)}};var Vt=require("three"),qm=-1,w1=1,Qm={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Ym={polygon_center:0,edge:1,vertex:2},Ei=(o,t)=>(A,e)=>!t||A===0||o===0?0:o*e/100,mA=(o,t)=>{let A=Math.abs(t),e=A*-1;return(o-qm)*(A-e)/(w1-qm)+e};function Xm(o){let t=[],A={};for(var e=0,r=o.length;e<r;e++){var n=JSON.stringify(o[e].pos.map(i=>Math.round(i*1e4)/1e4));A[n]||(t.push(o[e]),A[n]=!0)}return t}var T1=new Vt.Vector3,Oa=new Vt.Vector3,O1=new Vt.Vector3,P1=new Vt.Vector3;function yn(o,t){let A=O1.fromArray(o),e=P1.fromArray(t);Oa.copy(e).sub(A);let r=Oa.length();return Oa.normalize().multiplyScalar(r*.5),T1.copy(A).add(Oa).toArray()}var At=new Vt.Triangle,Pa=new Vt.Vector3,Na=new Vt.Vector3,$r=new Vt.Vector3;function Km(o){let t=[];for(let A=0;A<=o.index.count;A++)if(Pa.fromArray(o.index.array,A*3),At.setFromAttributeAndIndices(o.attributes.position,Pa.x,Pa.y,Pa.z),At.getNormal(Na),At.getMidpoint($r),!(isNaN($r.x)||isNaN($r.y)||isNaN($r.z))){let{a:e,b:r,c:n}=At,i=e.toArray(),a=r.toArray(),l=n.toArray(),d=e.distanceTo(r),s=r.distanceTo(n),c=n.distanceTo(e),u=yn(i,a),p=yn(a,l),f=yn(l,i),m=[d,s,c],h=Math.max(...m),y=m.filter(v=>Math.round(v)===Math.round(h)).length>1,x=[],S=At.getMidpoint($r).toArray();h===d&&!y&&(x=[p,f,f],S=u),h===s&&!y&&(x=[u,f,f],S=p),h===c&&!y&&(x=[u,p,p],S=f),y&&(x=[u,p,f]),t.push({vertices:[i,a,l],faceCenters:x,midpoint:S,norm:At.getNormal(Na).toArray()})}return t}function Zm(o){let t=[],{position:A}=o.attributes;for(let e=0;e<A.count;e++){At.setFromAttributeAndIndices(A,e*3,e*3+1,e*3+2),At.getNormal(Na),At.getMidpoint($r);let r=At.a.toArray(),n=At.b.toArray(),i=At.c.toArray();t.push({vertices:[r,n,i],faceCenters:[yn(r,n),yn(n,i),yn(i,r)],midpoint:$r.toArray(),norm:Na.toArray()})}return t}var N1=4,C1=.5,vc=o=>.5*(1-Math.cos(o*Math.PI)),bc=class{constructor(){this.perlin=new Array(4095+1)}noise(t,A=0,e=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),A<0&&(A=-A),e<0&&(e=-e);let r=Math.floor(t),n=Math.floor(A),i=Math.floor(e),a=t-r,l=A-n,d=e-i,s,c,u=0,p=.5,f,m,h;for(let y=0;y<N1;y++){let x=r+(n<<4)+(i<<8);s=vc(a),c=vc(l),f=this.perlin[x&4095],f+=s*(this.perlin[x+1&4095]-f),m=this.perlin[x+16&4095],m+=s*(this.perlin[x+16+1&4095]-m),f+=c*(m-f),x+=256,m=this.perlin[x&4095],m+=s*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=s*(this.perlin[x+16+1&4095]-h),m+=c*(h-m),f+=vc(d)*(m-f),u+=f*p,p*=C1,r<<=1,a*=2,n<<=1,l*=2,i<<=1,d*=2,a>=1&&(r++,a--),l>=1&&(n++,l--),d>=1&&(i++,d--)}return u}noiseSeed(t){let A=(()=>{let i,a;return{setSeed(l){a=i=(l??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();A.setSeed(t),this.perlin=new Array(4095+1);for(let e=0;e<4095+1;e++)this.perlin[e]=A.rand()}},Jm=bc;var xn=require("three");var _m=new xn.Vector3,$m=new xn.Matrix4,Ah=new xn.Ray;function eh(o){let t=!1;return o.scene.objects.traverse((A,e)=>{e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(t=!0)}),t}var gn=class extends Pe{constructor(A,e,r){super(A,e,r);this.data=e}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let A=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,A.geometry.height,this.fontScale,A.geometry.verticalAlign)??0}get fontScale(){let A=this.dataPatched;return this.font?A.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let A=this.dataPatched;return A.geometry.fontSize*A.geometry.lineHeight}raycast(A,e){let{matrixWorld:r}=this;if($m.copy(r).invert(),Ah.copy(A.ray).applyMatrix4($m),Ah.intersectBox(this.singleBBox,_m)){let n=_m.applyMatrix4(r),i=A.ray.origin.distanceTo(n);e.push({distance:i,point:n.clone(),object:this})}}};var Ne=1e-4,jt,oh,nh,ih,th=new IA.Vector3,rh=new IA.Vector3;$o.then(o=>{jt=o,oh=[jt.get_face_center,jt.get_edge_midpoint,jt.get_vertex_position],nh=[jt.get_face_normal,jt.get_edge_normal,jt.get_vertex_normal],ih=[jt.face_count,jt.edge_count,jt.vertex_count]});var I1=new IA.Matrix4,L1=new IA.Matrix4,Tr=new IA.Vector3,Ao=new IA.Vector3,Mi=new IA.Vector3,Sc=new IA.Vector3,E1=new IA.Vector3,M1=new IA.Vector3;var _t=new Jm,bn=class extends zo(IA.Object3D){constructor(A,e){super();this.parameters=e;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=A}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(A){if(this.parent===null)this.updateState(this.parameters,A);else for(let e of this.children)e instanceof Xt&&e.expand()}invalidateTransform(A){this.matrixWorldNeedsUpdate=!0,this.traverse(e=>{e instanceof Xt&&e.object===A&&(e.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let A of this.children)A.updateMatrix(),A.hasNonUniformScale&&(A.updateMatrixWorld(),A.updateMatrixWorldSVD())}_updateCount(A){let e;if(A!==void 0?e=A:e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(e=0),this.parameters.type==="toObject"&&this.objectForSample){for(let n=0,i=this.children.length;n<i;++n)this.remove(this.children[0]);let r=this.children;if(r.length===e)return;if(r.length<e)for(let n=0,i=e-r.length;n<i;++n){let a=new Xt(this.object);a.expand(),this.add(a)}else for(let n=0,i=r.length-e;n<i;++n)this.remove(r[n])}else{if(this.children.length===e)return;if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let i=new Xt(this.object);i.expand(),this.add(i)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}}_updateRadial(A){let e=A.radial,r=e.start*IA.MathUtils.DEG2RAD,n=e.end*IA.MathUtils.DEG2RAD,i=r-n,a=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),l;switch(e.axis){case"z":l=new IA.Vector3(0,0,1);break;case"y":l=new IA.Vector3(0,1,0);break;default:case"x":l=new IA.Vector3(1,0,0);break}let d=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,s=d.noiseType==="perlin";_t.noiseSeed(d.seed);let c=Ys((0,vn.default)(d.seed)),u=Ei(d.strength,this.parameters.randomness);for(let[p,f]of this.children.entries()){let m=p*(d.freqScale/10)+d.movement,h=s?_t.noise(m):c(m,m);f.scale.x=e.scale[0]+u(p,mA(h,d.scale[0]))||Ne,f.scale.y=e.scale[1]+u(p,mA(h,d.scale[1]))||Ne,f.scale.z=e.scale[2]+u(p,mA(h,d.scale[2]))||Ne,f.position.setScalar(0);let y=i/A.count*p-r;switch(e.axis){case"x":f.rotation.set(0,y,0);break;case"y":f.rotation.set(0,0,y);break;case"z":f.rotation.set(y,0,0);break}f.translateOnAxis(l,e.radius),f.position.x+=e.position[0]+u(p,mA(h,d.position[0])),f.position.y+=e.position[1]+u(p,mA(h,d.position[1])),f.position.z+=e.position[2]+u(p,mA(h,d.position[2]));let x=u(p,mA(h,d.rotation[0])),S=u(p,mA(h,d.rotation[1])),v=u(p,mA(h,d.rotation[2]));e.alignment===!0?(f.rotation.x+=a.x+x,f.rotation.y+=a.y+S,f.rotation.z+=a.z+v):f.rotation.set(a.x+x,a.y+S,a.z+v)}}_updateLinear(A){if(A.type!=="linear")throw new Error;let e=A.linear,r=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";_t.noiseSeed(n.seed);let a=Ys((0,vn.default)(n.seed)),l=Ei(n.strength,this.parameters.randomness);for(let[d,s]of this.children.entries()){let c=d*(n.freqScale/10)+n.movement,u=i?_t.noise(c):a(c,c),p=l(d,mA(u,n.rotation[0])),f=l(d,mA(u,n.rotation[1])),m=l(d,mA(u,n.rotation[2]));s.scale.x=1+(e.scale[0]-1)*d+l(d,mA(u,n.scale[0]))||Ne,s.scale.y=1+(e.scale[1]-1)*d+l(d,mA(u,n.scale[1]))||Ne,s.scale.z=1+(e.scale[2]-1)*d+l(d,mA(u,n.scale[2]))||Ne,s.rotation.x=r.x*d+p,s.rotation.y=r.y*d+f,s.rotation.z=r.z*d+m,s.position.x=e.position[0]*d+l(d,mA(u,n.position[0])),s.position.y=e.position[1]*d+l(d,mA(u,n.position[1])),s.position.z=e.position[2]*d+l(d,mA(u,n.position[2]))}}_updateGrid(A){let e=0,r=A.grid,n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=Ei(n.strength,this.parameters.randomness),a=n.noiseType==="perlin";_t.noiseSeed(n.seed);let l=Af((0,vn.default)(n.seed));if(r.useCenter===!0){let d={x:r.count[0]%2===0?2:1,y:r.count[1]%2===0?2:1,z:r.count[2]%2===0?2:1},s=new IA.Vector3(r.size[0]*(r.count[0]-d.x)*.5,r.size[1]*(r.count[1]-d.y)*.5,r.size[2]*(r.count[2]-d.z)*.5);for(let c=0;c<r.count[0];c++)for(let u=0;u<r.count[1];u++)for(let p=0;p<r.count[2];p++){let f=[(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement],m=a?_t.noise(...f):l(...f),h=this.children[e++];h.scale.x=1+i(e,mA(m,n.scale[0]))||Ne,h.scale.y=1+i(e,mA(m,n.scale[1]))||Ne,h.scale.z=1+i(e,mA(m,n.scale[2]))||Ne;let y=i(e,mA(m,n.rotation[0])),x=i(e,mA(m,n.rotation[1])),S=i(e,mA(m,n.rotation[2]));h.rotation.set(y,x,S),h.position.x=r.size[0]*c-s.x+i(e,mA(m,n.position[0])),h.position.y=r.size[1]*u-s.y+i(e,mA(m,n.position[1])),h.position.z=r.size[2]*p-s.z+i(e,mA(m,n.position[2]))}}else for(let d=0;d<r.count[0];d++)for(let s=0;s<r.count[1];s++)for(let c=0;c<r.count[2];c++){let u=[(d+1)*(n.freqScale/10)+n.movement,(s+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement],p=a?_t.noise(...u):l(...u),f=this.children[e++];f.scale.x=1+i(e,mA(p,n.scale[0]))||Ne,f.scale.y=1+i(e,mA(p,n.scale[1]))||Ne,f.scale.z=1+i(e,mA(p,n.scale[2]))||Ne;let m=i(e,mA(p,n.rotation[0])),h=i(e,mA(p,n.rotation[1])),y=i(e,mA(p,n.rotation[2]));f.rotation.set(m,h,y),f.position.x=r.size[0]*d+i(e,mA(p,n.position[0])),f.position.y=-r.size[1]*s+i(e,mA(p,n.position[1])),f.position.z=-r.size[2]*c+i(e,mA(p,n.position[2]))}}_updateToObject(A){if(A.type!=="toObject")throw new Error;let{toObject:e}=A,r=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";_t.noiseSeed(n.seed);let a=Ys((0,vn.default)(n.seed)),l=Ei(n.strength,this.parameters.randomness);if(!e.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof gn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;let d=this.getSubdivData(),s=[],c=y=>{let x=y.length,S=y.map(P=>P[0]).reduce((P,w)=>P+w,0),v=y.map(P=>P[1]).reduce((P,w)=>P+w,0),b=y.map(P=>P[2]).reduce((P,w)=>P+w,0);return[S/x,v/x,b/x]},u=y=>Math.round(y*1e6)/1e6;d.forEach(y=>{let x=d.filter(S=>u(y.pos[0])===u(S.pos[0])&&u(y.pos[1])===u(S.pos[1])&&u(y.pos[2])===u(S.pos[2]));x.length>1?s.push({pos:y.pos,norm:c(x.map(S=>S.norm))}):s.push(y)});let p=Xm(s);if(d.length>0){let y=Math.round(p.length*e.count/100);this._updateCount(y)}this.objectForSample.updateMatrixWorld();let f=new Xs(this.objectForSample).build(),m=Qm[e.axis],h=this.children;f.setRandomGenerator((0,vn.default)(this.object.uuid+e.seed));for(let[y,x]of h.entries()){let S=y*(n.freqScale/10)+n.movement,v=i?_t.noise(S):a(S,S),b=l(y,mA(v,n.rotation[0])),P=l(y,mA(v,n.rotation[1])),w=l(y,mA(v,n.rotation[2]));e.spreadType==="random"?f.sample(Mi,Sc):(p.length&&(Mi.fromArray(p[y].pos),Sc.fromArray(p[y].norm)),this.objectForSample instanceof _r&&Mi.applyMatrix4(I1.copy(this.objectForSample.matrixWorld).invert())),Mi.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(Mi),Tr.fromArray(m);let g=e.align==="normal"?Sc:this.object.getWorldDirection(M1),N=Ao.fromArray(e.position);Ao.x+=Ao.x+l(y,mA(v,n.position[0])),Ao.y+=Ao.y+l(y,mA(v,n.position[1])),Ao.z+=Ao.z+l(y,mA(v,n.position[2]));let O=Math.acos(g.dot(Tr)),C=E1.crossVectors(Tr,g).normalize(),T=L1.makeRotationAxis(C,O),L=g.clone().cross(this.object.up).normalize(),M=L.clone().cross(g).normalize(),U=new IA.Matrix4().makeBasis(L,g,M),X=new IA.Vector3(Tr.y,Tr.z,Tr.x).normalize(),eA=X.clone().cross(Tr).normalize(),nA=new IA.Matrix4().makeBasis(X,Tr,eA).invert(),k=new IA.Matrix4().multiplyMatrices(U,nA);x.rotation.setFromRotationMatrix(k),N.applyMatrix4(T),x.position.add(N),x.rotation.x=x.rotation.x+r.x+b,x.rotation.y=x.rotation.y+r.y+P,x.rotation.z=x.rotation.z+r.z+w,x.scale.setScalar(1),x.scale.x=x.scale.x+e.scale[0]+l(y,mA(v,n.scale[0]))||Ne,x.scale.y=x.scale.y+e.scale[1]+l(y,mA(v,n.scale[1]))||Ne,x.scale.z=x.scale.z+e.scale[2]+l(y,mA(v,n.scale[2]))||Ne,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let A=this.parameters.toObject.spreadType;if(A==="random")return[];if(this.objectForSample instanceof _r){let e=this.objectForSample,r=Ym[A],n=ih[r],i=oh[r],a=nh[r],l=[],d=n(e.subdivPointerNew);for(let s=0;s<=d-1;s++){let c=i(e.subdivPointerNew,s),u=a(e.subdivPointerNew,s);th.fromArray(c).applyMatrix4(e.matrixWorld),rh.fromArray(u),l.push({pos:th.toArray(),norm:rh.toArray()})}return l}else return(this.objectForSample.geometry.index?Km(this.objectForSample.geometry):Zm(this.objectForSample.geometry)).map((r,n)=>A==="polygon_center"?{pos:r.midpoint,norm:r.norm}:A==="vertex"?[{pos:r.vertices[0],norm:r.norm},{pos:r.vertices[1],norm:r.norm},{pos:r.vertices[2],norm:r.norm}]:A==="edge"?[{pos:r.faceCenters[0],norm:r.norm},{pos:r.faceCenters[1],norm:r.norm},{pos:r.faceCenters[2],norm:r.norm}]:[]).flat()}updateState(A,e){if(this.parameters=Vr(A),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=e.find(this.parameters.toObject.object);r instanceof he?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new IA.Matrix4,this.hiddenMatrix=new IA.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var ot=require("three");var WA=require("three");var xe=require("three");var sh=require("three"),Ft=o=>{var t;return t=class extends o{},t.geometryHelper=new sh.BoxGeometry(30,30,30),t};var be=require("three"),Ca=new be.Ray,wc=new be.Sphere,ah=new be.Matrix4,zt=(o,t,A,e,r=!1)=>{let n=t,i=o.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),wc.copy(n.boundingSphere),wc.applyMatrix4(i),A.ray.intersectsSphere(wc)===!1||(ah.copy(i).invert(),Ca.copy(A.ray).applyMatrix4(ah),n.boundingBox!==null&&Ca.intersectsBox(n.boundingBox)===!1))return;let a,l,d,s,c=n.index,u=n.attributes.position,p=n.drawRange,f,m;if(r===!1){let y=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(f=y,m=x;f<m;f+=3)if(l=c.getX(f),d=c.getX(f+1),s=c.getX(f+2),a=h(o,A,Ca,u,l,d,s),a){a.faceIndex=Math.floor(f/3),e.push(a);return}}else{let x=n.attributes.position,S=new be.Vector3,v=new be.Vector3,b=new be.Vector3,P=new be.Vector3,w=2,N=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=N*N,C=Math.max(0,p.start),T=Math.min(x.count,p.start+p.count);for(let L=C,M=T-1;L<M;L+=w){if(S.fromBufferAttribute(x,L),v.fromBufferAttribute(x,L+1),Ca.distanceSqToSegment(S,v,P,b)>O)continue;P.applyMatrix4(o.matrixWorld);let X=A.ray.origin.distanceTo(P);X<A.near||X>A.far||e.push({distance:X,point:b.clone().applyMatrix4(o.matrixWorld),object:o})}}function h(y,x,S,v,b,P,w){let g=new be.Vector3,N=new be.Vector3,O=new be.Vector3,C=new be.Vector3,T=new be.Vector3;if(g.fromBufferAttribute(v,b),N.fromBufferAttribute(v,P),O.fromBufferAttribute(v,w),S.intersectTriangle(g,N,O,!1,C)===null)return null;T.copy(C),T.applyMatrix4(y.matrixWorld);let M=x.ray.origin.distanceTo(T);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:T.clone(),object:y}}};var Ia=new xe.Vector3,et=new xe.Camera,Tc=class extends xe.LineSegments{constructor(A){let e=new xe.BufferGeometry,r=new xe.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},l=new xe.Color(15711266),d=new xe.Color(15711266),s=new xe.Color(2857471);c("n1","n2",l),c("n2","n4",l),c("n4","n3",l),c("n3","n1",l),c("f1","f2",l),c("f2","f4",l),c("f4","f3",l),c("f3","f1",l),c("n1","f1",l),c("n2","f2",l),c("n3","f3",l),c("n4","f4",l),c("p","n1",d),c("p","n2",d),c("p","n3",d),c("p","n4",d),c("u1","u2",s),c("u2","u3",s),c("u3","u1",s);function c(p,f,m){u(p,m),u(f,m)}function u(p,f){n.push(0,0,0),i.push(f.r,f.g,f.b),a[p]===void 0&&(a[p]=[]),a[p].push(n.length/3-1)}e.setAttribute("position",new xe.Float32BufferAttribute(n,3)),e.setAttribute("color",new xe.Float32BufferAttribute(i,3));super(e,r);this.type="CameraHelper",this.camera=A,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let A=this.geometry,e=this.pointMap,r=!0;et.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,i=1,a=r?.8:1e-4;yt("n1",e,A,et,-n,-i,a),yt("n2",e,A,et,n,-i,a),yt("n3",e,A,et,-n,i,a),yt("n4",e,A,et,n,i,a);let l=a;yt("f1",e,A,et,-n,-i,l),yt("f2",e,A,et,n,-i,l),yt("f3",e,A,et,-n,i,l),yt("f4",e,A,et,n,i,l);let d=l,s=.5;yt("u1",e,A,et,n*.7*s,i*1.1,d),yt("u2",e,A,et,-n*.7*s,i*1.1,d),yt("u3",e,A,et,0,i*(1.1+.9*s),d),A.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yt(o,t,A,e,r,n,i){Ia.set(r,n,i).unproject(e);let a=t[o];if(a!==void 0){let l=A.getAttribute("position");for(let d=0,s=a.length;d<s;d++)l.setXYZ(a[d],Ia.x,Ia.y,Ia.z)}}var La=class extends Ft(Tc){constructor(A){super(A);this.object=A;this.object=A,this.name=`CombinedCameraHelper: ${A.uuid}`}updateMatrixWorld(A){super.updateMatrixWorld(A),this.updateTarget()}updateTarget(){let A=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(A)}raycast(A,e){zt(this.object,this.geometry,A,e,!0)}};var Bi=require("three");var Ea;(t=>t.is=A=>"objectHelper"in A)(Ea||(Ea={}));var Or=(o,t)=>class extends Zs(o){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(r,n){this.objectHelper.raycast(r,n)}showGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof Bi.Box3Helper&&(n.visible=!0)}}updateEntityBoxSize(r,n){this.objectHelper.visible&&this.geometryHelper instanceof Bi.BoxGeometry?(r.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(r,n)}hideGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof Bi.Box3Helper&&(n.visible=!1)}}};var Sn=new WA.Vector3,Oc=new WA.Vector3,$t=class extends Or(WA.Camera,La){constructor(A="",e={...fo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Er.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(A,e),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let r=this.width,n=this.height;this.orthoCamera=new WA.OrthographicCamera(r*-.5,r*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new WA.PerspectiveCamera(45,r/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(A){this.perspCamera.fov=A}get fov(){return this.perspCamera.fov}setNear(A,e){A==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(A,e){e>=0&&(A==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(A){A==="PerspectiveCamera"?this.toPerspective():A==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(A){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=A:this.orthoCamera.near=A}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(A){A>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=A:this.orthoCamera.zoom=A)}lookAt(A){super.lookAt(A),this.getWorldPosition(Sn),this.targetOffset=Sn.distanceTo(A)}getTarget(A=new WA.Vector3){return this.getWorldDirection(Oc),this.getWorldPosition(Sn),Oc.multiplyScalar(this.targetOffset),A.copy(Sn).add(Oc),A}getDistanceToTarget(){let A=this.getTarget();return this.getWorldPosition(Sn),Sn.distanceTo(A)}updateUp(){let A=this.getWorldQuaternion(new WA.Quaternion),e=new WA.Vector3(0,0,1).applyQuaternion(A),r=new WA.Vector3().copy(WA.Object3D.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(A);let n=new WA.Vector3().copy(WA.Object3D.DefaultUp).projectOnPlane(e),i=new WA.Vector3().crossVectors(n,r).dot(e)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*i}updateTransformState(A){let e=super.updateTransformState(A);return A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateUp(),e}getViewFrontToObject(A){let e=A.getWorldPosition(new WA.Vector3),n=A.getWorldDirection(new WA.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().add(n),target:e}}getViewToObject(A){let e=A.getWorldPosition(new WA.Vector3),n=this.getWorldDirection(new WA.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}setViewplaneSize(A,e){this.left=-A*.5,this.right=A*.5,this.top=e*.5,this.bottom=-e*.5,this.aspect=A/e,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(A){this.perspCamera.setFocalLength(A),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(A,e,r,n,i,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(A,e,r,n,i,a):this.orthoCamera.setViewOffset(A,e,r,n,i,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,e){super.updateWorldMatrix(A,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(A,e){return super.copy(A,e),this.orthoCamera.copy(A.orthoCamera),this.perspCamera.copy(A.perspCamera),this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.bottom,this.far=A.far,this.view=A.view===null?null:Object.assign({},A.view),this._cameraType=A._cameraType,this.aspect=A.aspect,this.fov=A.fov,this.focus=A.focus,this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this.targetOffset=A.targetOffset,this.updateProjectionMatrix(),this}toCameraState(A=[]){let e={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return jo(e,A)}updateCameraSubtype(A,e){let r=A==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(r,e.zoom),e.near!==void 0&&this.setNear(r,e.near),e.fov!==void 0&&r==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(A){this.updateCameraState(A)}updateCameraState(A){this.updateState_Entity(A,{}),A.far!==void 0&&(this.far=A.far),A.orthographic!==void 0&&this.updateCameraSubtype("orthographic",A.orthographic),A.perspective!==void 0&&this.updateCameraSubtype("perspective",A.perspective),A.type!==void 0&&(this.cameraType=A.type),A.up!==void 0&&this.up.fromArray(A.up),A.targetOffset!==void 0&&(this.targetOffset=A.targetOffset),A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.type===0&&this.updateCameraSubtype(A.path[0],A.props)}toState(A){return{...super.toState(A),...this.toCameraState(A),type:this.cameraType}}};var eo=require("three");var lh=new eo.Matrix4;var tt=class extends ht{constructor(A,e,r){super(A,e);this.data=e;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new eo.BufferGeometry;this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&A.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(A,e=!0){if(this.booleanMeshSetAddress!==-1)return;for(let n=0;n<this.children.length;n++){let i=this.children[n];i instanceof tt&&i.recomputeBoolean(A===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let i=this.children[n];if(i instanceof he&&i.dataPatched.visible===!0&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if((i.geometry.index??i.geometry.getAttribute("position")).count/3<15e5&&(i.booleanMeshSetAddress=dt.getMeshSet(i.geometry,A===!0,e)),i.booleanMeshSetAddress===-1)return;dt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else i instanceof tt&&i.needsTransformForDownstream===!0?(dt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(lh.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),dt.transformMeshSet(i.booleanMeshSetAddress,lh),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new eo.Float16BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(A===!0)return dt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new eo.BufferGeometry,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=dt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,mn(this),hn(this)}dispose(){super.dispose(),this.geometry.dispose()}};var dh=require("three");var ch;(t=>{function o(A){return HA.is(A)&&A instanceof dh.Light}t.is=o})(ch||(ch={}));var wn=(o,t)=>class extends Or(o,t){updateState_Light(e,r){this.updateState_Entity(e,r),e.color!==void 0&&(this.color=r.shared.color(e.color)),e.intensity!==void 0&&(this.intensity=e.intensity),e.depth!==void 0&&(this.shadow.camera.far=e.depth,this.shadow.needsUpdate=!0),e.shadows!==void 0&&(this.castShadow=e.shadows)}};var Di=o=>o instanceof he,Gi=o=>o!==null&&o instanceof tt,uh=o=>o instanceof $t;var ph=o=>Ea.is(o);var mh=require("three");var fh=require("three");var Pr=class extends Ft(fh.AxesHelper){constructor(A,e=15){super(e);this.object=A;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${A.uuid}`,this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1}raycast(A,e){zt(this.object,Pr.geometryHelper,A,e)}update(){}};var Ri=class extends Or(mh.Group,Pr){constructor(t,A){super(),this.super_Entity(t,A),this.objectHelper.update()}updateState(t,A){this.updateState_Entity(t,A)}};var ji=require("three");var hh=require("three");var Tn=class extends Ft(hh.DirectionalLightHelper){constructor(A,e=15,r=10066329){super(A,e,r);this.object=A;this.added=!1;this.name=`DirectionalLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,Tn.geometryHelper,A,e)}};var yh=require("three");var On=class extends Ft(yh.PointLightHelper){constructor(A,e=15,r=6710886){super(A,e,r);this.object=A;this.name=`PointLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,On.geometryHelper,A,e)}};var Ba=require("three");var Ma=class extends Ft(Ba.SpotLightHelper){constructor(A,e=6710886){super(A,e);this.object=A;this.name=`SpotLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,Ma.geometryHelper,A,e)}update(){if(this.object!==void 0){let A=Ma._vector,e=this.object.distance?this.object.distance:1e3,r=e*Math.tan(this.object.angle);this.cone.scale.set(r,r,e),A.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(A);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let i=0,a=this.cone.material.length;i<a;i++)this.cone.material[i].color.set(n);else this.cone.material.color.set(n)}}},Vi=Ma;Vi._vector=new Ba.Vector3;function D1(o,t){o.shadow.camera.right=t/2,o.shadow.camera.left=-t/2,o.shadow.camera.top=t/2,o.shadow.camera.bottom=-t/2,o.shadow.needsUpdate=!0}var Da=class extends wn(ji.DirectionalLight,Tn){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let i=new ji.CameraHelper(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof ji.CameraHelper&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A);let e=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&D1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e&&this.update()}};var Fe=require("three");var Ga=class extends wn(Fe.PointLight,On){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let i=new Fe.Vector3(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Fe.Vector3(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new Fe.Box3(i,a),d=new Fe.Box3Helper(l,new Fe.Color(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let A=this.gizmos[t];if(A instanceof Fe.Box3Helper){let e=this.shadow.camera,r=new Fe.Vector3(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),n=new Fe.Vector3(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);A.box.set(r,n),A.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var rt=require("three");var gh=new rt.Vector3,xh=new rt.Vector3,vh=new rt.Quaternion,Ra=class extends wn(rt.SpotLight,Vi){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=rt.MathUtils.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let i=new rt.CameraHelper(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof rt.CameraHelper&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),xh.setFromMatrixPosition(this.matrixWorld),vh.setFromRotationMatrix(this.matrixWorld),gh.copy(this.up).applyQuaternion(vh).negate().multiplyScalar(this.distance),this.target.position.copy(xh).add(gh),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Va=class extends Pe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}constructor(t,A,e){super(t,A,e)}updateEntityBoxSize(t,A){let e=this.geometry.getAttribute("position");e!==void 0?Ql(e,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:e.count,t,A):super.updateEntityBoxSize(t,A)}};var Sh=require("three");var Ar=class extends Or(Sh.Group,Pr){constructor(A,e,r){super();e.type==="Instance"&&typeof A=="string"&&(e=this.transformAssignData(e,r)),this.super_Entity(A,e),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(A,e){let r=e.scene.data.objects.get(A.component);if(r){let n,i;for(let a of ar.rootOverrideProps)A[a]===void 0?(n===void 0&&(n={...A}),n[a]=r.data[a]):(i===void 0&&(i={}),i[a]=A[a]);return this.overrideData=i,n??A}return A}updateByOp(A,e,r,n){let i;if(this.isInstanceRoot&&!n&&(e=this.transformAssignData(e,r),A.type===0&&A.path.length===0&&this.component))for(let a of ar.rootOverrideProps)a in A.props&&A.props[a]===void 0&&(i===void 0&&(i={...A,props:{...A.props}}),i.props[a]=this.component.data[a]);super.updateByOp(i??A,e,r,n)}updateState(A,e){this.updateState_Entity(A,e)}expandInstanceChildren(A){let e=this.data;if(this.component===void 0){this.component=A.scene.find(e.component)??null;let r=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let n=0;for(let i of this.children)if(HA.is(i))A.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),ja(i),n+=1;else break;this.children.splice(0,n)}r=!0}this.component&&wh(A,[this.uuid],e.overrides,this,this.component,this.component,0,r),this.oldComponent=this.component}}};function ja(o){if(o.component){let t=o.component.instances.indexOf(o);t>=0&&o.component.instances.splice(t,1);for(let A of o.children)HA.is(A)&&ja(A)}}function bh(o,t,A,e){return o.component===t&&Fn(o.identity,e)?o.overrideData===A?2:1:0}function wh(o,t,A,e,r,n,i,a){if(i>50)return!1;if(e.component!==r){if(e.component){let d=e.component.instances.indexOf(e);d>=0&&e.component.instances.splice(d,1)}r.instances.push(e),e.component=r}r instanceof Ar&&r.isInstanceRoot&&r.expandInstanceChildren(o);let l=0;for(let d of r.children)if(HA.is(d)){let s=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],c=mo.resolve(A,s,1),u=null,p;if(!a){let f=e.children[l];if(u=HA.is(f)?f:null,u!==null){let m=bh(u,d,c,s);p=m>=1?u.stateSelection:void 0,m!==2&&(u=null)}if(u===null&&(u=o.scene.findInstance(s)??null,u!==null)){let m=bh(u,d,c,s);if(p=m>=1?u.stateSelection:void 0,m!==2)u=null;else{let h=u.parent.children.indexOf(u);u.parent.children.splice(h,1),e.children.splice(l,0,u),u.parent===e?(h<=l&&console.error("not possible"),void 0):(u.parent=e,u.matrixWorldNeedsUpdate=!0,u.resetBBoxNeedsUpdate(),u.updateVisible(),o.pendingDeletes.delete(u),void 0)}}}if(u===null){let f=c?kt.apply(d.data,c):d.data;it.is(f.type)&&(f={...f,type:"Empty"}),u=at.createEntity(s,f,o),u.overrideData=c,e.add(u),e.children.splice(e.children.length-1,1),e.children.splice(l,0,u),u.updateState(u.data,o),p&&u.changeSelectedState(p,o),o.scene.registerInstanceAndSetUuid(u)}l+=1,wh(o,t,A,u,d,n,i+1,a)}if(!a){let d=l;for(;;){let s=e.children[l];if(HA.is(s))o.pendingDeletes.add(s);else break;l+=1}e.children.splice(d,l-d)}return!0}function G1(o,t,A){let e;return t.geometry.type==="TextGeometry"?new gn(o,t,A):(t.geometry.type==="SubdivGeometry"?e=new _r(o,t,A):t.geometry.type==="VectorGeometry"?e=new Va(o,t,A):t.geometry.type==="BooleanGeometry"?e=new tt(o,t,A):e=new Pe(o,t,A),e)}function Fa(o,t,A){return t.type==="Mesh"?G1(o,t,A):t.type==="Empty"?new Ri(o,t):t.type==="PointLight"?new Ga(o,t,A):t.type==="SpotLight"?new Ra(o,t,A):t.type==="DirectionalLight"?new Da(o,t,A):t.type==="Component"||t.type==="Instance"?new Ar(o,t,A):it.is(t.type)?new $t(o,t):(console.error(t),new Ri(o,t))}at.createEntity=Fa;function R1(o,t,A){let e=Fa(o.identity,t,A),r=o.children,n=o.parent,i=o.component,a=o.instances,l=o.overrideData,d=o.uuid,s=o.stateSelection;o.dispose();for(let c of Object.keys(o))delete o[c];Object.setPrototypeOf(o,Object.getPrototypeOf(e));for(let c of Object.keys(e))o[c]=e[c];o.children=[...o.children,...r],o.parent=n,o.component=i,o.instances=a,o.uuid=d,o.overrideData=l,o.updateState(o.data,A),s&&o.changeSelectedState(s,A),o.resetBBoxNeedsUpdate()}at.changeEntityProptotype=R1;at.Cloner=bn;function Th(o,t,A,e){o.updateByOp(t,A,e,!1)}var Pn=require("three");function Oh(o,t){let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(o.layers.set(8),e.length>0&&o.layers.enable(3),A=!0,hn(o),mn(o)),e.length===0&&r.length===0&&o.layers.set(0),A}function Ph(o,t){if(!t.layers)return!1;let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return e.length>0&&(o.layers.set(3),r.length>0&&o.layers.enable(8),A=!0),e.length===0&&r.length===0&&o.layers.set(0),A}function Nh(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof ht)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Oh(A,A.material[e])&&(t=!0);else Oh(A,A.material)&&(t=!0)}),t}function Ch(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof ht)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Ph(A,A.material[e])&&(t=!0);else Ph(A,A.material)&&(t=!0)}),t}var j1=new Pn.Raycaster,F1=new Pn.Matrix4,z1=new Pn.Ray;function Ih(o,t,A){let e=o.cloner;if(e)for(let r of e.children){let n=F1.copy(r.matrixWorld).invert(),i=z1.copy(t.ray).applyMatrix4(n),a=o.matrixWorld;i.applyMatrix4(a);let l=j1;l.set(i.origin,i.direction),l.near=t.near,l.far=t.far,l.intersectObject(o,!1).length>0&&A.push({object:o})}}var U1=new ot.MeshBasicMaterial;U1.wireframe=!0;var Lh=new ot.Vector3,Pc=class extends ot.Scene{constructor(A,e){super();this.data=A;this.backupFog=new ot.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new ne(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new ot.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=A.postprocessing,this.init(A,e),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Ch(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Nh(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(A){let e=A.identity.join("-"),r=this.entityIdentityToEntity[e];r&&(A.uuid=r.uuid),this.entityIdentityToEntity[e]=A,this.entityByUuid[A.uuid]=A}findInstance(A){return this.entityIdentityToEntity[A.join("-")]}getWithSortKey(A){let e=this.find(A);if(e===void 0)return;let r=[],n=e;for(;n!==this;){let i=n;n=n.parent;let a=n.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(A){let e=[];for(let r of A){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>xd(r.sortKey,n.sortKey)),e.map(r=>r.entity)}nonExistOrDescendantOf(A,e){let r=this.find(A);if(r===void 0)return!0;for(;r;){if(r.uuid===e)return!0;r=r.parent}return!1}find(A){if(A===""||A===void 0)return;let e=this.entityByUuid[A];return e===void 0?this.getObjectByProperty("uuid",A):e}debugEnsureEntity(A){let e=this.find(A);if(e){if(Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(A){this.toExpandCloner.add(A)}addPendingUpdateCloner(A){this.toUpdateCloner.add(A)}markToExpandCloner(A){this.toExpandCloner.add(A),A.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(){this.toExpandCloner.forEach(A=>{A.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(A=>{A.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(A,e){if(A.path.length===0&&A.type===7){let r=A.parent===null?this:this.find(A.parent);if(r===void 0)throw new Error("unexpected");let n=this.createObject(A.id,A.data,A.children,r,A.localIndex,e);n.updateVisible(),n.resetBBoxNeedsUpdate(),Di(n)&&Gi(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n)}else if(A.path.length===0&&A.type===8){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(r),r.parent.remove(r),Gi(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Di(r)&&(r.freeBooleanPointer(),n instanceof tt&&n.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r)}else if(A.path.length===0&&A.type===9){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let i=A.parent===null?this:this.find(A.parent);if(i===void 0)throw new Error("unexpected");i.add(r),this.markNeedsRecomputeInstancesForAncessors(i),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate();let a=A.localIndex;i.children.splice(a,0,i.children.pop()),Di(r)&&(r.invalidateUpstreamBooleanData(),Gi(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof tt&&n.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(A,e,r,n){if(e.type===0&&(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),e.path.includes("overrides")&&"states"in e.props)){let{states:a,rest:l}=e.props;e={...e,props:l},this.markNeedsRecomputeInstances()}let i=this.find(A);if(i)try{Th(i,e,r,{scene:this,shared:n}),i instanceof Pe&&i.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(A){this.fog=A===!0?this.backupFog:null}init(A,e){if(this.createChildrenObjects(A.objects,this,e),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Oe(A.backgroundColor,e)),this.updateFog(A.fog,e),this.updateAmbientLight(A.environment.ambientLight,e),this.activeCamera=this.personalCamera,A.publish.playCamera!==null){let r=this.find(A.publish.playCamera);r instanceof $t&&this.switchActiveCamera(r)}this.expandInstances(e,!0),this.traverseEntity(r=>{Gi(r)&&r.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(A){A.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(A){HA.is(A)&&(A.data.type==="Component"&&this.markNeedsRecomputeInstances(),A.traverseAncestors(e=>{HA.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(A,e,r,n,i){if(A.data.type==="Transition"){let a=A.data.object;a&&a!==e.uuid&&e.find(a)&&r.forInstancesRec(d=>{d.isInstanceRoot||(d.data=ao(d.data,s=>{let c=s.events.data(i.id),u=d.goUp(n);if(u){let p=[...gs(u.identity),A.data.object].join("-"),f=this.entityIdentityToEntity[p];if(f){let m=f.uuid;c.actions.data(A.id).object=m}else{if(cr)debugger;console.warn("cannot find instance")}}}).data)})}}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(A=>{if(A instanceof Ar&&typeof A.identity=="string"&&A.data.type==="Component")return A.traverseEntity((e,r)=>{e.data.events.forEach(n=>{n.data.type==="GameControl"?e.forInstancesRec(i=>{i.isInstanceRoot||(i.data=ao(i.data,a=>{a.events.delete(n.id)}).data)}):"actions"in n.data&&n.data.actions.forEach(i=>{this.relativeizeInner(i,A,e,r,n)})})}),!0})}expandInstances(A,e){let r=new Set;this.traverseEntity(n=>{if(n instanceof Ar&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:A,pendingDeletes:r}),e||n.resetBBoxNeedsUpdate(),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),ja(n)}recomputeInstances(A){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{e instanceof Ar&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(A,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(A){A.traverseEntity(e=>{let r=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[r]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[r]),e.dispose()})}clearScene(){for(let A of this.children)lt(A)&&A.disposeRecursively();this.children.length=0}resetAfterClear(A,e){this.init(A,e)}createPersonalCamera(){let A=new $t(Pc.PERSONAL_CAMERA_ID,{...fo.defaultData,name:"Personal Camera"});return A.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(A),A}raycast(A){let e=[],r=n=>{for(let i of n.children)lt(i)&&!i.raycastLock&&i.visible&&((Di(i)||ph(i)&&this.enableHelpers&&i.objectHelper.visible)&&(A.intersectObject(i,!1,e),Ih(i,A,e)),r(i))};return r(this),e}forEachEntity(A){for(let e of this.children)lt(e)&&A(e)}traverseEntity(A){for(let e of this.children)lt(e)&&e.traverseEntity(A)}traverseObject(A){for(let e of this.children)Wn.is(e)&&e.traverseObject(A)}traverseVisibleEntity(A){for(let e of this.children)lt(e)&&e.visible&&e.traverseVisibleEntity(A)}updateFog(A,e){this.enableFog=A.enabled,this.fogUseBGColor=A.useBackgroundColor,A.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Oe(A.color,e),this.backupFog.near=A.near,this.backupFog.far=A.far}dispose(){this.clearScene()}updateAmbientLight(A,e){A.color!==void 0&&(this.ambientLight.color=Oe(A.color,e)),A.intensity!==void 0&&(this.ambientLight.intensity=A.intensity),A.groundColor!==void 0&&(this.ambientLight.groundColor=Oe(A.groundColor,e)),A.enabled!==void 0&&(this.ambientLight.visible=A.enabled)}switchActiveCamera(A){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=A,A.objectHelper.visible=!1}setBackgroundColor(A){this.bgColor=A,this.fogUseBGColor===!0&&(this.backupFog.color=A)}createChildrenObjects(A,e,r){let n=0;for(let i of A)this.createObject(i.id,i.data,i.children,e,n,r),n+=1}registerObjectCreatedInLegacy(A){this.entityByUuid[A.uuid]=A}unregisterObject(A){delete this.entityByUuid[A.uuid];for(let e of A.children)this.unregisterObject(e)}createObject(A,e,r,n,i,a){let l={scene:this,shared:a},d=Fa(A,e,l);return d&&(this.entityByUuid[A]=d,n.add(d),n.children.splice(i,0,n.children.pop()),r.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,d,a)),d.updateState(e,l),d instanceof Pe&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d)),d}getCenter(A){let e=[];for(let n=0,i=A.length;n<i;++n){let{id:a,recursive:l}=A[n],d=this.find(a),s=l?d.recursiveBBox:d.singleBBox;e.push(...s.vertices)}let r=new ot.Box3;return r.setFromPoints(e),r.getCenter(Lh),Lh}copyMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A);r?e.copy(r.matrixWorld):e.identity()}copyParentMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A)?.parent;r?e.copy(r.matrixWorld):e.identity()}traverseMaterial(A){this.traverseEntity(e=>{if(e instanceof he)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)e.material[r]instanceof je&&A(e.material[r]);else e.material instanceof je&&A(e.material)})}updateCanvasSize(A,e){this.activeCamera.setViewplaneSize(A,e);let r,n;A>=e?(r=e/A,n=1):(r=1,n=A/e),this.traverseMaterial(i=>{i.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=r,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},zi=Pc;zi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var Eh=require("three/examples/jsm/loaders/DRACOLoader.js");var Nr;function k1(){return Nr||(Nr=new Eh.DRACOLoader,Nr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Nr.decoderPending}async function H1(o){if(Nr){let t={attributeIDs:Nr.defaultAttributeIDs,attributeTypes:Nr.defaultAttributeTypes,useUniqueIDs:!1},A;try{A=await Nr.decodeGeometry(new Int8Array(o).buffer,t)}catch(e){console.error(e)}if(A)return{index:A.index?{array:A.index.array}:void 0,attributes:Object.entries(A.attributes).map(([e,r])=>({name:e,itemSize:r.itemSize,array:r.array}))}}return null}async function Mh(o,t){let[A,e]=Za(ds.deserialize(new Uint8Array(o)));Zp(A);let r=[];A.scene.objects.traverse((n,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&i.geometry.data.draco!==void 0&&r.push(i)}),r.length&&await k1();for(let n of r){let i=await H1(ae(n.geometry.data.draco));if(i){i.index&&(n.geometry.data.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:l,array:d,itemSize:s})=>{a[l]={array:d,itemSize:s,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(A),e.result().data}var W1=require("three"),q1=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Bh(o){let t;if(!!o.index)for(let A=0;A<o.index.array.length;A+=3)t=o.index.array[A],o.index.array[A]=o.index.array[A+2],o.index.array[A+2]=t}var Ui=require("three");function Dh(o){let t=new Set;return o.traverse(A=>{if(A instanceof ht)if(QA(A.material))A.material.forEach(e=>{let r=e;t.has(r)||t.add(r)});else{let e=A.material;t.has(e)||t.add(e)}}),t.forEach(A=>{if(A instanceof Array)return;let e=A.onBeforeCompile.bind(A);if(Q1(A)){Object.assign(A,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Ui.Color,specularColor:new Ui.Color});let r=0;A.onBeforeCompile=(n,i)=>{e&&e(n,i),n.uniforms=Object.assign({},Ui.ShaderLib.physical.uniforms,n.uniforms),A.getLayersOfType("transmission").forEach(a=>{if(n.uniforms.transmissionSamplerMap.value){let l=a.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value)}else r++,r<2&&(A.needsUpdate=!0)})}}else Y1(A)||(A.onBeforeCompile=(r,n)=>{e&&e(r,n),A.transparent=!1})}),o}function Q1(o){return o.getLayersOfType("transmission").length>0}function Y1(o){let t=0;return o.layers.forEach(A=>{if(A.type!=="light"&&A.type!=="fresnel"){let e=A.uniforms["f"+A.id+"_alpha"];e&&(t+=(1-t)*e.value)}}),t<1}function Gh(o){return o.traverse(t=>{if(t.type==="Camera"){let A=t;A.type=A.cameraType}}),o}function Rh(o){let t=[],A=(e,r=0)=>{let n=r>0?e+r:e;return t.includes(n)?A(e,r+1):n};return o.traverse(e=>{if(t.includes(e.name)){let r=e.name,n=A(e.name);if(e.name=n,e.isMesh){let i=e;i.material instanceof Array?i.material.forEach(a=>{a.name=a.name.replace(r,n)}):i.material.isAsset||(i.material.name=i.material.name.replace(r,n))}}t.push(e.name)}),o}var Vh=require("three/examples/jsm/utils/BufferGeometryUtils.js");function jh(o){let t=[];return o.traverse(A=>{A instanceof bn&&t.push(A)}),t.forEach(A=>{let e=A.object,n=A.children.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Bh(l),l}),i=(0,Vh.mergeBufferGeometries)(A.parameters.hideBase?n:[e instanceof he?e.geometry:[],...n]);e instanceof he&&(e.geometry=i),A.removeFromParent(),e.setFromClonerState(null,{scene:o,shared:Hm})}),o}function Fh(o){return o.traverse(t=>{t.matrixAutoUpdate=!0}),o}function zh(o){Object.values(o.shared.materials).forEach(t=>{Nc(t)}),o.scene.objects.traverse((t,A)=>{"material"in A?Nc(A.material):"materials"in A&&A.materials.forEach(e=>{Nc(e)})})}function Nc(o){if(typeof o=="string")return;let t=[];o.layers.forEach((A,e)=>{A.type==="outline"&&t.push(e)}),t.reverse().forEach(A=>{o.layers.delete(A)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Uh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",za=class extends Ua.Loader{load(t,A,e,r=console.error){let n=new Ua.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Uh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Uh),n.load(t,async i=>{try{if(typeof i=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(i);A(a)}catch(a){r(a)}},e,r)}async parse(t){let A=await Mh(t,zh);eh(A)&&await Um();let e=new Jr(A.shared);Object.values(e.getMaterials()).forEach(i=>Object.assign(i,{isAsset:!0}));let r=new zi(A.scene,e);r.remove(r.personalCamera),A.scene.environment.ambientLight.enabled||r.remove(r.ambientLight);let n=A.scene.publish.playCamera;if(n){let i=r.find(n);i&&uh(i)&&Object.assign(i,{makeDefault:!0})}return r=jh(r),r=Dh(r),r=Gh(r),r=Rh(r),r=Fh(r),r}};
|
|
1338
|
+
`)>=0&&(t-=n),e===3?A*.5-t*.5:e===2?A-t:0}getLineInitialOffsetY(t,A,e,r,n){let i=A*t,a=Math.abs(this.ascender-this.descender)*r,l=t-a,d=-this.ascender*r-l/2;return n===3?-(e-i-d):n===2?-(e*.5-i*.5-d):d}createPath(t,A,e,r,n){let i=t.getPath(e,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new wa,l=(t.advanceWidth??1)*A;if(t)for(let d of i.commands){let s=a.currentPath?.currentPoint;if(!(s&&d.type!=="Z"&&s.x===d.x&&-s.y===d.y))switch(d.type){case"M":a.moveTo(d.x,-d.y);break;case"L":a.lineTo(d.x,-d.y);break;case"Q":a.quadraticCurveTo(d.x1,-d.y1,d.x,-d.y);break;case"C":a.bezierCurveTo(d.x1,-d.y1,d.x2,-d.y2,d.x,-d.y);break}}return a.subPaths.forEach(d=>{let s=x1(d.curves);s!==void 0&&d.currentPoint.distanceTo(s)>0&&d.lineTo(s.x,s.y)}),{offsetX:l+n.fontSize*n.letterSpacing,path:a}}getCharWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}getTextWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}computeSpaceWidthForLine(t,A,e){let r=this.getCharWidth(" ",e),n=t[A];if(n){let i=this.countSpaces(n.trimEnd());if(e.horizontalAlign===4&&A<t.length-1&&i){let a=e.width,l=this.getTextWidth(n,e);return(a-(l-i*r))/i}}return r}countSpaces(t){return(t.match(/ /g)||[]).length}};function x1(o){if(o.length){let t=o[0];if(t instanceof fn.LineCurve)return t.v1;if(t instanceof fn.CubicBezierCurve||t instanceof fn.QuadraticBezierCurve)return t.v0}}var gc=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,A){let e=this.objects.get(t);return e===void 0?(e=this.createObject(t,A),this.objects.set(t,e)):e.isShared=!0,e}mutateIfUnique(t,A){let e=this.objects.get(t);if(e&&e.isShared!==!0)return this.objects.delete(t),this.objects.set(A,e),e}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,A){let e=this.objects.get(t);A===e?this.unreachable.delete(t):cr&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Ii=class extends gc{constructor(A){super();this.flatShading=A}disposeObject(A){A.dispose()}createObject(A,e){let r=Wr(A,e,this.flatShading);return r.computeBoundingSphere(),r}};var km={find(o){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(o){},addPendingUpdateCloner(o){}};var xc=class extends ga{constructor(A){super();this.shared=A}create(A){return new un(A,this.shared)}},Jr=class{constructor(t,A={}){this.geometryCache=new Ii(!0);this.geometryCache2=new Ii(!1);this.imageHolderCache=new xc(this);this.thisContext={scene:km,shared:this};this.deletedMaterial=new Kr(Ee.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new $e(Qs.emptyImage,this);this.deletedVideo=new $e(co.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(A.images)for(let[e,r]of Object.entries(A.images))this.addImage(e,r);if(A.videos)for(let[e,r]of Object.entries(A.videos))this.addVideo(e,r);if(A.audios)for(let[e,r]of Object.entries(A.audios))this.addAudio(e,r.data);this.reset(t)}setRequestRender(t){this._requestRender=t}reset(t){for(let[A,e]of Object.entries(t.images))this.addImage(A,e);for(let[A,e]of Object.entries(t.videos))this.addVideo(A,e);for(let[A,e]of Object.entries(t.colors))this.addColor(A,e);for(let[A,e]of Object.entries(t.materials))this.addMaterial(A,new Kr(e,this.thisContext));for(let[A,e]of Object.entries(t.audios))this.addAudio(A,e.data);for(let[A,e]of Object.entries(t.fonts))this.addFont(A,e);this.penumbraSize=t.penumbraSize}addMaterial(t,A){A.uuid=t,this.materials[t]=A}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let A=this.materials[t];return A}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new pn(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,A){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(A.data),!0):(this.images[t]=new $e(A,this),!1)}deleteImage(t){let A=this.images[t];A&&(A.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,A){return this.videos[t]?(this.videos[t].updateSrc(A.data),!0):(this.videos[t]=new $e(A,this),!1)}deleteVideo(t){let A=this.videos[t];A&&(A.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,A){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in A?this.colors[t].setRGBA(A.r,A.g,A.b,A.a):this.colors[t].setRGBA(A.r,A.g,A.b,1),!0):("a"in A?this.colors[t]=new Sr(A.r,A.g,A.b,A.a):this.colors[t]=new Sr(A.r,A.g,A.b,1),!1)}updateColor(t,A){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let e=this.colors[t];return this.colors[t].r=A.r??e.r,this.colors[t].g=A.g??e.g,this.colors[t].b=A.b??e.b,this.colors[t].a=A.a??e.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let A;if(typeof t=="string"){let e=this.getColor(t);e?A=e:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),A=new ne(0,0,0,0))}else return"a"in t?new ne(t.r,t.g,t.b,t.a):new ne(t.r,t.g,t.b,1);return A}addAudio(t,A){this.audios[t]=A}getAudio(t){let A=this.audios[t];if(A instanceof Zr)return A;{let e=new Zr({src:A});return this.audios[t]=e,e}}deleteAudio(t){let A=this.audios[t];A&&(A instanceof Zr&&A.dispose(),delete this.audios[t])}addFont(t,A){this.fonts[t]=new Ta(A),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(A=>this.deleteMaterial(A)),this._requestRender=void 0,Object.values(this.audios).forEach(A=>{A instanceof Zr&&A.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},Hm=new Jr(xs.emptyData());var ht=class extends he{updateByPatchedOp(A,e,r){if(super.updateByPatchedOp(A,e,r),Fc(A.path,["materials"])!==null&&A.type===0&&Array.isArray(this.material))for(let[n,i]of Object.entries(A.props)){let a=r.shared.material(i);this.material[Number(n)]=a}else if(vt(A.path,["material"])&&this.material instanceof je)"material"in e&&typeof e.material!="string"&&this.material.updateByOp(fe.drop(A,1),e.material,r);else if(vt(A.path,["materials","*"])&&Array.isArray(this.material)){let n=A.path[1];if("materials"in e&&n<this.material.length){let i=e.materials[n];typeof i!="string"&&this.material[n].updateByOp(fe.drop(A,2),i,r)}}}updateState(A,e){super.updateState(A,e),A.castShadow!==void 0&&(this.castShadow=A.castShadow),A.receiveShadow!==void 0&&(this.receiveShadow=A.receiveShadow);let r=this.dataPatched;if(A.geometry?.type!=="NonParametricGeometry"&&"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene?.markNeedsUpdateRendererDirty()),A.geometry?.type==="NonParametricGeometry"&&("materials"in A&&A.materials!==void 0?(this.disposeMaterial(),this.material=A.materials.map(n=>e.shared.material(n).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene?.markNeedsUpdateRendererDirty()):"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene?.markNeedsUpdateRendererDirty())),A.flatShading!==void 0||A.wireframe!==void 0||A.side!==void 0)if(Array.isArray(this.material))for(let n=0;n<this.material.length;n++)this.material[n]=this.material[n].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe)}disposeMaterial(){this.material&&gs(this.material).forEach(A=>{A instanceof je&&(A instanceof Kr||A.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Wm=require("three");var Pe=class extends ht{constructor(A,e,r){super(A,e);this.data=e;this.localGeometry=void 0}chooseGeoemtryCache(A){return A.geometryCache}markGeometryAsReachable(A){this.geometryCreateDeleyed instanceof Wm.BufferGeometry&&this.chooseGeoemtryCache(A).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Jr){let A=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(A);this.geometryCreateDeleyed=e.get(this.dataPatched.geometry,A)}return this.geometryCreateDeleyed}set geometry(A){this.localGeometry=A}get is2DAndNoDepth(){let A=this.dataPatched.geometry;return Dn.is2DParametricMesh(A.type)&&A.depth===0}get is2DType(){return Dn.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),vt(A.path,["geometry"])&&this.updateByPatchedOpGeometry(fe.drop(A,1),e.geometry,r)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(A,e){this.invalidateDownstreamBooleanData();let r=this.data.geometry.type;if(r==="NonParametricGeometry"||r==="SubdivGeometry"){let n=A;if(this.localGeometry===void 0){let s={...this.data.geometry,...n};this.localGeometry=Wr(s,e,this.data.flatShading)}let i,a,l;n.scaleBaked?[i,a,l]=n.scaleBaked:{width:i,height:a,depth:l}=n;let d=this.localGeometry.userData;d.sxPrev!==void 0&&ei(this.localGeometry.attributes,i/d.sxPrev,a/d.syPrev,l/d.szPrev),d.sxPrev=i,d.syPrev=a,d.szPrev=l}else{let n={...this.data.geometry,...A};this.localGeometry?.dispose(),this.localGeometry=Wr(n,e,this.data.flatShading)}}refreshAttachedCloners(A){for(let e of this.attachedSurfaceCloners)A.scene.addPendingUpdateCloner(e.object)}createGeometryDelayed(A){this.geometryCreateDeleyed=A.shared,this.refreshAttachedCloners(A)}updateByPatchedOpGeometry(A,e,r){let n=!1;A.type===0&&A.path.length===0&&Fn(["scaleBaked"],Object.keys(A.props))&&this.geometryCreateDeleyed instanceof JA&&this.chooseGeoemtryCache(r.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,A.props.scaleBaked),this.refreshAttachedCloners(r)),n||(r.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(r)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(A,e){this.createGeometryDelayed(e)}updateState(A,e){A.geometry!==void 0&&this.updateGeometryOnStateUpdate(A.geometry,e),super.updateState(A,e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;this.is2DType?A.set(0,0,r.depth*.5):A.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}};function v1(o){if(o.geometry.attributes.extrudeNormal||!o.geometry.attributes.position||!o.geometry.attributes.normal)return;let t=new Map,A=o.geometry.attributes.position.array,e=o.geometry.attributes.normal.array,r=new Float32Array(A.length);for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=new Ye.Vector3(e[n],e[n+1],e[n+2]);t.has(i)?t.get(i)?.normals.push(a):t.set(i,{normals:[a],result:new Ye.Vector3})}t.forEach((n,i)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=t.get(i)?.result;a&&(r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z)}o.geometry.setAttribute("extrudeNormal",new Ye.Float32BufferAttribute(r,3))}function b1(o){if(o.geometry.attributes.extrudeNormals||!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=new Ye.Vector3;for(let r=0;r<t.length;r+=3)e.set(t[r],t[r+1],t[r+2]).normalize(),A[r]=e.x,A[r+1]=e.y,A[r+2]=e.z;o.geometry.setAttribute("extrudeNormal",new Ye.Float32BufferAttribute(A,3))}function mn(o){if(Array.isArray(o.material)){for(let t of o.material)if(t.getLayersOfType("outline").length===0)return}else if(!(o.material instanceof je)||o.material.getLayersOfType("outline").length===0)return;o instanceof Pe&&o.is2DAndNoDepth?b1(o):v1(o)}function hn(o){if(!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=parseInt(o.uuid.replace(/\D/g,"")),r=[Ye.MathUtils.seededRandom(e),Ye.MathUtils.seededRandom(e+1e4),Ye.MathUtils.seededRandom(e+2e4)];for(let n=0;n<t.length;n++)A[n]=r[n%3];o.geometry.setAttribute("randomColor",new Ye.BufferAttribute(A,3))}var S1;$o.then(o=>{S1=o});var Rt=new Jt.Box3,Li=new Jt.Vector3;var _r=class extends Pe{constructor(A,e,r){super(A,e,r);this.data=e;this.hiddenMatrixOld=new Jt.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(A){return this.dataPatched.flatShading?A.geometryCache:A.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;A.copy(this.originalGeometryNew.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}createGeometryByControls(A){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:r,subdividedGeometry:n,subdivPointer:i}=JA.build(A,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=i,r!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=r),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,mn(this),hn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(A,e){if(super.updateState(A,e),A.flatShading!==void 0){let r=this.material;this.material=r.getFlavor(!1,r.side,r.wireframe),this.smoothShading=!A.flatShading,this.createGeometryDelayed(e)}}updateMesh(A=!1){JA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&JA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=JA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=JA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(A,e){let r=this.localGeometry;this.localGeometry=this.originalGeometryNew,he.prototype.raycast.call(this,A,e),this.localGeometry=r}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new Jt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let e=A.attributes.position,r=A.boundingSphere.center;Rt.setFromBufferAttribute(e),Rt.getCenter(r),A.boundingSphere.radius=r.distanceTo(Rt.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Rt.getSize(Li),this.hasNonUniformScale&&Li.divide(this.scale);let n={width:Li.x,height:Li.y,depth:Li.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(A){let e=this.originalGeometry;Rt.min.set(A[0],A[2],A[4]),Rt.max.set(A[1],A[3],A[5]),this.hasNonUniformScale&&(Rt.min.applyMatrix4(this.shearScaleInv),Rt.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new Jt.Sphere);let r=e.boundingSphere.center;Rt.getCenter(r),e.boundingSphere.radius=r.distanceTo(Rt.max)}freeSubdivPointer(){this.subdivPointer&&(JA.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(A,e,r){super.updateByPatchedOpGeometry(A,e,r),this.localGeometry&&this.createGeometryByControls(e)}};var Vt=require("three"),qm=-1,w1=1,Qm={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Ym={polygon_center:0,edge:1,vertex:2},Ei=(o,t)=>(A,e)=>!t||A===0||o===0?0:o*e/100,mA=(o,t)=>{let A=Math.abs(t),e=A*-1;return(o-qm)*(A-e)/(w1-qm)+e};function Xm(o){let t=[],A={};for(var e=0,r=o.length;e<r;e++){var n=JSON.stringify(o[e].pos.map(i=>Math.round(i*1e4)/1e4));A[n]||(t.push(o[e]),A[n]=!0)}return t}var T1=new Vt.Vector3,Oa=new Vt.Vector3,O1=new Vt.Vector3,P1=new Vt.Vector3;function yn(o,t){let A=O1.fromArray(o),e=P1.fromArray(t);Oa.copy(e).sub(A);let r=Oa.length();return Oa.normalize().multiplyScalar(r*.5),T1.copy(A).add(Oa).toArray()}var At=new Vt.Triangle,Pa=new Vt.Vector3,Na=new Vt.Vector3,$r=new Vt.Vector3;function Km(o){let t=[];for(let A=0;A<=o.index.count;A++)if(Pa.fromArray(o.index.array,A*3),At.setFromAttributeAndIndices(o.attributes.position,Pa.x,Pa.y,Pa.z),At.getNormal(Na),At.getMidpoint($r),!(isNaN($r.x)||isNaN($r.y)||isNaN($r.z))){let{a:e,b:r,c:n}=At,i=e.toArray(),a=r.toArray(),l=n.toArray(),d=e.distanceTo(r),s=r.distanceTo(n),c=n.distanceTo(e),u=yn(i,a),p=yn(a,l),f=yn(l,i),m=[d,s,c],h=Math.max(...m),y=m.filter(v=>Math.round(v)===Math.round(h)).length>1,x=[],S=At.getMidpoint($r).toArray();h===d&&!y&&(x=[p,f,f],S=u),h===s&&!y&&(x=[u,f,f],S=p),h===c&&!y&&(x=[u,p,p],S=f),y&&(x=[u,p,f]),t.push({vertices:[i,a,l],faceCenters:x,midpoint:S,norm:At.getNormal(Na).toArray()})}return t}function Zm(o){let t=[],{position:A}=o.attributes;for(let e=0;e<A.count;e++){At.setFromAttributeAndIndices(A,e*3,e*3+1,e*3+2),At.getNormal(Na),At.getMidpoint($r);let r=At.a.toArray(),n=At.b.toArray(),i=At.c.toArray();t.push({vertices:[r,n,i],faceCenters:[yn(r,n),yn(n,i),yn(i,r)],midpoint:$r.toArray(),norm:Na.toArray()})}return t}var N1=4,C1=.5,vc=o=>.5*(1-Math.cos(o*Math.PI)),bc=class{constructor(){this.perlin=new Array(4095+1)}noise(t,A=0,e=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),A<0&&(A=-A),e<0&&(e=-e);let r=Math.floor(t),n=Math.floor(A),i=Math.floor(e),a=t-r,l=A-n,d=e-i,s,c,u=0,p=.5,f,m,h;for(let y=0;y<N1;y++){let x=r+(n<<4)+(i<<8);s=vc(a),c=vc(l),f=this.perlin[x&4095],f+=s*(this.perlin[x+1&4095]-f),m=this.perlin[x+16&4095],m+=s*(this.perlin[x+16+1&4095]-m),f+=c*(m-f),x+=256,m=this.perlin[x&4095],m+=s*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=s*(this.perlin[x+16+1&4095]-h),m+=c*(h-m),f+=vc(d)*(m-f),u+=f*p,p*=C1,r<<=1,a*=2,n<<=1,l*=2,i<<=1,d*=2,a>=1&&(r++,a--),l>=1&&(n++,l--),d>=1&&(i++,d--)}return u}noiseSeed(t){let A=(()=>{let i,a;return{setSeed(l){a=i=(l??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();A.setSeed(t),this.perlin=new Array(4095+1);for(let e=0;e<4095+1;e++)this.perlin[e]=A.rand()}},Jm=bc;var xn=require("three");var _m=new xn.Vector3,$m=new xn.Matrix4,Ah=new xn.Ray;function eh(o){let t=!1;return o.scene.objects.traverse((A,e)=>{e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(t=!0)}),t}var gn=class extends Pe{constructor(A,e,r){super(A,e,r);this.data=e}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let A=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,A.geometry.height,this.fontScale,A.geometry.verticalAlign)??0}get fontScale(){let A=this.dataPatched;return this.font?A.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let A=this.dataPatched;return A.geometry.fontSize*A.geometry.lineHeight}raycast(A,e){let{matrixWorld:r}=this;if($m.copy(r).invert(),Ah.copy(A.ray).applyMatrix4($m),Ah.intersectBox(this.singleBBox,_m)){let n=_m.applyMatrix4(r),i=A.ray.origin.distanceTo(n);e.push({distance:i,point:n.clone(),object:this})}}};var Ne=1e-4,jt,oh,nh,ih,th=new IA.Vector3,rh=new IA.Vector3;$o.then(o=>{jt=o,oh=[jt.get_face_center,jt.get_edge_midpoint,jt.get_vertex_position],nh=[jt.get_face_normal,jt.get_edge_normal,jt.get_vertex_normal],ih=[jt.face_count,jt.edge_count,jt.vertex_count]});var I1=new IA.Matrix4,L1=new IA.Matrix4,Tr=new IA.Vector3,Ao=new IA.Vector3,Mi=new IA.Vector3,Sc=new IA.Vector3,E1=new IA.Vector3,M1=new IA.Vector3;var _t=new Jm,bn=class extends zo(IA.Object3D){constructor(A,e){super();this.parameters=e;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=A}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(A){if(this.parent===null)this.updateState(this.parameters,A);else for(let e of this.children)e instanceof Xt&&e.expand()}invalidateTransform(A){this.matrixWorldNeedsUpdate=!0,this.traverse(e=>{e instanceof Xt&&e.object===A&&(e.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let A of this.children)A.updateMatrix(),A.hasNonUniformScale&&(A.updateMatrixWorld(),A.updateMatrixWorldSVD())}_updateCount(A){let e;if(A!==void 0?e=A:e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(e=0),this.parameters.type==="toObject"&&this.objectForSample){for(let n=0,i=this.children.length;n<i;++n)this.remove(this.children[0]);let r=this.children;if(r.length===e)return;if(r.length<e)for(let n=0,i=e-r.length;n<i;++n){let a=new Xt(this.object);a.expand(),this.add(a)}else for(let n=0,i=r.length-e;n<i;++n)this.remove(r[n])}else{if(this.children.length===e)return;if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let i=new Xt(this.object);i.expand(),this.add(i)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}}_updateRadial(A){let e=A.radial,r=e.start*IA.MathUtils.DEG2RAD,n=e.end*IA.MathUtils.DEG2RAD,i=r-n,a=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),l;switch(e.axis){case"z":l=new IA.Vector3(0,0,1);break;case"y":l=new IA.Vector3(0,1,0);break;default:case"x":l=new IA.Vector3(1,0,0);break}let d=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,s=d.noiseType==="perlin";_t.noiseSeed(d.seed);let c=Ys((0,vn.default)(d.seed)),u=Ei(d.strength,this.parameters.randomness);for(let[p,f]of this.children.entries()){let m=p*(d.freqScale/10)+d.movement,h=s?_t.noise(m):c(m,m);f.scale.x=e.scale[0]+u(p,mA(h,d.scale[0]))||Ne,f.scale.y=e.scale[1]+u(p,mA(h,d.scale[1]))||Ne,f.scale.z=e.scale[2]+u(p,mA(h,d.scale[2]))||Ne,f.position.setScalar(0);let y=i/A.count*p-r;switch(e.axis){case"x":f.rotation.set(0,y,0);break;case"y":f.rotation.set(0,0,y);break;case"z":f.rotation.set(y,0,0);break}f.translateOnAxis(l,e.radius),f.position.x+=e.position[0]+u(p,mA(h,d.position[0])),f.position.y+=e.position[1]+u(p,mA(h,d.position[1])),f.position.z+=e.position[2]+u(p,mA(h,d.position[2]));let x=u(p,mA(h,d.rotation[0])),S=u(p,mA(h,d.rotation[1])),v=u(p,mA(h,d.rotation[2]));e.alignment===!0?(f.rotation.x+=a.x+x,f.rotation.y+=a.y+S,f.rotation.z+=a.z+v):f.rotation.set(a.x+x,a.y+S,a.z+v)}}_updateLinear(A){if(A.type!=="linear")throw new Error;let e=A.linear,r=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";_t.noiseSeed(n.seed);let a=Ys((0,vn.default)(n.seed)),l=Ei(n.strength,this.parameters.randomness);for(let[d,s]of this.children.entries()){let c=d*(n.freqScale/10)+n.movement,u=i?_t.noise(c):a(c,c),p=l(d,mA(u,n.rotation[0])),f=l(d,mA(u,n.rotation[1])),m=l(d,mA(u,n.rotation[2]));s.scale.x=1+(e.scale[0]-1)*d+l(d,mA(u,n.scale[0]))||Ne,s.scale.y=1+(e.scale[1]-1)*d+l(d,mA(u,n.scale[1]))||Ne,s.scale.z=1+(e.scale[2]-1)*d+l(d,mA(u,n.scale[2]))||Ne,s.rotation.x=r.x*d+p,s.rotation.y=r.y*d+f,s.rotation.z=r.z*d+m,s.position.x=e.position[0]*d+l(d,mA(u,n.position[0])),s.position.y=e.position[1]*d+l(d,mA(u,n.position[1])),s.position.z=e.position[2]*d+l(d,mA(u,n.position[2]))}}_updateGrid(A){let e=0,r=A.grid,n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=Ei(n.strength,this.parameters.randomness),a=n.noiseType==="perlin";_t.noiseSeed(n.seed);let l=Af((0,vn.default)(n.seed));if(r.useCenter===!0){let d={x:r.count[0]%2===0?2:1,y:r.count[1]%2===0?2:1,z:r.count[2]%2===0?2:1},s=new IA.Vector3(r.size[0]*(r.count[0]-d.x)*.5,r.size[1]*(r.count[1]-d.y)*.5,r.size[2]*(r.count[2]-d.z)*.5);for(let c=0;c<r.count[0];c++)for(let u=0;u<r.count[1];u++)for(let p=0;p<r.count[2];p++){let f=[(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement],m=a?_t.noise(...f):l(...f),h=this.children[e++];h.scale.x=1+i(e,mA(m,n.scale[0]))||Ne,h.scale.y=1+i(e,mA(m,n.scale[1]))||Ne,h.scale.z=1+i(e,mA(m,n.scale[2]))||Ne;let y=i(e,mA(m,n.rotation[0])),x=i(e,mA(m,n.rotation[1])),S=i(e,mA(m,n.rotation[2]));h.rotation.set(y,x,S),h.position.x=r.size[0]*c-s.x+i(e,mA(m,n.position[0])),h.position.y=r.size[1]*u-s.y+i(e,mA(m,n.position[1])),h.position.z=r.size[2]*p-s.z+i(e,mA(m,n.position[2]))}}else for(let d=0;d<r.count[0];d++)for(let s=0;s<r.count[1];s++)for(let c=0;c<r.count[2];c++){let u=[(d+1)*(n.freqScale/10)+n.movement,(s+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement],p=a?_t.noise(...u):l(...u),f=this.children[e++];f.scale.x=1+i(e,mA(p,n.scale[0]))||Ne,f.scale.y=1+i(e,mA(p,n.scale[1]))||Ne,f.scale.z=1+i(e,mA(p,n.scale[2]))||Ne;let m=i(e,mA(p,n.rotation[0])),h=i(e,mA(p,n.rotation[1])),y=i(e,mA(p,n.rotation[2]));f.rotation.set(m,h,y),f.position.x=r.size[0]*d+i(e,mA(p,n.position[0])),f.position.y=-r.size[1]*s+i(e,mA(p,n.position[1])),f.position.z=-r.size[2]*c+i(e,mA(p,n.position[2]))}}_updateToObject(A){if(A.type!=="toObject")throw new Error;let{toObject:e}=A,r=new IA.Euler(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??Ot.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";_t.noiseSeed(n.seed);let a=Ys((0,vn.default)(n.seed)),l=Ei(n.strength,this.parameters.randomness);if(!e.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof gn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;let d=this.getSubdivData(),s=[],c=y=>{let x=y.length,S=y.map(P=>P[0]).reduce((P,w)=>P+w,0),v=y.map(P=>P[1]).reduce((P,w)=>P+w,0),b=y.map(P=>P[2]).reduce((P,w)=>P+w,0);return[S/x,v/x,b/x]},u=y=>Math.round(y*1e6)/1e6;d.forEach(y=>{let x=d.filter(S=>u(y.pos[0])===u(S.pos[0])&&u(y.pos[1])===u(S.pos[1])&&u(y.pos[2])===u(S.pos[2]));x.length>1?s.push({pos:y.pos,norm:c(x.map(S=>S.norm))}):s.push(y)});let p=Xm(s);if(d.length>0){let y=Math.round(p.length*e.count/100);this._updateCount(y)}this.objectForSample.updateMatrixWorld();let f=new Xs(this.objectForSample).build(),m=Qm[e.axis],h=this.children;f.setRandomGenerator((0,vn.default)(this.object.uuid+e.seed));for(let[y,x]of h.entries()){let S=y*(n.freqScale/10)+n.movement,v=i?_t.noise(S):a(S,S),b=l(y,mA(v,n.rotation[0])),P=l(y,mA(v,n.rotation[1])),w=l(y,mA(v,n.rotation[2]));e.spreadType==="random"?f.sample(Mi,Sc):(p.length&&(Mi.fromArray(p[y].pos),Sc.fromArray(p[y].norm)),this.objectForSample instanceof _r&&Mi.applyMatrix4(I1.copy(this.objectForSample.matrixWorld).invert())),Mi.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(Mi),Tr.fromArray(m);let g=e.align==="normal"?Sc:this.object.getWorldDirection(M1),N=Ao.fromArray(e.position);Ao.x+=Ao.x+l(y,mA(v,n.position[0])),Ao.y+=Ao.y+l(y,mA(v,n.position[1])),Ao.z+=Ao.z+l(y,mA(v,n.position[2]));let O=Math.acos(g.dot(Tr)),C=E1.crossVectors(Tr,g).normalize(),T=L1.makeRotationAxis(C,O),L=g.clone().cross(this.object.up).normalize(),M=L.clone().cross(g).normalize(),U=new IA.Matrix4().makeBasis(L,g,M),X=new IA.Vector3(Tr.y,Tr.z,Tr.x).normalize(),eA=X.clone().cross(Tr).normalize(),nA=new IA.Matrix4().makeBasis(X,Tr,eA).invert(),k=new IA.Matrix4().multiplyMatrices(U,nA);x.rotation.setFromRotationMatrix(k),N.applyMatrix4(T),x.position.add(N),x.rotation.x=x.rotation.x+r.x+b,x.rotation.y=x.rotation.y+r.y+P,x.rotation.z=x.rotation.z+r.z+w,x.scale.setScalar(1),x.scale.x=x.scale.x+e.scale[0]+l(y,mA(v,n.scale[0]))||Ne,x.scale.y=x.scale.y+e.scale[1]+l(y,mA(v,n.scale[1]))||Ne,x.scale.z=x.scale.z+e.scale[2]+l(y,mA(v,n.scale[2]))||Ne,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let A=this.parameters.toObject.spreadType;if(A==="random")return[];if(this.objectForSample instanceof _r){let e=this.objectForSample,r=Ym[A],n=ih[r],i=oh[r],a=nh[r],l=[],d=n(e.subdivPointerNew);for(let s=0;s<=d-1;s++){let c=i(e.subdivPointerNew,s),u=a(e.subdivPointerNew,s);th.fromArray(c).applyMatrix4(e.matrixWorld),rh.fromArray(u),l.push({pos:th.toArray(),norm:rh.toArray()})}return l}else return(this.objectForSample.geometry.index?Km(this.objectForSample.geometry):Zm(this.objectForSample.geometry)).map((r,n)=>A==="polygon_center"?{pos:r.midpoint,norm:r.norm}:A==="vertex"?[{pos:r.vertices[0],norm:r.norm},{pos:r.vertices[1],norm:r.norm},{pos:r.vertices[2],norm:r.norm}]:A==="edge"?[{pos:r.faceCenters[0],norm:r.norm},{pos:r.faceCenters[1],norm:r.norm},{pos:r.faceCenters[2],norm:r.norm}]:[]).flat()}updateState(A,e){if(this.parameters=Vr(A),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=e.find(this.parameters.toObject.object);r instanceof he?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new IA.Matrix4,this.hiddenMatrix=new IA.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var ot=require("three");var WA=require("three");var xe=require("three");var sh=require("three"),Ft=o=>{var t;return t=class extends o{},t.geometryHelper=new sh.BoxGeometry(30,30,30),t};var be=require("three"),Ca=new be.Ray,wc=new be.Sphere,ah=new be.Matrix4,zt=(o,t,A,e,r=!1)=>{let n=t,i=o.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),wc.copy(n.boundingSphere),wc.applyMatrix4(i),A.ray.intersectsSphere(wc)===!1||(ah.copy(i).invert(),Ca.copy(A.ray).applyMatrix4(ah),n.boundingBox!==null&&Ca.intersectsBox(n.boundingBox)===!1))return;let a,l,d,s,c=n.index,u=n.attributes.position,p=n.drawRange,f,m;if(r===!1){let y=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(f=y,m=x;f<m;f+=3)if(l=c.getX(f),d=c.getX(f+1),s=c.getX(f+2),a=h(o,A,Ca,u,l,d,s),a){a.faceIndex=Math.floor(f/3),e.push(a);return}}else{let x=n.attributes.position,S=new be.Vector3,v=new be.Vector3,b=new be.Vector3,P=new be.Vector3,w=2,N=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=N*N,C=Math.max(0,p.start),T=Math.min(x.count,p.start+p.count);for(let L=C,M=T-1;L<M;L+=w){if(S.fromBufferAttribute(x,L),v.fromBufferAttribute(x,L+1),Ca.distanceSqToSegment(S,v,P,b)>O)continue;P.applyMatrix4(o.matrixWorld);let X=A.ray.origin.distanceTo(P);X<A.near||X>A.far||e.push({distance:X,point:b.clone().applyMatrix4(o.matrixWorld),object:o})}}function h(y,x,S,v,b,P,w){let g=new be.Vector3,N=new be.Vector3,O=new be.Vector3,C=new be.Vector3,T=new be.Vector3;if(g.fromBufferAttribute(v,b),N.fromBufferAttribute(v,P),O.fromBufferAttribute(v,w),S.intersectTriangle(g,N,O,!1,C)===null)return null;T.copy(C),T.applyMatrix4(y.matrixWorld);let M=x.ray.origin.distanceTo(T);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:T.clone(),object:y}}};var Ia=new xe.Vector3,et=new xe.Camera,Tc=class extends xe.LineSegments{constructor(A){let e=new xe.BufferGeometry,r=new xe.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},l=new xe.Color(15711266),d=new xe.Color(15711266),s=new xe.Color(2857471);c("n1","n2",l),c("n2","n4",l),c("n4","n3",l),c("n3","n1",l),c("f1","f2",l),c("f2","f4",l),c("f4","f3",l),c("f3","f1",l),c("n1","f1",l),c("n2","f2",l),c("n3","f3",l),c("n4","f4",l),c("p","n1",d),c("p","n2",d),c("p","n3",d),c("p","n4",d),c("u1","u2",s),c("u2","u3",s),c("u3","u1",s);function c(p,f,m){u(p,m),u(f,m)}function u(p,f){n.push(0,0,0),i.push(f.r,f.g,f.b),a[p]===void 0&&(a[p]=[]),a[p].push(n.length/3-1)}e.setAttribute("position",new xe.Float32BufferAttribute(n,3)),e.setAttribute("color",new xe.Float32BufferAttribute(i,3));super(e,r);this.type="CameraHelper",this.camera=A,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let A=this.geometry,e=this.pointMap,r=!0;et.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,i=1,a=r?.8:1e-4;yt("n1",e,A,et,-n,-i,a),yt("n2",e,A,et,n,-i,a),yt("n3",e,A,et,-n,i,a),yt("n4",e,A,et,n,i,a);let l=a;yt("f1",e,A,et,-n,-i,l),yt("f2",e,A,et,n,-i,l),yt("f3",e,A,et,-n,i,l),yt("f4",e,A,et,n,i,l);let d=l,s=.5;yt("u1",e,A,et,n*.7*s,i*1.1,d),yt("u2",e,A,et,-n*.7*s,i*1.1,d),yt("u3",e,A,et,0,i*(1.1+.9*s),d),A.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yt(o,t,A,e,r,n,i){Ia.set(r,n,i).unproject(e);let a=t[o];if(a!==void 0){let l=A.getAttribute("position");for(let d=0,s=a.length;d<s;d++)l.setXYZ(a[d],Ia.x,Ia.y,Ia.z)}}var La=class extends Ft(Tc){constructor(A){super(A);this.object=A;this.object=A,this.name=`CombinedCameraHelper: ${A.uuid}`}updateMatrixWorld(A){super.updateMatrixWorld(A),this.updateTarget()}updateTarget(){let A=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(A)}raycast(A,e){zt(this.object,this.geometry,A,e,!0)}};var Bi=require("three");var Ea;(t=>t.is=A=>"objectHelper"in A)(Ea||(Ea={}));var Or=(o,t)=>class extends Zs(o){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(r,n){this.objectHelper.raycast(r,n)}showGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof Bi.Box3Helper&&(n.visible=!0)}}updateEntityBoxSize(r,n){this.objectHelper.visible&&this.geometryHelper instanceof Bi.BoxGeometry?(r.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(r,n)}hideGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof Bi.Box3Helper&&(n.visible=!1)}}};var Sn=new WA.Vector3,Oc=new WA.Vector3,$t=class extends Or(WA.Camera,La){constructor(A="",e={...fo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Er.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(A,e),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let r=this.width,n=this.height;this.orthoCamera=new WA.OrthographicCamera(r*-.5,r*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new WA.PerspectiveCamera(45,r/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(A){this.perspCamera.fov=A}get fov(){return this.perspCamera.fov}setNear(A,e){A==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(A,e){e>=0&&(A==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(A){A==="PerspectiveCamera"?this.toPerspective():A==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(A){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=A:this.orthoCamera.near=A}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(A){A>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=A:this.orthoCamera.zoom=A)}lookAt(A){super.lookAt(A),this.getWorldPosition(Sn),this.targetOffset=Sn.distanceTo(A)}getTarget(A=new WA.Vector3){return this.getWorldDirection(Oc),this.getWorldPosition(Sn),Oc.multiplyScalar(this.targetOffset),A.copy(Sn).add(Oc),A}getDistanceToTarget(){let A=this.getTarget();return this.getWorldPosition(Sn),Sn.distanceTo(A)}updateUp(){let A=this.getWorldQuaternion(new WA.Quaternion),e=new WA.Vector3(0,0,1).applyQuaternion(A),r=new WA.Vector3().copy(WA.Object3D.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(A);let n=new WA.Vector3().copy(WA.Object3D.DefaultUp).projectOnPlane(e),i=new WA.Vector3().crossVectors(n,r).dot(e)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*i}updateTransformState(A){let e=super.updateTransformState(A);return A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateUp(),e}getViewFrontToObject(A){let e=A.getWorldPosition(new WA.Vector3),n=A.getWorldDirection(new WA.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().add(n),target:e}}getViewToObject(A){let e=A.getWorldPosition(new WA.Vector3),n=this.getWorldDirection(new WA.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}setViewplaneSize(A,e){this.left=-A*.5,this.right=A*.5,this.top=e*.5,this.bottom=-e*.5,this.aspect=A/e,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(A){this.perspCamera.setFocalLength(A),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(A,e,r,n,i,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(A,e,r,n,i,a):this.orthoCamera.setViewOffset(A,e,r,n,i,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,e){super.updateWorldMatrix(A,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(A,e){return super.copy(A,e),this.orthoCamera.copy(A.orthoCamera),this.perspCamera.copy(A.perspCamera),this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.bottom,this.far=A.far,this.view=A.view===null?null:Object.assign({},A.view),this._cameraType=A._cameraType,this.aspect=A.aspect,this.fov=A.fov,this.focus=A.focus,this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this.targetOffset=A.targetOffset,this.updateProjectionMatrix(),this}toCameraState(A=[]){let e={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return jo(e,A)}updateCameraSubtype(A,e){let r=A==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(r,e.zoom),e.near!==void 0&&this.setNear(r,e.near),e.fov!==void 0&&r==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(A){this.updateCameraState(A)}updateCameraState(A){this.updateState_Entity(A,{}),A.far!==void 0&&(this.far=A.far),A.orthographic!==void 0&&this.updateCameraSubtype("orthographic",A.orthographic),A.perspective!==void 0&&this.updateCameraSubtype("perspective",A.perspective),A.type!==void 0&&(this.cameraType=A.type),A.up!==void 0&&this.up.fromArray(A.up),A.targetOffset!==void 0&&(this.targetOffset=A.targetOffset),A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.type===0&&this.updateCameraSubtype(A.path[0],A.props)}toState(A){return{...super.toState(A),...this.toCameraState(A),type:this.cameraType}}};var eo=require("three");var lh=new eo.Matrix4;var tt=class extends ht{constructor(A,e,r){super(A,e);this.data=e;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new eo.BufferGeometry;this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&A.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(A,e=!0){if(this.booleanMeshSetAddress!==-1&&!A)return;for(let n=0;n<this.children.length;n++){let i=this.children[n];i instanceof tt&&i.recomputeBoolean(A===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let i=this.children[n];if(i instanceof he&&i.dataPatched.visible===!0&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if((i.geometry.index??i.geometry.getAttribute("position")).count/3<15e5&&(i.booleanMeshSetAddress=dt.getMeshSet(i.geometry,A===!0,e)),i.booleanMeshSetAddress===-1)return;dt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else i instanceof tt&&i.needsTransformForDownstream===!0?(dt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(lh.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),dt.transformMeshSet(i.booleanMeshSetAddress,lh),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new eo.Float16BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(A===!0)return dt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new eo.BufferGeometry,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=dt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,mn(this),hn(this)}dispose(){super.dispose(),this.geometry.dispose()}};var dh=require("three");var ch;(t=>{function o(A){return HA.is(A)&&A instanceof dh.Light}t.is=o})(ch||(ch={}));var wn=(o,t)=>class extends Or(o,t){updateState_Light(e,r){this.updateState_Entity(e,r),e.color!==void 0&&(this.color=r.shared.color(e.color)),e.intensity!==void 0&&(this.intensity=e.intensity),e.depth!==void 0&&(this.shadow.camera.far=e.depth,this.shadow.needsUpdate=!0),e.shadows!==void 0&&(this.castShadow=e.shadows)}};var Di=o=>o instanceof he,Gi=o=>o!==null&&o instanceof tt,uh=o=>o instanceof $t;var ph=o=>Ea.is(o);var mh=require("three");var fh=require("three");var Pr=class extends Ft(fh.AxesHelper){constructor(A,e=15){super(e);this.object=A;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${A.uuid}`,this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1}raycast(A,e){zt(this.object,Pr.geometryHelper,A,e)}update(){}};var Ri=class extends Or(mh.Group,Pr){constructor(t,A){super(),this.super_Entity(t,A),this.objectHelper.update()}updateState(t,A){this.updateState_Entity(t,A)}};var ji=require("three");var hh=require("three");var Tn=class extends Ft(hh.DirectionalLightHelper){constructor(A,e=15,r=10066329){super(A,e,r);this.object=A;this.added=!1;this.name=`DirectionalLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,Tn.geometryHelper,A,e)}};var yh=require("three");var On=class extends Ft(yh.PointLightHelper){constructor(A,e=15,r=6710886){super(A,e,r);this.object=A;this.name=`PointLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,On.geometryHelper,A,e)}};var Ba=require("three");var Ma=class extends Ft(Ba.SpotLightHelper){constructor(A,e=6710886){super(A,e);this.object=A;this.name=`SpotLightHelper: ${A.uuid}`}raycast(A,e){zt(this.object,Ma.geometryHelper,A,e)}update(){if(this.object!==void 0){let A=Ma._vector,e=this.object.distance?this.object.distance:1e3,r=e*Math.tan(this.object.angle);this.cone.scale.set(r,r,e),A.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(A);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let i=0,a=this.cone.material.length;i<a;i++)this.cone.material[i].color.set(n);else this.cone.material.color.set(n)}}},Vi=Ma;Vi._vector=new Ba.Vector3;function D1(o,t){o.shadow.camera.right=t/2,o.shadow.camera.left=-t/2,o.shadow.camera.top=t/2,o.shadow.camera.bottom=-t/2,o.shadow.needsUpdate=!0}var Da=class extends wn(ji.DirectionalLight,Tn){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let i=new ji.CameraHelper(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof ji.CameraHelper&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A);let e=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&D1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e&&this.update()}};var Fe=require("three");var Ga=class extends wn(Fe.PointLight,On){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let i=new Fe.Vector3(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new Fe.Vector3(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new Fe.Box3(i,a),d=new Fe.Box3Helper(l,new Fe.Color(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let A=this.gizmos[t];if(A instanceof Fe.Box3Helper){let e=this.shadow.camera,r=new Fe.Vector3(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),n=new Fe.Vector3(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);A.box.set(r,n),A.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var rt=require("three");var gh=new rt.Vector3,xh=new rt.Vector3,vh=new rt.Quaternion,Ra=class extends wn(rt.SpotLight,Vi){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=rt.MathUtils.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let i=new rt.CameraHelper(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof rt.CameraHelper&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),xh.setFromMatrixPosition(this.matrixWorld),vh.setFromRotationMatrix(this.matrixWorld),gh.copy(this.up).applyQuaternion(vh).negate().multiplyScalar(this.distance),this.target.position.copy(xh).add(gh),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Va=class extends Pe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}constructor(t,A,e){super(t,A,e)}updateEntityBoxSize(t,A){let e=this.geometry.getAttribute("position");e!==void 0?Ql(e,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:e.count,t,A):super.updateEntityBoxSize(t,A)}};var Sh=require("three");var Ar=class extends Or(Sh.Group,Pr){constructor(A,e,r){super();e.type==="Instance"&&typeof A=="string"&&(e=this.transformAssignData(e,r)),this.super_Entity(A,e),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(A,e){let r=e.scene.data.objects.get(A.component);if(r){let n,i;for(let a of ar.rootOverrideProps)A[a]===void 0?(n===void 0&&(n={...A}),n[a]=r.data[a]):(i===void 0&&(i={}),i[a]=A[a]);return this.overrideData=i,n??A}return A}updateByOp(A,e,r,n){let i;if(this.isInstanceRoot&&!n&&(e=this.transformAssignData(e,r),A.type===0&&A.path.length===0&&this.component))for(let a of ar.rootOverrideProps)a in A.props&&A.props[a]===void 0&&(i===void 0&&(i={...A,props:{...A.props}}),i.props[a]=this.component.data[a]);super.updateByOp(i??A,e,r,n)}updateState(A,e){this.updateState_Entity(A,e)}expandInstanceChildren(A){let e=this.data;if(this.component===void 0){this.component=A.scene.find(e.component)??null;let r=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let n=0;for(let i of this.children)if(HA.is(i))A.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),ja(i),n+=1;else break;this.children.splice(0,n)}r=!0}this.component&&wh(A,[this.uuid],e.overrides,this,this.component,this.component,0,r),this.oldComponent=this.component}}};function ja(o){if(o.component){let t=o.component.instances.indexOf(o);t>=0&&o.component.instances.splice(t,1);for(let A of o.children)HA.is(A)&&ja(A)}}function bh(o,t,A,e){return o.component===t&&Fn(o.identity,e)?o.overrideData===A?2:1:0}function wh(o,t,A,e,r,n,i,a){if(i>50)return!1;if(e.component!==r){if(e.component){let d=e.component.instances.indexOf(e);d>=0&&e.component.instances.splice(d,1)}r.instances.push(e),e.component=r}r instanceof Ar&&r.isInstanceRoot&&r.expandInstanceChildren(o);let l=0;for(let d of r.children)if(HA.is(d)){let s=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],c=mo.resolve(A,s,1),u=null,p;if(!a){let f=e.children[l];if(u=HA.is(f)?f:null,u!==null){let m=bh(u,d,c,s);p=m>=1?u.stateSelection:void 0,m!==2&&(u=null)}if(u===null&&(u=o.scene.findInstance(s)??null,u!==null)){let m=bh(u,d,c,s);if(p=m>=1?u.stateSelection:void 0,m!==2)u=null;else{let h=u.parent.children.indexOf(u);u.parent.children.splice(h,1),e.children.splice(l,0,u),u.parent===e?(h<=l&&console.error("not possible"),void 0):(u.parent=e,u.matrixWorldNeedsUpdate=!0,u.resetBBoxNeedsUpdate(),u.updateVisible(),o.pendingDeletes.delete(u),void 0)}}}if(u===null){let f=c?kt.apply(d.data,c):d.data;it.is(f.type)&&(f={...f,type:"Empty"}),u=at.createEntity(s,f,o),u.overrideData=c,e.add(u),e.children.splice(e.children.length-1,1),e.children.splice(l,0,u),u.updateState(u.data,o),p&&u.changeSelectedState(p,o),o.scene.registerInstanceAndSetUuid(u)}l+=1,wh(o,t,A,u,d,n,i+1,a)}if(!a){let d=l;for(;;){let s=e.children[l];if(HA.is(s))o.pendingDeletes.add(s);else break;l+=1}e.children.splice(d,l-d)}return!0}function G1(o,t,A){let e;return t.geometry.type==="TextGeometry"?new gn(o,t,A):(t.geometry.type==="SubdivGeometry"?e=new _r(o,t,A):t.geometry.type==="VectorGeometry"?e=new Va(o,t,A):t.geometry.type==="BooleanGeometry"?e=new tt(o,t,A):e=new Pe(o,t,A),e)}function Fa(o,t,A){return t.type==="Mesh"?G1(o,t,A):t.type==="Empty"?new Ri(o,t):t.type==="PointLight"?new Ga(o,t,A):t.type==="SpotLight"?new Ra(o,t,A):t.type==="DirectionalLight"?new Da(o,t,A):t.type==="Component"||t.type==="Instance"?new Ar(o,t,A):it.is(t.type)?new $t(o,t):(console.error(t),new Ri(o,t))}at.createEntity=Fa;function R1(o,t,A){let e=Fa(o.identity,t,A),r=o.children,n=o.parent,i=o.component,a=o.instances,l=o.overrideData,d=o.uuid,s=o.stateSelection;o.dispose();for(let c of Object.keys(o))delete o[c];Object.setPrototypeOf(o,Object.getPrototypeOf(e));for(let c of Object.keys(e))o[c]=e[c];o.children=[...o.children,...r],o.parent=n,o.component=i,o.instances=a,o.uuid=d,o.overrideData=l,o.updateState(o.data,A),s&&o.changeSelectedState(s,A),o.resetBBoxNeedsUpdate()}at.changeEntityProptotype=R1;at.Cloner=bn;function Th(o,t,A,e){o.updateByOp(t,A,e,!1)}var Pn=require("three");function Oh(o,t){let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(o.layers.set(8),e.length>0&&o.layers.enable(3),A=!0,hn(o),mn(o)),e.length===0&&r.length===0&&o.layers.set(0),A}function Ph(o,t){if(!t.layers)return!1;let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return e.length>0&&(o.layers.set(3),r.length>0&&o.layers.enable(8),A=!0),e.length===0&&r.length===0&&o.layers.set(0),A}function Nh(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof ht)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Oh(A,A.material[e])&&(t=!0);else Oh(A,A.material)&&(t=!0)}),t}function Ch(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof ht)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Ph(A,A.material[e])&&(t=!0);else Ph(A,A.material)&&(t=!0)}),t}var j1=new Pn.Raycaster,F1=new Pn.Matrix4,z1=new Pn.Ray;function Ih(o,t,A){let e=o.cloner;if(e)for(let r of e.children){let n=F1.copy(r.matrixWorld).invert(),i=z1.copy(t.ray).applyMatrix4(n),a=o.matrixWorld;i.applyMatrix4(a);let l=j1;l.set(i.origin,i.direction),l.near=t.near,l.far=t.far,l.intersectObject(o,!1).length>0&&A.push({object:o})}}var U1=new ot.MeshBasicMaterial;U1.wireframe=!0;var Lh=new ot.Vector3,Pc=class extends ot.Scene{constructor(A,e){super();this.data=A;this.backupFog=new ot.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new ne(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new ot.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=A.postprocessing,this.init(A,e),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Ch(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Nh(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(A){let e=A.identity.join("-"),r=this.entityIdentityToEntity[e];r&&(A.uuid=r.uuid),this.entityIdentityToEntity[e]=A,this.entityByUuid[A.uuid]=A}findInstance(A){return this.entityIdentityToEntity[A.join("-")]}getWithSortKey(A){let e=this.find(A);if(e===void 0)return;let r=[],n=e;for(;n!==this;){let i=n;n=n.parent;let a=n.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(A){let e=[];for(let r of A){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>xd(r.sortKey,n.sortKey)),e.map(r=>r.entity)}nonExistOrDescendantOf(A,e){let r=this.find(A);if(r===void 0)return!0;for(;r;){if(r.uuid===e)return!0;r=r.parent}return!1}find(A){if(A===""||A===void 0)return;let e=this.entityByUuid[A];return e===void 0?this.getObjectByProperty("uuid",A):e}debugEnsureEntity(A){let e=this.find(A);if(e){if(Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(A){this.toExpandCloner.add(A)}addPendingUpdateCloner(A){this.toUpdateCloner.add(A)}markToExpandCloner(A){this.toExpandCloner.add(A),A.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(){this.toExpandCloner.forEach(A=>{A.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(A=>{A.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(A,e){if(A.path.length===0&&A.type===7){let r=A.parent===null?this:this.find(A.parent);if(r===void 0)throw new Error("unexpected");let n=this.createObject(A.id,A.data,A.children,r,A.localIndex,e);n.updateVisible(),n.resetBBoxNeedsUpdate(),Di(n)&&Gi(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n)}else if(A.path.length===0&&A.type===8){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(r),r.parent.remove(r),Gi(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Di(r)&&(r.freeBooleanPointer(),n instanceof tt&&n.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r)}else if(A.path.length===0&&A.type===9){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let i=A.parent===null?this:this.find(A.parent);if(i===void 0)throw new Error("unexpected");i.add(r),this.markNeedsRecomputeInstancesForAncessors(i),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate();let a=A.localIndex;i.children.splice(a,0,i.children.pop()),Di(r)&&(r.invalidateUpstreamBooleanData(),Gi(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof tt&&n.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(A,e,r,n){if(e.type===0&&(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),e.path.includes("overrides")&&"states"in e.props)){let{states:a,rest:l}=e.props;e={...e,props:l},this.markNeedsRecomputeInstances()}let i=this.find(A);if(i)try{Th(i,e,r,{scene:this,shared:n}),i instanceof Pe&&i.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(A){this.fog=A===!0?this.backupFog:null}init(A,e){if(this.createChildrenObjects(A.objects,this,e),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Oe(A.backgroundColor,e)),this.updateFog(A.fog,e),this.updateAmbientLight(A.environment.ambientLight,e),this.activeCamera=this.personalCamera,A.publish.playCamera!==null){let r=this.find(A.publish.playCamera);r instanceof $t&&this.switchActiveCamera(r)}this.expandInstances(e,!0),this.traverseEntity(r=>{Gi(r)&&r.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(A){A.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(A){HA.is(A)&&(A.data.type==="Component"&&this.markNeedsRecomputeInstances(),A.traverseAncestors(e=>{HA.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(A,e,r,n,i){if(A.data.type==="Transition"){let a=A.data.object;a&&a!==e.uuid&&e.find(a)&&r.forInstancesRec(d=>{d.isInstanceRoot||(d.data=ao(d.data,s=>{let c=s.events.data(i.id),u=d.goUp(n);if(u){let p=[...gs(u.identity),A.data.object].join("-"),f=this.entityIdentityToEntity[p];if(f){let m=f.uuid;c.actions.data(A.id).object=m}else{if(cr)debugger;console.warn("cannot find instance")}}}).data)})}}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(A=>{if(A instanceof Ar&&typeof A.identity=="string"&&A.data.type==="Component")return A.traverseEntity((e,r)=>{e.data.events.forEach(n=>{n.data.type==="GameControl"?e.forInstancesRec(i=>{i.isInstanceRoot||(i.data=ao(i.data,a=>{a.events.delete(n.id)}).data)}):"actions"in n.data&&n.data.actions.forEach(i=>{this.relativeizeInner(i,A,e,r,n)})})}),!0})}expandInstances(A,e){let r=new Set;this.traverseEntity(n=>{if(n instanceof Ar&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:A,pendingDeletes:r}),e||n.resetBBoxNeedsUpdate(),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),ja(n)}recomputeInstances(A){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{e instanceof Ar&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(A,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(A){A.traverseEntity(e=>{let r=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[r]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[r]),e.dispose()})}clearScene(){for(let A of this.children)lt(A)&&A.disposeRecursively();this.children.length=0}resetAfterClear(A,e){this.init(A,e)}createPersonalCamera(){let A=new $t(Pc.PERSONAL_CAMERA_ID,{...fo.defaultData,name:"Personal Camera"});return A.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(A),A}raycast(A){let e=[],r=n=>{for(let i of n.children)lt(i)&&!i.raycastLock&&i.visible&&((Di(i)||ph(i)&&this.enableHelpers&&i.objectHelper.visible)&&(A.intersectObject(i,!1,e),Ih(i,A,e)),r(i))};return r(this),e}forEachEntity(A){for(let e of this.children)lt(e)&&A(e)}traverseEntity(A){for(let e of this.children)lt(e)&&e.traverseEntity(A)}traverseObject(A){for(let e of this.children)Wn.is(e)&&e.traverseObject(A)}traverseVisibleEntity(A){for(let e of this.children)lt(e)&&e.visible&&e.traverseVisibleEntity(A)}updateFog(A,e){this.enableFog=A.enabled,this.fogUseBGColor=A.useBackgroundColor,A.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Oe(A.color,e),this.backupFog.near=A.near,this.backupFog.far=A.far}dispose(){this.clearScene()}updateAmbientLight(A,e){A.color!==void 0&&(this.ambientLight.color=Oe(A.color,e)),A.intensity!==void 0&&(this.ambientLight.intensity=A.intensity),A.groundColor!==void 0&&(this.ambientLight.groundColor=Oe(A.groundColor,e)),A.enabled!==void 0&&(this.ambientLight.visible=A.enabled)}switchActiveCamera(A){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=A,A.objectHelper.visible=!1}setBackgroundColor(A){this.bgColor=A,this.fogUseBGColor===!0&&(this.backupFog.color=A)}createChildrenObjects(A,e,r){let n=0;for(let i of A)this.createObject(i.id,i.data,i.children,e,n,r),n+=1}registerObjectCreatedInLegacy(A){this.entityByUuid[A.uuid]=A}unregisterObject(A){delete this.entityByUuid[A.uuid];for(let e of A.children)this.unregisterObject(e)}createObject(A,e,r,n,i,a){let l={scene:this,shared:a},d=Fa(A,e,l);return d&&(this.entityByUuid[A]=d,n.add(d),n.children.splice(i,0,n.children.pop()),r.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,d,a)),d.updateState(e,l),d instanceof Pe&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d)),d}getCenter(A){let e=[];for(let n=0,i=A.length;n<i;++n){let{id:a,recursive:l}=A[n],d=this.find(a),s=l?d.recursiveBBox:d.singleBBox;e.push(...s.vertices)}let r=new ot.Box3;return r.setFromPoints(e),r.getCenter(Lh),Lh}copyMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A);r?e.copy(r.matrixWorld):e.identity()}copyParentMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A)?.parent;r?e.copy(r.matrixWorld):e.identity()}traverseMaterial(A){this.traverseEntity(e=>{if(e instanceof he)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)e.material[r]instanceof je&&A(e.material[r]);else e.material instanceof je&&A(e.material)})}updateCanvasSize(A,e){this.activeCamera.setViewplaneSize(A,e);let r,n;A>=e?(r=e/A,n=1):(r=1,n=A/e),this.traverseMaterial(i=>{i.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=r,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},zi=Pc;zi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var Eh=require("three/examples/jsm/loaders/DRACOLoader.js");var Nr;function k1(){return Nr||(Nr=new Eh.DRACOLoader,Nr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Nr.decoderPending}async function H1(o){if(Nr){let t={attributeIDs:Nr.defaultAttributeIDs,attributeTypes:Nr.defaultAttributeTypes,useUniqueIDs:!1},A;try{A=await Nr.decodeGeometry(new Int8Array(o).buffer,t)}catch(e){console.error(e)}if(A)return{index:A.index?{array:A.index.array}:void 0,attributes:Object.entries(A.attributes).map(([e,r])=>({name:e,itemSize:r.itemSize,array:r.array}))}}return null}async function Mh(o,t){let[A,e]=Za(ds.deserialize(new Uint8Array(o)));Zp(A);let r=[];A.scene.objects.traverse((n,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&i.geometry.data.draco!==void 0&&r.push(i)}),r.length&&await k1();for(let n of r){let i=await H1(ae(n.geometry.data.draco));if(i){i.index&&(n.geometry.data.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:l,array:d,itemSize:s})=>{a[l]={array:d,itemSize:s,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(A),e.result().data}var W1=require("three"),q1=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Bh(o){let t;if(!!o.index)for(let A=0;A<o.index.array.length;A+=3)t=o.index.array[A],o.index.array[A]=o.index.array[A+2],o.index.array[A+2]=t}var Ui=require("three");function Dh(o){let t=new Set;return o.traverse(A=>{if(A instanceof ht)if(QA(A.material))A.material.forEach(e=>{let r=e;t.has(r)||t.add(r)});else{let e=A.material;t.has(e)||t.add(e)}}),t.forEach(A=>{if(A instanceof Array)return;let e=A.onBeforeCompile.bind(A);if(Q1(A)){Object.assign(A,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Ui.Color,specularColor:new Ui.Color});let r=0;A.onBeforeCompile=(n,i)=>{e&&e(n,i),n.uniforms=Object.assign({},Ui.ShaderLib.physical.uniforms,n.uniforms),A.getLayersOfType("transmission").forEach(a=>{if(n.uniforms.transmissionSamplerMap.value){let l=a.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value)}else r++,r<2&&(A.needsUpdate=!0)})}}else Y1(A)||(A.onBeforeCompile=(r,n)=>{e&&e(r,n),A.transparent=!1})}),o}function Q1(o){return o.getLayersOfType("transmission").length>0}function Y1(o){let t=0;return o.layers.forEach(A=>{if(A.type!=="light"&&A.type!=="fresnel"){let e=A.uniforms["f"+A.id+"_alpha"];e&&(t+=(1-t)*e.value)}}),t<1}function Gh(o){return o.traverse(t=>{if(t.type==="Camera"){let A=t;A.type=A.cameraType}}),o}function Rh(o){let t=[],A=(e,r=0)=>{let n=r>0?e+r:e;return t.includes(n)?A(e,r+1):n};return o.traverse(e=>{if(t.includes(e.name)){let r=e.name,n=A(e.name);if(e.name=n,e.isMesh){let i=e;i.material instanceof Array?i.material.forEach(a=>{a.name=a.name.replace(r,n)}):i.material.isAsset||(i.material.name=i.material.name.replace(r,n))}}t.push(e.name)}),o}var Vh=require("three/examples/jsm/utils/BufferGeometryUtils.js");function jh(o){let t=[];return o.traverse(A=>{A instanceof bn&&t.push(A)}),t.forEach(A=>{let e=A.object,n=A.children.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Bh(l),l}),i=(0,Vh.mergeBufferGeometries)(A.parameters.hideBase?n:[e instanceof he?e.geometry:[],...n]);e instanceof he&&(e.geometry=i),A.removeFromParent(),e.setFromClonerState(null,{scene:o,shared:Hm})}),o}function Fh(o){return o.traverse(t=>{t.matrixAutoUpdate=!0}),o}function zh(o){Object.values(o.shared.materials).forEach(t=>{Nc(t)}),o.scene.objects.traverse((t,A)=>{"material"in A?Nc(A.material):"materials"in A&&A.materials.forEach(e=>{Nc(e)})})}function Nc(o){if(typeof o=="string")return;let t=[];o.layers.forEach((A,e)=>{A.type==="outline"&&t.push(e)}),t.reverse().forEach(A=>{o.layers.delete(A)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Uh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",za=class extends Ua.Loader{load(t,A,e,r=console.error){let n=new Ua.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Uh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Uh),n.load(t,async i=>{try{if(typeof i=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(i);A(a)}catch(a){r(a)}},e,r)}async parse(t){let A=await Mh(t,zh);eh(A)&&await Um();let e=new Jr(A.shared);Object.values(e.getMaterials()).forEach(i=>Object.assign(i,{isAsset:!0}));let r=new zi(A.scene,e);r.remove(r.personalCamera),A.scene.environment.ambientLight.enabled||r.remove(r.ambientLight);let n=A.scene.publish.playCamera;if(n){let i=r.find(n);i&&uh(i)&&Object.assign(i,{makeDefault:!0})}return r=jh(r),r=Dh(r),r=Gh(r),r=Rh(r),r=Fh(r),r}};
|
package/build/SplineLoader.js
CHANGED
|
@@ -1335,4 +1335,4 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
1335
1335
|
`,A),d=A.horizontalAlign===1?l:0,s=this.computeSpaceWidthForLine(t,0,A),c=this.getLineInitialOffsetX(i[0],a,A.horizontalAlign,t[0],l),u=this.getLineInitialOffsetY(n,t.length,A.height,r,A.verticalAlign),p=[],f=t.map(x=>[]),m=t.map(x=>[]),h;for(let x=0;x<t.length;x++){let S=t[x],v={features:{liga:!0}},b=[];try{b=e.stringToGlyphs(S,v)}catch(w){console.warn(w)}c=this.getLineInitialOffsetX(i[x],a,A.horizontalAlign,S,l);let P=[];try{P=this.reverseLigaturesTable(e,S,b)}catch(w){console.warn(w)}s=this.computeSpaceWidthForLine(t,x,A);for(let w=0;w<b.length;w++){let g=b[w],N=g.index===0?`
|
|
1336
1336
|
`:g.unicode?String.fromCharCode(g.unicode):void 0,O=P[w],C=0,T=0;w===0&&A.horizontalAlign===2&&g.leftSideBearing!==void 0&&(T=-g.leftSideBearing*r),h&&(C=e.getKerningValue(g,h)*r),c+=T+C;let L=0;if(N===`
|
|
1337
1337
|
`)L=d;else if(N===" ")L=s;else{let M=this.createPath(g,r,c,u,A);M&&(L=M.offsetX-(C+T),p.push(M.path))}if(O.replacements.length===1)m[x].push([c,u]),f[x].push(L);else{let M=O.replacements.map(nA=>(e.glyphs.get(nA).advanceWidth??0)*r),U=M.reduce((nA,k)=>nA+=k,0),X=M.map(nA=>nA/U),eA=c;for(let nA=0;nA<X.length;nA++){let k=L*X[nA];m[x].push([eA,u]),f[x].push(k),eA+=k}}c+=L,h=g}u-=n}let y=[];for(let x=0,S=p.length;x<S;x++)y.push(...p[x].toShapes());return{shapes:y,charWidths:f,lineWidths:i,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,A,e,r,n){return(e===3||e===2)&&r.indexOf(`
|
|
1338
|
-
`)>=0&&(t-=n),e===3?A*.5-t*.5:e===2?A-t:0}getLineInitialOffsetY(t,A,e,r,n){let i=A*t,a=Math.abs(this.ascender-this.descender)*r,l=t-a,d=-this.ascender*r-l/2;return n===3?-(e-i-d):n===2?-(e*.5-i*.5-d):d}createPath(t,A,e,r,n){let i=t.getPath(e,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new ra,l=(t.advanceWidth??1)*A;if(t)for(let d of i.commands){let s=a.currentPath?.currentPoint;if(!(s&&d.type!=="Z"&&s.x===d.x&&-s.y===d.y))switch(d.type){case"M":a.moveTo(d.x,-d.y);break;case"L":a.lineTo(d.x,-d.y);break;case"Q":a.quadraticCurveTo(d.x1,-d.y1,d.x,-d.y);break;case"C":a.bezierCurveTo(d.x1,-d.y1,d.x2,-d.y2,d.x,-d.y);break}}return a.subPaths.forEach(d=>{let s=JT(d.curves);s!==void 0&&d.currentPoint.distanceTo(s)>0&&d.lineTo(s.x,s.y)}),{offsetX:l+n.fontSize*n.letterSpacing,path:a}}getCharWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}getTextWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}computeSpaceWidthForLine(t,A,e){let r=this.getCharWidth(" ",e),n=t[A];if(n){let i=this.countSpaces(n.trimEnd());if(e.horizontalAlign===4&&A<t.length-1&&i){let a=e.width,l=this.getTextWidth(n,e);return(a-(l-i*r))/i}}return r}countSpaces(t){return(t.match(/ /g)||[]).length}};function JT(o){if(o.length){let t=o[0];if(t instanceof XT)return t.v1;if(t instanceof YT||t instanceof KT)return t.v0}}var uc=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,A){let e=this.objects.get(t);return e===void 0?(e=this.createObject(t,A),this.objects.set(t,e)):e.isShared=!0,e}mutateIfUnique(t,A){let e=this.objects.get(t);if(e&&e.isShared!==!0)return this.objects.delete(t),this.objects.set(A,e),e}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,A){let e=this.objects.get(t);A===e?this.unreachable.delete(t):_t&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},di=class extends uc{constructor(A){super();this.flatShading=A}disposeObject(A){A.dispose()}createObject(A,e){let r=Cr(A,e,this.flatShading);return r.computeBoundingSphere(),r}};var Um={find(o){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(o){},addPendingUpdateCloner(o){}};var pc=class extends $s{constructor(A){super();this.shared=A}create(A){return new Zo(A,this.shared)}},Vr=class{constructor(t,A={}){this.geometryCache=new di(!0);this.geometryCache2=new di(!1);this.imageHolderCache=new pc(this);this.thisContext={scene:Um,shared:this};this.deletedMaterial=new Dr(xe.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new ze(Ts.emptyImage,this);this.deletedVideo=new ze(Jr.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(A.images)for(let[e,r]of Object.entries(A.images))this.addImage(e,r);if(A.videos)for(let[e,r]of Object.entries(A.videos))this.addVideo(e,r);if(A.audios)for(let[e,r]of Object.entries(A.audios))this.addAudio(e,r.data);this.reset(t)}setRequestRender(t){this._requestRender=t}reset(t){for(let[A,e]of Object.entries(t.images))this.addImage(A,e);for(let[A,e]of Object.entries(t.videos))this.addVideo(A,e);for(let[A,e]of Object.entries(t.colors))this.addColor(A,e);for(let[A,e]of Object.entries(t.materials))this.addMaterial(A,new Dr(e,this.thisContext));for(let[A,e]of Object.entries(t.audios))this.addAudio(A,e.data);for(let[A,e]of Object.entries(t.fonts))this.addFont(A,e);this.penumbraSize=t.penumbraSize}addMaterial(t,A){A.uuid=t,this.materials[t]=A}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let A=this.materials[t];return A}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new _o(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,A){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(A.data),!0):(this.images[t]=new ze(A,this),!1)}deleteImage(t){let A=this.images[t];A&&(A.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,A){return this.videos[t]?(this.videos[t].updateSrc(A.data),!0):(this.videos[t]=new ze(A,this),!1)}deleteVideo(t){let A=this.videos[t];A&&(A.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,A){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in A?this.colors[t].setRGBA(A.r,A.g,A.b,A.a):this.colors[t].setRGBA(A.r,A.g,A.b,1),!0):("a"in A?this.colors[t]=new lr(A.r,A.g,A.b,A.a):this.colors[t]=new lr(A.r,A.g,A.b,1),!1)}updateColor(t,A){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let e=this.colors[t];return this.colors[t].r=A.r??e.r,this.colors[t].g=A.g??e.g,this.colors[t].b=A.b??e.b,this.colors[t].a=A.a??e.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let A;if(typeof t=="string"){let e=this.getColor(t);e?A=e:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),A=new YA(0,0,0,0))}else return"a"in t?new YA(t.r,t.g,t.b,t.a):new YA(t.r,t.g,t.b,1);return A}addAudio(t,A){this.audios[t]=A}getAudio(t){let A=this.audios[t];if(A instanceof Gr)return A;{let e=new Gr({src:A});return this.audios[t]=e,e}}deleteAudio(t){let A=this.audios[t];A&&(A instanceof Gr&&A.dispose(),delete this.audios[t])}addFont(t,A){this.fonts[t]=new oa(A),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(A=>this.deleteMaterial(A)),this._requestRender=void 0,Object.values(this.audios).forEach(A=>{A instanceof Gr&&A.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},km=new Vr(Zi.emptyData());var et=class extends oe{updateByPatchedOp(A,e,r){if(super.updateByPatchedOp(A,e,r),Rc(A.path,["materials"])!==null&&A.type===0&&Array.isArray(this.material))for(let[n,i]of Object.entries(A.props)){let a=r.shared.material(i);this.material[Number(n)]=a}else if(it(A.path,["material"])&&this.material instanceof Oe)"material"in e&&typeof e.material!="string"&&this.material.updateByOp(te.drop(A,1),e.material,r);else if(it(A.path,["materials","*"])&&Array.isArray(this.material)){let n=A.path[1];if("materials"in e&&n<this.material.length){let i=e.materials[n];typeof i!="string"&&this.material[n].updateByOp(te.drop(A,2),i,r)}}}updateState(A,e){super.updateState(A,e),A.castShadow!==void 0&&(this.castShadow=A.castShadow),A.receiveShadow!==void 0&&(this.receiveShadow=A.receiveShadow);let r=this.dataPatched;if(A.geometry?.type!=="NonParametricGeometry"&&"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene?.markNeedsUpdateRendererDirty()),A.geometry?.type==="NonParametricGeometry"&&("materials"in A&&A.materials!==void 0?(this.disposeMaterial(),this.material=A.materials.map(n=>e.shared.material(n).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene?.markNeedsUpdateRendererDirty()):"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene?.markNeedsUpdateRendererDirty())),A.flatShading!==void 0||A.wireframe!==void 0||A.side!==void 0)if(Array.isArray(this.material))for(let n=0;n<this.material.length;n++)this.material[n]=this.material[n].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe)}disposeMaterial(){this.material&&Ki(this.material).forEach(A=>{A instanceof Oe&&(A instanceof Dr||A.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as _T}from"three";var fe=class extends et{constructor(A,e,r){super(A,e);this.data=e;this.localGeometry=void 0}chooseGeoemtryCache(A){return A.geometryCache}markGeometryAsReachable(A){this.geometryCreateDeleyed instanceof _T&&this.chooseGeoemtryCache(A).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Vr){let A=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(A);this.geometryCreateDeleyed=e.get(this.dataPatched.geometry,A)}return this.geometryCreateDeleyed}set geometry(A){this.localGeometry=A}get is2DAndNoDepth(){let A=this.dataPatched.geometry;return yn.is2DParametricMesh(A.type)&&A.depth===0}get is2DType(){return yn.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),it(A.path,["geometry"])&&this.updateByPatchedOpGeometry(te.drop(A,1),e.geometry,r)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(A,e){this.invalidateDownstreamBooleanData();let r=this.data.geometry.type;if(r==="NonParametricGeometry"||r==="SubdivGeometry"){let n=A;if(this.localGeometry===void 0){let s={...this.data.geometry,...n};this.localGeometry=Cr(s,e,this.data.flatShading)}let i,a,l;n.scaleBaked?[i,a,l]=n.scaleBaked:{width:i,height:a,depth:l}=n;let d=this.localGeometry.userData;d.sxPrev!==void 0&&Fn(this.localGeometry.attributes,i/d.sxPrev,a/d.syPrev,l/d.szPrev),d.sxPrev=i,d.syPrev=a,d.szPrev=l}else{let n={...this.data.geometry,...A};this.localGeometry?.dispose(),this.localGeometry=Cr(n,e,this.data.flatShading)}}refreshAttachedCloners(A){for(let e of this.attachedSurfaceCloners)A.scene.addPendingUpdateCloner(e.object)}createGeometryDelayed(A){this.geometryCreateDeleyed=A.shared,this.refreshAttachedCloners(A)}updateByPatchedOpGeometry(A,e,r){let n=!1;A.type===0&&A.path.length===0&&Sn(["scaleBaked"],Object.keys(A.props))&&this.geometryCreateDeleyed instanceof zA&&this.chooseGeoemtryCache(r.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,A.props.scaleBaked),this.refreshAttachedCloners(r)),n||(r.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(r)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(A,e){this.createGeometryDelayed(e)}updateState(A,e){A.geometry!==void 0&&this.updateGeometryOnStateUpdate(A.geometry,e),super.updateState(A,e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;this.is2DType?A.set(0,0,r.depth*.5):A.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}};function AO(o){if(o.geometry.attributes.extrudeNormal||!o.geometry.attributes.position||!o.geometry.attributes.normal)return;let t=new Map,A=o.geometry.attributes.position.array,e=o.geometry.attributes.normal.array,r=new Float32Array(A.length);for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=new mc(e[n],e[n+1],e[n+2]);t.has(i)?t.get(i)?.normals.push(a):t.set(i,{normals:[a],result:new mc})}t.forEach((n,i)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=t.get(i)?.result;a&&(r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z)}o.geometry.setAttribute("extrudeNormal",new Hm(r,3))}function eO(o){if(o.geometry.attributes.extrudeNormals||!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=new mc;for(let r=0;r<t.length;r+=3)e.set(t[r],t[r+1],t[r+2]).normalize(),A[r]=e.x,A[r+1]=e.y,A[r+2]=e.z;o.geometry.setAttribute("extrudeNormal",new Hm(A,3))}function $o(o){if(Array.isArray(o.material)){for(let t of o.material)if(t.getLayersOfType("outline").length===0)return}else if(!(o.material instanceof Oe)||o.material.getLayersOfType("outline").length===0)return;o instanceof fe&&o.is2DAndNoDepth?eO(o):AO(o)}function An(o){if(!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=parseInt(o.uuid.replace(/\D/g,"")),r=[fc.seededRandom(e),fc.seededRandom(e+1e4),fc.seededRandom(e+2e4)];for(let n=0;n<t.length;n++)A[n]=r[n%3];o.geometry.setAttribute("randomColor",new $T(A,3))}var nO;zo.then(o=>{nO=o});var wt=new tO,ui=new oO;var jr=class extends fe{constructor(A,e,r){super(A,e,r);this.data=e;this.hiddenMatrixOld=new rO;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(A){return this.dataPatched.flatShading?A.geometryCache:A.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;A.copy(this.originalGeometryNew.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}createGeometryByControls(A){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:r,subdividedGeometry:n,subdivPointer:i}=zA.build(A,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=i,r!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=r),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,$o(this),An(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(A,e){if(super.updateState(A,e),A.flatShading!==void 0){let r=this.material;this.material=r.getFlavor(!1,r.side,r.wireframe),this.smoothShading=!A.flatShading,this.createGeometryDelayed(e)}}updateMesh(A=!1){zA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(A,e){let r=this.localGeometry;this.localGeometry=this.originalGeometryNew,oe.prototype.raycast.call(this,A,e),this.localGeometry=r}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new Wm,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let e=A.attributes.position,r=A.boundingSphere.center;wt.setFromBufferAttribute(e),wt.getCenter(r),A.boundingSphere.radius=r.distanceTo(wt.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),wt.getSize(ui),this.hasNonUniformScale&&ui.divide(this.scale);let n={width:ui.x,height:ui.y,depth:ui.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(A){let e=this.originalGeometry;wt.min.set(A[0],A[2],A[4]),wt.max.set(A[1],A[3],A[5]),this.hasNonUniformScale&&(wt.min.applyMatrix4(this.shearScaleInv),wt.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new Wm);let r=e.boundingSphere.center;wt.getCenter(r),e.boundingSphere.radius=r.distanceTo(wt.max)}freeSubdivPointer(){this.subdivPointer&&(zA.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(A,e,r){super.updateByPatchedOpGeometry(A,e,r),this.localGeometry&&this.createGeometryByControls(e)}};import{Triangle as iO,Vector3 as zr}from"three";var qm=-1,sO=1,Qm={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Ym={polygon_center:0,edge:1,vertex:2},pi=(o,t)=>(A,e)=>!t||A===0||o===0?0:o*e/100,fA=(o,t)=>{let A=Math.abs(t),e=A*-1;return(o-qm)*(A-e)/(sO-qm)+e};function Xm(o){let t=[],A={};for(var e=0,r=o.length;e<r;e++){var n=JSON.stringify(o[e].pos.map(i=>Math.round(i*1e4)/1e4));A[n]||(t.push(o[e]),A[n]=!0)}return t}var aO=new zr,na=new zr,lO=new zr,cO=new zr;function en(o,t){let A=lO.fromArray(o),e=cO.fromArray(t);na.copy(e).sub(A);let r=na.length();return na.normalize().multiplyScalar(r*.5),aO.copy(A).add(na).toArray()}var Ue=new iO,ia=new zr,sa=new zr,Fr=new zr;function Km(o){let t=[];for(let A=0;A<=o.index.count;A++)if(ia.fromArray(o.index.array,A*3),Ue.setFromAttributeAndIndices(o.attributes.position,ia.x,ia.y,ia.z),Ue.getNormal(sa),Ue.getMidpoint(Fr),!(isNaN(Fr.x)||isNaN(Fr.y)||isNaN(Fr.z))){let{a:e,b:r,c:n}=Ue,i=e.toArray(),a=r.toArray(),l=n.toArray(),d=e.distanceTo(r),s=r.distanceTo(n),c=n.distanceTo(e),u=en(i,a),p=en(a,l),f=en(l,i),m=[d,s,c],h=Math.max(...m),y=m.filter(v=>Math.round(v)===Math.round(h)).length>1,x=[],S=Ue.getMidpoint(Fr).toArray();h===d&&!y&&(x=[p,f,f],S=u),h===s&&!y&&(x=[u,f,f],S=p),h===c&&!y&&(x=[u,p,p],S=f),y&&(x=[u,p,f]),t.push({vertices:[i,a,l],faceCenters:x,midpoint:S,norm:Ue.getNormal(sa).toArray()})}return t}function Zm(o){let t=[],{position:A}=o.attributes;for(let e=0;e<A.count;e++){Ue.setFromAttributeAndIndices(A,e*3,e*3+1,e*3+2),Ue.getNormal(sa),Ue.getMidpoint(Fr);let r=Ue.a.toArray(),n=Ue.b.toArray(),i=Ue.c.toArray();t.push({vertices:[r,n,i],faceCenters:[en(r,n),en(n,i),en(i,r)],midpoint:Fr.toArray(),norm:sa.toArray()})}return t}var dO=4,uO=.5,hc=o=>.5*(1-Math.cos(o*Math.PI)),yc=class{constructor(){this.perlin=new Array(4095+1)}noise(t,A=0,e=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),A<0&&(A=-A),e<0&&(e=-e);let r=Math.floor(t),n=Math.floor(A),i=Math.floor(e),a=t-r,l=A-n,d=e-i,s,c,u=0,p=.5,f,m,h;for(let y=0;y<dO;y++){let x=r+(n<<4)+(i<<8);s=hc(a),c=hc(l),f=this.perlin[x&4095],f+=s*(this.perlin[x+1&4095]-f),m=this.perlin[x+16&4095],m+=s*(this.perlin[x+16+1&4095]-m),f+=c*(m-f),x+=256,m=this.perlin[x&4095],m+=s*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=s*(this.perlin[x+16+1&4095]-h),m+=c*(h-m),f+=hc(d)*(m-f),u+=f*p,p*=uO,r<<=1,a*=2,n<<=1,l*=2,i<<=1,d*=2,a>=1&&(r++,a--),l>=1&&(n++,l--),d>=1&&(i++,d--)}return u}noiseSeed(t){let A=(()=>{let i,a;return{setSeed(l){a=i=(l??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();A.setSeed(t),this.perlin=new Array(4095+1);for(let e=0;e<4095+1;e++)this.perlin[e]=A.rand()}},Jm=yc;import{Vector3 as pO,Matrix4 as fO,Ray as mO}from"three";var _m=new pO,$m=new fO,Ah=new mO;function eh(o){let t=!1;return o.scene.objects.traverse((A,e)=>{e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(t=!0)}),t}var tn=class extends fe{constructor(A,e,r){super(A,e,r);this.data=e}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let A=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,A.geometry.height,this.fontScale,A.geometry.verticalAlign)??0}get fontScale(){let A=this.dataPatched;return this.font?A.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let A=this.dataPatched;return A.geometry.fontSize*A.geometry.lineHeight}raycast(A,e){let{matrixWorld:r}=this;if($m.copy(r).invert(),Ah.copy(A.ray).applyMatrix4($m),Ah.intersectBox(this.singleBBox,_m)){let n=_m.applyMatrix4(r),i=A.ray.origin.distanceTo(n);e.push({distance:i,point:n.clone(),object:this})}}};var me=1e-4,Tt,nh,ih,sh,rh=new Be,oh=new Be;zo.then(o=>{Tt=o,nh=[Tt.get_face_center,Tt.get_edge_midpoint,Tt.get_vertex_position],ih=[Tt.get_face_normal,Tt.get_edge_normal,Tt.get_vertex_normal],sh=[Tt.face_count,Tt.edge_count,Tt.vertex_count]});var yO=new kr,gO=new kr,dr=new Be,Ur=new Be,fi=new Be,xc=new Be,xO=new Be,vO=new Be;var Ft=new Jm,on=class extends No(hO){constructor(A,e){super();this.parameters=e;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=A}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(A){if(this.parent===null)this.updateState(this.parameters,A);else for(let e of this.children)e instanceof Gt&&e.expand()}invalidateTransform(A){this.matrixWorldNeedsUpdate=!0,this.traverse(e=>{e instanceof Gt&&e.object===A&&(e.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let A of this.children)A.updateMatrix(),A.hasNonUniformScale&&(A.updateMatrixWorld(),A.updateMatrixWorldSVD())}_updateCount(A){let e;if(A!==void 0?e=A:e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(e=0),this.parameters.type==="toObject"&&this.objectForSample){for(let n=0,i=this.children.length;n<i;++n)this.remove(this.children[0]);let r=this.children;if(r.length===e)return;if(r.length<e)for(let n=0,i=e-r.length;n<i;++n){let a=new Gt(this.object);a.expand(),this.add(a)}else for(let n=0,i=r.length-e;n<i;++n)this.remove(r[n])}else{if(this.children.length===e)return;if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let i=new Gt(this.object);i.expand(),this.add(i)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}}_updateRadial(A){let e=A.radial,r=e.start*th.DEG2RAD,n=e.end*th.DEG2RAD,i=r-n,a=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),l;switch(e.axis){case"z":l=new Be(0,0,1);break;case"y":l=new Be(0,1,0);break;default:case"x":l=new Be(1,0,0);break}let d=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,s=d.noiseType==="perlin";Ft.noiseSeed(d.seed);let c=Os((0,rn.default)(d.seed)),u=pi(d.strength,this.parameters.randomness);for(let[p,f]of this.children.entries()){let m=p*(d.freqScale/10)+d.movement,h=s?Ft.noise(m):c(m,m);f.scale.x=e.scale[0]+u(p,fA(h,d.scale[0]))||me,f.scale.y=e.scale[1]+u(p,fA(h,d.scale[1]))||me,f.scale.z=e.scale[2]+u(p,fA(h,d.scale[2]))||me,f.position.setScalar(0);let y=i/A.count*p-r;switch(e.axis){case"x":f.rotation.set(0,y,0);break;case"y":f.rotation.set(0,0,y);break;case"z":f.rotation.set(y,0,0);break}f.translateOnAxis(l,e.radius),f.position.x+=e.position[0]+u(p,fA(h,d.position[0])),f.position.y+=e.position[1]+u(p,fA(h,d.position[1])),f.position.z+=e.position[2]+u(p,fA(h,d.position[2]));let x=u(p,fA(h,d.rotation[0])),S=u(p,fA(h,d.rotation[1])),v=u(p,fA(h,d.rotation[2]));e.alignment===!0?(f.rotation.x+=a.x+x,f.rotation.y+=a.y+S,f.rotation.z+=a.z+v):f.rotation.set(a.x+x,a.y+S,a.z+v)}}_updateLinear(A){if(A.type!=="linear")throw new Error;let e=A.linear,r=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let a=Os((0,rn.default)(n.seed)),l=pi(n.strength,this.parameters.randomness);for(let[d,s]of this.children.entries()){let c=d*(n.freqScale/10)+n.movement,u=i?Ft.noise(c):a(c,c),p=l(d,fA(u,n.rotation[0])),f=l(d,fA(u,n.rotation[1])),m=l(d,fA(u,n.rotation[2]));s.scale.x=1+(e.scale[0]-1)*d+l(d,fA(u,n.scale[0]))||me,s.scale.y=1+(e.scale[1]-1)*d+l(d,fA(u,n.scale[1]))||me,s.scale.z=1+(e.scale[2]-1)*d+l(d,fA(u,n.scale[2]))||me,s.rotation.x=r.x*d+p,s.rotation.y=r.y*d+f,s.rotation.z=r.z*d+m,s.position.x=e.position[0]*d+l(d,fA(u,n.position[0])),s.position.y=e.position[1]*d+l(d,fA(u,n.position[1])),s.position.z=e.position[2]*d+l(d,fA(u,n.position[2]))}}_updateGrid(A){let e=0,r=A.grid,n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=pi(n.strength,this.parameters.randomness),a=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let l=Jp((0,rn.default)(n.seed));if(r.useCenter===!0){let d={x:r.count[0]%2===0?2:1,y:r.count[1]%2===0?2:1,z:r.count[2]%2===0?2:1},s=new Be(r.size[0]*(r.count[0]-d.x)*.5,r.size[1]*(r.count[1]-d.y)*.5,r.size[2]*(r.count[2]-d.z)*.5);for(let c=0;c<r.count[0];c++)for(let u=0;u<r.count[1];u++)for(let p=0;p<r.count[2];p++){let f=[(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement],m=a?Ft.noise(...f):l(...f),h=this.children[e++];h.scale.x=1+i(e,fA(m,n.scale[0]))||me,h.scale.y=1+i(e,fA(m,n.scale[1]))||me,h.scale.z=1+i(e,fA(m,n.scale[2]))||me;let y=i(e,fA(m,n.rotation[0])),x=i(e,fA(m,n.rotation[1])),S=i(e,fA(m,n.rotation[2]));h.rotation.set(y,x,S),h.position.x=r.size[0]*c-s.x+i(e,fA(m,n.position[0])),h.position.y=r.size[1]*u-s.y+i(e,fA(m,n.position[1])),h.position.z=r.size[2]*p-s.z+i(e,fA(m,n.position[2]))}}else for(let d=0;d<r.count[0];d++)for(let s=0;s<r.count[1];s++)for(let c=0;c<r.count[2];c++){let u=[(d+1)*(n.freqScale/10)+n.movement,(s+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement],p=a?Ft.noise(...u):l(...u),f=this.children[e++];f.scale.x=1+i(e,fA(p,n.scale[0]))||me,f.scale.y=1+i(e,fA(p,n.scale[1]))||me,f.scale.z=1+i(e,fA(p,n.scale[2]))||me;let m=i(e,fA(p,n.rotation[0])),h=i(e,fA(p,n.rotation[1])),y=i(e,fA(p,n.rotation[2]));f.rotation.set(m,h,y),f.position.x=r.size[0]*d+i(e,fA(p,n.position[0])),f.position.y=-r.size[1]*s+i(e,fA(p,n.position[1])),f.position.z=-r.size[2]*c+i(e,fA(p,n.position[2]))}}_updateToObject(A){if(A.type!=="toObject")throw new Error;let{toObject:e}=A,r=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let a=Os((0,rn.default)(n.seed)),l=pi(n.strength,this.parameters.randomness);if(!e.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof tn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;let d=this.getSubdivData(),s=[],c=y=>{let x=y.length,S=y.map(P=>P[0]).reduce((P,w)=>P+w,0),v=y.map(P=>P[1]).reduce((P,w)=>P+w,0),b=y.map(P=>P[2]).reduce((P,w)=>P+w,0);return[S/x,v/x,b/x]},u=y=>Math.round(y*1e6)/1e6;d.forEach(y=>{let x=d.filter(S=>u(y.pos[0])===u(S.pos[0])&&u(y.pos[1])===u(S.pos[1])&&u(y.pos[2])===u(S.pos[2]));x.length>1?s.push({pos:y.pos,norm:c(x.map(S=>S.norm))}):s.push(y)});let p=Xm(s);if(d.length>0){let y=Math.round(p.length*e.count/100);this._updateCount(y)}this.objectForSample.updateMatrixWorld();let f=new Ps(this.objectForSample).build(),m=Qm[e.axis],h=this.children;f.setRandomGenerator((0,rn.default)(this.object.uuid+e.seed));for(let[y,x]of h.entries()){let S=y*(n.freqScale/10)+n.movement,v=i?Ft.noise(S):a(S,S),b=l(y,fA(v,n.rotation[0])),P=l(y,fA(v,n.rotation[1])),w=l(y,fA(v,n.rotation[2]));e.spreadType==="random"?f.sample(fi,xc):(p.length&&(fi.fromArray(p[y].pos),xc.fromArray(p[y].norm)),this.objectForSample instanceof jr&&fi.applyMatrix4(yO.copy(this.objectForSample.matrixWorld).invert())),fi.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(fi),dr.fromArray(m);let g=e.align==="normal"?xc:this.object.getWorldDirection(vO),N=Ur.fromArray(e.position);Ur.x+=Ur.x+l(y,fA(v,n.position[0])),Ur.y+=Ur.y+l(y,fA(v,n.position[1])),Ur.z+=Ur.z+l(y,fA(v,n.position[2]));let O=Math.acos(g.dot(dr)),C=xO.crossVectors(dr,g).normalize(),T=gO.makeRotationAxis(C,O),L=g.clone().cross(this.object.up).normalize(),M=L.clone().cross(g).normalize(),U=new kr().makeBasis(L,g,M),X=new Be(dr.y,dr.z,dr.x).normalize(),eA=X.clone().cross(dr).normalize(),nA=new kr().makeBasis(X,dr,eA).invert(),k=new kr().multiplyMatrices(U,nA);x.rotation.setFromRotationMatrix(k),N.applyMatrix4(T),x.position.add(N),x.rotation.x=x.rotation.x+r.x+b,x.rotation.y=x.rotation.y+r.y+P,x.rotation.z=x.rotation.z+r.z+w,x.scale.setScalar(1),x.scale.x=x.scale.x+e.scale[0]+l(y,fA(v,n.scale[0]))||me,x.scale.y=x.scale.y+e.scale[1]+l(y,fA(v,n.scale[1]))||me,x.scale.z=x.scale.z+e.scale[2]+l(y,fA(v,n.scale[2]))||me,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let A=this.parameters.toObject.spreadType;if(A==="random")return[];if(this.objectForSample instanceof jr){let e=this.objectForSample,r=Ym[A],n=sh[r],i=nh[r],a=ih[r],l=[],d=n(e.subdivPointerNew);for(let s=0;s<=d-1;s++){let c=i(e.subdivPointerNew,s),u=a(e.subdivPointerNew,s);rh.fromArray(c).applyMatrix4(e.matrixWorld),oh.fromArray(u),l.push({pos:rh.toArray(),norm:oh.toArray()})}return l}else return(this.objectForSample.geometry.index?Km(this.objectForSample.geometry):Zm(this.objectForSample.geometry)).map((r,n)=>A==="polygon_center"?{pos:r.midpoint,norm:r.norm}:A==="vertex"?[{pos:r.vertices[0],norm:r.norm},{pos:r.vertices[1],norm:r.norm},{pos:r.vertices[2],norm:r.norm}]:A==="edge"?[{pos:r.faceCenters[0],norm:r.norm},{pos:r.faceCenters[1],norm:r.norm},{pos:r.faceCenters[2],norm:r.norm}]:[]).flat()}updateState(A,e){if(this.parameters=Tr(A),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=e.find(this.parameters.toObject.object);r instanceof oe?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new kr,this.hiddenMatrix=new kr,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{HemisphereLight as lP,Scene as cP,Vector3 as dP,Fog as uP,Box3 as pP,MeshBasicMaterial as fP}from"three";import{Camera as MO,OrthographicCamera as BO,PerspectiveCamera as DO,Vector3 as rt,Object3D as dh,Quaternion as GO}from"three";import{Camera as PO,LineSegments as NO,BufferGeometry as CO,LineBasicMaterial as IO,Color as bc,Vector3 as LO,Float32BufferAttribute as lh}from"three";import{BoxGeometry as bO}from"three";var Ot=o=>{var t;return t=class extends o{},t.geometryHelper=new bO(30,30,30),t};import{Ray as SO,Sphere as wO,Matrix4 as TO,Vector3 as zt}from"three";var aa=new SO,vc=new wO,ah=new TO,Pt=(o,t,A,e,r=!1)=>{let n=t,i=o.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),vc.copy(n.boundingSphere),vc.applyMatrix4(i),A.ray.intersectsSphere(vc)===!1||(ah.copy(i).invert(),aa.copy(A.ray).applyMatrix4(ah),n.boundingBox!==null&&aa.intersectsBox(n.boundingBox)===!1))return;let a,l,d,s,c=n.index,u=n.attributes.position,p=n.drawRange,f,m;if(r===!1){let y=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(f=y,m=x;f<m;f+=3)if(l=c.getX(f),d=c.getX(f+1),s=c.getX(f+2),a=h(o,A,aa,u,l,d,s),a){a.faceIndex=Math.floor(f/3),e.push(a);return}}else{let x=n.attributes.position,S=new zt,v=new zt,b=new zt,P=new zt,w=2,N=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=N*N,C=Math.max(0,p.start),T=Math.min(x.count,p.start+p.count);for(let L=C,M=T-1;L<M;L+=w){if(S.fromBufferAttribute(x,L),v.fromBufferAttribute(x,L+1),aa.distanceSqToSegment(S,v,P,b)>O)continue;P.applyMatrix4(o.matrixWorld);let X=A.ray.origin.distanceTo(P);X<A.near||X>A.far||e.push({distance:X,point:b.clone().applyMatrix4(o.matrixWorld),object:o})}}function h(y,x,S,v,b,P,w){let g=new zt,N=new zt,O=new zt,C=new zt,T=new zt;if(g.fromBufferAttribute(v,b),N.fromBufferAttribute(v,P),O.fromBufferAttribute(v,w),S.intersectTriangle(g,N,O,!1,C)===null)return null;T.copy(C),T.applyMatrix4(y.matrixWorld);let M=x.ray.origin.distanceTo(T);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:T.clone(),object:y}}};var la=new LO,ke=new PO,Sc=class extends NO{constructor(A){let e=new CO,r=new IO({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},l=new bc(15711266),d=new bc(15711266),s=new bc(2857471);c("n1","n2",l),c("n2","n4",l),c("n4","n3",l),c("n3","n1",l),c("f1","f2",l),c("f2","f4",l),c("f4","f3",l),c("f3","f1",l),c("n1","f1",l),c("n2","f2",l),c("n3","f3",l),c("n4","f4",l),c("p","n1",d),c("p","n2",d),c("p","n3",d),c("p","n4",d),c("u1","u2",s),c("u2","u3",s),c("u3","u1",s);function c(p,f,m){u(p,m),u(f,m)}function u(p,f){n.push(0,0,0),i.push(f.r,f.g,f.b),a[p]===void 0&&(a[p]=[]),a[p].push(n.length/3-1)}e.setAttribute("position",new lh(n,3)),e.setAttribute("color",new lh(i,3));super(e,r);this.type="CameraHelper",this.camera=A,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let A=this.geometry,e=this.pointMap,r=!0;ke.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,i=1,a=r?.8:1e-4;tt("n1",e,A,ke,-n,-i,a),tt("n2",e,A,ke,n,-i,a),tt("n3",e,A,ke,-n,i,a),tt("n4",e,A,ke,n,i,a);let l=a;tt("f1",e,A,ke,-n,-i,l),tt("f2",e,A,ke,n,-i,l),tt("f3",e,A,ke,-n,i,l),tt("f4",e,A,ke,n,i,l);let d=l,s=.5;tt("u1",e,A,ke,n*.7*s,i*1.1,d),tt("u2",e,A,ke,-n*.7*s,i*1.1,d),tt("u3",e,A,ke,0,i*(1.1+.9*s),d),A.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function tt(o,t,A,e,r,n,i){la.set(r,n,i).unproject(e);let a=t[o];if(a!==void 0){let l=A.getAttribute("position");for(let d=0,s=a.length;d<s;d++)l.setXYZ(a[d],la.x,la.y,la.z)}}var ca=class extends Ot(Sc){constructor(A){super(A);this.object=A;this.object=A,this.name=`CombinedCameraHelper: ${A.uuid}`}updateMatrixWorld(A){super.updateMatrixWorld(A),this.updateTarget()}updateTarget(){let A=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(A)}raycast(A,e){Pt(this.object,this.geometry,A,e,!0)}};import{Box3Helper as ch,BoxGeometry as EO}from"three";var da;(t=>t.is=A=>"objectHelper"in A)(da||(da={}));var ur=(o,t)=>class extends Cs(o){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(r,n){this.objectHelper.raycast(r,n)}showGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof ch&&(n.visible=!0)}}updateEntityBoxSize(r,n){this.objectHelper.visible&&this.geometryHelper instanceof EO?(r.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(r,n)}hideGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof ch&&(n.visible=!1)}}};var nn=new rt,wc=new rt,Ut=class extends ur(MO,ca){constructor(A="",e={...Ao.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=gr.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(A,e),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let r=this.width,n=this.height;this.orthoCamera=new BO(r*-.5,r*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new DO(45,r/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(A){this.perspCamera.fov=A}get fov(){return this.perspCamera.fov}setNear(A,e){A==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(A,e){e>=0&&(A==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(A){A==="PerspectiveCamera"?this.toPerspective():A==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(A){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=A:this.orthoCamera.near=A}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(A){A>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=A:this.orthoCamera.zoom=A)}lookAt(A){super.lookAt(A),this.getWorldPosition(nn),this.targetOffset=nn.distanceTo(A)}getTarget(A=new rt){return this.getWorldDirection(wc),this.getWorldPosition(nn),wc.multiplyScalar(this.targetOffset),A.copy(nn).add(wc),A}getDistanceToTarget(){let A=this.getTarget();return this.getWorldPosition(nn),nn.distanceTo(A)}updateUp(){let A=this.getWorldQuaternion(new GO),e=new rt(0,0,1).applyQuaternion(A),r=new rt().copy(dh.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(A);let n=new rt().copy(dh.DefaultUp).projectOnPlane(e),i=new rt().crossVectors(n,r).dot(e)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*i}updateTransformState(A){let e=super.updateTransformState(A);return A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateUp(),e}getViewFrontToObject(A){let e=A.getWorldPosition(new rt),n=A.getWorldDirection(new rt).multiplyScalar(this.targetOffset);return{position:e.clone().add(n),target:e}}getViewToObject(A){let e=A.getWorldPosition(new rt),n=this.getWorldDirection(new rt).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}setViewplaneSize(A,e){this.left=-A*.5,this.right=A*.5,this.top=e*.5,this.bottom=-e*.5,this.aspect=A/e,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(A){this.perspCamera.setFocalLength(A),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(A,e,r,n,i,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(A,e,r,n,i,a):this.orthoCamera.setViewOffset(A,e,r,n,i,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,e){super.updateWorldMatrix(A,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(A,e){return super.copy(A,e),this.orthoCamera.copy(A.orthoCamera),this.perspCamera.copy(A.perspCamera),this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.bottom,this.far=A.far,this.view=A.view===null?null:Object.assign({},A.view),this._cameraType=A._cameraType,this.aspect=A.aspect,this.fov=A.fov,this.focus=A.focus,this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this.targetOffset=A.targetOffset,this.updateProjectionMatrix(),this}toCameraState(A=[]){let e={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Oo(e,A)}updateCameraSubtype(A,e){let r=A==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(r,e.zoom),e.near!==void 0&&this.setNear(r,e.near),e.fov!==void 0&&r==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(A){this.updateCameraState(A)}updateCameraState(A){this.updateState_Entity(A,{}),A.far!==void 0&&(this.far=A.far),A.orthographic!==void 0&&this.updateCameraSubtype("orthographic",A.orthographic),A.perspective!==void 0&&this.updateCameraSubtype("perspective",A.perspective),A.type!==void 0&&(this.cameraType=A.type),A.up!==void 0&&this.up.fromArray(A.up),A.targetOffset!==void 0&&(this.targetOffset=A.targetOffset),A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.type===0&&this.updateCameraSubtype(A.path[0],A.props)}toState(A){return{...super.toState(A),...this.toCameraState(A),type:this.cameraType}}};import{BufferGeometry as uh,Float16BufferAttribute as RO,Matrix4 as VO}from"three";var ph=new VO;var He=class extends et{constructor(A,e,r){super(A,e);this.data=e;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new uh;this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&A.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(A,e=!0){if(this.booleanMeshSetAddress!==-1)return;for(let n=0;n<this.children.length;n++){let i=this.children[n];i instanceof He&&i.recomputeBoolean(A===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let i=this.children[n];if(i instanceof oe&&i.dataPatched.visible===!0&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if((i.geometry.index??i.geometry.getAttribute("position")).count/3<15e5&&(i.booleanMeshSetAddress=Je.getMeshSet(i.geometry,A===!0,e)),i.booleanMeshSetAddress===-1)return;Je.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else i instanceof He&&i.needsTransformForDownstream===!0?(Je.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(ph.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),Je.transformMeshSet(i.booleanMeshSetAddress,ph),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new RO([],0)),this.geometry.setDrawRange(0,0);return}if(A===!0)return Je.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new uh,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Je.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,$o(this),An(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as jO}from"three";var fh;(t=>{function o(A){return GA.is(A)&&A instanceof jO}t.is=o})(fh||(fh={}));var sn=(o,t)=>class extends ur(o,t){updateState_Light(e,r){this.updateState_Entity(e,r),e.color!==void 0&&(this.color=r.shared.color(e.color)),e.intensity!==void 0&&(this.intensity=e.intensity),e.depth!==void 0&&(this.shadow.camera.far=e.depth,this.shadow.needsUpdate=!0),e.shadows!==void 0&&(this.castShadow=e.shadows)}};var mi=o=>o instanceof oe,hi=o=>o!==null&&o instanceof He,mh=o=>o instanceof Ut;var hh=o=>da.is(o);import{Group as zO}from"three";import{AxesHelper as FO}from"three";var pr=class extends Ot(FO){constructor(A,e=15){super(e);this.object=A;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${A.uuid}`,this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1}raycast(A,e){Pt(this.object,pr.geometryHelper,A,e)}update(){}};var yi=class extends ur(zO,pr){constructor(t,A){super(),this.super_Entity(t,A),this.objectHelper.update()}updateState(t,A){this.updateState_Entity(t,A)}};import{DirectionalLight as qO,CameraHelper as yh}from"three";import{DirectionalLightHelper as UO}from"three";var an=class extends Ot(UO){constructor(A,e=15,r=10066329){super(A,e,r);this.object=A;this.added=!1;this.name=`DirectionalLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,an.geometryHelper,A,e)}};import{PointLightHelper as kO}from"three";var ln=class extends Ot(kO){constructor(A,e=15,r=6710886){super(A,e,r);this.object=A;this.name=`PointLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,ln.geometryHelper,A,e)}};import{SpotLightHelper as HO,Vector3 as WO}from"three";var ua=class extends Ot(HO){constructor(A,e=6710886){super(A,e);this.object=A;this.name=`SpotLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,ua.geometryHelper,A,e)}update(){if(this.object!==void 0){let A=ua._vector,e=this.object.distance?this.object.distance:1e3,r=e*Math.tan(this.object.angle);this.cone.scale.set(r,r,e),A.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(A);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let i=0,a=this.cone.material.length;i<a;i++)this.cone.material[i].color.set(n);else this.cone.material.color.set(n)}}},gi=ua;gi._vector=new WO;function QO(o,t){o.shadow.camera.right=t/2,o.shadow.camera.left=-t/2,o.shadow.camera.top=t/2,o.shadow.camera.bottom=-t/2,o.shadow.needsUpdate=!0}var pa=class extends sn(qO,an){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let i=new yh(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof yh&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A);let e=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&QO(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e&&this.update()}};import{PointLight as YO,Vector3 as fa,Box3 as XO,Box3Helper as gh,Color as KO}from"three";var ma=class extends sn(YO,ln){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let i=new fa(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new fa(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new XO(i,a),d=new gh(l,new KO(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let A=this.gizmos[t];if(A instanceof gh){let e=this.shadow.camera,r=new fa(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),n=new fa(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);A.box.set(r,n),A.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};import{SpotLight as ZO,CameraHelper as xh,MathUtils as JO,Vector3 as wh,Quaternion as _O}from"three";var vh=new wh,bh=new wh,Sh=new _O,ha=class extends sn(ZO,gi){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=JO.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let i=new xh(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof xh&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),bh.setFromMatrixPosition(this.matrixWorld),Sh.setFromRotationMatrix(this.matrixWorld),vh.copy(this.up).applyQuaternion(Sh).negate().multiplyScalar(this.distance),this.target.position.copy(bh).add(vh),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ya=class extends fe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}constructor(t,A,e){super(t,A,e)}updateEntityBoxSize(t,A){let e=this.geometry.getAttribute("position");e!==void 0?kl(e,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:e.count,t,A):super.updateEntityBoxSize(t,A)}};import{Group as $O}from"three";var kt=class extends ur($O,pr){constructor(A,e,r){super();e.type==="Instance"&&typeof A=="string"&&(e=this.transformAssignData(e,r)),this.super_Entity(A,e),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(A,e){let r=e.scene.data.objects.get(A.component);if(r){let n,i;for(let a of Zt.rootOverrideProps)A[a]===void 0?(n===void 0&&(n={...A}),n[a]=r.data[a]):(i===void 0&&(i={}),i[a]=A[a]);return this.overrideData=i,n??A}return A}updateByOp(A,e,r,n){let i;if(this.isInstanceRoot&&!n&&(e=this.transformAssignData(e,r),A.type===0&&A.path.length===0&&this.component))for(let a of Zt.rootOverrideProps)a in A.props&&A.props[a]===void 0&&(i===void 0&&(i={...A,props:{...A.props}}),i.props[a]=this.component.data[a]);super.updateByOp(i??A,e,r,n)}updateState(A,e){this.updateState_Entity(A,e)}expandInstanceChildren(A){let e=this.data;if(this.component===void 0){this.component=A.scene.find(e.component)??null;let r=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let n=0;for(let i of this.children)if(GA.is(i))A.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),ga(i),n+=1;else break;this.children.splice(0,n)}r=!0}this.component&&Oh(A,[this.uuid],e.overrides,this,this.component,this.component,0,r),this.oldComponent=this.component}}};function ga(o){if(o.component){let t=o.component.instances.indexOf(o);t>=0&&o.component.instances.splice(t,1);for(let A of o.children)GA.is(A)&&ga(A)}}function Th(o,t,A,e){return o.component===t&&Sn(o.identity,e)?o.overrideData===A?2:1:0}function Oh(o,t,A,e,r,n,i,a){if(i>50)return!1;if(e.component!==r){if(e.component){let d=e.component.instances.indexOf(e);d>=0&&e.component.instances.splice(d,1)}r.instances.push(e),e.component=r}r instanceof kt&&r.isInstanceRoot&&r.expandInstanceChildren(o);let l=0;for(let d of r.children)if(GA.is(d)){let s=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],c=eo.resolve(A,s,1),u=null,p;if(!a){let f=e.children[l];if(u=GA.is(f)?f:null,u!==null){let m=Th(u,d,c,s);p=m>=1?u.stateSelection:void 0,m!==2&&(u=null)}if(u===null&&(u=o.scene.findInstance(s)??null,u!==null)){let m=Th(u,d,c,s);if(p=m>=1?u.stateSelection:void 0,m!==2)u=null;else{let h=u.parent.children.indexOf(u);u.parent.children.splice(h,1),e.children.splice(l,0,u),u.parent===e?(h<=l&&console.error("not possible"),void 0):(u.parent=e,u.matrixWorldNeedsUpdate=!0,u.resetBBoxNeedsUpdate(),u.updateVisible(),o.pendingDeletes.delete(u),void 0)}}}if(u===null){let f=c?Ct.apply(d.data,c):d.data;qe.is(f.type)&&(f={...f,type:"Empty"}),u=Ye.createEntity(s,f,o),u.overrideData=c,e.add(u),e.children.splice(e.children.length-1,1),e.children.splice(l,0,u),u.updateState(u.data,o),p&&u.changeSelectedState(p,o),o.scene.registerInstanceAndSetUuid(u)}l+=1,Oh(o,t,A,u,d,n,i+1,a)}if(!a){let d=l;for(;;){let s=e.children[l];if(GA.is(s))o.pendingDeletes.add(s);else break;l+=1}e.children.splice(d,l-d)}return!0}function AP(o,t,A){let e;return t.geometry.type==="TextGeometry"?new tn(o,t,A):(t.geometry.type==="SubdivGeometry"?e=new jr(o,t,A):t.geometry.type==="VectorGeometry"?e=new ya(o,t,A):t.geometry.type==="BooleanGeometry"?e=new He(o,t,A):e=new fe(o,t,A),e)}function xa(o,t,A){return t.type==="Mesh"?AP(o,t,A):t.type==="Empty"?new yi(o,t):t.type==="PointLight"?new ma(o,t,A):t.type==="SpotLight"?new ha(o,t,A):t.type==="DirectionalLight"?new pa(o,t,A):t.type==="Component"||t.type==="Instance"?new kt(o,t,A):qe.is(t.type)?new Ut(o,t):(console.error(t),new yi(o,t))}Ye.createEntity=xa;function eP(o,t,A){let e=xa(o.identity,t,A),r=o.children,n=o.parent,i=o.component,a=o.instances,l=o.overrideData,d=o.uuid,s=o.stateSelection;o.dispose();for(let c of Object.keys(o))delete o[c];Object.setPrototypeOf(o,Object.getPrototypeOf(e));for(let c of Object.keys(e))o[c]=e[c];o.children=[...o.children,...r],o.parent=n,o.component=i,o.instances=a,o.uuid=d,o.overrideData=l,o.updateState(o.data,A),s&&o.changeSelectedState(s,A),o.resetBBoxNeedsUpdate()}Ye.changeEntityProptotype=eP;Ye.Cloner=on;function Ph(o,t,A,e){o.updateByOp(t,A,e,!1)}import{Matrix4 as rP,Ray as oP,Raycaster as nP}from"three";function Nh(o,t){let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(o.layers.set(8),e.length>0&&o.layers.enable(3),A=!0,An(o),$o(o)),e.length===0&&r.length===0&&o.layers.set(0),A}function Ch(o,t){if(!t.layers)return!1;let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return e.length>0&&(o.layers.set(3),r.length>0&&o.layers.enable(8),A=!0),e.length===0&&r.length===0&&o.layers.set(0),A}function Ih(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof et)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Nh(A,A.material[e])&&(t=!0);else Nh(A,A.material)&&(t=!0)}),t}function Lh(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof et)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Ch(A,A.material[e])&&(t=!0);else Ch(A,A.material)&&(t=!0)}),t}var iP=new nP,sP=new rP,aP=new oP;function Eh(o,t,A){let e=o.cloner;if(e)for(let r of e.children){let n=sP.copy(r.matrixWorld).invert(),i=aP.copy(t.ray).applyMatrix4(n),a=o.matrixWorld;i.applyMatrix4(a);let l=iP;l.set(i.origin,i.direction),l.near=t.near,l.far=t.far,l.intersectObject(o,!1).length>0&&A.push({object:o})}}var mP=new fP;mP.wireframe=!0;var Mh=new dP,Tc=class extends cP{constructor(A,e){super();this.data=A;this.backupFog=new uP(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new YA(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new lP(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=A.postprocessing,this.init(A,e),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Lh(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ih(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(A){let e=A.identity.join("-"),r=this.entityIdentityToEntity[e];r&&(A.uuid=r.uuid),this.entityIdentityToEntity[e]=A,this.entityByUuid[A.uuid]=A}findInstance(A){return this.entityIdentityToEntity[A.join("-")]}getWithSortKey(A){let e=this.find(A);if(e===void 0)return;let r=[],n=e;for(;n!==this;){let i=n;n=n.parent;let a=n.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(A){let e=[];for(let r of A){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>hd(r.sortKey,n.sortKey)),e.map(r=>r.entity)}nonExistOrDescendantOf(A,e){let r=this.find(A);if(r===void 0)return!0;for(;r;){if(r.uuid===e)return!0;r=r.parent}return!1}find(A){if(A===""||A===void 0)return;let e=this.entityByUuid[A];return e===void 0?this.getObjectByProperty("uuid",A):e}debugEnsureEntity(A){let e=this.find(A);if(e){if(Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(A){this.toExpandCloner.add(A)}addPendingUpdateCloner(A){this.toUpdateCloner.add(A)}markToExpandCloner(A){this.toExpandCloner.add(A),A.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(){this.toExpandCloner.forEach(A=>{A.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(A=>{A.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(A,e){if(A.path.length===0&&A.type===7){let r=A.parent===null?this:this.find(A.parent);if(r===void 0)throw new Error("unexpected");let n=this.createObject(A.id,A.data,A.children,r,A.localIndex,e);n.updateVisible(),n.resetBBoxNeedsUpdate(),mi(n)&&hi(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n)}else if(A.path.length===0&&A.type===8){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(r),r.parent.remove(r),hi(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),mi(r)&&(r.freeBooleanPointer(),n instanceof He&&n.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r)}else if(A.path.length===0&&A.type===9){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let i=A.parent===null?this:this.find(A.parent);if(i===void 0)throw new Error("unexpected");i.add(r),this.markNeedsRecomputeInstancesForAncessors(i),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate();let a=A.localIndex;i.children.splice(a,0,i.children.pop()),mi(r)&&(r.invalidateUpstreamBooleanData(),hi(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof He&&n.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(A,e,r,n){if(e.type===0&&(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),e.path.includes("overrides")&&"states"in e.props)){let{states:a,rest:l}=e.props;e={...e,props:l},this.markNeedsRecomputeInstances()}let i=this.find(A);if(i)try{Ph(i,e,r,{scene:this,shared:n}),i instanceof fe&&i.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(A){this.fog=A===!0?this.backupFog:null}init(A,e){if(this.createChildrenObjects(A.objects,this,e),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(pe(A.backgroundColor,e)),this.updateFog(A.fog,e),this.updateAmbientLight(A.environment.ambientLight,e),this.activeCamera=this.personalCamera,A.publish.playCamera!==null){let r=this.find(A.publish.playCamera);r instanceof Ut&&this.switchActiveCamera(r)}this.expandInstances(e,!0),this.traverseEntity(r=>{hi(r)&&r.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(A){A.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(A){GA.is(A)&&(A.data.type==="Component"&&this.markNeedsRecomputeInstances(),A.traverseAncestors(e=>{GA.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(A,e,r,n,i){if(A.data.type==="Transition"){let a=A.data.object;a&&a!==e.uuid&&e.find(a)&&r.forInstancesRec(d=>{d.isInstanceRoot||(d.data=Kr(d.data,s=>{let c=s.events.data(i.id),u=d.goUp(n);if(u){let p=[...Ki(u.identity),A.data.object].join("-"),f=this.entityIdentityToEntity[p];if(f){let m=f.uuid;c.actions.data(A.id).object=m}else{if(_t)debugger;console.warn("cannot find instance")}}}).data)})}}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(A=>{if(A instanceof kt&&typeof A.identity=="string"&&A.data.type==="Component")return A.traverseEntity((e,r)=>{e.data.events.forEach(n=>{n.data.type==="GameControl"?e.forInstancesRec(i=>{i.isInstanceRoot||(i.data=Kr(i.data,a=>{a.events.delete(n.id)}).data)}):"actions"in n.data&&n.data.actions.forEach(i=>{this.relativeizeInner(i,A,e,r,n)})})}),!0})}expandInstances(A,e){let r=new Set;this.traverseEntity(n=>{if(n instanceof kt&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:A,pendingDeletes:r}),e||n.resetBBoxNeedsUpdate(),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),ga(n)}recomputeInstances(A){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{e instanceof kt&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(A,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(A){A.traverseEntity(e=>{let r=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[r]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[r]),e.dispose()})}clearScene(){for(let A of this.children)Xe(A)&&A.disposeRecursively();this.children.length=0}resetAfterClear(A,e){this.init(A,e)}createPersonalCamera(){let A=new Ut(Tc.PERSONAL_CAMERA_ID,{...Ao.defaultData,name:"Personal Camera"});return A.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(A),A}raycast(A){let e=[],r=n=>{for(let i of n.children)Xe(i)&&!i.raycastLock&&i.visible&&((mi(i)||hh(i)&&this.enableHelpers&&i.objectHelper.visible)&&(A.intersectObject(i,!1,e),Eh(i,A,e)),r(i))};return r(this),e}forEachEntity(A){for(let e of this.children)Xe(e)&&A(e)}traverseEntity(A){for(let e of this.children)Xe(e)&&e.traverseEntity(A)}traverseObject(A){for(let e of this.children)Pn.is(e)&&e.traverseObject(A)}traverseVisibleEntity(A){for(let e of this.children)Xe(e)&&e.visible&&e.traverseVisibleEntity(A)}updateFog(A,e){this.enableFog=A.enabled,this.fogUseBGColor=A.useBackgroundColor,A.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=pe(A.color,e),this.backupFog.near=A.near,this.backupFog.far=A.far}dispose(){this.clearScene()}updateAmbientLight(A,e){A.color!==void 0&&(this.ambientLight.color=pe(A.color,e)),A.intensity!==void 0&&(this.ambientLight.intensity=A.intensity),A.groundColor!==void 0&&(this.ambientLight.groundColor=pe(A.groundColor,e)),A.enabled!==void 0&&(this.ambientLight.visible=A.enabled)}switchActiveCamera(A){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=A,A.objectHelper.visible=!1}setBackgroundColor(A){this.bgColor=A,this.fogUseBGColor===!0&&(this.backupFog.color=A)}createChildrenObjects(A,e,r){let n=0;for(let i of A)this.createObject(i.id,i.data,i.children,e,n,r),n+=1}registerObjectCreatedInLegacy(A){this.entityByUuid[A.uuid]=A}unregisterObject(A){delete this.entityByUuid[A.uuid];for(let e of A.children)this.unregisterObject(e)}createObject(A,e,r,n,i,a){let l={scene:this,shared:a},d=xa(A,e,l);return d&&(this.entityByUuid[A]=d,n.add(d),n.children.splice(i,0,n.children.pop()),r.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,d,a)),d.updateState(e,l),d instanceof fe&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d)),d}getCenter(A){let e=[];for(let n=0,i=A.length;n<i;++n){let{id:a,recursive:l}=A[n],d=this.find(a),s=l?d.recursiveBBox:d.singleBBox;e.push(...s.vertices)}let r=new pP;return r.setFromPoints(e),r.getCenter(Mh),Mh}copyMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A);r?e.copy(r.matrixWorld):e.identity()}copyParentMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A)?.parent;r?e.copy(r.matrixWorld):e.identity()}traverseMaterial(A){this.traverseEntity(e=>{if(e instanceof oe)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)e.material[r]instanceof Oe&&A(e.material[r]);else e.material instanceof Oe&&A(e.material)})}updateCanvasSize(A,e){this.activeCamera.setViewplaneSize(A,e);let r,n;A>=e?(r=e/A,n=1):(r=1,n=A/e),this.traverseMaterial(i=>{i.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=r,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},vi=Tc;vi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as hP}from"three/examples/jsm/loaders/DRACOLoader.js";var fr;function yP(){return fr||(fr=new hP,fr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fr.decoderPending}async function gP(o){if(fr){let t={attributeIDs:fr.defaultAttributeIDs,attributeTypes:fr.defaultAttributeTypes,useUniqueIDs:!1},A;try{A=await fr.decodeGeometry(new Int8Array(o).buffer,t)}catch(e){console.error(e)}if(A)return{index:A.index?{array:A.index.array}:void 0,attributes:Object.entries(A.attributes).map(([e,r])=>({name:e,itemSize:r.itemSize,array:r.array}))}}return null}async function Bh(o,t){let[A,e]=La(ki.deserialize(new Uint8Array(o)));Yp(A);let r=[];A.scene.objects.traverse((n,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&i.geometry.data.draco!==void 0&&r.push(i)}),r.length&&await yP();for(let n of r){let i=await gP(KA(n.geometry.data.draco));if(i){i.index&&(n.geometry.data.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:l,array:d,itemSize:s})=>{a[l]={array:d,itemSize:s,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(A),e.result().data}import{Mesh as BX}from"three";import{mergeBufferGeometries as RX}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Dh(o){let t;if(!!o.index)for(let A=0;A<o.index.array.length;A+=3)t=o.index.array[A],o.index.array[A]=o.index.array[A+2],o.index.array[A+2]=t}import{Color as Gh,ShaderLib as xP}from"three";function Rh(o){let t=new Set;return o.traverse(A=>{if(A instanceof et)if(VA(A.material))A.material.forEach(e=>{let r=e;t.has(r)||t.add(r)});else{let e=A.material;t.has(e)||t.add(e)}}),t.forEach(A=>{if(A instanceof Array)return;let e=A.onBeforeCompile.bind(A);if(vP(A)){Object.assign(A,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Gh,specularColor:new Gh});let r=0;A.onBeforeCompile=(n,i)=>{e&&e(n,i),n.uniforms=Object.assign({},xP.physical.uniforms,n.uniforms),A.getLayersOfType("transmission").forEach(a=>{if(n.uniforms.transmissionSamplerMap.value){let l=a.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value)}else r++,r<2&&(A.needsUpdate=!0)})}}else bP(A)||(A.onBeforeCompile=(r,n)=>{e&&e(r,n),A.transparent=!1})}),o}function vP(o){return o.getLayersOfType("transmission").length>0}function bP(o){let t=0;return o.layers.forEach(A=>{if(A.type!=="light"&&A.type!=="fresnel"){let e=A.uniforms["f"+A.id+"_alpha"];e&&(t+=(1-t)*e.value)}}),t<1}function Vh(o){return o.traverse(t=>{if(t.type==="Camera"){let A=t;A.type=A.cameraType}}),o}function jh(o){let t=[],A=(e,r=0)=>{let n=r>0?e+r:e;return t.includes(n)?A(e,r+1):n};return o.traverse(e=>{if(t.includes(e.name)){let r=e.name,n=A(e.name);if(e.name=n,e.isMesh){let i=e;i.material instanceof Array?i.material.forEach(a=>{a.name=a.name.replace(r,n)}):i.material.isAsset||(i.material.name=i.material.name.replace(r,n))}}t.push(e.name)}),o}import{mergeBufferGeometries as SP}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Fh(o){let t=[];return o.traverse(A=>{A instanceof on&&t.push(A)}),t.forEach(A=>{let e=A.object,n=A.children.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Dh(l),l}),i=SP(A.parameters.hideBase?n:[e instanceof oe?e.geometry:[],...n]);e instanceof oe&&(e.geometry=i),A.removeFromParent(),e.setFromClonerState(null,{scene:o,shared:km})}),o}function zh(o){return o.traverse(t=>{t.matrixAutoUpdate=!0}),o}function Uh(o){Object.values(o.shared.materials).forEach(t=>{Oc(t)}),o.scene.objects.traverse((t,A)=>{"material"in A?Oc(A.material):"materials"in A&&A.materials.forEach(e=>{Oc(e)})})}function Oc(o){if(typeof o=="string")return;let t=[];o.layers.forEach((A,e)=>{A.type==="outline"&&t.push(e)}),t.reverse().forEach(A=>{o.layers.delete(A)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var kh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Pc=class extends TP{load(t,A,e,r=console.error){let n=new wP(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(kh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(kh),n.load(t,async i=>{try{if(typeof i=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(i);A(a)}catch(a){r(a)}},e,r)}async parse(t){let A=await Bh(t,Uh);eh(A)&&await zm();let e=new Vr(A.shared);Object.values(e.getMaterials()).forEach(i=>Object.assign(i,{isAsset:!0}));let r=new vi(A.scene,e);r.remove(r.personalCamera),A.scene.environment.ambientLight.enabled||r.remove(r.ambientLight);let n=A.scene.publish.playCamera;if(n){let i=r.find(n);i&&mh(i)&&Object.assign(i,{makeDefault:!0})}return r=Fh(r),r=Rh(r),r=Vh(r),r=jh(r),r=zh(r),r}};export{Pc as default};
|
|
1338
|
+
`)>=0&&(t-=n),e===3?A*.5-t*.5:e===2?A-t:0}getLineInitialOffsetY(t,A,e,r,n){let i=A*t,a=Math.abs(this.ascender-this.descender)*r,l=t-a,d=-this.ascender*r-l/2;return n===3?-(e-i-d):n===2?-(e*.5-i*.5-d):d}createPath(t,A,e,r,n){let i=t.getPath(e,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new ra,l=(t.advanceWidth??1)*A;if(t)for(let d of i.commands){let s=a.currentPath?.currentPoint;if(!(s&&d.type!=="Z"&&s.x===d.x&&-s.y===d.y))switch(d.type){case"M":a.moveTo(d.x,-d.y);break;case"L":a.lineTo(d.x,-d.y);break;case"Q":a.quadraticCurveTo(d.x1,-d.y1,d.x,-d.y);break;case"C":a.bezierCurveTo(d.x1,-d.y1,d.x2,-d.y2,d.x,-d.y);break}}return a.subPaths.forEach(d=>{let s=JT(d.curves);s!==void 0&&d.currentPoint.distanceTo(s)>0&&d.lineTo(s.x,s.y)}),{offsetX:l+n.fontSize*n.letterSpacing,path:a}}getCharWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}getTextWidth(t,A){return this.font?.getAdvanceWidth(t,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing})??0}computeSpaceWidthForLine(t,A,e){let r=this.getCharWidth(" ",e),n=t[A];if(n){let i=this.countSpaces(n.trimEnd());if(e.horizontalAlign===4&&A<t.length-1&&i){let a=e.width,l=this.getTextWidth(n,e);return(a-(l-i*r))/i}}return r}countSpaces(t){return(t.match(/ /g)||[]).length}};function JT(o){if(o.length){let t=o[0];if(t instanceof XT)return t.v1;if(t instanceof YT||t instanceof KT)return t.v0}}var uc=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,A){let e=this.objects.get(t);return e===void 0?(e=this.createObject(t,A),this.objects.set(t,e)):e.isShared=!0,e}mutateIfUnique(t,A){let e=this.objects.get(t);if(e&&e.isShared!==!0)return this.objects.delete(t),this.objects.set(A,e),e}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,A){let e=this.objects.get(t);A===e?this.unreachable.delete(t):_t&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},di=class extends uc{constructor(A){super();this.flatShading=A}disposeObject(A){A.dispose()}createObject(A,e){let r=Cr(A,e,this.flatShading);return r.computeBoundingSphere(),r}};var Um={find(o){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(o){},addPendingUpdateCloner(o){}};var pc=class extends $s{constructor(A){super();this.shared=A}create(A){return new Zo(A,this.shared)}},Vr=class{constructor(t,A={}){this.geometryCache=new di(!0);this.geometryCache2=new di(!1);this.imageHolderCache=new pc(this);this.thisContext={scene:Um,shared:this};this.deletedMaterial=new Dr(xe.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new ze(Ts.emptyImage,this);this.deletedVideo=new ze(Jr.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(A.images)for(let[e,r]of Object.entries(A.images))this.addImage(e,r);if(A.videos)for(let[e,r]of Object.entries(A.videos))this.addVideo(e,r);if(A.audios)for(let[e,r]of Object.entries(A.audios))this.addAudio(e,r.data);this.reset(t)}setRequestRender(t){this._requestRender=t}reset(t){for(let[A,e]of Object.entries(t.images))this.addImage(A,e);for(let[A,e]of Object.entries(t.videos))this.addVideo(A,e);for(let[A,e]of Object.entries(t.colors))this.addColor(A,e);for(let[A,e]of Object.entries(t.materials))this.addMaterial(A,new Dr(e,this.thisContext));for(let[A,e]of Object.entries(t.audios))this.addAudio(A,e.data);for(let[A,e]of Object.entries(t.fonts))this.addFont(A,e);this.penumbraSize=t.penumbraSize}addMaterial(t,A){A.uuid=t,this.materials[t]=A}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let A=this.materials[t];return A}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new _o(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,A){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(A.data),!0):(this.images[t]=new ze(A,this),!1)}deleteImage(t){let A=this.images[t];A&&(A.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,A){return this.videos[t]?(this.videos[t].updateSrc(A.data),!0):(this.videos[t]=new ze(A,this),!1)}deleteVideo(t){let A=this.videos[t];A&&(A.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,A){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in A?this.colors[t].setRGBA(A.r,A.g,A.b,A.a):this.colors[t].setRGBA(A.r,A.g,A.b,1),!0):("a"in A?this.colors[t]=new lr(A.r,A.g,A.b,A.a):this.colors[t]=new lr(A.r,A.g,A.b,1),!1)}updateColor(t,A){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let e=this.colors[t];return this.colors[t].r=A.r??e.r,this.colors[t].g=A.g??e.g,this.colors[t].b=A.b??e.b,this.colors[t].a=A.a??e.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let A;if(typeof t=="string"){let e=this.getColor(t);e?A=e:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),A=new YA(0,0,0,0))}else return"a"in t?new YA(t.r,t.g,t.b,t.a):new YA(t.r,t.g,t.b,1);return A}addAudio(t,A){this.audios[t]=A}getAudio(t){let A=this.audios[t];if(A instanceof Gr)return A;{let e=new Gr({src:A});return this.audios[t]=e,e}}deleteAudio(t){let A=this.audios[t];A&&(A instanceof Gr&&A.dispose(),delete this.audios[t])}addFont(t,A){this.fonts[t]=new oa(A),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(A=>this.deleteMaterial(A)),this._requestRender=void 0,Object.values(this.audios).forEach(A=>{A instanceof Gr&&A.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},km=new Vr(Zi.emptyData());var et=class extends oe{updateByPatchedOp(A,e,r){if(super.updateByPatchedOp(A,e,r),Rc(A.path,["materials"])!==null&&A.type===0&&Array.isArray(this.material))for(let[n,i]of Object.entries(A.props)){let a=r.shared.material(i);this.material[Number(n)]=a}else if(it(A.path,["material"])&&this.material instanceof Oe)"material"in e&&typeof e.material!="string"&&this.material.updateByOp(te.drop(A,1),e.material,r);else if(it(A.path,["materials","*"])&&Array.isArray(this.material)){let n=A.path[1];if("materials"in e&&n<this.material.length){let i=e.materials[n];typeof i!="string"&&this.material[n].updateByOp(te.drop(A,2),i,r)}}}updateState(A,e){super.updateState(A,e),A.castShadow!==void 0&&(this.castShadow=A.castShadow),A.receiveShadow!==void 0&&(this.receiveShadow=A.receiveShadow);let r=this.dataPatched;if(A.geometry?.type!=="NonParametricGeometry"&&"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene?.markNeedsUpdateRendererDirty()),A.geometry?.type==="NonParametricGeometry"&&("materials"in A&&A.materials!==void 0?(this.disposeMaterial(),this.material=A.materials.map(n=>e.shared.material(n).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene?.markNeedsUpdateRendererDirty()):"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(A.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene?.markNeedsUpdateRendererDirty())),A.flatShading!==void 0||A.wireframe!==void 0||A.side!==void 0)if(Array.isArray(this.material))for(let n=0;n<this.material.length;n++)this.material[n]=this.material[n].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe)}disposeMaterial(){this.material&&Ki(this.material).forEach(A=>{A instanceof Oe&&(A instanceof Dr||A.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as _T}from"three";var fe=class extends et{constructor(A,e,r){super(A,e);this.data=e;this.localGeometry=void 0}chooseGeoemtryCache(A){return A.geometryCache}markGeometryAsReachable(A){this.geometryCreateDeleyed instanceof _T&&this.chooseGeoemtryCache(A).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Vr){let A=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(A);this.geometryCreateDeleyed=e.get(this.dataPatched.geometry,A)}return this.geometryCreateDeleyed}set geometry(A){this.localGeometry=A}get is2DAndNoDepth(){let A=this.dataPatched.geometry;return yn.is2DParametricMesh(A.type)&&A.depth===0}get is2DType(){return yn.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),it(A.path,["geometry"])&&this.updateByPatchedOpGeometry(te.drop(A,1),e.geometry,r)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(A,e){this.invalidateDownstreamBooleanData();let r=this.data.geometry.type;if(r==="NonParametricGeometry"||r==="SubdivGeometry"){let n=A;if(this.localGeometry===void 0){let s={...this.data.geometry,...n};this.localGeometry=Cr(s,e,this.data.flatShading)}let i,a,l;n.scaleBaked?[i,a,l]=n.scaleBaked:{width:i,height:a,depth:l}=n;let d=this.localGeometry.userData;d.sxPrev!==void 0&&Fn(this.localGeometry.attributes,i/d.sxPrev,a/d.syPrev,l/d.szPrev),d.sxPrev=i,d.syPrev=a,d.szPrev=l}else{let n={...this.data.geometry,...A};this.localGeometry?.dispose(),this.localGeometry=Cr(n,e,this.data.flatShading)}}refreshAttachedCloners(A){for(let e of this.attachedSurfaceCloners)A.scene.addPendingUpdateCloner(e.object)}createGeometryDelayed(A){this.geometryCreateDeleyed=A.shared,this.refreshAttachedCloners(A)}updateByPatchedOpGeometry(A,e,r){let n=!1;A.type===0&&A.path.length===0&&Sn(["scaleBaked"],Object.keys(A.props))&&this.geometryCreateDeleyed instanceof zA&&this.chooseGeoemtryCache(r.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,A.props.scaleBaked),this.refreshAttachedCloners(r)),n||(r.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(r)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(A,e){this.createGeometryDelayed(e)}updateState(A,e){A.geometry!==void 0&&this.updateGeometryOnStateUpdate(A.geometry,e),super.updateState(A,e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;this.is2DType?A.set(0,0,r.depth*.5):A.setScalar(0),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}};function AO(o){if(o.geometry.attributes.extrudeNormal||!o.geometry.attributes.position||!o.geometry.attributes.normal)return;let t=new Map,A=o.geometry.attributes.position.array,e=o.geometry.attributes.normal.array,r=new Float32Array(A.length);for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=new mc(e[n],e[n+1],e[n+2]);t.has(i)?t.get(i)?.normals.push(a):t.set(i,{normals:[a],result:new mc})}t.forEach((n,i)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<A.length;n+=3){let i=`${A[n]}_${A[n+1]}_${A[n+2]}`,a=t.get(i)?.result;a&&(r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z)}o.geometry.setAttribute("extrudeNormal",new Hm(r,3))}function eO(o){if(o.geometry.attributes.extrudeNormals||!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=new mc;for(let r=0;r<t.length;r+=3)e.set(t[r],t[r+1],t[r+2]).normalize(),A[r]=e.x,A[r+1]=e.y,A[r+2]=e.z;o.geometry.setAttribute("extrudeNormal",new Hm(A,3))}function $o(o){if(Array.isArray(o.material)){for(let t of o.material)if(t.getLayersOfType("outline").length===0)return}else if(!(o.material instanceof Oe)||o.material.getLayersOfType("outline").length===0)return;o instanceof fe&&o.is2DAndNoDepth?eO(o):AO(o)}function An(o){if(!o.geometry.attributes.position)return;let t=o.geometry.attributes.position.array,A=new Float32Array(t.length),e=parseInt(o.uuid.replace(/\D/g,"")),r=[fc.seededRandom(e),fc.seededRandom(e+1e4),fc.seededRandom(e+2e4)];for(let n=0;n<t.length;n++)A[n]=r[n%3];o.geometry.setAttribute("randomColor",new $T(A,3))}var nO;zo.then(o=>{nO=o});var wt=new tO,ui=new oO;var jr=class extends fe{constructor(A,e,r){super(A,e,r);this.data=e;this.hiddenMatrixOld=new rO;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(A){return this.dataPatched.flatShading?A.geometryCache:A.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(A,e){let r=this.geometry.userData.parameters;A.copy(this.originalGeometryNew.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)}createGeometryByControls(A){if(this.skipReactionUpdate===!0)return;let e=this.localGeometry?.uuid,{originalGeometry:r,subdividedGeometry:n,subdivPointer:i}=zA.build(A,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=i,r!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=r),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,$o(this),An(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}updateState(A,e){if(super.updateState(A,e),A.flatShading!==void 0){let r=this.material;this.material=r.getFlavor(!1,r.side,r.wireframe),this.smoothShading=!A.flatShading,this.createGeometryDelayed(e)}}updateMesh(A=!1){zA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zA.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zA.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(A,e){let r=this.localGeometry;this.localGeometry=this.originalGeometryNew,oe.prototype.raycast.call(this,A,e),this.localGeometry=r}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new Wm,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let e=A.attributes.position,r=A.boundingSphere.center;wt.setFromBufferAttribute(e),wt.getCenter(r),A.boundingSphere.radius=r.distanceTo(wt.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),wt.getSize(ui),this.hasNonUniformScale&&ui.divide(this.scale);let n={width:ui.x,height:ui.y,depth:ui.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(A){let e=this.originalGeometry;wt.min.set(A[0],A[2],A[4]),wt.max.set(A[1],A[3],A[5]),this.hasNonUniformScale&&(wt.min.applyMatrix4(this.shearScaleInv),wt.max.applyMatrix4(this.shearScaleInv)),e.boundingSphere===null&&(e.boundingSphere=new Wm);let r=e.boundingSphere.center;wt.getCenter(r),e.boundingSphere.radius=r.distanceTo(wt.max)}freeSubdivPointer(){this.subdivPointer&&(zA.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(A,e,r){super.updateByPatchedOpGeometry(A,e,r),this.localGeometry&&this.createGeometryByControls(e)}};import{Triangle as iO,Vector3 as zr}from"three";var qm=-1,sO=1,Qm={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Ym={polygon_center:0,edge:1,vertex:2},pi=(o,t)=>(A,e)=>!t||A===0||o===0?0:o*e/100,fA=(o,t)=>{let A=Math.abs(t),e=A*-1;return(o-qm)*(A-e)/(sO-qm)+e};function Xm(o){let t=[],A={};for(var e=0,r=o.length;e<r;e++){var n=JSON.stringify(o[e].pos.map(i=>Math.round(i*1e4)/1e4));A[n]||(t.push(o[e]),A[n]=!0)}return t}var aO=new zr,na=new zr,lO=new zr,cO=new zr;function en(o,t){let A=lO.fromArray(o),e=cO.fromArray(t);na.copy(e).sub(A);let r=na.length();return na.normalize().multiplyScalar(r*.5),aO.copy(A).add(na).toArray()}var Ue=new iO,ia=new zr,sa=new zr,Fr=new zr;function Km(o){let t=[];for(let A=0;A<=o.index.count;A++)if(ia.fromArray(o.index.array,A*3),Ue.setFromAttributeAndIndices(o.attributes.position,ia.x,ia.y,ia.z),Ue.getNormal(sa),Ue.getMidpoint(Fr),!(isNaN(Fr.x)||isNaN(Fr.y)||isNaN(Fr.z))){let{a:e,b:r,c:n}=Ue,i=e.toArray(),a=r.toArray(),l=n.toArray(),d=e.distanceTo(r),s=r.distanceTo(n),c=n.distanceTo(e),u=en(i,a),p=en(a,l),f=en(l,i),m=[d,s,c],h=Math.max(...m),y=m.filter(v=>Math.round(v)===Math.round(h)).length>1,x=[],S=Ue.getMidpoint(Fr).toArray();h===d&&!y&&(x=[p,f,f],S=u),h===s&&!y&&(x=[u,f,f],S=p),h===c&&!y&&(x=[u,p,p],S=f),y&&(x=[u,p,f]),t.push({vertices:[i,a,l],faceCenters:x,midpoint:S,norm:Ue.getNormal(sa).toArray()})}return t}function Zm(o){let t=[],{position:A}=o.attributes;for(let e=0;e<A.count;e++){Ue.setFromAttributeAndIndices(A,e*3,e*3+1,e*3+2),Ue.getNormal(sa),Ue.getMidpoint(Fr);let r=Ue.a.toArray(),n=Ue.b.toArray(),i=Ue.c.toArray();t.push({vertices:[r,n,i],faceCenters:[en(r,n),en(n,i),en(i,r)],midpoint:Fr.toArray(),norm:sa.toArray()})}return t}var dO=4,uO=.5,hc=o=>.5*(1-Math.cos(o*Math.PI)),yc=class{constructor(){this.perlin=new Array(4095+1)}noise(t,A=0,e=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),A<0&&(A=-A),e<0&&(e=-e);let r=Math.floor(t),n=Math.floor(A),i=Math.floor(e),a=t-r,l=A-n,d=e-i,s,c,u=0,p=.5,f,m,h;for(let y=0;y<dO;y++){let x=r+(n<<4)+(i<<8);s=hc(a),c=hc(l),f=this.perlin[x&4095],f+=s*(this.perlin[x+1&4095]-f),m=this.perlin[x+16&4095],m+=s*(this.perlin[x+16+1&4095]-m),f+=c*(m-f),x+=256,m=this.perlin[x&4095],m+=s*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=s*(this.perlin[x+16+1&4095]-h),m+=c*(h-m),f+=hc(d)*(m-f),u+=f*p,p*=uO,r<<=1,a*=2,n<<=1,l*=2,i<<=1,d*=2,a>=1&&(r++,a--),l>=1&&(n++,l--),d>=1&&(i++,d--)}return u}noiseSeed(t){let A=(()=>{let i,a;return{setSeed(l){a=i=(l??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();A.setSeed(t),this.perlin=new Array(4095+1);for(let e=0;e<4095+1;e++)this.perlin[e]=A.rand()}},Jm=yc;import{Vector3 as pO,Matrix4 as fO,Ray as mO}from"three";var _m=new pO,$m=new fO,Ah=new mO;function eh(o){let t=!1;return o.scene.objects.traverse((A,e)=>{e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(t=!0)}),t}var tn=class extends fe{constructor(A,e,r){super(A,e,r);this.data=e}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let A=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,A.geometry.height,this.fontScale,A.geometry.verticalAlign)??0}get fontScale(){let A=this.dataPatched;return this.font?A.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let A=this.dataPatched;return A.geometry.fontSize*A.geometry.lineHeight}raycast(A,e){let{matrixWorld:r}=this;if($m.copy(r).invert(),Ah.copy(A.ray).applyMatrix4($m),Ah.intersectBox(this.singleBBox,_m)){let n=_m.applyMatrix4(r),i=A.ray.origin.distanceTo(n);e.push({distance:i,point:n.clone(),object:this})}}};var me=1e-4,Tt,nh,ih,sh,rh=new Be,oh=new Be;zo.then(o=>{Tt=o,nh=[Tt.get_face_center,Tt.get_edge_midpoint,Tt.get_vertex_position],ih=[Tt.get_face_normal,Tt.get_edge_normal,Tt.get_vertex_normal],sh=[Tt.face_count,Tt.edge_count,Tt.vertex_count]});var yO=new kr,gO=new kr,dr=new Be,Ur=new Be,fi=new Be,xc=new Be,xO=new Be,vO=new Be;var Ft=new Jm,on=class extends No(hO){constructor(A,e){super();this.parameters=e;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=A}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(A){if(this.parent===null)this.updateState(this.parameters,A);else for(let e of this.children)e instanceof Gt&&e.expand()}invalidateTransform(A){this.matrixWorldNeedsUpdate=!0,this.traverse(e=>{e instanceof Gt&&e.object===A&&(e.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let A of this.children)A.updateMatrix(),A.hasNonUniformScale&&(A.updateMatrixWorld(),A.updateMatrixWorldSVD())}_updateCount(A){let e;if(A!==void 0?e=A:e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(e=0),this.parameters.type==="toObject"&&this.objectForSample){for(let n=0,i=this.children.length;n<i;++n)this.remove(this.children[0]);let r=this.children;if(r.length===e)return;if(r.length<e)for(let n=0,i=e-r.length;n<i;++n){let a=new Gt(this.object);a.expand(),this.add(a)}else for(let n=0,i=r.length-e;n<i;++n)this.remove(r[n])}else{if(this.children.length===e)return;if(this.children.length<e)for(let r=0,n=e-this.children.length;r<n;++r){let i=new Gt(this.object);i.expand(),this.add(i)}else for(let r=0,n=this.children.length-e;r<n;++r)this.remove(this.children[0])}}_updateRadial(A){let e=A.radial,r=e.start*th.DEG2RAD,n=e.end*th.DEG2RAD,i=r-n,a=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),l;switch(e.axis){case"z":l=new Be(0,0,1);break;case"y":l=new Be(0,1,0);break;default:case"x":l=new Be(1,0,0);break}let d=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,s=d.noiseType==="perlin";Ft.noiseSeed(d.seed);let c=Os((0,rn.default)(d.seed)),u=pi(d.strength,this.parameters.randomness);for(let[p,f]of this.children.entries()){let m=p*(d.freqScale/10)+d.movement,h=s?Ft.noise(m):c(m,m);f.scale.x=e.scale[0]+u(p,fA(h,d.scale[0]))||me,f.scale.y=e.scale[1]+u(p,fA(h,d.scale[1]))||me,f.scale.z=e.scale[2]+u(p,fA(h,d.scale[2]))||me,f.position.setScalar(0);let y=i/A.count*p-r;switch(e.axis){case"x":f.rotation.set(0,y,0);break;case"y":f.rotation.set(0,0,y);break;case"z":f.rotation.set(y,0,0);break}f.translateOnAxis(l,e.radius),f.position.x+=e.position[0]+u(p,fA(h,d.position[0])),f.position.y+=e.position[1]+u(p,fA(h,d.position[1])),f.position.z+=e.position[2]+u(p,fA(h,d.position[2]));let x=u(p,fA(h,d.rotation[0])),S=u(p,fA(h,d.rotation[1])),v=u(p,fA(h,d.rotation[2]));e.alignment===!0?(f.rotation.x+=a.x+x,f.rotation.y+=a.y+S,f.rotation.z+=a.z+v):f.rotation.set(a.x+x,a.y+S,a.z+v)}}_updateLinear(A){if(A.type!=="linear")throw new Error;let e=A.linear,r=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let a=Os((0,rn.default)(n.seed)),l=pi(n.strength,this.parameters.randomness);for(let[d,s]of this.children.entries()){let c=d*(n.freqScale/10)+n.movement,u=i?Ft.noise(c):a(c,c),p=l(d,fA(u,n.rotation[0])),f=l(d,fA(u,n.rotation[1])),m=l(d,fA(u,n.rotation[2]));s.scale.x=1+(e.scale[0]-1)*d+l(d,fA(u,n.scale[0]))||me,s.scale.y=1+(e.scale[1]-1)*d+l(d,fA(u,n.scale[1]))||me,s.scale.z=1+(e.scale[2]-1)*d+l(d,fA(u,n.scale[2]))||me,s.rotation.x=r.x*d+p,s.rotation.y=r.y*d+f,s.rotation.z=r.z*d+m,s.position.x=e.position[0]*d+l(d,fA(u,n.position[0])),s.position.y=e.position[1]*d+l(d,fA(u,n.position[1])),s.position.z=e.position[2]*d+l(d,fA(u,n.position[2]))}}_updateGrid(A){let e=0,r=A.grid,n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=pi(n.strength,this.parameters.randomness),a=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let l=Jp((0,rn.default)(n.seed));if(r.useCenter===!0){let d={x:r.count[0]%2===0?2:1,y:r.count[1]%2===0?2:1,z:r.count[2]%2===0?2:1},s=new Be(r.size[0]*(r.count[0]-d.x)*.5,r.size[1]*(r.count[1]-d.y)*.5,r.size[2]*(r.count[2]-d.z)*.5);for(let c=0;c<r.count[0];c++)for(let u=0;u<r.count[1];u++)for(let p=0;p<r.count[2];p++){let f=[(c+1)*(n.freqScale/10)+n.movement,(u+1)*(n.freqScale/10)+n.movement,(p+1)*(n.freqScale/10)+n.movement],m=a?Ft.noise(...f):l(...f),h=this.children[e++];h.scale.x=1+i(e,fA(m,n.scale[0]))||me,h.scale.y=1+i(e,fA(m,n.scale[1]))||me,h.scale.z=1+i(e,fA(m,n.scale[2]))||me;let y=i(e,fA(m,n.rotation[0])),x=i(e,fA(m,n.rotation[1])),S=i(e,fA(m,n.rotation[2]));h.rotation.set(y,x,S),h.position.x=r.size[0]*c-s.x+i(e,fA(m,n.position[0])),h.position.y=r.size[1]*u-s.y+i(e,fA(m,n.position[1])),h.position.z=r.size[2]*p-s.z+i(e,fA(m,n.position[2]))}}else for(let d=0;d<r.count[0];d++)for(let s=0;s<r.count[1];s++)for(let c=0;c<r.count[2];c++){let u=[(d+1)*(n.freqScale/10)+n.movement,(s+1)*(n.freqScale/10)+n.movement,(c+1)*(n.freqScale/10)+n.movement],p=a?Ft.noise(...u):l(...u),f=this.children[e++];f.scale.x=1+i(e,fA(p,n.scale[0]))||me,f.scale.y=1+i(e,fA(p,n.scale[1]))||me,f.scale.z=1+i(e,fA(p,n.scale[2]))||me;let m=i(e,fA(p,n.rotation[0])),h=i(e,fA(p,n.rotation[1])),y=i(e,fA(p,n.rotation[2]));f.rotation.set(m,h,y),f.position.x=r.size[0]*d+i(e,fA(p,n.position[0])),f.position.y=-r.size[1]*s+i(e,fA(p,n.position[1])),f.position.z=-r.size[2]*c+i(e,fA(p,n.position[2]))}}_updateToObject(A){if(A.type!=="toObject")throw new Error;let{toObject:e}=A,r=new gc(e.rotation[0],e.rotation[1],e.rotation[2]),n=A.randomnessObject??dt.defaultData([1,1,1]).randomnessObject,i=n.noiseType==="perlin";Ft.noiseSeed(n.seed);let a=Os((0,rn.default)(n.seed)),l=pi(n.strength,this.parameters.randomness);if(!e.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof tn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;let d=this.getSubdivData(),s=[],c=y=>{let x=y.length,S=y.map(P=>P[0]).reduce((P,w)=>P+w,0),v=y.map(P=>P[1]).reduce((P,w)=>P+w,0),b=y.map(P=>P[2]).reduce((P,w)=>P+w,0);return[S/x,v/x,b/x]},u=y=>Math.round(y*1e6)/1e6;d.forEach(y=>{let x=d.filter(S=>u(y.pos[0])===u(S.pos[0])&&u(y.pos[1])===u(S.pos[1])&&u(y.pos[2])===u(S.pos[2]));x.length>1?s.push({pos:y.pos,norm:c(x.map(S=>S.norm))}):s.push(y)});let p=Xm(s);if(d.length>0){let y=Math.round(p.length*e.count/100);this._updateCount(y)}this.objectForSample.updateMatrixWorld();let f=new Ps(this.objectForSample).build(),m=Qm[e.axis],h=this.children;f.setRandomGenerator((0,rn.default)(this.object.uuid+e.seed));for(let[y,x]of h.entries()){let S=y*(n.freqScale/10)+n.movement,v=i?Ft.noise(S):a(S,S),b=l(y,fA(v,n.rotation[0])),P=l(y,fA(v,n.rotation[1])),w=l(y,fA(v,n.rotation[2]));e.spreadType==="random"?f.sample(fi,xc):(p.length&&(fi.fromArray(p[y].pos),xc.fromArray(p[y].norm)),this.objectForSample instanceof jr&&fi.applyMatrix4(yO.copy(this.objectForSample.matrixWorld).invert())),fi.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(fi),dr.fromArray(m);let g=e.align==="normal"?xc:this.object.getWorldDirection(vO),N=Ur.fromArray(e.position);Ur.x+=Ur.x+l(y,fA(v,n.position[0])),Ur.y+=Ur.y+l(y,fA(v,n.position[1])),Ur.z+=Ur.z+l(y,fA(v,n.position[2]));let O=Math.acos(g.dot(dr)),C=xO.crossVectors(dr,g).normalize(),T=gO.makeRotationAxis(C,O),L=g.clone().cross(this.object.up).normalize(),M=L.clone().cross(g).normalize(),U=new kr().makeBasis(L,g,M),X=new Be(dr.y,dr.z,dr.x).normalize(),eA=X.clone().cross(dr).normalize(),nA=new kr().makeBasis(X,dr,eA).invert(),k=new kr().multiplyMatrices(U,nA);x.rotation.setFromRotationMatrix(k),N.applyMatrix4(T),x.position.add(N),x.rotation.x=x.rotation.x+r.x+b,x.rotation.y=x.rotation.y+r.y+P,x.rotation.z=x.rotation.z+r.z+w,x.scale.setScalar(1),x.scale.x=x.scale.x+e.scale[0]+l(y,fA(v,n.scale[0]))||me,x.scale.y=x.scale.y+e.scale[1]+l(y,fA(v,n.scale[1]))||me,x.scale.z=x.scale.z+e.scale[2]+l(y,fA(v,n.scale[2]))||me,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let A=this.parameters.toObject.spreadType;if(A==="random")return[];if(this.objectForSample instanceof jr){let e=this.objectForSample,r=Ym[A],n=sh[r],i=nh[r],a=ih[r],l=[],d=n(e.subdivPointerNew);for(let s=0;s<=d-1;s++){let c=i(e.subdivPointerNew,s),u=a(e.subdivPointerNew,s);rh.fromArray(c).applyMatrix4(e.matrixWorld),oh.fromArray(u),l.push({pos:rh.toArray(),norm:oh.toArray()})}return l}else return(this.objectForSample.geometry.index?Km(this.objectForSample.geometry):Zm(this.objectForSample.geometry)).map((r,n)=>A==="polygon_center"?{pos:r.midpoint,norm:r.norm}:A==="vertex"?[{pos:r.vertices[0],norm:r.norm},{pos:r.vertices[1],norm:r.norm},{pos:r.vertices[2],norm:r.norm}]:A==="edge"?[{pos:r.faceCenters[0],norm:r.norm},{pos:r.faceCenters[1],norm:r.norm},{pos:r.faceCenters[2],norm:r.norm}]:[]).flat()}updateState(A,e){if(this.parameters=Tr(A),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=e.find(this.parameters.toObject.object);r instanceof oe?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new kr,this.hiddenMatrix=new kr,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{HemisphereLight as lP,Scene as cP,Vector3 as dP,Fog as uP,Box3 as pP,MeshBasicMaterial as fP}from"three";import{Camera as MO,OrthographicCamera as BO,PerspectiveCamera as DO,Vector3 as rt,Object3D as dh,Quaternion as GO}from"three";import{Camera as PO,LineSegments as NO,BufferGeometry as CO,LineBasicMaterial as IO,Color as bc,Vector3 as LO,Float32BufferAttribute as lh}from"three";import{BoxGeometry as bO}from"three";var Ot=o=>{var t;return t=class extends o{},t.geometryHelper=new bO(30,30,30),t};import{Ray as SO,Sphere as wO,Matrix4 as TO,Vector3 as zt}from"three";var aa=new SO,vc=new wO,ah=new TO,Pt=(o,t,A,e,r=!1)=>{let n=t,i=o.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),vc.copy(n.boundingSphere),vc.applyMatrix4(i),A.ray.intersectsSphere(vc)===!1||(ah.copy(i).invert(),aa.copy(A.ray).applyMatrix4(ah),n.boundingBox!==null&&aa.intersectsBox(n.boundingBox)===!1))return;let a,l,d,s,c=n.index,u=n.attributes.position,p=n.drawRange,f,m;if(r===!1){let y=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(f=y,m=x;f<m;f+=3)if(l=c.getX(f),d=c.getX(f+1),s=c.getX(f+2),a=h(o,A,aa,u,l,d,s),a){a.faceIndex=Math.floor(f/3),e.push(a);return}}else{let x=n.attributes.position,S=new zt,v=new zt,b=new zt,P=new zt,w=2,N=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=N*N,C=Math.max(0,p.start),T=Math.min(x.count,p.start+p.count);for(let L=C,M=T-1;L<M;L+=w){if(S.fromBufferAttribute(x,L),v.fromBufferAttribute(x,L+1),aa.distanceSqToSegment(S,v,P,b)>O)continue;P.applyMatrix4(o.matrixWorld);let X=A.ray.origin.distanceTo(P);X<A.near||X>A.far||e.push({distance:X,point:b.clone().applyMatrix4(o.matrixWorld),object:o})}}function h(y,x,S,v,b,P,w){let g=new zt,N=new zt,O=new zt,C=new zt,T=new zt;if(g.fromBufferAttribute(v,b),N.fromBufferAttribute(v,P),O.fromBufferAttribute(v,w),S.intersectTriangle(g,N,O,!1,C)===null)return null;T.copy(C),T.applyMatrix4(y.matrixWorld);let M=x.ray.origin.distanceTo(T);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:T.clone(),object:y}}};var la=new LO,ke=new PO,Sc=class extends NO{constructor(A){let e=new CO,r=new IO({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},l=new bc(15711266),d=new bc(15711266),s=new bc(2857471);c("n1","n2",l),c("n2","n4",l),c("n4","n3",l),c("n3","n1",l),c("f1","f2",l),c("f2","f4",l),c("f4","f3",l),c("f3","f1",l),c("n1","f1",l),c("n2","f2",l),c("n3","f3",l),c("n4","f4",l),c("p","n1",d),c("p","n2",d),c("p","n3",d),c("p","n4",d),c("u1","u2",s),c("u2","u3",s),c("u3","u1",s);function c(p,f,m){u(p,m),u(f,m)}function u(p,f){n.push(0,0,0),i.push(f.r,f.g,f.b),a[p]===void 0&&(a[p]=[]),a[p].push(n.length/3-1)}e.setAttribute("position",new lh(n,3)),e.setAttribute("color",new lh(i,3));super(e,r);this.type="CameraHelper",this.camera=A,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let A=this.geometry,e=this.pointMap,r=!0;ke.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,i=1,a=r?.8:1e-4;tt("n1",e,A,ke,-n,-i,a),tt("n2",e,A,ke,n,-i,a),tt("n3",e,A,ke,-n,i,a),tt("n4",e,A,ke,n,i,a);let l=a;tt("f1",e,A,ke,-n,-i,l),tt("f2",e,A,ke,n,-i,l),tt("f3",e,A,ke,-n,i,l),tt("f4",e,A,ke,n,i,l);let d=l,s=.5;tt("u1",e,A,ke,n*.7*s,i*1.1,d),tt("u2",e,A,ke,-n*.7*s,i*1.1,d),tt("u3",e,A,ke,0,i*(1.1+.9*s),d),A.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function tt(o,t,A,e,r,n,i){la.set(r,n,i).unproject(e);let a=t[o];if(a!==void 0){let l=A.getAttribute("position");for(let d=0,s=a.length;d<s;d++)l.setXYZ(a[d],la.x,la.y,la.z)}}var ca=class extends Ot(Sc){constructor(A){super(A);this.object=A;this.object=A,this.name=`CombinedCameraHelper: ${A.uuid}`}updateMatrixWorld(A){super.updateMatrixWorld(A),this.updateTarget()}updateTarget(){let A=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(A)}raycast(A,e){Pt(this.object,this.geometry,A,e,!0)}};import{Box3Helper as ch,BoxGeometry as EO}from"three";var da;(t=>t.is=A=>"objectHelper"in A)(da||(da={}));var ur=(o,t)=>class extends Cs(o){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(r,n){this.objectHelper.raycast(r,n)}showGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof ch&&(n.visible=!0)}}updateEntityBoxSize(r,n){this.objectHelper.visible&&this.geometryHelper instanceof EO?(r.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(r,n)}hideGizmos(){for(let r in this.gizmos){let n=this.gizmos[r];n instanceof ch&&(n.visible=!1)}}};var nn=new rt,wc=new rt,Ut=class extends ur(MO,ca){constructor(A="",e={...Ao.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=gr.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(A,e),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let r=this.width,n=this.height;this.orthoCamera=new BO(r*-.5,r*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new DO(45,r/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(A){this.perspCamera.fov=A}get fov(){return this.perspCamera.fov}setNear(A,e){A==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(A,e){e>=0&&(A==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(A){A==="PerspectiveCamera"?this.toPerspective():A==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(A){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=A:this.orthoCamera.near=A}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(A){A>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=A:this.orthoCamera.zoom=A)}lookAt(A){super.lookAt(A),this.getWorldPosition(nn),this.targetOffset=nn.distanceTo(A)}getTarget(A=new rt){return this.getWorldDirection(wc),this.getWorldPosition(nn),wc.multiplyScalar(this.targetOffset),A.copy(nn).add(wc),A}getDistanceToTarget(){let A=this.getTarget();return this.getWorldPosition(nn),nn.distanceTo(A)}updateUp(){let A=this.getWorldQuaternion(new GO),e=new rt(0,0,1).applyQuaternion(A),r=new rt().copy(dh.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(A);let n=new rt().copy(dh.DefaultUp).projectOnPlane(e),i=new rt().crossVectors(n,r).dot(e)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*i}updateTransformState(A){let e=super.updateTransformState(A);return A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateUp(),e}getViewFrontToObject(A){let e=A.getWorldPosition(new rt),n=A.getWorldDirection(new rt).multiplyScalar(this.targetOffset);return{position:e.clone().add(n),target:e}}getViewToObject(A){let e=A.getWorldPosition(new rt),n=this.getWorldDirection(new rt).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}setViewplaneSize(A,e){this.left=-A*.5,this.right=A*.5,this.top=e*.5,this.bottom=-e*.5,this.aspect=A/e,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(A){this.perspCamera.setFocalLength(A),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(A,e,r,n,i,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(A,e,r,n,i,a):this.orthoCamera.setViewOffset(A,e,r,n,i,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,e){super.updateWorldMatrix(A,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(A,e){return super.copy(A,e),this.orthoCamera.copy(A.orthoCamera),this.perspCamera.copy(A.perspCamera),this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.bottom,this.far=A.far,this.view=A.view===null?null:Object.assign({},A.view),this._cameraType=A._cameraType,this.aspect=A.aspect,this.fov=A.fov,this.focus=A.focus,this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this.targetOffset=A.targetOffset,this.updateProjectionMatrix(),this}toCameraState(A=[]){let e={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Oo(e,A)}updateCameraSubtype(A,e){let r=A==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(r,e.zoom),e.near!==void 0&&this.setNear(r,e.near),e.fov!==void 0&&r==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(A){this.updateCameraState(A)}updateCameraState(A){this.updateState_Entity(A,{}),A.far!==void 0&&(this.far=A.far),A.orthographic!==void 0&&this.updateCameraSubtype("orthographic",A.orthographic),A.perspective!==void 0&&this.updateCameraSubtype("perspective",A.perspective),A.type!==void 0&&(this.cameraType=A.type),A.up!==void 0&&this.up.fromArray(A.up),A.targetOffset!==void 0&&(this.targetOffset=A.targetOffset),A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.type===0&&this.updateCameraSubtype(A.path[0],A.props)}toState(A){return{...super.toState(A),...this.toCameraState(A),type:this.cameraType}}};import{BufferGeometry as uh,Float16BufferAttribute as RO,Matrix4 as VO}from"three";var ph=new VO;var He=class extends et{constructor(A,e,r){super(A,e);this.data=e;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new uh;this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(A,e,r){super.updateByPatchedOp(A,e,r),A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&A.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(A,e=!0){if(this.booleanMeshSetAddress!==-1&&!A)return;for(let n=0;n<this.children.length;n++){let i=this.children[n];i instanceof He&&i.recomputeBoolean(A===!0,e)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let i=this.children[n];if(i instanceof oe&&i.dataPatched.visible===!0&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if((i.geometry.index??i.geometry.getAttribute("position")).count/3<15e5&&(i.booleanMeshSetAddress=Je.getMeshSet(i.geometry,A===!0,e)),i.booleanMeshSetAddress===-1)return;Je.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else i instanceof He&&i.needsTransformForDownstream===!0?(Je.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(ph.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),Je.transformMeshSet(i.booleanMeshSetAddress,ph),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new RO([],0)),this.geometry.setDrawRange(0,0);return}if(A===!0)return Je.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new uh,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Je.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,$o(this),An(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as jO}from"three";var fh;(t=>{function o(A){return GA.is(A)&&A instanceof jO}t.is=o})(fh||(fh={}));var sn=(o,t)=>class extends ur(o,t){updateState_Light(e,r){this.updateState_Entity(e,r),e.color!==void 0&&(this.color=r.shared.color(e.color)),e.intensity!==void 0&&(this.intensity=e.intensity),e.depth!==void 0&&(this.shadow.camera.far=e.depth,this.shadow.needsUpdate=!0),e.shadows!==void 0&&(this.castShadow=e.shadows)}};var mi=o=>o instanceof oe,hi=o=>o!==null&&o instanceof He,mh=o=>o instanceof Ut;var hh=o=>da.is(o);import{Group as zO}from"three";import{AxesHelper as FO}from"three";var pr=class extends Ot(FO){constructor(A,e=15){super(e);this.object=A;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${A.uuid}`,this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1}raycast(A,e){Pt(this.object,pr.geometryHelper,A,e)}update(){}};var yi=class extends ur(zO,pr){constructor(t,A){super(),this.super_Entity(t,A),this.objectHelper.update()}updateState(t,A){this.updateState_Entity(t,A)}};import{DirectionalLight as qO,CameraHelper as yh}from"three";import{DirectionalLightHelper as UO}from"three";var an=class extends Ot(UO){constructor(A,e=15,r=10066329){super(A,e,r);this.object=A;this.added=!1;this.name=`DirectionalLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,an.geometryHelper,A,e)}};import{PointLightHelper as kO}from"three";var ln=class extends Ot(kO){constructor(A,e=15,r=6710886){super(A,e,r);this.object=A;this.name=`PointLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,ln.geometryHelper,A,e)}};import{SpotLightHelper as HO,Vector3 as WO}from"three";var ua=class extends Ot(HO){constructor(A,e=6710886){super(A,e);this.object=A;this.name=`SpotLightHelper: ${A.uuid}`}raycast(A,e){Pt(this.object,ua.geometryHelper,A,e)}update(){if(this.object!==void 0){let A=ua._vector,e=this.object.distance?this.object.distance:1e3,r=e*Math.tan(this.object.angle);this.cone.scale.set(r,r,e),A.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(A);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let i=0,a=this.cone.material.length;i<a;i++)this.cone.material[i].color.set(n);else this.cone.material.color.set(n)}}},gi=ua;gi._vector=new WO;function QO(o,t){o.shadow.camera.right=t/2,o.shadow.camera.left=-t/2,o.shadow.camera.top=t/2,o.shadow.camera.bottom=-t/2,o.shadow.needsUpdate=!0}var pa=class extends sn(qO,an){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let i=new yh(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof yh&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A);let e=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&QO(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e&&this.update()}};import{PointLight as YO,Vector3 as fa,Box3 as XO,Box3Helper as gh,Color as KO}from"three";var ma=class extends sn(YO,ln){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let i=new fa(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),a=new fa(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new XO(i,a),d=new gh(l,new KO(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let A=this.gizmos[t];if(A instanceof gh){let e=this.shadow.camera,r=new fa(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),n=new fa(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);A.box.set(r,n),A.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};import{SpotLight as ZO,CameraHelper as xh,MathUtils as JO,Vector3 as wh,Quaternion as _O}from"three";var vh=new wh,bh=new wh,Sh=new _O,ha=class extends sn(ZO,gi){constructor(t,A,e){super(),this.super_Entity(t,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=JO.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let i=new xh(this.shadow.camera);i.visible=!1,this.gizmos.shadowmap=i,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let A=this.gizmos[t];A instanceof xh&&A.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),bh.setFromMatrixPosition(this.matrixWorld),Sh.setFromRotationMatrix(this.matrixWorld),vh.copy(this.up).applyQuaternion(Sh).negate().multiplyScalar(this.distance),this.target.position.copy(bh).add(vh),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,A){this.updateState_Light(t,A),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ya=class extends fe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}constructor(t,A,e){super(t,A,e)}updateEntityBoxSize(t,A){let e=this.geometry.getAttribute("position");e!==void 0?kl(e,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:e.count,t,A):super.updateEntityBoxSize(t,A)}};import{Group as $O}from"three";var kt=class extends ur($O,pr){constructor(A,e,r){super();e.type==="Instance"&&typeof A=="string"&&(e=this.transformAssignData(e,r)),this.super_Entity(A,e),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(A,e){let r=e.scene.data.objects.get(A.component);if(r){let n,i;for(let a of Zt.rootOverrideProps)A[a]===void 0?(n===void 0&&(n={...A}),n[a]=r.data[a]):(i===void 0&&(i={}),i[a]=A[a]);return this.overrideData=i,n??A}return A}updateByOp(A,e,r,n){let i;if(this.isInstanceRoot&&!n&&(e=this.transformAssignData(e,r),A.type===0&&A.path.length===0&&this.component))for(let a of Zt.rootOverrideProps)a in A.props&&A.props[a]===void 0&&(i===void 0&&(i={...A,props:{...A.props}}),i.props[a]=this.component.data[a]);super.updateByOp(i??A,e,r,n)}updateState(A,e){this.updateState_Entity(A,e)}expandInstanceChildren(A){let e=this.data;if(this.component===void 0){this.component=A.scene.find(e.component)??null;let r=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let n=0;for(let i of this.children)if(GA.is(i))A.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),ga(i),n+=1;else break;this.children.splice(0,n)}r=!0}this.component&&Oh(A,[this.uuid],e.overrides,this,this.component,this.component,0,r),this.oldComponent=this.component}}};function ga(o){if(o.component){let t=o.component.instances.indexOf(o);t>=0&&o.component.instances.splice(t,1);for(let A of o.children)GA.is(A)&&ga(A)}}function Th(o,t,A,e){return o.component===t&&Sn(o.identity,e)?o.overrideData===A?2:1:0}function Oh(o,t,A,e,r,n,i,a){if(i>50)return!1;if(e.component!==r){if(e.component){let d=e.component.instances.indexOf(e);d>=0&&e.component.instances.splice(d,1)}r.instances.push(e),e.component=r}r instanceof kt&&r.isInstanceRoot&&r.expandInstanceChildren(o);let l=0;for(let d of r.children)if(GA.is(d)){let s=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],c=eo.resolve(A,s,1),u=null,p;if(!a){let f=e.children[l];if(u=GA.is(f)?f:null,u!==null){let m=Th(u,d,c,s);p=m>=1?u.stateSelection:void 0,m!==2&&(u=null)}if(u===null&&(u=o.scene.findInstance(s)??null,u!==null)){let m=Th(u,d,c,s);if(p=m>=1?u.stateSelection:void 0,m!==2)u=null;else{let h=u.parent.children.indexOf(u);u.parent.children.splice(h,1),e.children.splice(l,0,u),u.parent===e?(h<=l&&console.error("not possible"),void 0):(u.parent=e,u.matrixWorldNeedsUpdate=!0,u.resetBBoxNeedsUpdate(),u.updateVisible(),o.pendingDeletes.delete(u),void 0)}}}if(u===null){let f=c?Ct.apply(d.data,c):d.data;qe.is(f.type)&&(f={...f,type:"Empty"}),u=Ye.createEntity(s,f,o),u.overrideData=c,e.add(u),e.children.splice(e.children.length-1,1),e.children.splice(l,0,u),u.updateState(u.data,o),p&&u.changeSelectedState(p,o),o.scene.registerInstanceAndSetUuid(u)}l+=1,Oh(o,t,A,u,d,n,i+1,a)}if(!a){let d=l;for(;;){let s=e.children[l];if(GA.is(s))o.pendingDeletes.add(s);else break;l+=1}e.children.splice(d,l-d)}return!0}function AP(o,t,A){let e;return t.geometry.type==="TextGeometry"?new tn(o,t,A):(t.geometry.type==="SubdivGeometry"?e=new jr(o,t,A):t.geometry.type==="VectorGeometry"?e=new ya(o,t,A):t.geometry.type==="BooleanGeometry"?e=new He(o,t,A):e=new fe(o,t,A),e)}function xa(o,t,A){return t.type==="Mesh"?AP(o,t,A):t.type==="Empty"?new yi(o,t):t.type==="PointLight"?new ma(o,t,A):t.type==="SpotLight"?new ha(o,t,A):t.type==="DirectionalLight"?new pa(o,t,A):t.type==="Component"||t.type==="Instance"?new kt(o,t,A):qe.is(t.type)?new Ut(o,t):(console.error(t),new yi(o,t))}Ye.createEntity=xa;function eP(o,t,A){let e=xa(o.identity,t,A),r=o.children,n=o.parent,i=o.component,a=o.instances,l=o.overrideData,d=o.uuid,s=o.stateSelection;o.dispose();for(let c of Object.keys(o))delete o[c];Object.setPrototypeOf(o,Object.getPrototypeOf(e));for(let c of Object.keys(e))o[c]=e[c];o.children=[...o.children,...r],o.parent=n,o.component=i,o.instances=a,o.uuid=d,o.overrideData=l,o.updateState(o.data,A),s&&o.changeSelectedState(s,A),o.resetBBoxNeedsUpdate()}Ye.changeEntityProptotype=eP;Ye.Cloner=on;function Ph(o,t,A,e){o.updateByOp(t,A,e,!1)}import{Matrix4 as rP,Ray as oP,Raycaster as nP}from"three";function Nh(o,t){let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(o.layers.set(8),e.length>0&&o.layers.enable(3),A=!0,An(o),$o(o)),e.length===0&&r.length===0&&o.layers.set(0),A}function Ch(o,t){if(!t.layers)return!1;let A=!1,e=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return e.length>0&&(o.layers.set(3),r.length>0&&o.layers.enable(8),A=!0),e.length===0&&r.length===0&&o.layers.set(0),A}function Ih(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof et)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Nh(A,A.material[e])&&(t=!0);else Nh(A,A.material)&&(t=!0)}),t}function Lh(o){let t=!1;return o.traverseEntity(A=>{if(A instanceof et)if(Array.isArray(A.material))for(let e=0;e<A.material.length;e++)Ch(A,A.material[e])&&(t=!0);else Ch(A,A.material)&&(t=!0)}),t}var iP=new nP,sP=new rP,aP=new oP;function Eh(o,t,A){let e=o.cloner;if(e)for(let r of e.children){let n=sP.copy(r.matrixWorld).invert(),i=aP.copy(t.ray).applyMatrix4(n),a=o.matrixWorld;i.applyMatrix4(a);let l=iP;l.set(i.origin,i.direction),l.near=t.near,l.far=t.far,l.intersectObject(o,!1).length>0&&A.push({object:o})}}var mP=new fP;mP.wireframe=!0;var Mh=new dP,Tc=class extends cP{constructor(A,e){super();this.data=A;this.backupFog=new uP(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new YA(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new lP(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=A.postprocessing,this.init(A,e),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Lh(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ih(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(A){let e=A.identity.join("-"),r=this.entityIdentityToEntity[e];r&&(A.uuid=r.uuid),this.entityIdentityToEntity[e]=A,this.entityByUuid[A.uuid]=A}findInstance(A){return this.entityIdentityToEntity[A.join("-")]}getWithSortKey(A){let e=this.find(A);if(e===void 0)return;let r=[],n=e;for(;n!==this;){let i=n;n=n.parent;let a=n.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(A){let e=[];for(let r of A){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>hd(r.sortKey,n.sortKey)),e.map(r=>r.entity)}nonExistOrDescendantOf(A,e){let r=this.find(A);if(r===void 0)return!0;for(;r;){if(r.uuid===e)return!0;r=r.parent}return!1}find(A){if(A===""||A===void 0)return;let e=this.entityByUuid[A];return e===void 0?this.getObjectByProperty("uuid",A):e}debugEnsureEntity(A){let e=this.find(A);if(e){if(Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(A){this.toExpandCloner.add(A)}addPendingUpdateCloner(A){this.toUpdateCloner.add(A)}markToExpandCloner(A){this.toExpandCloner.add(A),A.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(){this.toExpandCloner.forEach(A=>{A.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(A=>{A.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(A,e){if(A.path.length===0&&A.type===7){let r=A.parent===null?this:this.find(A.parent);if(r===void 0)throw new Error("unexpected");let n=this.createObject(A.id,A.data,A.children,r,A.localIndex,e);n.updateVisible(),n.resetBBoxNeedsUpdate(),mi(n)&&hi(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n)}else if(A.path.length===0&&A.type===8){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(r),r.parent.remove(r),hi(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),mi(r)&&(r.freeBooleanPointer(),n instanceof He&&n.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r)}else if(A.path.length===0&&A.type===9){let r=this.find(A.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let n=r.parent;this.markNeedsRecomputeInstancesForAncessors(n),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let i=A.parent===null?this:this.find(A.parent);if(i===void 0)throw new Error("unexpected");i.add(r),this.markNeedsRecomputeInstancesForAncessors(i),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate();let a=A.localIndex;i.children.splice(a,0,i.children.pop()),mi(r)&&(r.invalidateUpstreamBooleanData(),hi(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof He&&n.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(A,e,r,n){if(e.type===0&&(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),e.path.includes("overrides")&&"states"in e.props)){let{states:a,rest:l}=e.props;e={...e,props:l},this.markNeedsRecomputeInstances()}let i=this.find(A);if(i)try{Ph(i,e,r,{scene:this,shared:n}),i instanceof fe&&i.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(A){this.fog=A===!0?this.backupFog:null}init(A,e){if(this.createChildrenObjects(A.objects,this,e),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(pe(A.backgroundColor,e)),this.updateFog(A.fog,e),this.updateAmbientLight(A.environment.ambientLight,e),this.activeCamera=this.personalCamera,A.publish.playCamera!==null){let r=this.find(A.publish.playCamera);r instanceof Ut&&this.switchActiveCamera(r)}this.expandInstances(e,!0),this.traverseEntity(r=>{hi(r)&&r.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(A){A.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(A){GA.is(A)&&(A.data.type==="Component"&&this.markNeedsRecomputeInstances(),A.traverseAncestors(e=>{GA.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(A,e,r,n,i){if(A.data.type==="Transition"){let a=A.data.object;a&&a!==e.uuid&&e.find(a)&&r.forInstancesRec(d=>{d.isInstanceRoot||(d.data=Kr(d.data,s=>{let c=s.events.data(i.id),u=d.goUp(n);if(u){let p=[...Ki(u.identity),A.data.object].join("-"),f=this.entityIdentityToEntity[p];if(f){let m=f.uuid;c.actions.data(A.id).object=m}else{if(_t)debugger;console.warn("cannot find instance")}}}).data)})}}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(A=>{if(A instanceof kt&&typeof A.identity=="string"&&A.data.type==="Component")return A.traverseEntity((e,r)=>{e.data.events.forEach(n=>{n.data.type==="GameControl"?e.forInstancesRec(i=>{i.isInstanceRoot||(i.data=Kr(i.data,a=>{a.events.delete(n.id)}).data)}):"actions"in n.data&&n.data.actions.forEach(i=>{this.relativeizeInner(i,A,e,r,n)})})}),!0})}expandInstances(A,e){let r=new Set;this.traverseEntity(n=>{if(n instanceof kt&&n.isInstanceRoot)return n.expandInstanceChildren({scene:this,shared:A,pendingDeletes:r}),e||n.resetBBoxNeedsUpdate(),!0});for(let n of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),ga(n)}recomputeInstances(A){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{e instanceof kt&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(A,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(A){A.traverseEntity(e=>{let r=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[r]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[r]),e.dispose()})}clearScene(){for(let A of this.children)Xe(A)&&A.disposeRecursively();this.children.length=0}resetAfterClear(A,e){this.init(A,e)}createPersonalCamera(){let A=new Ut(Tc.PERSONAL_CAMERA_ID,{...Ao.defaultData,name:"Personal Camera"});return A.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(A),A}raycast(A){let e=[],r=n=>{for(let i of n.children)Xe(i)&&!i.raycastLock&&i.visible&&((mi(i)||hh(i)&&this.enableHelpers&&i.objectHelper.visible)&&(A.intersectObject(i,!1,e),Eh(i,A,e)),r(i))};return r(this),e}forEachEntity(A){for(let e of this.children)Xe(e)&&A(e)}traverseEntity(A){for(let e of this.children)Xe(e)&&e.traverseEntity(A)}traverseObject(A){for(let e of this.children)Pn.is(e)&&e.traverseObject(A)}traverseVisibleEntity(A){for(let e of this.children)Xe(e)&&e.visible&&e.traverseVisibleEntity(A)}updateFog(A,e){this.enableFog=A.enabled,this.fogUseBGColor=A.useBackgroundColor,A.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=pe(A.color,e),this.backupFog.near=A.near,this.backupFog.far=A.far}dispose(){this.clearScene()}updateAmbientLight(A,e){A.color!==void 0&&(this.ambientLight.color=pe(A.color,e)),A.intensity!==void 0&&(this.ambientLight.intensity=A.intensity),A.groundColor!==void 0&&(this.ambientLight.groundColor=pe(A.groundColor,e)),A.enabled!==void 0&&(this.ambientLight.visible=A.enabled)}switchActiveCamera(A){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=A,A.objectHelper.visible=!1}setBackgroundColor(A){this.bgColor=A,this.fogUseBGColor===!0&&(this.backupFog.color=A)}createChildrenObjects(A,e,r){let n=0;for(let i of A)this.createObject(i.id,i.data,i.children,e,n,r),n+=1}registerObjectCreatedInLegacy(A){this.entityByUuid[A.uuid]=A}unregisterObject(A){delete this.entityByUuid[A.uuid];for(let e of A.children)this.unregisterObject(e)}createObject(A,e,r,n,i,a){let l={scene:this,shared:a},d=xa(A,e,l);return d&&(this.entityByUuid[A]=d,n.add(d),n.children.splice(i,0,n.children.pop()),r.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,d,a)),d.updateState(e,l),d instanceof fe&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d)),d}getCenter(A){let e=[];for(let n=0,i=A.length;n<i;++n){let{id:a,recursive:l}=A[n],d=this.find(a),s=l?d.recursiveBBox:d.singleBBox;e.push(...s.vertices)}let r=new pP;return r.setFromPoints(e),r.getCenter(Mh),Mh}copyMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A);r?e.copy(r.matrixWorld):e.identity()}copyParentMatrixWorld(A,e){if(A===null){e.identity();return}let r=this.find(A)?.parent;r?e.copy(r.matrixWorld):e.identity()}traverseMaterial(A){this.traverseEntity(e=>{if(e instanceof oe)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)e.material[r]instanceof Oe&&A(e.material[r]);else e.material instanceof Oe&&A(e.material)})}updateCanvasSize(A,e){this.activeCamera.setViewplaneSize(A,e);let r,n;A>=e?(r=e/A,n=1):(r=1,n=A/e),this.traverseMaterial(i=>{i.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=r,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},vi=Tc;vi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as hP}from"three/examples/jsm/loaders/DRACOLoader.js";var fr;function yP(){return fr||(fr=new hP,fr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fr.decoderPending}async function gP(o){if(fr){let t={attributeIDs:fr.defaultAttributeIDs,attributeTypes:fr.defaultAttributeTypes,useUniqueIDs:!1},A;try{A=await fr.decodeGeometry(new Int8Array(o).buffer,t)}catch(e){console.error(e)}if(A)return{index:A.index?{array:A.index.array}:void 0,attributes:Object.entries(A.attributes).map(([e,r])=>({name:e,itemSize:r.itemSize,array:r.array}))}}return null}async function Bh(o,t){let[A,e]=La(ki.deserialize(new Uint8Array(o)));Yp(A);let r=[];A.scene.objects.traverse((n,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&i.geometry.data.draco!==void 0&&r.push(i)}),r.length&&await yP();for(let n of r){let i=await gP(KA(n.geometry.data.draco));if(i){i.index&&(n.geometry.data.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:l,array:d,itemSize:s})=>{a[l]={array:d,itemSize:s,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(A),e.result().data}import{Mesh as BX}from"three";import{mergeBufferGeometries as RX}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Dh(o){let t;if(!!o.index)for(let A=0;A<o.index.array.length;A+=3)t=o.index.array[A],o.index.array[A]=o.index.array[A+2],o.index.array[A+2]=t}import{Color as Gh,ShaderLib as xP}from"three";function Rh(o){let t=new Set;return o.traverse(A=>{if(A instanceof et)if(VA(A.material))A.material.forEach(e=>{let r=e;t.has(r)||t.add(r)});else{let e=A.material;t.has(e)||t.add(e)}}),t.forEach(A=>{if(A instanceof Array)return;let e=A.onBeforeCompile.bind(A);if(vP(A)){Object.assign(A,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Gh,specularColor:new Gh});let r=0;A.onBeforeCompile=(n,i)=>{e&&e(n,i),n.uniforms=Object.assign({},xP.physical.uniforms,n.uniforms),A.getLayersOfType("transmission").forEach(a=>{if(n.uniforms.transmissionSamplerMap.value){let l=a.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value)}else r++,r<2&&(A.needsUpdate=!0)})}}else bP(A)||(A.onBeforeCompile=(r,n)=>{e&&e(r,n),A.transparent=!1})}),o}function vP(o){return o.getLayersOfType("transmission").length>0}function bP(o){let t=0;return o.layers.forEach(A=>{if(A.type!=="light"&&A.type!=="fresnel"){let e=A.uniforms["f"+A.id+"_alpha"];e&&(t+=(1-t)*e.value)}}),t<1}function Vh(o){return o.traverse(t=>{if(t.type==="Camera"){let A=t;A.type=A.cameraType}}),o}function jh(o){let t=[],A=(e,r=0)=>{let n=r>0?e+r:e;return t.includes(n)?A(e,r+1):n};return o.traverse(e=>{if(t.includes(e.name)){let r=e.name,n=A(e.name);if(e.name=n,e.isMesh){let i=e;i.material instanceof Array?i.material.forEach(a=>{a.name=a.name.replace(r,n)}):i.material.isAsset||(i.material.name=i.material.name.replace(r,n))}}t.push(e.name)}),o}import{mergeBufferGeometries as SP}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Fh(o){let t=[];return o.traverse(A=>{A instanceof on&&t.push(A)}),t.forEach(A=>{let e=A.object,n=A.children.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Dh(l),l}),i=SP(A.parameters.hideBase?n:[e instanceof oe?e.geometry:[],...n]);e instanceof oe&&(e.geometry=i),A.removeFromParent(),e.setFromClonerState(null,{scene:o,shared:km})}),o}function zh(o){return o.traverse(t=>{t.matrixAutoUpdate=!0}),o}function Uh(o){Object.values(o.shared.materials).forEach(t=>{Oc(t)}),o.scene.objects.traverse((t,A)=>{"material"in A?Oc(A.material):"materials"in A&&A.materials.forEach(e=>{Oc(e)})})}function Oc(o){if(typeof o=="string")return;let t=[];o.layers.forEach((A,e)=>{A.type==="outline"&&t.push(e)}),t.reverse().forEach(A=>{o.layers.delete(A)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var kh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Pc=class extends TP{load(t,A,e,r=console.error){let n=new wP(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(kh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(kh),n.load(t,async i=>{try{if(typeof i=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(i);A(a)}catch(a){r(a)}},e,r)}async parse(t){let A=await Bh(t,Uh);eh(A)&&await zm();let e=new Vr(A.shared);Object.values(e.getMaterials()).forEach(i=>Object.assign(i,{isAsset:!0}));let r=new vi(A.scene,e);r.remove(r.personalCamera),A.scene.environment.ambientLight.enabled||r.remove(r.ambientLight);let n=A.scene.publish.playCamera;if(n){let i=r.find(n);i&&mh(i)&&Object.assign(i,{makeDefault:!0})}return r=Fh(r),r=Rh(r),r=Vh(r),r=jh(r),r=zh(r),r}};export{Pc as default};
|