@splinetool/loader 0.9.108 → 0.9.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.cjs +1 -1
- package/build/SplineLoader.js +1 -1
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -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 rm=require("three");function tm(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Ca=class extends In{constructor(e,r){super(new rm.Matrix3);this.repeat=e;this.offset=r;tm(this.value,e,r)}updateMatrix(){tm(this.value,this.repeat,this.offset)}};var _r=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)uc(i,this,r)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return Tr.createLigherLayer(t,e,r,o);if(r.type==="texture"){let i=o.image(r.texture.image),s=new ji(i,r.texture.wrapping),a=new Aa(i),c=new Ca(r.texture.repeat,r.texture.offset),p=new Y(r.crop?1:0),l=new xe(r.projection??0),u=new xe(["x","y","z"].indexOf(r.axis)??0),d=new xe(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 xe(r.mode??0),g=new Mi(s,a,p,l,u,d,f,c,m,h),x=new _e(g.calpha,"f");return new ot(t,e,r,{texture:s,textureSize:a,crop:p,projection:l,axis:u,side:d,size:f,mat:c,alpha:m,mode:h},g,h,x)}else if(r.type==="matcap"){let i=o.image(r.texture.image),s=new ji(i,r.texture.wrapping),a=new Y(r.alpha??1),c=new xe(r.mode??0),p=new Ui(s,a,c),l=new _e(p.calpha,"f");return new ot(t,e,r,{texture:s,alpha:a,mode:c},p,c,l)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new ct(new Oe.Vector3(...r.offset)),s=new Y(r.scale??10),a=new Y(r.intensity??8),c=new Y(r.movement??1),p=new xe(r.noiseType??0),l=new Li(a,c,i,s,p);return new Hi(t,e,r,{offset:i,scale:s,intensity:a,movement:c,noiseType:p},l)}else throw new Error;else return TS(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?cc(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 _r{constructor(e,r,o,i,s,a,c){super(e,r,o,i);this.color=s;this.mode=a;this.alpha=c}},Hi=class extends _r{constructor(e,r,o,i,s){super(e,r,o,i);this.position=s}},Tr=class extends _r{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,a=new Y(o.alpha),c=new xe(o.mode),p;if(o.category==="lambert"){s=new Gi;let l=new Ce(i.color(o.emissive)??0);p={emissive:l},s.emissive=l}else if(o.category==="phong"){s=new Ta;let l=new Y(o.shininess??30),u=new Ce(i.color(o.specular)??1118481);p={shininess:l,specular:u},s.shininess=l,s.specular=u}else if(o.category==="toon"){s=new Vi;let l=new Y(o.shininess??30),u=new Ce(i.color(o.specular)??1118481);p={shininess:l,specular:u},s.shininess=l,s.specular=u}else if(o.category==="physical"){s=new Ri;let l=new Y(o.roughness??.3),u=new Y(o.metalness??0),d=new Y(o.reflectivity??.5);p={roughness:l,metalness:u,reflectivity:d},s.roughness=l,s.metalness=u,s.reflectivity=d}else s=new Lo,p={};return s.alpha=new Y(1),s.shadingAlpha=a,s.shadingBlend=c,p.alpha=s.shadingAlpha,p.mode=s.shadingBlend,new Tr(e,r,o,s,p)}};function om(n){let t=n instanceof _r?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}function _S(n,t,e,r){switch(n.type){case"color":{let o=new Ce(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 a=new xe(r.mode??0);return o.alpha=i,new ot(t,e,n,{color:o,alpha:i,mode:a},o,a,s)}case"fresnel":{let o=new Ce(r.color??16777215),i=new Y(r.bias??.1),s=new Y(r.scale??1),a=new Y(r.intensity??2),c=new Y(r.factor??1),p=new Y(r.alpha??1),l=new xe(r.mode??0),u=new Ti(o,i,s,a,c,p,l),d=new _e(u.calpha,"f");return new ot(t,e,n,{color:o,bias:i,scale:s,intensity:a,factor:c,alpha:p,mode:l},u,l,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)),a=new Y(r.noiseStrength??0),c=new Y(r.noiseScale??1),p=new ct(r.offset??new Oe.Vector3(0,0,0)),l=new Y(r.alpha??1),u=new Ai(o,i,s,a,c,p,l),d=new _e(u.calpha,"f"),f=new xe(r.mode??0);return new ot(t,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:a,noiseScale:c,offset:p,alpha:l,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),a=ut.transmissionSize,c=ut.transmissionRenderTarget,p=ut.transmissionRenderTargetDepth,l=window.innerWidth,u=window.innerHeight,d=l>=u?new st(u/l,1):new st(1,l/u),f=new Y(r.alpha??1),m=new Ni(o,i,s,a,c,p,d,f),h=new _e(m.calpha,"f"),g=new xe(r.mode??0);return new ot(t,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:d,alpha:f,mode:g},m,g,h)}case"toon":{let o=new xe(r.positioning??0),i;r.colors?i=new er(r.colors.length,r.colors):(i=new er(10,new Oe.Vector4(0,0,0,1)),i.value[1]=new Oe.Vector4(1,1,1,1));let s;r.steps?s=new Jt(r.steps.length,r.steps):(s=new Jt(10,1),s.value[0]=0);let a=new ct(r.source??new Oe.Vector3(0,0,0)),c=new so(r.isWorldSpace??!0),p=new Y(r.noiseStrength??0),l=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 ki(o,i,s,a,c,p,l,u,d,f),h=new _e(m.calpha,"f"),g=new xe(r.mode??0);return new ot(t,e,n,{positioning:o,colors:i,steps:s,source:a,isWorldSpace:c,noiseStrength:p,noiseScale:l,shadowColor:u,offset:d,alpha:f,mode:g},m,g,h)}case"outline":{let o=new Ce(r.outlineColor??16777215),i=new Ce(r.contourColor??16777215),s=new Y(r.outlineWidth??.1),a=new Y(r.contourWidth??.1),c=new Y(r.outlineThreshold??.1),p=new Y(r.contourThreshold??.1),l=new Y(r.outlineSmoothing??.1),u=new Y(r.contourFrequency??.1),d=new ct(r.contourDirections??new Oe.Vector3(0,1,0)),f=new so(r.positionalLines??!1),m=new so(r.compensation??!0),h=ut.normalRenderTarget,g=ut.normalRenderTargetDepth,x=ut.pixelRatioNode,v=ut.resolution,A=new Y(r.alpha??1),S=new Ci(o,i,s,a,c,p,l,u,d,f,m,v,h,g,x,A),b=new _e(S.calpha,"f"),D=new xe(r.mode??0);return new ot(t,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:a,outlineThreshold:c,contourThreshold:p,outlineSmoothing:l,contourFrequency:u,contourDirection:d,positionalLines:f,compensation:m,alpha:A,mode:D},S,D,b)}case"depth":{let o=new xe(r.gradientType??0),i=new so(r.smooth??!1),s=new Y(r.near??50),a=new Y(r.far??200),c=new Y(r.isVector??1),p=new Y(r.isWorldSpace??0),l=new ct(r.origin??new Oe.Vector3),u=new ct(r.direction??new Oe.Vector3),d;r.colors?d=new er(r.colors.length,r.colors):(d=new er(2,new Oe.Vector4(0,0,0,1)),d.value[1]=new Oe.Vector4(1,1,1,1));let f;r.steps?f=new Jt(r.steps.length,r.steps):(f=new Jt(2,1),f.value[0]=0);let m=new Y(r.alpha??1),h=new xe(r.mode??0),g=new Pi(o,i,s,a,c,p,l,u,d,f,m),x=new _e(g.calpha,"f");return new ot(t,e,n,{gradientType:o,smooth:i,near:s,far:a,isVector:c,isWorldSpace:p,origin:l,direction:u,colors:d,steps:f,alpha:m,mode:h},g,h,x)}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),a=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)),l=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 xe(r.mode??0),g=new xe(r.noiseType??0),x=new wi(o,i,s,a,c,p,l,u,d,f,m,g),v=new _e(x.calpha,"f");return new ot(t,e,n,{scale:o,size:i,move:s,fA:a,fB:c,distortion:p,colorA:l,colorB:u,colorC:d,colorD:f,alpha:m,mode:h,noiseType:g},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 xe(r.mode??0),a=new Bi(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},a,s,c)}case"gradient":{let o=new xe(r.gradientType??0),i=new so(r.smooth??!1),s;r.colors?s=new er(r.colors.length,r.colors):(s=new er(10,new Oe.Vector4(0,0,0,1)),s.value[1]=new Oe.Vector4(1,1,1,1));let a;r.steps?a=new Jt(r.steps.length,r.steps):(a=new Jt(10,1),a.value[0]=0);let c=new st(r.offset??new Oe.Vector2(0,0)),p=new st(r.morph??new Oe.Vector2(0,0)),l=new Y(r.angle??0),u=new Y(r.alpha??1),d=new xe(r.mode??0),f=new Oi(o,i,s,a,c,p,l,u),m=new _e(f.calpha,"f");return new ot(t,e,n,{gradientType:o,smooth:i,colors:s,steps:a,offset:c,morph:p,angle:l,alpha:u,mode:d},f,d,m)}default:{let o=new Ce(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 a=new xe(0);return o.alpha=i,new ot(t,e,n,{color:o,alpha:i,mode:a},o,a,s)}}}function TS(n,t,e,r){let o=Xf(e,r);return _S(e,n,t,o)}function uc(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 Rt=class extends Na.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??Yt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>_r.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 Tr),this.lightLayer===void 0&&(this.lightLayer=new Tr(0,"",eo.defaultData("light","basic"),new Lo,{})),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=_r.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),a=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,a)}this.layers.reverse(),this.onUpdate(o)}else{let s=this.layers.find(a=>a.uuid===i);if(s){let a=r.layers.data(i);if(s.updateByOp({...e,path:e.path.slice(2)},a,o)){let p=_r.create(this.layerIdGen++,i,a,o);this.layers.splice(this.layers.findIndex(l=>l.uuid===i),1,p),this.onUpdate(o)}}}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof ot),r=this.layers.findIndex(o=>o instanceof Tr);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 Ii(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 Tr);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 Ii(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 Hi);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,a)=>Math.min(Math.max(i,s),a);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.toUpperCase()}",`;else{let o=(ac[r.type]??[]).map(a=>r[a]),i=(lc[r.type]??[]).map(a=>r[a]?.length??0),s=[...o,...i];s.length?e+=`["${r.type}", "${s.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 wa;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>Na.NormalBlending,this}dispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Rt.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 Ft=require("three");function AS(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]}`,a=new Ft.Vector3(r[i],r[i+1],r[i+2]);t.has(s)?t.get(s)?.normals.push(a):t.set(s,{normals:[a],result:new Ft.Vector3})}t.forEach((i,s)=>{for(let a of i.normals)i.result.add(a);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]}`,a=t.get(s)?.result;a&&(o[i]=a.x,o[i+1]=a.y,o[i+2]=a.z)}n.geometry.setAttribute("extrudeNormal",new Ft.Float32BufferAttribute(o,3))}function CS(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 Ft.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 Ft.Float32BufferAttribute(e,3))}function co(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 Rt)||n.material.getLayersOfType("outline").length===0)return;n.objectType==="Mesh2D"?CS(n):AS(n)}}function uo(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=[Ft.MathUtils.seededRandom(r),Ft.MathUtils.seededRandom(r+1e4),Ft.MathUtils.seededRandom(r+2e4)];for(let i=0;i<t.length;i++)e[i]=o[i%3];n.geometry.setAttribute("randomColor",new Ft.BufferAttribute(e,3))}var lt=class extends kt(Pa.Mesh){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Pa.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=fc[r.userData.type],i=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=o.build(o.normalizeInputs(e,i)),a=r.uuid;this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),co(this),r.getAttribute("randomColor")&&uo(this)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=Wi(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&&(tr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),hr(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)mr(e)&&(e.freeBooleanPointer(),hr(e)&&e.invalidateUpstreamBooleanData())}};var NS=new po.Vector3(0,0,1),nm=new po.Vector3,im=new po.Vector3,sm=new po.Matrix3,Bn=class extends lt{constructor(e=xt.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new po.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),sm.getNormalMatrix(this.matrixWorld),nm.copy(NS).applyMatrix3(sm).normalize(),im.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(nm,im)}clone(e){let r=this.shape.clone(),o=this.material,i=this.geometry.userData,s=xt.create(Object.assign({},i,{shape:r})),a=new Bn(s,o).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){lt.prototype.raycast.call(this,e,r)}};function Ia(n,t){return PS(n)}function PS(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 am.BufferGeometryLoader().parse(n));let e;try{e=Wi(t)}catch(r){console.error(r)}if(!e){let r=Ae.createFromState(pn.defaultData(),100,100);t.shape=r,e=Wi(t)}return e}var de;ma.then(n=>{de=n});var lm=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cm=new Uint32Array([0,1,2,3]),um=new Uint8Array([4]),Wt=class{static build(n,t,e,r,o){let i,s,a,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:lm,indexWASM:cm,verticesPerFaceWASM:um},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?a=Wt.buildLevel(i,!1,c):a=null),{subdivPointer:i,originalGeometry:s,subdividedGeometry:a}}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:Ia(n),r,o,i,s;({positions:r,triIndices:s}=yc(e.getAttribute("position"),e.getIndex()));let a;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;a=[c,p]}return{indices:o,verticesPerFace:i}=xc(r,s,e,a),{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=lm,r=cm,o=um);let a=e.length,c=r.length,p=o.length,l=e.length+i.length+s.length,u=r.length+o.length,d=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=l*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,h=de._malloc(d),g=new Float32Array(de.HEAPF32.buffer,h,l),x=new Uint32Array(de.HEAPU32.buffer,h+f,u);g.set(e,0),g.set(i,e.length),g.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 We.Matrix4().makeScale(...n.scaleBaked)),t&&(v?v.premultiply(t):v=t);let A=v?de.alloc_subdivision_surface2(h,a,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p,v.elements):de.alloc_subdivision_surface(h,a,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,a=de.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(4,4+4),p=0,l=de.HEAPU32[a[p]>>2],u=de.HEAPF32.subarray(l>>2,(l>>2)+c[p]);p++;let d=de.HEAPU32[a[p]>>2],f=de.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=de.HEAPU32[a[p]>>2],h=de.HEAPU32.subarray(m>>2,(m>>2)+c[p]);p++;let g=de.HEAPU32[a[p]>>2],x=de.HEAPU32.subarray(g>>2,(g>>2)+c[p]);if(p++,r===void 0){let v=new We.BufferGeometry;if(v.setIndex(new We.Uint32BufferAttribute(x,1)),v.setAttribute("position",new We.Float32BufferAttribute(u,3)),v.setAttribute("normal",new We.Float32BufferAttribute(f,3)),t){v.setAttribute("faceMap",new We.Uint32BufferAttribute(h,1));let A=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new We.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),a=0,c=de.HEAPU32[i[a]>>2],p=de.HEAPF32.subarray(c>>2,(c>>2)+s[a]);a++;let l=de.HEAPU32[i[a]>>2],u=de.HEAPU32.subarray(l>>2,(l>>2)+s[a]);if(t===void 0){let d=new We.BufferGeometry;d.setAttribute("position",new We.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 We.BufferAttribute(f,3)),d.setIndex(new We.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),a=s.subarray(3,3+3),c=0,p=de.HEAPU32[s[c]>>2],l=new Float32Array(de.HEAPF32.subarray(p>>2,(p>>2)+a[c]));c++;let u=de.HEAPU32[s[c]>>2],d=new Uint32Array(de.HEAPU32.subarray(u>>2,(u>>2)+a[c]));c++;let f=de.HEAPU32[s[c]>>2],m=new Uint8Array(de.HEAPU32.subarray(f>>2,(f>>2)+a[c]));return de.free_topological_data(o),{positions:l,indices:d,verticesPerFace:m}}};var pm=["getX","getY","getZ"];function yc(n,t){let e={},r=t?t.count:n.count,o=0,i=[],s=[],a=1e4;for(let p=0;p<r;p++){let l=t?t.getX(p):p,u="";for(let d=0;d<3;d++)u+=`${~~(n[pm[d]](l)*a)},`;if(u in e)i.push(e[u]);else{for(let d=0;d<3;d++)s.push(n[pm[d]](l));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 La=new We.Vector3,mc=new We.Vector3,hc=new We.Vector3,gc=new We.Vector3;function xc(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([]),a=0;for(let p=0;p<s.length;p+=2)a+=(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(a<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,a=e.capStartIndex??t.length;s<a;)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]){La.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),mc.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),hc.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),gc.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),mc.sub(La).normalize(),hc.sub(La).normalize(),gc.sub(La).normalize();let c=mc.cross(hc).dot(gc);Math.abs(c)>.005||r&&r.some((p,l)=>l%2===1?!1:s>=r[l]&&s<r[l+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=[],a=[],c=0,p=new Float32Array([e.userData.parameters.depth])[0];for(let l=0,u=0;l<n.length;l+=3,u++)n[l+2]===0&&(s.push(u),c++),n[l+2]===p&&a.push(u);if(e.userData.parameters.extrudeBevelSize===0){let l=a[0];a[0]=a[1],a[1]=l}s.reverse(),o.push(...s,...a),i.push(c,c)}return{indices:o,verticesPerFace:i}}var tr={};Ic(tr,{calcBoolean:()=>MS,calcBooleanTopological:()=>OS,freeMeshSet:()=>ES,getMeshSet:()=>DS,transformMeshSet:()=>BS});var IS,dm=new Promise(n=>{IS=n});var qi=require("three");var ye,En;dm.then(n=>ye=n);function LS(n,t,e){let r,{positions:o,triIndices:i}=yc(n.getAttribute("position"),n.getIndex()),s;if(t&&e){let{indices:a,verticesPerFace:c}=xc(o,i,n);s=c.length,r=[];for(let p=0,l=0;p<s;p++){r.push(c[p]);for(let u=0;u<c[p];u++)r.push(a[l++])}}else{let a=i.length;r=Array(a+a/3),s=0;for(let c=0,p=0;p<r.length;)r[p++]=3,s++,r[p++]=i[c++],r[p++]=i[c++],r[p++]=i[c++]}return{positions:o,faceIndices:r,nFaces:s}}function fm(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=ye._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(ye.HEAPU32.buffer,i,t):new Float32Array(ye.HEAPF32.buffer,i,t)).set(n,0),i}function mm(n){switch(n){case 0:return ye.OP.UNION;case 1:return ye.OP.INTERSECTION;case 2:return ye.OP.A_MINUS_B;case 3:return ye.OP.B_MINUS_A;case 4:return ye.OP.SYMMETRIC_DIFFERENCE;case 5:return ye.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function OS(n,t){En===void 0&&(En=ye.init_csg());let e=fm(n),r=ye.csg_calc_topological(En,e,n.length,mm(t));ye._free(e);let o=6,i=ye.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(3,3+3),a=0,c=ye.HEAPU32[i[a]>>2],p=new Float32Array(ye.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=ye.HEAPU32[i[a]>>2],u=new Uint32Array(ye.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let d=ye.HEAPU32[i[a]>>2],f=new Uint8Array(ye.HEAPU32.subarray(d>>2,(d>>2)+s[a]));return ye.free_mesh_data(r),{positions:p,indices:u,verticesPerFace:f}}function MS(n,t,e,r){En===void 0&&(En=ye.init_csg());let o=fm(n),i=ye.csg_calc(En,o,n.length,r,mm(t));ye._free(o);let s=5,a=ye.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),p=0,l=ye.HEAPU32[a[p]>>2],u=ye.HEAPF32.subarray(l>>2,(l>>2)+c[p]);p++;let d=ye.HEAPU32[a[p]>>2],f=ye.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=c[p];e.setAttribute("position",new qi.Float32BufferAttribute(u,3)),e.setAttribute("normal",new qi.Float32BufferAttribute(f,3));let h=ye.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new qi.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},ye.free_mesh_data(i),m}function DS(n,t,e){if(ye===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((x,v)=>x+v,0)+i);for(let x=0,v=0,A=0;x<g.verticesPerFace.length;x++){o[A++]=g.verticesPerFace[x];for(let S=0;S<g.verticesPerFace[x];S++)o[A++]=g.indices[v++]}}else({positions:r,faceIndices:o,nFaces:i}=LS(n,t,e));let s=r.length,a=o.length,c=r.length,p=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+p*Uint32Array.BYTES_PER_ELEMENT,u=c*Float32Array.BYTES_PER_ELEMENT,d=p*Uint32Array.BYTES_PER_ELEMENT,f=ye._malloc(l),m=new Float32Array(ye.HEAPF32.buffer,f,c),h=new Uint32Array(ye.HEAPU32.buffer,f+u,p);return m.set(r,0),h.set(o,0),ye.get_csg_mesh(f,s,f+u,a,i)}function BS(n,t){ye.transform_csg_mesh(n,t.elements)}function ES(n){ye.free_csg_mesh(n)}var fc={ConeGeometry:Vd,CubeGeometry:zd,CylinderGeometry:Rd,DodecahedronGeometry:jd,EllipseGeometry:pf,HelixGeometry:hf,IcosahedronGeometry:yf,LatheGeometry:xf,NonParametricGeometry:vf,PolygonGeometry:bf,PyramidGeometry:Sf,RectangleGeometry:wf,SphereGeometry:Tf,PlaneGeometry:Cf,BackdropGeometry:Nf,StarGeometry:Pf,TextFrameGeometry:fa,TorusGeometry:Lf,TorusKnotGeometry:Mf,TriangleGeometry:Df,VectorGeometry:xt},Wi=n=>fc[n.type].create(n);var $i=require("three");var hm=new $i.Matrix4;var Oa=class extends lt{constructor(e=new $i.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,r=!0){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];hr(s)&&s.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(Vf(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.geometry.index&&s.geometry.index.count/3<15e5&&(s.booleanMeshSetAddress=tr.getMeshSet(s.geometry,e===!0,r)),s.booleanMeshSetAddress===-1)return;tr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else hr(s)&&s.needsTransformForDownstream===!0?(tr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(hm.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),tr.transformMeshSet(s.booleanMeshSetAddress,hm),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return tr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new $i.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=tr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,co(this),uo(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 gm=require("three"),Ar=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new gm.BoxBufferGeometry(30,30,30),t};var pt=require("three");var mt=require("three"),Ma=new mt.Ray,vc=new mt.Sphere,ym=new mt.Matrix4,Cr=(n,t,e,r,o=!1)=>{let i=t,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),vc.copy(i.boundingSphere),vc.applyMatrix4(s),e.ray.intersectsSphere(vc)===!1||(ym.copy(s).invert(),Ma.copy(e.ray).applyMatrix4(ym),i.boundingBox!==null&&Ma.intersectsBox(i.boundingBox)===!1))return;let a,c,p,l,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),l=u.getX(m+2),a=g(n,e,Ma,d,c,p,l),a){a.faceIndex=Math.floor(m/3),r.push(a);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,I=Math.max(0,f.start),C=Math.min(v.count,f.start+f.count);for(let N=I,k=C-1;N<k;N+=w){if(A.fromBufferAttribute(v,N),S.fromBufferAttribute(v,N+1),Ma.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 g(x,v,A,S,b,D,w){let y=new mt.Vector3,L=new mt.Vector3,T=new mt.Vector3,I=new mt.Vector3,C=new mt.Vector3;if(y.fromBufferAttribute(S,b),L.fromBufferAttribute(S,D),T.fromBufferAttribute(S,w),A.intersectTriangle(y,L,T,!1,I)===null)return null;C.copy(I),C.applyMatrix4(x.matrixWorld);let k=v.ray.origin.distanceTo(C);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:C.clone(),object:x}}};var Da=new pt.Vector3,qt=new pt.Camera,bc=class extends pt.LineSegments{constructor(e){let r=new pt.BufferGeometry,o=new pt.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={},c=new pt.Color(15711266),p=new pt.Color(15711266),l=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",l),u("u2","u3",l),u("u3","u1",l);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),a[f]===void 0&&(a[f]=[]),a[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=a,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,a=o?.8:1e-4;rr("n1",r,e,qt,-i,-s,a),rr("n2",r,e,qt,i,-s,a),rr("n3",r,e,qt,-i,s,a),rr("n4",r,e,qt,i,s,a);let c=a;rr("f1",r,e,qt,-i,-s,c),rr("f2",r,e,qt,i,-s,c),rr("f3",r,e,qt,-i,s,c),rr("f4",r,e,qt,i,s,c);let p=c,l=.5;rr("u1",r,e,qt,i*.7*l,s*1.1,p),rr("u2",r,e,qt,-i*.7*l,s*1.1,p),rr("u3",r,e,qt,0,s*(1.1+.9*l),p),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function rr(n,t,e,r,o,i,s){Da.set(o,i,s).unproject(r);let a=t[n];if(a!==void 0){let c=e.getAttribute("position");for(let p=0,l=a.length;p<l;p++)c.setXYZ(a[p],Da.x,Da.y,Da.z)}}var Ba=class extends Ar(bc){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){Cr(this.object,this.geometry,e,r,!0)}};var xm=require("three");var Gn=class extends Ar(xm.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){Cr(this.object,Gn.geometryHelper,e,r)}};var vm=require("three");var Rn=class extends Ar(vm.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){Cr(this.object,Rn.geometryHelper,e,r)}update(){}};var bm=require("three");var Fn=class extends Ar(bm.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Cr(this.object,Fn.geometryHelper,e,r)}};var Ga=require("three");var Ea=class extends Ar(Ga.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Cr(this.object,Ea.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Ea._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,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Xi=Ea;Xi._vector=new Ga.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=Ke(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 Vn=new Ge.Vector3,Sc=new Ge.Vector3,zr=class extends Nr(kt(Ge.Camera),Ba){constructor(e=window.innerWidth,r=window.innerHeight,o=45,i,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.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 zr().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(Vn),this.targetOffset=Vn.distanceTo(e)}getTarget(e=new Ge.Vector3){return this.getWorldDirection(Sc),this.getWorldPosition(Vn),Sc.multiplyScalar(this.targetOffset),e.copy(Vn).add(Sc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Vn),Vn.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,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,s,a):this.orthoCamera.setViewOffset(e,r,o,i,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(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 nn(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),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom)),e.type==="PerspectiveCamera"?(this.zoom=this.perspCamera.zoom,this.fov=this.perspCamera.fov,this.near=this.perspCamera.near):(this.near=this.orthoCamera.near,this.zoom=this.orthoCamera.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 Sm=require("three");var Mo=class extends Nr(kt(Sm.Group),Rn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new Mo().fromState(r);return o.uuid=e,o.objectHelper.update(),o}};var Do=require("three");var zn=class extends Nr(kt(Do.DirectionalLight),Gn){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 Do.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new zn().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 Do.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Do.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Do.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&&Gf(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 Un=class extends Nr(kt(ht.PointLight),Fn){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),a=new ht.Box3(i,s),c=new ht.Box3Helper(a,new ht.Color(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,r,o){let i=new Un().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 Ot=require("three");var wm=new Ot.Vector3,_m=new Ot.Vector3,Tm=new Ot.Quaternion,jn=class extends Nr(kt(Ot.SpotLight),Xi){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=Ot.MathUtils.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let i=new Ot.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new jn().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 Ot.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Ot.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Ot.CameraHelper&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),_m.setFromMatrixPosition(this.matrixWorld),Tm.setFromRotationMatrix(this.matrixWorld),wm.copy(this.up).applyQuaternion(Tm).negate().multiplyScalar(this.distance),this.target.position.copy(_m).add(wm),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 Am=n=>n.tagName==="VIDEO",kn=class{static resize(t,e,r){let o=t/e,i;if(!r.image)return;let s=r.image;Am(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];om(s)&&kn.resizeTextureLayer(t,e,s.uniforms[`f${s.id}_texture`].value)}}static resizeComplex(t,e,r,o){let i=t/e,s,a=r.image;Am(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.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 Ra=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&&kn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Hn=class extends lt{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var Fa=class extends Hn{constructor(e,r){super(e,r);this.objectType="NonParametric"}};var $t=require("three"),Cm=require("three/examples/jsm/loaders/FontLoader.js"),qe=class extends $t.Mesh{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:i,fontSize:s,LOD:a=16},c=new $t.MeshBasicMaterial({color:0,opacity:1,visible:!0,transparent:!0,side:$t.DoubleSide})){let p=qe.loadChar(e,o,a);super(p.geometry,c);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=i,this.fontSize=s,this.LOD=a,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 qe._fontPath}static set FONTS_PATH(e){qe._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=qe.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=qe.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=qe.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 qe(e).copy(this)}static loadFont(e){return new Promise(function(r,o){qe.fontCache[e]?r(qe.fontCache[e]):new Cm.FontLoader().load(qe.FONTS_PATH+e+".json",s=>{qe.fontCache[e]=s,r(s)},void 0,o)})}static loadChar(e,r,o){if(qe.charCache[e]){if(qe.charCache[e][o]&&qe.charCache[e][o].fontFamily===r)return qe.charCache[e][o]}else qe.charCache[e]={};let i=qe.fontCache[r],s=i.generateShapes(e,1);return qe.charCache[e][o]={geometry:new $t.ShapeBufferGeometry(s,o),fontFamily:r,resolution:i.data.resolution,glyphsHa:i.data.glyphs[e].ha},qe.charCache[e][o]}},or=qe;or.charCache={},or.fontCache={},or._fontPath="/_assets/_fonts/";var Pr=require("three");var wc=require("three"),Va=new wc.Vector2,Bo=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new wc.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){Va.set(e,r);let o=this.message.length;for(let i=0;i<o;i++)this.message[i].updatePosition(this.message[i].localPosition.add(Va),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 a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=i),Va.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(Va),e)}clone(){let t=new Bo(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 _c=class extends lt{constructor(e){super(e,new Pr.MeshBasicMaterial({transparent:!0,opacity:1,visible:!1,side:Pr.DoubleSide}));this.objectType="TextFrame";this.charContainer=new Pr.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 Pr.Vector3(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let i=fa.create({parameters:{width:r.width,height:r.height}}),s=new _c(i).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await or.loadFont(o),r.text=e;let i=r.textOrigin,s=new Pr.MeshBasicMaterial({visible:r.visible,transparent:!0,side:Pr.DoubleSide}),a=e.split(`
|
|
1333
|
-
`),c=0;this.userData.textFrame.textLines=a.map((p,l)=>{let u=new Bo(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 or(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,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof or&&(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,a=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=a,p.textOrigin.set(-.5*a,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):a!==i&&(i<a?this.checkCapacity():i>a&&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 a=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?a.unshift(i[s].getWord(i[s].message.length-1,-1)):a.unshift(i[s].popChar());if(a.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<a.length;p+=1)for(let l=0;l<a[p].length;l+=1)i[s+1].addChar3D(a[p][l],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 a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let c,p=s[a-1].spaceLeft(i);if(s[a].wordSize(0,1)<=p){s[a].containSpace()?c=s[a].getWord(0,1):c=s[a].popChar(0);for(let l=0;l<c.length;l+=1)c[l]&&s[a-1].addChar3D(c[l],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new Bo(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<i.length;a++)i[a].updateYLinePos(this.getNewLinePosition(a)),i[a].fullUpdate(o.textOrigin),i[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].material;c.visible=e}}}async updateFontFamily(e){await or.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)a[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 a=0;a<i.length;a++)i[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await or.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[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 a=0;a<s.length;a++)s[a].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=Ke(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}},Eo=_c;Eo.VerticalAlign=xl,Eo.HorizontalAlign=yl,Eo.TextTransform=vl;var Go=class extends Rt{};var Lm=Oc(Nm());var Pm=new Map;function Im(n){if(typeof n=="string")return n;let t=Pm.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Pm.set(n,t)),t.url}var Wn=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:Im(t),format:"wav"},this.sound=new Lm.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 Ki=class{constructor(t,e={}){this.deletedMaterial=new Go(Yt.defaultTwoLayerData("basic"),this);this.deletedImage=new Oo(oa.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 Go(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 Rt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new Oo(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 Dn(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 ao(e.r,e.g,e.b,e.a):this.colors[t]=new ao(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 Wn)return e;{let r=new Wn({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 Wn&&e.dispose()}),this.audios={}}},GU=new Ki(ra.emptyData());var Om=require("three/examples/jsm/loaders/DRACOLoader.js");var fo;function RS(){return fo||(fo=new Om.DRACOLoader,fo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fo.decoderPending}async function FS(n){if(fo){let t={attributeIDs:fo.defaultAttributeIDs,attributeTypes:fo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await fo.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 Mm(n,t){let[e,r]=tl($s.deserialize(new Uint8Array(n)));Bd(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 RS();for(let i of o){let s=await FS(Xt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:p,itemSize:l})=>{a[c]={array:p,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var Ir=require("three");var bt=require("three");var Gm=Oc(Bm());var Tc;ma.then(n=>{Tc=n});var Rm=new bt.Matrix4,VS=new bt.Matrix4,zS=new bt.Matrix4,nr=new bt.Box3,mo=new bt.Vector3,US=new bt.Matrix4,jS=new bt.Matrix4,qn=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:a}=Wt.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new qn(i,s,a||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,co(this),uo(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,Gm.SVD)(r),a=Rm.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=VS.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=zS.copy(c).transpose();this.shearScale=US.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=jS.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,p),s.every(l=>Math.abs(s[0]-l)<.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;nr.setFromBufferAttribute(r),nr.getCenter(o),e.boundingSphere.radius=o.distanceTo(nr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nr.getSize(mo);let i={width:mo.x,height:mo.y,depth:mo.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;nr.min.set(e[0],e[2],e[4]),nr.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(nr.min.applyMatrix4(this.shearScaleInv),nr.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new bt.Sphere);let o=r.boundingSphere.center;nr.getCenter(o),r.boundingSphere.radius=o.distanceTo(nr.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nr.getSize(mo);let i={width:mo.x,height:mo.y,depth:mo.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(Tc.free_bvh(this.subdivPointer),Tc.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,Em(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Em(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 Em(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Rm.makeScale(t,e,r).invert().elements,a,c,p;for(var l=0,u=o.length;l<u;l+=3)o[l]*=t,o[l+1]*=e,o[l+2]*=r,a=i[l],c=i[l+1],p=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*p,i[l+1]=s[1]*a+s[5]*c+s[9]*p,i[l+2]=s[2]*a+s[6]*c+s[10]*p}var ho=require("three");function Fm(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=ho.FrontSide:t.side===1?n.side=ho.BackSide:n.side=ho.DoubleSide)}function kS(n,t){if(Array.isArray(n.material))for(let e of n.material)Fm(e,t);else{let e=n.material;Fm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Vm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=qn.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new ho.BufferGeometry:Ia(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Zs.is2DParametricMesh(o.userData.type)?r=new Ra(o,i):o?.userData.type==="VectorGeometry"?r=new Bn(o,i):t.geometry.type==="NonParametricGeometry"?r=new Fa(o,i):t.geometry.type==="BooleanGeometry"?(r=new Oa(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new Hn(o,i),r.uuid=n,r.fromState(t,e)}return kS(r,t),r}function zm(n,t,e){return t.type==="Mesh"?Vm(n,t,e):t.type==="TextFrame"?Eo.createFromState(n,t,e):t.type==="Empty"?Mo.createFromState(n,t):t.type==="PointLight"?Un.createFromState(n,t,e):t.type==="SpotLight"?jn.createFromState(n,t,e):t.type==="DirectionalLight"?zn.createFromState(n,t,e):sn.is(t.type)?zr.createFromState(n,t):(console.error(t),new Mo)}var Ur=require("three");function Um(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,uo(n),co(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function jm(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 km(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ur.Mesh&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Um(e,e.material[r])&&(t=!0);else Um(e,e.material)&&(t=!0)}),t}function Hm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ur.Mesh)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)jm(e,e.material[r])&&(t=!0);else jm(e,e.material)&&(t=!0)}),t}function Wm(n){"material"in n&&WS(n.material),"geometry"in n&&n.geometry.dispose()}function WS(n){Mc(n).forEach(t=>{t instanceof Go||t.dispose()})}var qS=new Ur.Raycaster,$S=new Ur.Matrix4,XS=new Ur.Ray;function qm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=$S.copy(o.matrixWorld).invert(),s=XS.copy(t.ray).applyMatrix4(i),a=n.matrixWorld;s.applyMatrix4(a);let c=qS;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 $m=new Ir.Vector3,Ac=class extends ya(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=Hm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=km(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(Ke(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 zr&&this.switchActiveCamera(o)}this.traverse(o=>{hr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Wm(e)});for(let e of this.children)xr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=zr.createFromState(Ac.PERSONAL_CAMERA_ID,{...ea.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)xr(s)&&!s.raycastLock&&s.visible&&((mr(s)||ha(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),qm(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)xr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)xr(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=Ke(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Ef(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ke(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 a=zm(e,r,s);return a&&(this.entityByUuid[e]=a,i.add(a),hr(i)&&mr(a)&&(a.prevBooleanObjectParent=i),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],p=this.find(a),l=c?p.recursiveBBox:p.singleBBox;r.push(...l.vertices)}let o=new Ir.Box3;return o.setFromPoints(r),o.getCenter($m),$m}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 Rt&&e(r.material[o]);else r.material instanceof Rt&&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})})}},Qi=Ac;Qi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var YS=require("three"),KS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Xm(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 Zi=require("three");function Ym(n){let t=new Set;return n.traverse(e=>{if(mr(e))if(Fe(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(QS(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Zi.Color,specularColor:new Zi.Color});let o=0;e.onBeforeCompile=(i,s)=>{r&&r(i,s),i.uniforms=Object.assign(Zi.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else ZS(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function QS(n){return n.getLayersOfType("transmission").length>0}function ZS(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 Km(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Qm(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(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}var Zm=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Jm(n){let t=[];return n.traverse(e=>{e instanceof No&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(a=>{a.updateMatrix();let c=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Xm(c),c}),s=(0,Zm.mergeBufferGeometries)(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function eh(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function th(n){Object.values(n.shared.materials).forEach(t=>{Cc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Cc(e.material):"materials"in e&&e.materials.forEach(r=>{Cc(r)})})}function Cc(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 rh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ja=class extends ka.Loader{load(t,e,r,o=console.error){let i=new ka.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(rh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(rh),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await Mm(t,th),r=new Ki(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Qi(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&&Bf(s)&&Object.assign(s,{makeDefault:!0})}return o=Jm(o),o=Ym(o),o=Km(o),o=Qm(o),o=eh(o),o}};
|
|
1333
|
+
`),c=0;this.userData.textFrame.textLines=a.map((p,l)=>{let u=new Bo(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 or(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,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof or&&(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,a=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=a,p.textOrigin.set(-.5*a,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):a!==i&&(i<a?this.checkCapacity():i>a&&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 a=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?a.unshift(i[s].getWord(i[s].message.length-1,-1)):a.unshift(i[s].popChar());if(a.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<a.length;p+=1)for(let l=0;l<a[p].length;l+=1)i[s+1].addChar3D(a[p][l],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 a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let c,p=s[a-1].spaceLeft(i);if(s[a].wordSize(0,1)<=p){s[a].containSpace()?c=s[a].getWord(0,1):c=s[a].popChar(0);for(let l=0;l<c.length;l+=1)c[l]&&s[a-1].addChar3D(c[l],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new Bo(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<i.length;a++)i[a].updateYLinePos(this.getNewLinePosition(a)),i[a].fullUpdate(o.textOrigin),i[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].material;c.visible=e}}}async updateFontFamily(e){await or.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)a[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 a=0;a<i.length;a++)i[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await or.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[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 a=0;a<s.length;a++)s[a].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=Ke(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}},Eo=_c;Eo.VerticalAlign=xl,Eo.HorizontalAlign=yl,Eo.TextTransform=vl;var Go=class extends Rt{};var Lm=Oc(Nm());var Pm=new Map;function Im(n){if(typeof n=="string")return n;let t=Pm.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Pm.set(n,t)),t.url}var Wn=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:Im(t),format:"wav"},this.sound=new Lm.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 Ki=class{constructor(t,e={}){this.deletedMaterial=new Go(Yt.defaultTwoLayerData("basic"),this);this.deletedImage=new Oo(oa.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 Go(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 Rt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new Oo(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 Dn(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 ao(e.r,e.g,e.b,e.a):this.colors[t]=new ao(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 Wn)return e;{let r=new Wn({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 Wn&&e.dispose()}),this.audios={}}},GU=new Ki(ra.emptyData());var Om=require("three/examples/jsm/loaders/DRACOLoader.js");var fo;function RS(){return fo||(fo=new Om.DRACOLoader,fo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),fo.decoderPending}async function FS(n){if(fo){let t={attributeIDs:fo.defaultAttributeIDs,attributeTypes:fo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await fo.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 Mm(n,t){let[e,r]=tl($s.deserialize(new Uint8Array(n)));Bd(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 RS();for(let i of o){let s=await FS(Xt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:p,itemSize:l})=>{a[c]={array:p,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var Ir=require("three");var bt=require("three");var Gm=Oc(Bm());var Tc;ma.then(n=>{Tc=n});var Rm=new bt.Matrix4,VS=new bt.Matrix4,zS=new bt.Matrix4,nr=new bt.Box3,mo=new bt.Vector3,US=new bt.Matrix4,jS=new bt.Matrix4,qn=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:a}=Wt.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new qn(i,s,a||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,co(this),uo(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,Gm.SVD)(r),a=Rm.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=VS.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=zS.copy(c).transpose();this.shearScale=US.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=jS.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,p),s.every(l=>Math.abs(s[0]-l)<.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;nr.setFromBufferAttribute(r),nr.getCenter(o),e.boundingSphere.radius=o.distanceTo(nr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nr.getSize(mo);let i={width:mo.x,height:mo.y,depth:mo.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;nr.min.set(e[0],e[2],e[4]),nr.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(nr.min.applyMatrix4(this.shearScaleInv),nr.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new bt.Sphere);let o=r.boundingSphere.center;nr.getCenter(o),r.boundingSphere.radius=o.distanceTo(nr.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nr.getSize(mo);let i={width:mo.x,height:mo.y,depth:mo.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(Tc.free_bvh(this.subdivPointer),Tc.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,Em(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Em(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 Em(n,t,e,r){let o=n.position.array,i=n.normal.array,s=Rm.makeScale(t,e,r).invert().elements,a,c,p;for(var l=0,u=o.length;l<u;l+=3)o[l]*=t,o[l+1]*=e,o[l+2]*=r,a=i[l],c=i[l+1],p=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*p,i[l+1]=s[1]*a+s[5]*c+s[9]*p,i[l+2]=s[2]*a+s[6]*c+s[10]*p}var ho=require("three");function Fm(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=ho.FrontSide:t.side===1?n.side=ho.BackSide:n.side=ho.DoubleSide)}function kS(n,t){if(Array.isArray(n.material))for(let e of n.material)Fm(e,t);else{let e=n.material;Fm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Vm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=qn.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new ho.BufferGeometry:Ia(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Zs.is2DParametricMesh(o.userData.type)?r=new Ra(o,i):o?.userData.type==="VectorGeometry"?r=new Bn(o,i):t.geometry.type==="NonParametricGeometry"?r=new Fa(o,i):t.geometry.type==="BooleanGeometry"?(r=new Oa(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new Hn(o,i),r.uuid=n,r.fromState(t,e)}return kS(r,t),r}function zm(n,t,e){return t.type==="Mesh"?Vm(n,t,e):t.type==="TextFrame"?Eo.createFromState(n,t,e):t.type==="Empty"?Mo.createFromState(n,t):t.type==="PointLight"?Un.createFromState(n,t,e):t.type==="SpotLight"?jn.createFromState(n,t,e):t.type==="DirectionalLight"?zn.createFromState(n,t,e):sn.is(t.type)?zr.createFromState(n,t):(console.error(t),new Mo)}var Ur=require("three");function Um(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,uo(n),co(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function jm(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 km(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ur.Mesh&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Um(e,e.material[r])&&(t=!0);else Um(e,e.material)&&(t=!0)}),t}function Hm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ur.Mesh)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)jm(e,e.material[r])&&(t=!0);else jm(e,e.material)&&(t=!0)}),t}function Wm(n){"material"in n&&WS(n.material),"geometry"in n&&n.geometry.dispose()}function WS(n){Mc(n).forEach(t=>{t instanceof Go||t.dispose()})}var qS=new Ur.Raycaster,$S=new Ur.Matrix4,XS=new Ur.Ray;function qm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=$S.copy(o.matrixWorld).invert(),s=XS.copy(t.ray).applyMatrix4(i),a=n.matrixWorld;s.applyMatrix4(a);let c=qS;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 $m=new Ir.Vector3,Ac=class extends ya(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=Hm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=km(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(Ke(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 zr&&this.switchActiveCamera(o)}this.traverse(o=>{hr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Wm(e)});for(let e of this.children)xr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=zr.createFromState(Ac.PERSONAL_CAMERA_ID,{...ea.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)xr(s)&&!s.raycastLock&&s.visible&&((mr(s)||ha(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,r),qm(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)xr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)xr(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=Ke(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Ef(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ke(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 a=zm(e,r,s);return a&&(this.entityByUuid[e]=a,i.add(a),hr(i)&&mr(a)&&(a.prevBooleanObjectParent=i),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],p=this.find(a),l=c?p.recursiveBBox:p.singleBBox;r.push(...l.vertices)}let o=new Ir.Box3;return o.setFromPoints(r),o.getCenter($m),$m}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 Rt&&e(r.material[o]);else r.material instanceof Rt&&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})})}},Qi=Ac;Qi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var YS=require("three"),KS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Xm(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 Zi=require("three");function Ym(n){let t=new Set;return n.traverse(e=>{if(mr(e))if(Fe(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(QS(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Zi.Color,specularColor:new Zi.Color});let o=0;e.onBeforeCompile=(i,s)=>{r&&r(i,s),i.uniforms=Object.assign({},Zi.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else ZS(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function QS(n){return n.getLayersOfType("transmission").length>0}function ZS(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 Km(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function Qm(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(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}var Zm=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Jm(n){let t=[];return n.traverse(e=>{e instanceof No&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(a=>{a.updateMatrix();let c=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Xm(c),c}),s=(0,Zm.mergeBufferGeometries)(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function eh(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function th(n){Object.values(n.shared.materials).forEach(t=>{Cc(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Cc(e.material):"materials"in e&&e.materials.forEach(r=>{Cc(r)})})}function Cc(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 rh="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ja=class extends ka.Loader{load(t,e,r,o=console.error){let i=new ka.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(rh+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(rh),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await Mm(t,th),r=new Ki(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Qi(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&&Bf(s)&&Object.assign(s,{makeDefault:!0})}return o=Jm(o),o=Ym(o),o=Km(o),o=Qm(o),o=eh(o),o}};
|
package/build/SplineLoader.js
CHANGED
|
@@ -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 Vw}from"three";function nm(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var ca=class extends dn{constructor(e,r){super(new Vw);this.repeat=e;this.offset=r;nm(this.value,e,r)}updateMatrix(){nm(this.value,this.repeat,this.offset)}};var ur=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)rc(i,this,r)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return pr.createLigherLayer(t,e,r,o);if(r.type==="texture"){let i=o.image(r.texture.image),s=new Ci(i,r.texture.wrapping),a=new la(i),c=new ca(r.texture.repeat,r.texture.offset),p=new Y(r.crop?1:0),l=new ge(r.projection??0),u=new ge(["x","y","z"].indexOf(r.axis)??0),d=new ge(r.side??0),f=new Ye(r.size?new mo(r.size[0],r.size[1]):new mo(100,100)),m=new Y(r.alpha??1),h=new ge(r.mode??0),g=new yi(s,a,p,l,u,d,f,c,m,h),x=new ve(g.calpha,"f");return new We(t,e,r,{texture:s,textureSize:a,crop:p,projection:l,axis:u,side:d,size:f,mat:c,alpha:m,mode:h},g,h,x)}else if(r.type==="matcap"){let i=o.image(r.texture.image),s=new Ci(i,r.texture.wrapping),a=new Y(r.alpha??1),c=new ge(r.mode??0),p=new Ai(s,a,c),l=new ve(p.calpha,"f");return new We(t,e,r,{texture:s,alpha:a,mode:c},p,c,l)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Ze(new cr(...r.offset)),s=new Y(r.scale??10),a=new Y(r.intensity??8),c=new Y(r.movement??1),p=new ge(r.noiseType??0),l=new hi(a,c,i,s,p);return new Pi(t,e,r,{offset:i,scale:s,intensity:a,movement:c,noiseType:p},l)}else throw new Error;else return Uw(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:om(o.props,r,this,e)}else if(o.path[0]==="texture")return"texture"in e?tc(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 ur{constructor(e,r,o,i,s,a,c){super(e,r,o,i);this.color=s;this.mode=a;this.alpha=c}},Pi=class extends ur{constructor(e,r,o,i,s){super(e,r,o,i);this.position=s}},pr=class extends ur{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,a=new Y(o.alpha),c=new ge(o.mode),p;if(o.category==="lambert"){s=new bi;let l=new we(i.color(o.emissive)??0);p={emissive:l},s.emissive=l}else if(o.category==="phong"){s=new sa;let l=new Y(o.shininess??30),u=new we(i.color(o.specular)??1118481);p={shininess:l,specular:u},s.shininess=l,s.specular=u}else if(o.category==="toon"){s=new wi;let l=new Y(o.shininess??30),u=new we(i.color(o.specular)??1118481);p={shininess:l,specular:u},s.shininess=l,s.specular=u}else if(o.category==="physical"){s=new Si;let l=new Y(o.roughness??.3),u=new Y(o.metalness??0),d=new Y(o.reflectivity??.5);p={roughness:l,metalness:u,reflectivity:d},s.roughness=l,s.metalness=u,s.reflectivity=d}else s=new po,p={};return s.alpha=new Y(1),s.shadingAlpha=a,s.shadingBlend=c,p.alpha=s.shadingAlpha,p.mode=s.shadingBlend,new pr(e,r,o,s,p)}};function im(n){let t=n instanceof ur?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}function zw(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 a=new ge(r.mode??0);return o.alpha=i,new We(t,e,n,{color:o,alpha:i,mode:a},o,a,s)}case"fresnel":{let o=new we(r.color??16777215),i=new Y(r.bias??.1),s=new Y(r.scale??1),a=new Y(r.intensity??2),c=new Y(r.factor??1),p=new Y(r.alpha??1),l=new ge(r.mode??0),u=new ci(o,i,s,a,c,p,l),d=new ve(u.calpha,"f");return new We(t,e,n,{color:o,bias:i,scale:s,intensity:a,factor:c,alpha:p,mode:l},u,l,d)}case"rainbow":{let o=new Y(r.filmThickness??30),i=new Y(r.movement??0),s=new Ze(r.wavelengths??new cr(0,0,0)),a=new Y(r.noiseStrength??0),c=new Y(r.noiseScale??1),p=new Ze(r.offset??new cr(0,0,0)),l=new Y(r.alpha??1),u=new ui(o,i,s,a,c,p,l),d=new ve(u.calpha,"f"),f=new ge(r.mode??0);return new We(t,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:a,noiseScale:c,offset:p,alpha:l,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),a=Je.transmissionSize,c=Je.transmissionRenderTarget,p=Je.transmissionRenderTargetDepth,l=window.innerWidth,u=window.innerHeight,d=l>=u?new Ye(u/l,1):new Ye(1,l/u),f=new Y(r.alpha??1),m=new di(o,i,s,a,c,p,d,f),h=new ve(m.calpha,"f"),g=new ge(r.mode??0);return new We(t,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:d,alpha:f,mode:g},m,g,h)}case"toon":{let o=new ge(r.positioning??0),i;r.colors?i=new Vt(r.colors.length,r.colors):(i=new Vt(10,new gn(0,0,0,1)),i.value[1]=new gn(1,1,1,1));let s;r.steps?s=new Ft(r.steps.length,r.steps):(s=new Ft(10,1),s.value[0]=0);let a=new Ze(r.source??new cr(0,0,0)),c=new qr(r.isWorldSpace??!0),p=new Y(r.noiseStrength??0),l=new Y(r.noiseScale??1),u=new Lt(r.shadowColor),d=new Ze(r.offset??new cr(0,0,0)),f=new Y(r.alpha??1),m=new Ni(o,i,s,a,c,p,l,u,d,f),h=new ve(m.calpha,"f"),g=new ge(r.mode??0);return new We(t,e,n,{positioning:o,colors:i,steps:s,source:a,isWorldSpace:c,noiseStrength:p,noiseScale:l,shadowColor:u,offset:d,alpha:f,mode:g},m,g,h)}case"outline":{let o=new we(r.outlineColor??16777215),i=new we(r.contourColor??16777215),s=new Y(r.outlineWidth??.1),a=new Y(r.contourWidth??.1),c=new Y(r.outlineThreshold??.1),p=new Y(r.contourThreshold??.1),l=new Y(r.outlineSmoothing??.1),u=new Y(r.contourFrequency??.1),d=new Ze(r.contourDirections??new cr(0,1,0)),f=new qr(r.positionalLines??!1),m=new qr(r.compensation??!0),h=Je.normalRenderTarget,g=Je.normalRenderTargetDepth,x=Je.pixelRatioNode,v=Je.resolution,A=new Y(r.alpha??1),S=new pi(o,i,s,a,c,p,l,u,d,f,m,v,h,g,x,A),b=new ve(S.calpha,"f"),D=new ge(r.mode??0);return new We(t,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:a,outlineThreshold:c,contourThreshold:p,outlineSmoothing:l,contourFrequency:u,contourDirection:d,positionalLines:f,compensation:m,alpha:A,mode:D},S,D,b)}case"depth":{let o=new ge(r.gradientType??0),i=new qr(r.smooth??!1),s=new Y(r.near??50),a=new Y(r.far??200),c=new Y(r.isVector??1),p=new Y(r.isWorldSpace??0),l=new Ze(r.origin??new cr),u=new Ze(r.direction??new cr),d;r.colors?d=new Vt(r.colors.length,r.colors):(d=new Vt(2,new gn(0,0,0,1)),d.value[1]=new gn(1,1,1,1));let f;r.steps?f=new Ft(r.steps.length,r.steps):(f=new Ft(2,1),f.value[0]=0);let m=new Y(r.alpha??1),h=new ge(r.mode??0),g=new fi(o,i,s,a,c,p,l,u,d,f,m),x=new ve(g.calpha,"f");return new We(t,e,n,{gradientType:o,smooth:i,near:s,far:a,isVector:c,isWorldSpace:p,origin:l,direction:u,colors:d,steps:f,alpha:m,mode:h},g,h,x)}case"noise":{let o=new Y(r.scale??1),i=new Ze(r.size??new cr(100,100,100)),s=new Y(r.move??1),a=new Ye(r.fA??new mo(1.7,9.2)),c=new Ye(r.fB??new mo(8.3,2.8)),p=new Ye(r.distortion??new mo(1,1)),l=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 ge(r.mode??0),g=new ge(r.noiseType??0),x=new li(o,i,s,a,c,p,l,u,d,f,m,g),v=new ve(x.calpha,"f");return new We(t,e,n,{scale:o,size:i,move:s,fA:a,fB:c,distortion:p,colorA:l,colorB:u,colorC:d,colorD:f,alpha:m,mode:h,noiseType:g},x,h,v)}case"normal":{let o=new Ze(r.cnormal??new cr(1,1,1)),i=new Y(r.alpha??1),s=new ge(r.mode??0),a=new vi(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},a,s,c)}case"gradient":{let o=new ge(r.gradientType??0),i=new qr(r.smooth??!1),s;r.colors?s=new Vt(r.colors.length,r.colors):(s=new Vt(10,new gn(0,0,0,1)),s.value[1]=new gn(1,1,1,1));let a;r.steps?a=new Ft(r.steps.length,r.steps):(a=new Ft(10,1),a.value[0]=0);let c=new Ye(r.offset??new mo(0,0)),p=new Ye(r.morph??new mo(0,0)),l=new Y(r.angle??0),u=new Y(r.alpha??1),d=new ge(r.mode??0),f=new gi(o,i,s,a,c,p,l,u),m=new ve(f.calpha,"f");return new We(t,e,n,{gradientType:o,smooth:i,colors:s,steps:a,offset:c,morph:p,angle:l,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 a=new ge(0);return o.alpha=i,new We(t,e,n,{color:o,alpha:i,mode:a},o,a,s)}}}function Uw(n,t,e,r){let o=em(e,r);return zw(e,n,t,o)}function rc(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 wt=class extends kw{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??Bt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>ur.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 pr),this.lightLayer===void 0&&(this.lightLayer=new pr(0,"",zr.defaultData("light","basic"),new po,{})),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=ur.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),a=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,a)}this.layers.reverse(),this.onUpdate(o)}else{let s=this.layers.find(a=>a.uuid===i);if(s){let a=r.layers.data(i);if(s.updateByOp({...e,path:e.path.slice(2)},a,o)){let p=ur.create(this.layerIdGen++,i,a,o);this.layers.splice(this.layers.findIndex(l=>l.uuid===i),1,p),this.onUpdate(o)}}}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof We),r=this.layers.findIndex(o=>o instanceof pr);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 mi(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 pr);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 mi(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 Pi);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new ht(r,e[o].position,ht.ADD),r=new ht(r,new Y(.5).setReadonly(!0),ht.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,a)=>Math.min(Math.max(i,s),a);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.toUpperCase()}",`;else{let o=(Jl[r.type]??[]).map(a=>r[a]),i=(ec[r.type]??[]).map(a=>r[a]?.length??0),s=[...o,...i];s.length?e+=`["${r.type}", "${s.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 ia;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>jw,this}dispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(wt.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 ic,BufferAttribute as Hw,Vector3 as sc,Float32BufferAttribute as sm}from"three";function Ww(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]}`,a=new sc(r[i],r[i+1],r[i+2]);t.has(s)?t.get(s)?.normals.push(a):t.set(s,{normals:[a],result:new sc})}t.forEach((i,s)=>{for(let a of i.normals)i.result.add(a);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]}`,a=t.get(s)?.result;a&&(o[i]=a.x,o[i+1]=a.y,o[i+2]=a.z)}n.geometry.setAttribute("extrudeNormal",new sm(o,3))}function qw(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 sc;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 sm(e,3))}function Yr(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 wt)||n.material.getLayersOfType("outline").length===0)return;n.objectType==="Mesh2D"?qw(n):Ww(n)}}function Kr(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=[ic.seededRandom(r),ic.seededRandom(r+1e4),ic.seededRandom(r+2e4)];for(let i=0;i<t.length;i++)e[i]=o[i%3];n.geometry.setAttribute("randomColor",new Hw(e,3))}var Qe=class extends It($w){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Xw;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)),a=r.uuid;this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),Yr(this),r.getAttribute("randomColor")&&Kr(this)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=Ii(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 lo(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new lo(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&&(zt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),tr(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)er(e)&&(e.freeBooleanPointer(),tr(e)&&e.invalidateUpstreamBooleanData())}};var Qw=new lc(0,0,1),am=new lc,lm=new lc,cm=new Kw,yn=class extends Qe{constructor(e=st.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Yw;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),cm.getNormalMatrix(this.matrixWorld),am.copy(Qw).applyMatrix3(cm).normalize(),lm.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(am,lm)}clone(e){let r=this.shape.clone(),o=this.material,i=this.geometry.userData,s=st.create(Object.assign({},i,{shape:r})),a=new yn(s,o).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){Qe.prototype.raycast.call(this,e,r)}};function ua(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 Zw().parse(n));let e;try{e=Ii(t)}catch(r){console.error(r)}if(!e){let r=Se.createFromState($o.defaultData(),100,100);t.shape=r,e=Ii(t)}return e}var pe;Js.then(n=>{pe=n});var dm=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),fm=new Uint32Array([0,1,2,3]),mm=new Uint8Array([4]),Ot=class{static build(n,t,e,r,o){let i,s,a,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:dm,indexWASM:fm,verticesPerFaceWASM:mm},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?a=Ot.buildLevel(i,!1,c):a=null),{subdivPointer:i,originalGeometry:s,subdividedGeometry:a}}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:ua(n),r,o,i,s;({positions:r,triIndices:s}=mc(e.getAttribute("position"),e.getIndex()));let a;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;a=[c,p]}return{indices:o,verticesPerFace:i}=hc(r,s,e,a),{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=dm,r=fm,o=mm);let a=e.length,c=r.length,p=o.length,l=e.length+i.length+s.length,u=r.length+o.length,d=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=l*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,h=pe._malloc(d),g=new Float32Array(pe.HEAPF32.buffer,h,l),x=new Uint32Array(pe.HEAPU32.buffer,h+f,u);g.set(e,0),g.set(i,e.length),g.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 e1().makeScale(...n.scaleBaked)),t&&(v?v.premultiply(t):v=t);let A=v?pe.alloc_subdivision_surface2(h,a,h+f,c,h+f+r.length*Uint32Array.BYTES_PER_ELEMENT,p,v.elements):pe.alloc_subdivision_surface(h,a,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,a=pe.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(4,4+4),p=0,l=pe.HEAPU32[a[p]>>2],u=pe.HEAPF32.subarray(l>>2,(l>>2)+c[p]);p++;let d=pe.HEAPU32[a[p]>>2],f=pe.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=pe.HEAPU32[a[p]>>2],h=pe.HEAPU32.subarray(m>>2,(m>>2)+c[p]);p++;let g=pe.HEAPU32[a[p]>>2],x=pe.HEAPU32.subarray(g>>2,(g>>2)+c[p]);if(p++,r===void 0){let v=new um;if(v.setIndex(new cc(x,1)),v.setAttribute("position",new uc(u,3)),v.setAttribute("normal",new uc(f,3)),t){v.setAttribute("faceMap",new cc(h,1));let A=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new pm(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),a=0,c=pe.HEAPU32[i[a]>>2],p=pe.HEAPF32.subarray(c>>2,(c>>2)+s[a]);a++;let l=pe.HEAPU32[i[a]>>2],u=pe.HEAPU32.subarray(l>>2,(l>>2)+s[a]);if(t===void 0){let d=new um;d.setAttribute("position",new uc(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 pm(f,3)),d.setIndex(new cc(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),a=s.subarray(3,3+3),c=0,p=pe.HEAPU32[s[c]>>2],l=new Float32Array(pe.HEAPF32.subarray(p>>2,(p>>2)+a[c]));c++;let u=pe.HEAPU32[s[c]>>2],d=new Uint32Array(pe.HEAPU32.subarray(u>>2,(u>>2)+a[c]));c++;let f=pe.HEAPU32[s[c]>>2],m=new Uint8Array(pe.HEAPU32.subarray(f>>2,(f>>2)+a[c]));return pe.free_topological_data(o),{positions:l,indices:d,verticesPerFace:m}}};var hm=["getX","getY","getZ"];function mc(n,t){let e={},r=t?t.count:n.count,o=0,i=[],s=[],a=1e4;for(let p=0;p<r;p++){let l=t?t.getX(p):p,u="";for(let d=0;d<3;d++)u+=`${~~(n[hm[d]](l)*a)},`;if(u in e)i.push(e[u]);else{for(let d=0;d<3;d++)s.push(n[hm[d]](l));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 pa=new da,pc=new da,dc=new da,fc=new da;function hc(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([]),a=0;for(let p=0;p<s.length;p+=2)a+=(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(a<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,a=e.capStartIndex??t.length;s<a;)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]){pa.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),pc.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),dc.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),fc.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),pc.sub(pa).normalize(),dc.sub(pa).normalize(),fc.sub(pa).normalize();let c=pc.cross(dc).dot(fc);Math.abs(c)>.005||r&&r.some((p,l)=>l%2===1?!1:s>=r[l]&&s<r[l+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=[],a=[],c=0,p=new Float32Array([e.userData.parameters.depth])[0];for(let l=0,u=0;l<n.length;l+=3,u++)n[l+2]===0&&(s.push(u),c++),n[l+2]===p&&a.push(u);if(e.userData.parameters.extrudeBevelSize===0){let l=a[0];a[0]=a[1],a[1]=l}s.reverse(),o.push(...s,...a),i.push(c,c)}return{indices:o,verticesPerFace:i}}var zt={};wh(zt,{calcBoolean:()=>i1,calcBooleanTopological:()=>n1,freeMeshSet:()=>l1,getMeshSet:()=>s1,transformMeshSet:()=>a1});var t1,gm=new Promise(n=>{t1=n});import{Float32BufferAttribute as ym,Sphere as r1}from"three";var he,xn;gm.then(n=>he=n);function o1(n,t,e){let r,{positions:o,triIndices:i}=mc(n.getAttribute("position"),n.getIndex()),s;if(t&&e){let{indices:a,verticesPerFace:c}=hc(o,i,n);s=c.length,r=[];for(let p=0,l=0;p<s;p++){r.push(c[p]);for(let u=0;u<c[p];u++)r.push(a[l++])}}else{let a=i.length;r=Array(a+a/3),s=0;for(let c=0,p=0;p<r.length;)r[p++]=3,s++,r[p++]=i[c++],r[p++]=i[c++],r[p++]=i[c++]}return{positions:o,faceIndices:r,nFaces:s}}function xm(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=he._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(he.HEAPU32.buffer,i,t):new Float32Array(he.HEAPF32.buffer,i,t)).set(n,0),i}function vm(n){switch(n){case 0:return he.OP.UNION;case 1:return he.OP.INTERSECTION;case 2:return he.OP.A_MINUS_B;case 3:return he.OP.B_MINUS_A;case 4:return he.OP.SYMMETRIC_DIFFERENCE;case 5:return he.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function n1(n,t){xn===void 0&&(xn=he.init_csg());let e=xm(n),r=he.csg_calc_topological(xn,e,n.length,vm(t));he._free(e);let o=6,i=he.HEAPU32.subarray(r>>2,(r>>2)+o),s=i.subarray(3,3+3),a=0,c=he.HEAPU32[i[a]>>2],p=new Float32Array(he.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=he.HEAPU32[i[a]>>2],u=new Uint32Array(he.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let d=he.HEAPU32[i[a]>>2],f=new Uint8Array(he.HEAPU32.subarray(d>>2,(d>>2)+s[a]));return he.free_mesh_data(r),{positions:p,indices:u,verticesPerFace:f}}function i1(n,t,e,r){xn===void 0&&(xn=he.init_csg());let o=xm(n),i=he.csg_calc(xn,o,n.length,r,vm(t));he._free(o);let s=5,a=he.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),p=0,l=he.HEAPU32[a[p]>>2],u=he.HEAPF32.subarray(l>>2,(l>>2)+c[p]);p++;let d=he.HEAPU32[a[p]>>2],f=he.HEAPF32.subarray(d>>2,(d>>2)+c[p]);p++;let m=c[p];e.setAttribute("position",new ym(u,3)),e.setAttribute("normal",new ym(f,3));let h=he.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new r1),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},he.free_mesh_data(i),m}function s1(n,t,e){if(he===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((x,v)=>x+v,0)+i);for(let x=0,v=0,A=0;x<g.verticesPerFace.length;x++){o[A++]=g.verticesPerFace[x];for(let S=0;S<g.verticesPerFace[x];S++)o[A++]=g.indices[v++]}}else({positions:r,faceIndices:o,nFaces:i}=o1(n,t,e));let s=r.length,a=o.length,c=r.length,p=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+p*Uint32Array.BYTES_PER_ELEMENT,u=c*Float32Array.BYTES_PER_ELEMENT,d=p*Uint32Array.BYTES_PER_ELEMENT,f=he._malloc(l),m=new Float32Array(he.HEAPF32.buffer,f,c),h=new Uint32Array(he.HEAPU32.buffer,f+u,p);return m.set(r,0),h.set(o,0),he.get_csg_mesh(f,s,f+u,a,i)}function a1(n,t){he.transform_csg_mesh(n,t.elements)}function l1(n){he.free_csg_mesh(n)}var ac={ConeGeometry:Dd,CubeGeometry:Bd,CylinderGeometry:Md,DodecahedronGeometry:Ed,EllipseGeometry:cf,HelixGeometry:mf,IcosahedronGeometry:hf,LatheGeometry:gf,NonParametricGeometry:Tf,PolygonGeometry:Af,PyramidGeometry:Cf,RectangleGeometry:Nf,SphereGeometry:Pf,PlaneGeometry:If,BackdropGeometry:Lf,StarGeometry:Of,TextFrameGeometry:Zs,TorusGeometry:Mf,TorusKnotGeometry:Df,TriangleGeometry:Bf,VectorGeometry:st},Ii=n=>ac[n.type].create(n);import{BufferGeometry as bm,Matrix4 as c1}from"three";var Sm=new c1;var fa=class extends Qe{constructor(e=new bm,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,r=!0){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];tr(s)&&s.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(kf(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.geometry.index&&s.geometry.index.count/3<15e5&&(s.booleanMeshSetAddress=zt.getMeshSet(s.geometry,e===!0,r)),s.booleanMeshSetAddress===-1)return;zt.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else tr(s)&&s.needsTransformForDownstream===!0?(zt.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(Sm.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),zt.transformMeshSet(s.booleanMeshSetAddress,Sm),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return zt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new bm,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=zt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Yr(this),Kr(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 A1,OrthographicCamera as C1,PerspectiveCamera as N1,Vector3 as jt,Object3D as Tm,Quaternion as P1}from"three";import{BoxBufferGeometry as u1}from"three";var dr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new u1(30,30,30),t};import{Camera as h1,LineSegments as g1,BufferGeometry as y1,LineBasicMaterial as x1,Color as yc,Vector3 as v1,Float32BufferAttribute as _m}from"three";import{Ray as p1,Sphere as d1,Matrix4 as f1,Vector3 as Cr}from"three";var ma=new p1,gc=new d1,wm=new f1,fr=(n,t,e,r,o=!1)=>{let i=t,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),gc.copy(i.boundingSphere),gc.applyMatrix4(s),e.ray.intersectsSphere(gc)===!1||(wm.copy(s).invert(),ma.copy(e.ray).applyMatrix4(wm),i.boundingBox!==null&&ma.intersectsBox(i.boundingBox)===!1))return;let a,c,p,l,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),l=u.getX(m+2),a=g(n,e,ma,d,c,p,l),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=i.attributes.position,A=new Cr,S=new Cr,b=new Cr,D=new Cr,w=2,L=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=L*L,I=Math.max(0,f.start),C=Math.min(v.count,f.start+f.count);for(let N=I,k=C-1;N<k;N+=w){if(A.fromBufferAttribute(v,N),S.fromBufferAttribute(v,N+1),ma.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 g(x,v,A,S,b,D,w){let y=new Cr,L=new Cr,T=new Cr,I=new Cr,C=new Cr;if(y.fromBufferAttribute(S,b),L.fromBufferAttribute(S,D),T.fromBufferAttribute(S,w),A.intersectTriangle(y,L,T,!1,I)===null)return null;C.copy(I),C.applyMatrix4(x.matrixWorld);let k=v.ray.origin.distanceTo(C);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:C.clone(),object:x}}};var ha=new v1,Mt=new h1,xc=class extends g1{constructor(e){let r=new y1,o=new x1({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={},c=new yc(15711266),p=new yc(15711266),l=new yc(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",l),u("u2","u3",l),u("u3","u1",l);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),a[f]===void 0&&(a[f]=[]),a[f].push(i.length/3-1)}r.setAttribute("position",new _m(i,3)),r.setAttribute("color",new _m(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=a,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,a=o?.8:1e-4;Ut("n1",r,e,Mt,-i,-s,a),Ut("n2",r,e,Mt,i,-s,a),Ut("n3",r,e,Mt,-i,s,a),Ut("n4",r,e,Mt,i,s,a);let c=a;Ut("f1",r,e,Mt,-i,-s,c),Ut("f2",r,e,Mt,i,-s,c),Ut("f3",r,e,Mt,-i,s,c),Ut("f4",r,e,Mt,i,s,c);let p=c,l=.5;Ut("u1",r,e,Mt,i*.7*l,s*1.1,p),Ut("u2",r,e,Mt,-i*.7*l,s*1.1,p),Ut("u3",r,e,Mt,0,s*(1.1+.9*l),p),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ut(n,t,e,r,o,i,s){ha.set(o,i,s).unproject(r);let a=t[n];if(a!==void 0){let c=e.getAttribute("position");for(let p=0,l=a.length;p<l;p++)c.setXYZ(a[p],ha.x,ha.y,ha.z)}}var ga=class extends dr(xc){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){fr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as b1}from"three";var vn=class extends dr(b1){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){fr(this.object,vn.geometryHelper,e,r)}};import{AxesHelper as S1}from"three";var bn=class extends dr(S1){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){fr(this.object,bn.geometryHelper,e,r)}update(){}};import{PointLightHelper as w1}from"three";var Sn=class extends dr(w1){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){fr(this.object,Sn.geometryHelper,e,r)}};import{SpotLightHelper as _1,Vector3 as T1}from"three";var ya=class extends dr(_1){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){fr(this.object,ya.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ya._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,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Li=ya;Li._vector=new T1;var mr=(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=Ve(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 wn=new jt,vc=new jt,Nr=class extends mr(It(A1),ga){constructor(e=window.innerWidth,r=window.innerHeight,o=45,i,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=to.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new C1(e*-.5,e*.5,r*.5,r*-.5,i??-5e4,s),this.perspCamera=new N1(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(wn),this.targetOffset=wn.distanceTo(e)}getTarget(e=new jt){return this.getWorldDirection(vc),this.getWorldPosition(wn),vc.multiplyScalar(this.targetOffset),e.copy(wn).add(vc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wn),wn.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new P1),r=new jt(0,0,1).applyQuaternion(e),o=new jt().copy(Tm.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let i=new jt().copy(Tm.DefaultUp).projectOnPlane(r),s=new jt().crossVectors(i,o).dot(r)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(o)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new jt),i=e.getWorldDirection(new jt).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToObject(e){let r=e.getWorldPosition(new jt),i=this.getWorldDirection(new jt).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,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,s,a):this.orthoCamera.setViewOffset(e,r,o,i,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(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 Uo(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),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom)),e.type==="PerspectiveCamera"?(this.zoom=this.perspCamera.zoom,this.fov=this.perspCamera.fov,this.near=this.perspCamera.near):(this.near=this.orthoCamera.near,this.zoom=this.orthoCamera.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 I1}from"three";var ho=class extends mr(It(I1),bn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new ho().fromState(r);return o.uuid=e,o.objectHelper.update(),o}};import{DirectionalLight as L1,CameraHelper as xa}from"three";var _n=class extends mr(It(L1),vn){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 xa(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new _n().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 xa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&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&&Ff(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 O1,Vector3 as va,Box3 as M1,Box3Helper as ba,Color as D1}from"three";var Tn=class extends mr(It(O1),Sn){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 va(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new va(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),a=new M1(i,s),c=new ba(a,new D1(16755200));c.visible=!1,this._gizmos.shadowmap=c,this.update()}static createFromState(e,r,o){let i=new Tn().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 ba&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ba&&(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 ba){let o=this.shadow.camera,i=new va(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new va(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 B1,CameraHelper as Sa,MathUtils as E1,Vector3 as Pm,Quaternion as G1}from"three";var Am=new Pm,Cm=new Pm,Nm=new G1,An=class extends mr(It(B1),Li){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=E1.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let i=new Sa(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}static createFromState(e,r,o){let i=new An().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 Sa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Sa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof Sa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Cm.setFromMatrixPosition(this.matrixWorld),Nm.setFromRotationMatrix(this.matrixWorld),Am.copy(this.up).applyQuaternion(Nm).negate().multiplyScalar(this.distance),this.target.position.copy(Cm).add(Am),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 Im=n=>n.tagName==="VIDEO",Cn=class{static resize(t,e,r){let o=t/e,i;if(!r.image)return;let s=r.image;Im(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];im(s)&&Cn.resizeTextureLayer(t,e,s.uniforms[`f${s.id}_texture`].value)}}static resizeComplex(t,e,r,o){let i=t/e,s,a=r.image;Im(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.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 wa=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&&Cn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Nn=class extends Qe{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var _a=class extends Nn{constructor(e,r){super(e,r);this.objectType="NonParametric"}};import{DoubleSide as R1,Mesh as F1,MeshBasicMaterial as V1,ShapeBufferGeometry as z1,Vector2 as U1,Vector3 as j1}from"three";import{FontLoader as k1}from"three/examples/jsm/loaders/FontLoader.js";var Ee=class extends F1{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:i,fontSize:s,LOD:a=16},c=new V1({color:0,opacity:1,visible:!0,transparent:!0,side:R1})){let p=Ee.loadChar(e,o,a);super(p.geometry,c);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=i,this.fontSize=s,this.LOD=a,this.resolution=p.resolution,this.glyphsHa=p.glyphsHa,this.localPosition=new U1,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 j1(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 k1().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 z1(s,o),fontFamily:r,resolution:i.data.resolution,glyphsHa:i.data.glyphs[e].ha},Ee.charCache[e][o]}},kt=Ee;kt.charCache={},kt.fontCache={},kt._fontPath="/_assets/_fonts/";import{DoubleSide as Om,MeshBasicMaterial as Mm,Vector3 as H1,Object3D as W1}from"three";import{Vector2 as Lm}from"three";var Ta=new Lm,go=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new Lm(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){Ta.set(e,r);let o=this.message.length;for(let i=0;i<o;i++)this.message[i].updatePosition(this.message[i].localPosition.add(Ta),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 a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=i),Ta.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(Ta),e)}clone(){let t=new go(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 bc=class extends Qe{constructor(e){super(e,new Mm({transparent:!0,opacity:1,visible:!1,side:Om}));this.objectType="TextFrame";this.charContainer=new W1,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 H1(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let i=Zs.create({parameters:{width:r.width,height:r.height}}),s=new bc(i).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await kt.loadFont(o),r.text=e;let i=r.textOrigin,s=new Mm({visible:r.visible,transparent:!0,side:Om}),a=e.split(`
|
|
1333
|
-
`),c=0;this.userData.textFrame.textLines=a.map((p,l)=>{let u=new go(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 kt(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,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof kt&&(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,a=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=a,p.textOrigin.set(-.5*a,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):a!==i&&(i<a?this.checkCapacity():i>a&&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 a=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?a.unshift(i[s].getWord(i[s].message.length-1,-1)):a.unshift(i[s].popChar());if(a.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<a.length;p+=1)for(let l=0;l<a[p].length;l+=1)i[s+1].addChar3D(a[p][l],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 a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let c,p=s[a-1].spaceLeft(i);if(s[a].wordSize(0,1)<=p){s[a].containSpace()?c=s[a].getWord(0,1):c=s[a].popChar(0);for(let l=0;l<c.length;l+=1)c[l]&&s[a-1].addChar3D(c[l],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new go(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<i.length;a++)i[a].updateYLinePos(this.getNewLinePosition(a)),i[a].fullUpdate(o.textOrigin),i[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].material;c.visible=e}}}async updateFontFamily(e){await kt.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)a[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 a=0;a<i.length;a++)i[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await kt.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[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 a=0;a<s.length;a++)s[a].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=Ve(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}},yo=bc;yo.VerticalAlign=rl,yo.HorizontalAlign=tl,yo.TextTransform=ol;var xo=class extends wt{};var Gm=Nc(Dm());var Bm=new Map;function Em(n){if(typeof n=="string")return n;let t=Bm.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Bm.set(n,t)),t.url}var Pn=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:Em(t),format:"wav"},this.sound=new Gm.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 Mi=class{constructor(t,e={}){this.deletedMaterial=new xo(Bt.defaultTwoLayerData("basic"),this);this.deletedImage=new fo(Rs.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 xo(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 wt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new fo(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 hn(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 $r(e.r,e.g,e.b,e.a):this.colors[t]=new $r(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 Pn)return e;{let r=new Pn({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 Pn&&e.dispose()}),this.audios={}}},NH=new Mi(Gs.emptyData());import{DRACOLoader as q1}from"three/examples/jsm/loaders/DRACOLoader.js";var Qr;function $1(){return Qr||(Qr=new q1,Qr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Qr.decoderPending}async function X1(n){if(Qr){let t={attributeIDs:Qr.defaultAttributeIDs,attributeTypes:Qr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Qr.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 Rm(n,t){let[e,r]=Va(Ns.deserialize(new Uint8Array(n)));Ld(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 $1();for(let i of o){let s=await X1(Dt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:p,itemSize:l})=>{a[c]={array:p,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{HemisphereLight as m_,Scene as h_,Vector3 as g_,Fog as y_,Box3 as x_}from"three";import{Box3 as Y1,Matrix4 as vo,Sphere as zm,Vector3 as K1}from"three";var jm=Nc(Vm());var Sc;Js.then(n=>{Sc=n});var km=new vo,Q1=new vo,Z1=new vo,Ht=new Y1,Zr=new K1,J1=new vo,e_=new vo,In=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 vo;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new vo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:a}=Ot.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new In(i,s,a||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,Yr(this),Kr(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,jm.SVD)(r),a=km.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=Q1.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),p=Z1.copy(c).transpose();this.shearScale=J1.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=e_.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,p),s.every(l=>Math.abs(s[0]-l)<.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 zm);let r=e.attributes.position,o=e.boundingSphere.center;Ht.setFromBufferAttribute(r),Ht.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Zr);let i={width:Zr.x,height:Zr.y,depth:Zr.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;Ht.min.set(e[0],e[2],e[4]),Ht.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ht.min.applyMatrix4(this.shearScaleInv),Ht.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new zm);let o=r.boundingSphere.center;Ht.getCenter(o),r.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Zr);let i={width:Zr.x,height:Zr.y,depth:Zr.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(Sc.free_bvh(this.subdivPointer),Sc.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,Um(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Um(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 Um(n,t,e,r){let o=n.position.array,i=n.normal.array,s=km.makeScale(t,e,r).invert().elements,a,c,p;for(var l=0,u=o.length;l<u;l+=3)o[l]*=t,o[l+1]*=e,o[l+2]*=r,a=i[l],c=i[l+1],p=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*p,i[l+1]=s[1]*a+s[5]*c+s[9]*p,i[l+2]=s[2]*a+s[6]*c+s[10]*p}import{BackSide as t_,BufferGeometry as r_,DoubleSide as o_,FrontSide as n_}from"three";function Hm(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=n_:t.side===1?n.side=t_:n.side=o_)}function i_(n,t){if(Array.isArray(n.material))for(let e of n.material)Hm(e,t);else{let e=n.material;Hm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Wm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=In.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new r_:ua(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ms.is2DParametricMesh(o.userData.type)?r=new wa(o,i):o?.userData.type==="VectorGeometry"?r=new yn(o,i):t.geometry.type==="NonParametricGeometry"?r=new _a(o,i):t.geometry.type==="BooleanGeometry"?(r=new fa(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new Nn(o,i),r.uuid=n,r.fromState(t,e)}return i_(r,t),r}function qm(n,t,e){return t.type==="Mesh"?Wm(n,t,e):t.type==="TextFrame"?yo.createFromState(n,t,e):t.type==="Empty"?ho.createFromState(n,t):t.type==="PointLight"?Tn.createFromState(n,t,e):t.type==="SpotLight"?An.createFromState(n,t,e):t.type==="DirectionalLight"?_n.createFromState(n,t,e):jo.is(t.type)?Nr.createFromState(n,t):(console.error(t),new ho)}import{Mesh as Ym,Ray as a_,Matrix4 as l_,Raycaster as c_}from"three";function $m(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,Kr(n),Yr(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Xm(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 Km(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ym&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)$m(e,e.material[r])&&(t=!0);else $m(e,e.material)&&(t=!0)}),t}function Qm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ym)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Xm(e,e.material[r])&&(t=!0);else Xm(e,e.material)&&(t=!0)}),t}function Zm(n){"material"in n&&u_(n.material),"geometry"in n&&n.geometry.dispose()}function u_(n){Pc(n).forEach(t=>{t instanceof xo||t.dispose()})}var p_=new c_,d_=new l_,f_=new a_;function Jm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=d_.copy(o.matrixWorld).invert(),s=f_.copy(t.ray).applyMatrix4(i),a=n.matrixWorld;s.applyMatrix4(a);let c=p_;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 eh=new g_,wc=class extends ta(h_){constructor(e,r){super();this.objectType="Scene";this.backupFog=new y_(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 m_(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=Qm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Km(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(Ve(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=>{tr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Zm(e)});for(let e of this.children)nr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Nr.createFromState(wc.PERSONAL_CAMERA_ID,{...Bs.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)nr(s)&&!s.raycastLock&&s.visible&&((er(s)||ea(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)nr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)nr(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=Ve(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Rf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ve(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 a=qm(e,r,s);return a&&(this.entityByUuid[e]=a,i.add(a),tr(i)&&er(a)&&(a.prevBooleanObjectParent=i),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],p=this.find(a),l=c?p.recursiveBBox:p.singleBBox;r.push(...l.vertices)}let o=new x_;return o.setFromPoints(r),o.getCenter(eh),eh}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 wt&&e(r.material[o]);else r.material instanceof wt&&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})})}},Di=wc;Di.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as Y5}from"three";import{mergeBufferGeometries as Z5}from"three/examples/jsm/utils/BufferGeometryUtils.js";function th(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 rh,ShaderLib as v_}from"three";function oh(n){let t=new Set;return n.traverse(e=>{if(er(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);if(b_(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new rh,specularColor:new rh});let o=0;e.onBeforeCompile=(i,s)=>{r&&r(i,s),i.uniforms=Object.assign(v_.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else S_(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function b_(n){return n.getLayersOfType("transmission").length>0}function S_(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 nh(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function ih(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(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as w_}from"three/examples/jsm/utils/BufferGeometryUtils.js";function sh(n){let t=[];return n.traverse(e=>{e instanceof lo&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(a=>{a.updateMatrix();let c=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&th(c),c}),s=w_(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function ah(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function lh(n){Object.values(n.shared.materials).forEach(t=>{_c(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?_c(e.material):"materials"in e&&e.materials.forEach(r=>{_c(r)})})}function _c(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 ch="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Tc=class extends T_{load(t,e,r,o=console.error){let i=new __(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(ch+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(ch),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await Rm(t,lh),r=new Mi(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Di(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&&Gf(s)&&Object.assign(s,{makeDefault:!0})}return o=sh(o),o=oh(o),o=nh(o),o=ih(o),o=ah(o),o}};export{Tc as default};
|
|
1333
|
+
`),c=0;this.userData.textFrame.textLines=a.map((p,l)=>{let u=new go(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 kt(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,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof kt&&(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,a=e.parameters?.width??i,c=e.parameters?.height??s,p=r.textFrame;super.updateGeometry(e),p.maxLineSize=a,p.textOrigin.set(-.5*a,.5*c,0),c!==s?(this.checkOverFlow(),this.checkCapacity()):a!==i&&(i<a?this.checkCapacity():i>a&&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 a=[];for(;i[s].checkOverFlow(r.textFrame.maxLineSize);)i[s].containSpaceOverFlow()?a.unshift(i[s].getWord(i[s].message.length-1,-1)):a.unshift(i[s].popChar());if(a.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<a.length;p+=1)for(let l=0;l<a[p].length;l+=1)i[s+1].addChar3D(a[p][l],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 a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let c,p=s[a-1].spaceLeft(i);if(s[a].wordSize(0,1)<=p){s[a].containSpace()?c=s[a].getWord(0,1):c=s[a].popChar(0);for(let l=0;l<c.length;l+=1)c[l]&&s[a-1].addChar3D(c[l],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new go(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,i=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<i.length;a++)i[a].updateYLinePos(this.getNewLinePosition(a)),i[a].fullUpdate(o.textOrigin),i[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].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 a=0;a<s.length;a++){let c=s[a].material;c.visible=e}}}async updateFontFamily(e){await kt.loadFont(e);let o=this.userData.textFrame,i=o.textLines;o.fontFamily=e;for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)a[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 a=0;a<i.length;a++)i[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await kt.loadFont(o.fontFamily);let i=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toUpperCase())}break;case 3:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[c].char.toLowerCase())}break;default:for(let s=0;s<i.length;s++){let a=i[s].message;for(let c=0;c<a.length;c++)i[s].message[c].updateChar(a[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 a=0;a<s.length;a++)s[a].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=Ve(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}},yo=bc;yo.VerticalAlign=rl,yo.HorizontalAlign=tl,yo.TextTransform=ol;var xo=class extends wt{};var Gm=Nc(Dm());var Bm=new Map;function Em(n){if(typeof n=="string")return n;let t=Bm.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Bm.set(n,t)),t.url}var Pn=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:Em(t),format:"wav"},this.sound=new Gm.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 Mi=class{constructor(t,e={}){this.deletedMaterial=new xo(Bt.defaultTwoLayerData("basic"),this);this.deletedImage=new fo(Rs.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 xo(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 wt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new fo(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 hn(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 $r(e.r,e.g,e.b,e.a):this.colors[t]=new $r(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 Pn)return e;{let r=new Pn({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 Pn&&e.dispose()}),this.audios={}}},NH=new Mi(Gs.emptyData());import{DRACOLoader as q1}from"three/examples/jsm/loaders/DRACOLoader.js";var Qr;function $1(){return Qr||(Qr=new q1,Qr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Qr.decoderPending}async function X1(n){if(Qr){let t={attributeIDs:Qr.defaultAttributeIDs,attributeTypes:Qr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Qr.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 Rm(n,t){let[e,r]=Va(Ns.deserialize(new Uint8Array(n)));Ld(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 $1();for(let i of o){let s=await X1(Dt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:p,itemSize:l})=>{a[c]={array:p,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{HemisphereLight as m_,Scene as h_,Vector3 as g_,Fog as y_,Box3 as x_}from"three";import{Box3 as Y1,Matrix4 as vo,Sphere as zm,Vector3 as K1}from"three";var jm=Nc(Vm());var Sc;Js.then(n=>{Sc=n});var km=new vo,Q1=new vo,Z1=new vo,Ht=new Y1,Zr=new K1,J1=new vo,e_=new vo,In=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 vo;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new vo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:i,originalGeometry:s,subdividedGeometry:a}=Ot.build(r.geometry,void 0,void 0,!r.flatShading),c=o.material(r.material),p=new In(i,s,a||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,Yr(this),Kr(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,jm.SVD)(r),a=km.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=Q1.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),p=Z1.copy(c).transpose();this.shearScale=J1.makeScale(s[0],s[1],s[2]).multiply(p).premultiply(c),this.shearScaleInv=e_.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,p),s.every(l=>Math.abs(s[0]-l)<.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 zm);let r=e.attributes.position,o=e.boundingSphere.center;Ht.setFromBufferAttribute(r),Ht.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Zr);let i={width:Zr.x,height:Zr.y,depth:Zr.z};return this.geometry.userData.parameters=i,i}updateBoundingBox(e){let r=this.originalGeometry;Ht.min.set(e[0],e[2],e[4]),Ht.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ht.min.applyMatrix4(this.shearScaleInv),Ht.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new zm);let o=r.boundingSphere.center;Ht.getCenter(o),r.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Zr);let i={width:Zr.x,height:Zr.y,depth:Zr.z};return this.geometry.userData.parameters=i,i}freeSubdivPointer(){this.subdivPointer&&(Sc.free_bvh(this.subdivPointer),Sc.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,Um(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Um(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 Um(n,t,e,r){let o=n.position.array,i=n.normal.array,s=km.makeScale(t,e,r).invert().elements,a,c,p;for(var l=0,u=o.length;l<u;l+=3)o[l]*=t,o[l+1]*=e,o[l+2]*=r,a=i[l],c=i[l+1],p=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*p,i[l+1]=s[1]*a+s[5]*c+s[9]*p,i[l+2]=s[2]*a+s[6]*c+s[10]*p}import{BackSide as t_,BufferGeometry as r_,DoubleSide as o_,FrontSide as n_}from"three";function Hm(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=n_:t.side===1?n.side=t_:n.side=o_)}function i_(n,t){if(Array.isArray(n.material))for(let e of n.material)Hm(e,t);else{let e=n.material;Hm(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Wm(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=In.createFromState(n,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new r_:ua(t.geometry,e),i="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ms.is2DParametricMesh(o.userData.type)?r=new wa(o,i):o?.userData.type==="VectorGeometry"?r=new yn(o,i):t.geometry.type==="NonParametricGeometry"?r=new _a(o,i):t.geometry.type==="BooleanGeometry"?(r=new fa(void 0,i),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new Nn(o,i),r.uuid=n,r.fromState(t,e)}return i_(r,t),r}function qm(n,t,e){return t.type==="Mesh"?Wm(n,t,e):t.type==="TextFrame"?yo.createFromState(n,t,e):t.type==="Empty"?ho.createFromState(n,t):t.type==="PointLight"?Tn.createFromState(n,t,e):t.type==="SpotLight"?An.createFromState(n,t,e):t.type==="DirectionalLight"?_n.createFromState(n,t,e):jo.is(t.type)?Nr.createFromState(n,t):(console.error(t),new ho)}import{Mesh as Ym,Ray as a_,Matrix4 as l_,Raycaster as c_}from"three";function $m(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,Kr(n),Yr(n)),r.length===0&&o.length===0&&n.layers.set(0),e}function Xm(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 Km(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ym&&e.objectType!=="TextFrame")if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)$m(e,e.material[r])&&(t=!0);else $m(e,e.material)&&(t=!0)}),t}function Qm(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof Ym)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Xm(e,e.material[r])&&(t=!0);else Xm(e,e.material)&&(t=!0)}),t}function Zm(n){"material"in n&&u_(n.material),"geometry"in n&&n.geometry.dispose()}function u_(n){Pc(n).forEach(t=>{t instanceof xo||t.dispose()})}var p_=new c_,d_=new l_,f_=new a_;function Jm(n,t,e){let r=n.cloner;if(r)for(let o of r.children){let i=d_.copy(o.matrixWorld).invert(),s=f_.copy(t.ray).applyMatrix4(i),a=n.matrixWorld;s.applyMatrix4(a);let c=p_;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 eh=new g_,wc=class extends ta(h_){constructor(e,r){super();this.objectType="Scene";this.backupFog=new y_(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 m_(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=Qm(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Km(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(Ve(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=>{tr(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Zm(e)});for(let e of this.children)nr(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Nr.createFromState(wc.PERSONAL_CAMERA_ID,{...Bs.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)nr(s)&&!s.raycastLock&&s.visible&&((er(s)||ea(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)nr(r)&&r.traverseEntity(e)}traverseVisibleEntity(e){for(let r of this.children)nr(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=Ve(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){Rf(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ve(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 a=qm(e,r,s);return a&&(this.entityByUuid[e]=a,i.add(a),tr(i)&&er(a)&&(a.prevBooleanObjectParent=i),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],p=this.find(a),l=c?p.recursiveBBox:p.singleBBox;r.push(...l.vertices)}let o=new x_;return o.setFromPoints(r),o.getCenter(eh),eh}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 wt&&e(r.material[o]);else r.material instanceof wt&&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})})}},Di=wc;Di.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as Y5}from"three";import{mergeBufferGeometries as Z5}from"three/examples/jsm/utils/BufferGeometryUtils.js";function th(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 rh,ShaderLib as v_}from"three";function oh(n){let t=new Set;return n.traverse(e=>{if(er(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);if(b_(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new rh,specularColor:new rh});let o=0;e.onBeforeCompile=(i,s)=>{r&&r(i,s),i.uniforms=Object.assign({},v_.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else S_(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function b_(n){return n.getLayersOfType("transmission").length>0}function S_(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 nh(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function ih(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(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as w_}from"three/examples/jsm/utils/BufferGeometryUtils.js";function sh(n){let t=[];return n.traverse(e=>{e instanceof lo&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children.map(a=>{a.updateMatrix();let c=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&th(c),c}),s=w_(e.parameters.hideBase?i:[r.geometry,...i]);r.geometry=s,r.remove(e),r.cloner=void 0}),n}function ah(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function lh(n){Object.values(n.shared.materials).forEach(t=>{_c(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?_c(e.material):"materials"in e&&e.materials.forEach(r=>{_c(r)})})}function _c(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 ch="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Tc=class extends T_{load(t,e,r,o=console.error){let i=new __(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(ch+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(ch),i.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await Rm(t,lh),r=new Mi(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Di(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&&Gf(s)&&Object.assign(s,{makeDefault:!0})}return o=sh(o),o=oh(o),o=nh(o),o=ih(o),o=ah(o),o}};export{Tc as default};
|