@splinetool/loader 0.9.98 → 0.9.99

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.
@@ -1330,4 +1330,4 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1330
1330
  return color.xyz;
1331
1331
 
1332
1332
  }`,[ft.simplex,e,o,s])}}();var Wf=require("three");function Hf(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var _a=class extends An{constructor(e,r){super(new Wf.Matrix3);this.repeat=e;this.offset=r;Hf(this.value,e,r)}updateMatrix(){Hf(this.value,this.repeat,this.offset)}};var wr=class{constructor(t,e,r,o){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in r)nc(i,this,r)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return _r.createLigherLayer(t,e,r,o);if(r.type==="texture"){let i=o.image(r.texture.image),s=new Gi(i,r.texture.wrapping),l=new wa(i),c=new _a(r.texture.repeat,r.texture.offset),p=new Y(r.crop?1:0),a=new ye(r.projection??0),u=new ye(["x","y","z"].indexOf(r.axis)??0),d=new ye(r.side??0),f=new st(r.size?new Oe.Vector2(r.size[0],r.size[1]):new Oe.Vector2(100,100)),m=new Y(r.alpha??1),h=new ye(r.mode??0),y=new Ni(s,l,p,a,u,d,f,c,m,h),x=new _e(y.calpha,"f");return new ot(t,e,r,{texture:s,textureSize:l,crop:p,projection:a,axis:u,side:d,size:f,mat:c,alpha:m,mode:h},y,h,x)}else if(r.type==="matcap"){let i=o.image(r.texture.image),s=new Gi(i,r.texture.wrapping),l=new Y(r.alpha??1),c=new ye(r.mode??0),p=new Ei(s,l,c),a=new _e(p.calpha,"f");return new ot(t,e,r,{texture:s,alpha:l,mode:c},p,c,a)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new ct(new Oe.Vector3(...r.offset)),s=new Y(r.scale??10),l=new Y(r.intensity??8),c=new Y(r.movement??1),p=new ye(r.noiseType??0),a=new Ti(l,c,i,s,p);return new Vi(t,e,r,{offset:i,scale:s,intensity:l,movement:c,noiseType:p},a)}else throw new Error;else return fS(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props?!0:jf(o.props,r,this,e)}else if(o.path[0]==="texture")return"texture"in e?oc(o.props,r,this):!0;return!1}dispose(){}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},ot=class extends wr{constructor(e,r,o,i,s,l,c){super(e,r,o,i);this.color=s;this.mode=l;this.alpha=c}},Vi=class extends wr{constructor(e,r,o,i,s){super(e,r,o,i);this.position=s}},_r=class extends wr{constructor(e,r,o,i,s){super(e,r,o,s);this.data=o;this.node=i}static createLigherLayer(e,r,o,i){let s,l=new Y(o.alpha),c=new ye(o.mode),p;if(o.category==="lambert"){s=new Li;let a=new Ne(i.color(o.emissive)??0);p={emissive:a},s.emissive=a}else if(o.category==="phong"){s=new Sa;let a=new Y(o.shininess??30),u=new Ne(i.color(o.specular)??1118481);p={shininess:a,specular:u},s.shininess=a,s.specular=u}else if(o.category==="toon"){s=new Di;let a=new Y(o.shininess??30),u=new Ne(i.color(o.specular)??1118481);p={shininess:a,specular:u},s.shininess=a,s.specular=u}else if(o.category==="physical"){s=new Oi;let a=new Y(o.roughness??.3),u=new Y(o.metalness??0),d=new Y(o.reflectivity??.5);p={roughness:a,metalness:u,reflectivity:d},s.roughness=a,s.metalness=u,s.reflectivity=d}else s=new No,p={};return s.alpha=new Y(1),s.shadingAlpha=l,s.shadingBlend=c,p.alpha=s.shadingAlpha,p.mode=s.shadingBlend,new _r(e,r,o,s,p)}};function qf(n){let t=n instanceof wr?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}function dS(n,t,e,r){switch(n.type){case"color":{let o=new Ne(r.color??5855577),i=new Y(r.alpha??1),s=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new ye(r.mode??0);return o.alpha=i,new ot(t,e,n,{color:o,alpha:i,mode:l},o,l,s)}case"fresnel":{let o=new Ne(r.color??16777215),i=new Y(r.bias??.1),s=new Y(r.scale??1),l=new Y(r.intensity??2),c=new Y(r.factor??1),p=new Y(r.alpha??1),a=new ye(r.mode??0),u=new xi(o,i,s,l,c,p,a),d=new _e(u.calpha,"f");return new ot(t,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,alpha:p,mode:a},u,a,d)}case"rainbow":{let o=new Y(r.filmThickness??30),i=new Y(r.movement??0),s=new ct(r.wavelengths??new Oe.Vector3(0,0,0)),l=new Y(r.noiseStrength??0),c=new Y(r.noiseScale??1),p=new ct(r.offset??new Oe.Vector3(0,0,0)),a=new Y(r.alpha??1),u=new vi(o,i,s,l,c,p,a),d=new _e(u.calpha,"f"),f=new ye(r.mode??0);return new ot(t,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:p,alpha:a,mode:f},u,f,d)}case"transmission":{let o=new Y(r.thickness??10),i=new Y(r.ior??1.5),s=new Y(r.roughness??.5),l=ut.transmissionSize,c=ut.transmissionRenderTarget,p=ut.transmissionRenderTargetDepth,a=window.innerWidth,u=window.innerHeight,d=a>=u?new st(u/a,1):new st(1,a/u),f=new Y(r.alpha??1),m=new Si(o,i,s,l,c,p,d,f),h=new _e(m.calpha,"f"),y=new ye(r.mode??0);return new ot(t,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:d,alpha:f,mode:y},m,y,h)}case"toon":{let o=new ye(r.positioning??0),i;r.colors?i=new Zt(r.colors.length,r.colors):(i=new Zt(10,new Oe.Vector4(0,0,0,1)),i.value[1]=new Oe.Vector4(1,1,1,1));let s;r.steps?s=new Qt(r.steps.length,r.steps):(s=new Qt(10,1),s.value[0]=0);let l=new ct(r.source??new Oe.Vector3(0,0,0)),c=new no(r.isWorldSpace??!0),p=new Y(r.noiseStrength??0),a=new Y(r.noiseScale??1),u=new Ht(r.shadowColor),d=new ct(r.offset??new Oe.Vector3(0,0,0)),f=new Y(r.alpha??1),m=new Ri(o,i,s,l,c,p,a,u,d,f),h=new _e(m.calpha,"f"),y=new ye(r.mode??0);return new ot(t,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:p,noiseScale:a,shadowColor:u,offset:d,alpha:f,mode:y},m,y,h)}case"outline":{let o=new Ne(r.outlineColor??16777215),i=new Ne(r.contourColor??16777215),s=new Y(r.outlineWidth??.1),l=new Y(r.contourWidth??.1),c=new Y(r.outlineThreshold??.1),p=new Y(r.contourThreshold??.1),a=new Y(r.outlineSmoothing??.1),u=new Y(r.contourFrequency??.1),d=new ct(r.contourDirections??new Oe.Vector3(0,1,0)),f=new no(r.positionalLines??!1),m=new no(r.compensation??!0),h=ut.normalRenderTarget,y=ut.normalRenderTargetDepth,x=ut.pixelRatioNode,v=ut.resolution,A=new Y(r.alpha??1),S=new bi(o,i,s,l,c,p,a,u,d,f,m,v,h,y,x,A),b=new _e(S.calpha,"f"),D=new ye(r.mode??0);return new ot(t,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:p,outlineSmoothing:a,contourFrequency:u,contourDirection:d,positionalLines:f,compensation:m,alpha:A,mode:D},S,D,b)}case"depth":{let o=new ye(r.gradientType??0),i=new no(r.smooth??!1),s=new Y(r.near??50),l=new Y(r.far??200),c=new Y(r.isVector??1),p=new Y(r.isWorldSpace??0),a=new ct(r.origin??new Oe.Vector3),u=new ct(r.direction??new Oe.Vector3),d=new ye(r.num??0),f;r.colors?f=new Zt(d.value+1,r.colors):(f=new Zt(d.value+1,new Oe.Vector4(0,0,0,1)),f.value[1]=new Oe.Vector4(1,1,1,1));let m;r.steps?m=new Qt(d.value+1,r.steps):(m=new Qt(d.value+1,1),m.value[0]=0);let h=new Y(r.alpha??1),y=new ye(r.mode??0),x=new wi(o,i,s,l,c,p,a,u,f,m,d,h),v=new _e(x.calpha,"f");return new ot(t,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:p,origin:a,direction:u,colors:f,steps:m,num:d,alpha:h,mode:y},x,y,v)}case"noise":{let o=new Y(r.scale??1),i=new ct(r.size??new Oe.Vector3(100,100,100)),s=new Y(r.move??1),l=new st(r.fA??new Oe.Vector2(1.7,9.2)),c=new st(r.fB??new Oe.Vector2(8.3,2.8)),p=new st(r.distortion??new Oe.Vector2(1,1)),a=new Ht(r.colorA),u=new Ht(r.colorB),d=new Ht(r.colorC),f=new Ht(r.colorD),m=new Y(r.alpha??1),h=new ye(r.mode??0),y=new ye(r.noiseType??0),x=new gi(o,i,s,l,c,p,a,u,d,f,m,y),v=new _e(x.calpha,"f");return new ot(t,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:p,colorA:a,colorB:u,colorC:d,colorD:f,alpha:m,mode:h,noiseType:y},x,h,v)}case"normal":{let o=new ct(r.cnormal??new Oe.Vector3(1,1,1)),i=new Y(r.alpha??1),s=new ye(r.mode??0),l=new Ii(o,i),c=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return c.keywords.alpha=i,new ot(t,e,n,{cnormal:o,alpha:i,mode:s},l,s,c)}case"gradient":{let o=new ye(r.gradientType??0),i=new no(r.smooth??!1),s;r.colors?s=new Zt(r.colors.length,r.colors):(s=new Zt(10,new Oe.Vector4(0,0,0,1)),s.value[1]=new Oe.Vector4(1,1,1,1));let l;r.steps?l=new Qt(r.steps.length,r.steps):(l=new Qt(10,1),l.value[0]=0);let c=new st(r.offset??new Oe.Vector2(0,0)),p=new st(r.morph??new Oe.Vector2(0,0)),a=new Y(r.angle??0),u=new Y(r.alpha??1),d=new ye(r.mode??0),f=new Ai(o,i,s,l,c,p,a,u),m=new _e(f.calpha,"f");return new ot(t,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:p,angle:a,alpha:u,mode:d},f,d,m)}default:{let o=new Ne(1,0,0,1),i=new Y(1),s=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new ye(0);return o.alpha=i,new ot(t,e,n,{color:o,alpha:i,mode:l},o,l,s)}}}function fS(n,t,e,r){let o=Rf(e,r);return dS(e,n,t,o)}function nc(n,t,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n=="visible"){let o=t.uniforms[`f${t.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return r}}var Gt=class extends Ta.ShaderMaterial{constructor(e,r){super(void 0);this.data=e;this.layerIdGen=0;this.type="NodeMaterial";this.uniformsBackup={};this.fog=!0,this.updaters=[],this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile,this.transparent=!0,this.reset(e,r)}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.data.category}reset(e,r){let o=e.layers??Er.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>wr.create(this.layerIdGen++,i.id,i.data,r)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r)}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof _r),this.lightLayer===void 0&&(this.lightLayer=new _r(0,"",Zr.defaultData("light","basic"),new No,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,r,o){if(this.data=r,e.path[0]==="layers"){let i=e.path[1];if(i===void 0){if(this.layers.reverse(),e.type===4){let s=wr.create(this.layerIdGen++,e.id,e.data,o);this.layers.splice(e.localIndex,0,s)}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose();else if(e.type===6){let s=this.layers.findIndex(c=>c.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l)}this.layers.reverse(),this.onUpdate(o)}else{let s=this.layers.find(l=>l.uuid===i);if(s){let l=r.layers.data(i);if(s.updateByOp({...e,path:e.path.slice(2)},l,o)){let p=wr.create(this.layerIdGen++,i,l,o);this.layers.splice(this.layers.findIndex(a=>a.uuid===i),1,p),this.onUpdate(o)}}}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof ot),r=this.layers.findIndex(o=>o instanceof _r);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let s=this.layers[i];s instanceof ot&&(o=new _i(o,s.color,s.alpha,s.mode))}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new _e("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof _r);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];i instanceof ot&&(e=new _i(e,i.color,i.alpha,i.mode))}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof Vi);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new It(r,e[o].position,It.ADD),r=new It(r,new Y(.5).setReadonly(!0),It.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,s,l)=>Math.min(Math.max(i,s),l);for(let i of this.layers)if(i.type==="displace"){this.uniformsBackup[`f${i.id}_intensity`]=i.uniforms[`f${i.id}_intensity`].value;let s=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=s}}restoreClampedUniforms(){for(let e of this.layers)e.type==="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.category}",`;else{let o=rc[r.type];o&&o.length?e+=`["${r.type}", "${o.map(i=>r[i]).join('","')}"],`:e+=`"${r.type}",`}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){e=e??{};let r=e.builder??new va;return this.lights=this.lightLayer.data.category!=="basic",r.setMaterial(this,e.renderer),r.build(this.fragment,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.transparent=r.requires.transparent||this.blending>Ta.NormalBlending,this}dispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Gt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(n){n===!0&&this.version++,this.needsCompile=n},get:function(){return this.needsCompile}}});var Rt=require("three");function mS(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position)return;let t=new Map,e=n.geometry.attributes.position.array,r=n.geometry.attributes.normal.array,o=new Float32Array(e.length);for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=new Rt.Vector3(r[i],r[i+1],r[i+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new Rt.Vector3})}t.forEach((i,s)=>{for(let l of i.normals)i.result.add(l);i.result.divideScalar(i.normals.length)});for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=t.get(s)?.result;l&&(o[i]=l.x,o[i+1]=l.y,o[i+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Rt.Float32BufferAttribute(o,3))}function hS(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let t=n.geometry.attributes.position.array,e=new Float32Array(t.length),r=new Rt.Vector3;for(let o=0;o<t.length;o+=3)r.set(t[o],t[o+1],t[o+2]).normalize(),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z;n.geometry.setAttribute("extrudeNormal",new Rt.Float32BufferAttribute(e,3))}function ao(n){if(n.objectType!=="TextFrame"){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Gt)||n.material.getLayersOfType("outline").length===0)return;n.objectType==="Mesh2D"?hS(n):mS(n)}}function lo(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes.position.array,e=new Float32Array(t.length),r=parseInt(n.uuid.replace(/\D/g,"")),o=[Rt.MathUtils.seededRandom(r),Rt.MathUtils.seededRandom(r+1e4),Rt.MathUtils.seededRandom(r+2e4)];for(let i=0;i<t.length;i++)e[i]=o[i%3];n.geometry.setAttribute("randomColor",new Rt.BufferAttribute(e,3))}var lt=class extends kt(Aa.Mesh){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Aa.Matrix4;this.booleanExclude=null;Array.isArray(r)&&e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0)}get isGroup(){return this._cloner?.parameters.hideBase===!0}get isMesh(){return!this.isGroup}set isMesh(e){}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}updateGeometry(e){let r=this.geometry,o=ac[r.userData.type],i=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=o.build(o.normalizeInputs(e,i)),l=r.uuid;this.geometry.dispose(),this.geometry=s,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),ao(this),r.getAttribute("randomColor")&&lo(this)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=Fi(r),i=this.material;return new this.constructor(o,i).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new _o(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new _o(this)),this.cloner.fromClonerState(e))}fromState(e,r){return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=e.castShadow??!0,this.receiveShadow=e.receiveShadow??!0,this.booleanExclude=e.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Jt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),mr(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)fr(e)&&(e.freeBooleanPointer(),mr(e)&&e.invalidateUpstreamBooleanData())}};var gS=new co.Vector3(0,0,1),$f=new co.Vector3,Xf=new co.Vector3,Yf=new co.Matrix3,Ln=class extends lt{constructor(e=xt.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new co.EventDispatcher;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=e,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Yf.getNormalMatrix(this.matrixWorld),$f.copy(gS).applyMatrix3(Yf).normalize(),Xf.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint($f,Xf)}clone(e){let r=this.shape.clone(),o=this.material,i=this.geometry.userData,s=xt.create(Object.assign({},i,{shape:r})),l=new Ln(s,o).copy(this,e);return l.shape=r,r.update(),l}raycast(e,r){lt.prototype.raycast.call(this,e,r)}};function Na(n,t){return yS(n)}function yS(n){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=Ae.createFromState(n.shape,n.width,n.height);t.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),t.geometry=new Kf.BufferGeometryLoader().parse(n));let e;try{e=Fi(t)}catch(r){console.error(r)}if(!e){let r=Ae.createFromState(ln.defaultData(),100,100);t.shape=r,e=Fi(t)}return e}var de;pa.then(n=>{de=n});var Qf=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Zf=new Uint32Array([0,1,2,3]),Jf=new Uint8Array([4]),Wt=class{static build(n,t,e,r,o){let i,s,l,c=n?.phongAngle??t?.phongAngle??35;if(r===!1&&(c=-1),n.positionWASM!==void 0){e&&e!==0&&(de.free_bvh(e),de.free_subdivision_surface(e));try{i=Wt.allocate(n,o)}catch(p){console.error(p,n),i=Wt.allocate({positionWASM:Qf,indexWASM:Zf,verticesPerFaceWASM:Jf},o)}de.set_destination_refinement_level(i,0),s=Wt.buildLevel(i,!0,c)}else i=e,n.phongAngle!==void 0&&(s=Wt.buildLevel(i,!0,c));return n.subdivisions!==void 0&&(de.set_destination_refinement_level(i,n.subdivisions),n.subdivisions>0?l=Wt.buildLevel(i,!1,c):l=null),{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(n,t){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 e=n.shape!==void 0?t.geometry:Na(n),r,o,i,s;({positions:r,triIndices:s}=pc(e.getAttribute("position"),e.getIndex()));let l;if(n.type==="CylinderGeometry"&&n.cornerRadius===0&&n.hollow===0&&n.openEnded===!1){let c=n.radialSegments*n.heightSegments*3*2,p=c+n.radialSegments*3;l=[c,p]}return{indices:o,verticesPerFace:i}=dc(r,s,e,l),{positions:r,indices:o,verticesPerFace:i}}static allocate(n,t){let e,r,o,i=[],s=[];n.positionWASM&&n.positionWASM.length>0?(e=n.positionWASM,r=n.indexWASM,o=n.verticesPerFaceWASM):(e=Qf,r=Zf,o=Jf);let l=e.length,c=r.length,p=o.length,a=e.length+i.length+s.length,u=r.length+o.length,d=a*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=a*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,h=de._malloc(d),y=new Float32Array(de.HEAPF32.buffer,h,a),x=new Uint32Array(de.HEAPU32.buffer,h+f,u);y.set(e,0),y.set(i,e.length),y.set(s,e.length+i.length),x.set(r,0),x.set(o,r.length);let v;n?.scaleBaked?.some(S=>S!==1)&&(v=new He.Matrix4().makeScale(...n.scaleBaked)),t&&(v?v.premultiply(t):v=t);let A=v?de.alloc_subdivision_surface2(h,l,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p,v.elements):de.alloc_subdivision_surface(h,l,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p);return de._free(h),A}static buildLevel(n,t,e,r,o){let i=o?de.get_mesh_data2(n,t?de.Level.CONTROL:de.Level.REFINED,e,o.elements):de.get_mesh_data(n,t?de.Level.CONTROL:de.Level.REFINED,e),s=8,l=de.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(4,4+4),p=0,a=de.HEAPU32[l[p]>>2],u=de.HEAPF32.subarray(a>>2,(a>>2)+c[p]);p++;let d=de.HEAPU32[l[p]>>2],f=de.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=de.HEAPU32[l[p]>>2],h=de.HEAPU32.subarray(m>>2,(m>>2)+c[p]);p++;let y=de.HEAPU32[l[p]>>2],x=de.HEAPU32.subarray(y>>2,(y>>2)+c[p]);if(p++,r===void 0){let v=new He.BufferGeometry;if(v.setIndex(new He.Uint32BufferAttribute(x,1)),v.setAttribute("position",new He.Float32BufferAttribute(u,3)),v.setAttribute("normal",new He.Float32BufferAttribute(f,3)),t){v.setAttribute("faceMap",new He.Uint32BufferAttribute(h,1));let A=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new He.BufferAttribute(A,4))}return de.free_mesh_data(i),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(f),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,de.free_mesh_data(i)}static buildControlCageWireframe(n,t,e){let r=de.get_wireframe_data_for_base_level(n),o=4,i=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(2,2+2),l=0,c=de.HEAPU32[i[l]>>2],p=de.HEAPF32.subarray(c>>2,(c>>2)+s[l]);l++;let a=de.HEAPU32[i[l]>>2],u=de.HEAPU32.subarray(a>>2,(a>>2)+s[l]);if(t===void 0){let d=new He.BufferGeometry;d.setAttribute("position",new He.Float32BufferAttribute(p,3));let f=new Float32Array(p.length);for(let m=0,h=p.length;m<h;)f[m++]=e.r,f[m++]=e.g,f[m++]=e.b;return d.setAttribute("color",new He.BufferAttribute(f,3)),d.setIndex(new He.Uint32BufferAttribute(u,1)),de.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,de.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,t,e){let r=t===0;r||de.set_destination_refinement_level(n,t);let o=e?de.get_topological_data2(n,r?de.Level.CONTROL:de.Level.REFINED,e.elements):de.get_topological_data(n,r?de.Level.CONTROL:de.Level.REFINED),i=6,s=de.HEAPU32.subarray(o>>2,(o>>2)+i),l=s.subarray(3,3+3),c=0,p=de.HEAPU32[s[c]>>2],a=new Float32Array(de.HEAPF32.subarray(p>>2,(p>>2)+l[c]));c++;let u=de.HEAPU32[s[c]>>2],d=new Uint32Array(de.HEAPU32.subarray(u>>2,(u>>2)+l[c]));c++;let f=de.HEAPU32[s[c]>>2],m=new Uint8Array(de.HEAPU32.subarray(f>>2,(f>>2)+l[c]));return de.free_topological_data(o),{positions:a,indices:d,verticesPerFace:m}}};var em=["getX","getY","getZ"];function pc(n,t){let e={},r=t?t.count:n.count,o=0,i=[],s=[],l=1e4;for(let p=0;p<r;p++){let a=t?t.getX(p):p,u="";for(let d=0;d<3;d++)u+=`${~~(n[em[d]](a)*l)},`;if(u in e)i.push(e[u]);else{for(let d=0;d<3;d++)s.push(n[em[d]](a));e[u]=o,i.push(o),o++}}let c=[];for(let p=0;p<i.length;p+=3)i[p]===i[p+1]||i[p]===i[p+2]||i[p+1]===i[p+2]||c.push(i[p],i[p+1],i[p+2]);return{positions:s,triIndices:c}}var Ca=new He.Vector3,lc=new He.Vector3,cc=new He.Vector3,uc=new He.Vector3;function dc(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let s=e.userData.shape.extractShapePointsToFlatArray([]),l=0;for(let p=0;p<s.length;p+=2)l+=(s[p]-s[(p===0?s.length:p)-2])*(s[p+1]+s[(p===0?s.length:p)-1]);n.length=0;let c=0;if(l<0)for(let p=0;p<s.length;p+=2)n.push(s[p],s[p+1],0),o.push(c++);else for(let p=s.length-2;p>=0;p-=2)n.push(s[p],s[p+1],0),o.push(c++);return i.push(c),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??t.length;s<l;)if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Ca.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),lc.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),cc.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),uc.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),lc.sub(Ca).normalize(),cc.sub(Ca).normalize(),uc.sub(Ca).normalize();let c=lc.cross(cc).dot(uc);Math.abs(c)>.005||r&&r.some((p,a)=>a%2===1?!1:s>=r[a]&&s<r[a+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3;if(e.capStartIndex!==void 0){let s=[],l=[],c=0;for(let p=0,a=0;p<n.length;p+=3,a++)n[p+2]===0&&(s.push(a),c++),n[p+2]===e.userData.parameters.depth&&l.push(a);if(e.userData.parameters.extrudeBevelSize===0){let p=l[0];l[0]=l[1],l[1]=p}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Jt={};_c(Jt,{calcBoolean:()=>SS,calcBooleanTopological:()=>bS,freeMeshSet:()=>TS,getMeshSet:()=>wS,transformMeshSet:()=>_S});var xS,tm=new Promise(n=>{xS=n});var zi=require("three");var xe,On;tm.then(n=>xe=n);function vS(n,t){let e,{positions:r,triIndices:o}=pc(n.getAttribute("position"),n.getIndex()),i;if(t){let{indices:s,verticesPerFace:l}=dc(r,o,n);i=l.length,e=[];for(let c=0,p=0;c<i;c++){e.push(l[c]);for(let a=0;a<l[c];a++)e.push(s[p++])}}else{let s=o.length;e=Array(s+s/3),i=0;for(let l=0,c=0;c<e.length;)e[c++]=3,i++,e[c++]=o[l++],e[c++]=o[l++],e[c++]=o[l++]}return{positions:r,faceIndices:e,nFaces:i}}function rm(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=xe._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(xe.HEAPU32.buffer,i,t):new Float32Array(xe.HEAPF32.buffer,i,t)).set(n,0),i}function om(n){switch(n){case 0:return xe.OP.UNION;case 1:return xe.OP.INTERSECTION;case 2:return xe.OP.A_MINUS_B;case 3:return xe.OP.B_MINUS_A;case 4:return xe.OP.SYMMETRIC_DIFFERENCE;case 5:return xe.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function bS(n,t){On===void 0&&(On=xe.init_csg());let e=rm(n),r=xe.csg_calc_topological(On,e,n.length,om(t));xe._free(e);let o=6,i=xe.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(3,3+3),l=0,c=xe.HEAPU32[i[l]>>2],p=new Float32Array(xe.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=xe.HEAPU32[i[l]>>2],u=new Uint32Array(xe.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let d=xe.HEAPU32[i[l]>>2],f=new Uint8Array(xe.HEAPU32.subarray(d>>2,(d>>2)+s[l]));return xe.free_mesh_data(r),{positions:p,indices:u,verticesPerFace:f}}function SS(n,t,e,r){On===void 0&&(On=xe.init_csg());let o=rm(n),i=xe.csg_calc(On,o,n.length,r,om(t));xe._free(o);let s=5,l=xe.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),p=0,a=xe.HEAPU32[l[p]>>2],u=xe.HEAPF32.subarray(a>>2,(a>>2)+c[p]);p++;let d=xe.HEAPU32[l[p]>>2],f=xe.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=c[p];e.setAttribute("position",new zi.Float32BufferAttribute(u,3)),e.setAttribute("normal",new zi.Float32BufferAttribute(f,3));let h=xe.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new zi.Sphere),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},xe.free_mesh_data(i),m}function wS(n,t){if(xe===void 0)return-1;let e,r,o;if(t&&n.userData.positions!==void 0){let h=n.userData;o=h.verticesPerFace.length,e=h.positions,r=Array(h.verticesPerFace.reduce((y,x)=>y+x,0)+o);for(let y=0,x=0,v=0;y<h.verticesPerFace.length;y++){r[v++]=h.verticesPerFace[y];for(let A=0;A<h.verticesPerFace[y];A++)r[v++]=h.indices[x++]}}else({positions:e,faceIndices:r,nFaces:o}=vS(n,t));let i=e.length,s=r.length,l=e.length,c=r.length,p=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,a=l*Float32Array.BYTES_PER_ELEMENT,u=c*Uint32Array.BYTES_PER_ELEMENT,d=xe._malloc(p),f=new Float32Array(xe.HEAPF32.buffer,d,l),m=new Uint32Array(xe.HEAPU32.buffer,d+a,c);return f.set(e,0),m.set(r,0),xe.get_csg_mesh(d,i,d+a,s,o)}function _S(n,t){xe.transform_csg_mesh(n,t.elements)}function TS(n){xe.free_csg_mesh(n)}var ac={ConeGeometry:Id,CubeGeometry:Pd,CylinderGeometry:Nd,DodecahedronGeometry:Od,EllipseGeometry:Jd,HelixGeometry:of,IcosahedronGeometry:sf,LatheGeometry:af,NonParametricGeometry:lf,PolygonGeometry:cf,PyramidGeometry:uf,RectangleGeometry:pf,SphereGeometry:ff,PlaneGeometry:hf,BackdropGeometry:gf,StarGeometry:yf,TextFrameGeometry:ua,TorusGeometry:vf,TorusKnotGeometry:Sf,TriangleGeometry:wf,VectorGeometry:xt},Fi=n=>ac[n.type].create(n);var Ui=require("three");var nm=new Ui.Matrix4;var Ia=class extends lt{constructor(e=new Ui.BufferGeometry,r){super(e,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.objectType="BooleanObject",this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.objectType="BooleanObject",this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(e){if(this.booleanMeshSetAddress!==-1)return;for(let o=0;o<this.children.length;o++){let i=this.children[o];mr(i)&&i.recomputeBoolean(e===!0)}this.meshSetAddresses=[];for(let o=0;o<this.children.length;o++){let i=this.children[o];if(If(i)&&i.booleanExclude===!1&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if(i.booleanMeshSetAddress=Jt.getMeshSet(i.geometry,e===!0),i.booleanMeshSetAddress===-1)return;Jt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else mr(i)&&i.needsTransformForDownstream===!0?(Jt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(nm.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),Jt.transformMeshSet(i.booleanMeshSetAddress,nm),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return Jt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Ui.BufferGeometry,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Jt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(o){this.booleanMeshSetAddress=0,console.error(o)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,ao(this),lo(this)}updateGeometry(e){let r=e.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ge=require("three");var im=require("three"),Tr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new im.BoxBufferGeometry(30,30,30),t};var pt=require("three");var mt=require("three"),Pa=new mt.Ray,fc=new mt.Sphere,sm=new mt.Matrix4,Ar=(n,t,e,r,o=!1)=>{let i=t,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),fc.copy(i.boundingSphere),fc.applyMatrix4(s),e.ray.intersectsSphere(fc)===!1||(sm.copy(s).invert(),Pa.copy(e.ray).applyMatrix4(sm),i.boundingBox!==null&&Pa.intersectsBox(i.boundingBox)===!1))return;let l,c,p,a,u=i.index,d=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let x=Math.max(0,f.start),v=Math.min(u.count,f.start+f.count);for(m=x,h=v;m<h;m+=3)if(c=u.getX(m),p=u.getX(m+1),a=u.getX(m+2),l=y(n,e,Pa,d,c,p,a),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let v=i.attributes.position,A=new mt.Vector3,S=new mt.Vector3,b=new mt.Vector3,D=new mt.Vector3,w=2,L=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=L*L,P=Math.max(0,f.start),N=Math.min(v.count,f.start+f.count);for(let C=P,k=N-1;C<k;C+=w){if(A.fromBufferAttribute(v,C),S.fromBufferAttribute(v,C+1),Pa.distanceSqToSegment(A,S,D,b)>T)continue;D.applyMatrix4(n.matrixWorld);let ne=e.ray.origin.distanceTo(D);ne<e.near||ne>e.far||r.push({distance:ne,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(x,v,A,S,b,D,w){let g=new mt.Vector3,L=new mt.Vector3,T=new mt.Vector3,P=new mt.Vector3,N=new mt.Vector3;if(g.fromBufferAttribute(S,b),L.fromBufferAttribute(S,D),T.fromBufferAttribute(S,w),A.intersectTriangle(g,L,T,!1,P)===null)return null;N.copy(P),N.applyMatrix4(x.matrixWorld);let k=v.ray.origin.distanceTo(N);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:N.clone(),object:x}}};var La=new pt.Vector3,qt=new pt.Camera,mc=class extends pt.LineSegments{constructor(e){let r=new pt.BufferGeometry,o=new pt.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new pt.Color(15711266),p=new pt.Color(15711266),a=new pt.Color(2857471);u("n1","n2",c),u("n2","n4",c),u("n4","n3",c),u("n3","n1",c),u("f1","f2",c),u("f2","f4",c),u("f4","f3",c),u("f3","f1",c),u("n1","f1",c),u("n2","f2",c),u("n3","f3",c),u("n4","f4",c),u("p","n1",p),u("p","n2",p),u("p","n3",p),u("p","n4",p),u("u1","u2",a),u("u2","u3",a),u("u3","u1",a);function u(f,m,h){d(f,h),d(m,h)}function d(f,m){i.push(0,0,0),s.push(m.r,m.g,m.b),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}r.setAttribute("position",new pt.Float32BufferAttribute(i,3)),r.setAttribute("color",new pt.Float32BufferAttribute(s,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;qt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;er("n1",r,e,qt,-i,-s,l),er("n2",r,e,qt,i,-s,l),er("n3",r,e,qt,-i,s,l),er("n4",r,e,qt,i,s,l);let c=l;er("f1",r,e,qt,-i,-s,c),er("f2",r,e,qt,i,-s,c),er("f3",r,e,qt,-i,s,c),er("f4",r,e,qt,i,s,c);let p=c,a=.5;er("u1",r,e,qt,i*.7*a,s*1.1,p),er("u2",r,e,qt,-i*.7*a,s*1.1,p),er("u3",r,e,qt,0,s*(1.1+.9*a),p),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function er(n,t,e,r,o,i,s){La.set(o,i,s).unproject(r);let l=t[n];if(l!==void 0){let c=e.getAttribute("position");for(let p=0,a=l.length;p<a;p++)c.setXYZ(l[p],La.x,La.y,La.z)}}var Oa=class extends Tr(mc){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Ar(this.object,this.geometry,e,r,!0)}};var am=require("three");var Mn=class extends Tr(am.DirectionalLightHelper){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){Ar(this.object,Mn.geometryHelper,e,r)}};var lm=require("three");var Dn=class extends Tr(lm.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){Ar(this.object,Dn.geometryHelper,e,r)}update(){}};var cm=require("three");var Bn=class extends Tr(cm.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Ar(this.object,Bn.geometryHelper,e,r)}};var Da=require("three");var Ma=class extends Tr(Da.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Ar(this.object,Ma.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Ma._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},ji=Ma;ji._vector=new Da.Vector3;var Nr=(n,t)=>class extends n{constructor(){super(...arguments);this.objectHelper=new t(this)}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}fromLightState(o,i){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;o.color!==void 0&&(s.color=Ye(o.color,i)),o.intensity!==void 0&&(s.intensity=o.intensity),o.depth!==void 0&&(s.shadow.camera.far=o.depth,s.shadow.needsUpdate=!0),o.shadows!==void 0&&(this.castShadow=o.shadows)}return this}};var En=new Ge.Vector3,hc=new Ge.Vector3,Fr=class extends Nr(kt(Ge.Camera),Oa){constructor(e=window.innerWidth,r=window.innerHeight,o=45,i,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=go.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new Ge.OrthographicCamera(e*-.5,e*.5,r*.5,r*-.5,i??-5e4,s),this.perspCamera=new Ge.PerspectiveCamera(o,e/r,i??50,s),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()}static createFromState(e,r){let o=new Fr().fromState(r);return o.objectHelper.update(),o.uuid=e,o}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(En),this.targetOffset=En.distanceTo(e)}getTarget(e=new Ge.Vector3){return this.getWorldDirection(hc),this.getWorldPosition(En),hc.multiplyScalar(this.targetOffset),e.copy(En).add(hc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(En),En.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new Ge.Quaternion),r=new Ge.Vector3(0,0,1).applyQuaternion(e),o=new Ge.Vector3().copy(Ge.Object3D.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let i=new Ge.Vector3().copy(Ge.Object3D.DefaultUp).projectOnPlane(r),s=new Ge.Vector3().crossVectors(i,o).dot(r)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(o)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new Ge.Vector3),i=e.getWorldDirection(new Ge.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Ge.Vector3),i=this.getWorldDirection(new Ge.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().sub(i),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,s,l):this.orthoCamera.setViewOffset(e,r,o,i,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){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 en(r,e)}fromCameraState(e){let{orthographic:r,perspective:o}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near,this.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom,this.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near,this.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov,this.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom,this.zoom=o.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};var um=require("three");var Io=class extends Nr(kt(um.Group),Dn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new Io().fromState(r);return o.uuid=e,o.objectHelper.update(),o}};var Po=require("three");var Gn=class extends Nr(kt(Po.DirectionalLight),Mn){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.top=1250,o.bottom=-1250,o.right=1250,o.left=-1250,o.near=-1e4,o.far=2500;let i=new Po.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new Gn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Po.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Po.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Po.CameraHelper&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}fromDirectionalLightState(e,r){let o=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&Af(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),o&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};var ht=require("three");var Rn=class extends Nr(kt(ht.PointLight),Bn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let i=new ht.Vector3(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ht.Vector3(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),l=new ht.Box3(i,s),c=new ht.Box3Helper(l,new ht.Color(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,r,o){let i=new Rn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ht.Box3Helper&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ht.Box3Helper&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof ht.Box3Helper){let o=this.shadow.camera,i=new ht.Vector3(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ht.Vector3(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z);r.box.set(i,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};var Lt=require("three");var pm=new Lt.Vector3,dm=new Lt.Vector3,fm=new Lt.Quaternion,Vn=class extends Nr(kt(Lt.SpotLight),ji){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=Lt.MathUtils.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let i=new Lt.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new Vn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Lt.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Lt.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Lt.CameraHelper&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),dm.setFromMatrixPosition(this.matrixWorld),fm.setFromRotationMatrix(this.matrixWorld),pm.copy(this.up).applyQuaternion(fm).negate().multiplyScalar(this.distance),this.target.position.copy(dm).add(pm),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var mm=n=>n.tagName==="VIDEO",Fn=class{static resize(t,e,r){let o=t/e,i;if(!r.image)return;let s=r.image;mm(s)?i=s.videoWidth/s.videoHeight:i=s.width/s.height,o>i&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*i/o):r.repeat.set(1,1*i/o)),o<i&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/i*-1,1):r.repeat.set(1*o/i,1)),o==i&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let o=t/e,i=r.image!==void 0?r.image.width/r.image.height:1,s;o>i?s={x:1,y:i/o}:o<i?s={x:o/i,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let o=r.layers;for(let i=0;i<o.length;i++){let s=o[i];qf(s)&&Fn.resizeTextureLayer(t,e,s.uniforms[`f${s.id}_texture`].value)}}static resizeComplex(t,e,r,o){let i=t/e,s,l=r.image;mm(l)?s=l.videoWidth/l.videoHeight:s=l.width/l.height,o.geometry.type.includes("Shape")?(i>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/i):r.repeat.set(1/t,1/e*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*i/s*-1,1/e):r.repeat.set(1/t*i/s,1/e)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(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)))}};var Ba=class extends lt{constructor(e,r){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.layers&&Fn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var zn=class extends lt{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var Ea=class extends zn{constructor(e,r){super(e,r);this.objectType="NonParametric"}};var $t=require("three"),hm=require("three/examples/jsm/loaders/FontLoader.js"),We=class extends $t.Mesh{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:i,fontSize:s,LOD:l=16},c=new $t.MeshBasicMaterial({color:0,opacity:1,visible:!0,transparent:!0,side:$t.DoubleSide})){let p=We.loadChar(e,o,l);super(p.geometry,c);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=i,this.fontSize=s,this.LOD=l,this.resolution=p.resolution,this.glyphsHa=p.glyphsHa,this.localPosition=new $t.Vector2,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 We._fontPath}static set FONTS_PATH(e){We._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let o=new $t.Vector3(this.localPosition.x,-this.localPosition.y,0);this.position.copy(o).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=We.loadChar(this.char,e,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(e){if(this.char===e)return;this.char=e;let r=We.loadChar(e,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(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=We.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 e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new We(e).copy(this)}static loadFont(e){return new Promise(function(r,o){We.fontCache[e]?r(We.fontCache[e]):new hm.FontLoader().load(We.FONTS_PATH+e+".json",s=>{We.fontCache[e]=s,r(s)},void 0,o)})}static loadChar(e,r,o){if(We.charCache[e]){if(We.charCache[e][o]&&We.charCache[e][o].fontFamily===r)return We.charCache[e][o]}else We.charCache[e]={};let i=We.fontCache[r],s=i.generateShapes(e,1);return We.charCache[e][o]={geometry:new $t.ShapeBufferGeometry(s,o),fontFamily:r,resolution:i.data.resolution,glyphsHa:i.data.glyphs[e].ha},We.charCache[e][o]}},tr=We;tr.charCache={},tr.fontCache={},tr._fontPath="/_assets/_fonts/";var Cr=require("three");var gc=require("three"),Ga=new gc.Vector2,Lo=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new gc.Vector2(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,o;for(o=t;o>=0;o-=1)if(this.message[o].char===" "){r=!1,e.length===0&&(o-=1,e.splice(0,0,this.message[o]));break}else e.splice(0,0,this.message[o]);return r?e=[]:this.message.splice(o+1,e.length),e}getWord(t=0,e=1){let r=[],o=t;for(o=t;;o+=e){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}e>0?(r.push(this.message[o]),this.message.splice(o,1),o-=e):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,o=t;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=e}return(o<0||o>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let o=e;o<=r;o+=1)this.message[o].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,o,i){switch(r){case 1:this.leftAlign(t,i);break;case 3:this.centerAlign(this.spaceLeft(e),t,i);break;case 2:this.rightAlign(this.spaceLeft(e),t,i);break;case 4:this.justifyAlign(this.spaceLeft(e),t,i);break}}offsetCharacters(t,e,r){Ga.set(e,r);let o=this.message.length;for(let i=0;i<o;i++)this.message[i].updatePosition(this.message[i].localPosition.add(Ga),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(e,0,r);return}let i=t/o,s=0;for(let l=0;l<this.message.length;l++)this.message[l].char===" "&&(s+=i),Ga.set(s,r),this.message[l].updatePosition(this.message[l].localPosition.add(Ga),e)}clone(){let t=new Lo(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var yc=class extends lt{constructor(e){super(e,new Cr.MeshBasicMaterial({transparent:!0,opacity:1,visible:!1,side:Cr.DoubleSide}));this.objectType="TextFrame";this.charContainer=new Cr.Object3D,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.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 Cr.Vector3(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let i=ua.create({parameters:{width:r.width,height:r.height}}),s=new yc(i).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await tr.loadFont(o),r.text=e;let i=r.textOrigin,s=new Cr.MeshBasicMaterial({visible:r.visible,transparent:!0,side:Cr.DoubleSide}),l=e.split(`
1333
- `),c=0;this.userData.textFrame.textLines=l.map((p,a)=>{let u=new Lo(c,r.lineHeight,r.fontSize);return u.message=p.split("").map(d=>{let f={char:d,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=s.clone();m.color=r.hexColor,m.opacity=r.opacity;let h=new tr(f,m);return u.addChar3D(h,i),this.charContainer.add(h),h}),c+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let i=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof tr&&(e.intersectObject(this.charContainer.children[s],!1,i),i.length>0)){i[0].object=this,r.push(i[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,i=o.parameters.width,s=o.parameters.height,l=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=l,p.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==i&&(i<l?this.checkCapacity():i>l&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.textLines;for(let s=e;s<i.length;s++){i[s].updateYLinePos(this.getNewLinePosition(s)),i[s].fullUpdate(o);let l=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?l.unshift(i[s].getWord(i[s].message.length-1,-1)):l.unshift(i[s].popChar());if(l.length>0){i[s+1]===void 0?(i[s].isEndLine(!1),this.createTextLine()):i[s].endLine&&(this.createTextLine(s+1),i[s].isEndLine(!1),i[s+1].isEndLine(!0));let c=0;for(let p=0;p<l.length;p+=1)for(let a=0;a<l[p].length;a+=1)i[s+1].addChar3D(l[p][a],o,c),c+=1;i[s+1].fullUpdate(o)}i[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o),!!s[l-1])for(;!s[l-1].endLine;){let c,p=s[l-1].spaceLeft(i);if(s[l].wordSize(0,1)<=p){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let a=0;a<c.length;a+=1)c[a]&&s[l-1].addChar3D(c[a],o)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new Lo(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<i.length;l++)i[l].updateYLinePos(this.getNewLinePosition(l)),i[l].fullUpdate(o.textOrigin),i[l].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}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(e){let o=this.userData.textFrame.textLines,i=0;for(let s=0;s<e;s+=1)i+=o[s].maxCharSize*o[s].lineHeight;return i}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.color?.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await tr.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,i=o.textLines,s=o.fontSize;o.fontSize=e;for(let l=0;l<i.length;l++)i[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await tr.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let i=0;i<o.length;i++)o[i].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Ye(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}},Oo=yc;Oo.VerticalAlign=ml,Oo.HorizontalAlign=fl,Oo.TextTransform=hl;var Mo=class extends Gt{};var vm=Ac(gm());var ym=new Map;function xm(n){if(typeof n=="string")return n;let t=ym.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},ym.set(n,t)),t.url}var Un=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._isStarted=!1;this.onEnd=()=>{this._loop>1?this.loopsRemaining===1/0?this.play():this.loopsRemaining>1?(this.play(),this.loopsRemaining--):this._isStarted=!1:this._isStarted=!1};let i;typeof t=="string"?i={src:t}:i={src:xm(t),format:"wav"},this.sound=new vm.Howl(i),this.sound.on("end",this.onEnd),this._src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get src(){return this._src}get isStarted(){return this._isStarted}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._isStarted=!0,this.delay?(this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)):this.sound.play()}pause(){this._isStarted=!1,this.sound.pause(),this.clearFade(),this.clearDelay()}stop(){this._isStarted=!1,this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay()}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Hi=class{constructor(t){this.deletedMaterial=new Mo(Er.defaultTwoLayerData("basic"),this);this.deletedImage=new Co(ea.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};this.reset(t)}setOnImageLoad(t){this._onImageLoad=t}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,new Mo(r,this));for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.data);this.penumbraSize=t.penumbraSize}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new Gt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new Co(e,this.onImageLoad),!1)}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):new Pn(t,this.onImageLoad)}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new io(e.r,e.g,e.b,e.a):this.colors[t]=new io(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Je(0,0,0,0))}else return"a"in t?new Je(t.r,t.g,t.b,t.a):new Je(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Un)return e;{let r=new Un({src:e});return this.audios[t]=r,r}}deleteAudio(t){this.audios[t]&&delete this.audios[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._onImageLoad=void 0,Object.values(this.audios).forEach(e=>{e instanceof Un&&e.dispose()}),this.audios={}}},uU=new Hi(Js.emptyData());var bm=require("three/examples/jsm/loaders/DRACOLoader.js");var uo;function NS(){return uo||(uo=new bm.DRACOLoader,uo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),uo.decoderPending}async function CS(n){if(uo){let t={attributeIDs:uo.defaultAttributeIDs,attributeTypes:uo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await uo.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function Sm(n,t){let[e,r]=Qa(Hs.deserialize(new Uint8Array(n)));_d(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await NS();for(let i of o){let s=await CS(sr(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:p,itemSize:a})=>{l[c]={array:p,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var Ir=require("three");var bt=require("three");var Am=Ac(_m());var xc;pa.then(n=>{xc=n});var Nm=new bt.Matrix4,IS=new bt.Matrix4,PS=new bt.Matrix4,rr=new bt.Box3,po=new bt.Vector3,LS=new bt.Matrix4,OS=new bt.Matrix4,jn=class extends lt{constructor(e,r,o,i){super(o??r,i);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new bt.Matrix4;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new bt.Matrix4;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}=Wt.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new jn(i,s,l||void 0,c);return r.geometry.phongAngle!==void 0&&(p.phongAngle=r.geometry.phongAngle),p.calcBoundingBox(),p.freeSubdivPointer(),p.uuid=e,p.fromState(r),p}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Wt.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,ao(this),lo(this),e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,lt.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:i,q:s}=(0,Am.SVD)(r),l=Nm.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=IS.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),p=PS.copy(c).transpose();this.shearScale=LS.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=OS.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,p),s.every(a=>Math.abs(s[0]-a)<.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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new bt.Sphere);let r=e.attributes.position,o=e.boundingSphere.center;rr.setFromBufferAttribute(r),rr.getCenter(o),e.boundingSphere.radius=o.distanceTo(rr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),rr.getSize(po);let i={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;rr.min.set(e[0],e[2],e[4]),rr.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(rr.min.applyMatrix4(this.shearScaleInv),rr.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new bt.Sphere);let o=r.boundingSphere.center;rr.getCenter(o),r.boundingSphere.radius=o.distanceTo(rr.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),rr.getSize(po);let i={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(xc.free_bvh(this.subdivPointer),xc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Tm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Tm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function Tm(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Nm.makeScale(t,e,r).invert().elements,l,c,p;for(var a=0,u=o.length;a<u;a+=3)o[a]*=t,o[a+1]*=e,o[a+2]*=r,l=i[a],c=i[a+1],p=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*p,i[a+1]=s[1]*l+s[5]*c+s[9]*p,i[a+2]=s[2]*l+s[6]*c+s[10]*p}var fo=require("three");function Cm(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=fo.FrontSide:t.side===1?n.side=fo.BackSide:n.side=fo.DoubleSide)}function MS(n,t){if(Array.isArray(n.material))for(let e of n.material)Cm(e,t);else{let e=n.material;Cm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Im(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=jn.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new fo.BufferGeometry:Na(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ys.is2DParametricMesh(o.userData.type)?r=new Ba(o,i):o?.userData.type==="VectorGeometry"?r=new Ln(o,i):t.geometry.type==="NonParametricGeometry"?r=new Ea(o,i):t.geometry.type==="BooleanGeometry"?(r=new Ia(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new zn(o,i),r.uuid=n,r.fromState(t,e)}return MS(r,t),r}function Pm(n,t,e){return t.type==="Mesh"?Im(n,t,e):t.type==="TextFrame"?Oo.createFromState(n,t,e):t.type==="Empty"?Io.createFromState(n,t):t.type==="PointLight"?Rn.createFromState(n,t,e):t.type==="SpotLight"?Vn.createFromState(n,t,e):t.type==="DirectionalLight"?Gn.createFromState(n,t,e):tn.is(t.type)?Fr.createFromState(n,t):(console.error(t),new Io)}var zr=require("three");function Lm(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,lo(n),ao(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Om(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),e}function Mm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof zr.Mesh&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Lm(e,e.material[r])&&(t=!0);else Lm(e,e.material)&&(t=!0)}),t}function Dm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof zr.Mesh)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Om(e,e.material[r])&&(t=!0);else Om(e,e.material)&&(t=!0)}),t}function Bm(n){"material"in n&&BS(n.material),"geometry"in n&&n.geometry.dispose()}function BS(n){Nc(n).forEach(t=>{t instanceof Mo||t.dispose()})}var ES=new zr.Raycaster,GS=new zr.Matrix4,RS=new zr.Ray;function Em(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=GS.copy(o.matrixWorld).invert(),s=RS.copy(t.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=ES;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var Gm=new Ir.Vector3,vc=class extends ma(Ir.Scene){constructor(e,r){super();this.objectType="Scene";this.backupFog=new Ir.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.bgColor=new Je(1,1,1,1);this.entityByUuid={};this.ambientLight=new Ir.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,r)}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Dm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Mm(this),this.needsNormalDirty=!1),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ye(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Fr&&this.switchActiveCamera(o)}this.traverse(o=>{mr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Bm(e)});for(let e of this.children)yr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Fr.createFromState(vc.PERSONAL_CAMERA_ID,{...Qs.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=i=>{for(let s of i.children)yr(s)&&!s.raycastLock&&s.visible&&((fr(s)||da(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),Em(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)yr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)yr(r)&&r.visible&&r.traverseVisibleEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Tf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,r,o){for(let i of e)this.createChildObject(i.id,i.data,i.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,i,s){let l=Pm(e,r,s);return l&&(this.entityByUuid[e]=l,i.add(l),mr(i)&&fr(l)&&(l.prevBooleanObjectParent=i),this.createChildrenObjects(o,l,s)),l}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],p=this.find(l),a=c?p.recursiveBBox:p.singleBBox;r.push(...a.vertices)}let o=new Ir.Box3;return o.setFromPoints(r),o.getCenter(Gm),Gm}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof lt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Gt&&e(r.material[o]);else r.material instanceof Gt&&e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,i;e>=r?(o=r/e,i=1):(o=1,i=e/r),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},Wi=vc;Wi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var VS=require("three"),FS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Rm(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var qi=require("three");function Vm(n){let t=new Set;return n.traverse(e=>{if(fr(e))if(Ve(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);zS(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new qi.Color,specularColor:new qi.Color}),e.onBeforeCompile=(o,i)=>{r&&r(o,i),o.uniforms=Object.assign(qi.ShaderLib.physical.uniforms,o.uniforms),e.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):US(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function zS(n){return n.getLayersOfType("transmission").length>0}function US(n){let t=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}}),t<1}function Fm(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function zm(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}var Um=require("three/examples/jsm/utils/BufferGeometryUtils.js");function jm(n){let t=[];return n.traverse(e=>{e instanceof _o&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Rm(c),c}),s=(0,Um.mergeBufferGeometries)(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function km(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Hm(n){Object.values(n.shared.materials).forEach(t=>{bc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?bc(e.material):"materials"in e&&e.materials.forEach(r=>{bc(r)})})}function bc(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Wm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fa=class extends za.Loader{load(t,e,r,o=console.error){let i=new za.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Wm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Wm),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},r,o)}async parse(t){let e=await Sm(t,Hm),r=new Hi(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Wi(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&_f(s)&&Object.assign(s,{makeDefault:!0})}return o=jm(o),o=Vm(o),o=Fm(o),o=zm(o),o=km(o),o}};
1333
+ `),c=0;this.userData.textFrame.textLines=l.map((p,a)=>{let u=new Lo(c,r.lineHeight,r.fontSize);return u.message=p.split("").map(d=>{let f={char:d,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=s.clone();m.color=r.hexColor,m.opacity=r.opacity;let h=new tr(f,m);return u.addChar3D(h,i),this.charContainer.add(h),h}),c+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let i=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof tr&&(e.intersectObject(this.charContainer.children[s],!1,i),i.length>0)){i[0].object=this,r.push(i[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,i=o.parameters.width,s=o.parameters.height,l=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=l,p.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==i&&(i<l?this.checkCapacity():i>l&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.textLines;for(let s=e;s<i.length;s++){i[s].updateYLinePos(this.getNewLinePosition(s)),i[s].fullUpdate(o);let l=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?l.unshift(i[s].getWord(i[s].message.length-1,-1)):l.unshift(i[s].popChar());if(l.length>0){i[s+1]===void 0?(i[s].isEndLine(!1),this.createTextLine()):i[s].endLine&&(this.createTextLine(s+1),i[s].isEndLine(!1),i[s+1].isEndLine(!0));let c=0;for(let p=0;p<l.length;p+=1)for(let a=0;a<l[p].length;a+=1)i[s+1].addChar3D(l[p][a],o,c),c+=1;i[s+1].fullUpdate(o)}i[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o),!!s[l-1])for(;!s[l-1].endLine;){let c,p=s[l-1].spaceLeft(i);if(s[l].wordSize(0,1)<=p){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let a=0;a<c.length;a+=1)c[a]&&s[l-1].addChar3D(c[a],o)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new Lo(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<i.length;l++)i[l].updateYLinePos(this.getNewLinePosition(l)),i[l].fullUpdate(o.textOrigin),i[l].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}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(e){let o=this.userData.textFrame.textLines,i=0;for(let s=0;s<e;s+=1)i+=o[s].maxCharSize*o[s].lineHeight;return i}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.color?.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await tr.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,i=o.textLines,s=o.fontSize;o.fontSize=e;for(let l=0;l<i.length;l++)i[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await tr.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let i=0;i<o.length;i++)o[i].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Ye(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}},Oo=yc;Oo.VerticalAlign=ml,Oo.HorizontalAlign=fl,Oo.TextTransform=hl;var Mo=class extends Gt{};var vm=Ac(gm());var ym=new Map;function xm(n){if(typeof n=="string")return n;let t=ym.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},ym.set(n,t)),t.url}var Un=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._isStarted=!1;this.onEnd=()=>{this._loop>1?this.loopsRemaining===1/0?this.play():this.loopsRemaining>1?(this.play(),this.loopsRemaining--):this._isStarted=!1:this._isStarted=!1};let i;typeof t=="string"?i={src:t}:i={src:xm(t),format:"wav"},this.sound=new vm.Howl(i),this.sound.on("end",this.onEnd),this._src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get src(){return this._src}get isStarted(){return this._isStarted}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._isStarted=!0,this.delay?(this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)):this.sound.play()}pause(){this._isStarted=!1,this.sound.pause(),this.clearFade(),this.clearDelay()}stop(){this._isStarted=!1,this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay()}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Hi=class{constructor(t,e={}){this.deletedMaterial=new Mo(Er.defaultTwoLayerData("basic"),this);this.deletedImage=new Co(ea.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o.data);this.reset(t)}setOnImageLoad(t){this._onImageLoad=t}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,new Mo(r,this));for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.data);this.penumbraSize=t.penumbraSize}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new Gt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new Co(e,this.onImageLoad),!1)}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):new Pn(t,this.onImageLoad)}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new io(e.r,e.g,e.b,e.a):this.colors[t]=new io(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Je(0,0,0,0))}else return"a"in t?new Je(t.r,t.g,t.b,t.a):new Je(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Un)return e;{let r=new Un({src:e});return this.audios[t]=r,r}}deleteAudio(t){this.audios[t]&&delete this.audios[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._onImageLoad=void 0,Object.values(this.audios).forEach(e=>{e instanceof Un&&e.dispose()}),this.audios={}}},uU=new Hi(Js.emptyData());var bm=require("three/examples/jsm/loaders/DRACOLoader.js");var uo;function NS(){return uo||(uo=new bm.DRACOLoader,uo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),uo.decoderPending}async function CS(n){if(uo){let t={attributeIDs:uo.defaultAttributeIDs,attributeTypes:uo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await uo.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function Sm(n,t){let[e,r]=Qa(Hs.deserialize(new Uint8Array(n)));_d(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await NS();for(let i of o){let s=await CS(sr(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:p,itemSize:a})=>{l[c]={array:p,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var Ir=require("three");var bt=require("three");var Am=Ac(_m());var xc;pa.then(n=>{xc=n});var Nm=new bt.Matrix4,IS=new bt.Matrix4,PS=new bt.Matrix4,rr=new bt.Box3,po=new bt.Vector3,LS=new bt.Matrix4,OS=new bt.Matrix4,jn=class extends lt{constructor(e,r,o,i){super(o??r,i);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new bt.Matrix4;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new bt.Matrix4;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}=Wt.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new jn(i,s,l||void 0,c);return r.geometry.phongAngle!==void 0&&(p.phongAngle=r.geometry.phongAngle),p.calcBoundingBox(),p.freeSubdivPointer(),p.uuid=e,p.fromState(r),p}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Wt.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,ao(this),lo(this),e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,lt.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:i,q:s}=(0,Am.SVD)(r),l=Nm.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=IS.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),p=PS.copy(c).transpose();this.shearScale=LS.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=OS.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,p),s.every(a=>Math.abs(s[0]-a)<.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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new bt.Sphere);let r=e.attributes.position,o=e.boundingSphere.center;rr.setFromBufferAttribute(r),rr.getCenter(o),e.boundingSphere.radius=o.distanceTo(rr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),rr.getSize(po);let i={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;rr.min.set(e[0],e[2],e[4]),rr.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(rr.min.applyMatrix4(this.shearScaleInv),rr.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new bt.Sphere);let o=r.boundingSphere.center;rr.getCenter(o),r.boundingSphere.radius=o.distanceTo(rr.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),rr.getSize(po);let i={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(xc.free_bvh(this.subdivPointer),xc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Tm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Tm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function Tm(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Nm.makeScale(t,e,r).invert().elements,l,c,p;for(var a=0,u=o.length;a<u;a+=3)o[a]*=t,o[a+1]*=e,o[a+2]*=r,l=i[a],c=i[a+1],p=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*p,i[a+1]=s[1]*l+s[5]*c+s[9]*p,i[a+2]=s[2]*l+s[6]*c+s[10]*p}var fo=require("three");function Cm(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=fo.FrontSide:t.side===1?n.side=fo.BackSide:n.side=fo.DoubleSide)}function MS(n,t){if(Array.isArray(n.material))for(let e of n.material)Cm(e,t);else{let e=n.material;Cm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Im(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=jn.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new fo.BufferGeometry:Na(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ys.is2DParametricMesh(o.userData.type)?r=new Ba(o,i):o?.userData.type==="VectorGeometry"?r=new Ln(o,i):t.geometry.type==="NonParametricGeometry"?r=new Ea(o,i):t.geometry.type==="BooleanGeometry"?(r=new Ia(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new zn(o,i),r.uuid=n,r.fromState(t,e)}return MS(r,t),r}function Pm(n,t,e){return t.type==="Mesh"?Im(n,t,e):t.type==="TextFrame"?Oo.createFromState(n,t,e):t.type==="Empty"?Io.createFromState(n,t):t.type==="PointLight"?Rn.createFromState(n,t,e):t.type==="SpotLight"?Vn.createFromState(n,t,e):t.type==="DirectionalLight"?Gn.createFromState(n,t,e):tn.is(t.type)?Fr.createFromState(n,t):(console.error(t),new Io)}var zr=require("three");function Lm(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,lo(n),ao(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Om(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),e}function Mm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof zr.Mesh&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Lm(e,e.material[r])&&(t=!0);else Lm(e,e.material)&&(t=!0)}),t}function Dm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof zr.Mesh)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Om(e,e.material[r])&&(t=!0);else Om(e,e.material)&&(t=!0)}),t}function Bm(n){"material"in n&&BS(n.material),"geometry"in n&&n.geometry.dispose()}function BS(n){Nc(n).forEach(t=>{t instanceof Mo||t.dispose()})}var ES=new zr.Raycaster,GS=new zr.Matrix4,RS=new zr.Ray;function Em(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=GS.copy(o.matrixWorld).invert(),s=RS.copy(t.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=ES;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var Gm=new Ir.Vector3,vc=class extends ma(Ir.Scene){constructor(e,r){super();this.objectType="Scene";this.backupFog=new Ir.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.bgColor=new Je(1,1,1,1);this.entityByUuid={};this.ambientLight=new Ir.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,r)}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Dm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Mm(this),this.needsNormalDirty=!1),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ye(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Fr&&this.switchActiveCamera(o)}this.traverse(o=>{mr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Bm(e)});for(let e of this.children)yr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Fr.createFromState(vc.PERSONAL_CAMERA_ID,{...Qs.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=i=>{for(let s of i.children)yr(s)&&!s.raycastLock&&s.visible&&((fr(s)||da(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),Em(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)yr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)yr(r)&&r.visible&&r.traverseVisibleEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Tf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,r,o){for(let i of e)this.createChildObject(i.id,i.data,i.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,i,s){let l=Pm(e,r,s);return l&&(this.entityByUuid[e]=l,i.add(l),mr(i)&&fr(l)&&(l.prevBooleanObjectParent=i),this.createChildrenObjects(o,l,s)),l}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],p=this.find(l),a=c?p.recursiveBBox:p.singleBBox;r.push(...a.vertices)}let o=new Ir.Box3;return o.setFromPoints(r),o.getCenter(Gm),Gm}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof lt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Gt&&e(r.material[o]);else r.material instanceof Gt&&e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,i;e>=r?(o=r/e,i=1):(o=1,i=e/r),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},Wi=vc;Wi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var VS=require("three"),FS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Rm(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}var qi=require("three");function Vm(n){let t=new Set;return n.traverse(e=>{if(fr(e))if(Ve(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);zS(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new qi.Color,specularColor:new qi.Color}),e.onBeforeCompile=(o,i)=>{r&&r(o,i),o.uniforms=Object.assign(qi.ShaderLib.physical.uniforms,o.uniforms),e.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):US(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function zS(n){return n.getLayersOfType("transmission").length>0}function US(n){let t=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}}),t<1}function Fm(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function zm(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}var Um=require("three/examples/jsm/utils/BufferGeometryUtils.js");function jm(n){let t=[];return n.traverse(e=>{e instanceof _o&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Rm(c),c}),s=(0,Um.mergeBufferGeometries)(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function km(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Hm(n){Object.values(n.shared.materials).forEach(t=>{bc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?bc(e.material):"materials"in e&&e.materials.forEach(r=>{bc(r)})})}function bc(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Wm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fa=class extends za.Loader{load(t,e,r,o=console.error){let i=new za.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Wm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Wm),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},r,o)}async parse(t){let e=await Sm(t,Hm),r=new Hi(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Wi(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&_f(s)&&Object.assign(s,{makeDefault:!0})}return o=jm(o),o=Vm(o),o=Fm(o),o=zm(o),o=km(o),o}};
@@ -1330,4 +1330,4 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1330
1330
  return color.xyz;
1331
1331
 
1332
1332
  }`,[ot.simplex,e,o,s])}}();import{Matrix3 as Iw}from"three";function $f(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var ia=class extends ln{constructor(e,r){super(new Iw);this.repeat=e;this.offset=r;$f(this.value,e,r)}updateMatrix(){$f(this.value,this.repeat,this.offset)}};var cr=class{constructor(t,e,r,o){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in r)Kl(i,this,r)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return ur.createLigherLayer(t,e,r,o);if(r.type==="texture"){let i=o.image(r.texture.image),s=new bi(i,r.texture.wrapping),l=new na(i),c=new ia(r.texture.repeat,r.texture.offset),p=new Y(r.crop?1:0),a=new he(r.projection??0),u=new he(["x","y","z"].indexOf(r.axis)??0),d=new he(r.side??0),f=new Ye(r.size?new co(r.size[0],r.size[1]):new co(100,100)),m=new Y(r.alpha??1),h=new he(r.mode??0),y=new pi(s,l,p,a,u,d,f,c,m,h),x=new ve(y.calpha,"f");return new We(t,e,r,{texture:s,textureSize:l,crop:p,projection:a,axis:u,side:d,size:f,mat:c,alpha:m,mode:h},y,h,x)}else if(r.type==="matcap"){let i=o.image(r.texture.image),s=new bi(i,r.texture.wrapping),l=new Y(r.alpha??1),c=new he(r.mode??0),p=new vi(s,l,c),a=new ve(p.calpha,"f");return new We(t,e,r,{texture:s,alpha:l,mode:c},p,c,a)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Ze(new lr(...r.offset)),s=new Y(r.scale??10),l=new Y(r.intensity??8),c=new Y(r.movement??1),p=new he(r.noiseType??0),a=new ci(l,c,i,s,p);return new wi(t,e,r,{offset:i,scale:s,intensity:l,movement:c,noiseType:p},a)}else throw new Error;else return Lw(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props?!0:qf(o.props,r,this,e)}else if(o.path[0]==="texture")return"texture"in e?Yl(o.props,r,this):!0;return!1}dispose(){}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},We=class extends cr{constructor(e,r,o,i,s,l,c){super(e,r,o,i);this.color=s;this.mode=l;this.alpha=c}},wi=class extends cr{constructor(e,r,o,i,s){super(e,r,o,i);this.position=s}},ur=class extends cr{constructor(e,r,o,i,s){super(e,r,o,s);this.data=o;this.node=i}static createLigherLayer(e,r,o,i){let s,l=new Y(o.alpha),c=new he(o.mode),p;if(o.category==="lambert"){s=new mi;let a=new we(i.color(o.emissive)??0);p={emissive:a},s.emissive=a}else if(o.category==="phong"){s=new oa;let a=new Y(o.shininess??30),u=new we(i.color(o.specular)??1118481);p={shininess:a,specular:u},s.shininess=a,s.specular=u}else if(o.category==="toon"){s=new gi;let a=new Y(o.shininess??30),u=new we(i.color(o.specular)??1118481);p={shininess:a,specular:u},s.shininess=a,s.specular=u}else if(o.category==="physical"){s=new hi;let a=new Y(o.roughness??.3),u=new Y(o.metalness??0),d=new Y(o.reflectivity??.5);p={roughness:a,metalness:u,reflectivity:d},s.roughness=a,s.metalness=u,s.reflectivity=d}else s=new ao,p={};return s.alpha=new Y(1),s.shadingAlpha=l,s.shadingBlend=c,p.alpha=s.shadingAlpha,p.mode=s.shadingBlend,new ur(e,r,o,s,p)}};function Xf(n){let t=n instanceof cr?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}function Pw(n,t,e,r){switch(n.type){case"color":{let o=new we(r.color??5855577),i=new Y(r.alpha??1),s=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new he(r.mode??0);return o.alpha=i,new We(t,e,n,{color:o,alpha:i,mode:l},o,l,s)}case"fresnel":{let o=new we(r.color??16777215),i=new Y(r.bias??.1),s=new Y(r.scale??1),l=new Y(r.intensity??2),c=new Y(r.factor??1),p=new Y(r.alpha??1),a=new he(r.mode??0),u=new oi(o,i,s,l,c,p,a),d=new ve(u.calpha,"f");return new We(t,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,alpha:p,mode:a},u,a,d)}case"rainbow":{let o=new Y(r.filmThickness??30),i=new Y(r.movement??0),s=new Ze(r.wavelengths??new lr(0,0,0)),l=new Y(r.noiseStrength??0),c=new Y(r.noiseScale??1),p=new Ze(r.offset??new lr(0,0,0)),a=new Y(r.alpha??1),u=new ni(o,i,s,l,c,p,a),d=new ve(u.calpha,"f"),f=new he(r.mode??0);return new We(t,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:p,alpha:a,mode:f},u,f,d)}case"transmission":{let o=new Y(r.thickness??10),i=new Y(r.ior??1.5),s=new Y(r.roughness??.5),l=Je.transmissionSize,c=Je.transmissionRenderTarget,p=Je.transmissionRenderTargetDepth,a=window.innerWidth,u=window.innerHeight,d=a>=u?new Ye(u/a,1):new Ye(1,a/u),f=new Y(r.alpha??1),m=new si(o,i,s,l,c,p,d,f),h=new ve(m.calpha,"f"),y=new he(r.mode??0);return new We(t,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:d,alpha:f,mode:y},m,y,h)}case"toon":{let o=new he(r.positioning??0),i;r.colors?i=new Rt(r.colors.length,r.colors):(i=new Rt(10,new dn(0,0,0,1)),i.value[1]=new dn(1,1,1,1));let s;r.steps?s=new Gt(r.steps.length,r.steps):(s=new Gt(10,1),s.value[0]=0);let l=new Ze(r.source??new lr(0,0,0)),c=new Hr(r.isWorldSpace??!0),p=new Y(r.noiseStrength??0),a=new Y(r.noiseScale??1),u=new Lt(r.shadowColor),d=new Ze(r.offset??new lr(0,0,0)),f=new Y(r.alpha??1),m=new Si(o,i,s,l,c,p,a,u,d,f),h=new ve(m.calpha,"f"),y=new he(r.mode??0);return new We(t,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:p,noiseScale:a,shadowColor:u,offset:d,alpha:f,mode:y},m,y,h)}case"outline":{let o=new we(r.outlineColor??16777215),i=new we(r.contourColor??16777215),s=new Y(r.outlineWidth??.1),l=new Y(r.contourWidth??.1),c=new Y(r.outlineThreshold??.1),p=new Y(r.contourThreshold??.1),a=new Y(r.outlineSmoothing??.1),u=new Y(r.contourFrequency??.1),d=new Ze(r.contourDirections??new lr(0,1,0)),f=new Hr(r.positionalLines??!1),m=new Hr(r.compensation??!0),h=Je.normalRenderTarget,y=Je.normalRenderTargetDepth,x=Je.pixelRatioNode,v=Je.resolution,A=new Y(r.alpha??1),S=new ii(o,i,s,l,c,p,a,u,d,f,m,v,h,y,x,A),b=new ve(S.calpha,"f"),D=new he(r.mode??0);return new We(t,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:p,outlineSmoothing:a,contourFrequency:u,contourDirection:d,positionalLines:f,compensation:m,alpha:A,mode:D},S,D,b)}case"depth":{let o=new he(r.gradientType??0),i=new Hr(r.smooth??!1),s=new Y(r.near??50),l=new Y(r.far??200),c=new Y(r.isVector??1),p=new Y(r.isWorldSpace??0),a=new Ze(r.origin??new lr),u=new Ze(r.direction??new lr),d=new he(r.num??0),f;r.colors?f=new Rt(d.value+1,r.colors):(f=new Rt(d.value+1,new dn(0,0,0,1)),f.value[1]=new dn(1,1,1,1));let m;r.steps?m=new Gt(d.value+1,r.steps):(m=new Gt(d.value+1,1),m.value[0]=0);let h=new Y(r.alpha??1),y=new he(r.mode??0),x=new ai(o,i,s,l,c,p,a,u,f,m,d,h),v=new ve(x.calpha,"f");return new We(t,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:p,origin:a,direction:u,colors:f,steps:m,num:d,alpha:h,mode:y},x,y,v)}case"noise":{let o=new Y(r.scale??1),i=new Ze(r.size??new lr(100,100,100)),s=new Y(r.move??1),l=new Ye(r.fA??new co(1.7,9.2)),c=new Ye(r.fB??new co(8.3,2.8)),p=new Ye(r.distortion??new co(1,1)),a=new Lt(r.colorA),u=new Lt(r.colorB),d=new Lt(r.colorC),f=new Lt(r.colorD),m=new Y(r.alpha??1),h=new he(r.mode??0),y=new he(r.noiseType??0),x=new ri(o,i,s,l,c,p,a,u,d,f,m,y),v=new ve(x.calpha,"f");return new We(t,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:p,colorA:a,colorB:u,colorC:d,colorD:f,alpha:m,mode:h,noiseType:y},x,h,v)}case"normal":{let o=new Ze(r.cnormal??new lr(1,1,1)),i=new Y(r.alpha??1),s=new he(r.mode??0),l=new fi(o,i),c=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return c.keywords.alpha=i,new We(t,e,n,{cnormal:o,alpha:i,mode:s},l,s,c)}case"gradient":{let o=new he(r.gradientType??0),i=new Hr(r.smooth??!1),s;r.colors?s=new Rt(r.colors.length,r.colors):(s=new Rt(10,new dn(0,0,0,1)),s.value[1]=new dn(1,1,1,1));let l;r.steps?l=new Gt(r.steps.length,r.steps):(l=new Gt(10,1),l.value[0]=0);let c=new Ye(r.offset??new co(0,0)),p=new Ye(r.morph??new co(0,0)),a=new Y(r.angle??0),u=new Y(r.alpha??1),d=new he(r.mode??0),f=new ui(o,i,s,l,c,p,a,u),m=new ve(f.calpha,"f");return new We(t,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:p,angle:a,alpha:u,mode:d},f,d,m)}default:{let o=new we(1,0,0,1),i=new Y(1),s=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new he(0);return o.alpha=i,new We(t,e,n,{color:o,alpha:i,mode:l},o,l,s)}}}function Lw(n,t,e,r){let o=kf(e,r);return Pw(e,n,t,o)}function Kl(n,t,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n=="visible"){let o=t.uniforms[`f${t.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return r}}var St=class extends Mw{constructor(e,r){super(void 0);this.data=e;this.layerIdGen=0;this.type="NodeMaterial";this.uniformsBackup={};this.fog=!0,this.updaters=[],this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile,this.transparent=!0,this.reset(e,r)}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.data.category}reset(e,r){let o=e.layers??br.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>cr.create(this.layerIdGen++,i.id,i.data,r)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r)}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof ur),this.lightLayer===void 0&&(this.lightLayer=new ur(0,"",Vr.defaultData("light","basic"),new ao,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,r,o){if(this.data=r,e.path[0]==="layers"){let i=e.path[1];if(i===void 0){if(this.layers.reverse(),e.type===4){let s=cr.create(this.layerIdGen++,e.id,e.data,o);this.layers.splice(e.localIndex,0,s)}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose();else if(e.type===6){let s=this.layers.findIndex(c=>c.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l)}this.layers.reverse(),this.onUpdate(o)}else{let s=this.layers.find(l=>l.uuid===i);if(s){let l=r.layers.data(i);if(s.updateByOp({...e,path:e.path.slice(2)},l,o)){let p=cr.create(this.layerIdGen++,i,l,o);this.layers.splice(this.layers.findIndex(a=>a.uuid===i),1,p),this.onUpdate(o)}}}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof We),r=this.layers.findIndex(o=>o instanceof ur);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let s=this.layers[i];s instanceof We&&(o=new li(o,s.color,s.alpha,s.mode))}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ve("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof ur);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];i instanceof We&&(e=new li(e,i.color,i.alpha,i.mode))}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof wi);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new mt(r,e[o].position,mt.ADD),r=new mt(r,new Y(.5).setReadonly(!0),mt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,s,l)=>Math.min(Math.max(i,s),l);for(let i of this.layers)if(i.type==="displace"){this.uniformsBackup[`f${i.id}_intensity`]=i.uniforms[`f${i.id}_intensity`].value;let s=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=s}}restoreClampedUniforms(){for(let e of this.layers)e.type==="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.category}",`;else{let o=Xl[r.type];o&&o.length?e+=`["${r.type}", "${o.map(i=>r[i]).join('","')}"],`:e+=`"${r.type}",`}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){e=e??{};let r=e.builder??new ra;return this.lights=this.lightLayer.data.category!=="basic",r.setMaterial(this,e.renderer),r.build(this.fragment,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.transparent=r.requires.transparent||this.blending>Ow,this}dispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(St.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(n){n===!0&&this.version++,this.needsCompile=n},get:function(){return this.needsCompile}}});import{MathUtils as Jl,BufferAttribute as Dw,Vector3 as ec,Float32BufferAttribute as Yf}from"three";function Bw(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position)return;let t=new Map,e=n.geometry.attributes.position.array,r=n.geometry.attributes.normal.array,o=new Float32Array(e.length);for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=new ec(r[i],r[i+1],r[i+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new ec})}t.forEach((i,s)=>{for(let l of i.normals)i.result.add(l);i.result.divideScalar(i.normals.length)});for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=t.get(s)?.result;l&&(o[i]=l.x,o[i+1]=l.y,o[i+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Yf(o,3))}function Ew(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let t=n.geometry.attributes.position.array,e=new Float32Array(t.length),r=new ec;for(let o=0;o<t.length;o+=3)r.set(t[o],t[o+1],t[o+2]).normalize(),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z;n.geometry.setAttribute("extrudeNormal",new Yf(e,3))}function $r(n){if(n.objectType!=="TextFrame"){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof St)||n.material.getLayersOfType("outline").length===0)return;n.objectType==="Mesh2D"?Ew(n):Bw(n)}}function Xr(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes.position.array,e=new Float32Array(t.length),r=parseInt(n.uuid.replace(/\D/g,"")),o=[Jl.seededRandom(r),Jl.seededRandom(r+1e4),Jl.seededRandom(r+2e4)];for(let i=0;i<t.length;i++)e[i]=o[i%3];n.geometry.setAttribute("randomColor",new Dw(e,3))}var Qe=class extends Pt(Gw){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Rw;this.booleanExclude=null;Array.isArray(r)&&e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0)}get isGroup(){return this._cloner?.parameters.hideBase===!0}get isMesh(){return!this.isGroup}set isMesh(e){}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}updateGeometry(e){let r=this.geometry,o=tc[r.userData.type],i=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=o.build(o.normalizeInputs(e,i)),l=r.uuid;this.geometry.dispose(),this.geometry=s,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),$r(this),r.getAttribute("randomColor")&&Xr(this)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=_i(r),i=this.material;return new this.constructor(o,i).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new no(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new no(this)),this.cloner.fromClonerState(e))}fromState(e,r){return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=e.castShadow??!0,this.receiveShadow=e.receiveShadow??!0,this.booleanExclude=e.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Vt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),er(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)Jt(e)&&(e.freeBooleanPointer(),er(e)&&e.invalidateUpstreamBooleanData())}};var zw=new rc(0,0,1),Kf=new rc,Qf=new rc,Zf=new Fw,fn=class extends Qe{constructor(e=st.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Vw;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=e,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Zf.getNormalMatrix(this.matrixWorld),Kf.copy(zw).applyMatrix3(Zf).normalize(),Qf.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Kf,Qf)}clone(e){let r=this.shape.clone(),o=this.material,i=this.geometry.userData,s=st.create(Object.assign({},i,{shape:r})),l=new fn(s,o).copy(this,e);return l.shape=r,r.update(),l}raycast(e,r){Qe.prototype.raycast.call(this,e,r)}};function sa(n,t){return jw(n)}function jw(n){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=Se.createFromState(n.shape,n.width,n.height);t.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),t.geometry=new Uw().parse(n));let e;try{e=_i(t)}catch(r){console.error(r)}if(!e){let r=Se.createFromState(Ho.defaultData(),100,100);t.shape=r,e=_i(t)}return e}var pe;Ks.then(n=>{pe=n});var tm=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rm=new Uint32Array([0,1,2,3]),om=new Uint8Array([4]),Ot=class{static build(n,t,e,r,o){let i,s,l,c=n?.phongAngle??t?.phongAngle??35;if(r===!1&&(c=-1),n.positionWASM!==void 0){e&&e!==0&&(pe.free_bvh(e),pe.free_subdivision_surface(e));try{i=Ot.allocate(n,o)}catch(p){console.error(p,n),i=Ot.allocate({positionWASM:tm,indexWASM:rm,verticesPerFaceWASM:om},o)}pe.set_destination_refinement_level(i,0),s=Ot.buildLevel(i,!0,c)}else i=e,n.phongAngle!==void 0&&(s=Ot.buildLevel(i,!0,c));return n.subdivisions!==void 0&&(pe.set_destination_refinement_level(i,n.subdivisions),n.subdivisions>0?l=Ot.buildLevel(i,!1,c):l=null),{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(n,t){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 e=n.shape!==void 0?t.geometry:sa(n),r,o,i,s;({positions:r,triIndices:s}=lc(e.getAttribute("position"),e.getIndex()));let l;if(n.type==="CylinderGeometry"&&n.cornerRadius===0&&n.hollow===0&&n.openEnded===!1){let c=n.radialSegments*n.heightSegments*3*2,p=c+n.radialSegments*3;l=[c,p]}return{indices:o,verticesPerFace:i}=cc(r,s,e,l),{positions:r,indices:o,verticesPerFace:i}}static allocate(n,t){let e,r,o,i=[],s=[];n.positionWASM&&n.positionWASM.length>0?(e=n.positionWASM,r=n.indexWASM,o=n.verticesPerFaceWASM):(e=tm,r=rm,o=om);let l=e.length,c=r.length,p=o.length,a=e.length+i.length+s.length,u=r.length+o.length,d=a*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=a*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,h=pe._malloc(d),y=new Float32Array(pe.HEAPF32.buffer,h,a),x=new Uint32Array(pe.HEAPU32.buffer,h+f,u);y.set(e,0),y.set(i,e.length),y.set(s,e.length+i.length),x.set(r,0),x.set(o,r.length);let v;n?.scaleBaked?.some(S=>S!==1)&&(v=new kw().makeScale(...n.scaleBaked)),t&&(v?v.premultiply(t):v=t);let A=v?pe.alloc_subdivision_surface2(h,l,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p,v.elements):pe.alloc_subdivision_surface(h,l,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p);return pe._free(h),A}static buildLevel(n,t,e,r,o){let i=o?pe.get_mesh_data2(n,t?pe.Level.CONTROL:pe.Level.REFINED,e,o.elements):pe.get_mesh_data(n,t?pe.Level.CONTROL:pe.Level.REFINED,e),s=8,l=pe.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(4,4+4),p=0,a=pe.HEAPU32[l[p]>>2],u=pe.HEAPF32.subarray(a>>2,(a>>2)+c[p]);p++;let d=pe.HEAPU32[l[p]>>2],f=pe.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=pe.HEAPU32[l[p]>>2],h=pe.HEAPU32.subarray(m>>2,(m>>2)+c[p]);p++;let y=pe.HEAPU32[l[p]>>2],x=pe.HEAPU32.subarray(y>>2,(y>>2)+c[p]);if(p++,r===void 0){let v=new Jf;if(v.setIndex(new oc(x,1)),v.setAttribute("position",new nc(u,3)),v.setAttribute("normal",new nc(f,3)),t){v.setAttribute("faceMap",new oc(h,1));let A=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new em(A,4))}return pe.free_mesh_data(i),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(f),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,pe.free_mesh_data(i)}static buildControlCageWireframe(n,t,e){let r=pe.get_wireframe_data_for_base_level(n),o=4,i=pe.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(2,2+2),l=0,c=pe.HEAPU32[i[l]>>2],p=pe.HEAPF32.subarray(c>>2,(c>>2)+s[l]);l++;let a=pe.HEAPU32[i[l]>>2],u=pe.HEAPU32.subarray(a>>2,(a>>2)+s[l]);if(t===void 0){let d=new Jf;d.setAttribute("position",new nc(p,3));let f=new Float32Array(p.length);for(let m=0,h=p.length;m<h;)f[m++]=e.r,f[m++]=e.g,f[m++]=e.b;return d.setAttribute("color",new em(f,3)),d.setIndex(new oc(u,1)),pe.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(p),t.attributes.position.needsUpdate=!0,pe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,t,e){let r=t===0;r||pe.set_destination_refinement_level(n,t);let o=e?pe.get_topological_data2(n,r?pe.Level.CONTROL:pe.Level.REFINED,e.elements):pe.get_topological_data(n,r?pe.Level.CONTROL:pe.Level.REFINED),i=6,s=pe.HEAPU32.subarray(o>>2,(o>>2)+i),l=s.subarray(3,3+3),c=0,p=pe.HEAPU32[s[c]>>2],a=new Float32Array(pe.HEAPF32.subarray(p>>2,(p>>2)+l[c]));c++;let u=pe.HEAPU32[s[c]>>2],d=new Uint32Array(pe.HEAPU32.subarray(u>>2,(u>>2)+l[c]));c++;let f=pe.HEAPU32[s[c]>>2],m=new Uint8Array(pe.HEAPU32.subarray(f>>2,(f>>2)+l[c]));return pe.free_topological_data(o),{positions:a,indices:d,verticesPerFace:m}}};var nm=["getX","getY","getZ"];function lc(n,t){let e={},r=t?t.count:n.count,o=0,i=[],s=[],l=1e4;for(let p=0;p<r;p++){let a=t?t.getX(p):p,u="";for(let d=0;d<3;d++)u+=`${~~(n[nm[d]](a)*l)},`;if(u in e)i.push(e[u]);else{for(let d=0;d<3;d++)s.push(n[nm[d]](a));e[u]=o,i.push(o),o++}}let c=[];for(let p=0;p<i.length;p+=3)i[p]===i[p+1]||i[p]===i[p+2]||i[p+1]===i[p+2]||c.push(i[p],i[p+1],i[p+2]);return{positions:s,triIndices:c}}var aa=new la,ic=new la,sc=new la,ac=new la;function cc(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let s=e.userData.shape.extractShapePointsToFlatArray([]),l=0;for(let p=0;p<s.length;p+=2)l+=(s[p]-s[(p===0?s.length:p)-2])*(s[p+1]+s[(p===0?s.length:p)-1]);n.length=0;let c=0;if(l<0)for(let p=0;p<s.length;p+=2)n.push(s[p],s[p+1],0),o.push(c++);else for(let p=s.length-2;p>=0;p-=2)n.push(s[p],s[p+1],0),o.push(c++);return i.push(c),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??t.length;s<l;)if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){aa.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),ic.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),sc.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),ac.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),ic.sub(aa).normalize(),sc.sub(aa).normalize(),ac.sub(aa).normalize();let c=ic.cross(sc).dot(ac);Math.abs(c)>.005||r&&r.some((p,a)=>a%2===1?!1:s>=r[a]&&s<r[a+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3;if(e.capStartIndex!==void 0){let s=[],l=[],c=0;for(let p=0,a=0;p<n.length;p+=3,a++)n[p+2]===0&&(s.push(a),c++),n[p+2]===e.userData.parameters.depth&&l.push(a);if(e.userData.parameters.extrudeBevelSize===0){let p=l[0];l[0]=l[1],l[1]=p}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Vt={};ph(Vt,{calcBoolean:()=>Xw,calcBooleanTopological:()=>$w,freeMeshSet:()=>Qw,getMeshSet:()=>Yw,transformMeshSet:()=>Kw});var Hw,im=new Promise(n=>{Hw=n});import{Float32BufferAttribute as sm,Sphere as Ww}from"three";var ge,mn;im.then(n=>ge=n);function qw(n,t){let e,{positions:r,triIndices:o}=lc(n.getAttribute("position"),n.getIndex()),i;if(t){let{indices:s,verticesPerFace:l}=cc(r,o,n);i=l.length,e=[];for(let c=0,p=0;c<i;c++){e.push(l[c]);for(let a=0;a<l[c];a++)e.push(s[p++])}}else{let s=o.length;e=Array(s+s/3),i=0;for(let l=0,c=0;c<e.length;)e[c++]=3,i++,e[c++]=o[l++],e[c++]=o[l++],e[c++]=o[l++]}return{positions:r,faceIndices:e,nFaces:i}}function am(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=ge._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(ge.HEAPU32.buffer,i,t):new Float32Array(ge.HEAPF32.buffer,i,t)).set(n,0),i}function lm(n){switch(n){case 0:return ge.OP.UNION;case 1:return ge.OP.INTERSECTION;case 2:return ge.OP.A_MINUS_B;case 3:return ge.OP.B_MINUS_A;case 4:return ge.OP.SYMMETRIC_DIFFERENCE;case 5:return ge.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function $w(n,t){mn===void 0&&(mn=ge.init_csg());let e=am(n),r=ge.csg_calc_topological(mn,e,n.length,lm(t));ge._free(e);let o=6,i=ge.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(3,3+3),l=0,c=ge.HEAPU32[i[l]>>2],p=new Float32Array(ge.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=ge.HEAPU32[i[l]>>2],u=new Uint32Array(ge.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let d=ge.HEAPU32[i[l]>>2],f=new Uint8Array(ge.HEAPU32.subarray(d>>2,(d>>2)+s[l]));return ge.free_mesh_data(r),{positions:p,indices:u,verticesPerFace:f}}function Xw(n,t,e,r){mn===void 0&&(mn=ge.init_csg());let o=am(n),i=ge.csg_calc(mn,o,n.length,r,lm(t));ge._free(o);let s=5,l=ge.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),p=0,a=ge.HEAPU32[l[p]>>2],u=ge.HEAPF32.subarray(a>>2,(a>>2)+c[p]);p++;let d=ge.HEAPU32[l[p]>>2],f=ge.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=c[p];e.setAttribute("position",new sm(u,3)),e.setAttribute("normal",new sm(f,3));let h=ge.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ww),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},ge.free_mesh_data(i),m}function Yw(n,t){if(ge===void 0)return-1;let e,r,o;if(t&&n.userData.positions!==void 0){let h=n.userData;o=h.verticesPerFace.length,e=h.positions,r=Array(h.verticesPerFace.reduce((y,x)=>y+x,0)+o);for(let y=0,x=0,v=0;y<h.verticesPerFace.length;y++){r[v++]=h.verticesPerFace[y];for(let A=0;A<h.verticesPerFace[y];A++)r[v++]=h.indices[x++]}}else({positions:e,faceIndices:r,nFaces:o}=qw(n,t));let i=e.length,s=r.length,l=e.length,c=r.length,p=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,a=l*Float32Array.BYTES_PER_ELEMENT,u=c*Uint32Array.BYTES_PER_ELEMENT,d=ge._malloc(p),f=new Float32Array(ge.HEAPF32.buffer,d,l),m=new Uint32Array(ge.HEAPU32.buffer,d+a,c);return f.set(e,0),m.set(r,0),ge.get_csg_mesh(d,i,d+a,s,o)}function Kw(n,t){ge.transform_csg_mesh(n,t.elements)}function Qw(n){ge.free_csg_mesh(n)}var tc={ConeGeometry:wd,CubeGeometry:_d,CylinderGeometry:Sd,DodecahedronGeometry:Td,EllipseGeometry:Qd,HelixGeometry:rf,IcosahedronGeometry:of,LatheGeometry:nf,NonParametricGeometry:ff,PolygonGeometry:mf,PyramidGeometry:hf,RectangleGeometry:gf,SphereGeometry:yf,PlaneGeometry:xf,BackdropGeometry:vf,StarGeometry:bf,TextFrameGeometry:Ys,TorusGeometry:Sf,TorusKnotGeometry:wf,TriangleGeometry:_f,VectorGeometry:st},_i=n=>tc[n.type].create(n);import{BufferGeometry as cm,Matrix4 as Zw}from"three";var um=new Zw;var ca=class extends Qe{constructor(e=new cm,r){super(e,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.objectType="BooleanObject",this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.objectType="BooleanObject",this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(e){if(this.booleanMeshSetAddress!==-1)return;for(let o=0;o<this.children.length;o++){let i=this.children[o];er(i)&&i.recomputeBoolean(e===!0)}this.meshSetAddresses=[];for(let o=0;o<this.children.length;o++){let i=this.children[o];if(Mf(i)&&i.booleanExclude===!1&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0){if(i.booleanMeshSetAddress===-1){if(i.booleanMeshSetAddress=Vt.getMeshSet(i.geometry,e===!0),i.booleanMeshSetAddress===-1)return;Vt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1}else er(i)&&i.needsTransformForDownstream===!0?(Vt.transformMeshSet(i.booleanMeshSetAddress,i.matrix),i.needsTransformForDownstream=!1):i.booleanWasTransformed===!0&&(um.multiplyMatrices(i.matrix,i.booleanMatrixInvOld),Vt.transformMeshSet(i.booleanMeshSetAddress,um),i.booleanMatrixInvOld.copy(i.matrix).invert(),i.booleanWasTransformed=!1);this.meshSetAddresses.push(i.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return Vt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new cm,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Vt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(o){this.booleanMeshSetAddress=0,console.error(o)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,$r(this),Xr(this)}updateGeometry(e){let r=e.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};import{Camera as m1,OrthographicCamera as h1,PerspectiveCamera as g1,Vector3 as zt,Object3D as fm,Quaternion as y1}from"three";import{BoxBufferGeometry as Jw}from"three";var pr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new Jw(30,30,30),t};import{Camera as n1,LineSegments as i1,BufferGeometry as s1,LineBasicMaterial as a1,Color as pc,Vector3 as l1,Float32BufferAttribute as dm}from"three";import{Ray as e1,Sphere as t1,Matrix4 as r1,Vector3 as Ar}from"three";var ua=new e1,uc=new t1,pm=new r1,dr=(n,t,e,r,o=!1)=>{let i=t,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),uc.copy(i.boundingSphere),uc.applyMatrix4(s),e.ray.intersectsSphere(uc)===!1||(pm.copy(s).invert(),ua.copy(e.ray).applyMatrix4(pm),i.boundingBox!==null&&ua.intersectsBox(i.boundingBox)===!1))return;let l,c,p,a,u=i.index,d=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let x=Math.max(0,f.start),v=Math.min(u.count,f.start+f.count);for(m=x,h=v;m<h;m+=3)if(c=u.getX(m),p=u.getX(m+1),a=u.getX(m+2),l=y(n,e,ua,d,c,p,a),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let v=i.attributes.position,A=new Ar,S=new Ar,b=new Ar,D=new Ar,w=2,L=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=L*L,P=Math.max(0,f.start),N=Math.min(v.count,f.start+f.count);for(let C=P,k=N-1;C<k;C+=w){if(A.fromBufferAttribute(v,C),S.fromBufferAttribute(v,C+1),ua.distanceSqToSegment(A,S,D,b)>T)continue;D.applyMatrix4(n.matrixWorld);let oe=e.ray.origin.distanceTo(D);oe<e.near||oe>e.far||r.push({distance:oe,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(x,v,A,S,b,D,w){let g=new Ar,L=new Ar,T=new Ar,P=new Ar,N=new Ar;if(g.fromBufferAttribute(S,b),L.fromBufferAttribute(S,D),T.fromBufferAttribute(S,w),A.intersectTriangle(g,L,T,!1,P)===null)return null;N.copy(P),N.applyMatrix4(x.matrixWorld);let k=v.ray.origin.distanceTo(N);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:N.clone(),object:x}}};var pa=new l1,Mt=new n1,dc=class extends i1{constructor(e){let r=new s1,o=new a1({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new pc(15711266),p=new pc(15711266),a=new pc(2857471);u("n1","n2",c),u("n2","n4",c),u("n4","n3",c),u("n3","n1",c),u("f1","f2",c),u("f2","f4",c),u("f4","f3",c),u("f3","f1",c),u("n1","f1",c),u("n2","f2",c),u("n3","f3",c),u("n4","f4",c),u("p","n1",p),u("p","n2",p),u("p","n3",p),u("p","n4",p),u("u1","u2",a),u("u2","u3",a),u("u3","u1",a);function u(f,m,h){d(f,h),d(m,h)}function d(f,m){i.push(0,0,0),s.push(m.r,m.g,m.b),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}r.setAttribute("position",new dm(i,3)),r.setAttribute("color",new dm(s,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Mt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;Ft("n1",r,e,Mt,-i,-s,l),Ft("n2",r,e,Mt,i,-s,l),Ft("n3",r,e,Mt,-i,s,l),Ft("n4",r,e,Mt,i,s,l);let c=l;Ft("f1",r,e,Mt,-i,-s,c),Ft("f2",r,e,Mt,i,-s,c),Ft("f3",r,e,Mt,-i,s,c),Ft("f4",r,e,Mt,i,s,c);let p=c,a=.5;Ft("u1",r,e,Mt,i*.7*a,s*1.1,p),Ft("u2",r,e,Mt,-i*.7*a,s*1.1,p),Ft("u3",r,e,Mt,0,s*(1.1+.9*a),p),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ft(n,t,e,r,o,i,s){pa.set(o,i,s).unproject(r);let l=t[n];if(l!==void 0){let c=e.getAttribute("position");for(let p=0,a=l.length;p<a;p++)c.setXYZ(l[p],pa.x,pa.y,pa.z)}}var da=class extends pr(dc){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){dr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as c1}from"three";var hn=class extends pr(c1){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){dr(this.object,hn.geometryHelper,e,r)}};import{AxesHelper as u1}from"three";var gn=class extends pr(u1){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){dr(this.object,gn.geometryHelper,e,r)}update(){}};import{PointLightHelper as p1}from"three";var yn=class extends pr(p1){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){dr(this.object,yn.geometryHelper,e,r)}};import{SpotLightHelper as d1,Vector3 as f1}from"three";var fa=class extends pr(d1){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){dr(this.object,fa.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=fa._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Ti=fa;Ti._vector=new f1;var fr=(n,t)=>class extends n{constructor(){super(...arguments);this.objectHelper=new t(this)}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}fromLightState(o,i){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;o.color!==void 0&&(s.color=Fe(o.color,i)),o.intensity!==void 0&&(s.intensity=o.intensity),o.depth!==void 0&&(s.shadow.camera.far=o.depth,s.shadow.needsUpdate=!0),o.shadows!==void 0&&(this.castShadow=o.shadows)}return this}};var xn=new zt,fc=new zt,Nr=class extends fr(Pt(m1),da){constructor(e=window.innerWidth,r=window.innerHeight,o=45,i,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Jr.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new h1(e*-.5,e*.5,r*.5,r*-.5,i??-5e4,s),this.perspCamera=new g1(o,e/r,i??50,s),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()}static createFromState(e,r){let o=new Nr().fromState(r);return o.objectHelper.update(),o.uuid=e,o}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(xn),this.targetOffset=xn.distanceTo(e)}getTarget(e=new zt){return this.getWorldDirection(fc),this.getWorldPosition(xn),fc.multiplyScalar(this.targetOffset),e.copy(xn).add(fc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(xn),xn.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new y1),r=new zt(0,0,1).applyQuaternion(e),o=new zt().copy(fm.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let i=new zt().copy(fm.DefaultUp).projectOnPlane(r),s=new zt().crossVectors(i,o).dot(r)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(o)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new zt),i=e.getWorldDirection(new zt).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToObject(e){let r=e.getWorldPosition(new zt),i=this.getWorldDirection(new zt).multiplyScalar(this.targetOffset);return{position:r.clone().sub(i),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,s,l):this.orthoCamera.setViewOffset(e,r,o,i,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){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 Ro(r,e)}fromCameraState(e){let{orthographic:r,perspective:o}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near,this.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom,this.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near,this.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov,this.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom,this.zoom=o.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as x1}from"three";var uo=class extends fr(Pt(x1),gn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new uo().fromState(r);return o.uuid=e,o.objectHelper.update(),o}};import{DirectionalLight as v1,CameraHelper as ma}from"three";var vn=class extends fr(Pt(v1),hn){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.top=1250,o.bottom=-1250,o.right=1250,o.left=-1250,o.near=-1e4,o.far=2500;let i=new ma(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new vn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ma&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ma&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ma&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}fromDirectionalLightState(e,r){let o=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&Cf(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),o&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as b1,Vector3 as ha,Box3 as S1,Box3Helper as ga,Color as w1}from"three";var bn=class extends fr(Pt(b1),yn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let i=new ha(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ha(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),l=new S1(i,s),c=new ga(l,new w1(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,r,o){let i=new bn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof ga){let o=this.shadow.camera,i=new ha(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ha(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z);r.box.set(i,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as _1,CameraHelper as ya,MathUtils as T1,Vector3 as ym,Quaternion as A1}from"three";var mm=new ym,hm=new ym,gm=new A1,Sn=class extends fr(Pt(_1),Ti){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=T1.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let i=new ya(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new Sn().fromState(r,o);return i.uuid=e,i}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ya&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ya&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ya&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),hm.setFromMatrixPosition(this.matrixWorld),gm.setFromRotationMatrix(this.matrixWorld),mm.copy(this.up).applyQuaternion(gm).negate().multiplyScalar(this.distance),this.target.position.copy(hm).add(mm),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var xm=n=>n.tagName==="VIDEO",wn=class{static resize(t,e,r){let o=t/e,i;if(!r.image)return;let s=r.image;xm(s)?i=s.videoWidth/s.videoHeight:i=s.width/s.height,o>i&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*i/o):r.repeat.set(1,1*i/o)),o<i&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/i*-1,1):r.repeat.set(1*o/i,1)),o==i&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let o=t/e,i=r.image!==void 0?r.image.width/r.image.height:1,s;o>i?s={x:1,y:i/o}:o<i?s={x:o/i,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let o=r.layers;for(let i=0;i<o.length;i++){let s=o[i];Xf(s)&&wn.resizeTextureLayer(t,e,s.uniforms[`f${s.id}_texture`].value)}}static resizeComplex(t,e,r,o){let i=t/e,s,l=r.image;xm(l)?s=l.videoWidth/l.videoHeight:s=l.width/l.height,o.geometry.type.includes("Shape")?(i>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/i):r.repeat.set(1/t,1/e*s/i)),i<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*i/s*-1,1/e):r.repeat.set(1/t*i/s,1/e)),i==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(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)))}};var xa=class extends Qe{constructor(e,r){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.layers&&wn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var _n=class extends Qe{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var va=class extends _n{constructor(e,r){super(e,r);this.objectType="NonParametric"}};import{DoubleSide as N1,Mesh as C1,MeshBasicMaterial as I1,ShapeBufferGeometry as P1,Vector2 as L1,Vector3 as O1}from"three";import{FontLoader as M1}from"three/examples/jsm/loaders/FontLoader.js";var Ee=class extends C1{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:i,fontSize:s,LOD:l=16},c=new I1({color:0,opacity:1,visible:!0,transparent:!0,side:N1})){let p=Ee.loadChar(e,o,l);super(p.geometry,c);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=i,this.fontSize=s,this.LOD=l,this.resolution=p.resolution,this.glyphsHa=p.glyphsHa,this.localPosition=new L1,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 Ee._fontPath}static set FONTS_PATH(e){Ee._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let o=new O1(this.localPosition.x,-this.localPosition.y,0);this.position.copy(o).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Ee.loadChar(this.char,e,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(e){if(this.char===e)return;this.char=e;let r=Ee.loadChar(e,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(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=Ee.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 e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Ee(e).copy(this)}static loadFont(e){return new Promise(function(r,o){Ee.fontCache[e]?r(Ee.fontCache[e]):new M1().load(Ee.FONTS_PATH+e+".json",s=>{Ee.fontCache[e]=s,r(s)},void 0,o)})}static loadChar(e,r,o){if(Ee.charCache[e]){if(Ee.charCache[e][o]&&Ee.charCache[e][o].fontFamily===r)return Ee.charCache[e][o]}else Ee.charCache[e]={};let i=Ee.fontCache[r],s=i.generateShapes(e,1);return Ee.charCache[e][o]={geometry:new P1(s,o),fontFamily:r,resolution:i.data.resolution,glyphsHa:i.data.glyphs[e].ha},Ee.charCache[e][o]}},Ut=Ee;Ut.charCache={},Ut.fontCache={},Ut._fontPath="/_assets/_fonts/";import{DoubleSide as bm,MeshBasicMaterial as Sm,Vector3 as D1,Object3D as B1}from"three";import{Vector2 as vm}from"three";var ba=new vm,po=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new vm(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,o;for(o=t;o>=0;o-=1)if(this.message[o].char===" "){r=!1,e.length===0&&(o-=1,e.splice(0,0,this.message[o]));break}else e.splice(0,0,this.message[o]);return r?e=[]:this.message.splice(o+1,e.length),e}getWord(t=0,e=1){let r=[],o=t;for(o=t;;o+=e){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}e>0?(r.push(this.message[o]),this.message.splice(o,1),o-=e):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,o=t;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=e}return(o<0||o>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let o=e;o<=r;o+=1)this.message[o].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,o,i){switch(r){case 1:this.leftAlign(t,i);break;case 3:this.centerAlign(this.spaceLeft(e),t,i);break;case 2:this.rightAlign(this.spaceLeft(e),t,i);break;case 4:this.justifyAlign(this.spaceLeft(e),t,i);break}}offsetCharacters(t,e,r){ba.set(e,r);let o=this.message.length;for(let i=0;i<o;i++)this.message[i].updatePosition(this.message[i].localPosition.add(ba),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(e,0,r);return}let i=t/o,s=0;for(let l=0;l<this.message.length;l++)this.message[l].char===" "&&(s+=i),ba.set(s,r),this.message[l].updatePosition(this.message[l].localPosition.add(ba),e)}clone(){let t=new po(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var mc=class extends Qe{constructor(e){super(e,new Sm({transparent:!0,opacity:1,visible:!1,side:bm}));this.objectType="TextFrame";this.charContainer=new B1,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.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 D1(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let i=Ys.create({parameters:{width:r.width,height:r.height}}),s=new mc(i).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await Ut.loadFont(o),r.text=e;let i=r.textOrigin,s=new Sm({visible:r.visible,transparent:!0,side:bm}),l=e.split(`
1333
- `),c=0;this.userData.textFrame.textLines=l.map((p,a)=>{let u=new po(c,r.lineHeight,r.fontSize);return u.message=p.split("").map(d=>{let f={char:d,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=s.clone();m.color=r.hexColor,m.opacity=r.opacity;let h=new Ut(f,m);return u.addChar3D(h,i),this.charContainer.add(h),h}),c+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let i=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof Ut&&(e.intersectObject(this.charContainer.children[s],!1,i),i.length>0)){i[0].object=this,r.push(i[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,i=o.parameters.width,s=o.parameters.height,l=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=l,p.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==i&&(i<l?this.checkCapacity():i>l&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.textLines;for(let s=e;s<i.length;s++){i[s].updateYLinePos(this.getNewLinePosition(s)),i[s].fullUpdate(o);let l=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?l.unshift(i[s].getWord(i[s].message.length-1,-1)):l.unshift(i[s].popChar());if(l.length>0){i[s+1]===void 0?(i[s].isEndLine(!1),this.createTextLine()):i[s].endLine&&(this.createTextLine(s+1),i[s].isEndLine(!1),i[s+1].isEndLine(!0));let c=0;for(let p=0;p<l.length;p+=1)for(let a=0;a<l[p].length;a+=1)i[s+1].addChar3D(l[p][a],o,c),c+=1;i[s+1].fullUpdate(o)}i[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o),!!s[l-1])for(;!s[l-1].endLine;){let c,p=s[l-1].spaceLeft(i);if(s[l].wordSize(0,1)<=p){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let a=0;a<c.length;a+=1)c[a]&&s[l-1].addChar3D(c[a],o)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new po(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<i.length;l++)i[l].updateYLinePos(this.getNewLinePosition(l)),i[l].fullUpdate(o.textOrigin),i[l].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}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(e){let o=this.userData.textFrame.textLines,i=0;for(let s=0;s<e;s+=1)i+=o[s].maxCharSize*o[s].lineHeight;return i}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.color?.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await Ut.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,i=o.textLines,s=o.fontSize;o.fontSize=e;for(let l=0;l<i.length;l++)i[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await Ut.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let i=0;i<o.length;i++)o[i].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Fe(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}},fo=mc;fo.VerticalAlign=Qa,fo.HorizontalAlign=Ka,fo.TextTransform=Za;var mo=class extends St{};var Am=Sc(wm());var _m=new Map;function Tm(n){if(typeof n=="string")return n;let t=_m.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},_m.set(n,t)),t.url}var Tn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._isStarted=!1;this.onEnd=()=>{this._loop>1?this.loopsRemaining===1/0?this.play():this.loopsRemaining>1?(this.play(),this.loopsRemaining--):this._isStarted=!1:this._isStarted=!1};let i;typeof t=="string"?i={src:t}:i={src:Tm(t),format:"wav"},this.sound=new Am.Howl(i),this.sound.on("end",this.onEnd),this._src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get src(){return this._src}get isStarted(){return this._isStarted}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._isStarted=!0,this.delay?(this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)):this.sound.play()}pause(){this._isStarted=!1,this.sound.pause(),this.clearFade(),this.clearDelay()}stop(){this._isStarted=!1,this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay()}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Ni=class{constructor(t){this.deletedMaterial=new mo(br.defaultTwoLayerData("basic"),this);this.deletedImage=new lo(Bs.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};this.reset(t)}setOnImageLoad(t){this._onImageLoad=t}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,new mo(r,this));for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.data);this.penumbraSize=t.penumbraSize}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new St(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new lo(e,this.onImageLoad),!1)}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):new pn(t,this.onImageLoad)}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Wr(e.r,e.g,e.b,e.a):this.colors[t]=new Wr(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Ue(0,0,0,0))}else return"a"in t?new Ue(t.r,t.g,t.b,t.a):new Ue(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Tn)return e;{let r=new Tn({src:e});return this.audios[t]=r,r}}deleteAudio(t){this.audios[t]&&delete this.audios[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._onImageLoad=void 0,Object.values(this.audios).forEach(e=>{e instanceof Tn&&e.dispose()}),this.audios={}}},tH=new Ni(Ds.emptyData());import{DRACOLoader as E1}from"three/examples/jsm/loaders/DRACOLoader.js";var Yr;function G1(){return Yr||(Yr=new E1,Yr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Yr.decoderPending}async function R1(n){if(Yr){let t={attributeIDs:Yr.defaultAttributeIDs,attributeTypes:Yr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Yr.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function Nm(n,t){let[e,r]=Ba(Ts.deserialize(new Uint8Array(n)));vd(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await G1();for(let i of o){let s=await R1(qt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:p,itemSize:a})=>{l[c]={array:p,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{HemisphereLight as o_,Scene as n_,Vector3 as i_,Fog as s_,Box3 as a_}from"three";import{Box3 as V1,Matrix4 as ho,Sphere as Pm,Vector3 as F1}from"three";var Om=Sc(Im());var hc;Ks.then(n=>{hc=n});var Mm=new ho,z1=new ho,U1=new ho,jt=new V1,Kr=new F1,j1=new ho,k1=new ho,An=class extends Qe{constructor(e,r,o,i){super(o??r,i);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new ho;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new ho;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}=Ot.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new An(i,s,l||void 0,c);return r.geometry.phongAngle!==void 0&&(p.phongAngle=r.geometry.phongAngle),p.calcBoundingBox(),p.freeSubdivPointer(),p.uuid=e,p.fromState(r),p}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Ot.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,$r(this),Xr(this),e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Ot.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ot.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,Qe.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:i,q:s}=(0,Om.SVD)(r),l=Mm.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=z1.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),p=U1.copy(c).transpose();this.shearScale=j1.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=k1.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,p),s.every(a=>Math.abs(s[0]-a)<.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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Pm);let r=e.attributes.position,o=e.boundingSphere.center;jt.setFromBufferAttribute(r),jt.getCenter(o),e.boundingSphere.radius=o.distanceTo(jt.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jt.getSize(Kr);let i={width:Kr.x,height:Kr.y,depth:Kr.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;jt.min.set(e[0],e[2],e[4]),jt.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(jt.min.applyMatrix4(this.shearScaleInv),jt.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Pm);let o=r.boundingSphere.center;jt.getCenter(o),r.boundingSphere.radius=o.distanceTo(jt.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jt.getSize(Kr);let i={width:Kr.x,height:Kr.y,depth:Kr.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(hc.free_bvh(this.subdivPointer),hc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Lm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Lm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function Lm(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Mm.makeScale(t,e,r).invert().elements,l,c,p;for(var a=0,u=o.length;a<u;a+=3)o[a]*=t,o[a+1]*=e,o[a+2]*=r,l=i[a],c=i[a+1],p=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*p,i[a+1]=s[1]*l+s[5]*c+s[9]*p,i[a+2]=s[2]*l+s[6]*c+s[10]*p}import{BackSide as H1,BufferGeometry as W1,DoubleSide as q1,FrontSide as $1}from"three";function Dm(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=$1:t.side===1?n.side=H1:n.side=q1)}function X1(n,t){if(Array.isArray(n.material))for(let e of n.material)Dm(e,t);else{let e=n.material;Dm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Bm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=An.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new W1:sa(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ps.is2DParametricMesh(o.userData.type)?r=new xa(o,i):o?.userData.type==="VectorGeometry"?r=new fn(o,i):t.geometry.type==="NonParametricGeometry"?r=new va(o,i):t.geometry.type==="BooleanGeometry"?(r=new ca(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new _n(o,i),r.uuid=n,r.fromState(t,e)}return X1(r,t),r}function Em(n,t,e){return t.type==="Mesh"?Bm(n,t,e):t.type==="TextFrame"?fo.createFromState(n,t,e):t.type==="Empty"?uo.createFromState(n,t):t.type==="PointLight"?bn.createFromState(n,t,e):t.type==="SpotLight"?Sn.createFromState(n,t,e):t.type==="DirectionalLight"?vn.createFromState(n,t,e):Vo.is(t.type)?Nr.createFromState(n,t):(console.error(t),new uo)}import{Mesh as Vm,Ray as K1,Matrix4 as Q1,Raycaster as Z1}from"three";function Gm(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,Xr(n),$r(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Rm(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),e}function Fm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Vm&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Gm(e,e.material[r])&&(t=!0);else Gm(e,e.material)&&(t=!0)}),t}function zm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Vm)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Rm(e,e.material[r])&&(t=!0);else Rm(e,e.material)&&(t=!0)}),t}function Um(n){"material"in n&&J1(n.material),"geometry"in n&&n.geometry.dispose()}function J1(n){wc(n).forEach(t=>{t instanceof mo||t.dispose()})}var e_=new Z1,t_=new Q1,r_=new K1;function jm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=t_.copy(o.matrixWorld).invert(),s=r_.copy(t.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=e_;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var km=new i_,gc=class extends Zs(n_){constructor(e,r){super();this.objectType="Scene";this.backupFog=new s_(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.bgColor=new Ue(1,1,1,1);this.entityByUuid={};this.ambientLight=new o_(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,r)}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=zm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Fm(this),this.needsNormalDirty=!1),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Fe(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Nr&&this.switchActiveCamera(o)}this.traverse(o=>{er(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Um(e)});for(let e of this.children)or(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Nr.createFromState(gc.PERSONAL_CAMERA_ID,{...Os.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=i=>{for(let s of i.children)or(s)&&!s.raycastLock&&s.visible&&((Jt(s)||Qs(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),jm(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)or(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)or(r)&&r.visible&&r.traverseVisibleEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Fe(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Nf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Fe(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,r,o){for(let i of e)this.createChildObject(i.id,i.data,i.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,i,s){let l=Em(e,r,s);return l&&(this.entityByUuid[e]=l,i.add(l),er(i)&&Jt(l)&&(l.prevBooleanObjectParent=i),this.createChildrenObjects(o,l,s)),l}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],p=this.find(l),a=c?p.recursiveBBox:p.singleBBox;r.push(...a.vertices)}let o=new a_;return o.setFromPoints(r),o.getCenter(km),km}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Qe)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof St&&e(r.material[o]);else r.material instanceof St&&e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,i;e>=r?(o=r/e,i=1):(o=1,i=e/r),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},Ci=gc;Ci.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as _5}from"three";import{mergeBufferGeometries as N5}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Hm(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as Wm,ShaderLib as l_}from"three";function qm(n){let t=new Set;return n.traverse(e=>{if(Jt(e))if(Oe(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);c_(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Wm,specularColor:new Wm}),e.onBeforeCompile=(o,i)=>{r&&r(o,i),o.uniforms=Object.assign(l_.physical.uniforms,o.uniforms),e.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):u_(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function c_(n){return n.getLayersOfType("transmission").length>0}function u_(n){let t=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}}),t<1}function $m(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Xm(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as p_}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Ym(n){let t=[];return n.traverse(e=>{e instanceof no&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Hm(c),c}),s=p_(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function Km(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Qm(n){Object.values(n.shared.materials).forEach(t=>{yc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?yc(e.material):"materials"in e&&e.materials.forEach(r=>{yc(r)})})}function yc(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Zm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xc=class extends f_{load(t,e,r,o=console.error){let i=new d_(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Zm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Zm),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},r,o)}async parse(t){let e=await Nm(t,Qm),r=new Ni(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Ci(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&Af(s)&&Object.assign(s,{makeDefault:!0})}return o=Ym(o),o=qm(o),o=$m(o),o=Xm(o),o=Km(o),o}};export{xc as default};
1333
+ `),c=0;this.userData.textFrame.textLines=l.map((p,a)=>{let u=new po(c,r.lineHeight,r.fontSize);return u.message=p.split("").map(d=>{let f={char:d,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=s.clone();m.color=r.hexColor,m.opacity=r.opacity;let h=new Ut(f,m);return u.addChar3D(h,i),this.charContainer.add(h),h}),c+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let i=[];for(let s=0,l=this.charContainer.children.length;s<l;++s)if(this.charContainer.children[s]instanceof Ut&&(e.intersectObject(this.charContainer.children[s],!1,i),i.length>0)){i[0].object=this,r.push(i[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,i=o.parameters.width,s=o.parameters.height,l=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=l,p.textOrigin.set(-.5*l,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):l!==i&&(i<l?this.checkCapacity():i>l&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.textLines;for(let s=e;s<i.length;s++){i[s].updateYLinePos(this.getNewLinePosition(s)),i[s].fullUpdate(o);let l=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?l.unshift(i[s].getWord(i[s].message.length-1,-1)):l.unshift(i[s].popChar());if(l.length>0){i[s+1]===void 0?(i[s].isEndLine(!1),this.createTextLine()):i[s].endLine&&(this.createTextLine(s+1),i[s].isEndLine(!1),i[s+1].isEndLine(!0));let c=0;for(let p=0;p<l.length;p+=1)for(let a=0;a<l[p].length;a+=1)i[s+1].addChar3D(l[p][a],o,c),c+=1;i[s+1].fullUpdate(o)}i[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,i=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let l=e;l<s.length;l+=1)if(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o),!!s[l-1])for(;!s[l-1].endLine;){let c,p=s[l-1].spaceLeft(i);if(s[l].wordSize(0,1)<=p){s[l].containSpace()?c=s[l].getWord(0,1):c=s[l].popChar(0);for(let a=0;a<c.length;a+=1)c[a]&&s[l-1].addChar3D(c[a],o)}else{s[l].isEmpty()?(s[l].endLine&&s[l-1].isEndLine(!0),s.splice(l,1),l-=1):(s[l].updateYLinePos(this.getNewLinePosition(l)),s[l].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new po(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let l=e;l<i.length;l++)i[l].updateYLinePos(this.getNewLinePosition(l)),i[l].fullUpdate(o.textOrigin),i[l].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}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(e){let o=this.userData.textFrame.textLines,i=0;for(let s=0;s<e;s+=1)i+=o[s].maxCharSize*o[s].lineHeight;return i}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.color?.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++){let c=s[l].material;c.visible=e}}}async updateFontFamily(e){await Ut.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)l[c].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,i=o.textLines,s=o.fontSize;o.fontSize=e;for(let l=0;l<i.length;l++)i[l].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await Ut.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let l=i[s].message;for(let c=0;c<l.length;c++)i[s].message[c].updateChar(l[c].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let i=0;i<o.length;i++){let s=o[i].message;for(let l=0;l<s.length;l++)s[l].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let i=0;i<o.length;i++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let i=0;i<o.length;i++)o[i].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Fe(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}},fo=mc;fo.VerticalAlign=Qa,fo.HorizontalAlign=Ka,fo.TextTransform=Za;var mo=class extends St{};var Am=Sc(wm());var _m=new Map;function Tm(n){if(typeof n=="string")return n;let t=_m.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},_m.set(n,t)),t.url}var Tn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._isStarted=!1;this.onEnd=()=>{this._loop>1?this.loopsRemaining===1/0?this.play():this.loopsRemaining>1?(this.play(),this.loopsRemaining--):this._isStarted=!1:this._isStarted=!1};let i;typeof t=="string"?i={src:t}:i={src:Tm(t),format:"wav"},this.sound=new Am.Howl(i),this.sound.on("end",this.onEnd),this._src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get src(){return this._src}get isStarted(){return this._isStarted}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._isStarted=!0,this.delay?(this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)):this.sound.play()}pause(){this._isStarted=!1,this.sound.pause(),this.clearFade(),this.clearDelay()}stop(){this._isStarted=!1,this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay()}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Ni=class{constructor(t,e={}){this.deletedMaterial=new mo(br.defaultTwoLayerData("basic"),this);this.deletedImage=new lo(Bs.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o.data);this.reset(t)}setOnImageLoad(t){this._onImageLoad=t}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,new mo(r,this));for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.data);this.penumbraSize=t.penumbraSize}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new St(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new lo(e,this.onImageLoad),!1)}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):new pn(t,this.onImageLoad)}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Wr(e.r,e.g,e.b,e.a):this.colors[t]=new Wr(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Ue(0,0,0,0))}else return"a"in t?new Ue(t.r,t.g,t.b,t.a):new Ue(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Tn)return e;{let r=new Tn({src:e});return this.audios[t]=r,r}}deleteAudio(t){this.audios[t]&&delete this.audios[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._onImageLoad=void 0,Object.values(this.audios).forEach(e=>{e instanceof Tn&&e.dispose()}),this.audios={}}},tH=new Ni(Ds.emptyData());import{DRACOLoader as E1}from"three/examples/jsm/loaders/DRACOLoader.js";var Yr;function G1(){return Yr||(Yr=new E1,Yr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Yr.decoderPending}async function R1(n){if(Yr){let t={attributeIDs:Yr.defaultAttributeIDs,attributeTypes:Yr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Yr.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function Nm(n,t){let[e,r]=Ba(Ts.deserialize(new Uint8Array(n)));vd(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await G1();for(let i of o){let s=await R1(qt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:p,itemSize:a})=>{l[c]={array:p,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{HemisphereLight as o_,Scene as n_,Vector3 as i_,Fog as s_,Box3 as a_}from"three";import{Box3 as V1,Matrix4 as ho,Sphere as Pm,Vector3 as F1}from"three";var Om=Sc(Im());var hc;Ks.then(n=>{hc=n});var Mm=new ho,z1=new ho,U1=new ho,jt=new V1,Kr=new F1,j1=new ho,k1=new ho,An=class extends Qe{constructor(e,r,o,i){super(o??r,i);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new ho;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new ho;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:l}=Ot.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new An(i,s,l||void 0,c);return r.geometry.phongAngle!==void 0&&(p.phongAngle=r.geometry.phongAngle),p.calcBoundingBox(),p.freeSubdivPointer(),p.uuid=e,p.fromState(r),p}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Ot.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,$r(this),Xr(this),e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Ot.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ot.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,Qe.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:i,q:s}=(0,Om.SVD)(r),l=Mm.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=z1.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),p=U1.copy(c).transpose();this.shearScale=j1.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=k1.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,p),s.every(a=>Math.abs(s[0]-a)<.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 e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Pm);let r=e.attributes.position,o=e.boundingSphere.center;jt.setFromBufferAttribute(r),jt.getCenter(o),e.boundingSphere.radius=o.distanceTo(jt.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jt.getSize(Kr);let i={width:Kr.x,height:Kr.y,depth:Kr.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;jt.min.set(e[0],e[2],e[4]),jt.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(jt.min.applyMatrix4(this.shearScaleInv),jt.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Pm);let o=r.boundingSphere.center;jt.getCenter(o),r.boundingSphere.radius=o.distanceTo(jt.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jt.getSize(Kr);let i={width:Kr.x,height:Kr.y,depth:Kr.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(hc.free_bvh(this.subdivPointer),hc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Lm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Lm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function Lm(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Mm.makeScale(t,e,r).invert().elements,l,c,p;for(var a=0,u=o.length;a<u;a+=3)o[a]*=t,o[a+1]*=e,o[a+2]*=r,l=i[a],c=i[a+1],p=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*p,i[a+1]=s[1]*l+s[5]*c+s[9]*p,i[a+2]=s[2]*l+s[6]*c+s[10]*p}import{BackSide as H1,BufferGeometry as W1,DoubleSide as q1,FrontSide as $1}from"three";function Dm(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=$1:t.side===1?n.side=H1:n.side=q1)}function X1(n,t){if(Array.isArray(n.material))for(let e of n.material)Dm(e,t);else{let e=n.material;Dm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Bm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=An.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new W1:sa(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ps.is2DParametricMesh(o.userData.type)?r=new xa(o,i):o?.userData.type==="VectorGeometry"?r=new fn(o,i):t.geometry.type==="NonParametricGeometry"?r=new va(o,i):t.geometry.type==="BooleanGeometry"?(r=new ca(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new _n(o,i),r.uuid=n,r.fromState(t,e)}return X1(r,t),r}function Em(n,t,e){return t.type==="Mesh"?Bm(n,t,e):t.type==="TextFrame"?fo.createFromState(n,t,e):t.type==="Empty"?uo.createFromState(n,t):t.type==="PointLight"?bn.createFromState(n,t,e):t.type==="SpotLight"?Sn.createFromState(n,t,e):t.type==="DirectionalLight"?vn.createFromState(n,t,e):Vo.is(t.type)?Nr.createFromState(n,t):(console.error(t),new uo)}import{Mesh as Vm,Ray as K1,Matrix4 as Q1,Raycaster as Z1}from"three";function Gm(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,Xr(n),$r(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Rm(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),e}function Fm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Vm&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Gm(e,e.material[r])&&(t=!0);else Gm(e,e.material)&&(t=!0)}),t}function zm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Vm)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Rm(e,e.material[r])&&(t=!0);else Rm(e,e.material)&&(t=!0)}),t}function Um(n){"material"in n&&J1(n.material),"geometry"in n&&n.geometry.dispose()}function J1(n){wc(n).forEach(t=>{t instanceof mo||t.dispose()})}var e_=new Z1,t_=new Q1,r_=new K1;function jm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=t_.copy(o.matrixWorld).invert(),s=r_.copy(t.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=e_;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var km=new i_,gc=class extends Zs(n_){constructor(e,r){super();this.objectType="Scene";this.backupFog=new s_(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.bgColor=new Ue(1,1,1,1);this.entityByUuid={};this.ambientLight=new o_(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,r)}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=zm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Fm(this),this.needsNormalDirty=!1),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Fe(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Nr&&this.switchActiveCamera(o)}this.traverse(o=>{er(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Um(e)});for(let e of this.children)or(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Nr.createFromState(gc.PERSONAL_CAMERA_ID,{...Os.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=i=>{for(let s of i.children)or(s)&&!s.raycastLock&&s.visible&&((Jt(s)||Qs(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),jm(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)or(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)or(r)&&r.visible&&r.traverseVisibleEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Fe(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Nf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Fe(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,r,o){for(let i of e)this.createChildObject(i.id,i.data,i.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,i,s){let l=Em(e,r,s);return l&&(this.entityByUuid[e]=l,i.add(l),er(i)&&Jt(l)&&(l.prevBooleanObjectParent=i),this.createChildrenObjects(o,l,s)),l}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],p=this.find(l),a=c?p.recursiveBBox:p.singleBBox;r.push(...a.vertices)}let o=new a_;return o.setFromPoints(r),o.getCenter(km),km}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Qe)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof St&&e(r.material[o]);else r.material instanceof St&&e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,i;e>=r?(o=r/e,i=1):(o=1,i=e/r),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},Ci=gc;Ci.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as _5}from"three";import{mergeBufferGeometries as N5}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Hm(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as Wm,ShaderLib as l_}from"three";function qm(n){let t=new Set;return n.traverse(e=>{if(Jt(e))if(Oe(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);c_(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Wm,specularColor:new Wm}),e.onBeforeCompile=(o,i)=>{r&&r(o,i),o.uniforms=Object.assign(l_.physical.uniforms,o.uniforms),e.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):u_(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function c_(n){return n.getLayersOfType("transmission").length>0}function u_(n){let t=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}}),t<1}function $m(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Xm(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as p_}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Ym(n){let t=[];return n.traverse(e=>{e instanceof no&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Hm(c),c}),s=p_(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function Km(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function Qm(n){Object.values(n.shared.materials).forEach(t=>{yc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?yc(e.material):"materials"in e&&e.materials.forEach(r=>{yc(r)})})}function yc(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Zm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xc=class extends f_{load(t,e,r,o=console.error){let i=new d_(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Zm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Zm),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},r,o)}async parse(t){let e=await Nm(t,Qm),r=new Ni(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Ci(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&Af(s)&&Object.assign(s,{makeDefault:!0})}return o=Ym(o),o=qm(o),o=$m(o),o=Xm(o),o=Km(o),o}};export{xc as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/loader",
3
- "version": "0.9.98",
3
+ "version": "0.9.99",
4
4
  "type": "module",
5
5
  "main": "./build/SplineLoader.js",
6
6
  "module": "./build/SplineLoader.js",
@@ -37,7 +37,7 @@
37
37
  "prettier": "^2.6.2",
38
38
  "raw-loader": "^4.0.2",
39
39
  "source-map-explorer": "^2.5.2",
40
- "spe": "workspace:*",
40
+ "spe": "0.0.0",
41
41
  "three": "^0.142.0",
42
42
  "typescript": "^4.1.3",
43
43
  "vite": "^2.9.0"
@@ -57,4 +57,4 @@
57
57
  "not Android <= 4.4"
58
58
  ]
59
59
  }
60
- }
60
+ }
package/build/Parser.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import { DocumentData } from 'spline-data';
2
- export default class Parser {
3
- private dracoLoader?;
4
- /**
5
- * Only get the draco decoders if this function is called
6
- */
7
- private _preloadDraco;
8
- parseDraco(encodedData: number[]): Promise<{
9
- index: {
10
- array: ArrayLike<number>;
11
- } | undefined;
12
- attributes: {
13
- name: string;
14
- itemSize: number;
15
- array: ArrayLike<number>;
16
- }[];
17
- } | null>;
18
- parse(buffer: ArrayBuffer): Promise<DocumentData>;
19
- }
@@ -1,2 +0,0 @@
1
- import { Scene as SplineScene } from 'spe';
2
- export declare function convertCloners(scene: SplineScene): SplineScene;