@splinetool/runtime 0.9.67 → 0.9.68

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/runtime.cjs CHANGED
@@ -4488,7 +4488,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
4488
4488
  }
4489
4489
 
4490
4490
  #endif
4491
- `,xR=$e.lights_fragment_begin,bR=$e.shadowmask_pars_fragment,gy=!1,wR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},yy=(n="medium")=>{if(!gy){gy=!0;let e=wR(n);$e.shadowmap_pars_fragment=vR(e);let t=xR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=bR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},m1=n=>{gy=!1,yy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,g1=n=>n.objectType==="CombinedCamera",y1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var vy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function xy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function SR(n,e){xy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function v1(n,e,t){SR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function x1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,w1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],AR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function _R(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var b1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(_R(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):w1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&b1(o,r,s,t.enableHelper===!0)}):b1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=w1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=AR.map(([t,r])=>new Cu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function TR(n){let e=[];for(let t in n)e.push(n[t]);return e}var Md=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=TR(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,S1=n=>"isAbstractMesh"in n,Dn=n=>class extends Md(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Af.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=by[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){ad.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var ER=new A(0,0,1),A1=new A,M1=new A,_1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),_1.getNormalMatrix(this.matrixWorld),A1.copy(ER).applyMatrix3(_1).normalize(),M1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(A1,M1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function _d(n,e){return CR(n)}function CR(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ld.then(n=>{We=n});var T1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),E1=new Uint32Array([0,1,2,3]),C1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:T1,indexWASM:E1,verticesPerFaceWASM:C1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:_d(n),r,i,s,o;return{positions:r,triIndices:o}=My(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=_y(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=T1,r=E1,i=C1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var D1=["getX","getY","getZ"];function My(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[D1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[D1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Td=new A,wy=new A,Sy=new A,Ay=new A;function _y(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Td.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),wy.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),Sy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Ay.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),wy.sub(Td).normalize(),Sy.sub(Td).normalize(),Ay.sub(Td).normalize();let a=wy.cross(Sy).dot(Ay);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};ap(Kn,{calcBoolean:()=>LR,calcBooleanTopological:()=>PR,freeMeshSet:()=>BR,getMeshSet:()=>IR,transformMeshSet:()=>NR});var L1,I1=new Promise(n=>{L1=n}),P1=!1;async function N1(){if(P1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.67/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});L1(s),P1=!0}var ot,Sl;I1.then(n=>ot=n);function DR(n,e){let t,{positions:r,triIndices:i}=My(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=_y(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function B1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function O1(n){switch(n){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function PR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=B1(n),r=ot.csg_calc_topological(Sl,t,n.length,O1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function LR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=B1(n),s=ot.csg_calc(Sl,i,n.length,r,O1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function IR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=DR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function NR(n,e){ot.transform_csg_mesh(n,e.elements)}function BR(n){ot.free_csg_mesh(n)}var by={ConeGeometry:vS,CubeGeometry:xS,CylinderGeometry:yS,DodecahedronGeometry:bS,EllipseGeometry:VS,HelixGeometry:qS,IcosahedronGeometry:YS,LatheGeometry:XS,NonParametricGeometry:JS,PolygonGeometry:QS,PyramidGeometry:KS,RectangleGeometry:sd,SphereGeometry:ZS,PlaneGeometry:$S,BackdropGeometry:e1,StarGeometry:t1,TextFrameGeometry:od,TorusGeometry:r1,TorusKnotGeometry:n1,TriangleGeometry:i1,VectorGeometry:Er},Sh=n=>by[n.type].create(n);var R1=new Be;function Ty(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ed=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(S1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(R1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,R1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Cd=new so,Ey=new Br,F1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ey.copy(s.boundingSphere),Ey.applyMatrix4(o),t.ray.intersectsSphere(Ey)===!1||(F1.copy(o).invert(),Cd.copy(t.ray).applyMatrix4(F1),s.boundingBox!==null&&Cd.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Cd,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Cd.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Dd=new A,Ln=new Gn,Cy=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Dd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Dd.x,Dd.y,Dd.z)}}var Pd=class extends Ai(Cy){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Lu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Iu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Pu){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Ld=class extends Ai(Du){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Ld.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Ld._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Ld;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Dy=new A,vn=class extends _i(Dn(Gn),Pd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Dy),this.getWorldPosition(Tl),Dy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Dy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={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 ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&x1(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)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var z1=new A,U1=new A,G1=new jt,Dl=class extends _i(Dn(Au),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),U1.setFromMatrixPosition(this.matrixWorld),G1.setFromRotationMatrix(this.matrixWorld),z1.copy(this.up).applyQuaternion(G1).negate().multiplyScalar(this.distance),this.target.position.copy(U1).add(z1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var k1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;k1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];c1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;k1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof wu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=sd.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Id=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Py(e)}},Py=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=RR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function RR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
4491
+ `,xR=$e.lights_fragment_begin,bR=$e.shadowmask_pars_fragment,gy=!1,wR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},yy=(n="medium")=>{if(!gy){gy=!0;let e=wR(n);$e.shadowmap_pars_fragment=vR(e);let t=xR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=bR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},m1=n=>{gy=!1,yy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,g1=n=>n.objectType==="CombinedCamera",y1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var vy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function xy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function SR(n,e){xy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function v1(n,e,t){SR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function x1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,w1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],AR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function _R(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var b1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(_R(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):w1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&b1(o,r,s,t.enableHelper===!0)}):b1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=w1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=AR.map(([t,r])=>new Cu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function TR(n){let e=[];for(let t in n)e.push(n[t]);return e}var Md=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=TR(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,S1=n=>"isAbstractMesh"in n,Dn=n=>class extends Md(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Af.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=by[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){ad.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var ER=new A(0,0,1),A1=new A,M1=new A,_1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),_1.getNormalMatrix(this.matrixWorld),A1.copy(ER).applyMatrix3(_1).normalize(),M1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(A1,M1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function _d(n,e){return CR(n)}function CR(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ld.then(n=>{We=n});var T1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),E1=new Uint32Array([0,1,2,3]),C1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:T1,indexWASM:E1,verticesPerFaceWASM:C1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:_d(n),r,i,s,o;return{positions:r,triIndices:o}=My(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=_y(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=T1,r=E1,i=C1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var D1=["getX","getY","getZ"];function My(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[D1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[D1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Td=new A,wy=new A,Sy=new A,Ay=new A;function _y(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Td.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),wy.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),Sy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Ay.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),wy.sub(Td).normalize(),Sy.sub(Td).normalize(),Ay.sub(Td).normalize();let a=wy.cross(Sy).dot(Ay);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};ap(Kn,{calcBoolean:()=>LR,calcBooleanTopological:()=>PR,freeMeshSet:()=>BR,getMeshSet:()=>IR,transformMeshSet:()=>NR});var L1,I1=new Promise(n=>{L1=n}),P1=!1;async function N1(){if(P1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.68/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});L1(s),P1=!0}var ot,Sl;I1.then(n=>ot=n);function DR(n,e){let t,{positions:r,triIndices:i}=My(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=_y(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function B1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function O1(n){switch(n){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function PR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=B1(n),r=ot.csg_calc_topological(Sl,t,n.length,O1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function LR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=B1(n),s=ot.csg_calc(Sl,i,n.length,r,O1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function IR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=DR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function NR(n,e){ot.transform_csg_mesh(n,e.elements)}function BR(n){ot.free_csg_mesh(n)}var by={ConeGeometry:vS,CubeGeometry:xS,CylinderGeometry:yS,DodecahedronGeometry:bS,EllipseGeometry:VS,HelixGeometry:qS,IcosahedronGeometry:YS,LatheGeometry:XS,NonParametricGeometry:JS,PolygonGeometry:QS,PyramidGeometry:KS,RectangleGeometry:sd,SphereGeometry:ZS,PlaneGeometry:$S,BackdropGeometry:e1,StarGeometry:t1,TextFrameGeometry:od,TorusGeometry:r1,TorusKnotGeometry:n1,TriangleGeometry:i1,VectorGeometry:Er},Sh=n=>by[n.type].create(n);var R1=new Be;function Ty(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ed=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(S1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(R1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,R1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Cd=new so,Ey=new Br,F1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ey.copy(s.boundingSphere),Ey.applyMatrix4(o),t.ray.intersectsSphere(Ey)===!1||(F1.copy(o).invert(),Cd.copy(t.ray).applyMatrix4(F1),s.boundingBox!==null&&Cd.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Cd,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Cd.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Dd=new A,Ln=new Gn,Cy=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Dd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Dd.x,Dd.y,Dd.z)}}var Pd=class extends Ai(Cy){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Lu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Iu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Pu){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Ld=class extends Ai(Du){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Ld.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Ld._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Ld;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Dy=new A,vn=class extends _i(Dn(Gn),Pd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Dy),this.getWorldPosition(Tl),Dy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Dy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={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 ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&x1(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)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var z1=new A,U1=new A,G1=new jt,Dl=class extends _i(Dn(Au),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),U1.setFromMatrixPosition(this.matrixWorld),G1.setFromRotationMatrix(this.matrixWorld),z1.copy(this.up).applyQuaternion(G1).negate().multiplyScalar(this.distance),this.target.position.copy(U1).add(z1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var k1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;k1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];c1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;k1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof wu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=sd.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Id=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Py(e)}},Py=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=RR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function RR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
4492
4492
  `)a=0,l-=s;else{let u=FR(h,i,a,l,t);a+=u.offsetX,o.push(u.path)}}return o}function FR(n,e,t,r,i){let s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}let o=new Nu,a,l,c,h,u,f,d,m;if(s.o){let p=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,x=p.length;g<x;)switch(p[g++]){case"m":a=p[g++]*e+t,l=p[g++]*e+r,o.moveTo(a,l);break;case"l":a=p[g++]*e+t,l=p[g++]*e+r,o.lineTo(a,l);break;case"q":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,o.quadraticCurveTo(u,f,c,h);break;case"b":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,d=p[g++]*e+t,m=p[g++]*e+r,o.bezierCurveTo(u,f,d,m,c,h);break}}return{offsetX:s.ha*e,path:o}}var $t=class extends ir{constructor({char:t,originalChar:r,fontFamily:i,letterSpacing:s,fontSize:o,LOD:a=16},l=new Un({color:0,opacity:1,visible:!0,transparent:!0,side:Wt})){let c=$t.loadChar(t,i,a);super(c.geometry,l);this.char=t,this.originalChar=r??t,this.fontFamily=i,this.letterSpacing=s,this.fontSize=o,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new O,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return $t._fontPath}static set FONTS_PATH(t){$t._fontPath=t}updatePosition(t,r){this.localPosition.copy(t);let i=new A(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(t){let r=t/this.resolution;this.fontSize=t,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(t){if(this.fontFamily===t)return;this.fontFamily=t;let r=$t.loadChar(this.char,t,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(t){if(this.char===t)return;this.char=t;let r=$t.loadChar(t,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(t){this.letterSpacing!==t&&(this.letterSpacing=t,this.updateFontSize(this.fontSize))}updateLOD(t){if(this.LOD===t)return;this.LOD=t;let r=$t.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let t={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new $t(t).copy(this)}static loadFont(t){return new Promise(function(r,i){$t.fontCache[t]?r($t.fontCache[t]):new Id().load($t.FONTS_PATH+t+".json",o=>{$t.fontCache[t]=o,r(o)},void 0,i)})}static loadChar(t,r,i){if($t.charCache[t]){if($t.charCache[t][i]&&$t.charCache[t][i].fontFamily===r)return $t.charCache[t][i]}else $t.charCache[t]={};let s=$t.fontCache[r],o=s.generateShapes(t,1);return $t.charCache[t][i]={geometry:new pa(o,i),fontFamily:r,resolution:s.data.resolution,glyphsHa:s.data.glyphs[t].ha},$t.charCache[t][i]}},Xr=$t;Xr.charCache={},Xr.fontCache={},Xr._fontPath="/_assets/_fonts/";var Nd=new O,Hs=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new O(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,i;for(i=e;i>=0;i-=1)if(this.message[i].char===" "){r=!1,t.length===0&&(i-=1,t.splice(0,0,this.message[i]));break}else t.splice(0,0,this.message[i]);return r?t=[]:this.message.splice(i+1,t.length),t}getWord(e=0,t=1){let r=[],i=e;for(i=e;;i+=t){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}t>0?(r.push(this.message[i]),this.message.splice(i,1),i-=t):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,i=e;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=t}return(i<0||i>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let i=t;i<=r;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,i,s){switch(r){case 1:this.leftAlign(e,s);break;case 3:this.centerAlign(this.spaceLeft(t),e,s);break;case 2:this.rightAlign(this.spaceLeft(t),e,s);break;case 4:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Nd.set(t,r);let i=this.message.length;for(let s=0;s<i;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Nd),e)}leftAlign(e,t){this.align=1,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=3,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=2,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=4,this.endLine){this.offsetCharacters(t,0,r);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(t,0,r);return}let s=e/i,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),Nd.set(o,r),this.message[a].updatePosition(this.message[a].localPosition.add(Nd),t)}clone(){let e=new Hs(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var Ly=class extends Ct{constructor(t,r=new Ir({transparent:!0,opacity:1,visible:!1,side:Wt})){super(t,r);this.objectType="TextFrame";this.charContainer=new lt,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=t.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(t,r,i){let s=od.create({parameters:{width:r.width,height:r.height}}),o=new Ly(s).fromState(r,i);return o.uuid=t,o}async updateText(t){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Xr.loadFont(i),r.text=t;let s=r.textOrigin,o=new Un({visible:r.visible,transparent:!0,side:Wt}),a=t.split(`
4493
4493
  `),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let u=new Hs(l,r.lineHeight,r.fontSize);return u.message=c.split("").map(f=>{let d={char:f,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=o.clone();m.color=r.hexColor,m.opacity=r.opacity;let p=new Xr(d,m);return u.addChar3D(p,s),this.charContainer.add(p),p}),l+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let t=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;t.length;)t.pop()}raycast(t,r){let i=[];if(super.raycast(t,i),i.length>0){r.push(i[0]);return}let s=[];for(let o=0,a=this.charContainer.children.length;o<a;++o)if(this.charContainer.children[o]instanceof Xr&&(t.intersectObject(this.charContainer.children[o],!1,s),s.length>0)){s[0].object=this,r.push(s[0]);return}}updateGeometry(t){let r=this.userData,i=this.geometry.userData,s=i.parameters.width,o=i.parameters.height,a=t.parameters?.width??s,l=t.parameters?.height??o,c=r.textFrame;super.updateGeometry(t),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==o?(this.checkOverFlow(),this.checkCapacity()):a!==s&&(s<a?this.checkCapacity():s>a&&this.checkOverFlow())}checkOverFlow(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.textLines;for(let o=t;o<s.length;o++){s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(i);let a=[];for(;s[o].checkOverFlow(r.textFrame.maxLineSize);)s[o].containSpaceOverFlow()?a.unshift(s[o].getWord(s[o].message.length-1,-1)):a.unshift(s[o].popChar());if(a.length>0){s[o+1]===void 0?(s[o].isEndLine(!1),this.createTextLine()):s[o].endLine&&(this.createTextLine(o+1),s[o].isEndLine(!1),s[o+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)s[o+1].addChar3D(a[c][h],i,l),l+=1;s[o+1].fullUpdate(i)}s[o].fullUpdate(i)}this.textFullUpdate(t)}checkCapacity(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.maxLineSize,o=r.textFrame.textLines;for(let a=t;a<o.length;a+=1)if(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i),!!o[a-1])for(;!o[a-1].endLine;){let l,c=o[a-1].spaceLeft(s);if(o[a].wordSize(0,1)<=c){o[a].containSpace()?l=o[a].getWord(0,1):l=o[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&o[a-1].addChar3D(l[h],i)}else{o[a].isEmpty()?(o[a].endLine&&o[a-1].isEndLine(!0),o.splice(a,1),a-=1):(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i));break}}this.textFullUpdate(t)}createTextLine(t=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(t,0,new Hs(this.getNewLinePosition(t),i.lineHeight,i.fontSize))}textFullUpdate(t=0){let i=this.userData.textFrame,s=i.textLines,o=this.getVerticalAlignmentOffSet();for(let a=t;a<s.length;a++)s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i.textOrigin),s[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,o)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(t){let i=this.userData.textFrame.textLines,s=0;for(let o=0;o<t;o+=1)s+=i[o].maxCharSize*i[o].lineHeight;return s}updateColor(t){let r=this.userData;r.textFrame.hexColor=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.color?.isColor&&(l.color=t)}}}updateOpacity(t){let r=this.userData;r.textFrame.opacity=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.opacity=t}}}updateVisible(t){let r=this.userData;r.textFrame.visible=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.visible=t}}}async updateFontFamily(t){await Xr.loadFont(t);let i=this.userData.textFrame,s=i.textLines;i.fontFamily=t;for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(t){let i=this.userData.textFrame,s=i.textLines,o=i.fontSize;i.fontSize=t;for(let a=0;a<s.length;a++)s[a].updateFontSize(t);this.textFullUpdate(),t>o?this.checkOverFlow():t<o&&this.checkCapacity()}async updateTextTransform(t){let i=this.userData.textFrame;await Xr.loadFont(i.fontFamily);let s=i.textLines;switch(i.textTransform=t,t){case 2:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=t;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++)o[a].updateLetterSpacing(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(t){let r=this.userData;r.textFrame.LOD=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=t;for(let s=0;s<i.length;s++)i[s].updatelineHeight(t);this.textFullUpdate()}updateVerticalAlignment(t){let r=this.userData;r.textFrame.verticalAlignment=t,this.textFullUpdate()}updateHorizontalAlignment(t){let r=this.userData;r.textFrame.horizontalAlignment=t,this.textFullUpdate()}toJSON(t){let r=super.toJSON(t),i=r.object;i.objectType="TextFrame";let o=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=o,r}async fromJSONasync(t){if(super.fromJSON(t),t.userData!==void 0){let r=t.userData.textFrame;await Xr.loadFont(r.fontFamily),r.textOrigin=new A(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Un({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:Wt});r.textLinesData&&(r.textLines=r.textLinesData.map((s,o)=>{let a=new Hs(Number(s.yLinePos),Number(s.lineHeight),Number(s.maxCharSize)),l=s.message.map((c,h)=>{if(c.char===void 0){let d=r.textLines[o].message[h];if("geometries"in d){let m=d.geometries[0].userData.parameters;Object.assign(c,{LOD:m.lod,char:m.char,fontFamily:m.fontFamily,fontSize:m.fontSize,letterSpacing:m.letterSpacing,originalChar:m.char})}}let u={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},f=new Xr(u,i.clone());return a.addChar3D(f,r.textOrigin),this.charContainer.add(f),f});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(t,r){if(t.color!==void 0){let i=Zt(t.color,r);this.updateColor(i),this.updateOpacity(i.a)}t.alpha!==void 0&&this.updateOpacity(t.alpha),t.font!==void 0&&this.updateFontFamily(t.font),t.horizontalAlign!==void 0&&this.updateHorizontalAlignment(t.horizontalAlign),t.verticalAlign!==void 0&&this.updateVerticalAlignment(t.verticalAlign),t.textTransform!==void 0&&this.updateTextTransform(t.textTransform),t.fontSize!==void 0&&this.updateFontSize(t.fontSize),t.lineHeight!==void 0&&this.updateLineHeight(t.lineHeight),t.letterSpacing!==void 0&&this.updateLetterSpacing(t.letterSpacing),t.text!==void 0&&t.text!==""&&this.updateText(t.text),(t.width!==void 0||t.height!==void 0)&&this.updateGeometry({parameters:{width:t.width,height:t.height}})}fromState(t,r){return super.fromState(t),this.fromTextFrameData(t,r),this}convertToVector(){let{fontFamily:t,hexColor:r}=this.userData.textFrame,i=new Qi;i.name="Text Shape";let s=Xr.fontCache[t];for(let o of this.charContainer.children)o instanceof Xr&&s.generateShapes(o.char,1).forEach(a=>{let l=new dt().fromShape(a);l.applyScale(o.scale.x,o.scale.y);let c=Er.create({shape:l}),h=new Ir({side:Wt});h.color=r;let u=new Vs(c,h);u.name=o.char,u.position.copy(o.position),u.rotation.copy(o.rotation),i.attach(u)});return i}},Lo=Ly;Lo.VerticalAlign=Pg,Lo.HorizontalAlign=Dg,Lo.TextTransform=Lg;var j1=yv(H1());var Iy;ld.then(n=>{Iy=n});var q1=new Be,zR=new Be,UR=new Be,$n=new yr,Ws=new A,GR=new Be,kR=new Be,js=class extends Ct{constructor(t,r,i,s=new Yr){super(i??r,s);this.subdivPointer=t;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Be;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new Be;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,r,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Pn.build(r.geometry,void 0,void 0,!r.flatShading),l=vh(r.material,i),c=new js(s,o,a||void 0,l);return r.geometry.phongAngle!==void 0&&(c.phongAngle=r.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=t,c.fromState(r),c}shallowClone(t){return new Il(this.geometry,this.material).shallowCopy(this,t)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="SubdivObject",r}buildFromStore(t,r){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Pn.build(t,r,this.subdivPointer,this.smoothShading,this.shearScale);if(t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,r){this.geometry=this.originalGeometry,Ct.prototype.raycast.call(this,t,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,r=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,j1.SVD)(r),a=q1.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=zR.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=UR.copy(l).transpose();this.shearScale=GR.makeScale(o[0],o[1],o[2]).multiply(c).premultiply(l),this.shearScaleInv=kR.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),o.every(h=>Math.abs(o[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Br);let r=t.attributes.position,i=t.boundingSphere.center;$n.setFromBufferAttribute(r),$n.getCenter(i),t.boundingSphere.radius=i.distanceTo($n.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let r=this.originalGeometry;$n.min.set(t[0],t[2],t[4]),$n.max.set(t[1],t[3],t[5]),this.shearScaleInv&&($n.min.applyMatrix4(this.shearScaleInv),$n.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Br);let i=r.boundingSphere.center;$n.getCenter(i),r.boundingSphere.radius=i.distanceTo($n.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&(Iy.free_bvh(this.subdivPointer),Iy.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,W1(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(W1(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function W1(n,e,t,r){let i=n.position.array,s=n.normal.array,o=q1.makeScale(e,t,r).invert().elements,a,l,c;for(var h=0,u=i.length;h<u;h+=3)i[h]*=e,i[h+1]*=t,i[h+2]*=r,a=s[h],l=s[h+1],c=s[h+2],s[h]=o[0]*a+o[4]*l+o[8]*c,s[h+1]=o[1]*a+o[5]*l+o[9]*c,s[h+2]=o[2]*a+o[6]*l+o[10]*c}function Y1(n,e){e.flatShading!==void 0&&(n.flatShading=e.flatShading,n.needsUpdate=!0),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?n.side=zn:e.side===1?n.side=gr:n.side=Wt)}function VR(n,e){if(Array.isArray(n.material))for(let t of n.material)Y1(t,e);else{let t=n.material;Y1(t,e)}n.objectType==="SubdivObject"&&e.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!e.flatShading,n.updateMesh())}function X1(n,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=js.createFromState(n,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new Le:_d(e.geometry,t),s="materials"in e?p1(e.materials,t):vh(e.material,t);qf.is2DParametricMesh(i.userData.type)?r=new Pl(i,s):i?.userData.type==="VectorGeometry"?r=new Vs(i,s):e.geometry.type==="NonParametricGeometry"?r=new Il(i,s):e.geometry.type==="BooleanGeometry"?(r=new Ed(void 0,s),r.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(r.phongAngle=e.geometry.phongAngle)):r=new Ll(i,s),r.uuid=n,r.fromState(e)}return VR(r,e),r}function J1(n,e,t){return e.type==="Mesh"?X1(n,e,t):e.type==="TextFrame"?Lo.createFromState(n,e,t):e.type==="Empty"?Qi.createFromState(n,e):e.type==="PointLight"?Cl.createFromState(n,e,t):e.type==="SpotLight"?Dl.createFromState(n,e,t):e.type==="DirectionalLight"?El.createFromState(n,e,t):Is.is(e.type)?vn.createFromState(n,e):(console.error(e),new Qi)}function HR(n,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=n.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=n.depthTexture}function Q1(n,e,t){if(!t.userData.layers)return!1;let r=!1,i=t.userData.layers.getLayersOfType("transmission");return i.length>0?(e.layers.set(3),r=!0,n!==void 0&&i.forEach(s=>HR(n,s))):e.layers.set(0),r}function K1(n,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Q1(n,r,r.material[i])&&(t=!0);else Q1(n,r,r.material)&&(t=!0)}),t}function Z1(n,e){"material"in n&&WR(n.material,e),"geometry"in n&&n.geometry.dispose()}function WR(n,e){Dw(n).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var $1=new A,Ny=class extends Md(un){constructor(t,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new aa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Se(1,0,0);this.bgColor=new Se(1,1,1);this.entityByUuid={};this.ambientLight=new mo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(t,r)}needsTransmission(t){return this.needsTransmissionDirty&&(this._needsTransmission=K1(t,this),t!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(t){if(t===""||t===void 0)return;let r=this.entityByUuid[t];return r===void 0?this.getObjectByProperty("uuid",t):r}get color(){return this._color}set color(t){this.fogUseBGColor===!0&&this.backupFog.color.copy(t),this._color.copy(t)}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,r){if(this.createChildrenObjects(t.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Zt(t.backgroundColor,r)),this.updateFog(t.fog,r),this.updateAmbientLight(t.environment.ambientLight,r),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof vn&&this.switchActiveCamera(i)}this.traverse(i=>{xt(i)&&i.recomputeBoolean()})}clearScene(t){this.traverseEntity(r=>{Z1(r,t)});for(let r of this.children)Cn(r)&&r.removeFromParent()}resetAfterClear(t,r){this.init(t,r)}createPersonalCamera(){let t=vn.createFromState(Ny.PERSONAL_CAMERA_ID,{...Xf.defaultData,name:"Personal Camera"});return t.enableHelper=!1,t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let r=[],i=s=>{for(let o of s.children)Cn(o)&&!o.raycastLock&&o.visible&&((zt(o)||Ji(o)&&o.enableHelper&&o.objectHelper.parent)&&t.intersectObject(o,!1,r),i(o))};return i(this),r}traverseEntity(t){for(let r of this.children)Cn(r)&&r.traverseEntity(t)}updateFog(t,r){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Zt(t.color,r),this.backupFog.near=t.near,this.backupFog.far=t.far}toJSON(t){return{}}fromJSON(t){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(t,r){v1(this.ambientLight,t,r),t.groundColor!==void 0&&(this.ambientLight.groundColor=Zt(t.groundColor,r)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=t,t.enableHelper=!1}setBackgroundColor(t){this.bgColor=t,this.alpha=t.a}createChildrenObjects(t,r,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,r,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let r of t.children)this.unregisterObject(r)}createChildObject(t,r,i,s,o){let a=J1(t,r,o);return a&&(this.entityByUuid[t]=a,s.add(a),xt(s)&&zt(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let r=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;r.push(...h.vertices)}let i=new yr;return i.setFromPoints(r),i.getCenter($1),$1}copyMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t)?.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(t){this.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)t(r.material[i]);else t(r.material)})}updateCanvasSize(t,r){this.activeCamera.setViewplaneSize(t,r);let i,s;t>=r?(i=r/t,s=1):(i=1,s=t/r),this.traverseMaterial(o=>{o.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Mh=Ny;Mh.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var oA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var _h="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var jR=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4494
4494
  uniform mediump sampler2D inputBuffer;
package/build/runtime.js CHANGED
@@ -4488,7 +4488,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
4488
4488
  }
4489
4489
 
4490
4490
  #endif
4491
- `,vR=$e.lights_fragment_begin,xR=$e.shadowmask_pars_fragment,my=!1,bR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},gy=(n="medium")=>{if(!my){my=!0;let e=bR(n);$e.shadowmap_pars_fragment=yR(e);let t=vR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=xR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},f1=n=>{my=!1,gy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,d1=n=>n.objectType==="CombinedCamera",p1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var yy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function vy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function wR(n,e){vy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function m1(n,e,t){wR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function g1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,v1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],SR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],AR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function MR(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var y1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(MR(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):v1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&y1(o,r,s,t.enableHelper===!0)}):y1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=v1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=SR.map(([t,r])=>new Eu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=AR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function _R(n){let e=[];for(let t in n)e.push(n[t]);return e}var Ad=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=_R(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,x1=n=>"isAbstractMesh"in n,Dn=n=>class extends Ad(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Sf.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=xy[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){od.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var TR=new A(0,0,1),b1=new A,w1=new A,S1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),S1.getNormalMatrix(this.matrixWorld),b1.copy(TR).applyMatrix3(S1).normalize(),w1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(b1,w1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function Md(n,e){return ER(n)}function ER(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ad.then(n=>{We=n});var A1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),M1=new Uint32Array([0,1,2,3]),_1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:A1,indexWASM:M1,verticesPerFaceWASM:_1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:Md(n),r,i,s,o;return{positions:r,triIndices:o}=Ay(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=My(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=A1,r=M1,i=_1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var T1=["getX","getY","getZ"];function Ay(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[T1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[T1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var _d=new A,by=new A,wy=new A,Sy=new A;function My(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){_d.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),by.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),wy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Sy.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),by.sub(_d).normalize(),wy.sub(_d).normalize(),Sy.sub(_d).normalize();let a=by.cross(wy).dot(Sy);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};pv(Kn,{calcBoolean:()=>PR,calcBooleanTopological:()=>DR,freeMeshSet:()=>NR,getMeshSet:()=>LR,transformMeshSet:()=>IR});var C1,D1=new Promise(n=>{C1=n}),E1=!1;async function P1(){if(E1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.67/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});C1(s),E1=!0}var ot,Sl;D1.then(n=>ot=n);function CR(n,e){let t,{positions:r,triIndices:i}=Ay(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=My(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function L1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function I1(n){switch(n){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function DR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=L1(n),r=ot.csg_calc_topological(Sl,t,n.length,I1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function PR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=L1(n),s=ot.csg_calc(Sl,i,n.length,r,I1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function LR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=CR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function IR(n,e){ot.transform_csg_mesh(n,e.elements)}function NR(n){ot.free_csg_mesh(n)}var xy={ConeGeometry:mS,CubeGeometry:gS,CylinderGeometry:pS,DodecahedronGeometry:yS,EllipseGeometry:US,HelixGeometry:HS,IcosahedronGeometry:WS,LatheGeometry:jS,NonParametricGeometry:qS,PolygonGeometry:YS,PyramidGeometry:XS,RectangleGeometry:id,SphereGeometry:JS,PlaneGeometry:QS,BackdropGeometry:KS,StarGeometry:ZS,TextFrameGeometry:sd,TorusGeometry:$S,TorusKnotGeometry:e1,TriangleGeometry:t1,VectorGeometry:Er},Sh=n=>xy[n.type].create(n);var N1=new Be;function _y(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Td=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(x1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(N1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,N1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Ed=new so,Ty=new Br,B1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ty.copy(s.boundingSphere),Ty.applyMatrix4(o),t.ray.intersectsSphere(Ty)===!1||(B1.copy(o).invert(),Ed.copy(t.ray).applyMatrix4(B1),s.boundingBox!==null&&Ed.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Ed,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Ed.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Cd=new A,Ln=new Gn,Ey=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Cd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Cd.x,Cd.y,Cd.z)}}var Dd=class extends Ai(Ey){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Pu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Lu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Du){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Pd=class extends Ai(Cu){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Pd.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Pd._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Pd;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Cy=new A,vn=class extends _i(Dn(Gn),Dd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Cy),this.getWorldPosition(Tl),Cy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Cy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={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 ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(Mu),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&g1(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)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Au),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var O1=new A,R1=new A,F1=new jt,Dl=class extends _i(Dn(Su),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),R1.setFromMatrixPosition(this.matrixWorld),F1.setFromRotationMatrix(this.matrixWorld),O1.copy(this.up).applyQuaternion(F1).negate().multiplyScalar(this.distance),this.target.position.copy(R1).add(O1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var z1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;z1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];o1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;z1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof bu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=id.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Ld=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Dy(e)}},Dy=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=OR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function OR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
4491
+ `,vR=$e.lights_fragment_begin,xR=$e.shadowmask_pars_fragment,my=!1,bR=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},gy=(n="medium")=>{if(!my){my=!0;let e=bR(n);$e.shadowmap_pars_fragment=yR(e);let t=vR.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let r=xR.slice();r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=r}},f1=n=>{my=!1,gy(n)};var Xi=n=>"isEntity"in n,zt=n=>"isAbstractMesh"in n,xt=n=>n!==null&&n.isBooleanMesh,d1=n=>n.objectType==="CombinedCamera",p1=n=>Xi(n)&&(n.objectType==="LightDirectional"||n.objectType==="LightSpot"||n.objectType==="LightPoint");var yy=n=>n.objectType==="EmptyObject",Ji=n=>"objectHelper"in n;function vy(n,e){let t=!1;e.position&&(n.position.fromArray(e.position),t=!0),e.rotation&&(n.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,n.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(t=!0,n.hiddenMatrix.fromArray(e.hiddenMatrix??ui.identity)),t&&(n.updateMatrix(),xt(n.parent)&&zt(n)&&n.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=e.isUpVectorFlipped),n.updateUp())}function wR(n,e){vy(n,e),e.name!==void 0&&(n.name=e.name),e.visible!==void 0&&(n.isEntity?n.visibility=e.visible:n.visible=e.visible)}function m1(n,e,t){wR(n,e),e.color!==void 0&&(n.color=Zt(e.color,t)),e.intensity!==void 0&&(n.intensity=e.intensity),e.shadows!==void 0&&!(n instanceof mo)&&(n.castShadow=e.shadows),n.shadow&&!(n instanceof mo)&&e.depth!==void 0&&(n.shadow.camera.far=e.depth,n.shadow.needsUpdate=!0),e.helper!==void 0&&Ji(n)&&(n.enableHelper=e.helper,n.gizmos.shadowmap.visible=e.helper)}function g1(n,e){n.shadow.camera.right=e/2,n.shadow.camera.left=-e/2,n.shadow.camera.top=e/2,n.shadow.camera.bottom=-e/2,n.shadow.needsUpdate=!0}var bl=new yr,wi=new A,Si=new A,wl=new Be,v1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],SR=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],AR=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function MR(n,e,t=0,r=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<r;h++){let u=e.getX(h),f=e.getY(h),d=e.getZ(h);u<i&&(i=u),f<s&&(s=f),d<o&&(o=d),u>a&&(a=u),f>l&&(l=f),d>c&&(c=d)}return n.min.set(i,s,o),n.max.set(a,l,c),n}var y1=(n,e,t,r)=>{if(zt(n)){let i=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?wi.copy(n.originalGeometry.boundingSphere.center):s!==void 0&&(MR(bl,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),bl.getCenter(wi)),n.forceComputeSize?bl.getSize(Si).multiplyScalar(.5):Si.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Ji(n)&&r===!0){let i=n.geometryHelper.getAttribute("position");bl.setFromArray(i.array),bl.getCenter(wi),bl.getSize(Si).multiplyScalar(.5)}else wi.setScalar(0),Si.setScalar(0);wl.copy(e).multiply(n.matrixWorld),Si.x===0&&Si.y===0&&Si.z===0?t.push(new A(wi.x,wi.y,wi.z).applyMatrix4(wl)):v1.forEach(i=>{t.push(i.clone().multiply(Si).add(wi).applyMatrix4(wl))})},xh=class extends yr{constructor(){super(...arguments);this.matrix=new Be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(r=>r.clone()),this.faces=t.faces.map(r=>r.clone()),this.edges=t.edges.map(r=>r.clone()),this.centerEdges=t.centerEdges.map(r=>r.clone()),this}setFromObjectSize(t,r=!1){t.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,r)}expandByObjectSize(t,r,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&y1(o,r,s,t.enableHelper===!0)}):y1(t,r,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(wl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Si).multiplyScalar(.5),this.getCenter(wi),wl.copy(this.matrix).setPosition(wi),this.vertices=v1.map(t=>t.clone().multiply(Si).applyMatrix4(wl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=SR.map(([t,r])=>new Eu(this.vertices[t],this.vertices[r])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=AR.map(([t,r])=>this.vertices[t].clone().add(this.vertices[r]).multiplyScalar(.5))}};function bh(n){let e=[];for(let t in n){let r=n[t];delete r.metadata,e.push(r)}return e}function _R(n){let e=[];for(let t in n)e.push(n[t]);return e}var Ad=n=>class extends n{hasEntityChild(){return this.children.some(t=>Xi(t))}isDescendantOf(t){t instanceof lt&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let i=new Be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Xi(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,i={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Xi(o)||o instanceof ws)&&s.children.push(o.toJSON(t).object)}if(r){let o=bh(t.geometries),a=bh(t.materials),l=bh(t.textures),c=bh(t.images),h=bh(t.interactionStates),u=_R(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.interactionStates=h),u.length>0&&(i.nodes=u)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var Cn=n=>"isEntity"in n,x1=n=>"isAbstractMesh"in n,Dn=n=>class extends Ad(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Be;this._singleBBox=new xh;this._recursiveBBox=new xh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Cn(i)&&i.traverseEntity(s=>{Ji(s)&&s.visible&&(s.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Cn(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Cn(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let s of r.children)Cn(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let r=new Be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let s of this.children)Cn(s)&&s.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),s=i.object;return this.raycastLock===!0&&(s.raycastLock=!0),this.scaleLock===!0&&(s.scaleLock=!0),s.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Be}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ja(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};var wh=class extends lt{constructor(t,r={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=Sf.defaultData(i.toArray(),s),wo(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let r of this.object.material)r.visible=!0;if(t){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let r=0,i=t-this.children.length;r<i;++r){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-t;r<i;++r)this.remove(this.children[0])}_updateRadial(t){let r=t.radial,i=r.start*je.DEG2RAD,s=r.end*je.DEG2RAD,o=i-s,a=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD),l;switch(r.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(r.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let r=t.linear,i=new wn(r.rotation[0]*je.DEG2RAD,r.rotation[1]*je.DEG2RAD,r.rotation[2]*je.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(r.scale[0]-1)*s,o.scale.y=1+(r.scale[1]-1)*s,o.scale.z=1+(r.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=r.position[0]*s,o.position.y=r.position[1]*s,o.position.z=r.position[2]*s}_updateGrid(t){let r=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromJSON(t){return this}toJSON(){return{}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),wo(this.parameters,t),this.update(),this}};var Ct=class extends Dn(ir){constructor(t,r){super(t,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Be;this.booleanExclude=null;Array.isArray(r)&&(this.selectedMaterial=0,t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}getSelectedMaterial(t){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t??0),this.material[t??this.selectedMaterial]):this.material}setSelectedMaterial(t,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r??0),r=r??this.selectedMaterial,this.material[r].dispose(),this.material[r]=t):(this.material.dispose(),this.material=t)}updateGeometry(t){let r=this.geometry,i=xy[r.userData.type],s=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,o=i.build(i.normalizeInputs(t,s)),a=r.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(t,r,i){od.resizeGeometry(this.geometry,{width:t,height:r,depth:i})}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Sh(r),s=Array.isArray(this.material)?this.material.map(o=>o.clone()):this.material.clone();return new this.constructor(i,s).copy(this,t)}copy(t,r=!0){return super.copy(t,r),t.cloner&&(this.cloner=new wh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new wh(this)),this.cloner.fromClonerState(t))}fromState(t,r){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Kn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),xt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)zt(t)&&(t.freeBooleanPointer(),xt(t)&&t.invalidateUpstreamBooleanData())}};var TR=new A(0,0,1),b1=new A,w1=new A,S1=new Ht,Vs=class extends Ct{constructor(t=Er.create({}),r=new Ir({side:Wt})){super(t,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Ot;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="VectorObject",r}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),S1.getNormalMatrix(this.matrixWorld),b1.copy(TR).applyMatrix3(S1).normalize(),w1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(b1,w1)}clone(t){let r=this.shape.clone(),i=this.material.clone(),s=this.geometry.userData,o=Er.create(Object.assign({},s,{shape:r})),a=new Vs(o,i).copy(this,t);return a.shape=r,r.update(),a}raycast(t,r){Ct.prototype.raycast.call(this,t,r)}};function Md(n,e){return ER(n)}function ER(n){let e={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=dt.createFromState(n.shape,n.width,n.height);e.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),e.geometry=new Ss().parse(n));let t;try{t=Sh(e)}catch(r){console.error(r)}if(!t){let r=dt.createFromState(Ka.defaultData(),100,100);e.shape=r,t=Sh(e)}return t}var We;ad.then(n=>{We=n});var A1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),M1=new Uint32Array([0,1,2,3]),_1=new Uint8Array([4]),Pn=class{static build(n,e,t,r,i){let s,o,a,l=n?.phongAngle??e?.phongAngle??35;if(r===!1&&(l=-1),n.positionWASM!==void 0){t&&t!==0&&(We.free_bvh(t),We.free_subdivision_surface(t));try{s=Pn.allocate(n,i)}catch(c){console.error(c,n),s=Pn.allocate({positionWASM:A1,indexWASM:M1,verticesPerFaceWASM:_1},i)}We.set_destination_refinement_level(s,0),o=Pn.buildLevel(s,!0,l)}else s=t,n.phongAngle!==void 0&&(o=Pn.buildLevel(s,!0,l));return n.subdivisions!==void 0&&(We.set_destination_refinement_level(s,n.subdivisions),n.subdivisions>0?a=Pn.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(n,e){n.widthSegments>16&&(n.widthSegments=16),n.heightSegments>16&&(n.heightSegments=16),n.depthSegments>16&&(n.depthSegments=16),n.radialSegments>16&&(n.radialSegments=16),n.type==="DodecahedronGeometry"&&(n.detail=0);let t=n.shape!==void 0?e.geometry:Md(n),r,i,s,o;return{positions:r,triIndices:o}=Ay(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=My(r,o,t),{positions:r,indices:i,verticesPerFace:s}}static allocate(n,e){let t,r,i,s=[],o=[];n.positionWASM&&n.positionWASM.length>0?(t=n.positionWASM,r=n.indexWASM,i=n.verticesPerFaceWASM):(t=A1,r=M1,i=_1);let a=t.length,l=r.length,c=i.length,h=t.length+s.length+o.length,u=r.length+i.length,f=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=We._malloc(f),g=new Float32Array(We.HEAPF32.buffer,p,h),x=new Uint32Array(We.HEAPU32.buffer,p+d,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(r,0),x.set(i,r.length);let v;n?.scaleBaked?.some(b=>b!==1)&&(v=new Be().makeScale(...n.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?We.alloc_subdivision_surface2(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):We.alloc_subdivision_surface(p,a,p+d,l,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return We._free(p),w}static buildLevel(n,e,t,r,i){let s=i?We.get_mesh_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t,i.elements):We.get_mesh_data(n,e?We.Level.CONTROL:We.Level.REFINED,t),o=8,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=We.HEAPU32[a[c]>>2],u=We.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=We.HEAPU32[a[c]>>2],d=We.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=We.HEAPU32[a[c]>>2],p=We.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=We.HEAPU32[a[c]>>2],x=We.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let v=new Le;if(v.setIndex(new gs(x,1)),v.setAttribute("position",new Ae(u,3)),v.setAttribute("normal",new Ae(d,3)),e){v.setAttribute("faceMap",new gs(p,1));let w=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return We.free_mesh_data(s),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,We.free_mesh_data(s)}static buildControlCageWireframe(n,e,t){let r=We.get_wireframe_data_for_base_level(n),i=4,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(2,2+2),a=0,l=We.HEAPU32[s[a]>>2],c=We.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=We.HEAPU32[s[a]>>2],u=We.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Ae(c,3));let d=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new Xe(d,3)),f.setIndex(new gs(u,1)),We.free_wireframe_data_for_base_level(r),f}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,e,t){e||We.set_destination_refinement_level(n,1);let r=t?We.get_topological_data2(n,e?We.Level.CONTROL:We.Level.REFINED,t.elements):We.get_topological_data(n,e?We.Level.CONTROL:We.Level.REFINED),i=6,s=We.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=We.HEAPU32[s[a]>>2],c=new Float32Array(We.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=We.HEAPU32[s[a]>>2],u=new Uint32Array(We.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=We.HEAPU32[s[a]>>2],d=new Uint8Array(We.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return We.free_topological_data(r),{positions:c,indices:u,verticesPerFace:d}}};var T1=["getX","getY","getZ"];function Ay(n,e){let t={},r=e?e.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let h=e?e.getX(c):c,u="";for(let f=0;f<3;f++)u+=`${~~(n[T1[f]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let f=0;f<3;f++)o.push(n[T1[f]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var _d=new A,by=new A,wy=new A,Sy=new A;function My(n,e,t){let r=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),r.push(a++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),r.push(a++);return i.push(a),{indices:r,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){_d.set(n[e[s]*3],n[e[s]*3+1],n[e[s]*3+2]),by.set(n[e[s+1]*3],n[e[s+1]*3+1],n[e[s+1]*3+2]),wy.set(n[e[s+4]*3],n[e[s+4]*3+1],n[e[s+4]*3+2]),Sy.set(n[e[s+5]*3],n[e[s+5]*3+1],n[e[s+5]*3+2]),by.sub(_d).normalize(),wy.sub(_d).normalize(),Sy.sub(_d).normalize();let a=by.cross(wy).dot(Sy);Math.abs(a)>.005?(r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(r.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else r.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<n.length;l+=3,c++)n[l+2]===0&&(s.push(c),a++),n[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),r.push(...s,...o),i.push(a,a)}return{indices:r,verticesPerFace:i}}var Kn={};pv(Kn,{calcBoolean:()=>PR,calcBooleanTopological:()=>DR,freeMeshSet:()=>NR,getMeshSet:()=>LR,transformMeshSet:()=>IR});var C1,D1=new Promise(n=>{C1=n}),E1=!1;async function P1(){if(E1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.68/build",[t,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:r});C1(s),E1=!0}var ot,Sl;D1.then(n=>ot=n);function CR(n,e){let t,{positions:r,triIndices:i}=Ay(n.getAttribute("position"),n.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=My(r,i,n);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:r,faceIndices:t,nFaces:s}}function L1(n){let e=n.length,t=e*Uint32Array.BYTES_PER_ELEMENT,r=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?t:r,s=ot._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(n,0),s}function I1(n){switch(n){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function DR(n,e){Sl===void 0&&(Sl=ot.init_csg());let t=L1(n),r=ot.csg_calc_topological(Sl,t,n.length,I1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let f=ot.HEAPU32[s[a]>>2],d=new Uint8Array(ot.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return ot.free_mesh_data(r),{positions:c,indices:u,verticesPerFace:d}}function PR(n,e,t,r){Sl===void 0&&(Sl=ot.init_csg());let i=L1(n),s=ot.csg_calc(Sl,i,n.length,r,I1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let f=ot.HEAPU32[a[c]>>2],d=ot.HEAPF32.subarray(f>>2,(f>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Ae(u,3)),t.setAttribute("normal",new Ae(d,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Br),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function LR(n,e){if(ot===void 0)return-1;let t,r,i;if(e&&n.userData.positions!==void 0){let p=n.userData;i=p.verticesPerFace.length,t=p.positions,r=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){r[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)r[v++]=p.indices[x++]}}else({positions:t,faceIndices:r,nFaces:i}=CR(n,e));let s=t.length,o=r.length,a=t.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,f=ot._malloc(c),d=new Float32Array(ot.HEAPF32.buffer,f,a),m=new Uint32Array(ot.HEAPU32.buffer,f+h,l);return d.set(t,0),m.set(r,0),ot.get_csg_mesh(f,s,f+h,o,i)}function IR(n,e){ot.transform_csg_mesh(n,e.elements)}function NR(n){ot.free_csg_mesh(n)}var xy={ConeGeometry:mS,CubeGeometry:gS,CylinderGeometry:pS,DodecahedronGeometry:yS,EllipseGeometry:US,HelixGeometry:HS,IcosahedronGeometry:WS,LatheGeometry:jS,NonParametricGeometry:qS,PolygonGeometry:YS,PyramidGeometry:XS,RectangleGeometry:id,SphereGeometry:JS,PlaneGeometry:QS,BackdropGeometry:KS,StarGeometry:ZS,TextFrameGeometry:sd,TorusGeometry:$S,TorusKnotGeometry:e1,TriangleGeometry:t1,VectorGeometry:Er},Sh=n=>xy[n.type].create(n);var N1=new Be;function _y(n){let e=!1;return n.scene.objects.traverse((t,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Td=class extends Ct{constructor(t=new Le,r=new Yr){super(t,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];xt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(x1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Kn.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else xt(s)&&s.needsTransformForDownstream===!0?(Kn.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(N1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Kn.transformMeshSet(s.booleanMeshSetAddress,N1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Kn.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Le,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Kn.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}updateGeometry(t){let r=t.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=n=>{var e;return e=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Kr(30,30,30),e};var Ed=new so,Ty=new Br,B1=new Be,Mi=(n,e,t,r,i=!1)=>{let s=e,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ty.copy(s.boundingSphere),Ty.applyMatrix4(o),t.ray.intersectsSphere(Ty)===!1||(B1.copy(o).invert(),Ed.copy(t.ray).applyMatrix4(B1),s.boundingBox!==null&&Ed.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let x=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(n,t,Ed,f,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),E=T*T,C=Math.max(0,d.start),I=Math.min(v.count,d.start+d.count);for(let B=C,N=I-1;B<N;B+=_){if(w.fromBufferAttribute(v,B),b.fromBufferAttribute(v,B+1),Ed.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(n.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||r.push({distance:j,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Cd=new A,Ln=new Gn,Ey=class extends ys{constructor(t){let r=new Le,i=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Se(15711266),c=new Se(15711266),h=new Se(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}r.setAttribute("position",new Ae(s,3)),r.setAttribute("color",new Ae(o,3));super(r,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,r=this.pointMap,i=!0;Ln.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Zn("n1",r,t,Ln,-s,-o,a),Zn("n2",r,t,Ln,s,-o,a),Zn("n3",r,t,Ln,-s,o,a),Zn("n4",r,t,Ln,s,o,a);let l=a;Zn("f1",r,t,Ln,-s,-o,l),Zn("f2",r,t,Ln,s,-o,l),Zn("f3",r,t,Ln,-s,o,l),Zn("f4",r,t,Ln,s,o,l);let c=l,h=.5;Zn("u1",r,t,Ln,s*.7*h,o*1.1,c),Zn("u2",r,t,Ln,-s*.7*h,o*1.1,c),Zn("u3",r,t,Ln,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Zn(n,e,t,r,i,s,o){Cd.set(i,s,o).unproject(r);let a=e[n];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Cd.x,Cd.y,Cd.z)}}var Dd=class extends Ai(Ey){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,r){Mi(this.object,this.geometry,t,r,!0)}};var Al=class extends Ai(Pu){constructor(t,r=15,i=10066329){super(t,r,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Al.geometryHelper,t,r)}};var Ml=class extends Ai(Lu){constructor(t,r=15){super(r);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,r){Mi(this.object,Ml.geometryHelper,t,r)}update(){}};var _l=class extends Ai(Du){constructor(t,r=15,i=6710886){super(t,r,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,_l.geometryHelper,t,r)}};var Pd=class extends Ai(Cu){constructor(t,r=6710886){super(t,r);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,r){Mi(this.object,Pd.geometryHelper,t,r)}update(){if(this.object!==void 0){let t=Pd._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ah=Pd;Ah._vector=new A;var _i=(n,e)=>class extends n{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cn(s)&&s.traverseEntity(o=>{Ji(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}copy(i,s=!0){return super.copy(i,s),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let s=super.toJSON(i),o=s.object;return o.enableHelper=this.enableHelper,s}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Zt(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Cy=new A,vn=class extends _i(Dn(Gn),Dd){constructor(t=window.innerWidth,r=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=r,this.orthoCamera=new oa(t*-.5,t*.5,r*.5,r*-.5,s??-5e4,o),this.perspCamera=new Jt(i,t/r,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,r){let i=new vn().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,r){t==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(t,r){r>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Cy),this.getWorldPosition(Tl),Cy.multiplyScalar(this.targetOffset),t.copy(Tl).add(Cy),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new jt),r=new A(0,0,1).applyQuaternion(t),i=new A().copy(lt.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(lt.DefaultUp).projectOnPlane(r),o=new A().crossVectors(s,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let r=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToObject(t){let r=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:r.clone().sub(s),target:r}}setViewplaneSize(t,r){this.left=-t*.5,this.right=t*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=t/r,this.updateProjectionMatrix()}toOrthographic(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){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.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,r,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,r,i,s,o,a):this.orthoCamera.setViewOffset(t,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,r){super.updateWorldMatrix(t,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,r){return super.copy(t,r),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(t){let r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(t),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(t){if(super.fromJSON(t),this.cameraType=t.cameraType,t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),i=new A().fromArray(t.orbitControlsTarget);this.targetOffset=i.distanceTo(r)}else t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=t.angleOffsetFromUp??0,t.left!==void 0&&(this.left=t.left),t.right!==void 0&&(this.right=t.right),t.top!==void 0&&(this.top=t.top),t.bottom!==void 0&&(this.bottom=t.bottom),t.view!==void 0&&(this.view=Object.assign({},t.view)),t.zoomOrtho!==void 0&&(this.orthoCamera.zoom=t.zoomOrtho),t.nearOrtho!==void 0&&(this.orthoCamera.near=t.nearOrtho),t.far!==void 0&&(this.far=t.far),t.aspect!==void 0&&(this.aspect=t.aspect),t.fov!==void 0&&(this.fov=t.fov),t.focus!==void 0&&(this.focus=t.focus),t.filmGauge!==void 0&&(this.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(this.filmOffset=t.filmOffset),t.zoomPersp!==void 0&&(this.perspCamera.zoom=t.zoomPersp),t.nearPersp!==void 0&&(this.perspCamera.near=t.nearPersp),this.updateProjectionMatrix(),this}toCameraState(t=[]){let r={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 ja(r,t)}fromCameraState(t){let{orthographic:r,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dn(cs),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,r){let i=new Qi().fromState(r);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(t){let r=super.toJSON(t);return r.object.objectType="EmptyObject",r}};var El=class extends _i(Dn(Mu),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new El().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(t,r){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,r),t.size!==void 0&&g1(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)),i&&this.update(),this}fromState(t,r){return super.fromState(t),this.fromDirectionalLightState(t,r),this}};var Cl=class extends _i(Dn(Au),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new yr(s,o),l=new go(a,new Se(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,r,i){let s=new Cl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof go&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let r=this._gizmos[t];if(r instanceof go){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(s,o),r.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.decay=t.decay,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize??[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromPointLightState(t,r),this}};var O1=new A,R1=new A,F1=new jt,Dl=class extends _i(Dn(Su),Ah){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=je.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new An(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,r,i){let s=new Dl().fromState(r,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let r=this._gizmos[t];r instanceof An&&r.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),R1.setFromMatrixPosition(this.matrixWorld),F1.setFromRotationMatrix(this.matrixWorld),O1.copy(this.up).applyQuaternion(F1).negate().multiplyScalar(this.distance),this.target.position.copy(R1).add(O1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(t,r=!0){return super.copy(t,r),this.color.copy(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let r=super.toJSON(t),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}fromJSON(t){super.fromJSON(t),this.color.set(t.color),this.intensity=t.intensity,this.distance=t.distance,this.angle=t.angle,this.decay=t.decay,this.penumbra=t.penumbra,this.shadow.normalBias=t.shadow.normalBias??0,this.shadow.radius=t.shadow.radius,this.shadow.mapSize.fromArray(t.shadow.mapSize);let r=this.shadow.camera,i=t.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(t,r){return super.fromLightState(t,r),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)),this}fromState(t,r){return super.fromState(t),this.fromSpotLightState(t,r),this}};var z1=n=>n.tagName==="VIDEO",Po=class{static resize(e,t,r){let i=e/t,s;if(!r.image)return;let o=r.image;z1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/i):r.repeat.set(1,1*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/s*-1,1):r.repeat.set(1*i/s,1)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let i=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let i=r.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];o1(a)&&(Po.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){let s=e/t,o,a=r.image;z1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var Pl=class extends Ct{constructor(t,r=new Ir){super(t,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(t,r){super.resizeGeometry(t,r,0),this.material.userData.layers&&Po.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh2D",r}clone(){let t=super.clone();return t.updateGeometry({}),t}static fromTexture(t){let r,i;if(t instanceof bu){let a=t.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=t.image;r=a.width*.5,i=a.height*.5}let s=id.create({parameters:{width:r,height:i}}),o=new Ir;return o.layersList.changeLayer(0,{type:"texture",texture:t}),o.layersList.moveLayer(0,1),o.dispose(),new Pl(s,o)}};var Ll=class extends Ct{constructor(t,r=new Yr){super(t,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(t){let r=super.toJSON(t);return r.object.objectType="Mesh3D",r}};var Il=class extends Ll{constructor(t,r=new Yr){super(t,r);this.objectType="NonParametric"}toJSON(t){let r=super.toJSON(t);return r.object.objectType="NonParametric",r}};var Ld=class extends xs{constructor(e){super(e)}load(e,t,r,i){let s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},r,i)}parse(e){return new Dy(e)}},Dy=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let r=[],i=OR(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(r,i[s].toShapes());return r}};function OR(n,e,t){let r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<r.length;c++){let h=r[c];if(h===`
4492
4492
  `)a=0,l-=s;else{let u=RR(h,i,a,l,t);a+=u.offsetX,o.push(u.path)}}return o}function RR(n,e,t,r,i){let s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}let o=new Iu,a,l,c,h,u,f,d,m;if(s.o){let p=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,x=p.length;g<x;)switch(p[g++]){case"m":a=p[g++]*e+t,l=p[g++]*e+r,o.moveTo(a,l);break;case"l":a=p[g++]*e+t,l=p[g++]*e+r,o.lineTo(a,l);break;case"q":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,o.quadraticCurveTo(u,f,c,h);break;case"b":c=p[g++]*e+t,h=p[g++]*e+r,u=p[g++]*e+t,f=p[g++]*e+r,d=p[g++]*e+t,m=p[g++]*e+r,o.bezierCurveTo(u,f,d,m,c,h);break}}return{offsetX:s.ha*e,path:o}}var $t=class extends ir{constructor({char:t,originalChar:r,fontFamily:i,letterSpacing:s,fontSize:o,LOD:a=16},l=new Un({color:0,opacity:1,visible:!0,transparent:!0,side:Wt})){let c=$t.loadChar(t,i,a);super(c.geometry,l);this.char=t,this.originalChar=r??t,this.fontFamily=i,this.letterSpacing=s,this.fontSize=o,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new O,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return $t._fontPath}static set FONTS_PATH(t){$t._fontPath=t}updatePosition(t,r){this.localPosition.copy(t);let i=new A(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(t){let r=t/this.resolution;this.fontSize=t,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(t){if(this.fontFamily===t)return;this.fontFamily=t;let r=$t.loadChar(this.char,t,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(t){if(this.char===t)return;this.char=t;let r=$t.loadChar(t,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(t){this.letterSpacing!==t&&(this.letterSpacing=t,this.updateFontSize(this.fontSize))}updateLOD(t){if(this.LOD===t)return;this.LOD=t;let r=$t.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let t={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new $t(t).copy(this)}static loadFont(t){return new Promise(function(r,i){$t.fontCache[t]?r($t.fontCache[t]):new Ld().load($t.FONTS_PATH+t+".json",o=>{$t.fontCache[t]=o,r(o)},void 0,i)})}static loadChar(t,r,i){if($t.charCache[t]){if($t.charCache[t][i]&&$t.charCache[t][i].fontFamily===r)return $t.charCache[t][i]}else $t.charCache[t]={};let s=$t.fontCache[r],o=s.generateShapes(t,1);return $t.charCache[t][i]={geometry:new pa(o,i),fontFamily:r,resolution:s.data.resolution,glyphsHa:s.data.glyphs[t].ha},$t.charCache[t][i]}},Xr=$t;Xr.charCache={},Xr.fontCache={},Xr._fontPath="/_assets/_fonts/";var Id=new O,Hs=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new O(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,i;for(i=e;i>=0;i-=1)if(this.message[i].char===" "){r=!1,t.length===0&&(i-=1,t.splice(0,0,this.message[i]));break}else t.splice(0,0,this.message[i]);return r?t=[]:this.message.splice(i+1,t.length),t}getWord(e=0,t=1){let r=[],i=e;for(i=e;;i+=t){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}t>0?(r.push(this.message[i]),this.message.splice(i,1),i-=t):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,i=e;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=t}return(i<0||i>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let i=t;i<=r;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,i,s){switch(r){case 1:this.leftAlign(e,s);break;case 3:this.centerAlign(this.spaceLeft(t),e,s);break;case 2:this.rightAlign(this.spaceLeft(t),e,s);break;case 4:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Id.set(t,r);let i=this.message.length;for(let s=0;s<i;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Id),e)}leftAlign(e,t){this.align=1,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=3,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=2,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=4,this.endLine){this.offsetCharacters(t,0,r);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(t,0,r);return}let s=e/i,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),Id.set(o,r),this.message[a].updatePosition(this.message[a].localPosition.add(Id),t)}clone(){let e=new Hs(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var Py=class extends Ct{constructor(t,r=new Ir({transparent:!0,opacity:1,visible:!1,side:Wt})){super(t,r);this.objectType="TextFrame";this.charContainer=new lt,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=t.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(t,r,i){let s=sd.create({parameters:{width:r.width,height:r.height}}),o=new Py(s).fromState(r,i);return o.uuid=t,o}async updateText(t){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Xr.loadFont(i),r.text=t;let s=r.textOrigin,o=new Un({visible:r.visible,transparent:!0,side:Wt}),a=t.split(`
4493
4493
  `),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let u=new Hs(l,r.lineHeight,r.fontSize);return u.message=c.split("").map(f=>{let d={char:f,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=o.clone();m.color=r.hexColor,m.opacity=r.opacity;let p=new Xr(d,m);return u.addChar3D(p,s),this.charContainer.add(p),p}),l+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let t=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;t.length;)t.pop()}raycast(t,r){let i=[];if(super.raycast(t,i),i.length>0){r.push(i[0]);return}let s=[];for(let o=0,a=this.charContainer.children.length;o<a;++o)if(this.charContainer.children[o]instanceof Xr&&(t.intersectObject(this.charContainer.children[o],!1,s),s.length>0)){s[0].object=this,r.push(s[0]);return}}updateGeometry(t){let r=this.userData,i=this.geometry.userData,s=i.parameters.width,o=i.parameters.height,a=t.parameters?.width??s,l=t.parameters?.height??o,c=r.textFrame;super.updateGeometry(t),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==o?(this.checkOverFlow(),this.checkCapacity()):a!==s&&(s<a?this.checkCapacity():s>a&&this.checkOverFlow())}checkOverFlow(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.textLines;for(let o=t;o<s.length;o++){s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(i);let a=[];for(;s[o].checkOverFlow(r.textFrame.maxLineSize);)s[o].containSpaceOverFlow()?a.unshift(s[o].getWord(s[o].message.length-1,-1)):a.unshift(s[o].popChar());if(a.length>0){s[o+1]===void 0?(s[o].isEndLine(!1),this.createTextLine()):s[o].endLine&&(this.createTextLine(o+1),s[o].isEndLine(!1),s[o+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)s[o+1].addChar3D(a[c][h],i,l),l+=1;s[o+1].fullUpdate(i)}s[o].fullUpdate(i)}this.textFullUpdate(t)}checkCapacity(t=0){let r=this.userData,i=r.textFrame.textOrigin,s=r.textFrame.maxLineSize,o=r.textFrame.textLines;for(let a=t;a<o.length;a+=1)if(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i),!!o[a-1])for(;!o[a-1].endLine;){let l,c=o[a-1].spaceLeft(s);if(o[a].wordSize(0,1)<=c){o[a].containSpace()?l=o[a].getWord(0,1):l=o[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&o[a-1].addChar3D(l[h],i)}else{o[a].isEmpty()?(o[a].endLine&&o[a-1].isEndLine(!0),o.splice(a,1),a-=1):(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i));break}}this.textFullUpdate(t)}createTextLine(t=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(t,0,new Hs(this.getNewLinePosition(t),i.lineHeight,i.fontSize))}textFullUpdate(t=0){let i=this.userData.textFrame,s=i.textLines,o=this.getVerticalAlignmentOffSet();for(let a=t;a<s.length;a++)s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i.textOrigin),s[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,o)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(t){let i=this.userData.textFrame.textLines,s=0;for(let o=0;o<t;o+=1)s+=i[o].maxCharSize*i[o].lineHeight;return s}updateColor(t){let r=this.userData;r.textFrame.hexColor=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.color?.isColor&&(l.color=t)}}}updateOpacity(t){let r=this.userData;r.textFrame.opacity=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.opacity=t}}}updateVisible(t){let r=this.userData;r.textFrame.visible=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.visible=t}}}async updateFontFamily(t){await Xr.loadFont(t);let i=this.userData.textFrame,s=i.textLines;i.fontFamily=t;for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(t){let i=this.userData.textFrame,s=i.textLines,o=i.fontSize;i.fontSize=t;for(let a=0;a<s.length;a++)s[a].updateFontSize(t);this.textFullUpdate(),t>o?this.checkOverFlow():t<o&&this.checkCapacity()}async updateTextTransform(t){let i=this.userData.textFrame;await Xr.loadFont(i.fontFamily);let s=i.textLines;switch(i.textTransform=t,t){case 2:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=t;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++)o[a].updateLetterSpacing(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(t){let r=this.userData;r.textFrame.LOD=t;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(t){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=t;for(let s=0;s<i.length;s++)i[s].updatelineHeight(t);this.textFullUpdate()}updateVerticalAlignment(t){let r=this.userData;r.textFrame.verticalAlignment=t,this.textFullUpdate()}updateHorizontalAlignment(t){let r=this.userData;r.textFrame.horizontalAlignment=t,this.textFullUpdate()}toJSON(t){let r=super.toJSON(t),i=r.object;i.objectType="TextFrame";let o=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=o,r}async fromJSONasync(t){if(super.fromJSON(t),t.userData!==void 0){let r=t.userData.textFrame;await Xr.loadFont(r.fontFamily),r.textOrigin=new A(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Un({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:Wt});r.textLinesData&&(r.textLines=r.textLinesData.map((s,o)=>{let a=new Hs(Number(s.yLinePos),Number(s.lineHeight),Number(s.maxCharSize)),l=s.message.map((c,h)=>{if(c.char===void 0){let d=r.textLines[o].message[h];if("geometries"in d){let m=d.geometries[0].userData.parameters;Object.assign(c,{LOD:m.lod,char:m.char,fontFamily:m.fontFamily,fontSize:m.fontSize,letterSpacing:m.letterSpacing,originalChar:m.char})}}let u={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},f=new Xr(u,i.clone());return a.addChar3D(f,r.textOrigin),this.charContainer.add(f),f});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(t,r){if(t.color!==void 0){let i=Zt(t.color,r);this.updateColor(i),this.updateOpacity(i.a)}t.alpha!==void 0&&this.updateOpacity(t.alpha),t.font!==void 0&&this.updateFontFamily(t.font),t.horizontalAlign!==void 0&&this.updateHorizontalAlignment(t.horizontalAlign),t.verticalAlign!==void 0&&this.updateVerticalAlignment(t.verticalAlign),t.textTransform!==void 0&&this.updateTextTransform(t.textTransform),t.fontSize!==void 0&&this.updateFontSize(t.fontSize),t.lineHeight!==void 0&&this.updateLineHeight(t.lineHeight),t.letterSpacing!==void 0&&this.updateLetterSpacing(t.letterSpacing),t.text!==void 0&&t.text!==""&&this.updateText(t.text),(t.width!==void 0||t.height!==void 0)&&this.updateGeometry({parameters:{width:t.width,height:t.height}})}fromState(t,r){return super.fromState(t),this.fromTextFrameData(t,r),this}convertToVector(){let{fontFamily:t,hexColor:r}=this.userData.textFrame,i=new Qi;i.name="Text Shape";let s=Xr.fontCache[t];for(let o of this.charContainer.children)o instanceof Xr&&s.generateShapes(o.char,1).forEach(a=>{let l=new dt().fromShape(a);l.applyScale(o.scale.x,o.scale.y);let c=Er.create({shape:l}),h=new Ir({side:Wt});h.color=r;let u=new Vs(c,h);u.name=o.char,u.position.copy(o.position),u.rotation.copy(o.rotation),i.attach(u)});return i}},Lo=Py;Lo.VerticalAlign=Dg,Lo.HorizontalAlign=Cg,Lo.TextTransform=Pg;var V1=wM(G1());var Ly;ad.then(n=>{Ly=n});var H1=new Be,FR=new Be,zR=new Be,$n=new yr,Ws=new A,UR=new Be,GR=new Be,js=class extends Ct{constructor(t,r,i,s=new Yr){super(i??r,s);this.subdivPointer=t;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Be;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new Be;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,r,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Pn.build(r.geometry,void 0,void 0,!r.flatShading),l=vh(r.material,i),c=new js(s,o,a||void 0,l);return r.geometry.phongAngle!==void 0&&(c.phongAngle=r.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=t,c.fromState(r),c}shallowClone(t){return new Il(this.geometry,this.material).shallowCopy(this,t)}toJSON(t){let r=super.toJSON(t);return r.object.objectType="SubdivObject",r}buildFromStore(t,r){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Pn.build(t,r,this.subdivPointer,this.smoothShading,this.shearScale);if(t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Pn.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Pn.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,r){this.geometry=this.originalGeometry,Ct.prototype.raycast.call(this,t,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,r=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,V1.SVD)(r),a=H1.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=FR.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=zR.copy(l).transpose();this.shearScale=UR.makeScale(o[0],o[1],o[2]).multiply(c).premultiply(l),this.shearScaleInv=GR.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),o.every(h=>Math.abs(o[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Br);let r=t.attributes.position,i=t.boundingSphere.center;$n.setFromBufferAttribute(r),$n.getCenter(i),t.boundingSphere.radius=i.distanceTo($n.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let r=this.originalGeometry;$n.min.set(t[0],t[2],t[4]),$n.max.set(t[1],t[3],t[5]),this.shearScaleInv&&($n.min.applyMatrix4(this.shearScaleInv),$n.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Br);let i=r.boundingSphere.center;$n.getCenter(i),r.boundingSphere.radius=i.distanceTo($n.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),$n.getSize(Ws);let s={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&(Ly.free_bvh(this.subdivPointer),Ly.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,k1(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(k1(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function k1(n,e,t,r){let i=n.position.array,s=n.normal.array,o=H1.makeScale(e,t,r).invert().elements,a,l,c;for(var h=0,u=i.length;h<u;h+=3)i[h]*=e,i[h+1]*=t,i[h+2]*=r,a=s[h],l=s[h+1],c=s[h+2],s[h]=o[0]*a+o[4]*l+o[8]*c,s[h+1]=o[1]*a+o[5]*l+o[9]*c,s[h+2]=o[2]*a+o[6]*l+o[10]*c}function W1(n,e){e.flatShading!==void 0&&(n.flatShading=e.flatShading,n.needsUpdate=!0),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?n.side=zn:e.side===1?n.side=gr:n.side=Wt)}function kR(n,e){if(Array.isArray(n.material))for(let t of n.material)W1(t,e);else{let t=n.material;W1(t,e)}n.objectType==="SubdivObject"&&e.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!e.flatShading,n.updateMesh())}function j1(n,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=js.createFromState(n,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new Le:Md(e.geometry,t),s="materials"in e?u1(e.materials,t):vh(e.material,t);jf.is2DParametricMesh(i.userData.type)?r=new Pl(i,s):i?.userData.type==="VectorGeometry"?r=new Vs(i,s):e.geometry.type==="NonParametricGeometry"?r=new Il(i,s):e.geometry.type==="BooleanGeometry"?(r=new Td(void 0,s),r.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(r.phongAngle=e.geometry.phongAngle)):r=new Ll(i,s),r.uuid=n,r.fromState(e)}return kR(r,e),r}function q1(n,e,t){return e.type==="Mesh"?j1(n,e,t):e.type==="TextFrame"?Lo.createFromState(n,e,t):e.type==="Empty"?Qi.createFromState(n,e):e.type==="PointLight"?Cl.createFromState(n,e,t):e.type==="SpotLight"?Dl.createFromState(n,e,t):e.type==="DirectionalLight"?El.createFromState(n,e,t):Is.is(e.type)?vn.createFromState(n,e):(console.error(e),new Qi)}function VR(n,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=n.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=n.depthTexture}function Y1(n,e,t){if(!t.userData.layers)return!1;let r=!1,i=t.userData.layers.getLayersOfType("transmission");return i.length>0?(e.layers.set(3),r=!0,n!==void 0&&i.forEach(s=>VR(n,s))):e.layers.set(0),r}function X1(n,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Y1(n,r,r.material[i])&&(t=!0);else Y1(n,r,r.material)&&(t=!0)}),t}function J1(n,e){"material"in n&&HR(n.material,e),"geometry"in n&&n.geometry.dispose()}function HR(n,e){Tw(n).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var Q1=new A,Iy=class extends Ad(un){constructor(t,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new aa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Se(1,0,0);this.bgColor=new Se(1,1,1);this.entityByUuid={};this.ambientLight=new mo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(t,r)}needsTransmission(t){return this.needsTransmissionDirty&&(this._needsTransmission=X1(t,this),t!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(t){if(t===""||t===void 0)return;let r=this.entityByUuid[t];return r===void 0?this.getObjectByProperty("uuid",t):r}get color(){return this._color}set color(t){this.fogUseBGColor===!0&&this.backupFog.color.copy(t),this._color.copy(t)}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,r){if(this.createChildrenObjects(t.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Zt(t.backgroundColor,r)),this.updateFog(t.fog,r),this.updateAmbientLight(t.environment.ambientLight,r),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof vn&&this.switchActiveCamera(i)}this.traverse(i=>{xt(i)&&i.recomputeBoolean()})}clearScene(t){this.traverseEntity(r=>{J1(r,t)});for(let r of this.children)Cn(r)&&r.removeFromParent()}resetAfterClear(t,r){this.init(t,r)}createPersonalCamera(){let t=vn.createFromState(Iy.PERSONAL_CAMERA_ID,{...Yf.defaultData,name:"Personal Camera"});return t.enableHelper=!1,t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let r=[],i=s=>{for(let o of s.children)Cn(o)&&!o.raycastLock&&o.visible&&((zt(o)||Ji(o)&&o.enableHelper&&o.objectHelper.parent)&&t.intersectObject(o,!1,r),i(o))};return i(this),r}traverseEntity(t){for(let r of this.children)Cn(r)&&r.traverseEntity(t)}updateFog(t,r){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Zt(t.color,r),this.backupFog.near=t.near,this.backupFog.far=t.far}toJSON(t){return{}}fromJSON(t){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(t,r){m1(this.ambientLight,t,r),t.groundColor!==void 0&&(this.ambientLight.groundColor=Zt(t.groundColor,r)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=t,t.enableHelper=!1}setBackgroundColor(t){this.bgColor=t,this.alpha=t.a}createChildrenObjects(t,r,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,r,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let r of t.children)this.unregisterObject(r)}createChildObject(t,r,i,s,o){let a=q1(t,r,o);return a&&(this.entityByUuid[t]=a,s.add(a),xt(s)&&zt(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let r=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;r.push(...h.vertices)}let i=new yr;return i.setFromPoints(r),i.getCenter(Q1),Q1}copyMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(t,r){if(t===null){r.identity();return}let i=this.find(t)?.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(t){this.traverseEntity(r=>{if(r instanceof Ct)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)t(r.material[i]);else t(r.material)})}updateCanvasSize(t,r){this.activeCamera.setViewplaneSize(t,r);let i,s;t>=r?(i=r/t,s=1):(i=1,s=t/r),this.traverseMaterial(o=>{o.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Mh=Iy;Mh.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var nA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var _h="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var WR=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4494
4494
  uniform mediump sampler2D inputBuffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/runtime",
3
- "version": "0.9.67",
3
+ "version": "0.9.68",
4
4
  "type": "module",
5
5
  "main": "./build/runtime.js",
6
6
  "module": "./build/runtime.js",