@splinetool/runtime 0.9.10 → 0.9.11

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.
Files changed (2) hide show
  1. package/build/runtime.js +2 -2
  2. package/package.json +1 -1
package/build/runtime.js CHANGED
@@ -4139,7 +4139,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
4139
4139
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
4140
4140
  }
4141
4141
  `),c&&h.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
4142
- `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.metalness&&(this.metalness=t.getNode(e.metalness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.reflectivity&&(this.reflectivity=t.getNode(e.reflectivity)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var Qy=class extends Zn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new Yy,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var Eu=class extends Qy{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof mn){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Eu(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};function $f(i,e){switch(i.data.type){case"light":return wi(i);case"fresnel":return XF(i,e);case"gradient":return YF(i);case"depth":return QF(i);case"normal":return KF(i);case"noise":return ZF(i,e);case"texture":return $F(i,e);case"rainbow":return eG(i);case"transmission":return tG(i,e);case"matcap":return rG(i,e);case"displace":return nG(i);case"color":default:return qF(i,e)}}function Z1(i){return{type:i.data.type}}function wi(i){let{alpha:e,mode:t}=i.data;return xe(re({},Z1(i)),{alpha:e,mode:t})}function qF(i,e){return xe(re({},wi(i)),{color:sr(i.data.color,e)})}function XF(i,e){let{bias:t,scale:r,intensity:n,factor:s,color:o}=i.data;return xe(re({},wi(i)),{color:sr(o,e),bias:t,scale:r,intensity:n,factor:s})}function YF(i){let{gradientType:e,smooth:t,colors:r,steps:n,angle:s,offset:o,morph:a}=i.data;return xe(re({},wi(i)),{gradientType:e,smooth:t,colors:r.map(l=>new Qe(l[0],l[1],l[2],l[3])),num:r.length,steps:n,offset:new F(...o),morph:new F(...a),angle:s})}function QF(i){let{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:o,direction:a,colors:l,steps:c,smooth:u}=i.data;return xe(re({},wi(i)),{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:new A(...o),direction:a?new A(...a):new A(1,0,0),num:l.length,colors:l.map(d=>new Qe(d[0],d[1],d[2],d[3])),steps:c,smooth:u})}function KF(i){let{cnormal:e}=i.data;return xe(re({},wi(i)),{cnormal:new A(e[0],e[1],e[2])})}function ZF(i,e){let{data:t}=i;return xe(re({},wi(i)),{scale:t.scale,move:t.move,fA:new F(...t.fA),fB:new F(...t.fB),distortion:new F(...t.distortion),colorA:sr(t.colorA,e),colorB:sr(t.colorB,e),colorC:sr(t.colorC,e),colorD:sr(t.colorD,e),noiseType:t.noiseType})}function $F(i,e){let{projection:t,axis:r,crop:n,size:s}=i.data,{image:o,wrapping:a,repeat:l,offset:c}=i.data.texture,u=new Pt,d;if(typeof o=="string")d=e==null?void 0:e.getImage(o);else{let h=new Image;h.src=o.data,h.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(o.data))},d=h}return u.image=d,u.wrapS=u.wrapT=a,xe(re({},wi(i)),{texture:u,mat:new Dt().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:n,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function eG(i){let{data:e}=i;return xe(re({},wi(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new A(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new A(...e.offset)})}function tG(i,e){let{data:t}=i;return xe(re({},wi(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function rG(i,e){let t=new Pt,{image:r}=i.data.texture,n;if(typeof r=="string")n=e==null?void 0:e.getImage(r);else{let o=new Image;o.src=r.data,o.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},n=o}t.image=n;let s=16777215;return xe(re({},wi(i)),{color:s,texture:t})}function nG(i){let{data:e}=i,t=xe(re({},Z1(i)),{intensity:e.intensity});if(e.displacementType==="noise")return xe(re({},t),{offset:new A(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new Pt,n=new Dt().setUvTransform(0,0,1,1,0,0,0);return xe(re({},t),{texture:r,mat:n,crop:e.crop})}}function ep(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}var Kl;(function(e){function i(t){return new ve(t.x,t.y,t.z).getHex()}e.getHex=i})(Kl||(Kl={}));var $1;(function(e){function i(t){return new Qe(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})($1||($1={}));var eA;(function(t){function i(r,n){r.setRGB(n.r,n.g,n.b)}t.setThreeColor=i;function e(r){return new ve(r.r,r.g,r.b).getHex()}t.getHex=e})(eA||(eA={}));function yo(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):Ky(i,e)}function tA(i,e){return i.map(t=>yo(t,e))}function Ky(i,e){var o;let t=(o=i.layers)!=null?o:Ol.defaultTwoLayerData("phong").layers,r=iG(t),n;switch(r.category){case"basic":n=new sn;break;case"lambert":{n=new Tu;break}case"toon":{n=new _u;break}case"physical":n=new Eu;break;case"phong":default:{n=new $n;break}}let s=n.userData.layers;sG(s);for(let a=t.length-1;a>=0;a--)oG(s,t[a],e);switch(r.category){case"basic":break;case"lambert":{let c=n,d=sr(r.emissive,e);d instanceof ve?c.emissive.value=d:c.emissive.value.setHex(Kl.getHex(d));break}case"toon":{let c=n,u=r;c.shininess.value=u.shininess;let d=sr(u.specular,e);d instanceof ve?c.specular.value=d:c.specular.value.setHex(Kl.getHex(d));break}case"physical":let a=n,l=r;a.metalness.value=l.metalness,a.roughness.value=l.roughness,a.reflectivity.value=l.reflectivity;break;case"phong":default:{let c=n,u=r;c.shininess.value=u.shininess;let d=sr(u.specular,e);d instanceof ve?c.specular.value=d:c.specular.value.setHex(Kl.getHex(d));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),n}function iG(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:Ar.Normal}}function sG(i){for(let e of i.getLayers())i.removeLayer(e.id)}function oG(i,e,t){let r=$f(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let n=i.addLayer(r);n.uuid=e.id;for(let s in e.data)ep(s,n,e.data)}var aa=new Set;var Si;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Si||(Si={}));var Ts=class{constructor(){this.easing=4;this.duration=1e3;this.delay=0;this.cubicControls=[.5,.05,.1,.3];this.springParameters={mass:1,stiffness:80,damping:10,velocity:0};this.repeat=!1;this.cycle=!1;this.rewind=!1}static create(e){let t=new Ts,r=e;return t.easing=e.easing,t.duration=e.duration,t.delay=e.delay,r.easing===Zc.CUBIC?t.cubicControls=[...r.control1,...r.control2]:r.easing===Zc.SPRING&&(t.springParameters={mass:r.mass,stiffness:r.stiffness,damping:r.damping,velocity:r.velocity}),t.repeat=e.repeat,t.cycle=e.cycle,t.rewind=e.rewind,t}get sp_mass(){return this.springParameters.mass}set sp_mass(e){this.springParameters.mass=e}get sp_stiffness(){return this.springParameters.stiffness}set sp_stiffness(e){this.springParameters.stiffness=e}get sp_damping(){return this.springParameters.damping}set sp_damping(e){this.springParameters.damping=e}get sp_velocity(){return this.springParameters.velocity}set sp_velocity(e){this.springParameters.velocity=e}copy(e){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters=re({},e.springParameters),this.repeat=e.repeat,this.cycle=e.cycle,this.rewind=e.rewind,this}clone(){return new Ts().copy(this)}toJSON(){let e={easing:this.easing,duration:this.duration,delay:this.delay,cubicControls:this.cubicControls,springParameters:re({},this.springParameters)};return this.repeat===!0&&(e.repeat=!0),this.cycle===!0&&(e.cycle=!0),this.rewind===!0&&(e.rewind=!0),this.object!==void 0&&(e.object=this.object.uuid),this.state!==void 0&&(e.state=this.state.uuid),e}fromJSON(e,t,r){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters.mass=e.springParameters.mass,this.springParameters.stiffness=e.springParameters.stiffness,this.springParameters.damping=e.springParameters.damping,this.springParameters.velocity=e.springParameters.velocity,e.repeat!==void 0&&(this.repeat=e.repeat),e.cycle!==void 0&&(this.cycle=e.cycle),e.rewind!==void 0&&(this.rewind=e.rewind),e.object!==void 0&&(this.object=t[e.object]),e.state!==void 0&&(this.state=r[e.state]),this}};function aG(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Je;(function(h){h[h.MOUSE_DOWN=0]="MOUSE_DOWN",h[h.MOUSE_UP=1]="MOUSE_UP",h[h.MOUSE_HOVER=2]="MOUSE_HOVER",h[h.MOUSE_ENTER=3]="MOUSE_ENTER",h[h.MOUSE_LEAVE=4]="MOUSE_LEAVE",h[h.KEY_DOWN=5]="KEY_DOWN",h[h.KEY_UP=6]="KEY_UP",h[h.START=7]="START",h[h.OPEN_LINK=8]="OPEN_LINK",h[h.LOOK_AT=9]="LOOK_AT",h[h.FOLLOW=10]="FOLLOW",h[h.SCROLL=11]="SCROLL"})(Je||(Je={}));var vo=class{constructor(e,t){this.targets=[];this._type=e,this.key=t}get type(){return this._type}set type(e){this._type=e,e===9?this.distance=1e3:this.distance=void 0,e!==5&&e!==6&&(this.key=void 0)}newTarget(e){let t=new Ts;if(t.object=e,e!==void 0){let r=e.interaction.states;r.length>0&&(t.state=r[r.length-1])}return this.targets.push(t),aa.add(t),t}addTarget(e,t=0){this.targets.splice(t,0,e),aa.add(e)}removeTarget(e){aa.delete(this.targets[e]),this.targets.splice(e,1)}dispatchReverse(){for(let e=0,t=this.targets.length;e<t;++e){let r=this.targets[e];r.state!==void 0&&r.object!==void 0&&r.object.interaction.reverse(r)}}dispatch(e){this.url!==void 0&&(this._type===8||this._type===0||this._type===1||this._type===5||this._type===6)&&(aG()?window.location.assign(this.url):window.open(this.url,"_blank"));for(let t=0,r=this.targets.length;t<r;++t){let n=this.targets[t];n.state!==void 0&&n.object!==void 0&&(this._type===11?n.object.interaction.seek(n,e,this.steps):n.object.interaction.play(n))}}copy(e){return this._type=e.type,this.key=e.key,this.url=e.url,this.distance=e.distance,this}clone(){return new vo().copy(this)}toJSON(){let e={type:this._type,key:this.key,ui:{isCollapsed:!1}};if(this.url!==void 0&&(e.url=this.url),this.distance!==void 0&&(e.distance=this.distance),this.targets.length>0){e.targets=[];for(let t=0,r=this.targets.length;t<r;++t)e.targets.push(this.targets[t].toJSON())}return e}fromJSON(e,t,r){if(this._type=e.type,this.key=e.key,this.targets=[],this.url=e.url,e.distance!==void 0&&(this.distance=e.distance),e.targets!==void 0)for(let n=0,s=e.targets.length;n<s;++n)this.addTarget(new Ts().fromJSON(e.targets[n],t,r),n);return this}};var Qi=class{constructor(){this.uuid=rt.generateUUID();this.name="";this.position=new A;this.rotation=new jn;this.scale=new A;this.hiddenMatrix=new Me}static create(e,t,r){let n=new Qi;if(n.uuid=e,n.position.fromArray(t.position),n.scale.fromArray(t.scale),n.rotation.fromArray(t.rotation),n.hiddenMatrix.fromArray(t.hiddenMatrix),"geometry"in t&&(n.geometry=t.geometry),"material"in t&&(n.material={layersList:yo(t.material,r).layersList.getLayers()}),"materials"in t&&(n.material=t.materials.map(s=>({layersList:yo(s,r).layersList.getLayers()}))),"perspective"in t&&(n.camera={zoomOrtho:t.orthographic.zoom,zoomPersp:t.perspective.zoom,targetOffset:t.targetOffset}),Il.is(t.type)){let s=t;n.light={intensity:s.intensity,color:sr(s.color,r)}}return n}update(e){this.updateMatrix(e),"geometry"in e&&this.updateGeometry(e),"material"in e&&this.updateMaterial(e),e.objectType==="CombinedCamera"?this.updateCamera(e):(e.objectType==="LightDirectional"||e.objectType==="LightPoint"||e.objectType==="LightSpot")&&this.updateLight(e)}updateCamera(e){this.camera={zoomPersp:e.perspCamera.zoom,zoomOrtho:e.orthoCamera.zoom,targetOffset:e.targetOffset}}updateLight(e){let t=e.color;this.light={intensity:e.intensity,color:{r:t.r,g:t.g,b:t.b}}}updateMatrix(e){this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),"hiddenMatrix"in e&&this.hiddenMatrix.copy(e.hiddenMatrix)}updateGeometry(e){if("geometry"in e&&this.geometry!==void 0){let{width:t,height:r,depth:n}=e.geometry.userData.parameters;this.geometry={width:t,height:r,depth:n}}}updateMaterial(e){if("material"in e&&this.material!==void 0)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t){let n=e.material[t],s=[],o=n.layersList.head;for(;o;)s.push(o.clone()),o=o.next;this.material.push({layersList:s})}}else{let t=e.material,r=[],n=t.layersList.head;for(;n;)r.push(n.clone()),n=n.next;this.material={layersList:r}}}execute(e){if(e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale),e.updateMatrix(),"hiddenMatrix"in e&&e.hiddenMatrix.copy(this.hiddenMatrix),"geometry"in e&&this.geometry!==void 0){let r=e.geometry.userData.parameters,n=this.geometry;(n.width!==r.width||n.height!==r.height||n.depth!==r.depth)&&e.updateGeometry({parameters:{width:n.width,height:n.height,depth:n.depth}})}if("material"in e&&this.material!==void 0){let t=e.material;if(t instanceof Array){let r=this.material;for(let n=0,s=r.length;n<s;++n){let o=t[n].layersList.head,a=r[n].layersList,l=0;for(;o;)o.copy(a[l++]),o=o.next;t[n].dispose()}}else{if(t.userData.isAsset)return;let r=0,n=t.layersList.head,o=this.material.layersList;for(;n;)n.copyUniforms(o[r++]),n=n.next;t.dispose()}}if(this.camera&&e.objectType==="CombinedCamera"&&(e=e,e.zoom=e.cameraType==="OrthographicCamera"?this.camera.zoomOrtho:this.camera.zoomPersp,e.targetOffset=this.camera.targetOffset,e.updateProjectionMatrix()),this.light&&(e.objectType==="LightDirectional"||e.objectType==="LightPoint"||e.objectType==="LightSpot")){e=e,e.intensity=this.light.intensity;let t=this.light.color;e.color.setRGB(t.r,t.g,t.b)}}copy(e){if(this.name=e.name,this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),this.hiddenMatrix.copy(e.hiddenMatrix),e.geometry!==void 0&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),e.material!==void 0)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t)this.material.push({layersList:e.material[t].layersList.map(n=>n.clone())})}else this.material={layersList:e.material.layersList.map(t=>t.clone())};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:e.camera.targetOffset}),e.light!==void 0&&(this.light={intensity:e.light.intensity,color:Ur.clone(e.light.color)}),this}clone(){return new Qi().copy(this)}toJSON(e){let t={uuid:this.uuid,name:this.name,position:this.position.toArray(),rotation:this.rotation.toArray(),scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};if(this.geometry!==void 0&&(t.geometry={width:this.geometry.width,height:this.geometry.height,depth:this.geometry.depth}),this.material!==void 0)if(this.material instanceof Array){t.material=[];for(let r=0,n=this.material.length;r<n;++r)t.material.push({layersList:this.material[r].layersList.map(s=>s.toJSON(e))})}else t.material={layersList:this.material.layersList.map(r=>r.toJSON(e))};return this.camera!==void 0&&(t.camera={zoomPersp:this.camera.zoomPersp,zoomOrtho:this.camera.zoomOrtho,targetOffset:this.camera.targetOffset}),t}fromJSON(e,t){var r;if(this.uuid=e.uuid,this.name=e.name,this.position.fromArray(e.position),this.rotation.fromArray(e.rotation),this.scale.fromArray(e.scale),this.hiddenMatrix.fromArray(e.hiddenMatrix),e.geometry!==void 0&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),e.material!==void 0)if(e.material instanceof Array){this.material=[];for(let n=0,s=e.material.length;n<s;++n)this.material.push({layersList:e.material[n].layersList.map(o=>Iy(o,t))})}else this.material={layersList:e.material.layersList.map(n=>Iy(n,t))};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:(r=e.camera.targetOffset)!=null?r:-1}),this}};"use strict";var rA={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Zy={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},lG=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],tp={CSS:{},springs:{}};function Ki(i,e,t){return Math.min(Math.max(i,e),t)}function Cu(i,e){return i.indexOf(e)>-1}function $y(i,e){return i.apply(null,e)}var qe={arr:function(i){return Array.isArray(i)},obj:function(i){return Cu(Object.prototype.toString.call(i),"Object")},pth:function(i){return qe.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||qe.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i=="undefined"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return qe.hex(i)||qe.rgb(i)||qe.hsl(i)},key:function(i){return!rA.hasOwnProperty(i)&&!Zy.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function nA(i){var e=/\(([^)]+)\)/.exec(i);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function iA(i,e){var t=nA(i),r=Ki(qe.und(t[0])?1:t[0],.1,100),n=Ki(qe.und(t[1])?100:t[1],.1,100),s=Ki(qe.und(t[2])?10:t[2],.1,100),o=Ki(qe.und(t[3])?0:t[3],.1,100),a=Math.sqrt(n/r),l=s/(2*Math.sqrt(n*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,d=l<1?(l*a+-o)/c:-o+a;function h(f){var g=e?e*f/1e3:f;return l<1?g=Math.exp(-g*l*a)*(u*Math.cos(c*g)+d*Math.sin(c*g)):g=(u+d*g)*Math.exp(-g*a),f===0||f===1?f:1-g}function p(){var f=tp.springs[i];if(f)return f;for(var g=1/6,v=0,y=0;;)if(v+=g,h(v)===1){if(y++,y>=16)break}else y=0;var m=v*g*1e3;return tp.springs[i]=m,m}return e?h:p}function cG(i){return i===void 0&&(i=10),function(e){return Math.ceil(Ki(e,1e-6,1)*i)*(1/i)}}var uG=function(){var i=11,e=1/(i-1);function t(u,d){return 1-3*d+3*u}function r(u,d){return 3*d-6*u}function n(u){return 3*u}function s(u,d,h){return((t(d,h)*u+r(d,h))*u+n(d))*u}function o(u,d,h){return 3*t(d,h)*u*u+2*r(d,h)*u+n(d)}function a(u,d,h,p,f){var g,v,y=0;do v=d+(h-d)/2,g=s(v,p,f)-u,g>0?h=v:d=v;while(Math.abs(g)>1e-7&&++y<10);return v}function l(u,d,h,p){for(var f=0;f<4;++f){var g=o(d,h,p);if(g===0)return d;var v=s(d,h,p)-u;d-=v/g}return d}function c(u,d,h,p){if(!(0<=u&&u<=1&&0<=h&&h<=1))return;var f=new Float32Array(i);if(u!==d||h!==p)for(var g=0;g<i;++g)f[g]=s(g*e,u,h);function v(y){for(var m=0,x=1,b=i-1;x!==b&&f[x]<=y;++x)m+=e;--x;var w=(y-f[x])/(f[x+1]-f[x]),T=m+w*e,S=o(T,u,h);return S>=.001?l(y,T,u,h):S===0?T:a(y,m,m+e,u,h)}return function(y){return u===d&&h===p||y===0||y===1?y:s(v(y),d,p)}}return c}(),sA=function(){var i={linear:function(){return function(r){return r}}},e={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var n,s=4;r<((n=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((n*3-2)/22-r,2)}},Elastic:function(r,n){r===void 0&&(r=1),n===void 0&&(n=.5);var s=Ki(r,1,10),o=Ki(n,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(r,n){e[r]=function(){return function(s){return Math.pow(s,n+2)}}}),Object.keys(e).forEach(function(r){var n=e[r];i["easeIn"+r]=n,i["easeOut"+r]=function(s,o){return function(a){return 1-n(s,o)(1-a)}},i["easeInOut"+r]=function(s,o){return function(a){return a<.5?n(s,o)(a*2)/2:1-n(s,o)(a*-2+2)/2}}}),i}();function ev(i,e){if(qe.fnc(i))return i;var t=i.split("(")[0],r=sA[t],n=nA(i);switch(t){case"spring":return iA(i,e);case"cubicBezier":return $y(uG,n);case"steps":return $y(cG,n);default:return $y(r,n)}}function oA(i){try{var e=document.querySelectorAll(i);return e}catch(t){return}}function rp(i,e){for(var t=i.length,r=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<t;s++)if(s in i){var o=i[s];e.call(r,o,s,i)&&n.push(o)}return n}function np(i){return i.reduce(function(e,t){return e.concat(qe.arr(t)?np(t):t)},[])}function aA(i){return qe.arr(i)?i:(qe.str(i)&&(i=oA(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function tv(i,e){return i.some(function(t){return t===e})}function rv(i){var e={};for(var t in i)e[t]=i[t];return e}function nv(i,e){var t=rv(i);for(var r in i)t[r]=e.hasOwnProperty(r)?e[r]:i[r];return t}function ip(i,e){var t=rv(i);for(var r in e)t[r]=qe.und(i[r])?e[r]:i[r];return t}function hG(i){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return e?"rgba("+e[1]+",1)":i}function dG(i){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=i.replace(e,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),n=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+n+","+s+","+o+",1)"}function fG(i){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),t=parseInt(e[1],10)/360,r=parseInt(e[2],10)/100,n=parseInt(e[3],10)/100,s=e[4]||1;function o(h,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?h+(p-h)*6*f:f<1/2?p:f<2/3?h+(p-h)*(2/3-f)*6:h}var a,l,c;if(r==0)a=l=c=n;else{var u=n<.5?n*(1+r):n+r-n*r,d=2*n-u;a=o(d,u,t+1/3),l=o(d,u,t),c=o(d,u,t-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function pG(i){if(qe.rgb(i))return hG(i);if(qe.hex(i))return dG(i);if(qe.hsl(i))return fG(i)}function _s(i){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(i);if(e)return e[1]}function mG(i){if(Cu(i,"translate")||i==="perspective")return"px";if(Cu(i,"rotate")||Cu(i,"skew"))return"deg"}function iv(i,e){return qe.fnc(i)?i(e.target,e.id,e.total):i}function Zi(i,e){return i.getAttribute(e)}function sv(i,e,t){var r=_s(e);if(tv([t,"deg","rad","turn"],r))return e;var n=tp.CSS[e+t];if(!qe.und(n))return n;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(e);return tp.CSS[e+t]=c,c}function lA(i,e,t){if(e in i.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=i.style[e]||getComputedStyle(i).getPropertyValue(r)||"0";return t?sv(i,n,t):n}}function ov(i,e){if(qe.dom(i)&&!qe.inp(i)&&(Zi(i,e)||qe.svg(i)&&i[e]))return"attribute";if(qe.dom(i)&&tv(lG,e))return"transform";if(qe.dom(i)&&e!=="transform"&&lA(i,e))return"css";if(i[e]!=null)return"object"}function cA(i){if(!!qe.dom(i)){for(var e=i.style.transform||"",t=/(\w+)\(([^)]*)\)/g,r=new Map,n;n=t.exec(e);)r.set(n[1],n[2]);return r}}function gG(i,e,t,r){var n=Cu(e,"scale")?1:0+mG(e),s=cA(i).get(e)||n;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),r?sv(i,s,r):s}function av(i,e,t,r){switch(ov(i,e)){case"transform":return gG(i,e,r,t);case"css":return lA(i,e,t);case"attribute":return Zi(i,e);default:return i[e]||0}}function lv(i,e){var t=/^(\*=|\+=|-=)/.exec(i);if(!t)return i;var r=_s(i)||0,n=parseFloat(e),s=parseFloat(i.replace(t[0],""));switch(t[0][0]){case"+":return n+s+r;case"-":return n-s+r;case"*":return n*s+r}}function uA(i,e){if(qe.col(i))return pG(i);if(/\s/g.test(i))return i;var t=_s(i),r=t?i.substr(0,i.length-t.length):i;return e?r+e:r}function cv(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function yG(i){return Math.PI*2*Zi(i,"r")}function vG(i){return Zi(i,"width")*2+Zi(i,"height")*2}function xG(i){return cv({x:Zi(i,"x1"),y:Zi(i,"y1")},{x:Zi(i,"x2"),y:Zi(i,"y2")})}function hA(i){for(var e=i.points,t=0,r,n=0;n<e.numberOfItems;n++){var s=e.getItem(n);n>0&&(t+=cv(r,s)),r=s}return t}function bG(i){var e=i.points;return hA(i)+cv(e.getItem(e.numberOfItems-1),e.getItem(0))}function dA(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return yG(i);case"rect":return vG(i);case"line":return xG(i);case"polyline":return hA(i);case"polygon":return bG(i)}}function wG(i){var e=dA(i);return i.setAttribute("stroke-dasharray",e),e}function SG(i){for(var e=i.parentNode;qe.svg(e)&&qe.svg(e.parentNode);)e=e.parentNode;return e}function fA(i,e){var t=e||{},r=t.el||SG(i),n=r.getBoundingClientRect(),s=Zi(r,"viewBox"),o=n.width,a=n.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function MG(i,e){var t=qe.str(i)?oA(i)[0]:i,r=e||100;return function(n){return{property:n,el:t,svg:fA(t),totalLength:dA(t)*(r/100)}}}function AG(i,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return i.el.getPointAtLength(l)}var r=fA(i.el,i.svg),n=t(),s=t(-1),o=t(1);switch(i.property){case"x":return(n.x-r.x)*r.w;case"y":return(n.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function pA(i,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=uA(qe.pth(i)?i.totalLength:i,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:qe.str(i)||e?r.split(t):[]}}function mA(i){var e=i?np(qe.arr(i)?i.map(aA):aA(i)):[];return rp(e,function(t,r,n){return n.indexOf(t)===r})}function gA(i){var e=mA(i);return e.map(function(t,r){return{target:t,id:r,total:e.length,transforms:{list:cA(t)}}})}function TG(i,e){var t=rv(e);if(/^spring/.test(t.easing)&&(t.duration=iA(t.easing)),qe.arr(i)){var r=i.length,n=r===2&&!qe.obj(i[0]);n?i={value:i}:qe.fnc(e.duration)||(t.duration=e.duration/r)}var s=qe.arr(i)?i:[i];return s.map(function(o,a){var l=qe.obj(o)&&!qe.pth(o)?o:{value:o};return qe.und(l.delay)&&(l.delay=a?0:e.delay),qe.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return ip(o,t)})}function _G(i){for(var e=rp(np(i.map(function(s){return Object.keys(s)})),function(s){return qe.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},r=function(s){var o=e[s];t[o]=i.map(function(a){var l={};for(var c in a)qe.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},n=0;n<e.length;n++)r(n);return t}function EG(i,e){var t=[],r=e.keyframes;r&&(e=ip(_G(r),e));for(var n in e)qe.key(n)&&t.push({name:n,tweens:TG(e[n],i)});return t}function CG(i,e){var t={};for(var r in i){var n=iv(i[r],e);qe.arr(n)&&(n=n.map(function(s){return iv(s,e)}),n.length===1&&(n=n[0])),t[r]=n}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function LG(i,e){var t;return i.tweens.map(function(r){var n=CG(r,e),s=n.value,o=qe.arr(s)?s[1]:s,a=_s(o),l=av(e.target,i.name,a,e),c=t?t.to.original:l,u=qe.arr(s)?s[0]:c,d=_s(u)||_s(l),h=a||d;return qe.und(o)&&(o=c),n.from=pA(u,h),n.to=pA(lv(o,u),h),n.start=t?t.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=ev(n.easing,n.duration),n.isPath=qe.pth(s),n.isColor=qe.col(n.from.original),n.isColor&&(n.round=1),t=n,n})}var yA={css:function(i,e,t){return i.style[e]=t},attribute:function(i,e,t){return i.setAttribute(e,t)},object:function(i,e,t){return i[e]=t},transform:function(i,e,t,r,n){if(r.list.set(e,t),e===r.last||n){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function vA(i,e){var t=gA(i);t.forEach(function(r){for(var n in e){var s=iv(e[n],r),o=r.target,a=_s(s),l=av(o,n,a,r),c=a||_s(l),u=lv(uA(s,c),l),d=ov(o,n);yA[d](o,n,u,r.transforms,!0)}})}function NG(i,e){var t=ov(i.target,e.name);if(t){var r=LG(e,i),n=r[r.length-1];return{type:t,property:e.name,animatable:i,tweens:r,duration:n.end,delay:r[0].delay,endDelay:n.endDelay}}}function PG(i,e){return rp(np(i.map(function(t){return e.map(function(r){return NG(t,r)})})),function(t){return!qe.und(t)})}function xA(i,e){var t=i.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},n={};return n.duration=t?Math.max.apply(Math,i.map(function(s){return r(s)+s.duration})):e.duration,n.delay=t?Math.min.apply(Math,i.map(function(s){return r(s)+s.delay})):e.delay,n.endDelay=t?n.duration-Math.max.apply(Math,i.map(function(s){return r(s)+s.duration-s.endDelay})):e.endDelay,n}var bA=0;function IG(i){var e=nv(rA,i),t=nv(Zy,i),r=EG(t,i),n=gA(i.targets),s=PG(n,r),o=xA(s,t),a=bA;return bA++,ip(e,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var _n=[],wA=[],sp,DG=function(){function i(){sp=requestAnimationFrame(e)}function e(t){var r=_n.length;if(r){for(var n=0;n<r;){var s=_n[n];if(!s.paused)s.tick(t);else{var o=_n.indexOf(s);o>-1&&(_n.splice(o,1),r=_n.length)}n++}i()}else sp=cancelAnimationFrame(sp)}return i}();function RG(){document.hidden?(_n.forEach(function(i){return i.pause()}),wA=_n.slice(0),Sr.running=_n=[]):wA.forEach(function(i){return i.play()})}typeof document!="undefined"&&document.addEventListener("visibilitychange",RG);function Sr(i){i===void 0&&(i={});var e=0,t=0,r=0,n,s=0,o=null;function a(x){var b=window.Promise&&new Promise(function(w){return o=w});return x.finished=b,b}var l=IG(i),c=a(l);function u(){var x=l.direction;x!=="alternate"&&(l.direction=x!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,n.forEach(function(b){return b.reversed=l.reversed})}function d(x){return l.reversed?l.duration-x:x}function h(){e=0,t=d(l.currentTime)*(1/Sr.speed)}function p(x,b){b&&b.seek(x-b.timelineOffset)}function f(x){if(l.reversePlayback)for(var w=s;w--;)p(x,n[w]);else for(var b=0;b<s;b++)p(x,n[b])}function g(x){var b=0,w=l.animations,T=w.length;for(l.reversePlayback===!0&&l.rewind===!1&&(x=l.duration-x);b<T;){var S=w[b],M=S.animatable,E=S.tweens,C=E.length-1,_=E[C];C&&(_=rp(E,function(ce){return x<ce.end})[0]||_);for(var O=Ki(x-_.start-_.delay,0,_.duration)/_.duration,P=isNaN(O)?1:_.easing(O),D=_.to.strings,G=_.round,R=[],U=_.to.numbers.length,te=void 0,he=0;he<U;he++){var H=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var z=_.to.numbers[he],B=_.from.numbers[he]||0;else var B=_.to.numbers[he],z=_.from.numbers[he]||0;_.isPath?H=AG(_.value,P*B):H=z+P*(B-z),G&&(_.isColor&&he>2||(H=Math.round(H*G)/G)),R.push(H)}var Y=D.length;if(!Y)te=R[0];else{te=D[0];for(var q=0;q<Y;q++){var ee=D[q],k=D[q+1],pe=R[q];isNaN(pe)||(k?te+=pe+k:te+=pe+" ")}}yA[S.type](M.target,S.property,te,M.transforms),S.currentValue=te,b++}}function v(x){l[x]&&!l.passThrough&&l[x](l)}function y(){l.remaining&&l.remaining!==!0&&l.remaining--}function m(x){var b=l.duration,w=l.delay,T=b-l.endDelay,S=d(x);l.progress=Ki(S/b*100,0,100),l.reversePlayback=S<l.currentTime,n&&f(S),!l.began&&l.currentTime>=0&&(l.began=!0,v("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,v("loopBegin")),S<=w&&l.currentTime!==0&&g(0),(S>=T&&l.currentTime!==b||!b)&&g(b),S>w&&S<T?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,v("changeBegin")),v("change"),g(S)):l.changeBegan&&(l.changeCompleted=!0,l.changeBegan=!1,v("changeComplete")),l.currentTime=Ki(S,0,b),l.began&&v("update"),x>=b&&(t=0,y(),l.remaining?(e=r,v("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&u()):(l.paused=!0,l.completed||(l.completed=!0,v("loopComplete"),v("complete"),!l.passThrough&&"Promise"in window&&(o(),c=a(l)))))}return l.reset=function(){var x=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=x==="reverse",l.remaining=l.loop,n=l.children,s=n.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||x==="alternate"&&l.loop===1)&&l.remaining++,g(l.reversed?l.duration:0)},l.set=function(x,b){return vA(x,b),l},l.tick=function(x){r=x,e||(e=r),m((r+(t-e))*Sr.speed)},l.seek=function(x){m(d(x))},l.pause=function(){l.paused=!0,h()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,_n.push(l),h(),sp||DG())},l.reverse=function(){u(),l.completed=!l.reversed,h()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function SA(i,e){for(var t=e.length;t--;)tv(i,e[t].animatable.target)&&e.splice(t,1)}function OG(i){for(var e=mA(i),t=_n.length;t--;){var r=_n[t],n=r.animations,s=r.children;SA(e,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;SA(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!n.length&&!s.length&&r.pause()}}function BG(i,e){e===void 0&&(e={});var t=e.direction||"normal",r=e.easing?ev(e.easing):null,n=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",c=o==="last",u=qe.arr(i),d=parseFloat(u?i[0]:i),h=u?parseFloat(i[1]):0,p=_s(u?i[1]:i)||0,f=e.start||0+(u?d:0),g=[],v=0;return function(y,m,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!g.length){for(var b=0;b<x;b++){if(!n)g.push(Math.abs(o-b));else{var w=l?(n[0]-1)/2:o%n[0],T=l?(n[1]-1)/2:Math.floor(o/n[0]),S=b%n[0],M=Math.floor(b/n[0]),E=w-S,C=T-M,_=Math.sqrt(E*E+C*C);s==="x"&&(_=-E),s==="y"&&(_=-C),g.push(_)}v=Math.max.apply(Math,g)}r&&(g=g.map(function(P){return r(P/v)*v})),t==="reverse"&&(g=g.map(function(P){return s?P<0?P*-1:-P:Math.abs(v-P)}))}var O=u?(h-d)/v:d;return f+O*(Math.round(g[m]*100)/100)+p}}function FG(i){i===void 0&&(i={});var e=Sr(i);return e.duration=0,e.add=function(t,r){var n=_n.indexOf(e),s=e.children;n>-1&&_n.splice(n,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=ip(t,nv(Zy,i));l.targets=l.targets||i.targets;var c=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=qe.und(r)?c:lv(r,c),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var u=Sr(l);o(u),s.push(u);var d=xA(s,i);return e.delay=d.delay,e.endDelay=d.endDelay,e.duration=d.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}Sr.version="3.2.0";Sr.speed=1;Sr.running=_n;Sr.remove=OG;Sr.get=av;Sr.set=vA;Sr.convertPx=sv;Sr.path=MG;Sr.setDashoffset=wG;Sr.stagger=BG;Sr.timeline=FG;Sr.easing=ev;Sr.penner=sA;Sr.random=function(i,e){return Math.floor(Math.random()*(e-i+1))+i};var Lu=Sr;function MA(i){var o;let e=[],t=i.groups,r=i.getAttribute("position").array,n=i.getAttribute("normal").array,s=(o=i.getAttribute("uv"))==null?void 0:o.array;return t.forEach(a=>{let l=a.count,c=new _e,u=new Float32Array(l*3),d=new Float32Array(l*3),h=new Float32Array(l*2);for(let p=0;p<l;p++){let f=3*(a.start+p),g=3*p;if(u[g]=r[f],u[g+1]=r[f+1],u[g+2]=r[f+2],d[g]=n[f],d[g+1]=n[f+1],d[g+2]=n[f+2],s){let v=2*(a.start+p),y=2*p;h[y]=s[v],h[y+1]=s[v+1]}}c.setAttribute("position",new Ae(u,3)),c.setAttribute("normal",new Ae(d,3)),s&&c.setAttribute("uv",new Ae(h,2)),e.push(c)}),e}var Nu=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new NA(e)}),this.register(function(e){return new PA(e)}),this.register(function(e){return new IA(e)}),this.register(function(e){return new DA(e)}),this.register(function(e){return new RA(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r){let n=new LA,s=[];for(let o=0,a=this.pluginCallbacks.length;o<a;o++)s.push(this.pluginCallbacks[o](n));n.setPlugins(s),n.write(e,t,r)}},Bt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},kn={};kn[tr]=Bt.NEAREST;kn[ah]=Bt.NEAREST_MIPMAP_NEAREST;kn[lh]=Bt.NEAREST_MIPMAP_LINEAR;kn[tt]=Bt.LINEAR;kn[Dp]=Bt.LINEAR_MIPMAP_NEAREST;kn[Li]=Bt.LINEAR_MIPMAP_LINEAR;kn[ar]=Bt.CLAMP_TO_EDGE;kn[Os]=Bt.REPEAT;kn[hc]=Bt.MIRRORED_REPEAT;var AA={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},TA=12,GG=1179937895,zG=2,_A=8,UG=1313821514,kG=5130562;function Pu(i,e){return i.length===e.length&&i.every(function(t,r){return t===e[r]})}function VG(i){if(window.TextEncoder!==void 0)return new TextEncoder().encode(i).buffer;let e=new Uint8Array(new ArrayBuffer(i.length));for(let t=0,r=i.length;t<r;t++){let n=i.charCodeAt(t);e[t]=n>255?32:n}return e.buffer}function HG(i){return Pu(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function jG(i,e,t){let r={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=e;n<e+t;n++)for(let s=0;s<i.itemSize;s++){let o;i.itemSize>4?o=i.array[n*i.itemSize+s]:s===0?o=i.getX(n):s===1?o=i.getY(n):s===2?o=i.getZ(n):s===3&&(o=i.getW(n)),r.min[s]=Math.min(r.min[s],o),r.max[s]=Math.max(r.max[s],o)}return r}function EA(i){return Math.ceil(i/4)*4}function uv(i,e=0){let t=EA(i.byteLength);if(t!==i.byteLength){let r=new Uint8Array(t);if(r.set(new Uint8Array(i)),e!==0)for(let n=i.byteLength;n<t;n++)r[n]=e;return r.buffer}return i}var CA=null,LA=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);let n=this;Promise.all(this.pending).then(function(){let s=n.buffers,o=n.json,a=n.options,l=n.extensionsUsed,c=new Blob(s,{type:"application/octet-stream"}),u=Object.keys(l);if(u.length>0&&(o.extensionsUsed=u),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),a.binary===!0){let d=new window.FileReader;d.readAsArrayBuffer(c),d.onloadend=function(){let h=uv(d.result),p=new DataView(new ArrayBuffer(_A));p.setUint32(0,h.byteLength,!0),p.setUint32(4,kG,!0);let f=uv(VG(JSON.stringify(o)),32),g=new DataView(new ArrayBuffer(_A));g.setUint32(0,f.byteLength,!0),g.setUint32(4,UG,!0);let v=new ArrayBuffer(TA),y=new DataView(v);y.setUint32(0,GG,!0),y.setUint32(4,zG,!0);let m=TA+g.byteLength+f.byteLength+p.byteLength+h.byteLength;y.setUint32(8,m,!0);let x=new Blob([v,g,f,p,h],{type:"application/octet-stream"}),b=new window.FileReader;b.readAsArrayBuffer(x),b.onloadend=function(){t(b.result)}}}else if(o.buffers&&o.buffers.length>0){let d=new window.FileReader;d.readAsDataURL(c),d.onloadend=function(){let h=d.result;o.buffers[0].uri=h,t(o)}}else t(o)})}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let r=this.options,n=this.extensionsUsed;try{let s=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],n[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let r=new A;for(let n=0,s=e.count;n<s;n++)if(Math.abs(r.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let r=e.clone(),n=new A;for(let s=0,o=r.count;s<o;s++)n.fromBufferAttribute(r,s),n.x===0&&n.y===0&&n.z===0?n.setX(1):n.normalize(),r.setXYZ(s,n.x,n.y,n.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1,n={};(t.offset.x!==0||t.offset.y!==0)&&(n.offset=t.offset.toArray(),r=!0),t.rotation!==0&&(n.rotation=t.rotation,r=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(n.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){let t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,n,s){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;t===Bt.UNSIGNED_BYTE?a=1:t===Bt.UNSIGNED_SHORT?a=2:a=4;let l=EA(n*e.itemSize*a),c=new DataView(new ArrayBuffer(l)),u=0;for(let p=r;p<r+n;p++)for(let f=0;f<e.itemSize;f++){let g;e.itemSize>4?g=e.array[p*e.itemSize+f]:f===0?g=e.getX(p):f===1?g=e.getY(p):f===2?g=e.getZ(p):f===3&&(g=e.getW(p)),t===Bt.FLOAT?c.setFloat32(u,g,!0):t===Bt.UNSIGNED_INT?c.setUint32(u,g,!0):t===Bt.UNSIGNED_SHORT?c.setUint16(u,g,!0):t===Bt.UNSIGNED_BYTE&&c.setUint8(u,g),u+=a}let d={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(d.target=s),s===Bt.ARRAY_BUFFER&&(d.byteStride=e.itemSize*a),this.byteOffset+=l,o.bufferViews.push(d),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(n){let s=new window.FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){let o=uv(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,n(r.bufferViews.push(a)-1)}})}processAccessor(e,t,r,n){let s=this.options,o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"},l;if(e.array.constructor===Float32Array)l=Bt.FLOAT;else if(e.array.constructor===Uint32Array)l=Bt.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)l=Bt.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)l=Bt.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(r===void 0&&(r=0),n===void 0&&(n=e.count),s.truncateDrawRange&&t!==void 0&&t.index===null){let p=r+n,f=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;r=Math.max(r,t.drawRange.start),n=Math.min(p,f)-r,n<0&&(n=0)}if(n===0)return null;let c=jG(e,r,n),u;t!==void 0&&(u=e===t.index?Bt.ELEMENT_ARRAY_BUFFER:Bt.ARRAY_BUFFER);let d=this.processBufferView(e,l,r,n,u),h={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:n,max:c.max,min:c.min,type:a[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(h)-1}processImage(e,t,r){let n=this,s=n.cache,o=n.json,a=n.options,l=n.pending;s.images.has(e)||s.images.set(e,{});let c=s.images.get(e),u=t===Qt?"image/png":"image/jpeg",d=u+":flipY/"+r.toString();if(c[d]!==void 0)return c[d];o.images||(o.images=[]);let h={mimeType:u};if(a.embedImages){let f=CA=CA||document.createElement("canvas");f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let g=f.getContext("2d");if(r===!0&&(g.translate(0,f.height),g.scale(1,-1)),typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)g.drawImage(e,0,0,f.width,f.height);else{t!==Qt&&t!==jt&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let v=new Uint8ClampedArray(e.height*e.width*4);if(t===Qt)for(let y=0;y<v.length;y+=4)v[y+0]=e.data[y+0],v[y+1]=e.data[y+1],v[y+2]=e.data[y+2],v[y+3]=e.data[y+3];else for(let y=0,m=0;y<v.length;y+=4,m+=3)v[y+0]=e.data[m+0],v[y+1]=e.data[m+1],v[y+2]=e.data[m+2],v[y+3]=255;g.putImageData(new ImageData(v,e.width,e.height),0,0)}a.binary===!0?l.push(new Promise(function(v){f.toBlob(function(y){n.processBufferViewImage(y).then(function(m){h.bufferView=m,v()})},u)})):h.uri=f.toDataURL(u)}else h.uri=e.src;let p=o.images.push(h)-1;return c[d]=p,p}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let r={magFilter:kn[e.magFilter],minFilter:kn[e.minFilter],wrapS:kn[e.wrapS],wrapT:kn[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){let t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);let n={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(n.name=e.name),this._invokeAll(function(o){o.writeTexture&&o.writeTexture(e,n)});let s=r.textures.push(n)-1;return t.textures.set(e,s),s}processMaterial(e){let t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);let n={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(Pu(s,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap)if(e.metalnessMap===e.roughnessMap){let a={index:this.processTexture(e.metalnessMap)};this.applyTextureTransform(a,e.metalnessMap),n.pbrMetallicRoughness.metallicRoughnessTexture=a}else console.warn("THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.");if(e.map){let a={index:this.processTexture(e.map)};this.applyTextureTransform(a,e.map),n.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){let a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),l=Math.max(a.r,a.g,a.b);if(l>1&&(a.multiplyScalar(1/l),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),l>0&&(n.emissiveFactor=a.toArray()),e.emissiveMap){let c={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(c,e.emissiveMap),n.emissiveTexture=c}}if(e.normalMap){let a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),n.normalTexture=a}if(e.aoMap){let a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),n.occlusionTexture=a}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),e.side===Yt&&(n.doubleSided=!0),e.name!==""&&(n.name=e.name),this.serializeUserData(e,n),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,n)});let o=r.materials.push(n)-1;return t.materials.set(e,o),o}processMesh(e){let t=this.cache,r=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,b=e.material.length;x<b;x++)n.push(e.material[x].uuid);else n.push(e.material.uuid);let s=n.join(":");if(t.meshes.has(s))return t.meshes.get(s);let o=e.geometry,a;if(e.isLineSegments?a=Bt.LINES:e.isLineLoop?a=Bt.LINE_LOOP:e.isLine?a=Bt.LINE_STRIP:e.isPoints?a=Bt.POINTS:a=e.material.wireframe?Bt.LINES:Bt.TRIANGLES,o.isBufferGeometry!==!0)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");let l={},c={},u=[],d=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=o.getAttribute("normal");p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let f=null;for(let x in o.attributes){if(x.substr(0,5)==="morph")continue;let b=o.attributes[x];if(x=h[x]||x.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(x)||(x="_"+x),t.attributes.has(this.getUID(b))){c[x]=t.attributes.get(this.getUID(b));continue}f=null;let T=b.array;x==="JOINTS_0"&&!(T instanceof Uint16Array)&&!(T instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new Fe(new Uint16Array(T),b.itemSize,b.normalized));let S=this.processAccessor(f||b,o);S!==null&&(c[x]=S,t.attributes.set(this.getUID(b),S))}if(p!==void 0&&o.setAttribute("normal",p),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let x=[],b=[],w={};if(e.morphTargetDictionary!==void 0)for(let T in e.morphTargetDictionary)w[e.morphTargetDictionary[T]]=T;for(let T=0;T<e.morphTargetInfluences.length;++T){let S={},M=!1;for(let E in o.morphAttributes){if(E!=="position"&&E!=="normal"){M||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),M=!0);continue}let C=o.morphAttributes[E][T],_=E.toUpperCase(),O=o.attributes[E];if(t.attributes.has(this.getUID(C))){S[_]=t.attributes.get(this.getUID(C));continue}let P=C.clone();if(!o.morphTargetsRelative)for(let D=0,G=C.count;D<G;D++)P.setXYZ(D,C.getX(D)-O.getX(D),C.getY(D)-O.getY(D),C.getZ(D)-O.getZ(D));S[_]=this.processAccessor(P,o),t.attributes.set(this.getUID(O),S[_])}d.push(S),x.push(e.morphTargetInfluences[T]),e.morphTargetDictionary!==void 0&&b.push(w[T])}l.weights=x,b.length>0&&(l.extras={},l.extras.targetNames=b)}let g=Array.isArray(e.material);if(g&&o.groups.length===0)return null;let v=g?e.material:[e.material],y=g?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,b=y.length;x<b;x++){let w={mode:a,attributes:c};if(this.serializeUserData(o,w),d.length>0&&(w.targets=d),o.index!==null){let S=this.getUID(o.index);(y[x].start!==void 0||y[x].count!==void 0)&&(S+=":"+y[x].start+":"+y[x].count),t.attributes.has(S)?w.indices=t.attributes.get(S):(w.indices=this.processAccessor(o.index,o,y[x].start,y[x].count),t.attributes.set(S,w.indices)),w.indices===null&&delete w.indices}let T=this.processMaterial(v[y[x].materialIndex]);T!==null&&(w.material=T),u.push(w)}l.primitives=u,r.meshes||(r.meshes=[]),this._invokeAll(function(x){x.writeMesh&&x.writeMesh(e,l)});let m=r.meshes.push(l)-1;return t.meshes.set(s,m),m}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let r=e.isOrthographicCamera,n={type:r?"orthographic":"perspective"};return r?n.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:rt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(n.name=e.type),t.cameras.push(n)-1}processAnimation(e,t){let r=this.json,n=this.nodeMap;r.animations||(r.animations=[]),e=Nu.Utils.mergeMorphTargetTracks(e.clone(),t);let s=e.tracks,o=[],a=[];for(let l=0;l<s.length;++l){let c=s[l],u=lt.parseTrackName(c.name),d=lt.findNode(t,u.nodeName),h=AA[u.propertyName];if(u.objectName==="bones"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(u.objectIndex):d=void 0),!d||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name),null;let p=1,f=c.values.length/c.times.length;h===AA.morphTargetInfluences&&(f/=d.morphTargetInfluences.length);let g;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(g="CUBICSPLINE",f/=3):c.getInterpolation()===Ma?g="STEP":g="LINEAR",a.push({input:this.processAccessor(new Fe(c.times,p)),output:this.processAccessor(new Fe(c.values,f)),interpolation:g}),o.push({sampler:a.length-1,target:{node:n.get(d),path:h}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:a,channels:o}),r.animations.length-1}processSkin(e){let t=this.json,r=this.nodeMap,n=t.nodes[r.get(e)],s=e.skeleton;if(s===void 0)return null;let o=e.skeleton.bones[0];if(o===void 0)return null;let a=[],l=new Float32Array(s.bones.length*16),c=new Me;for(let d=0;d<s.bones.length;++d)a.push(r.get(s.bones[d])),c.copy(s.boneInverses[d]),c.multiply(e.bindMatrix).toArray(l,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Fe(l,16)),joints:a,skeleton:r.get(o)}),n.skin=t.skins.length-1}processNode(e){let t=this.json,r=this.options,n=this.nodeMap;t.nodes||(t.nodes=[]);let s={};if(r.trs){let a=e.quaternion.toArray(),l=e.position.toArray(),c=e.scale.toArray();Pu(a,[0,0,0,1])||(s.rotation=a),Pu(l,[0,0,0])||(s.translation=l),Pu(c,[1,1,1])||(s.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),HG(e.matrix)===!1&&(s.matrix=e.matrix.elements);if(e.name!==""&&(s.name=String(e.name)),this.serializeUserData(e,s),e.isMesh||e.isLine||e.isPoints){let a=this.processMesh(e);a!==null&&(s.mesh=a)}else e.isCamera&&(s.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let a=[];for(let l=0,c=e.children.length;l<c;l++){let u=e.children[l];if(u.visible||r.onlyVisible===!1){let d=this.processNode(u);d!==null&&a.push(d)}}a.length>0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});let o=t.nodes.push(s)-1;return n.set(e,o),o}processScene(e){let t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);let n={};e.name!==""&&(n.name=e.name),t.scenes.push(n);let s=[];for(let o=0,a=e.children.length;o<a;o++){let l=e.children[o];if(l.visible||r.onlyVisible===!1){let c=this.processNode(l);c!==null&&s.push(c)}}s.length>0&&(n.nodes=s),this.serializeUserData(e,n)}processObjects(e){let t=new Gr;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(n){n.beforeParse&&n.beforeParse(e)});let r=[];for(let n=0;n<e.length;n++)e[n]instanceof Gr?this.processScene(e[n]):r.push(e[n]);r.length>0&&this.processObjects(r);for(let n=0;n<this.skins.length;++n)this.processSkin(this.skins[n]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll(function(n){n.afterParse&&n.afterParse(e)})}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}},NA=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let r=this.writer,n=r.json,s=r.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(n.extensions=n.extensions||{},n.extensions[this.name]={lights:[]},s[this.name]=!0);let a=n.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},PA=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},IA=class{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let r=this.writer,n=r.extensionsUsed,s={};t.pbrMetallicRoughness.baseColorFactor&&(s.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let o=[1,1,1];if(e.specular.toArray(o,0),s.specularFactor=o,s.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(s.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let a={index:r.processTexture(e.specularMap)};r.applyTextureTransform(a,e.specularMap),s.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}},DA=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let r=this.writer,n=r.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){let o={index:r.processTexture(e.transmissionMap)};r.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}},RA=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.thickness===0)return;let r=this.writer,n=r.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){let o={index:r.processTexture(e.thicknessMap)};r.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationTint.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}};Nu.Utils={insertKeyframe:function(i,e){let t=.001,r=i.getValueSize(),n=new i.TimeBufferType(i.times.length+1),s=new i.ValueBufferType(i.values.length+r),o=i.createInterpolant(new i.ValueBufferType(r)),a;if(i.times.length===0){n[0]=e;for(let l=0;l<r;l++)s[l]=0;a=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<t)return 0;n[0]=e,n.set(i.times,1),s.set(o.evaluate(e),0),s.set(i.values,r),a=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<t)return i.times.length-1;n[n.length-1]=e,n.set(i.times,0),s.set(i.values,0),s.set(o.evaluate(e),i.values.length),a=n.length-1}else for(let l=0;l<i.times.length;l++){if(Math.abs(i.times[l]-e)<t)return l;if(i.times[l]<e&&i.times[l+1]>e){n.set(i.times.slice(0,l+1),0),n[l+1]=e,n.set(i.times.slice(l+1),l+2),s.set(i.values.slice(0,(l+1)*r),0),s.set(o.evaluate(e),(l+1)*r),s.set(i.values.slice((l+1)*r),(l+2)*r),a=l+1;break}}return i.times=n,i.values=s,a},mergeMorphTargetTracks:function(i,e){let t=[],r={},n=i.tracks;for(let s=0;s<n.length;++s){let o=n[s],a=lt.parseTrackName(o.name),l=lt.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(Aa)}let c=l.morphTargetInfluences.length,u=l.morphTargetDictionary[a.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let d;if(r[l.uuid]===void 0){d=o.clone();let p=new d.ValueBufferType(c*d.times.length);for(let f=0;f<d.times.length;f++)p[f*c+u]=d.values[f];d.name=(a.nodeName||"")+".morphTargetInfluences",d.values=p,r[l.uuid]=d,t.push(d);continue}let h=o.createInterpolant(new o.ValueBufferType(1));d=r[l.uuid];for(let p=0;p<d.times.length;p++)d.values[p*c+u]=h.evaluate(d.times[p]);for(let p=0;p<o.times.length;p++){let f=this.insertKeyframe(d,o.times[p]);d.values[f*c+u]=o.values[p]}}return i.tracks=t,i}};var WG,OA=new Promise(i=>{WG=i});var zA=Hv(GA());var ap={isPublish:!1,gltfQueue:[]};function Iu(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var $G=new Nu;function UA(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(ap.isPublish)e=Pf.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let n=e.originalGeometry;if(n){let s=e.userData;e=n.clone(),e.userData=s}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let n=e.userData;e=r,e.userData=n}if(!ap.isPublish)i[e.uuid]=e.toJSON();else{let n={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(n.name=e.name),Object.keys(e.userData).length>0&&(n.userData=re({},e.userData));let s=e.index===null,o=new Oi;if(Array.isArray(t))MA(e).forEach((l,c)=>{let u=new Wt(l,new il);o.add(u),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(s=!0)});else{let a=new Wt(e,new il);o.add(a)}ap.gltfQueue.push(new Promise(async a=>{await Promise.all(ap.gltfQueue),$G.parse(o,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:u,addIndex:d}=await OA,h=c.readJSON({json:gg(l),resources:{}});h.createExtension(u).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),s&&await h.transform(d);try{let{json:p,resources:f}=c.writeJSON(h),g=zA.default.fromByteArray(new Uint8Array(f[".bin"]));p.buffers[0].uri=`data:application/octet-stream;base64,${g}`,a()}catch(p){a()}},{})})),i[e.uuid]=n}}else{let r=e.userData;if(r.type==="VectorGeometry"){let n=e.userData.shape;r=Object.assign({},r,{shape:n.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function Zl(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function kA(i){let e=[];for(let t in i)e.push(i[t]);return e}var Es;(function(r){r[r.started=0]="started",r[r.ended=1]="ended",r[r.once=2]="once"})(Es||(Es={}));var Mi=class{constructor(e){this.object=e;this.uuid=rt.generateUUID();this.states=[];this.events=[];this._scrollCounter=null;this._interpolateMaterialBetweenValues=(e,t,r,n=t.getNames())=>{var s,o,a,l,c;for(let u=0,d=n.length;u<d;++u){let h=n[u],p=`f${t.id}_${h}`,f=`f${r.id}_${h}`,g=t.uniforms[p],v=r.uniforms[f];if(!(!g||g.value===void 0||v===void 0)){if(h==="mode"){g.value!==v.value&&(g.value=v.value);continue}if(typeof g.value=="boolean"){g.value!==v.value&&(g.value=v.value);continue}if(typeof g.value=="number"){g.value!==v.value&&((s=this._animation)==null||s.add({targets:g,value:Number(v.value)},0));continue}if("isVector2"in g.value){g.value.equals(v.value)===!1&&((o=this._animation)==null||o.add({targets:g,x:v.value.x,y:v.value.y},0));continue}if("isVector3"in g.value){g.value.equals(v.value)===!1&&((a=this._animation)==null||a.add({targets:g,x:v.value.x,y:v.value.y,z:v.value.z},0));continue}if("isColor"in g.value){g.value.equals(v.value)===!1&&((l=this._animation)==null||l.add({targets:g.value,r:v.value.r,g:v.value.g,b:v.value.b},0));continue}}}if(t.backLayer){let d=`f${t.backLayer.id}_alpha`,h=t.backLayer.uniforms[d];(c=this._animation)==null||c.add({targets:h,value:0},0)}};this._interpolateMaterialBetweenLayers=(e,t,r)=>{var c,u,d;let n=e.layersList;if(t.backLayer===void 0){let h=r.getValues();h.alpha=0,t.backLayer=n.addLayerBeforeAt(h,t),t.backLayer.isBack=!0,e.dispose()}let s=`f${t.id}_alpha`,o=`f${(c=t.backLayer)==null?void 0:c.id}_alpha`,a=t.uniforms[s],l=(u=t.backLayer)==null?void 0:u.uniforms[o];(d=this._animation)==null||d.add({targets:a,value:0},0).add({targets:l,value:r.uniforms[`f${r.id}_alpha`].value},0)};this._interpolateMaterialTexture=(e,t,r)=>{var h;let n=`f${t.id}_texture`,s=t.uniforms[n].value,o=r.uniforms[`f${r.id}_texture`].value,a=t.uniforms[`f${t.id}_crop`],l=r.uniforms[`f${r.id}_crop`];a&&l&&a.value!==l.value&&(a.value=Number(l.value)),(s.wrapS!==o.wrapS||s.wrapT!==o.wrapT)&&(s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.needsUpdate=!0);let c=s.matrix,u=o.matrix;if(c.equals(u)===!1){let p={repeatX:s.repeat.x,repeatY:s.repeat.y,offsetX:s.offset.x,offsetY:s.offset.y};(h=this._animation)==null||h.add({targets:p,repeatX:o.repeat.x,repeatY:o.repeat.y,offsetX:o.offset.x,offsetY:o.offset.y,update:()=>{s.repeat.set(p.repeatX,p.repeatY),s.offset.set(p.offsetX,p.offsetY),s.updateMatrix(),s.needsUpdate=!0}},0)}let d=["alpha","mode"];t.type==="displace_map"&&d.push("intensity"),this._interpolateMaterialBetweenValues(e,t,r,d)};this._interpolateMaterialGradient=(e,t,r)=>{var p;let n=10,s=`f${t.id}_steps`,o=`f${r.id}_steps`,a=t.uniforms[s],l=r.uniforms[o],c=`f${t.id}_colors`,u=`f${r.id}_colors`,d=t.uniforms[c],h=r.uniforms[u];for(let f=0;f<n;++f){let g=d.value[f],v=h.value[f];if(a.value[f]!==l.value[f]||!g.equals(v)){let y={value:a.value[f]};(p=this._animation)==null||p.add({targets:[y,g],value:l.value[f],x:v.x,y:v.y,z:v.z,w:v.w,update:()=>{a.value[f]=y.value}},0)}}this._interpolateMaterialBetweenValues(e,t,r,["alpha","mode","gradientType","smooth","offset","morph","angle","origin","direction","near","far"])}}static get isAllAnimationsEnded(){let e;for(let t in Mi.isAnimating){if(Mi.isAnimating[t]===2)return Mi.isAnimating[t]=1,!1;if(Mi.isAnimating[t]===0)return!1;e=!0}return e}computeCache(){return this.cache={mouseDown:this.events.find(e=>e.type===Je.MOUSE_DOWN),mouseUp:this.events.find(e=>e.type===Je.MOUSE_UP),mouseHover:this.events.find(e=>e.type===Je.MOUSE_HOVER),start:this.events.find(e=>e.type===Je.START),lookAt:this.events.find(e=>e.type===Je.LOOK_AT),follow:this.events.find(e=>e.type===Je.FOLLOW),keyDown:this.events.filter(e=>e.type===Je.KEY_DOWN),keyUp:this.events.filter(e=>e.type===Je.KEY_UP),scroll:this.events.find(e=>e.type===Je.SCROLL)},this.cache}newState(e){let t=new Qi;return t.name=e,t.update(this.object),this.states.push(t),t}addState(e,t){this.states.splice(t,0,e)}removeState(e){this.states.splice(e,1)}selectState(e){e!==void 0&&this.states[e].execute(this.object)}hasEventType(e,t){return e===Je.KEY_DOWN||e===Je.KEY_UP?t===void 0?!1:this.events.some(r=>r.type===e&&r.key===t):this.events.some(r=>r.type===e)}newEvent(){let e=[Je.MOUSE_DOWN,Je.MOUSE_UP,Je.MOUSE_HOVER,Je.KEY_DOWN].find(r=>this.hasEventType(r)===!1),t=new vo(e);return this.events.push(t),t}addEvent(e,t){this.events.splice(t,0,e);let r=this.events[t].targets;for(let n=0,s=r.length;n<s;++n)r[n].object!==void 0&&aa.add(r[n])}removeEvent(e){let t=this.events[e].targets;for(let r=0,n=t.length;r<n;++r)t[r].object!==void 0&&aa.delete(t[r]);this.events.splice(e,1)}copy(e){for(let t=0,r=e.states.length;t<r;++t)this.addState(e.states[t].clone(),t);for(let t=0,r=e.events.length;t<r;++t){this.addEvent(e.events[t].clone(),t);let n=e.events[t].targets;for(let s=0,o=n.length;s<o;++s){let a=n[s].clone();n[s].object===e.object?(a.object=this.object,a.state=this.states[e.states.indexOf(n[s].state)]):(a.object=n[s].object,a.state=n[s].state),this.events[t].addTarget(a,s)}}return this}clone(e){return new Mi(e).copy(this)}toJSON(e){e===void 0&&(e={nodes:{},geometries:{},materials:{},textures:{},images:{},interactionStates:{}});let t={uuid:this.uuid};if(this.states.length>0){t.states=[];for(let r=0,n=this.states.length;r<n;++r)t.states.push(Iu(e.interactionStates,this.states[r],e))}if(this.events.length>0){t.events=[];for(let r=0,n=this.events.length;r<n;++r)t.events.push(this.events[r].toJSON())}return t}fromJSON(e,t,r){var n;if(this.uuid=e.uuid,this.states=[],this.events=[],e.states!==void 0)for(let s=0,o=e.states.length;s<o;++s){let a=r[e.states[s]];this.states.push(a),((n=a.camera)==null?void 0:n.targetOffset)===-1&&(a.camera.targetOffset=this.object.getDistanceToTarget())}if(e.events!==void 0)for(let s=0,o=e.events.length;s<o;++s)this.events.push(new vo().fromJSON(e.events[s],t,r));return this}start(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._scrollCounter=null,this._removeBackLayer()),this.states.length>1?(this.states[0].execute(this.object),this._currentState=this.states[0],this._prevState=void 0):this._state0!==void 0?this._state0.execute(this.object):this.events.some(e=>e.type===Je.LOOK_AT||e.type===Je.FOLLOW)&&(this._state0=new Qi,this._state0.update(this.object))}end(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._removeBackLayer()),this.states.length>1?this.states[0].execute(this.object):this._state0!==void 0&&(this._state0.execute(this.object),this._state0=void 0),this._currentState=void 0,this._prevState=void 0}lookAt(e){var t;this.object.lookAt(e),this.object.updateMatrix(),(t=this._animation)==null||t.finished.then(()=>{this.lookAt(e),this.object.updateMatrix()})}follow(e){this.object.position.copy(e),this.object.parent!==null&&this.object.position.applyMatrix4(new Me().copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4(new Me().copy(this.object.hiddenMatrix).invert()),this.object.updateMatrix()}play(e){this.object.visible&&e.state!==void 0&&this.animate(e.state,e)}seek(e,t,r){var n;this._scrollCounter===null&&(this.object.visible&&e.state!==void 0&&this.animate(e.state,e,!0),this._scrollCounter=0),this._scrollCounter+=t,this._scrollCounter=Math.min(Math.max(this._scrollCounter,0),r),Mi.isAnimating[e.state.uuid]=2,(n=this._animation)==null||n.seek(this._scrollCounter/r*e.duration)}reverse(e){this.object.visible&&this._prevState!==void 0&&this.animate(this._prevState,e)}_removeBackLayer(){if("material"in this.object){let e=this.object.material;if(e instanceof Array)for(let t=0,r=e.length;t<r;++t){let n=e[t].layersList,s=n.head;for(;s;)if(s.backLayer){delete s.backLayer;let o=s.next;n.removeLayer(s.id),s=o}else s.isBack&&(s.isBack=!1),s=s.next}else{let t=e.layersList,r=t.head;for(;r;)for(;r;)if(r.backLayer){delete r.backLayer;let n=r.next;t.removeLayer(r.id),r=n}else r.isBack&&(r.isBack=!1),r=r.next}}}getTimingFunction(e,t,r){switch(e){case Si.LINEAR:return"cubicBezier( 0, 0, 1, 1 )";case Si.EASE:return"cubicBezier( .25, .1, .25, 1 )";case Si.EASE_IN:return"cubicBezier( .42, 0, 1, 1 )";case Si.EASE_OUT:return"cubicBezier( 0, 0, .58, 1 )";case Si.EASE_IN_OUT:return"cubicBezier( .42, 0, .58, 1 )";case Si.CUBIC:return`cubicBezier( ${t[0]}, ${t[1]}, ${t[2]}, ${t[3]} )`;case Si.SPRING:return`spring( ${r.mass}, ${r.stiffness}, ${r.damping}, ${r.velocity} )`}}animate(e,t,r=!1){var n,s,o,a,l,c;if(Mi.isAnimating[e.uuid]=0,this._currentState===e){if((n=this._animation)==null?void 0:n.reversed){let u=(o=(s=this._animation)==null?void 0:s.currentTime)!=null?o:0;(a=this._animation)==null||a.reset(),(l=this._animation)==null||l.seek(u),(c=this._animation)==null||c.play()}}else this._prevState=this._currentState,this._currentState=e,this._animation!==void 0&&(Mi.isAnimating[this._prevState.uuid]=1,this._animation.pause()),this._removeBackLayer(),t.cycle===!0&&t.repeat===!0?this._animation=Lu.timeline({duration:t.duration,delay:t.delay/2,endDelay:t.delay/2,direction:"alternate",loop:!0,rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):t.cycle===!0&&t.repeat===!1?this._animation=Lu.timeline({duration:t.duration,delay:t.delay,endDelay:t.delay/2,direction:"alternate",rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):t.cycle===!1&&t.repeat===!0?this._animation=Lu.timeline({duration:t.duration,delay:t.delay,direction:"normal",loop:!0,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):this._animation=Lu.timeline({duration:t.duration,delay:t.delay,direction:"normal",easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}),this._animation.finished.then(()=>{r||(this._removeBackLayer(),this._animation=void 0,Mi.isAnimating[e.uuid]=1)}),this.animateMatrix(e),this.animateGeometry(e),this.animateMaterial(e),this.animateCamera(e),this.animateLight(e.light)}animateMatrix(e){var s,o,a,l;if(this.object.position.equals(e.position)===!1){let c=this.object.position.clone(),u={t:0};(s=this._animation)==null||s.add({targets:u,t:1,update:()=>{this.object.position.lerpVectors(c,e.position,u.t),this.object.updateMatrix()}},0)}if(this.object.scale.equals(e.scale)===!1){let c=this.object.scale.clone(),u={t:0};(o=this._animation)==null||o.add({targets:u,t:1,update:()=>{this.object.scale.lerpVectors(c,e.scale,u.t),this.object.updateMatrix()}},0)}if(this.object.rotation.equals(e.rotation)===!1){let c=this.object.quaternion.clone(),u={t:0},d={x:this.object.rotation.x,y:this.object.rotation.y,z:this.object.rotation.z},h={x:e.rotation.x-this.object.rotation.x,y:e.rotation.y-this.object.rotation.y,z:e.rotation.z-this.object.rotation.z},p=e.rotation.clone(),f=new Ft().setFromEuler(p);(a=this._animation)==null||a.add({targets:u,t:1,update:Object.values(h).every(g=>Math.abs(g)<2*Math.PI)?()=>{q1(c,f,this.object.quaternion,u.t),this.object.updateMatrix()}:()=>{this.object.rotation.x=d.x+h.x*u.t,this.object.rotation.y=d.y+h.y*u.t,this.object.rotation.z=d.z+h.z*u.t,this.object.updateMatrix()}},0)}let t=new A,r=new Ft,n=new A;if(e.hiddenMatrix.decompose(t,r,n),"hiddenMatrix"in this.object){let c=new A,u=new Ft,d=new A;if(this.object.hiddenMatrix.decompose(c,u,d),this.object.hiddenMatrix.equals(e.hiddenMatrix)===!1){let h=new A,p=new Ft,f=new A,g={t:0},v=this.object.hiddenMatrix;(l=this._animation)==null||l.add({targets:g,t:1,update:()=>{p.slerpQuaternions(u,r,g.t),h.lerpVectors(c,t,g.t),f.lerpVectors(d,n,g.t),v.compose(h,p,f)}},0)}}}animateGeometry(e){var t;if("geometry"in this.object&&e.geometry!==void 0){let n=this.object.geometry.userData.parameters,s=e.geometry;if(s.width!==n.width||s.height!==n.height||s.depth!==n.depth){let o=this.object;(t=this._animation)==null||t.add({targets:n,width:s.width,height:s.height,depth:s.depth,update:()=>{o.updateGeometry({parameters:{width:n.width,height:n.height,depth:n.depth}})}},0)}}}animateMaterial(e){if("material"in this.object&&e.material!==void 0)if(this.object.material instanceof Array)for(let t=0,r=this.object.material.length;t<r;++t)this._interpolateMaterial(this.object.material[t],e.material[t]);else{if(this.object.material.userData.isAsset)return;this._interpolateMaterial(this.object.material,e.material)}}animateCamera(e){var t,r;if(this.object.objectType==="CombinedCamera"&&e.camera!==void 0){let n=this.object,s=n.cameraType==="OrthographicCamera"?e.camera.zoomOrtho:e.camera.zoomPersp;n.zoom!==s&&((t=this._animation)==null||t.add({targets:n,zoom:s,update:()=>{n.updateProjectionMatrix()}},0)),n.targetOffset!==e.camera.targetOffset&&((r=this._animation)==null||r.add({targets:n,targetOffset:e.camera.targetOffset},0))}}animateLight(e){var t,r;if(e!==void 0&&(this.object.objectType==="LightDirectional"||this.object.objectType==="LightSpot"||this.object.objectType==="LightPoint")){let n=this.object;n.intensity!==e.intensity&&((t=this._animation)==null||t.add({targets:n,intensity:e.intensity},0)),Ur.equals(n.color,e.color)||(r=this._animation)==null||r.add({targets:n.color,r:e.color.r,g:e.color.g,b:e.color.b},0)}}_interpolateMaterial(e,t){let r=e.layersList.head,n=0;for(;r;){if(r.isBack===!0){r=r.next;continue}let s=t.layersList[n++];if(kf(r)){let o=r.uniforms[`f${r.id}_texture`].value,a=s.uniforms[`f${s.id}_texture`].value;o.image===a.image?this._interpolateMaterialTexture(e,r,s):this._interpolateMaterialBetweenLayers(e,r,s)}else r.type==="gradient"||r.type==="depth"?r.uniforms[`f${r.id}_gradientType`].value===s.uniforms[`f${s.id}_gradientType`].value?this._interpolateMaterialGradient(e,r,s):this._interpolateMaterialBetweenLayers(e,r,s):this._interpolateMaterialBetweenValues(e,r,s);r=r.next}}},xo=Mi;xo.isAnimating={};var lp=i=>class extends i{hasEntityChild(){return this.children.some(t=>Of(t))}isDescendantOf(t){t instanceof Ze&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let n=new Me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),Of(t)?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,n={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Of(o)||o instanceof On)&&s.children.push(o.toJSON(t).object)}if(r){let o=Zl(t.geometries),a=Zl(t.materials),l=Zl(t.textures),c=Zl(t.images),u=Zl(t.interactionStates),d=kA(t.nodes);o.length>0&&(n.geometries=o),a.length>0&&(n.materials=a),l.length>0&&(n.textures=l),c.length>0&&(n.images=c),u.length>0&&(n.interactionStates=u),d.length>0&&(n.nodes=d)}return n.object=s,n}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var En=i=>"isEntity"in i,VA=i=>"isAbstractMesh"in i,ti=i=>class extends lp(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Me;this.interaction=new xo(this);this._singleBBox=new Ff;this._recursiveBBox=new Ff;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)En(r)&&r.traverseEntity(n=>{Ss(n)&&n.visible&&(n.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){return this.interaction.cache===void 0&&this.interaction.computeCache(),this.interaction.cache}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{En(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)En(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),r===!0)for(let n of t.children)En(n)&&this.add(n.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),r===!0)for(let n of t.children)En(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let t=new Me,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let n of this.children)En(n)&&n.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),n=r.object;return this.raycastLock===!0&&(n.raycastLock=!0),this.scaleLock===!0&&(n.scaleLock=!0),n.hiddenMatrix=this.hiddenMatrix.toArray(),this.interaction!==void 0&&(n.interaction=this.interaction.toJSON(t)),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Me}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return El(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=re({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return El(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};var cp=class extends Ze{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new A),n=.1;this.parameters=Vd.defaultData(r.toArray(),n),Jo(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let n=this.object.shallowClone(!1);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*rt.DEG2RAD,n=t.end*rt.DEG2RAD,s=r-n,o=new jn(t.rotation[0]*rt.DEG2RAD,t.rotation[1]*rt.DEG2RAD,t.rotation[2]*rt.DEG2RAD),a;switch(t.axis){case"z":a=new A(0,0,1);break;case"y":a=new A(0,1,0);break;default:case"x":a=new A(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let u=s/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,u,0);break;case"y":c.rotation.set(0,0,u);break;case"z":c.rotation.set(u,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=o.x,c.rotation.y+=o.y,c.rotation.z+=o.z):c.rotation.copy(o)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new jn(t.rotation[0]*rt.DEG2RAD,t.rotation[1]*rt.DEG2RAD,t.rotation[2]*rt.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=t.scale[0]*n+1,s.scale.y=t.scale[1]*n+1,s.scale.z=t.scale[2]*n+1,s.rotation.x=r.x*n,s.rotation.y=r.y*n,s.rotation.z=r.z*n,s.position.x=t.position[0]*n,s.position.y=t.position[1]*n,s.position.z=t.position[2]*n}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let n={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new A(r.size[0]*(r.count[0]-n.x)*.5,r.size[1]*(r.count[1]-n.y)*.5,r.size[2]*(r.count[2]-n.z)*.5);for(let o=0;o<r.count[0];o++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*o-s.x,c.position.y=r.size[1]*a-s.y,c.position.z=r.size[2]*l-s.z}}else for(let n=0;n<r.count[0];n++)for(let s=0;s<r.count[1];s++)for(let o=0;o<r.count[2];o++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*n,a.position.y=-r.size[1]*s,a.position.z=-r.size[2]*o}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),Jo(this.parameters,e),this.update(),this}};var Lr=class extends ti(Wt){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0)}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Ty[t.userData.type],n=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,n)),o=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=o,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){vu.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=xu(t),n=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,n).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new cp(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=UA(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let n=[];for(let s=0,o=this.material.length;s<o;s++)n.push(Iu(e.materials,this.material[s],e));r.material=n}else r.material=Iu(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new cp(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,n;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(n=e.receiveShadow)!=null?n:!0),this}};var up=new F,ca=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new F(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=pn.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,n;for(n=e;n>=0;n-=1)if(this.message[n].char===" "){r=!1,t.length===0&&(n-=1,t.splice(0,0,this.message[n]));break}else t.splice(0,0,this.message[n]);return r?t=[]:this.message.splice(n+1,t.length),t}getWord(e=0,t=1){let r=[],n=e;for(n=e;;n+=t){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}t>0?(r.push(this.message[n]),this.message.splice(n,1),n-=t):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,n=e;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=t}return(n<0||n>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let n=t;n<=r;n+=1)this.message[n].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,n,s){switch(r){case pn.Left:this.leftAlign(e,s);break;case pn.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case pn.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case pn.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){up.set(t,r);let n=this.message.length;for(let s=0;s<n;s++)this.message[s].updatePosition(this.message[s].localPosition.add(up),e)}leftAlign(e,t){this.align=pn.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=pn.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=pn.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=pn.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(t,0,r);return}let s=e/n,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),up.set(o,r),this.message[a].updatePosition(this.message[a].localPosition.add(up),t)}clone(){let e=new ca(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var ez=new A(0,0,1),HA=new A,jA=new A,WA=new Dt,ua=class extends Lr{constructor(e=jr.create({}),t=new sn({side:Yt})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new xr;this._onShapeUpdate=()=>{if(this.geometry instanceof mu){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),WA.getNormalMatrix(this.matrixWorld),HA.copy(ez).applyMatrix3(WA).normalize(),jA.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(HA,jA)}clone(e){let t=this.shape.clone(),r=this.material.clone(),n=this.geometry.userData,s=jr.create(Object.assign({},n,{shape:t})),o=new ua(s,r).copy(this,e);return o.shape=t,t.update(),o}raycast(e,t){Lr.prototype.raycast.call(this,e,t)}};var es=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new In(30,30,30),e};var hp=new Ni,dv=new ln,JA=new Me,ts=(i,e,t,r,n=!1)=>{let s=e,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),dv.copy(s.boundingSphere),dv.applyMatrix4(o),t.ray.intersectsSphere(dv)===!1||(JA.copy(o).invert(),hp.copy(t.ray).applyMatrix4(JA),s.boundingBox!==null&&hp.intersectsBox(s.boundingBox)===!1))return;let a,l,c,u,d=s.index,h=s.attributes.position,p=s.drawRange,f,g;if(n===!1){let y=Math.max(0,p.start),m=Math.min(d.count,p.start+p.count);for(f=y,g=m;f<g;f+=3)if(l=d.getX(f),c=d.getX(f+1),u=d.getX(f+2),a=v(i,t,hp,h,l,c,u),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let m=s.attributes.position,x=new A,b=new A,w=new A,T=new A,S=2,E=1/((i.scale.x+i.scale.y+i.scale.z)/3),C=E*E,_=Math.max(0,p.start),O=Math.min(m.count,p.start+p.count);for(let P=_,D=O-1;P<D;P+=S){if(x.fromBufferAttribute(m,P),b.fromBufferAttribute(m,P+1),hp.distanceSqToSegment(x,b,T,w)>C)continue;T.applyMatrix4(i.matrixWorld);let R=t.ray.origin.distanceTo(T);R<t.near||R>t.far||r.push({distance:R,point:w.clone().applyMatrix4(i.matrixWorld),object:i})}}function v(y,m,x,b,w,T,S){let M=new A,E=new A,C=new A,_=new A,O=new A;if(M.fromBufferAttribute(b,w),E.fromBufferAttribute(b,T),C.fromBufferAttribute(b,S),x.intersectTriangle(M,E,C,!1,_)===null)return null;O.copy(_),O.applyMatrix4(y.matrixWorld);let D=m.ray.origin.distanceTo(O);return D<m.near||D>m.far?null:{faceIndex:1,distance:D,point:O.clone(),object:y}}};var dp=new A,ri=new hi,qA=class extends Fi{constructor(e){let t=new _e,r=new un({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={},a=new ve(oy),l=new ve(oy),c=new ve(t1);u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",l),u("p","n2",l),u("p","n3",l),u("p","n4",l),u("u1","u2",c),u("u2","u3",c),u("u3","u1",c);function u(h,p,f){d(h,f),d(p,f)}function d(h,p){n.push(0,0,0),s.push(p.r,p.g,p.b),o[h]===void 0&&(o[h]=[]),o[h].push(n.length/3-1)}t.setAttribute("position",new Ae(n,3)),t.setAttribute("color",new Ae(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;ri.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,o=r?.8:1e-4;Ai("n1",t,e,ri,-n,-s,o),Ai("n2",t,e,ri,n,-s,o),Ai("n3",t,e,ri,-n,s,o),Ai("n4",t,e,ri,n,s,o);let a=o;Ai("f1",t,e,ri,-n,-s,a),Ai("f2",t,e,ri,n,-s,a),Ai("f3",t,e,ri,-n,s,a),Ai("f4",t,e,ri,n,s,a);let l=a,c=.5;Ai("u1",t,e,ri,n*.7*c,s*1.1,l),Ai("u2",t,e,ri,-n*.7*c,s*1.1,l),Ai("u3",t,e,ri,0,s*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ai(i,e,t,r,n,s,o){dp.set(n,s,o).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],dp.x,dp.y,dp.z)}}var fv=class extends es(qA){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,t){ts(this.object,this.geometry,e,t,!0)}};var Du=class extends es(lg){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,Du.geometryHelper,e,t)}};var Ru=class extends es(cg){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){ts(this.object,Ru.geometryHelper,e,t)}update(){}};var Ou=class extends es(ag){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,Ou.geometryHelper,e,t)}};var pp=class extends es(sg){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,pp.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=pp._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,o=this.cone.material.length;s<o;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},fp=pp;fp._vector=new A;var rs=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let n of this.children)En(n)&&n.traverseEntity(s=>{Ss(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,n){this.objectHelper.raycast(r,n)}copy(r,n=!0){return super.copy(r,n),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let n=super.toJSON(r),s=n.object;return s.enableHelper=this.enableHelper,n}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=sr(r.color,n)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var $l=new A,pv=new A,ni=class extends rs(ti(hi),fv){constructor(e=window.innerWidth,t=window.innerHeight,r=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=qo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new Va(e*-.5,e*.5,t*.5,t*-.5,n!=null?n:-5e4,s),this.perspCamera=new dr(r,e/t,n!=null?n: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(!0)}static createFromState(e,t){let r=new ni().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}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($l),this.targetOffset=$l.distanceTo(e)}getTarget(e=new A){return this.getWorldDirection(pv),this.getWorldPosition($l),pv.multiplyScalar(this.targetOffset),e.copy($l).add(pv),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition($l),$l.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new Ft),t=new A(0,0,1).applyQuaternion(e),r=new A().copy(Ze.DefaultUp).applyQuaternion(e),n=new A().copy(Ze.DefaultUp).projectOnPlane(t),s=new A().crossVectors(n,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new A),n=e.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToObject(e){let t=e.getWorldPosition(new A),n=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:t.clone().sub(n),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&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,t,r,n,s,o){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,n,s,o):this.orthoCamera.setViewOffset(e,t,r,n,s,o)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),n=new A().fromArray(e.orbitControlsTarget);this.targetOffset=n.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={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};return El(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),this.updateProjectionMatrix(),this}toState(e){return xe(re(re({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};var ii=class extends rs(ti(Oi),Ru){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new ii().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};var Bu=class extends rs(ti(nd),Du){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let n=new mi(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Bu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=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,t),e.size!==void 0&&W1(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};var Fu=class extends rs(ti(rd),Ou){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let n=new A(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new A(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),o=new rr(n,s),a=new cl(o,new ve(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let n=new Fu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof cl&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof cl&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof cl){let r=this.shadow.camera,n=new A(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new A(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(n,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),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,t){return super.fromState(e),this.fromPointLightState(e,t),this}};var XA=new A,YA=new A,QA=new Ft,Gu=class extends rs(ti(td),fp){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=rt.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new mi(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Gu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),YA.setFromMatrixPosition(this.matrixWorld),QA.setFromRotationMatrix(this.matrixWorld),XA.copy(this.up).applyQuaternion(QA).negate().multiplyScalar(this.distance),this.target.position.copy(YA).add(XA),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),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),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};var KA=i=>i.tagName==="VIDEO",ec=class{static resize(e,t,r){let n=e/t,s;if(!r.image)return;let o=r.image;KA(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let n=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;n>s?o={x:1,y:s/n}:n<s?o={x:n/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let n=r.userData.layers,s=n.getLayers();for(let o=0;o<s.length;o++){let a=s[o];kf(a)&&(ec.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(e,t,r,n){let s=e/t,o,a=r.image;KA(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,n.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var zu=class extends Lr{constructor(e,t=new sn){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&ec.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&ec.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof qh){let o=e.image;t=o.videoWidth*.5,r=o.videoHeight*.5}else{let o=e.image;t=o.width*.5,r=o.height*.5}let n=If.create({parameters:{width:t,height:r}}),s=new sn;return s.layersList.changeLayer(0,{type:at.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new zu(n,s)}};var Uu=class extends Lr{constructor(e,t=new $n){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var ku=class extends Uu{constructor(e,t=new $n){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var Vu;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Vu||(Vu={}));var mv=class extends Lr{constructor(e,t=new sn({transparent:!0,opacity:1,visible:!1,side:Yt})){super(e,t);this.objectType="TextFrame";this.charContainer=new Ze,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:co.None,horizontalAlignment:1,verticalAlignment:ws.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let n=Df.create({parameters:{width:t.width,height:t.height}}),s=new mv(n).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await en.loadFont(r),t.text=e;let n=t.textOrigin,s=new Pi({visible:t.visible,transparent:!0,side:Yt}),o=e.split(`
4142
+ `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.metalness&&(this.metalness=t.getNode(e.metalness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.reflectivity&&(this.reflectivity=t.getNode(e.reflectivity)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var Qy=class extends Zn{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new Yy,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var Eu=class extends Qy{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof mn){let t=e.userData.layers,r=e.fragment;super.copy(e);let n=r.clone();this.fragment=n,this.vertex=n;let s=t.clone(this);this.userData.layers=s,n.shadingAlpha.value=r.shadingAlpha.value,n.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let n=r.getNode(t.vertex),s=new Eu(void 0,n);return s.fromJSON(t,r),s}dispose(){super.dispose()}};function $f(i,e){switch(i.data.type){case"light":return wi(i);case"fresnel":return XF(i,e);case"gradient":return YF(i);case"depth":return QF(i);case"normal":return KF(i);case"noise":return ZF(i,e);case"texture":return $F(i,e);case"rainbow":return eG(i);case"transmission":return tG(i,e);case"matcap":return rG(i,e);case"displace":return nG(i);case"color":default:return qF(i,e)}}function Z1(i){return{type:i.data.type}}function wi(i){let{alpha:e,mode:t}=i.data;return xe(re({},Z1(i)),{alpha:e,mode:t})}function qF(i,e){return xe(re({},wi(i)),{color:sr(i.data.color,e)})}function XF(i,e){let{bias:t,scale:r,intensity:n,factor:s,color:o}=i.data;return xe(re({},wi(i)),{color:sr(o,e),bias:t,scale:r,intensity:n,factor:s})}function YF(i){let{gradientType:e,smooth:t,colors:r,steps:n,angle:s,offset:o,morph:a}=i.data;return xe(re({},wi(i)),{gradientType:e,smooth:t,colors:r.map(l=>new Qe(l[0],l[1],l[2],l[3])),num:r.length,steps:n,offset:new F(...o),morph:new F(...a),angle:s})}function QF(i){let{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:o,direction:a,colors:l,steps:c,smooth:u}=i.data;return xe(re({},wi(i)),{gradientType:e,near:t,far:r,isVector:n,isWorldSpace:s,origin:new A(...o),direction:a?new A(...a):new A(1,0,0),num:l.length,colors:l.map(d=>new Qe(d[0],d[1],d[2],d[3])),steps:c,smooth:u})}function KF(i){let{cnormal:e}=i.data;return xe(re({},wi(i)),{cnormal:new A(e[0],e[1],e[2])})}function ZF(i,e){let{data:t}=i;return xe(re({},wi(i)),{scale:t.scale,move:t.move,fA:new F(...t.fA),fB:new F(...t.fB),distortion:new F(...t.distortion),colorA:sr(t.colorA,e),colorB:sr(t.colorB,e),colorC:sr(t.colorC,e),colorD:sr(t.colorD,e),noiseType:t.noiseType})}function $F(i,e){let{projection:t,axis:r,crop:n,size:s}=i.data,{image:o,wrapping:a,repeat:l,offset:c}=i.data.texture,u=new Pt,d;if(typeof o=="string")d=e==null?void 0:e.getImage(o);else{let h=new Image;h.src=o.data,h.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(o.data))},d=h}return u.image=d,u.wrapS=u.wrapT=a,xe(re({},wi(i)),{texture:u,mat:new Dt().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:n,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function eG(i){let{data:e}=i;return xe(re({},wi(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new A(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new A(...e.offset)})}function tG(i,e){let{data:t}=i;return xe(re({},wi(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function rG(i,e){let t=new Pt,{image:r}=i.data.texture,n;if(typeof r=="string")n=e==null?void 0:e.getImage(r);else{let o=new Image;o.src=r.data,o.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},n=o}t.image=n;let s=16777215;return xe(re({},wi(i)),{color:s,texture:t})}function nG(i){let{data:e}=i,t=xe(re({},Z1(i)),{intensity:e.intensity});if(e.displacementType==="noise")return xe(re({},t),{offset:new A(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new Pt,n=new Dt().setUvTransform(0,0,1,1,0,0,0);return xe(re({},t),{texture:r,mat:n,crop:e.crop})}}function ep(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}var Kl;(function(e){function i(t){return new ve(t.x,t.y,t.z).getHex()}e.getHex=i})(Kl||(Kl={}));var $1;(function(e){function i(t){return new Qe(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})($1||($1={}));var eA;(function(t){function i(r,n){r.setRGB(n.r,n.g,n.b)}t.setThreeColor=i;function e(r){return new ve(r.r,r.g,r.b).getHex()}t.getHex=e})(eA||(eA={}));function yo(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):Ky(i,e)}function tA(i,e){return i.map(t=>yo(t,e))}function Ky(i,e){var o;let t=(o=i.layers)!=null?o:Ol.defaultTwoLayerData("phong").layers,r=iG(t),n;switch(r.category){case"basic":n=new sn;break;case"lambert":{n=new Tu;break}case"toon":{n=new _u;break}case"physical":n=new Eu;break;case"phong":default:{n=new $n;break}}let s=n.userData.layers;sG(s);for(let a=t.length-1;a>=0;a--)oG(s,t[a],e);switch(r.category){case"basic":break;case"lambert":{let c=n,d=sr(r.emissive,e);d instanceof ve?c.emissive.value=d:c.emissive.value.setHex(Kl.getHex(d));break}case"toon":{let c=n,u=r;c.shininess.value=u.shininess;let d=sr(u.specular,e);d instanceof ve?c.specular.value=d:c.specular.value.setHex(Kl.getHex(d));break}case"physical":let a=n,l=r;a.metalness.value=l.metalness,a.roughness.value=l.roughness,a.reflectivity.value=l.reflectivity;break;case"phong":default:{let c=n,u=r;c.shininess.value=u.shininess;let d=sr(u.specular,e);d instanceof ve?c.specular.value=d:c.specular.value.setHex(Kl.getHex(d));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),n}function iG(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:Ar.Normal}}function sG(i){for(let e of i.getLayers())i.removeLayer(e.id)}function oG(i,e,t){let r=$f(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let n=i.addLayer(r);n.uuid=e.id;for(let s in e.data)ep(s,n,e.data)}var aa=new Set;var Si;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Si||(Si={}));var Ts=class{constructor(){this.easing=4;this.duration=1e3;this.delay=0;this.cubicControls=[.5,.05,.1,.3];this.springParameters={mass:1,stiffness:80,damping:10,velocity:0};this.repeat=!1;this.cycle=!1;this.rewind=!1}static create(e){let t=new Ts,r=e;return t.easing=e.easing,t.duration=e.duration,t.delay=e.delay,r.easing===Zc.CUBIC?t.cubicControls=[...r.control1,...r.control2]:r.easing===Zc.SPRING&&(t.springParameters={mass:r.mass,stiffness:r.stiffness,damping:r.damping,velocity:r.velocity}),t.repeat=e.repeat,t.cycle=e.cycle,t.rewind=e.rewind,t}get sp_mass(){return this.springParameters.mass}set sp_mass(e){this.springParameters.mass=e}get sp_stiffness(){return this.springParameters.stiffness}set sp_stiffness(e){this.springParameters.stiffness=e}get sp_damping(){return this.springParameters.damping}set sp_damping(e){this.springParameters.damping=e}get sp_velocity(){return this.springParameters.velocity}set sp_velocity(e){this.springParameters.velocity=e}copy(e){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters=re({},e.springParameters),this.repeat=e.repeat,this.cycle=e.cycle,this.rewind=e.rewind,this}clone(){return new Ts().copy(this)}toJSON(){let e={easing:this.easing,duration:this.duration,delay:this.delay,cubicControls:this.cubicControls,springParameters:re({},this.springParameters)};return this.repeat===!0&&(e.repeat=!0),this.cycle===!0&&(e.cycle=!0),this.rewind===!0&&(e.rewind=!0),this.object!==void 0&&(e.object=this.object.uuid),this.state!==void 0&&(e.state=this.state.uuid),e}fromJSON(e,t,r){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters.mass=e.springParameters.mass,this.springParameters.stiffness=e.springParameters.stiffness,this.springParameters.damping=e.springParameters.damping,this.springParameters.velocity=e.springParameters.velocity,e.repeat!==void 0&&(this.repeat=e.repeat),e.cycle!==void 0&&(this.cycle=e.cycle),e.rewind!==void 0&&(this.rewind=e.rewind),e.object!==void 0&&(this.object=t[e.object]),e.state!==void 0&&(this.state=r[e.state]),this}};function aG(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Je;(function(h){h[h.MOUSE_DOWN=0]="MOUSE_DOWN",h[h.MOUSE_UP=1]="MOUSE_UP",h[h.MOUSE_HOVER=2]="MOUSE_HOVER",h[h.MOUSE_ENTER=3]="MOUSE_ENTER",h[h.MOUSE_LEAVE=4]="MOUSE_LEAVE",h[h.KEY_DOWN=5]="KEY_DOWN",h[h.KEY_UP=6]="KEY_UP",h[h.START=7]="START",h[h.OPEN_LINK=8]="OPEN_LINK",h[h.LOOK_AT=9]="LOOK_AT",h[h.FOLLOW=10]="FOLLOW",h[h.SCROLL=11]="SCROLL"})(Je||(Je={}));var vo=class{constructor(e,t){this.targets=[];this._type=e,this.key=t}get type(){return this._type}set type(e){this._type=e,e===9?this.distance=1e3:this.distance=void 0,e!==5&&e!==6&&(this.key=void 0)}newTarget(e){let t=new Ts;if(t.object=e,e!==void 0){let r=e.interaction.states;r.length>0&&(t.state=r[r.length-1])}return this.targets.push(t),aa.add(t),t}addTarget(e,t=0){this.targets.splice(t,0,e),aa.add(e)}removeTarget(e){aa.delete(this.targets[e]),this.targets.splice(e,1)}dispatchReverse(){for(let e=0,t=this.targets.length;e<t;++e){let r=this.targets[e];r.state!==void 0&&r.object!==void 0&&r.object.interaction.reverse(r)}}dispatch(e){this.url!==void 0&&(this._type===8||this._type===0||this._type===1||this._type===5||this._type===6)&&(aG()?window.location.assign(this.url):window.open(this.url,"_blank"));for(let t=0,r=this.targets.length;t<r;++t){let n=this.targets[t];n.state!==void 0&&n.object!==void 0&&(this._type===11?n.object.interaction.seek(n,e,this.steps):n.object.interaction.play(n))}}copy(e){return this._type=e.type,this.key=e.key,this.url=e.url,this.distance=e.distance,this}clone(){return new vo().copy(this)}toJSON(){let e={type:this._type,key:this.key,ui:{isCollapsed:!1}};if(this.url!==void 0&&(e.url=this.url),this.distance!==void 0&&(e.distance=this.distance),this.targets.length>0){e.targets=[];for(let t=0,r=this.targets.length;t<r;++t)e.targets.push(this.targets[t].toJSON())}return e}fromJSON(e,t,r){if(this._type=e.type,this.key=e.key,this.targets=[],this.url=e.url,e.distance!==void 0&&(this.distance=e.distance),e.targets!==void 0)for(let n=0,s=e.targets.length;n<s;++n)this.addTarget(new Ts().fromJSON(e.targets[n],t,r),n);return this}};var Qi=class{constructor(){this.uuid=rt.generateUUID();this.name="";this.position=new A;this.rotation=new jn;this.scale=new A;this.hiddenMatrix=new Me}static create(e,t,r){let n=new Qi;if(n.uuid=e,n.position.fromArray(t.position),n.scale.fromArray(t.scale),n.rotation.fromArray(t.rotation),n.hiddenMatrix.fromArray(t.hiddenMatrix),"geometry"in t&&(n.geometry=t.geometry),"material"in t&&(n.material={layersList:yo(t.material,r).layersList.getLayers()}),"materials"in t&&(n.material=t.materials.map(s=>({layersList:yo(s,r).layersList.getLayers()}))),"perspective"in t&&(n.camera={zoomOrtho:t.orthographic.zoom,zoomPersp:t.perspective.zoom,targetOffset:t.targetOffset}),Il.is(t.type)){let s=t;n.light={intensity:s.intensity,color:sr(s.color,r)}}return n}update(e){this.updateMatrix(e),"geometry"in e&&this.updateGeometry(e),"material"in e&&this.updateMaterial(e),e.objectType==="CombinedCamera"?this.updateCamera(e):(e.objectType==="LightDirectional"||e.objectType==="LightPoint"||e.objectType==="LightSpot")&&this.updateLight(e)}updateCamera(e){this.camera={zoomPersp:e.perspCamera.zoom,zoomOrtho:e.orthoCamera.zoom,targetOffset:e.targetOffset}}updateLight(e){let t=e.color;this.light={intensity:e.intensity,color:{r:t.r,g:t.g,b:t.b}}}updateMatrix(e){this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),"hiddenMatrix"in e&&this.hiddenMatrix.copy(e.hiddenMatrix)}updateGeometry(e){if("geometry"in e&&this.geometry!==void 0){let{width:t,height:r,depth:n}=e.geometry.userData.parameters;this.geometry={width:t,height:r,depth:n}}}updateMaterial(e){if("material"in e&&this.material!==void 0)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t){let n=e.material[t],s=[],o=n.layersList.head;for(;o;)s.push(o.clone()),o=o.next;this.material.push({layersList:s})}}else{let t=e.material,r=[],n=t.layersList.head;for(;n;)r.push(n.clone()),n=n.next;this.material={layersList:r}}}execute(e){if(e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale),e.updateMatrix(),"hiddenMatrix"in e&&e.hiddenMatrix.copy(this.hiddenMatrix),"geometry"in e&&this.geometry!==void 0){let r=e.geometry.userData.parameters,n=this.geometry;(n.width!==r.width||n.height!==r.height||n.depth!==r.depth)&&e.updateGeometry({parameters:{width:n.width,height:n.height,depth:n.depth}})}if("material"in e&&this.material!==void 0){let t=e.material;if(t instanceof Array){let r=this.material;for(let n=0,s=r.length;n<s;++n){let o=t[n].layersList.head,a=r[n].layersList,l=0;for(;o;)o.copy(a[l++]),o=o.next;t[n].dispose()}}else{if(t.userData.isAsset)return;let r=0,n=t.layersList.head,o=this.material.layersList;for(;n;)n.copyUniforms(o[r++]),n=n.next;t.dispose()}}if(this.camera&&e.objectType==="CombinedCamera"&&(e=e,e.zoom=e.cameraType==="OrthographicCamera"?this.camera.zoomOrtho:this.camera.zoomPersp,e.targetOffset=this.camera.targetOffset,e.updateProjectionMatrix()),this.light&&(e.objectType==="LightDirectional"||e.objectType==="LightPoint"||e.objectType==="LightSpot")){e=e,e.intensity=this.light.intensity;let t=this.light.color;e.color.setRGB(t.r,t.g,t.b)}}copy(e){if(this.name=e.name,this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),this.hiddenMatrix.copy(e.hiddenMatrix),e.geometry!==void 0&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),e.material!==void 0)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t)this.material.push({layersList:e.material[t].layersList.map(n=>n.clone())})}else this.material={layersList:e.material.layersList.map(t=>t.clone())};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:e.camera.targetOffset}),e.light!==void 0&&(this.light={intensity:e.light.intensity,color:Ur.clone(e.light.color)}),this}clone(){return new Qi().copy(this)}toJSON(e){let t={uuid:this.uuid,name:this.name,position:this.position.toArray(),rotation:this.rotation.toArray(),scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};if(this.geometry!==void 0&&(t.geometry={width:this.geometry.width,height:this.geometry.height,depth:this.geometry.depth}),this.material!==void 0)if(this.material instanceof Array){t.material=[];for(let r=0,n=this.material.length;r<n;++r)t.material.push({layersList:this.material[r].layersList.map(s=>s.toJSON(e))})}else t.material={layersList:this.material.layersList.map(r=>r.toJSON(e))};return this.camera!==void 0&&(t.camera={zoomPersp:this.camera.zoomPersp,zoomOrtho:this.camera.zoomOrtho,targetOffset:this.camera.targetOffset}),t}fromJSON(e,t){var r;if(this.uuid=e.uuid,this.name=e.name,this.position.fromArray(e.position),this.rotation.fromArray(e.rotation),this.scale.fromArray(e.scale),this.hiddenMatrix.fromArray(e.hiddenMatrix),e.geometry!==void 0&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),e.material!==void 0)if(e.material instanceof Array){this.material=[];for(let n=0,s=e.material.length;n<s;++n)this.material.push({layersList:e.material[n].layersList.map(o=>Iy(o,t))})}else this.material={layersList:e.material.layersList.map(n=>Iy(n,t))};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:(r=e.camera.targetOffset)!=null?r:-1}),this}};"use strict";var rA={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Zy={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},lG=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],tp={CSS:{},springs:{}};function Ki(i,e,t){return Math.min(Math.max(i,e),t)}function Cu(i,e){return i.indexOf(e)>-1}function $y(i,e){return i.apply(null,e)}var qe={arr:function(i){return Array.isArray(i)},obj:function(i){return Cu(Object.prototype.toString.call(i),"Object")},pth:function(i){return qe.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||qe.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i=="undefined"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return qe.hex(i)||qe.rgb(i)||qe.hsl(i)},key:function(i){return!rA.hasOwnProperty(i)&&!Zy.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function nA(i){var e=/\(([^)]+)\)/.exec(i);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function iA(i,e){var t=nA(i),r=Ki(qe.und(t[0])?1:t[0],.1,100),n=Ki(qe.und(t[1])?100:t[1],.1,100),s=Ki(qe.und(t[2])?10:t[2],.1,100),o=Ki(qe.und(t[3])?0:t[3],.1,100),a=Math.sqrt(n/r),l=s/(2*Math.sqrt(n*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,d=l<1?(l*a+-o)/c:-o+a;function h(f){var g=e?e*f/1e3:f;return l<1?g=Math.exp(-g*l*a)*(u*Math.cos(c*g)+d*Math.sin(c*g)):g=(u+d*g)*Math.exp(-g*a),f===0||f===1?f:1-g}function p(){var f=tp.springs[i];if(f)return f;for(var g=1/6,v=0,y=0;;)if(v+=g,h(v)===1){if(y++,y>=16)break}else y=0;var m=v*g*1e3;return tp.springs[i]=m,m}return e?h:p}function cG(i){return i===void 0&&(i=10),function(e){return Math.ceil(Ki(e,1e-6,1)*i)*(1/i)}}var uG=function(){var i=11,e=1/(i-1);function t(u,d){return 1-3*d+3*u}function r(u,d){return 3*d-6*u}function n(u){return 3*u}function s(u,d,h){return((t(d,h)*u+r(d,h))*u+n(d))*u}function o(u,d,h){return 3*t(d,h)*u*u+2*r(d,h)*u+n(d)}function a(u,d,h,p,f){var g,v,y=0;do v=d+(h-d)/2,g=s(v,p,f)-u,g>0?h=v:d=v;while(Math.abs(g)>1e-7&&++y<10);return v}function l(u,d,h,p){for(var f=0;f<4;++f){var g=o(d,h,p);if(g===0)return d;var v=s(d,h,p)-u;d-=v/g}return d}function c(u,d,h,p){if(!(0<=u&&u<=1&&0<=h&&h<=1))return;var f=new Float32Array(i);if(u!==d||h!==p)for(var g=0;g<i;++g)f[g]=s(g*e,u,h);function v(y){for(var m=0,x=1,b=i-1;x!==b&&f[x]<=y;++x)m+=e;--x;var w=(y-f[x])/(f[x+1]-f[x]),T=m+w*e,S=o(T,u,h);return S>=.001?l(y,T,u,h):S===0?T:a(y,m,m+e,u,h)}return function(y){return u===d&&h===p||y===0||y===1?y:s(v(y),d,p)}}return c}(),sA=function(){var i={linear:function(){return function(r){return r}}},e={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var n,s=4;r<((n=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((n*3-2)/22-r,2)}},Elastic:function(r,n){r===void 0&&(r=1),n===void 0&&(n=.5);var s=Ki(r,1,10),o=Ki(n,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(r,n){e[r]=function(){return function(s){return Math.pow(s,n+2)}}}),Object.keys(e).forEach(function(r){var n=e[r];i["easeIn"+r]=n,i["easeOut"+r]=function(s,o){return function(a){return 1-n(s,o)(1-a)}},i["easeInOut"+r]=function(s,o){return function(a){return a<.5?n(s,o)(a*2)/2:1-n(s,o)(a*-2+2)/2}}}),i}();function ev(i,e){if(qe.fnc(i))return i;var t=i.split("(")[0],r=sA[t],n=nA(i);switch(t){case"spring":return iA(i,e);case"cubicBezier":return $y(uG,n);case"steps":return $y(cG,n);default:return $y(r,n)}}function oA(i){try{var e=document.querySelectorAll(i);return e}catch(t){return}}function rp(i,e){for(var t=i.length,r=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<t;s++)if(s in i){var o=i[s];e.call(r,o,s,i)&&n.push(o)}return n}function np(i){return i.reduce(function(e,t){return e.concat(qe.arr(t)?np(t):t)},[])}function aA(i){return qe.arr(i)?i:(qe.str(i)&&(i=oA(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function tv(i,e){return i.some(function(t){return t===e})}function rv(i){var e={};for(var t in i)e[t]=i[t];return e}function nv(i,e){var t=rv(i);for(var r in i)t[r]=e.hasOwnProperty(r)?e[r]:i[r];return t}function ip(i,e){var t=rv(i);for(var r in e)t[r]=qe.und(i[r])?e[r]:i[r];return t}function hG(i){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return e?"rgba("+e[1]+",1)":i}function dG(i){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=i.replace(e,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),n=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+n+","+s+","+o+",1)"}function fG(i){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),t=parseInt(e[1],10)/360,r=parseInt(e[2],10)/100,n=parseInt(e[3],10)/100,s=e[4]||1;function o(h,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?h+(p-h)*6*f:f<1/2?p:f<2/3?h+(p-h)*(2/3-f)*6:h}var a,l,c;if(r==0)a=l=c=n;else{var u=n<.5?n*(1+r):n+r-n*r,d=2*n-u;a=o(d,u,t+1/3),l=o(d,u,t),c=o(d,u,t-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function pG(i){if(qe.rgb(i))return hG(i);if(qe.hex(i))return dG(i);if(qe.hsl(i))return fG(i)}function _s(i){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(i);if(e)return e[1]}function mG(i){if(Cu(i,"translate")||i==="perspective")return"px";if(Cu(i,"rotate")||Cu(i,"skew"))return"deg"}function iv(i,e){return qe.fnc(i)?i(e.target,e.id,e.total):i}function Zi(i,e){return i.getAttribute(e)}function sv(i,e,t){var r=_s(e);if(tv([t,"deg","rad","turn"],r))return e;var n=tp.CSS[e+t];if(!qe.und(n))return n;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(e);return tp.CSS[e+t]=c,c}function lA(i,e,t){if(e in i.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=i.style[e]||getComputedStyle(i).getPropertyValue(r)||"0";return t?sv(i,n,t):n}}function ov(i,e){if(qe.dom(i)&&!qe.inp(i)&&(Zi(i,e)||qe.svg(i)&&i[e]))return"attribute";if(qe.dom(i)&&tv(lG,e))return"transform";if(qe.dom(i)&&e!=="transform"&&lA(i,e))return"css";if(i[e]!=null)return"object"}function cA(i){if(!!qe.dom(i)){for(var e=i.style.transform||"",t=/(\w+)\(([^)]*)\)/g,r=new Map,n;n=t.exec(e);)r.set(n[1],n[2]);return r}}function gG(i,e,t,r){var n=Cu(e,"scale")?1:0+mG(e),s=cA(i).get(e)||n;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),r?sv(i,s,r):s}function av(i,e,t,r){switch(ov(i,e)){case"transform":return gG(i,e,r,t);case"css":return lA(i,e,t);case"attribute":return Zi(i,e);default:return i[e]||0}}function lv(i,e){var t=/^(\*=|\+=|-=)/.exec(i);if(!t)return i;var r=_s(i)||0,n=parseFloat(e),s=parseFloat(i.replace(t[0],""));switch(t[0][0]){case"+":return n+s+r;case"-":return n-s+r;case"*":return n*s+r}}function uA(i,e){if(qe.col(i))return pG(i);if(/\s/g.test(i))return i;var t=_s(i),r=t?i.substr(0,i.length-t.length):i;return e?r+e:r}function cv(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function yG(i){return Math.PI*2*Zi(i,"r")}function vG(i){return Zi(i,"width")*2+Zi(i,"height")*2}function xG(i){return cv({x:Zi(i,"x1"),y:Zi(i,"y1")},{x:Zi(i,"x2"),y:Zi(i,"y2")})}function hA(i){for(var e=i.points,t=0,r,n=0;n<e.numberOfItems;n++){var s=e.getItem(n);n>0&&(t+=cv(r,s)),r=s}return t}function bG(i){var e=i.points;return hA(i)+cv(e.getItem(e.numberOfItems-1),e.getItem(0))}function dA(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return yG(i);case"rect":return vG(i);case"line":return xG(i);case"polyline":return hA(i);case"polygon":return bG(i)}}function wG(i){var e=dA(i);return i.setAttribute("stroke-dasharray",e),e}function SG(i){for(var e=i.parentNode;qe.svg(e)&&qe.svg(e.parentNode);)e=e.parentNode;return e}function fA(i,e){var t=e||{},r=t.el||SG(i),n=r.getBoundingClientRect(),s=Zi(r,"viewBox"),o=n.width,a=n.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function MG(i,e){var t=qe.str(i)?oA(i)[0]:i,r=e||100;return function(n){return{property:n,el:t,svg:fA(t),totalLength:dA(t)*(r/100)}}}function AG(i,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return i.el.getPointAtLength(l)}var r=fA(i.el,i.svg),n=t(),s=t(-1),o=t(1);switch(i.property){case"x":return(n.x-r.x)*r.w;case"y":return(n.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function pA(i,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=uA(qe.pth(i)?i.totalLength:i,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:qe.str(i)||e?r.split(t):[]}}function mA(i){var e=i?np(qe.arr(i)?i.map(aA):aA(i)):[];return rp(e,function(t,r,n){return n.indexOf(t)===r})}function gA(i){var e=mA(i);return e.map(function(t,r){return{target:t,id:r,total:e.length,transforms:{list:cA(t)}}})}function TG(i,e){var t=rv(e);if(/^spring/.test(t.easing)&&(t.duration=iA(t.easing)),qe.arr(i)){var r=i.length,n=r===2&&!qe.obj(i[0]);n?i={value:i}:qe.fnc(e.duration)||(t.duration=e.duration/r)}var s=qe.arr(i)?i:[i];return s.map(function(o,a){var l=qe.obj(o)&&!qe.pth(o)?o:{value:o};return qe.und(l.delay)&&(l.delay=a?0:e.delay),qe.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return ip(o,t)})}function _G(i){for(var e=rp(np(i.map(function(s){return Object.keys(s)})),function(s){return qe.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},r=function(s){var o=e[s];t[o]=i.map(function(a){var l={};for(var c in a)qe.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},n=0;n<e.length;n++)r(n);return t}function EG(i,e){var t=[],r=e.keyframes;r&&(e=ip(_G(r),e));for(var n in e)qe.key(n)&&t.push({name:n,tweens:TG(e[n],i)});return t}function CG(i,e){var t={};for(var r in i){var n=iv(i[r],e);qe.arr(n)&&(n=n.map(function(s){return iv(s,e)}),n.length===1&&(n=n[0])),t[r]=n}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function LG(i,e){var t;return i.tweens.map(function(r){var n=CG(r,e),s=n.value,o=qe.arr(s)?s[1]:s,a=_s(o),l=av(e.target,i.name,a,e),c=t?t.to.original:l,u=qe.arr(s)?s[0]:c,d=_s(u)||_s(l),h=a||d;return qe.und(o)&&(o=c),n.from=pA(u,h),n.to=pA(lv(o,u),h),n.start=t?t.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=ev(n.easing,n.duration),n.isPath=qe.pth(s),n.isColor=qe.col(n.from.original),n.isColor&&(n.round=1),t=n,n})}var yA={css:function(i,e,t){return i.style[e]=t},attribute:function(i,e,t){return i.setAttribute(e,t)},object:function(i,e,t){return i[e]=t},transform:function(i,e,t,r,n){if(r.list.set(e,t),e===r.last||n){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function vA(i,e){var t=gA(i);t.forEach(function(r){for(var n in e){var s=iv(e[n],r),o=r.target,a=_s(s),l=av(o,n,a,r),c=a||_s(l),u=lv(uA(s,c),l),d=ov(o,n);yA[d](o,n,u,r.transforms,!0)}})}function NG(i,e){var t=ov(i.target,e.name);if(t){var r=LG(e,i),n=r[r.length-1];return{type:t,property:e.name,animatable:i,tweens:r,duration:n.end,delay:r[0].delay,endDelay:n.endDelay}}}function PG(i,e){return rp(np(i.map(function(t){return e.map(function(r){return NG(t,r)})})),function(t){return!qe.und(t)})}function xA(i,e){var t=i.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},n={};return n.duration=t?Math.max.apply(Math,i.map(function(s){return r(s)+s.duration})):e.duration,n.delay=t?Math.min.apply(Math,i.map(function(s){return r(s)+s.delay})):e.delay,n.endDelay=t?n.duration-Math.max.apply(Math,i.map(function(s){return r(s)+s.duration-s.endDelay})):e.endDelay,n}var bA=0;function IG(i){var e=nv(rA,i),t=nv(Zy,i),r=EG(t,i),n=gA(i.targets),s=PG(n,r),o=xA(s,t),a=bA;return bA++,ip(e,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var _n=[],wA=[],sp,DG=function(){function i(){sp=requestAnimationFrame(e)}function e(t){var r=_n.length;if(r){for(var n=0;n<r;){var s=_n[n];if(!s.paused)s.tick(t);else{var o=_n.indexOf(s);o>-1&&(_n.splice(o,1),r=_n.length)}n++}i()}else sp=cancelAnimationFrame(sp)}return i}();function RG(){document.hidden?(_n.forEach(function(i){return i.pause()}),wA=_n.slice(0),Sr.running=_n=[]):wA.forEach(function(i){return i.play()})}typeof document!="undefined"&&document.addEventListener("visibilitychange",RG);function Sr(i){i===void 0&&(i={});var e=0,t=0,r=0,n,s=0,o=null;function a(x){var b=window.Promise&&new Promise(function(w){return o=w});return x.finished=b,b}var l=IG(i),c=a(l);function u(){var x=l.direction;x!=="alternate"&&(l.direction=x!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,n.forEach(function(b){return b.reversed=l.reversed})}function d(x){return l.reversed?l.duration-x:x}function h(){e=0,t=d(l.currentTime)*(1/Sr.speed)}function p(x,b){b&&b.seek(x-b.timelineOffset)}function f(x){if(l.reversePlayback)for(var w=s;w--;)p(x,n[w]);else for(var b=0;b<s;b++)p(x,n[b])}function g(x){var b=0,w=l.animations,T=w.length;for(l.reversePlayback===!0&&l.rewind===!1&&(x=l.duration-x);b<T;){var S=w[b],M=S.animatable,E=S.tweens,C=E.length-1,_=E[C];C&&(_=rp(E,function(ce){return x<ce.end})[0]||_);for(var O=Ki(x-_.start-_.delay,0,_.duration)/_.duration,P=isNaN(O)?1:_.easing(O),D=_.to.strings,G=_.round,R=[],U=_.to.numbers.length,te=void 0,he=0;he<U;he++){var H=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var z=_.to.numbers[he],B=_.from.numbers[he]||0;else var B=_.to.numbers[he],z=_.from.numbers[he]||0;_.isPath?H=AG(_.value,P*B):H=z+P*(B-z),G&&(_.isColor&&he>2||(H=Math.round(H*G)/G)),R.push(H)}var Y=D.length;if(!Y)te=R[0];else{te=D[0];for(var q=0;q<Y;q++){var ee=D[q],k=D[q+1],pe=R[q];isNaN(pe)||(k?te+=pe+k:te+=pe+" ")}}yA[S.type](M.target,S.property,te,M.transforms),S.currentValue=te,b++}}function v(x){l[x]&&!l.passThrough&&l[x](l)}function y(){l.remaining&&l.remaining!==!0&&l.remaining--}function m(x){var b=l.duration,w=l.delay,T=b-l.endDelay,S=d(x);l.progress=Ki(S/b*100,0,100),l.reversePlayback=S<l.currentTime,n&&f(S),!l.began&&l.currentTime>=0&&(l.began=!0,v("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,v("loopBegin")),S<=w&&l.currentTime!==0&&g(0),(S>=T&&l.currentTime!==b||!b)&&g(b),S>w&&S<T?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,v("changeBegin")),v("change"),g(S)):l.changeBegan&&(l.changeCompleted=!0,l.changeBegan=!1,v("changeComplete")),l.currentTime=Ki(S,0,b),l.began&&v("update"),x>=b&&(t=0,y(),l.remaining?(e=r,v("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&u()):(l.paused=!0,l.completed||(l.completed=!0,v("loopComplete"),v("complete"),!l.passThrough&&"Promise"in window&&(o(),c=a(l)))))}return l.reset=function(){var x=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=x==="reverse",l.remaining=l.loop,n=l.children,s=n.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||x==="alternate"&&l.loop===1)&&l.remaining++,g(l.reversed?l.duration:0)},l.set=function(x,b){return vA(x,b),l},l.tick=function(x){r=x,e||(e=r),m((r+(t-e))*Sr.speed)},l.seek=function(x){m(d(x))},l.pause=function(){l.paused=!0,h()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,_n.push(l),h(),sp||DG())},l.reverse=function(){u(),l.completed=!l.reversed,h()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function SA(i,e){for(var t=e.length;t--;)tv(i,e[t].animatable.target)&&e.splice(t,1)}function OG(i){for(var e=mA(i),t=_n.length;t--;){var r=_n[t],n=r.animations,s=r.children;SA(e,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;SA(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!n.length&&!s.length&&r.pause()}}function BG(i,e){e===void 0&&(e={});var t=e.direction||"normal",r=e.easing?ev(e.easing):null,n=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",c=o==="last",u=qe.arr(i),d=parseFloat(u?i[0]:i),h=u?parseFloat(i[1]):0,p=_s(u?i[1]:i)||0,f=e.start||0+(u?d:0),g=[],v=0;return function(y,m,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!g.length){for(var b=0;b<x;b++){if(!n)g.push(Math.abs(o-b));else{var w=l?(n[0]-1)/2:o%n[0],T=l?(n[1]-1)/2:Math.floor(o/n[0]),S=b%n[0],M=Math.floor(b/n[0]),E=w-S,C=T-M,_=Math.sqrt(E*E+C*C);s==="x"&&(_=-E),s==="y"&&(_=-C),g.push(_)}v=Math.max.apply(Math,g)}r&&(g=g.map(function(P){return r(P/v)*v})),t==="reverse"&&(g=g.map(function(P){return s?P<0?P*-1:-P:Math.abs(v-P)}))}var O=u?(h-d)/v:d;return f+O*(Math.round(g[m]*100)/100)+p}}function FG(i){i===void 0&&(i={});var e=Sr(i);return e.duration=0,e.add=function(t,r){var n=_n.indexOf(e),s=e.children;n>-1&&_n.splice(n,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=ip(t,nv(Zy,i));l.targets=l.targets||i.targets;var c=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=qe.und(r)?c:lv(r,c),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var u=Sr(l);o(u),s.push(u);var d=xA(s,i);return e.delay=d.delay,e.endDelay=d.endDelay,e.duration=d.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}Sr.version="3.2.0";Sr.speed=1;Sr.running=_n;Sr.remove=OG;Sr.get=av;Sr.set=vA;Sr.convertPx=sv;Sr.path=MG;Sr.setDashoffset=wG;Sr.stagger=BG;Sr.timeline=FG;Sr.easing=ev;Sr.penner=sA;Sr.random=function(i,e){return Math.floor(Math.random()*(e-i+1))+i};var Lu=Sr;function MA(i){var o;let e=[],t=i.groups,r=i.getAttribute("position").array,n=i.getAttribute("normal").array,s=(o=i.getAttribute("uv"))==null?void 0:o.array;return t.forEach(a=>{let l=a.count,c=new _e,u=new Float32Array(l*3),d=new Float32Array(l*3),h=new Float32Array(l*2);for(let p=0;p<l;p++){let f=3*(a.start+p),g=3*p;if(u[g]=r[f],u[g+1]=r[f+1],u[g+2]=r[f+2],d[g]=n[f],d[g+1]=n[f+1],d[g+2]=n[f+2],s){let v=2*(a.start+p),y=2*p;h[y]=s[v],h[y+1]=s[v+1]}}c.setAttribute("position",new Ae(u,3)),c.setAttribute("normal",new Ae(d,3)),s&&c.setAttribute("uv",new Ae(h,2)),e.push(c)}),e}var Nu=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new NA(e)}),this.register(function(e){return new PA(e)}),this.register(function(e){return new IA(e)}),this.register(function(e){return new DA(e)}),this.register(function(e){return new RA(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r){let n=new LA,s=[];for(let o=0,a=this.pluginCallbacks.length;o<a;o++)s.push(this.pluginCallbacks[o](n));n.setPlugins(s),n.write(e,t,r)}},Bt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},kn={};kn[tr]=Bt.NEAREST;kn[ah]=Bt.NEAREST_MIPMAP_NEAREST;kn[lh]=Bt.NEAREST_MIPMAP_LINEAR;kn[tt]=Bt.LINEAR;kn[Dp]=Bt.LINEAR_MIPMAP_NEAREST;kn[Li]=Bt.LINEAR_MIPMAP_LINEAR;kn[ar]=Bt.CLAMP_TO_EDGE;kn[Os]=Bt.REPEAT;kn[hc]=Bt.MIRRORED_REPEAT;var AA={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},TA=12,GG=1179937895,zG=2,_A=8,UG=1313821514,kG=5130562;function Pu(i,e){return i.length===e.length&&i.every(function(t,r){return t===e[r]})}function VG(i){if(window.TextEncoder!==void 0)return new TextEncoder().encode(i).buffer;let e=new Uint8Array(new ArrayBuffer(i.length));for(let t=0,r=i.length;t<r;t++){let n=i.charCodeAt(t);e[t]=n>255?32:n}return e.buffer}function HG(i){return Pu(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function jG(i,e,t){let r={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=e;n<e+t;n++)for(let s=0;s<i.itemSize;s++){let o;i.itemSize>4?o=i.array[n*i.itemSize+s]:s===0?o=i.getX(n):s===1?o=i.getY(n):s===2?o=i.getZ(n):s===3&&(o=i.getW(n)),r.min[s]=Math.min(r.min[s],o),r.max[s]=Math.max(r.max[s],o)}return r}function EA(i){return Math.ceil(i/4)*4}function uv(i,e=0){let t=EA(i.byteLength);if(t!==i.byteLength){let r=new Uint8Array(t);if(r.set(new Uint8Array(i)),e!==0)for(let n=i.byteLength;n<t;n++)r[n]=e;return r.buffer}return i}var CA=null,LA=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,r){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);let n=this;Promise.all(this.pending).then(function(){let s=n.buffers,o=n.json,a=n.options,l=n.extensionsUsed,c=new Blob(s,{type:"application/octet-stream"}),u=Object.keys(l);if(u.length>0&&(o.extensionsUsed=u),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),a.binary===!0){let d=new window.FileReader;d.readAsArrayBuffer(c),d.onloadend=function(){let h=uv(d.result),p=new DataView(new ArrayBuffer(_A));p.setUint32(0,h.byteLength,!0),p.setUint32(4,kG,!0);let f=uv(VG(JSON.stringify(o)),32),g=new DataView(new ArrayBuffer(_A));g.setUint32(0,f.byteLength,!0),g.setUint32(4,UG,!0);let v=new ArrayBuffer(TA),y=new DataView(v);y.setUint32(0,GG,!0),y.setUint32(4,zG,!0);let m=TA+g.byteLength+f.byteLength+p.byteLength+h.byteLength;y.setUint32(8,m,!0);let x=new Blob([v,g,f,p,h],{type:"application/octet-stream"}),b=new window.FileReader;b.readAsArrayBuffer(x),b.onloadend=function(){t(b.result)}}}else if(o.buffers&&o.buffers.length>0){let d=new window.FileReader;d.readAsDataURL(c),d.onloadend=function(){let h=d.result;o.buffers[0].uri=h,t(o)}}else t(o)})}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let r=this.options,n=this.extensionsUsed;try{let s=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],n[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let r=new A;for(let n=0,s=e.count;n<s;n++)if(Math.abs(r.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let r=e.clone(),n=new A;for(let s=0,o=r.count;s<o;s++)n.fromBufferAttribute(r,s),n.x===0&&n.y===0&&n.z===0?n.setX(1):n.normalize(),r.setXYZ(s,n.x,n.y,n.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1,n={};(t.offset.x!==0||t.offset.y!==0)&&(n.offset=t.offset.toArray(),r=!0),t.rotation!==0&&(n.rotation=t.rotation,r=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(n.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){let t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,n,s){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;t===Bt.UNSIGNED_BYTE?a=1:t===Bt.UNSIGNED_SHORT?a=2:a=4;let l=EA(n*e.itemSize*a),c=new DataView(new ArrayBuffer(l)),u=0;for(let p=r;p<r+n;p++)for(let f=0;f<e.itemSize;f++){let g;e.itemSize>4?g=e.array[p*e.itemSize+f]:f===0?g=e.getX(p):f===1?g=e.getY(p):f===2?g=e.getZ(p):f===3&&(g=e.getW(p)),t===Bt.FLOAT?c.setFloat32(u,g,!0):t===Bt.UNSIGNED_INT?c.setUint32(u,g,!0):t===Bt.UNSIGNED_SHORT?c.setUint16(u,g,!0):t===Bt.UNSIGNED_BYTE&&c.setUint8(u,g),u+=a}let d={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(d.target=s),s===Bt.ARRAY_BUFFER&&(d.byteStride=e.itemSize*a),this.byteOffset+=l,o.bufferViews.push(d),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(n){let s=new window.FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){let o=uv(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,n(r.bufferViews.push(a)-1)}})}processAccessor(e,t,r,n){let s=this.options,o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"},l;if(e.array.constructor===Float32Array)l=Bt.FLOAT;else if(e.array.constructor===Uint32Array)l=Bt.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)l=Bt.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)l=Bt.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(r===void 0&&(r=0),n===void 0&&(n=e.count),s.truncateDrawRange&&t!==void 0&&t.index===null){let p=r+n,f=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;r=Math.max(r,t.drawRange.start),n=Math.min(p,f)-r,n<0&&(n=0)}if(n===0)return null;let c=jG(e,r,n),u;t!==void 0&&(u=e===t.index?Bt.ELEMENT_ARRAY_BUFFER:Bt.ARRAY_BUFFER);let d=this.processBufferView(e,l,r,n,u),h={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:n,max:c.max,min:c.min,type:a[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(h)-1}processImage(e,t,r){let n=this,s=n.cache,o=n.json,a=n.options,l=n.pending;s.images.has(e)||s.images.set(e,{});let c=s.images.get(e),u=t===Qt?"image/png":"image/jpeg",d=u+":flipY/"+r.toString();if(c[d]!==void 0)return c[d];o.images||(o.images=[]);let h={mimeType:u};if(a.embedImages){let f=CA=CA||document.createElement("canvas");f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let g=f.getContext("2d");if(r===!0&&(g.translate(0,f.height),g.scale(1,-1)),typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)g.drawImage(e,0,0,f.width,f.height);else{t!==Qt&&t!==jt&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let v=new Uint8ClampedArray(e.height*e.width*4);if(t===Qt)for(let y=0;y<v.length;y+=4)v[y+0]=e.data[y+0],v[y+1]=e.data[y+1],v[y+2]=e.data[y+2],v[y+3]=e.data[y+3];else for(let y=0,m=0;y<v.length;y+=4,m+=3)v[y+0]=e.data[m+0],v[y+1]=e.data[m+1],v[y+2]=e.data[m+2],v[y+3]=255;g.putImageData(new ImageData(v,e.width,e.height),0,0)}a.binary===!0?l.push(new Promise(function(v){f.toBlob(function(y){n.processBufferViewImage(y).then(function(m){h.bufferView=m,v()})},u)})):h.uri=f.toDataURL(u)}else h.uri=e.src;let p=o.images.push(h)-1;return c[d]=p,p}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let r={magFilter:kn[e.magFilter],minFilter:kn[e.minFilter],wrapS:kn[e.wrapS],wrapT:kn[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){let t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);let n={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(n.name=e.name),this._invokeAll(function(o){o.writeTexture&&o.writeTexture(e,n)});let s=r.textures.push(n)-1;return t.textures.set(e,s),s}processMaterial(e){let t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);let n={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(Pu(s,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap)if(e.metalnessMap===e.roughnessMap){let a={index:this.processTexture(e.metalnessMap)};this.applyTextureTransform(a,e.metalnessMap),n.pbrMetallicRoughness.metallicRoughnessTexture=a}else console.warn("THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.");if(e.map){let a={index:this.processTexture(e.map)};this.applyTextureTransform(a,e.map),n.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){let a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),l=Math.max(a.r,a.g,a.b);if(l>1&&(a.multiplyScalar(1/l),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),l>0&&(n.emissiveFactor=a.toArray()),e.emissiveMap){let c={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(c,e.emissiveMap),n.emissiveTexture=c}}if(e.normalMap){let a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),n.normalTexture=a}if(e.aoMap){let a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),n.occlusionTexture=a}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),e.side===Yt&&(n.doubleSided=!0),e.name!==""&&(n.name=e.name),this.serializeUserData(e,n),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,n)});let o=r.materials.push(n)-1;return t.materials.set(e,o),o}processMesh(e){let t=this.cache,r=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,b=e.material.length;x<b;x++)n.push(e.material[x].uuid);else n.push(e.material.uuid);let s=n.join(":");if(t.meshes.has(s))return t.meshes.get(s);let o=e.geometry,a;if(e.isLineSegments?a=Bt.LINES:e.isLineLoop?a=Bt.LINE_LOOP:e.isLine?a=Bt.LINE_STRIP:e.isPoints?a=Bt.POINTS:a=e.material.wireframe?Bt.LINES:Bt.TRIANGLES,o.isBufferGeometry!==!0)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");let l={},c={},u=[],d=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=o.getAttribute("normal");p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let f=null;for(let x in o.attributes){if(x.substr(0,5)==="morph")continue;let b=o.attributes[x];if(x=h[x]||x.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(x)||(x="_"+x),t.attributes.has(this.getUID(b))){c[x]=t.attributes.get(this.getUID(b));continue}f=null;let T=b.array;x==="JOINTS_0"&&!(T instanceof Uint16Array)&&!(T instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new Fe(new Uint16Array(T),b.itemSize,b.normalized));let S=this.processAccessor(f||b,o);S!==null&&(c[x]=S,t.attributes.set(this.getUID(b),S))}if(p!==void 0&&o.setAttribute("normal",p),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let x=[],b=[],w={};if(e.morphTargetDictionary!==void 0)for(let T in e.morphTargetDictionary)w[e.morphTargetDictionary[T]]=T;for(let T=0;T<e.morphTargetInfluences.length;++T){let S={},M=!1;for(let E in o.morphAttributes){if(E!=="position"&&E!=="normal"){M||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),M=!0);continue}let C=o.morphAttributes[E][T],_=E.toUpperCase(),O=o.attributes[E];if(t.attributes.has(this.getUID(C))){S[_]=t.attributes.get(this.getUID(C));continue}let P=C.clone();if(!o.morphTargetsRelative)for(let D=0,G=C.count;D<G;D++)P.setXYZ(D,C.getX(D)-O.getX(D),C.getY(D)-O.getY(D),C.getZ(D)-O.getZ(D));S[_]=this.processAccessor(P,o),t.attributes.set(this.getUID(O),S[_])}d.push(S),x.push(e.morphTargetInfluences[T]),e.morphTargetDictionary!==void 0&&b.push(w[T])}l.weights=x,b.length>0&&(l.extras={},l.extras.targetNames=b)}let g=Array.isArray(e.material);if(g&&o.groups.length===0)return null;let v=g?e.material:[e.material],y=g?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,b=y.length;x<b;x++){let w={mode:a,attributes:c};if(this.serializeUserData(o,w),d.length>0&&(w.targets=d),o.index!==null){let S=this.getUID(o.index);(y[x].start!==void 0||y[x].count!==void 0)&&(S+=":"+y[x].start+":"+y[x].count),t.attributes.has(S)?w.indices=t.attributes.get(S):(w.indices=this.processAccessor(o.index,o,y[x].start,y[x].count),t.attributes.set(S,w.indices)),w.indices===null&&delete w.indices}let T=this.processMaterial(v[y[x].materialIndex]);T!==null&&(w.material=T),u.push(w)}l.primitives=u,r.meshes||(r.meshes=[]),this._invokeAll(function(x){x.writeMesh&&x.writeMesh(e,l)});let m=r.meshes.push(l)-1;return t.meshes.set(s,m),m}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let r=e.isOrthographicCamera,n={type:r?"orthographic":"perspective"};return r?n.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:rt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(n.name=e.type),t.cameras.push(n)-1}processAnimation(e,t){let r=this.json,n=this.nodeMap;r.animations||(r.animations=[]),e=Nu.Utils.mergeMorphTargetTracks(e.clone(),t);let s=e.tracks,o=[],a=[];for(let l=0;l<s.length;++l){let c=s[l],u=lt.parseTrackName(c.name),d=lt.findNode(t,u.nodeName),h=AA[u.propertyName];if(u.objectName==="bones"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(u.objectIndex):d=void 0),!d||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name),null;let p=1,f=c.values.length/c.times.length;h===AA.morphTargetInfluences&&(f/=d.morphTargetInfluences.length);let g;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(g="CUBICSPLINE",f/=3):c.getInterpolation()===Ma?g="STEP":g="LINEAR",a.push({input:this.processAccessor(new Fe(c.times,p)),output:this.processAccessor(new Fe(c.values,f)),interpolation:g}),o.push({sampler:a.length-1,target:{node:n.get(d),path:h}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:a,channels:o}),r.animations.length-1}processSkin(e){let t=this.json,r=this.nodeMap,n=t.nodes[r.get(e)],s=e.skeleton;if(s===void 0)return null;let o=e.skeleton.bones[0];if(o===void 0)return null;let a=[],l=new Float32Array(s.bones.length*16),c=new Me;for(let d=0;d<s.bones.length;++d)a.push(r.get(s.bones[d])),c.copy(s.boneInverses[d]),c.multiply(e.bindMatrix).toArray(l,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Fe(l,16)),joints:a,skeleton:r.get(o)}),n.skin=t.skins.length-1}processNode(e){let t=this.json,r=this.options,n=this.nodeMap;t.nodes||(t.nodes=[]);let s={};if(r.trs){let a=e.quaternion.toArray(),l=e.position.toArray(),c=e.scale.toArray();Pu(a,[0,0,0,1])||(s.rotation=a),Pu(l,[0,0,0])||(s.translation=l),Pu(c,[1,1,1])||(s.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),HG(e.matrix)===!1&&(s.matrix=e.matrix.elements);if(e.name!==""&&(s.name=String(e.name)),this.serializeUserData(e,s),e.isMesh||e.isLine||e.isPoints){let a=this.processMesh(e);a!==null&&(s.mesh=a)}else e.isCamera&&(s.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let a=[];for(let l=0,c=e.children.length;l<c;l++){let u=e.children[l];if(u.visible||r.onlyVisible===!1){let d=this.processNode(u);d!==null&&a.push(d)}}a.length>0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});let o=t.nodes.push(s)-1;return n.set(e,o),o}processScene(e){let t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);let n={};e.name!==""&&(n.name=e.name),t.scenes.push(n);let s=[];for(let o=0,a=e.children.length;o<a;o++){let l=e.children[o];if(l.visible||r.onlyVisible===!1){let c=this.processNode(l);c!==null&&s.push(c)}}s.length>0&&(n.nodes=s),this.serializeUserData(e,n)}processObjects(e){let t=new Gr;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(n){n.beforeParse&&n.beforeParse(e)});let r=[];for(let n=0;n<e.length;n++)e[n]instanceof Gr?this.processScene(e[n]):r.push(e[n]);r.length>0&&this.processObjects(r);for(let n=0;n<this.skins.length;++n)this.processSkin(this.skins[n]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll(function(n){n.afterParse&&n.afterParse(e)})}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}},NA=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let r=this.writer,n=r.json,s=r.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(n.extensions=n.extensions||{},n.extensions[this.name]={lights:[]},s[this.name]=!0);let a=n.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},PA=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},IA=class{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let r=this.writer,n=r.extensionsUsed,s={};t.pbrMetallicRoughness.baseColorFactor&&(s.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let o=[1,1,1];if(e.specular.toArray(o,0),s.specularFactor=o,s.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(s.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let a={index:r.processTexture(e.specularMap)};r.applyTextureTransform(a,e.specularMap),s.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}},DA=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let r=this.writer,n=r.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){let o={index:r.processTexture(e.transmissionMap)};r.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}},RA=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.thickness===0)return;let r=this.writer,n=r.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){let o={index:r.processTexture(e.thicknessMap)};r.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationTint.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,n[this.name]=!0}};Nu.Utils={insertKeyframe:function(i,e){let t=.001,r=i.getValueSize(),n=new i.TimeBufferType(i.times.length+1),s=new i.ValueBufferType(i.values.length+r),o=i.createInterpolant(new i.ValueBufferType(r)),a;if(i.times.length===0){n[0]=e;for(let l=0;l<r;l++)s[l]=0;a=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<t)return 0;n[0]=e,n.set(i.times,1),s.set(o.evaluate(e),0),s.set(i.values,r),a=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<t)return i.times.length-1;n[n.length-1]=e,n.set(i.times,0),s.set(i.values,0),s.set(o.evaluate(e),i.values.length),a=n.length-1}else for(let l=0;l<i.times.length;l++){if(Math.abs(i.times[l]-e)<t)return l;if(i.times[l]<e&&i.times[l+1]>e){n.set(i.times.slice(0,l+1),0),n[l+1]=e,n.set(i.times.slice(l+1),l+2),s.set(i.values.slice(0,(l+1)*r),0),s.set(o.evaluate(e),(l+1)*r),s.set(i.values.slice((l+1)*r),(l+2)*r),a=l+1;break}}return i.times=n,i.values=s,a},mergeMorphTargetTracks:function(i,e){let t=[],r={},n=i.tracks;for(let s=0;s<n.length;++s){let o=n[s],a=lt.parseTrackName(o.name),l=lt.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(Aa)}let c=l.morphTargetInfluences.length,u=l.morphTargetDictionary[a.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let d;if(r[l.uuid]===void 0){d=o.clone();let p=new d.ValueBufferType(c*d.times.length);for(let f=0;f<d.times.length;f++)p[f*c+u]=d.values[f];d.name=(a.nodeName||"")+".morphTargetInfluences",d.values=p,r[l.uuid]=d,t.push(d);continue}let h=o.createInterpolant(new o.ValueBufferType(1));d=r[l.uuid];for(let p=0;p<d.times.length;p++)d.values[p*c+u]=h.evaluate(d.times[p]);for(let p=0;p<o.times.length;p++){let f=this.insertKeyframe(d,o.times[p]);d.values[f*c+u]=o.values[p]}}return i.tracks=t,i}};var WG,OA=new Promise(i=>{WG=i});var zA=Hv(GA());var ap={isPublish:!1,gltfQueue:[]};function Iu(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var $G=new Nu;function UA(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(ap.isPublish)e=Pf.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let n=e.originalGeometry;if(n){let s=e.userData;e=n.clone(),e.userData=s}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let n=e.userData;e=r,e.userData=n}if(!ap.isPublish)i[e.uuid]=e.toJSON();else{let n={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(n.name=e.name),Object.keys(e.userData).length>0&&(n.userData=re({},e.userData));let s=e.index===null,o=new Oi;if(Array.isArray(t))MA(e).forEach((l,c)=>{let u=new Wt(l,new il);o.add(u),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(s=!0)});else{let a=new Wt(e,new il);o.add(a)}ap.gltfQueue.push(new Promise(async a=>{await Promise.all(ap.gltfQueue),$G.parse(o,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:u,addIndex:d}=await OA,h=c.readJSON({json:gg(l),resources:{}});h.createExtension(u).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),s&&await h.transform(d);try{let{json:p,resources:f}=c.writeJSON(h),g=zA.default.fromByteArray(new Uint8Array(f[".bin"]));p.buffers[0].uri=`data:application/octet-stream;base64,${g}`,a()}catch(p){a()}},{})})),i[e.uuid]=n}}else{let r=e.userData;if(r.type==="VectorGeometry"){let n=e.userData.shape;r=Object.assign({},r,{shape:n.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function Zl(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function kA(i){let e=[];for(let t in i)e.push(i[t]);return e}var Es;(function(r){r[r.started=0]="started",r[r.ended=1]="ended",r[r.once=2]="once"})(Es||(Es={}));var Mi=class{constructor(e){this.object=e;this.uuid=rt.generateUUID();this.states=[];this.events=[];this._scrollCounter=null;this._interpolateMaterialBetweenValues=(e,t,r,n=t.getNames())=>{var s,o,a,l,c;for(let u=0,d=n.length;u<d;++u){let h=n[u],p=`f${t.id}_${h}`,f=`f${r.id}_${h}`,g=t.uniforms[p],v=r.uniforms[f];if(!(!g||g.value===void 0||v===void 0)){if(h==="mode"){g.value!==v.value&&(g.value=v.value);continue}if(typeof g.value=="boolean"){g.value!==v.value&&(g.value=v.value);continue}if(typeof g.value=="number"){g.value!==v.value&&((s=this._animation)==null||s.add({targets:g,value:Number(v.value)},0));continue}if("isVector2"in g.value){g.value.equals(v.value)===!1&&((o=this._animation)==null||o.add({targets:g,x:v.value.x,y:v.value.y},0));continue}if("isVector3"in g.value){g.value.equals(v.value)===!1&&((a=this._animation)==null||a.add({targets:g,x:v.value.x,y:v.value.y,z:v.value.z},0));continue}if("isColor"in g.value){g.value.equals(v.value)===!1&&((l=this._animation)==null||l.add({targets:g.value,r:v.value.r,g:v.value.g,b:v.value.b},0));continue}}}if(t.backLayer){let d=`f${t.backLayer.id}_alpha`,h=t.backLayer.uniforms[d];(c=this._animation)==null||c.add({targets:h,value:0},0)}};this._interpolateMaterialBetweenLayers=(e,t,r)=>{var c,u,d;let n=e.layersList;if(t.backLayer===void 0){let h=r.getValues();h.alpha=0,t.backLayer=n.addLayerBeforeAt(h,t),t.backLayer.isBack=!0,e.dispose()}let s=`f${t.id}_alpha`,o=`f${(c=t.backLayer)==null?void 0:c.id}_alpha`,a=t.uniforms[s],l=(u=t.backLayer)==null?void 0:u.uniforms[o];(d=this._animation)==null||d.add({targets:a,value:0},0).add({targets:l,value:r.uniforms[`f${r.id}_alpha`].value},0)};this._interpolateMaterialTexture=(e,t,r)=>{var h;let n=`f${t.id}_texture`,s=t.uniforms[n].value,o=r.uniforms[`f${r.id}_texture`].value,a=t.uniforms[`f${t.id}_crop`],l=r.uniforms[`f${r.id}_crop`];a&&l&&a.value!==l.value&&(a.value=Number(l.value)),(s.wrapS!==o.wrapS||s.wrapT!==o.wrapT)&&(s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.needsUpdate=!0);let c=s.matrix,u=o.matrix;if(c.equals(u)===!1){let p={repeatX:s.repeat.x,repeatY:s.repeat.y,offsetX:s.offset.x,offsetY:s.offset.y};(h=this._animation)==null||h.add({targets:p,repeatX:o.repeat.x,repeatY:o.repeat.y,offsetX:o.offset.x,offsetY:o.offset.y,update:()=>{s.repeat.set(p.repeatX,p.repeatY),s.offset.set(p.offsetX,p.offsetY),s.updateMatrix(),s.needsUpdate=!0}},0)}let d=["alpha","mode"];t.type==="displace_map"&&d.push("intensity"),this._interpolateMaterialBetweenValues(e,t,r,d)};this._interpolateMaterialGradient=(e,t,r)=>{var p;let n=10,s=`f${t.id}_steps`,o=`f${r.id}_steps`,a=t.uniforms[s],l=r.uniforms[o],c=`f${t.id}_colors`,u=`f${r.id}_colors`,d=t.uniforms[c],h=r.uniforms[u];for(let f=0;f<n;++f){let g=d.value[f],v=h.value[f];if(a.value[f]!==l.value[f]||!g.equals(v)){let y={value:a.value[f]};(p=this._animation)==null||p.add({targets:[y,g],value:l.value[f],x:v.x,y:v.y,z:v.z,w:v.w,update:()=>{a.value[f]=y.value}},0)}}this._interpolateMaterialBetweenValues(e,t,r,["alpha","mode","gradientType","smooth","offset","morph","angle","origin","direction","near","far"])}}static get isAllAnimationsEnded(){let e;for(let t in Mi.isAnimating){if(Mi.isAnimating[t]===2)return Mi.isAnimating[t]=1,!1;if(Mi.isAnimating[t]===0)return!1;e=!0}return e}computeCache(){return this.cache={mouseDown:this.events.find(e=>e.type===Je.MOUSE_DOWN),mouseUp:this.events.find(e=>e.type===Je.MOUSE_UP),mouseHover:this.events.find(e=>e.type===Je.MOUSE_HOVER),start:this.events.find(e=>e.type===Je.START),lookAt:this.events.find(e=>e.type===Je.LOOK_AT),follow:this.events.find(e=>e.type===Je.FOLLOW),keyDown:this.events.filter(e=>e.type===Je.KEY_DOWN),keyUp:this.events.filter(e=>e.type===Je.KEY_UP),scroll:this.events.find(e=>e.type===Je.SCROLL)},this.cache}newState(e){let t=new Qi;return t.name=e,t.update(this.object),this.states.push(t),t}addState(e,t){this.states.splice(t,0,e)}removeState(e){this.states.splice(e,1)}selectState(e){e!==void 0&&this.states[e].execute(this.object)}hasEventType(e,t){return e===Je.KEY_DOWN||e===Je.KEY_UP?t===void 0?!1:this.events.some(r=>r.type===e&&r.key===t):this.events.some(r=>r.type===e)}newEvent(){let e=[Je.MOUSE_DOWN,Je.MOUSE_UP,Je.MOUSE_HOVER,Je.KEY_DOWN].find(r=>this.hasEventType(r)===!1),t=new vo(e);return this.events.push(t),t}addEvent(e,t){this.events.splice(t,0,e);let r=this.events[t].targets;for(let n=0,s=r.length;n<s;++n)r[n].object!==void 0&&aa.add(r[n])}removeEvent(e){let t=this.events[e].targets;for(let r=0,n=t.length;r<n;++r)t[r].object!==void 0&&aa.delete(t[r]);this.events.splice(e,1)}copy(e){for(let t=0,r=e.states.length;t<r;++t)this.addState(e.states[t].clone(),t);for(let t=0,r=e.events.length;t<r;++t){this.addEvent(e.events[t].clone(),t);let n=e.events[t].targets;for(let s=0,o=n.length;s<o;++s){let a=n[s].clone();n[s].object===e.object?(a.object=this.object,a.state=this.states[e.states.indexOf(n[s].state)]):(a.object=n[s].object,a.state=n[s].state),this.events[t].addTarget(a,s)}}return this}clone(e){return new Mi(e).copy(this)}toJSON(e){e===void 0&&(e={nodes:{},geometries:{},materials:{},textures:{},images:{},interactionStates:{}});let t={uuid:this.uuid};if(this.states.length>0){t.states=[];for(let r=0,n=this.states.length;r<n;++r)t.states.push(Iu(e.interactionStates,this.states[r],e))}if(this.events.length>0){t.events=[];for(let r=0,n=this.events.length;r<n;++r)t.events.push(this.events[r].toJSON())}return t}fromJSON(e,t,r){var n;if(this.uuid=e.uuid,this.states=[],this.events=[],e.states!==void 0)for(let s=0,o=e.states.length;s<o;++s){let a=r[e.states[s]];this.states.push(a),((n=a.camera)==null?void 0:n.targetOffset)===-1&&(a.camera.targetOffset=this.object.getDistanceToTarget())}if(e.events!==void 0)for(let s=0,o=e.events.length;s<o;++s)this.events.push(new vo().fromJSON(e.events[s],t,r));return this}start(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._scrollCounter=null,this._removeBackLayer()),this.states.length>1?(this.states[0].execute(this.object),this._currentState=this.states[0],this._prevState=void 0):this._state0!==void 0?this._state0.execute(this.object):this.events.some(e=>e.type===Je.LOOK_AT||e.type===Je.FOLLOW)&&(this._state0=new Qi,this._state0.update(this.object))}end(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._removeBackLayer()),this.states.length>1?this.states[0].execute(this.object):this._state0!==void 0&&(this._state0.execute(this.object),this._state0=void 0),this._currentState=void 0,this._prevState=void 0}lookAt(e){var t;this.object.lookAt(e),this.object.updateMatrix(),(t=this._animation)==null||t.finished.then(()=>{this.lookAt(e),this.object.updateMatrix()})}follow(e){this.object.position.copy(e),this.object.parent!==null&&this.object.position.applyMatrix4(new Me().copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4(new Me().copy(this.object.hiddenMatrix).invert()),this.object.updateMatrix()}play(e){this.object.visible&&e.state!==void 0&&this.animate(e.state,e)}seek(e,t,r){var n;this._scrollCounter===null&&(this.object.visible&&e.state!==void 0&&this.animate(e.state,e,!0),this._scrollCounter=0),this._scrollCounter+=t,this._scrollCounter=Math.min(Math.max(this._scrollCounter,0),r),Mi.isAnimating[e.state.uuid]=2,(n=this._animation)==null||n.seek(this._scrollCounter/r*e.duration)}reverse(e){this.object.visible&&this._prevState!==void 0&&this.animate(this._prevState,e)}_removeBackLayer(){if("material"in this.object){let e=this.object.material;if(e instanceof Array)for(let t=0,r=e.length;t<r;++t){let n=e[t].layersList,s=n.head;for(;s;)if(s.backLayer){delete s.backLayer;let o=s.next;n.removeLayer(s.id),s=o}else s.isBack&&(s.isBack=!1),s=s.next}else{let t=e.layersList,r=t.head;for(;r;)for(;r;)if(r.backLayer){delete r.backLayer;let n=r.next;t.removeLayer(r.id),r=n}else r.isBack&&(r.isBack=!1),r=r.next}}}getTimingFunction(e,t,r){switch(e){case Si.LINEAR:return"cubicBezier( 0, 0, 1, 1 )";case Si.EASE:return"cubicBezier( .25, .1, .25, 1 )";case Si.EASE_IN:return"cubicBezier( .42, 0, 1, 1 )";case Si.EASE_OUT:return"cubicBezier( 0, 0, .58, 1 )";case Si.EASE_IN_OUT:return"cubicBezier( .42, 0, .58, 1 )";case Si.CUBIC:return`cubicBezier( ${t[0]}, ${t[1]}, ${t[2]}, ${t[3]} )`;case Si.SPRING:return`spring( ${r.mass}, ${r.stiffness}, ${r.damping}, ${r.velocity} )`}}animate(e,t,r=!1){var n,s,o,a,l,c;if(Mi.isAnimating[e.uuid]=0,this._currentState===e){if((n=this._animation)==null?void 0:n.reversed){let u=(o=(s=this._animation)==null?void 0:s.currentTime)!=null?o:0;(a=this._animation)==null||a.reset(),(l=this._animation)==null||l.seek(u),(c=this._animation)==null||c.play()}}else this._prevState=this._currentState,this._currentState=e,this._animation!==void 0&&(Mi.isAnimating[this._prevState.uuid]=1,this._animation.pause()),this._removeBackLayer(),t.cycle===!0&&t.repeat===!0?this._animation=Lu.timeline({duration:t.duration,delay:t.delay/2,endDelay:t.delay/2,direction:"alternate",loop:!0,rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):t.cycle===!0&&t.repeat===!1?this._animation=Lu.timeline({duration:t.duration,delay:t.delay,endDelay:t.delay/2,direction:"alternate",rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):t.cycle===!1&&t.repeat===!0?this._animation=Lu.timeline({duration:t.duration,delay:t.delay,direction:"normal",loop:!0,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}):this._animation=Lu.timeline({duration:t.duration,delay:t.delay,direction:"normal",easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters),autoplay:!r}),this._animation.finished.then(()=>{r||(this._removeBackLayer(),this._animation=void 0,Mi.isAnimating[e.uuid]=1)}),this.animateMatrix(e),this.animateGeometry(e),this.animateMaterial(e),this.animateCamera(e),this.animateLight(e.light)}animateMatrix(e){var s,o,a,l;if(this.object.position.equals(e.position)===!1){let c=this.object.position.clone(),u={t:0};(s=this._animation)==null||s.add({targets:u,t:1,update:()=>{this.object.position.lerpVectors(c,e.position,u.t),this.object.updateMatrix()}},0)}if(this.object.scale.equals(e.scale)===!1){let c=this.object.scale.clone(),u={t:0};(o=this._animation)==null||o.add({targets:u,t:1,update:()=>{this.object.scale.lerpVectors(c,e.scale,u.t),this.object.updateMatrix()}},0)}if(this.object.rotation.equals(e.rotation)===!1){let c=this.object.quaternion.clone(),u={t:0},d={x:this.object.rotation.x,y:this.object.rotation.y,z:this.object.rotation.z},h={x:e.rotation.x-this.object.rotation.x,y:e.rotation.y-this.object.rotation.y,z:e.rotation.z-this.object.rotation.z},p=e.rotation.clone(),f=new Ft().setFromEuler(p);(a=this._animation)==null||a.add({targets:u,t:1,update:Object.values(h).every(g=>Math.abs(g)<2*Math.PI)?()=>{q1(c,f,this.object.quaternion,u.t),this.object.updateMatrix()}:()=>{this.object.rotation.x=d.x+h.x*u.t,this.object.rotation.y=d.y+h.y*u.t,this.object.rotation.z=d.z+h.z*u.t,this.object.updateMatrix()}},0)}let t=new A,r=new Ft,n=new A;if(e.hiddenMatrix.decompose(t,r,n),"hiddenMatrix"in this.object){let c=new A,u=new Ft,d=new A;if(this.object.hiddenMatrix.decompose(c,u,d),this.object.hiddenMatrix.equals(e.hiddenMatrix)===!1){let h=new A,p=new Ft,f=new A,g={t:0},v=this.object.hiddenMatrix;(l=this._animation)==null||l.add({targets:g,t:1,update:()=>{p.slerpQuaternions(u,r,g.t),h.lerpVectors(c,t,g.t),f.lerpVectors(d,n,g.t),v.compose(h,p,f)}},0)}}}animateGeometry(e){var t;if("geometry"in this.object&&e.geometry!==void 0){let n=this.object.geometry.userData.parameters,s=e.geometry;if(s.width!==n.width||s.height!==n.height||s.depth!==n.depth){let o=this.object;(t=this._animation)==null||t.add({targets:n,width:s.width,height:s.height,depth:s.depth,update:()=>{o.updateGeometry({parameters:{width:n.width,height:n.height,depth:n.depth}})}},0)}}}animateMaterial(e){if("material"in this.object&&e.material!==void 0)if(this.object.material instanceof Array)for(let t=0,r=this.object.material.length;t<r;++t)this._interpolateMaterial(this.object.material[t],e.material[t]);else{if(this.object.material.userData.isAsset)return;this._interpolateMaterial(this.object.material,e.material)}}animateCamera(e){var t,r;if(this.object.objectType==="CombinedCamera"&&e.camera!==void 0){let n=this.object,s=n.cameraType==="OrthographicCamera"?e.camera.zoomOrtho:e.camera.zoomPersp;n.zoom!==s&&((t=this._animation)==null||t.add({targets:n,zoom:s,update:()=>{n.updateProjectionMatrix()}},0)),n.targetOffset!==e.camera.targetOffset&&((r=this._animation)==null||r.add({targets:n,targetOffset:e.camera.targetOffset},0))}}animateLight(e){var t,r;if(e!==void 0&&(this.object.objectType==="LightDirectional"||this.object.objectType==="LightSpot"||this.object.objectType==="LightPoint")){let n=this.object;n.intensity!==e.intensity&&((t=this._animation)==null||t.add({targets:n,intensity:e.intensity},0)),Ur.equals(n.color,e.color)||(r=this._animation)==null||r.add({targets:n.color,r:e.color.r,g:e.color.g,b:e.color.b},0)}}_interpolateMaterial(e,t){let r=e.layersList.head,n=0;for(;r;){if(r.isBack===!0){r=r.next;continue}let s=t.layersList[n++];if(kf(r)){let o=r.uniforms[`f${r.id}_texture`].value,a=s.uniforms[`f${s.id}_texture`].value;o.image===a.image?this._interpolateMaterialTexture(e,r,s):this._interpolateMaterialBetweenLayers(e,r,s)}else r.type==="gradient"||r.type==="depth"?r.uniforms[`f${r.id}_gradientType`].value===s.uniforms[`f${s.id}_gradientType`].value?this._interpolateMaterialGradient(e,r,s):this._interpolateMaterialBetweenLayers(e,r,s):this._interpolateMaterialBetweenValues(e,r,s);r=r.next}}},xo=Mi;xo.isAnimating={};var lp=i=>class extends i{hasEntityChild(){return this.children.some(t=>Of(t))}isDescendantOf(t){t instanceof Ze&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let n=new Me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),n.multiply(t.parent.matrixWorld)),Of(t)?t.hiddenMatrix.premultiply(n):t.applyMatrix4(n),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,n={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},n.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let o of this.children)(Of(o)||o instanceof On)&&s.children.push(o.toJSON(t).object)}if(r){let o=Zl(t.geometries),a=Zl(t.materials),l=Zl(t.textures),c=Zl(t.images),u=Zl(t.interactionStates),d=kA(t.nodes);o.length>0&&(n.geometries=o),a.length>0&&(n.materials=a),l.length>0&&(n.textures=l),c.length>0&&(n.images=c),u.length>0&&(n.interactionStates=u),d.length>0&&(n.nodes=d)}return n.object=s,n}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var En=i=>"isEntity"in i,VA=i=>"isAbstractMesh"in i,ti=i=>class extends lp(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Me;this.interaction=new xo(this);this._singleBBox=new Ff;this._recursiveBBox=new Ff;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)En(r)&&r.traverseEntity(n=>{Ss(n)&&n.visible&&(n.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){return this.interaction.cache===void 0&&this.interaction.computeCache(),this.interaction.cache}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{En(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)En(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let n=this.parent;if(t&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),r===!0)for(let n of t.children)En(n)&&this.add(n.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),r===!0)for(let n of t.children)En(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let t=new Me,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let n of this.children)En(n)&&n.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),n=r.object;return this.raycastLock===!0&&(n.raycastLock=!0),this.scaleLock===!0&&(n.scaleLock=!0),n.hiddenMatrix=this.hiddenMatrix.toArray(),this.interaction!==void 0&&(n.interaction=this.interaction.toJSON(t)),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Me}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return El(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=re({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return El(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};var cp=class extends Ze{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new A),n=.1;this.parameters=Vd.defaultData(r.toArray(),n),Jo(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let n=this.object.shallowClone(!1);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*rt.DEG2RAD,n=t.end*rt.DEG2RAD,s=r-n,o=new jn(t.rotation[0]*rt.DEG2RAD,t.rotation[1]*rt.DEG2RAD,t.rotation[2]*rt.DEG2RAD),a;switch(t.axis){case"z":a=new A(0,0,1);break;case"y":a=new A(0,1,0);break;default:case"x":a=new A(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let u=s/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,u,0);break;case"y":c.rotation.set(0,0,u);break;case"z":c.rotation.set(u,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=o.x,c.rotation.y+=o.y,c.rotation.z+=o.z):c.rotation.copy(o)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new jn(t.rotation[0]*rt.DEG2RAD,t.rotation[1]*rt.DEG2RAD,t.rotation[2]*rt.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=t.scale[0]*n+1,s.scale.y=t.scale[1]*n+1,s.scale.z=t.scale[2]*n+1,s.rotation.x=r.x*n,s.rotation.y=r.y*n,s.rotation.z=r.z*n,s.position.x=t.position[0]*n,s.position.y=t.position[1]*n,s.position.z=t.position[2]*n}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let n={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new A(r.size[0]*(r.count[0]-n.x)*.5,r.size[1]*(r.count[1]-n.y)*.5,r.size[2]*(r.count[2]-n.z)*.5);for(let o=0;o<r.count[0];o++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*o-s.x,c.position.y=r.size[1]*a-s.y,c.position.z=r.size[2]*l-s.z}}else for(let n=0;n<r.count[0];n++)for(let s=0;s<r.count[1];s++)for(let o=0;o<r.count[2];o++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*n,a.position.y=-r.size[1]*s,a.position.z=-r.size[2]*o}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),Jo(this.parameters,e),this.update(),this}};var Lr=class extends ti(Wt){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Ty[t.userData.type],n=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,n)),o=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=o,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){vu.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=xu(t),n=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,n).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new cp(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=UA(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let n=[];for(let s=0,o=this.material.length;s<o;s++)n.push(Iu(e.materials,this.material[s],e));r.material=n}else r.material=Iu(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new cp(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,n;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(n=e.receiveShadow)!=null?n:!0),this}};var up=new F,ca=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new F(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=pn.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,n=this.message.length;r<n;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,n;for(n=e;n>=0;n-=1)if(this.message[n].char===" "){r=!1,t.length===0&&(n-=1,t.splice(0,0,this.message[n]));break}else t.splice(0,0,this.message[n]);return r?t=[]:this.message.splice(n+1,t.length),t}getWord(e=0,t=1){let r=[],n=e;for(n=e;;n+=t){if(!this.message[n]||this.message[n].char===" "){r.length===0&&this.message[n]&&(r.push(this.message[n]),this.message.splice(n,1));break}t>0?(r.push(this.message[n]),this.message.splice(n,1),n-=t):(r.splice(0,0,this.message[n]),this.message.splice(n,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,n=e;for(;n>=0&&n<this.message.length;){if(this.message[n].char===" "){r===0&&(r=this.message[n].charSize);break}r+=this.message[n].charSize,n+=t}return(n<0||n>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let n=t;n<=r;n+=1)this.message[n].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,n,s){switch(r){case pn.Left:this.leftAlign(e,s);break;case pn.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case pn.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case pn.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){up.set(t,r);let n=this.message.length;for(let s=0;s<n;s++)this.message[s].updatePosition(this.message[s].localPosition.add(up),e)}leftAlign(e,t){this.align=pn.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=pn.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=pn.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=pn.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let n=this.countSpaces();if(n===0){this.offsetCharacters(t,0,r);return}let s=e/n,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),up.set(o,r),this.message[a].updatePosition(this.message[a].localPosition.add(up),t)}clone(){let e=new ca(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var ez=new A(0,0,1),HA=new A,jA=new A,WA=new Dt,ua=class extends Lr{constructor(e=jr.create({}),t=new sn({side:Yt})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new xr;this._onShapeUpdate=()=>{if(this.geometry instanceof mu){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),WA.getNormalMatrix(this.matrixWorld),HA.copy(ez).applyMatrix3(WA).normalize(),jA.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(HA,jA)}clone(e){let t=this.shape.clone(),r=this.material.clone(),n=this.geometry.userData,s=jr.create(Object.assign({},n,{shape:t})),o=new ua(s,r).copy(this,e);return o.shape=t,t.update(),o}raycast(e,t){Lr.prototype.raycast.call(this,e,t)}};var es=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new In(30,30,30),e};var hp=new Ni,dv=new ln,JA=new Me,ts=(i,e,t,r,n=!1)=>{let s=e,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),dv.copy(s.boundingSphere),dv.applyMatrix4(o),t.ray.intersectsSphere(dv)===!1||(JA.copy(o).invert(),hp.copy(t.ray).applyMatrix4(JA),s.boundingBox!==null&&hp.intersectsBox(s.boundingBox)===!1))return;let a,l,c,u,d=s.index,h=s.attributes.position,p=s.drawRange,f,g;if(n===!1){let y=Math.max(0,p.start),m=Math.min(d.count,p.start+p.count);for(f=y,g=m;f<g;f+=3)if(l=d.getX(f),c=d.getX(f+1),u=d.getX(f+2),a=v(i,t,hp,h,l,c,u),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let m=s.attributes.position,x=new A,b=new A,w=new A,T=new A,S=2,E=1/((i.scale.x+i.scale.y+i.scale.z)/3),C=E*E,_=Math.max(0,p.start),O=Math.min(m.count,p.start+p.count);for(let P=_,D=O-1;P<D;P+=S){if(x.fromBufferAttribute(m,P),b.fromBufferAttribute(m,P+1),hp.distanceSqToSegment(x,b,T,w)>C)continue;T.applyMatrix4(i.matrixWorld);let R=t.ray.origin.distanceTo(T);R<t.near||R>t.far||r.push({distance:R,point:w.clone().applyMatrix4(i.matrixWorld),object:i})}}function v(y,m,x,b,w,T,S){let M=new A,E=new A,C=new A,_=new A,O=new A;if(M.fromBufferAttribute(b,w),E.fromBufferAttribute(b,T),C.fromBufferAttribute(b,S),x.intersectTriangle(M,E,C,!1,_)===null)return null;O.copy(_),O.applyMatrix4(y.matrixWorld);let D=m.ray.origin.distanceTo(O);return D<m.near||D>m.far?null:{faceIndex:1,distance:D,point:O.clone(),object:y}}};var dp=new A,ri=new hi,qA=class extends Fi{constructor(e){let t=new _e,r=new un({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={},a=new ve(oy),l=new ve(oy),c=new ve(t1);u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",l),u("p","n2",l),u("p","n3",l),u("p","n4",l),u("u1","u2",c),u("u2","u3",c),u("u3","u1",c);function u(h,p,f){d(h,f),d(p,f)}function d(h,p){n.push(0,0,0),s.push(p.r,p.g,p.b),o[h]===void 0&&(o[h]=[]),o[h].push(n.length/3-1)}t.setAttribute("position",new Ae(n,3)),t.setAttribute("color",new Ae(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;ri.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,o=r?.8:1e-4;Ai("n1",t,e,ri,-n,-s,o),Ai("n2",t,e,ri,n,-s,o),Ai("n3",t,e,ri,-n,s,o),Ai("n4",t,e,ri,n,s,o);let a=o;Ai("f1",t,e,ri,-n,-s,a),Ai("f2",t,e,ri,n,-s,a),Ai("f3",t,e,ri,-n,s,a),Ai("f4",t,e,ri,n,s,a);let l=a,c=.5;Ai("u1",t,e,ri,n*.7*c,s*1.1,l),Ai("u2",t,e,ri,-n*.7*c,s*1.1,l),Ai("u3",t,e,ri,0,s*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ai(i,e,t,r,n,s,o){dp.set(n,s,o).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],dp.x,dp.y,dp.z)}}var fv=class extends es(qA){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,t){ts(this.object,this.geometry,e,t,!0)}};var Du=class extends es(lg){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,Du.geometryHelper,e,t)}};var Ru=class extends es(cg){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){ts(this.object,Ru.geometryHelper,e,t)}update(){}};var Ou=class extends es(ag){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,Ou.geometryHelper,e,t)}};var pp=class extends es(sg){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){ts(this.object,pp.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=pp._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,o=this.cone.material.length;s<o;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},fp=pp;fp._vector=new A;var rs=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let n of this.children)En(n)&&n.traverseEntity(s=>{Ss(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,n){this.objectHelper.raycast(r,n)}copy(r,n=!0){return super.copy(r,n),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let n=super.toJSON(r),s=n.object;return s.enableHelper=this.enableHelper,n}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=sr(r.color,n)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var $l=new A,pv=new A,ni=class extends rs(ti(hi),fv){constructor(e=window.innerWidth,t=window.innerHeight,r=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=qo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new Va(e*-.5,e*.5,t*.5,t*-.5,n!=null?n:-5e4,s),this.perspCamera=new dr(r,e/t,n!=null?n: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(!0)}static createFromState(e,t){let r=new ni().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}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($l),this.targetOffset=$l.distanceTo(e)}getTarget(e=new A){return this.getWorldDirection(pv),this.getWorldPosition($l),pv.multiplyScalar(this.targetOffset),e.copy($l).add(pv),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition($l),$l.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new Ft),t=new A(0,0,1).applyQuaternion(e),r=new A().copy(Ze.DefaultUp).applyQuaternion(e),n=new A().copy(Ze.DefaultUp).projectOnPlane(t),s=new A().crossVectors(n,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new A),n=e.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:t.clone().add(n),target:t}}getViewToObject(e){let t=e.getWorldPosition(new A),n=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:t.clone().sub(n),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&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,t,r,n,s,o){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,n,s,o):this.orthoCamera.setViewOffset(e,t,r,n,s,o)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new A),n=new A().fromArray(e.orbitControlsTarget);this.targetOffset=n.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={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};return El(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),this.updateProjectionMatrix(),this}toState(e){return xe(re(re({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};var ii=class extends rs(ti(Oi),Ru){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new ii().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};var Bu=class extends rs(ti(nd),Du){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let n=new mi(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Bu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=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,t),e.size!==void 0&&W1(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};var Fu=class extends rs(ti(rd),Ou){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let n=new A(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new A(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),o=new rr(n,s),a=new cl(o,new ve(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let n=new Fu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof cl&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof cl&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof cl){let r=this.shadow.camera,n=new A(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new A(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(n,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),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,t){return super.fromState(e),this.fromPointLightState(e,t),this}};var XA=new A,YA=new A,QA=new Ft,Gu=class extends rs(ti(td),fp){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=rt.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let n=new mi(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,t,r){let n=new Gu().fromState(t,r);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof mi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),YA.setFromMatrixPosition(this.matrixWorld),QA.setFromRotationMatrix(this.matrixWorld),XA.copy(this.up).applyQuaternion(QA).negate().multiplyScalar(this.distance),this.target.position.copy(YA).add(XA),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(n=e.shadow.normalBias)!=null?n:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),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),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};var KA=i=>i.tagName==="VIDEO",ec=class{static resize(e,t,r){let n=e/t,s;if(!r.image)return;let o=r.image;KA(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let n=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,o;n>s?o={x:1,y:s/n}:n<s?o={x:n/s,y:1}:o={x:1,y:1},r.repeat.set(o.x,o.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let n=r.userData.layers,s=n.getLayers();for(let o=0;o<s.length;o++){let a=s[o];kf(a)&&(ec.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),n.updateLayerUniform())}}static resizeComplex(e,t,r,n){let s=e/t,o,a=r.image;KA(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,n.geometry.type.includes("Shape")?(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*o/s):r.repeat.set(1/e,1/t*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/o*-1,1/t):r.repeat.set(1/e*s/o,1/t)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/s):r.repeat.set(1,1*o/s)),s<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/o*-1,1):r.repeat.set(1*s/o,1)),s==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var zu=class extends Lr{constructor(e,t=new sn){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&ec.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&ec.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof qh){let o=e.image;t=o.videoWidth*.5,r=o.videoHeight*.5}else{let o=e.image;t=o.width*.5,r=o.height*.5}let n=If.create({parameters:{width:t,height:r}}),s=new sn;return s.layersList.changeLayer(0,{type:at.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new zu(n,s)}};var Uu=class extends Lr{constructor(e,t=new $n){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var ku=class extends Uu{constructor(e,t=new $n){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var Vu;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Vu||(Vu={}));var mv=class extends Lr{constructor(e,t=new sn({transparent:!0,opacity:1,visible:!1,side:Yt})){super(e,t);this.objectType="TextFrame";this.charContainer=new Ze,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:co.None,horizontalAlignment:1,verticalAlignment:ws.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let n=Df.create({parameters:{width:t.width,height:t.height}}),s=new mv(n).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await en.loadFont(r),t.text=e;let n=t.textOrigin,s=new Pi({visible:t.visible,transparent:!0,side:Yt}),o=e.split(`
4143
4143
  `),a=0;this.userData.textFrame.textLines=o.map((l,c)=>{let u=new ca(a,t.lineHeight,t.fontSize);return u.message=l.split("").map(d=>{let h={char:d,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},p=s.clone();p.color=t.hexColor,p.opacity=t.opacity;let f=new en(h,p);return u.addChar3D(f,n),this.charContainer.add(f),f}),a+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let n=[];for(let s=0,o=this.charContainer.children.length;s<o;++s)if(this.charContainer.children[s]instanceof en&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,t.push(n[0]);return}}updateGeometry(e){var c,u,d,h;let t=this.userData,r=this.geometry.userData,n=r.parameters.width,s=r.parameters.height,o=(u=(c=e.parameters)==null?void 0:c.width)!=null?u:n,a=(h=(d=e.parameters)==null?void 0:d.height)!=null?h:s,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=o,l.textOrigin.set(-.5*o,.5*a,0),a!==s?(this.checkOverFlow(),this.checkCapacity()):o!==n&&(n<o?this.checkCapacity():n>o&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r);let o=[];for(;n[s].checkOverFlow(t.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?o.unshift(n[s].getWord(n[s].message.length-1,-1)):o.unshift(n[s].popChar());if(o.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let a=0;for(let l=0;l<o.length;l+=1)for(let c=0;c<o[l].length;c+=1)n[s+1].addChar3D(o[l][c],r,a),a+=1;n[s+1].fullUpdate(r)}n[s].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,n=t.textFrame.maxLineSize,s=t.textFrame.textLines;for(let o=e;o<s.length;o+=1)if(s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(r),!!s[o-1])for(;!s[o-1].endLine;){let a,l=s[o-1].spaceLeft(n);if(s[o].wordSize(0,1)<=l){s[o].containSpace()?a=s[o].getWord(0,1):a=s[o].popChar(0);for(let c=0;c<a.length;c+=1)a[c]&&s[o-1].addChar3D(a[c],r)}else{s[o].isEmpty()?(s[o].endLine&&s[o-1].isEndLine(!0),s.splice(o,1),o-=1):(s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new ca(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,n=r.textLines,s=this.getVerticalAlignmentOffSet();for(let o=e;o<n.length;o++)n[o].updateYLinePos(this.getNewLinePosition(o)),n[o].fullUpdate(r.textOrigin),n[o].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case ws.Top:return 0;case ws.Center:return this.getRemainingVerticalSpace()/2;case ws.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=r[s].maxCharSize*r[s].lineHeight;return n}updateColor(e){var n;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let s=0;s<r.length;s++){let o=r[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;((n=l.color)==null?void 0:n.isColor)&&(l.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let o=0;o<s.length;o++){let a=s[o].material;a.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let o=0;o<s.length;o++){let a=s[o].material;a.visible=e}}}async updateFontFamily(e){await en.loadFont(e);let r=this.userData.textFrame,n=r.textLines;r.fontFamily=e;for(let s=0;s<n.length;s++){let o=n[s].message;for(let a=0;a<o.length;a++)o[a].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,n=r.textLines,s=r.fontSize;r.fontSize=e;for(let o=0;o<n.length;o++)n[o].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await en.loadFont(r.fontFamily);let n=r.textLines;switch(r.textTransform=e,e){case co.Upper:for(let s=0;s<n.length;s++){let o=n[s].message;for(let a=0;a<o.length;a++)n[s].message[a].updateChar(o[a].char.toUpperCase())}break;case co.Lower:for(let s=0;s<n.length;s++){let o=n[s].message;for(let a=0;a<o.length;a++)n[s].message[a].updateChar(o[a].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let o=n[s].message;for(let a=0;a<o.length;a++)n[s].message[a].updateChar(o[a].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let n=0;n<r.length;n++){let s=r[n].message;for(let o=0;o<s.length;o++)s[o].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let n=0;n<r.length;n++)r[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(o=>{let a=o.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:o.align,endLine:o.endLine,lineHeight:o.lineHeight,maxCharSize:o.maxCharSize,yLinePos:o.yLinePos,message:a}});return r.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await en.loadFont(t.fontFamily),t.textOrigin=new A(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new Pi({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Yt});t.textLinesData&&(t.textLines=t.textLinesData.map((n,s)=>{let o=new ca(Number(n.yLinePos),Number(n.lineHeight),Number(n.maxCharSize)),a=n.message.map((l,c)=>{if(l.char===void 0){let h=t.textLines[s].message[c];if("geometries"in h){let p=h.geometries[0].userData.parameters;Object.assign(l,{LOD:p.lod,char:p.char,fontFamily:p.fontFamily,fontSize:p.fontSize,letterSpacing:p.letterSpacing,originalChar:p.char})}}let u={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},d=new en(u,r.clone());return o.addChar3D(d,t.textOrigin),this.charContainer.add(d),d});return o.message=a,o}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=sr(e.color,t);this.updateColor(r),this.updateOpacity(r.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,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new ii;r.name="Text Shape";let n=en.fontCache[e];for(let s of this.charContainer.children)s instanceof en&&n.generateShapes(s.char,1).forEach(o=>{let a=new wt().fromShape(o);a.applyScale(s.scale.x,s.scale.y);let l=jr.create({shape:a}),c=new sn({side:Yt});c.color=t;let u=new ua(l,c);u.name=s.char,u.position.copy(s.position),u.rotation.copy(s.rotation),r.attach(u)});return r}},tc=mv;tc.VerticalAlign=ws,tc.HorizontalAlign=pn,tc.TextTransform=co;var ZA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Hu="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var tz=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4144
4144
  uniform mediump sampler2D inputBuffer;
4145
4145
  #else
@@ -4414,4 +4414,4 @@ vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord
4414
4414
  #else
4415
4415
  float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
4416
4416
  #endif
4417
- outputColor=vec4(color,inputColor.a);}`,xT=class extends ns{constructor(i={}){let e=Object.assign({blendFunction:pt.NORMAL,eskil:!1,offset:.5,darkness:.5},i);super("VignetteEffect",iU,{blendFunction:e.blendFunction,uniforms:new Map([["offset",new Te(e.offset)],["darkness",new Te(e.darkness)]])});this.eskil=e.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(i){this.eskil!==i&&(i?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},mse=[new Float32Array(3),new Float32Array(3)],gse=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],yse=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var vse=[new Float32Array(2),new Float32Array(2)];var xse=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),bse=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],wse=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Sse=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Mse=new Map([[on(0,0,0,0),new Float32Array([0,0,0,0])],[on(0,0,0,1),new Float32Array([0,0,0,1])],[on(0,0,1,0),new Float32Array([0,0,1,0])],[on(0,0,1,1),new Float32Array([0,0,1,1])],[on(0,1,0,0),new Float32Array([0,1,0,0])],[on(0,1,0,1),new Float32Array([0,1,0,1])],[on(0,1,1,0),new Float32Array([0,1,1,0])],[on(0,1,1,1),new Float32Array([0,1,1,1])],[on(1,0,0,0),new Float32Array([1,0,0,0])],[on(1,0,0,1),new Float32Array([1,0,0,1])],[on(1,0,1,0),new Float32Array([1,0,1,0])],[on(1,0,1,1),new Float32Array([1,0,1,1])],[on(1,1,0,0),new Float32Array([1,1,0,0])],[on(1,1,0,1),new Float32Array([1,1,0,1])],[on(1,1,1,0),new Float32Array([1,1,1,0])],[on(1,1,1,1),new Float32Array([1,1,1,1])]]);function wv(i,e,t){return i+(e-i)*t}function on(i,e,t,r){let n=wv(i,e,1-.25),s=wv(t,r,1-.25);return wv(n,s,1-.125)}var bT=class extends Rn{load(i=()=>{},e=null){arguments.length===4?(i=arguments[1],e=arguments[3]):(arguments.length===3||typeof arguments[0]!="function")&&(i=arguments[1],e=null);let t=this.manager,r=new al;return new Promise((n,s)=>{let o=new Image,a=new Image;r.onError=l=>{t.itemError(l),e!==null?(e(`Failed to load ${l}`),n()):s(`Failed to load ${l}`)},r.onLoad=()=>{let l=[o,a];i(l),n(l)},o.addEventListener("error",l=>{r.itemError("smaa-search")}),a.addEventListener("error",l=>{r.itemError("smaa-area")}),o.addEventListener("load",()=>{t.itemEnd("smaa-search"),r.itemEnd("smaa-search")}),a.addEventListener("load",()=>{t.itemEnd("smaa-area"),r.itemEnd("smaa-area")}),t.itemStart("smaa-search"),t.itemStart("smaa-area"),r.itemStart("smaa-search"),r.itemStart("smaa-area"),o.src=gT,a.src=yT})}};var Mr=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(r){this.effect.blendMode.opacity.value=r},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(r){this.effect.blendMode.setBlendFunction(Number(r))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=pt.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=re({},this),r=Object.getPrototypeOf(this),n=Object.getOwnPropertyNames(r);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ju=class extends Mr{constructor(){super(lT);this.blendFunction=pt.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var Wu=class extends Mr{constructor(){super(cT)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var Ju=class extends Mr{constructor(){super(hT);this.effect.offset=new F(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var qu=class extends Mr{constructor(){super(uT)}};var Xu=class extends Mr{constructor(){super(fT);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var Yu=class extends Mr{constructor(){super(pT);this.blendFunction=pt.OVERLAY}};var Qu=class extends Mr{constructor(){super(xT)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var Ku=class extends Mr{constructor(e){super(dT,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var Zu=class extends Mr{constructor(){super(mT)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function wT(i,e){return e&&e.enabled&&i.push(e.effect),i}var xp=class{constructor(){this._scene=new Gr;this._camera=new ni;this.effects=new Map;this.loadingManager=new al;this.smaaImageLoader=new bT(this.loadingManager);this.renderPass=new xv;this._renderToScreen=!0;this._hasSmaa=!1;this.search=null;this.area=null;this.clock=new eg,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ju),this.effects.set("chromaticAberration",new Ju),this.effects.set("vignette",new Qu),this.effects.set("noise",new Yu),this.effects.set("colorAverage",new qu),this.effects.set("hueSaturation",new Xu),this.effects.set("brightnessContrast",new Wu),this.effects.set("depthOfField",new Ku),this.effects.set("pixelation",new Zu),this.smaaPromise=this.loadSmaaImages()}get scene(){return this._scene}set scene(e){this._scene=e}get camera(){return this._camera}set camera(e){this._camera=e}loadSmaaImages(){return new Promise(e=>{this.smaaImageLoader.load(([t,r])=>{this.search=t,this.area=r,e()})})}async _initSmaa(){if(!this.effectComposer)return;let e=this.effectComposer.passes.length;(!this.area||!this.search)&&await this.smaaPromise;let t=new vT(this.search,this.area,ha.ULTRA,yp.COLOR);t.edgeDetectionMaterial.setPredicationMode(tT.DEPTH),t.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),t.edgeDetectionMaterial.setPredicationThreshold(.002),t.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new vp(this.camera,t),e),this._hasSmaa=!0}async _initPasses(){if(!(!this.effectComposer||!this.renderer))if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new xv(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),await this._initSmaa();let e=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(wT,[]),t=[this.effects.get("pixelation")].reduce(wT,[]);t.length>0&&this.effectComposer.addPass(new vp(this.camera,...t)),this.effectComposer.addPass(new vp(this.camera,...e))}else this.effectComposer.addPass(this.renderPass)}async reinit(){!this.renderer||(this.effectComposer=new aT(this.renderer),await this._initPasses())}async init({renderer:e,camera:t,scene:r}){this.renderer=e,this.scene=r,this.camera=t,this._initSavePass(),await this.reinit()}_initSavePass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e);let t=this.renderer.capabilities.isWebGL2?Gs:xt;this._rt=new t(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Os,wrapT:Os}),this._savePass=new nT(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var r,n;let t=this.effectComposer;!t||(e===!0?(((r=this.renderer)==null?void 0:r.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((n=this.renderer)==null?void 0:n.capabilities.isWebGL2)&&!this._hasSmaa&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let r=e[t],n=this.effects.get(t);Object.keys(r).forEach(s=>{n[s]=r[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,r)=>{e[r]=t.toJSON()},e),re({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,r,n){if(!this.effectComposer||!this.renderer)return;e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,r,n),this.effectComposer.outputBuffer.scissor.set(e,t,r,n));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,r,n)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,r,n){!this.effectComposer||(e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,r,n),this.effectComposer.outputBuffer.viewport.set(e,t,r,n)))}resize(e,t){var r,n;if((r=this.effectComposer)==null||r.setSize(e,t),this._rt){let s=((n=this.renderer)==null?void 0:n.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}dispose(){var e;(e=this.effectComposer)==null||e.dispose()}};function ST(i,e){return sU(i)}function sU(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=wt.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(e.geometry=new Ho().parse(i));let t;try{t=xu(e)}catch(r){console.error(r)}if(!t){let r=wt.createFromState(Bl.defaultData(),100,100);e.shape=r,t=xu(e)}return t}var TT=Hv(AT());var Sv;Rf.then(i=>{Sv=i});var _T=new Me,oU=new Me,aU=new Me,Ei=new rr,wo=new A,lU=new Me,cU=new Me,da=class extends Lr{constructor(e,t,r,n=new $n){super(r!=null?r:t,n);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Me;this.smoothShading=!0;this.matrixWorldRigid=new Me;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:o}=Kn.build(t.geometry,void 0,void 0,!t.flatShading),a=yo(t.material,r),l=new da(n,s,o||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new ku(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,o,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:n}=Kn.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=n,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((o=this.subdividedGeometry)==null||o.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Kn.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Kn.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=Kn.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Kn.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,Lr.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:n,q:s}=(0,TT.SVD)(t),o=_T.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=oU.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),l=aU.copy(a).transpose();this.shearScale=lU.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(a),this.shearScaleInv=cU.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(o,l),s.every(c=>Math.abs(s[0]-c)<.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 ln);let t=e.attributes.position,r=e.boundingSphere.center;Ei.setFromBufferAttribute(t),Ei.getCenter(r),e.boundingSphere.radius=r.distanceTo(Ei.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ei.getSize(wo);let n={width:wo.x,height:wo.y,depth:wo.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let t=this.originalGeometry;Ei.min.set(e[0],e[2],e[4]),Ei.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ei.min.applyMatrix4(this.shearScaleInv),Ei.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new ln);let r=t.boundingSphere.center;Ei.getCenter(r),t.boundingSphere.radius=r.distanceTo(Ei.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ei.getSize(wo);let n={width:wo.x,height:wo.y,depth:wo.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(Sv.free_bvh(this.subdivPointer),Sv.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,ET(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(ET(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=re({},e.parameters)}};function ET(i,e,t,r){let n=i.position.array,s=i.normal.array,o=_T.makeScale(e,t,r).invert().elements,a,l,c;for(var u=0,d=n.length;u<d;u+=3)n[u]*=e,n[u+1]*=t,n[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c}function CT(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===Dl.Front?i.side=oi:e.side===Dl.Back?i.side=zt:i.side=Yt)}function uU(i,e){if(Array.isArray(i.material))for(let t of i.material)CT(t,e);else{let t=i.material;CT(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function LT(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=da.createFromState(i,e,t);else{let n=ST(e.geometry,t),s="materials"in e?tA(e.materials,t):yo(e.material,t);df.is2DParametricMesh(n.userData.type)?r=new zu(n,s):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new ua(n,s):e.geometry.type==="NonParametricGeometry"?r=new ku(n,s):r=new Uu(n,s),r.uuid=i,r.fromState(e)}return uU(r,e),r}function NT(i,e,t){return e.type==="Mesh"?LT(i,e,t):e.type==="TextFrame"?tc.createFromState(i,e,t):e.type==="Empty"?ii.createFromState(i,e):e.type==="PointLight"?Fu.createFromState(i,e,t):e.type==="SpotLight"?Gu.createFromState(i,e,t):e.type==="DirectionalLight"?Bu.createFromState(i,e,t):so.is(e.type)?ni.createFromState(i,e):(console.error(e),new ii)}function hU(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function PT(i,e,t){if(!t.userData.layers)return!1;let r=!1,n=t.userData.layers.getLayersOfType(at.TRANSMISSION);return n.length>0?(e.layers.set(3),r=!0,i!==void 0&&n.forEach(s=>hU(i,s))):e.layers.set(0),r}function IT(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof Lr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)PT(i,r,r.material[n])&&(t=!0);else PT(i,r,r.material)&&(t=!0)}),t}function DT(i,e){"material"in i&&dU(i.material,e),"geometry"in i&&i.geometry.dispose()}function dU(i,e){Bb(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var RT=new A,Mv=class extends lp(Gr){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new Xa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new ve(1,0,0);this.bgColor=new ve(1,1,1);this.entityByUuid={};this.postprocessing=new xp,this.ambientLight=new Vo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=IT(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.initPostprocessing(e.postprocessing),this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(sr(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof ni&&this.switchActiveCamera(r)}}initPostprocessing(e){let n=e,{enabled:t}=n,r=kv(n,["enabled"]);for(let s of Object.entries(r)){let o=s[1],a=this.postprocessing.effects.get(s[0]);if(a){a.enabled=o.enabled;for(let[l,c]of Object.entries(o))a[l]=c}}this.postprocessing.enabled=t,this.postprocessing.reinit()}clearScene(e){this.traverseEntity(t=>{DT(t,e)});for(let t of this.children)En(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=ni.createFromState(Mv.PERSONAL_CAMERA_ID,xe(re({},pf.defaultData),{name:"personal"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=n=>{for(let s of n.children)En(s)&&!s.raycastLock&&s.visible&&((Bf(s)||Ss(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)En(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=sr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.postprocessing.dispose()}updateAmbientLight(e,t){j1(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=sr(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,this.postprocessing.camera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let n of e)this.createChildObject(n.id,n.data,n.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,n,s){let o=NT(e,t,s);return o&&(this.entityByUuid[e]=o,n.add(o),this.createChildrenObjects(r,o,s)),o}getCenter(e){let t=[];for(let n=0,s=e.length;n<s;++n){let{id:o,recursive:a}=e[n],l=this.find(o),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new rr;return r.setFromPoints(t),r.getCenter(RT),RT}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var n;if(e===null){t.identity();return}let r=(n=this.find(e))==null?void 0:n.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Lr)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,n;e>=t?(r=t/e,n=1):(r=1,n=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(at.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=n})})}},wp=Mv;wp.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var Av=class{constructor(e,t,r,n){this.isEnable=!1;this.splineEvents={};this._enableEvent={};this._map={};this._prevAncestors=[];this._raycaster=new ay;this._intersection=new A;this._plane=new xn;this._normal=new A;this._position=new A;this._onMouseDown=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseDownEvent()};this._onMouseUp=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseUpEvent()};this._onMouseMove=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent()};this._onWheel=e=>{this._handleWheelEvent(e)};this._onTouchStart=e=>{e.touches.length===1&&(this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseDownEvent(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onTouchEnd=()=>{this._handleMouseUpEvent(),this._handleMouseHoverEvent(!0)};this._onTouchMove=e=>{e.touches.length===1&&(this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onKeyDown=e=>{this._handleKeyDownEvent(e.key)};this._onKeyUp=e=>{this._handleKeyUpEvent(e.key)};this._domElement=e,this._scene=t,this._camera=r,this._app=n}activate(){this.isEnable=!0,this._scene.traverseEntity(e=>{if(e.interaction!==void 0){e.interaction.start();for(let t of e.interaction.events){let r=t.type;this._addCustomEvent(r,e),this._enableEvent[r]=!0,(r===Je.KEY_DOWN||r===Je.KEY_UP||r===Je.START||r===Je.LOOK_AT||r===Je.FOLLOW||r===Je.SCROLL)&&(this._map[r]===void 0&&(this._map[r]=[]),this._map[r].push(e))}}}),this._enableEvent[Je.START]!==void 0&&this._handleStartEvent(),this._enableEvent[Je.MOUSE_DOWN]!==void 0&&(this._domElement.addEventListener("pointerdown",this._onMouseDown,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1)),this._enableEvent[Je.MOUSE_UP]!==void 0&&(this._domElement.addEventListener("pointerup",this._onMouseUp,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1)),(this._enableEvent[Je.MOUSE_HOVER]!==void 0||this._enableEvent[Je.LOOK_AT]!==void 0||this._enableEvent[Je.FOLLOW]!==void 0)&&(this._domElement.addEventListener("pointermove",this._onMouseMove,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1),this._domElement.addEventListener("touchmove",this._onTouchMove,!1)),this._enableEvent[Je.KEY_DOWN]!==void 0&&document.addEventListener("keydown",this._onKeyDown,!1),this._enableEvent[Je.KEY_UP]!==void 0&&document.addEventListener("keyup",this._onKeyUp,!1),this._enableEvent[Je.SCROLL]!==void 0&&this._domElement.addEventListener("wheel",this._onWheel,!1)}deactivate(){this._scene.traverseEntity(e=>{e.interaction!==void 0&&e.interaction.end(),e.interaction.cache=void 0}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),this._domElement.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._enableEvent={},this._map={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction.start()}),this._handleStartEvent()}_getPointer(e,t){let r=this._domElement.getBoundingClientRect();return{x:(e-r.left)/r.width*2-1,y:-((t-r.top)/r.height)*2+1}}_handleStartEvent(){var e;(e=this._map[Je.START])==null||e.forEach(t=>{var r;(r=t.interactionCache.start)==null||r.dispatch()})}_handleWheelEvent(e){var t;(t=this._map[Je.SCROLL])==null||t.forEach(r=>{var n;this._dispatchDOMCustomEvent("scroll",r.uuid),(n=r.interactionCache.scroll)==null||n.dispatch(e.deltaY>0?1:-1)})}_handleMouseDownEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let r=0,n=e.length;r<n;++r){let s=e[r].object;if(this._dispatchDOMCustomEvent("mouseDown",s.uuid),(t=s.interactionCache.mouseDown)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof ii&&(this._dispatchDOMCustomEvent("mouseDown",o.uuid),(a=o.interactionCache.mouseDown)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseUpEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let r=0,n=e.length;r<n;++r){let s=e[r].object;if(this._dispatchDOMCustomEvent("mouseUp",s.uuid),(t=s.interactionCache.mouseUp)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof ii&&(this._dispatchDOMCustomEvent("mouseUp",o.uuid),(a=o.interactionCache.mouseUp)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseHoverEvent(e=!1){var t,r;if(this._enableEvent[Je.MOUSE_HOVER]!==void 0){let n;if(!e){let o=this._raycastMesh(this._raycaster).find(a=>!a.object.interactionCache.follow);n=o?o.object:void 0}if(this._prevObject!==n){this._prevObject!==void 0&&((t=this._prevObject.interactionCache.mouseHover)==null||t.dispatchReverse()),n!==void 0&&(this._dispatchDOMCustomEvent("mouseHover",n.uuid),(r=n.interactionCache.mouseHover)==null||r.dispatch());let s=[];n==null||n.traverseAncestors(l=>{l instanceof ii&&l.interactionCache.mouseHover&&s.push(l)}),this._prevAncestors.filter(l=>{var c;return s.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatchReverse(),!0)});let o=s.filter(l=>{var c;return this._prevAncestors.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatch(),!0)}),a=this._prevAncestors.filter(l=>s.includes(l));this._prevAncestors=[...a,...o]}this._prevObject=n}}_handleLookAtEvent(){var e;(e=this._map[Je.LOOK_AT])==null||e.forEach(t=>{var n;let r=(n=t.interactionCache.lookAt)==null?void 0:n.distance;this._dispatchDOMCustomEvent("lookAt",t.uuid),r!==void 0&&(this._plane.set(this._normal,-r),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.lookAt(this._intersection))}),this._app.requestRender()}_handleFollowEvent(){var e;(e=this._map[Je.FOLLOW])==null||e.forEach(t=>{this._dispatchDOMCustomEvent("follow",t.uuid),this._plane.setFromNormalAndCoplanarPoint(this._normal,t.getWorldPosition(this._position)),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.follow(this._intersection)}),this._app.requestRender()}_handleKeyDownEvent(e){var t;(t=this._map[Je.KEY_DOWN])==null||t.forEach(r=>{var s;let n=(s=r.interactionCache.keyDown)==null?void 0:s.find(o=>o.key===e);this._dispatchDOMCustomEvent("keyDown",r.uuid),n==null||n.dispatch()})}_handleKeyUpEvent(e){var t;(t=this._map[Je.KEY_UP])==null||t.forEach(r=>{var s;let n=(s=r.interactionCache.keyUp)==null?void 0:s.find(o=>o.key===e);this._dispatchDOMCustomEvent("keyUp",r.uuid),n==null||n.dispatch()})}_raycastMesh(e){let t=[],r=n=>{for(let s of n.children)En(s)&&!s.raycastLock&&s.visible&&(VA(s)&&e.intersectObject(s,!1,t),r(s))};return r(this._scene),t}_addCustomEvent(e,t){let r=(()=>{switch(e){case 0:return"mouseDown";case 1:return"mouseUp";case 2:return"mouseHover";case 5:return"keyDown";case 6:return"keyUp";case 7:return"start";case 9:return"lookAt";case 10:return"follow";case 11:return"scroll"}})();if(r){let n=new CustomEvent(r,{bubbles:!0});Object.defineProperty(n,"target",{writable:!1,value:{id:t.uuid,name:t.name}}),this.splineEvents[r]?this.splineEvents[r][t.uuid]=n:this.splineEvents[r]={[t.uuid]:n}}}_dispatchDOMCustomEvent(e,t){var n;let r=(n=this.splineEvents[e])==null?void 0:n[t];r&&this._domElement.dispatchEvent(r)}};var Tv=class{constructor(e,t,r,n,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new F().copy(r),this._editorSize=new F().copy(n),this._aspect=t.aspect,this._fov=s!=null?s:t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,r=this._editorSize.x,n=this._editorSize.y,s=0,o=0,a=e,l=t;e<r&&(s=(r-e)*.5,s=-s,a=r),t<n&&(o=(n-t)*.5,o=-o,l=n),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,r=this._fov;if(e>t){let n=fU(e,1080,2160,1,15)/100;r*=e/t,r*=1-n}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function fU(i,e,t,r,n){return(i-e)/(t-e)*(n-r)+r}var OT=new sn,rc=class extends tn{},$u=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new xt(2048,2048,{generateMipmaps:!0,minFilter:Li,magFilter:tt,wrapS:ar,wrapT:ar}),this.transmissionRenderTarget.depthTexture=new fs(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,Ky(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===OT}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:OT}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new rc(t.r,t.g,t.b,t.a):this.colors[e]=new rc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,n,s,o;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(n=t.g)!=null?n:a.g,this.colors[e].b=(s=t.b)!=null?s:a.b,this.colors[e].a=(o=t.a)!=null?o:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};function pU(i,e){switch(i.type){case at.NOISE:return e==="noiseType";case at.TEXTURE:return e==="projection"||e==="axis";case at.DISPLACE:return e==="noiseType";default:return!1}}function _v(i,e,t,r,n){var o;let s=!1;for(let[a,l]of Object.entries(i)){if(!a||l===void 0||ep(a,t,n))continue;let c=t.uniforms[`f${t.id}_${a}`];if(!!c)switch(c.constructor){case Lt:if(typeof l=="string"){let u=e.getColor(l);u&&(c.value=u);break}else{let u=l;c.value instanceof rc?c.value=new tn(u.r,u.g,u.b,u.a):c.setRGBA(u);break}case Xi:if(typeof l=="string"){let u=e.getColor(l);u&&(c.value=u);break}else{let u=l;c.value instanceof rc?c.value=new tn(u.r,u.g,u.b,u.a):c.value.setRGBA(u.r,u.g,u.b,u.a);break}case Jr:{let u=l;c.value.setX(u[0]),c.value.setY(u[1]);break}case qr:{let u=l;c.value.setX(u[0]),c.value.setY(u[1]),c.value.setZ(u[2]);break}case rn:{let u=l;"image"in u&&(c.value.image=e.getImage(u.image)),"wrapping"in u&&(c.value.wrapS=c.value.wrapT=u.wrapping),"repeat"in u&&(c.value.repeat=u.repeat),"offset"in u&&(c.value.offset=u.offset),c.value.needsUpdate=!0;break}case go:{l.forEach((u,d)=>{c.value[d].setX(u[0]),c.value[d].setY(u[1]),c.value[d].setZ(u[2]),c.value[d].setW(u[3])});break}default:{s=s||pU(t,a),c.value=l;break}}}if(s&&n){let a=$f({id:"0",fi:0,data:n},e);(o=r.userData.layers)==null||o.changeLayer(t.id,re({},a)),r.dispose(),r.needsUpdate=!0}}function BT(i,e,t){var n;let r=[];i.objects.traverse((s,o)=>{var c;if(o.states===void 0)return;let a=e.find(s),l=a.interaction=new xo(a);mU(a,o,null,t),l.states.push(Qi.create(s,o,t));for(let u of o.states){let d=su.patch(o,u.data);l.states.push(Qi.create(u.id,d,t))}if(o.events)for(let u of o.events){let d=u.data,h=new vo(d.type);if("key"in d&&(h.key=d.key),"url"in d&&(h.url=(c=d.url)!=null?c:void 0),"distance"in d&&(h.distance=d.distance),"steps"in d&&(h.steps=d.steps),"targets"in d)for(let{data:p}of d.targets){let f=Ts.create(p);p.object?(f.object=e.find(p.object),r.push([f,p.object,p.state])):f.object=void 0,h.addTarget(f)}l.events.push(h)}});for(let[s,o,a]of r){let l=e.find(o);l&&(a?s.state=(n=l.interaction.states.find(c=>c.uuid===a))!=null?n:l.interaction.states[0]:s.state=l.interaction.states[0])}}function mU(i,e,t,r,n=!1){if(!n&&e.states.length===0)return;let s=t===null?e:su.patch(e,e.states.data(t));if(_y(i,s),i instanceof ni&&so.is(s.type)){let a=s;i.setZoom("PerspectiveCamera",a.perspective.zoom),i.setZoom("OrthographicCamera",a.orthographic.zoom)}else if(i instanceof Lr&&s.type==="Mesh"){if(i instanceof da?i.buildFromStore(s.geometry):i.updateGeometry({parameters:s.geometry}),"material"in s){if(i.material instanceof Array)return;if(typeof s.material!="string"){let a=s.material.layers;for(let l of a){let c=i.material.userData.layers.getLayerByUuid(l.id);_v(l.data,r,c,i.material,l.data)}}}else if("materials"in s){if(!(i.material instanceof Array))return;var o=0;for(let a of s.materials){if(typeof a!="string"){let l=a.layers;for(let c of l){let u=i.material[o].userData.layers.getLayerByUuid(c.id);_v(c.data,r,u,i.material[o],c.data)}}o++}}}else s.type==="DirectionalLight"?i.fromDirectionalLightState(s,r):s.type==="PointLight"?i.fromPointLightState(s,r):s.type==="SpotLight"&&i.fromSpotLightState(s,r)}var Ev=class{constructor(e){this.sharedAssets=new $u(e.shared),this.scene=new wp(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(this.sharedAssets),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.clearScene(this.sharedAssets),this.sharedAssets.dispose()}};var nc=".",eh=Symbol("target"),Cv=Symbol("unsubscribe");function th(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function FT(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Vn=Array.isArray;function fa(i){return typeof i=="symbol"}var gU={after:(i,e)=>Vn(i)?i.slice(e.length):e===""?i:i.slice(e.length+1),concat:(i,e)=>Vn(i)?(i=[...i],e&&i.push(e),i):e&&e.toString!==void 0?(i!==""&&(i+=nc),fa(e)?i+e.toString():i+e):i,initial:i=>{if(Vn(i))return i.slice(0,-1);if(i==="")return i;let e=i.lastIndexOf(nc);return e===-1?"":i.slice(0,e)},last:i=>{if(Vn(i))return i[i.length-1]||"";if(i==="")return i;let e=i.lastIndexOf(nc);return e===-1?i:i.slice(e+1)},walk:(i,e)=>{if(Vn(i))for(let t of i)e(t);else if(i!==""){let t=0,r=i.indexOf(nc);if(r===-1)e(i);else for(;t<i.length;)r===-1&&(r=i.length),e(i.slice(t,r)),t=r+1,r=i.indexOf(nc,t)}},get(i,e){return this.walk(e,t=>{i&&(i=i[t])}),i}},gn=gU;function Lv(i){return typeof i=="object"&&typeof i.next=="function"}function Nv(i,e,t,r,n){let s=i.next;if(e.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],e,o.value[0],r),o.value[1]=n(o.value[1],e,o.value[0],r)),o};else if(e.name==="values"){let o=t[eh].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,e,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,e,o.value,r)),o};return i}function Sp(i,e,t){return i.isUnsubscribed||e.ignoreSymbols&&fa(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Mp=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),r=t.get(e);return r===void 0&&(r={},t.set(e,r)),r}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let r=this._getProperties(e),n=r[t];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(e,t),r[t]=n),n}getProxy(e,t,r,n){if(this.isUnsubscribed)return e;let s=e[n],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,r):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,gn.get(t,this.getPath(e)))}defineProperty(e,t,r){return Reflect.defineProperty(e,t,r)?(this.isUnsubscribed||(this._getProperties(e)[t]=r),!0):!1}setProperty(e,t,r,n,s){if(!this._equals(s,r)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,r,n):Reflect.set(e,t,r)}return!0}deleteProperty(e,t,r){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(e);n&&(delete n[t],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(e,t,r){let n=this._getOwnPropertyDescriptor(t,r);return e!==void 0&&n!==void 0&&Object.is(e.value,n.value)&&(e.writable||!1)===(n.writable||!1)&&(e.enumerable||!1)===(n.enumerable||!1)&&(e.configurable||!1)===(n.configurable||!1)&&e.get===n.get&&e.set===n.set}isGetInvariant(e,t){let r=this._getOwnPropertyDescriptor(e,t);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function ic(i){return toString.call(i)==="[object Object]"}function sc(){return!0}function So(i,e){return i.length!==e.length||i.some((t,r)=>e[r]!==t)}var Ap=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var yU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Pv={push:sc,pop:sc,shift:sc,unshift:sc,copyWithin:So,reverse:So,sort:So,splice:So,flat:So,fill:So},GT=new Set([...Ap,...yU,...Object.keys(Pv)]);function oc(i,e){if(i.size!==e.size)return!0;for(let t of i)if(!e.has(t))return!0;return!1}var Iv=["keys","values","entries"],Dv=new Set(["has","toString"]),Rv={add:oc,clear:oc,delete:oc,forEach:oc},zT=new Set([...Dv,...Object.keys(Rv),...Iv]);function ac(i,e){if(i.size!==e.size)return!0;let t;for(let[r,n]of i)if(t=e.get(r),t!==n||t===void 0&&!e.has(r))return!0;return!1}var vU=new Set([...Dv,"get"]),Ov={set:ac,clear:ac,delete:ac,forEach:ac},UT=new Set([...vU,...Object.keys(Ov),...Iv]);var Yr=class{constructor(e,t,r,n){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Ap.has(e)}_shallowClone(e){let t=e;if(ic(e))t=re({},e);else if(Vn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(r=>this._shallowClone(r)));else if(e instanceof Map){t=new Map;for(let[r,n]of e.entries())t.set(r,this._shallowClone(n))}return this._clonedCache.add(t),t}preferredThisArg(e,t,r,n){return e?(Vn(n)?this._onIsChanged=Pv[t]:n instanceof Set?this._onIsChanged=Rv[t]:n instanceof Map&&(this._onIsChanged=Ov[t]),n):r}update(e,t,r){let n=gn.after(e,this._path);if(t!=="length"){let s=this.clone;gn.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:t,previous:r}),s&&s[t]&&(s[t]=r)}this._isChanged=!0}undo(e){let t;for(let r=this._changes.length-1;r!==-1;r--)t=this._changes[r],gn.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var rh=class extends Yr{static isHandledMethod(e){return GT.has(e)}};var Tp=class extends Yr{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var nh=class extends Yr{static isHandledMethod(e){return zT.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var ih=class extends Yr{static isHandledMethod(e){return UT.has(e)}undo(e){for(let[t,r]of this.clone.entries())e.set(t,r);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var _p=class extends Yr{constructor(e,t,r,n){super(void 0,t,r,n);this._arg1=r[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Ep=class extends Yr{constructor(e,t,r,n){super(void 0,t,r,n);this._weakKey=r[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var is=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return ic(e)||Vn(e)||th(e)}static isHandledMethod(e,t){return ic(e)?Yr.isHandledMethod(t):Vn(e)?rh.isHandledMethod(t):e instanceof Set?nh.isHandledMethod(t):e instanceof Map?ih.isHandledMethod(t):th(e)}get isCloning(){return this._stack.length>0}start(e,t,r){let n=Yr;Vn(e)?n=rh:e instanceof Date?n=Tp:e instanceof Set?n=nh:e instanceof Map?n=ih:e instanceof WeakSet?n=_p:e instanceof WeakMap&&(n=Ep),this._stack.push(new n(e,t,r,this._hasOnValidate))}update(e,t,r){this._stack[this._stack.length-1].update(e,t,r)}preferredThisArg(e,t,r){let{name:n}=e,s=is.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,t,r)}isChanged(e,t,r){return this._stack[this._stack.length-1].isChanged(e,t,r)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var xU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Bv=(i,e,t={})=>{t=re(re({},xU),t);let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=t,l=new Mp(n),c=typeof t.onValidate=="function",u=new is(c),d=(m,x,b,w,T)=>!c||u.isCloning||t.onValidate(gn.concat(l.getPath(m),x),b,w,T)===!0,h=(m,x,b,w)=>{!Sp(l,t,x)&&!(o&&l.isDetached(m,i))&&p(l.getPath(m),x,b,w)},p=(m,x,b,w,T)=>{u.isCloning?u.update(m,x,w):e(gn.concat(m,x),b,w,T)},f=m=>m&&(m[r]||m),g=(m,x,b,w)=>FT(m)||b==="constructor"||s&&!is.isHandledMethod(x,b)||Sp(l,t,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?m:(w===void 0&&(w=l.getPath(x)),l.getProxy(m,gn.concat(w,b),v,r)),v={get(m,x,b){if(fa(x)){if(x===r||x===eh)return m;if(x===Cv&&!l.isUnsubscribed&&l.getPath(m).length===0)return l.unsubscribe(),m}let w=th(m)?Reflect.get(m,x):Reflect.get(m,x,b);return g(w,m,x)},set(m,x,b,w){b=f(b);let T=m[r]||m,S=T[x];if(n(S,b)&&x in m)return!0;let M=d(m,x,b,S);return M&&l.setProperty(T,x,b,w,S)?(h(m,x,m[x],S),!0):!M},defineProperty(m,x,b){if(!l.isSameDescriptor(b,m,x)){let w=m[x];d(m,x,b.value,w)&&l.defineProperty(m,x,b,w)&&h(m,x,b.value,w)}return!0},deleteProperty(m,x){if(!Reflect.has(m,x))return!0;let b=Reflect.get(m,x),w=d(m,x,void 0,b);return w&&l.deleteProperty(m,x,b)?(h(m,x,void 0,b),!0):!w},apply(m,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(m,w,b);if((a===!1||a!==!0&&!a.includes(m.name))&&is.isHandledType(w)){let T=gn.initial(l.getPath(m)),S=is.isHandledMethod(w,m.name);u.start(w,T,b);let M=Reflect.apply(m,u.preferredThisArg(m,x,w),S?b.map(_=>f(_)):b),E=u.isChanged(w,n),C=u.stop();if(is.isHandledType(M)&&S&&(x instanceof Map&&m.name==="get"&&(T=gn.concat(T,b[0])),M=l.getProxy(M,T,v)),E){let _={name:m.name,args:b,result:M},O=u.isCloning?gn.initial(T):T,P=u.isCloning?gn.last(T):"";d(gn.get(i,O),P,w,C,_)?p(O,P,w,C,_):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Lv(M)?Nv(M,m,x,T,g):M}return Reflect.apply(m,x,b)}},y=l.getProxy(i,t.pathAsArray?[]:"",v);return e=e.bind(y),c&&(t.onValidate=t.onValidate.bind(y)),y};Bv.target=i=>i&&i[eh]||i;Bv.unsubscribe=i=>i[Cv]||i;var Fv=Bv;var Mo;(function(t){t[t.FULLSCREEN=1]="FULLSCREEN",t[t.CUSTOM=2]="CUSTOM"})(Mo||(Mo={}));var bU=class{constructor(e,{autoRender:t=!1}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._skipRender=!0;this.autoRender=!1;this.requestRender=()=>{this._skipRender=!1};this.render=()=>{var t;if(!this._renderer)return;this._rafId=requestAnimationFrame(this.render);let e=xo.isAllAnimationsEnded;!this.autoRender&&this._skipRender&&(e===void 0||e)||(this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this._skipRender=!this._controls.update():this._skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._transmissionRenderTarget&&(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3)),((t=this._scene.postprocessing)==null?void 0:t.enabled)?(this._renderer.autoClear=!1,this._scene.postprocessing.render()):(this._renderer.autoClear=!0,this._renderer.render(this._scene,this._camera))))};this.resize=()=>{var e,t,r,n;!this._renderer||(this._viewportMode===1&&(this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._frameView&&(this._frameView.frameSize=new F(this._viewportWidth,this._viewportHeight))),(e=this._frameView)==null||e.updateRenderer(),((t=this._scene)==null?void 0:t.postprocessing)&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._viewportMode!==1&&((r=this._frameView)==null||r.updateViewport()),this._camera&&((n=this._frameView)==null||n.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())};this.canvas=e,this.autoRender=t,window.addEventListener("resize",Yc(this.resize,200))}async load(e){let r=await(await fetch(e,{credentials:"include",mode:"no-cors"})).arrayBuffer();this.start(r)}start(e){var a;let t=sf.deserialize(new Uint8Array(e));this._publishData=t.scene.publish;let n=new Ev(t).scene;this._scene=n,this._sharedAssetsManager=new $u(t.shared),this._sharedAssetsManager.onImageLoad=()=>{this.requestRender()},BT(t.scene,this._scene,this._sharedAssetsManager),this._camera=this._scene.activeCamera;let s=Object.values(t.frames)[0];s&&(s.preset==="fullscreen"?(this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.size[1])),((a=this._scene.postprocessing)==null?void 0:a.enabled)?(this._renderer=new _t({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene}).then(this.requestRender)):this._renderer=new _t({canvas:this.canvas,antialias:!0,alpha:!0,stencil:!0,depth:!0,powerPreference:"high-performance"}),this._scene.needsTransmission(void 0)&&(this._transmissionRenderTarget=new xt(2048,2048,{generateMipmaps:!0,minFilter:Li,magFilter:tt,wrapS:ar,wrapT:ar}),this._transmissionRenderTarget.depthTexture=new fs(2048,2048),this._scene.needsTransmission(this._transmissionRenderTarget)),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=Lp,this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._frameView=new Tv(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),!0&&(this._controls=new iy(this._camera,this._renderer.domElement),this._publishData&&(this._controls.fromJSON(this._publishData.orbitControls),this._controls.useKeyEvents=!1),this._controls.addEventListener("change",this.requestRender),this._controls.addEventListener("start",this.requestRender)),this._playmode=new Av(this._renderer.domElement,this._scene,this._camera,this),this.resize(),this.render()}findObjectById(e){var r;let t=(r=this._scene)==null?void 0:r.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){var r;let t=(r=this._scene)==null?void 0:r.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){var e;return(e=this._playmode)==null?void 0:e.splineEvents}emitEvent(e,t){let r=this.findObjectById(t);r==null||r.emitEvent(e)}emitEventReverse(e,t){let r=this.findObjectById(t);r==null||r.emitEventReverse(e)}addEventListener(e,t){var r;(r=this._renderer)==null||r.domElement.addEventListener(e,t)}removeEventListener(e,t){var r;(r=this._renderer)==null||r.domElement.removeEventListener(e,t)}setZoom(e){var t;(t=this._controls)==null||t.zoomOut(e)}dispose(){var e,t,r,n,s,o,a;(e=this._playmode)==null||e.deactivate(),(t=this._scene)==null||t.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(l=>{Fv.unsubscribe(l)}),(r=this._renderer)==null||r.dispose(),(n=this._transmissionRenderTarget)==null||n.dispose(),(o=(s=this._transmissionRenderTarget)==null?void 0:s.depthTexture)==null||o.dispose(),(a=this._sharedAssetsManager)==null||a.dispose()}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(n){var o;let s=(o=e.interactionCache)==null?void 0:o[n];Array.isArray(s)?s.forEach(a=>{a==null||a.dispatch()}):s==null||s.dispatch()},emitEventReverse(n){var o;let s=(o=e.interactionCache)==null?void 0:o[n];Array.isArray(s)?s.forEach(a=>{a==null||a.dispatchReverse()}):s==null||s.dispatchReverse()}},r=Fv(t,(n,s)=>{var a;typeof e[n]!="object"&&((a=Object.getOwnPropertyDescriptor(e,n))==null?void 0:a.writable)&&(e[n]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};en.FONTS_PATH="_assets/_fonts/";export{bU as Application};
4417
+ outputColor=vec4(color,inputColor.a);}`,xT=class extends ns{constructor(i={}){let e=Object.assign({blendFunction:pt.NORMAL,eskil:!1,offset:.5,darkness:.5},i);super("VignetteEffect",iU,{blendFunction:e.blendFunction,uniforms:new Map([["offset",new Te(e.offset)],["darkness",new Te(e.darkness)]])});this.eskil=e.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(i){this.eskil!==i&&(i?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},mse=[new Float32Array(3),new Float32Array(3)],gse=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],yse=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var vse=[new Float32Array(2),new Float32Array(2)];var xse=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),bse=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],wse=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Sse=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Mse=new Map([[on(0,0,0,0),new Float32Array([0,0,0,0])],[on(0,0,0,1),new Float32Array([0,0,0,1])],[on(0,0,1,0),new Float32Array([0,0,1,0])],[on(0,0,1,1),new Float32Array([0,0,1,1])],[on(0,1,0,0),new Float32Array([0,1,0,0])],[on(0,1,0,1),new Float32Array([0,1,0,1])],[on(0,1,1,0),new Float32Array([0,1,1,0])],[on(0,1,1,1),new Float32Array([0,1,1,1])],[on(1,0,0,0),new Float32Array([1,0,0,0])],[on(1,0,0,1),new Float32Array([1,0,0,1])],[on(1,0,1,0),new Float32Array([1,0,1,0])],[on(1,0,1,1),new Float32Array([1,0,1,1])],[on(1,1,0,0),new Float32Array([1,1,0,0])],[on(1,1,0,1),new Float32Array([1,1,0,1])],[on(1,1,1,0),new Float32Array([1,1,1,0])],[on(1,1,1,1),new Float32Array([1,1,1,1])]]);function wv(i,e,t){return i+(e-i)*t}function on(i,e,t,r){let n=wv(i,e,1-.25),s=wv(t,r,1-.25);return wv(n,s,1-.125)}var bT=class extends Rn{load(i=()=>{},e=null){arguments.length===4?(i=arguments[1],e=arguments[3]):(arguments.length===3||typeof arguments[0]!="function")&&(i=arguments[1],e=null);let t=this.manager,r=new al;return new Promise((n,s)=>{let o=new Image,a=new Image;r.onError=l=>{t.itemError(l),e!==null?(e(`Failed to load ${l}`),n()):s(`Failed to load ${l}`)},r.onLoad=()=>{let l=[o,a];i(l),n(l)},o.addEventListener("error",l=>{r.itemError("smaa-search")}),a.addEventListener("error",l=>{r.itemError("smaa-area")}),o.addEventListener("load",()=>{t.itemEnd("smaa-search"),r.itemEnd("smaa-search")}),a.addEventListener("load",()=>{t.itemEnd("smaa-area"),r.itemEnd("smaa-area")}),t.itemStart("smaa-search"),t.itemStart("smaa-area"),r.itemStart("smaa-search"),r.itemStart("smaa-area"),o.src=gT,a.src=yT})}};var Mr=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(r){this.effect.blendMode.opacity.value=r},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(r){this.effect.blendMode.setBlendFunction(Number(r))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=pt.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=re({},this),r=Object.getPrototypeOf(this),n=Object.getOwnPropertyNames(r);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ju=class extends Mr{constructor(){super(lT);this.blendFunction=pt.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var Wu=class extends Mr{constructor(){super(cT)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var Ju=class extends Mr{constructor(){super(hT);this.effect.offset=new F(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var qu=class extends Mr{constructor(){super(uT)}};var Xu=class extends Mr{constructor(){super(fT);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var Yu=class extends Mr{constructor(){super(pT);this.blendFunction=pt.OVERLAY}};var Qu=class extends Mr{constructor(){super(xT)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var Ku=class extends Mr{constructor(e){super(dT,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var Zu=class extends Mr{constructor(){super(mT)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function wT(i,e){return e&&e.enabled&&i.push(e.effect),i}var xp=class{constructor(){this._scene=new Gr;this._camera=new ni;this.effects=new Map;this.loadingManager=new al;this.smaaImageLoader=new bT(this.loadingManager);this.renderPass=new xv;this._renderToScreen=!0;this._hasSmaa=!1;this.search=null;this.area=null;this.clock=new eg,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ju),this.effects.set("chromaticAberration",new Ju),this.effects.set("vignette",new Qu),this.effects.set("noise",new Yu),this.effects.set("colorAverage",new qu),this.effects.set("hueSaturation",new Xu),this.effects.set("brightnessContrast",new Wu),this.effects.set("depthOfField",new Ku),this.effects.set("pixelation",new Zu),this.smaaPromise=this.loadSmaaImages()}get scene(){return this._scene}set scene(e){this._scene=e}get camera(){return this._camera}set camera(e){this._camera=e}loadSmaaImages(){return new Promise(e=>{this.smaaImageLoader.load(([t,r])=>{this.search=t,this.area=r,e()})})}async _initSmaa(){if(!this.effectComposer)return;let e=this.effectComposer.passes.length;(!this.area||!this.search)&&await this.smaaPromise;let t=new vT(this.search,this.area,ha.ULTRA,yp.COLOR);t.edgeDetectionMaterial.setPredicationMode(tT.DEPTH),t.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),t.edgeDetectionMaterial.setPredicationThreshold(.002),t.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new vp(this.camera,t),e),this._hasSmaa=!0}async _initPasses(){if(!(!this.effectComposer||!this.renderer))if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new xv(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),await this._initSmaa();let e=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(wT,[]),t=[this.effects.get("pixelation")].reduce(wT,[]);t.length>0&&this.effectComposer.addPass(new vp(this.camera,...t)),this.effectComposer.addPass(new vp(this.camera,...e))}else this.effectComposer.addPass(this.renderPass)}async reinit(){!this.renderer||(this.effectComposer=new aT(this.renderer),await this._initPasses())}async init({renderer:e,camera:t,scene:r}){this.renderer=e,this.scene=r,this.camera=t,this._initSavePass(),await this.reinit()}_initSavePass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e);let t=this.renderer.capabilities.isWebGL2?Gs:xt;this._rt=new t(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Os,wrapT:Os}),this._savePass=new nT(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var r,n;let t=this.effectComposer;!t||(e===!0?(((r=this.renderer)==null?void 0:r.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((n=this.renderer)==null?void 0:n.capabilities.isWebGL2)&&!this._hasSmaa&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let r=e[t],n=this.effects.get(t);Object.keys(r).forEach(s=>{n[s]=r[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,r)=>{e[r]=t.toJSON()},e),re({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,r,n){if(!this.effectComposer||!this.renderer)return;e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,r,n),this.effectComposer.outputBuffer.scissor.set(e,t,r,n));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,r,n)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,r,n){!this.effectComposer||(e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,r,n),this.effectComposer.outputBuffer.viewport.set(e,t,r,n)))}resize(e,t){var r,n;if((r=this.effectComposer)==null||r.setSize(e,t),this._rt){let s=((n=this.renderer)==null?void 0:n.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}dispose(){var e;(e=this.effectComposer)==null||e.dispose()}};function ST(i,e){return sU(i)}function sU(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=wt.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(e.geometry=new Ho().parse(i));let t;try{t=xu(e)}catch(r){console.error(r)}if(!t){let r=wt.createFromState(Bl.defaultData(),100,100);e.shape=r,t=xu(e)}return t}var TT=Hv(AT());var Sv;Rf.then(i=>{Sv=i});var _T=new Me,oU=new Me,aU=new Me,Ei=new rr,wo=new A,lU=new Me,cU=new Me,da=class extends Lr{constructor(e,t,r,n=new $n){super(r!=null?r:t,n);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Me;this.smoothShading=!0;this.matrixWorldRigid=new Me;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:o}=Kn.build(t.geometry,void 0,void 0,!t.flatShading),a=yo(t.material,r),l=new da(n,s,o||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new ku(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,o,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:n}=Kn.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=n,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((o=this.subdividedGeometry)==null||o.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Kn.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Kn.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=Kn.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Kn.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,Lr.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:n,q:s}=(0,TT.SVD)(t),o=_T.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=oU.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),l=aU.copy(a).transpose();this.shearScale=lU.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(a),this.shearScaleInv=cU.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(o,l),s.every(c=>Math.abs(s[0]-c)<.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 ln);let t=e.attributes.position,r=e.boundingSphere.center;Ei.setFromBufferAttribute(t),Ei.getCenter(r),e.boundingSphere.radius=r.distanceTo(Ei.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ei.getSize(wo);let n={width:wo.x,height:wo.y,depth:wo.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let t=this.originalGeometry;Ei.min.set(e[0],e[2],e[4]),Ei.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ei.min.applyMatrix4(this.shearScaleInv),Ei.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new ln);let r=t.boundingSphere.center;Ei.getCenter(r),t.boundingSphere.radius=r.distanceTo(Ei.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ei.getSize(wo);let n={width:wo.x,height:wo.y,depth:wo.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(Sv.free_bvh(this.subdivPointer),Sv.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,ET(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(ET(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=re({},e.parameters)}};function ET(i,e,t,r){let n=i.position.array,s=i.normal.array,o=_T.makeScale(e,t,r).invert().elements,a,l,c;for(var u=0,d=n.length;u<d;u+=3)n[u]*=e,n[u+1]*=t,n[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c}function CT(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===Dl.Front?i.side=oi:e.side===Dl.Back?i.side=zt:i.side=Yt)}function uU(i,e){if(Array.isArray(i.material))for(let t of i.material)CT(t,e);else{let t=i.material;CT(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function LT(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=da.createFromState(i,e,t);else{let n=ST(e.geometry,t),s="materials"in e?tA(e.materials,t):yo(e.material,t);df.is2DParametricMesh(n.userData.type)?r=new zu(n,s):(n==null?void 0:n.userData.type)==="VectorGeometry"?r=new ua(n,s):e.geometry.type==="NonParametricGeometry"?r=new ku(n,s):r=new Uu(n,s),r.uuid=i,r.fromState(e)}return uU(r,e),r}function NT(i,e,t){return e.type==="Mesh"?LT(i,e,t):e.type==="TextFrame"?tc.createFromState(i,e,t):e.type==="Empty"?ii.createFromState(i,e):e.type==="PointLight"?Fu.createFromState(i,e,t):e.type==="SpotLight"?Gu.createFromState(i,e,t):e.type==="DirectionalLight"?Bu.createFromState(i,e,t):so.is(e.type)?ni.createFromState(i,e):(console.error(e),new ii)}function hU(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function PT(i,e,t){if(!t.userData.layers)return!1;let r=!1,n=t.userData.layers.getLayersOfType(at.TRANSMISSION);return n.length>0?(e.layers.set(3),r=!0,i!==void 0&&n.forEach(s=>hU(i,s))):e.layers.set(0),r}function IT(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof Lr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)PT(i,r,r.material[n])&&(t=!0);else PT(i,r,r.material)&&(t=!0)}),t}function DT(i,e){"material"in i&&dU(i.material,e),"geometry"in i&&i.geometry.dispose()}function dU(i,e){Bb(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var RT=new A,Mv=class extends lp(Gr){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new Xa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new ve(1,0,0);this.bgColor=new ve(1,1,1);this.entityByUuid={};this.postprocessing=new xp,this.ambientLight=new Vo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=IT(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.initPostprocessing(e.postprocessing),this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(sr(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof ni&&this.switchActiveCamera(r)}}initPostprocessing(e){let n=e,{enabled:t}=n,r=kv(n,["enabled"]);for(let s of Object.entries(r)){let o=s[1],a=this.postprocessing.effects.get(s[0]);if(a){a.enabled=o.enabled;for(let[l,c]of Object.entries(o))a[l]=c}}this.postprocessing.enabled=t,this.postprocessing.reinit()}clearScene(e){this.traverseEntity(t=>{DT(t,e)});for(let t of this.children)En(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=ni.createFromState(Mv.PERSONAL_CAMERA_ID,xe(re({},pf.defaultData),{name:"personal"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=n=>{for(let s of n.children)En(s)&&!s.raycastLock&&s.visible&&((Bf(s)||Ss(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)En(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=sr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.postprocessing.dispose()}updateAmbientLight(e,t){j1(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=sr(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,this.postprocessing.camera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let n of e)this.createChildObject(n.id,n.data,n.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,n,s){let o=NT(e,t,s);return o&&(this.entityByUuid[e]=o,n.add(o),this.createChildrenObjects(r,o,s)),o}getCenter(e){let t=[];for(let n=0,s=e.length;n<s;++n){let{id:o,recursive:a}=e[n],l=this.find(o),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new rr;return r.setFromPoints(t),r.getCenter(RT),RT}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var n;if(e===null){t.identity();return}let r=(n=this.find(e))==null?void 0:n.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Lr)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,n;e>=t?(r=t/e,n=1):(r=1,n=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(at.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=n})})}},wp=Mv;wp.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var Av=class{constructor(e,t,r,n){this.isEnable=!1;this.splineEvents={};this._enableEvent={};this._map={};this._prevAncestors=[];this._raycaster=new ay;this._intersection=new A;this._plane=new xn;this._normal=new A;this._position=new A;this._onMouseDown=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseDownEvent()};this._onMouseUp=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseUpEvent()};this._onMouseMove=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent()};this._onWheel=e=>{this._handleWheelEvent(e)};this._onTouchStart=e=>{e.touches.length===1&&(this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseDownEvent(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onTouchEnd=()=>{this._handleMouseUpEvent(),this._handleMouseHoverEvent(!0)};this._onTouchMove=e=>{e.touches.length===1&&(this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onKeyDown=e=>{this._handleKeyDownEvent(e.key)};this._onKeyUp=e=>{this._handleKeyUpEvent(e.key)};this._domElement=e,this._scene=t,this._camera=r,this._app=n}activate(){this.isEnable=!0,this._scene.traverseEntity(e=>{if(e.interaction!==void 0){e.interaction.start();for(let t of e.interaction.events){let r=t.type;this._addCustomEvent(r,e),this._enableEvent[r]=!0,(r===Je.KEY_DOWN||r===Je.KEY_UP||r===Je.START||r===Je.LOOK_AT||r===Je.FOLLOW||r===Je.SCROLL)&&(this._map[r]===void 0&&(this._map[r]=[]),this._map[r].push(e))}}}),this._enableEvent[Je.START]!==void 0&&this._handleStartEvent(),this._enableEvent[Je.MOUSE_DOWN]!==void 0&&(this._domElement.addEventListener("pointerdown",this._onMouseDown,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1)),this._enableEvent[Je.MOUSE_UP]!==void 0&&(this._domElement.addEventListener("pointerup",this._onMouseUp,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1)),(this._enableEvent[Je.MOUSE_HOVER]!==void 0||this._enableEvent[Je.LOOK_AT]!==void 0||this._enableEvent[Je.FOLLOW]!==void 0)&&(this._domElement.addEventListener("pointermove",this._onMouseMove,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1),this._domElement.addEventListener("touchmove",this._onTouchMove,!1)),this._enableEvent[Je.KEY_DOWN]!==void 0&&document.addEventListener("keydown",this._onKeyDown,!1),this._enableEvent[Je.KEY_UP]!==void 0&&document.addEventListener("keyup",this._onKeyUp,!1),this._enableEvent[Je.SCROLL]!==void 0&&this._domElement.addEventListener("wheel",this._onWheel,!1)}deactivate(){this._scene.traverseEntity(e=>{e.interaction!==void 0&&e.interaction.end(),e.interaction.cache=void 0}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),this._domElement.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._enableEvent={},this._map={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction.start()}),this._handleStartEvent()}_getPointer(e,t){let r=this._domElement.getBoundingClientRect();return{x:(e-r.left)/r.width*2-1,y:-((t-r.top)/r.height)*2+1}}_handleStartEvent(){var e;(e=this._map[Je.START])==null||e.forEach(t=>{var r;(r=t.interactionCache.start)==null||r.dispatch()})}_handleWheelEvent(e){var t;(t=this._map[Je.SCROLL])==null||t.forEach(r=>{var n;this._dispatchDOMCustomEvent("scroll",r.uuid),(n=r.interactionCache.scroll)==null||n.dispatch(e.deltaY>0?1:-1)})}_handleMouseDownEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let r=0,n=e.length;r<n;++r){let s=e[r].object;if(this._dispatchDOMCustomEvent("mouseDown",s.uuid),(t=s.interactionCache.mouseDown)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof ii&&(this._dispatchDOMCustomEvent("mouseDown",o.uuid),(a=o.interactionCache.mouseDown)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseUpEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let r=0,n=e.length;r<n;++r){let s=e[r].object;if(this._dispatchDOMCustomEvent("mouseUp",s.uuid),(t=s.interactionCache.mouseUp)==null||t.dispatch(),s.traverseAncestors(o=>{var a;o instanceof ii&&(this._dispatchDOMCustomEvent("mouseUp",o.uuid),(a=o.interactionCache.mouseUp)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseHoverEvent(e=!1){var t,r;if(this._enableEvent[Je.MOUSE_HOVER]!==void 0){let n;if(!e){let o=this._raycastMesh(this._raycaster).find(a=>!a.object.interactionCache.follow);n=o?o.object:void 0}if(this._prevObject!==n){this._prevObject!==void 0&&((t=this._prevObject.interactionCache.mouseHover)==null||t.dispatchReverse()),n!==void 0&&(this._dispatchDOMCustomEvent("mouseHover",n.uuid),(r=n.interactionCache.mouseHover)==null||r.dispatch());let s=[];n==null||n.traverseAncestors(l=>{l instanceof ii&&l.interactionCache.mouseHover&&s.push(l)}),this._prevAncestors.filter(l=>{var c;return s.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatchReverse(),!0)});let o=s.filter(l=>{var c;return this._prevAncestors.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatch(),!0)}),a=this._prevAncestors.filter(l=>s.includes(l));this._prevAncestors=[...a,...o]}this._prevObject=n}}_handleLookAtEvent(){var e;(e=this._map[Je.LOOK_AT])==null||e.forEach(t=>{var n;let r=(n=t.interactionCache.lookAt)==null?void 0:n.distance;this._dispatchDOMCustomEvent("lookAt",t.uuid),r!==void 0&&(this._plane.set(this._normal,-r),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.lookAt(this._intersection))}),this._app.requestRender()}_handleFollowEvent(){var e;(e=this._map[Je.FOLLOW])==null||e.forEach(t=>{this._dispatchDOMCustomEvent("follow",t.uuid),this._plane.setFromNormalAndCoplanarPoint(this._normal,t.getWorldPosition(this._position)),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.follow(this._intersection)}),this._app.requestRender()}_handleKeyDownEvent(e){var t;(t=this._map[Je.KEY_DOWN])==null||t.forEach(r=>{var s;let n=(s=r.interactionCache.keyDown)==null?void 0:s.find(o=>o.key===e);this._dispatchDOMCustomEvent("keyDown",r.uuid),n==null||n.dispatch()})}_handleKeyUpEvent(e){var t;(t=this._map[Je.KEY_UP])==null||t.forEach(r=>{var s;let n=(s=r.interactionCache.keyUp)==null?void 0:s.find(o=>o.key===e);this._dispatchDOMCustomEvent("keyUp",r.uuid),n==null||n.dispatch()})}_raycastMesh(e){let t=[],r=n=>{for(let s of n.children)En(s)&&!s.raycastLock&&s.visible&&(VA(s)&&e.intersectObject(s,!1,t),r(s))};return r(this._scene),t}_addCustomEvent(e,t){let r=(()=>{switch(e){case 0:return"mouseDown";case 1:return"mouseUp";case 2:return"mouseHover";case 5:return"keyDown";case 6:return"keyUp";case 7:return"start";case 9:return"lookAt";case 10:return"follow";case 11:return"scroll"}})();if(r){let n=new CustomEvent(r,{bubbles:!0});Object.defineProperty(n,"target",{writable:!1,value:{id:t.uuid,name:t.name}}),this.splineEvents[r]?this.splineEvents[r][t.uuid]=n:this.splineEvents[r]={[t.uuid]:n}}}_dispatchDOMCustomEvent(e,t){var n;let r=(n=this.splineEvents[e])==null?void 0:n[t];r&&this._domElement.dispatchEvent(r)}};var Tv=class{constructor(e,t,r,n,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new F().copy(r),this._editorSize=new F().copy(n),this._aspect=t.aspect,this._fov=s!=null?s:t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,r=this._editorSize.x,n=this._editorSize.y,s=0,o=0,a=e,l=t;e<r&&(s=(r-e)*.5,s=-s,a=r),t<n&&(o=(n-t)*.5,o=-o,l=n),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,r=this._fov;if(e>t){let n=fU(e,1080,2160,1,15)/100;r*=e/t,r*=1-n}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function fU(i,e,t,r,n){return(i-e)/(t-e)*(n-r)+r}var OT=new sn,rc=class extends tn{},$u=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new xt(2048,2048,{generateMipmaps:!0,minFilter:Li,magFilter:tt,wrapS:ar,wrapT:ar}),this.transmissionRenderTarget.depthTexture=new fs(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,Ky(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===OT}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:OT}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new rc(t.r,t.g,t.b,t.a):this.colors[e]=new rc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,n,s,o;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(n=t.g)!=null?n:a.g,this.colors[e].b=(s=t.b)!=null?s:a.b,this.colors[e].a=(o=t.a)!=null?o:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};function pU(i,e){switch(i.type){case at.NOISE:return e==="noiseType";case at.TEXTURE:return e==="projection"||e==="axis";case at.DISPLACE:return e==="noiseType";default:return!1}}function _v(i,e,t,r,n){var o;let s=!1;for(let[a,l]of Object.entries(i)){if(!a||l===void 0||ep(a,t,n))continue;let c=t.uniforms[`f${t.id}_${a}`];if(!!c)switch(c.constructor){case Lt:if(typeof l=="string"){let u=e.getColor(l);u&&(c.value=u);break}else{let u=l;c.value instanceof rc?c.value=new tn(u.r,u.g,u.b,u.a):c.setRGBA(u);break}case Xi:if(typeof l=="string"){let u=e.getColor(l);u&&(c.value=u);break}else{let u=l;c.value instanceof rc?c.value=new tn(u.r,u.g,u.b,u.a):c.value.setRGBA(u.r,u.g,u.b,u.a);break}case Jr:{let u=l;c.value.setX(u[0]),c.value.setY(u[1]);break}case qr:{let u=l;c.value.setX(u[0]),c.value.setY(u[1]),c.value.setZ(u[2]);break}case rn:{let u=l;"image"in u&&(c.value.image=e.getImage(u.image)),"wrapping"in u&&(c.value.wrapS=c.value.wrapT=u.wrapping),"repeat"in u&&c.value.repeat.fromArray(u.repeat),"offset"in u&&c.value.offset.fromArray(u.offset),c.value.needsUpdate=!0;break}case go:{l.forEach((u,d)=>{c.value[d].setX(u[0]),c.value[d].setY(u[1]),c.value[d].setZ(u[2]),c.value[d].setW(u[3])});break}default:{s=s||pU(t,a),c.value=l;break}}}if(s&&n){let a=$f({id:"0",fi:0,data:n},e);(o=r.userData.layers)==null||o.changeLayer(t.id,re({},a)),r.dispose(),r.needsUpdate=!0}}function BT(i,e,t){var n;let r=[];i.objects.traverse((s,o)=>{var c;if(o.states===void 0)return;let a=e.find(s),l=a.interaction=new xo(a);mU(a,o,null,t),l.states.push(Qi.create(s,o,t));for(let u of o.states){let d=su.patch(o,u.data);l.states.push(Qi.create(u.id,d,t))}if(o.events)for(let u of o.events){let d=u.data,h=new vo(d.type);if("key"in d&&(h.key=d.key),"url"in d&&(h.url=(c=d.url)!=null?c:void 0),"distance"in d&&(h.distance=d.distance),"steps"in d&&(h.steps=d.steps),"targets"in d)for(let{data:p}of d.targets){let f=Ts.create(p);p.object?(f.object=e.find(p.object),r.push([f,p.object,p.state])):f.object=void 0,h.addTarget(f)}l.events.push(h)}});for(let[s,o,a]of r){let l=e.find(o);l&&(a?s.state=(n=l.interaction.states.find(c=>c.uuid===a))!=null?n:l.interaction.states[0]:s.state=l.interaction.states[0])}}function mU(i,e,t,r,n=!1){if(!n&&e.states.length===0)return;let s=t===null?e:su.patch(e,e.states.data(t));if(_y(i,s),i instanceof ni&&so.is(s.type)){let a=s;i.setZoom("PerspectiveCamera",a.perspective.zoom),i.setZoom("OrthographicCamera",a.orthographic.zoom)}else if(i instanceof Lr&&s.type==="Mesh"){if(i instanceof da?i.buildFromStore(s.geometry):i.updateGeometry({parameters:s.geometry}),"material"in s){if(i.material instanceof Array)return;if(typeof s.material!="string"){let a=s.material.layers;for(let l of a){let c=i.material.userData.layers.getLayerByUuid(l.id);_v(l.data,r,c,i.material,l.data)}}}else if("materials"in s){if(!(i.material instanceof Array))return;var o=0;for(let a of s.materials){if(typeof a!="string"){let l=a.layers;for(let c of l){let u=i.material[o].userData.layers.getLayerByUuid(c.id);_v(c.data,r,u,i.material[o],c.data)}}o++}}}else s.type==="DirectionalLight"?i.fromDirectionalLightState(s,r):s.type==="PointLight"?i.fromPointLightState(s,r):s.type==="SpotLight"&&i.fromSpotLightState(s,r)}var Ev=class{constructor(e){this.sharedAssets=new $u(e.shared),this.scene=new wp(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(this.sharedAssets),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.clearScene(this.sharedAssets),this.sharedAssets.dispose()}};var nc=".",eh=Symbol("target"),Cv=Symbol("unsubscribe");function th(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function FT(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Vn=Array.isArray;function fa(i){return typeof i=="symbol"}var gU={after:(i,e)=>Vn(i)?i.slice(e.length):e===""?i:i.slice(e.length+1),concat:(i,e)=>Vn(i)?(i=[...i],e&&i.push(e),i):e&&e.toString!==void 0?(i!==""&&(i+=nc),fa(e)?i+e.toString():i+e):i,initial:i=>{if(Vn(i))return i.slice(0,-1);if(i==="")return i;let e=i.lastIndexOf(nc);return e===-1?"":i.slice(0,e)},last:i=>{if(Vn(i))return i[i.length-1]||"";if(i==="")return i;let e=i.lastIndexOf(nc);return e===-1?i:i.slice(e+1)},walk:(i,e)=>{if(Vn(i))for(let t of i)e(t);else if(i!==""){let t=0,r=i.indexOf(nc);if(r===-1)e(i);else for(;t<i.length;)r===-1&&(r=i.length),e(i.slice(t,r)),t=r+1,r=i.indexOf(nc,t)}},get(i,e){return this.walk(e,t=>{i&&(i=i[t])}),i}},gn=gU;function Lv(i){return typeof i=="object"&&typeof i.next=="function"}function Nv(i,e,t,r,n){let s=i.next;if(e.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],e,o.value[0],r),o.value[1]=n(o.value[1],e,o.value[0],r)),o};else if(e.name==="values"){let o=t[eh].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,e,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,e,o.value,r)),o};return i}function Sp(i,e,t){return i.isUnsubscribed||e.ignoreSymbols&&fa(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Mp=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),r=t.get(e);return r===void 0&&(r={},t.set(e,r)),r}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let r=this._getProperties(e),n=r[t];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(e,t),r[t]=n),n}getProxy(e,t,r,n){if(this.isUnsubscribed)return e;let s=e[n],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,r):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,gn.get(t,this.getPath(e)))}defineProperty(e,t,r){return Reflect.defineProperty(e,t,r)?(this.isUnsubscribed||(this._getProperties(e)[t]=r),!0):!1}setProperty(e,t,r,n,s){if(!this._equals(s,r)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,r,n):Reflect.set(e,t,r)}return!0}deleteProperty(e,t,r){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(e);n&&(delete n[t],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(e,t,r){let n=this._getOwnPropertyDescriptor(t,r);return e!==void 0&&n!==void 0&&Object.is(e.value,n.value)&&(e.writable||!1)===(n.writable||!1)&&(e.enumerable||!1)===(n.enumerable||!1)&&(e.configurable||!1)===(n.configurable||!1)&&e.get===n.get&&e.set===n.set}isGetInvariant(e,t){let r=this._getOwnPropertyDescriptor(e,t);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function ic(i){return toString.call(i)==="[object Object]"}function sc(){return!0}function So(i,e){return i.length!==e.length||i.some((t,r)=>e[r]!==t)}var Ap=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var yU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Pv={push:sc,pop:sc,shift:sc,unshift:sc,copyWithin:So,reverse:So,sort:So,splice:So,flat:So,fill:So},GT=new Set([...Ap,...yU,...Object.keys(Pv)]);function oc(i,e){if(i.size!==e.size)return!0;for(let t of i)if(!e.has(t))return!0;return!1}var Iv=["keys","values","entries"],Dv=new Set(["has","toString"]),Rv={add:oc,clear:oc,delete:oc,forEach:oc},zT=new Set([...Dv,...Object.keys(Rv),...Iv]);function ac(i,e){if(i.size!==e.size)return!0;let t;for(let[r,n]of i)if(t=e.get(r),t!==n||t===void 0&&!e.has(r))return!0;return!1}var vU=new Set([...Dv,"get"]),Ov={set:ac,clear:ac,delete:ac,forEach:ac},UT=new Set([...vU,...Object.keys(Ov),...Iv]);var Yr=class{constructor(e,t,r,n){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Ap.has(e)}_shallowClone(e){let t=e;if(ic(e))t=re({},e);else if(Vn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(r=>this._shallowClone(r)));else if(e instanceof Map){t=new Map;for(let[r,n]of e.entries())t.set(r,this._shallowClone(n))}return this._clonedCache.add(t),t}preferredThisArg(e,t,r,n){return e?(Vn(n)?this._onIsChanged=Pv[t]:n instanceof Set?this._onIsChanged=Rv[t]:n instanceof Map&&(this._onIsChanged=Ov[t]),n):r}update(e,t,r){let n=gn.after(e,this._path);if(t!=="length"){let s=this.clone;gn.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:t,previous:r}),s&&s[t]&&(s[t]=r)}this._isChanged=!0}undo(e){let t;for(let r=this._changes.length-1;r!==-1;r--)t=this._changes[r],gn.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var rh=class extends Yr{static isHandledMethod(e){return GT.has(e)}};var Tp=class extends Yr{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var nh=class extends Yr{static isHandledMethod(e){return zT.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var ih=class extends Yr{static isHandledMethod(e){return UT.has(e)}undo(e){for(let[t,r]of this.clone.entries())e.set(t,r);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var _p=class extends Yr{constructor(e,t,r,n){super(void 0,t,r,n);this._arg1=r[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Ep=class extends Yr{constructor(e,t,r,n){super(void 0,t,r,n);this._weakKey=r[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var is=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return ic(e)||Vn(e)||th(e)}static isHandledMethod(e,t){return ic(e)?Yr.isHandledMethod(t):Vn(e)?rh.isHandledMethod(t):e instanceof Set?nh.isHandledMethod(t):e instanceof Map?ih.isHandledMethod(t):th(e)}get isCloning(){return this._stack.length>0}start(e,t,r){let n=Yr;Vn(e)?n=rh:e instanceof Date?n=Tp:e instanceof Set?n=nh:e instanceof Map?n=ih:e instanceof WeakSet?n=_p:e instanceof WeakMap&&(n=Ep),this._stack.push(new n(e,t,r,this._hasOnValidate))}update(e,t,r){this._stack[this._stack.length-1].update(e,t,r)}preferredThisArg(e,t,r){let{name:n}=e,s=is.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,t,r)}isChanged(e,t,r){return this._stack[this._stack.length-1].isChanged(e,t,r)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var xU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Bv=(i,e,t={})=>{t=re(re({},xU),t);let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=t,l=new Mp(n),c=typeof t.onValidate=="function",u=new is(c),d=(m,x,b,w,T)=>!c||u.isCloning||t.onValidate(gn.concat(l.getPath(m),x),b,w,T)===!0,h=(m,x,b,w)=>{!Sp(l,t,x)&&!(o&&l.isDetached(m,i))&&p(l.getPath(m),x,b,w)},p=(m,x,b,w,T)=>{u.isCloning?u.update(m,x,w):e(gn.concat(m,x),b,w,T)},f=m=>m&&(m[r]||m),g=(m,x,b,w)=>FT(m)||b==="constructor"||s&&!is.isHandledMethod(x,b)||Sp(l,t,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?m:(w===void 0&&(w=l.getPath(x)),l.getProxy(m,gn.concat(w,b),v,r)),v={get(m,x,b){if(fa(x)){if(x===r||x===eh)return m;if(x===Cv&&!l.isUnsubscribed&&l.getPath(m).length===0)return l.unsubscribe(),m}let w=th(m)?Reflect.get(m,x):Reflect.get(m,x,b);return g(w,m,x)},set(m,x,b,w){b=f(b);let T=m[r]||m,S=T[x];if(n(S,b)&&x in m)return!0;let M=d(m,x,b,S);return M&&l.setProperty(T,x,b,w,S)?(h(m,x,m[x],S),!0):!M},defineProperty(m,x,b){if(!l.isSameDescriptor(b,m,x)){let w=m[x];d(m,x,b.value,w)&&l.defineProperty(m,x,b,w)&&h(m,x,b.value,w)}return!0},deleteProperty(m,x){if(!Reflect.has(m,x))return!0;let b=Reflect.get(m,x),w=d(m,x,void 0,b);return w&&l.deleteProperty(m,x,b)?(h(m,x,void 0,b),!0):!w},apply(m,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(m,w,b);if((a===!1||a!==!0&&!a.includes(m.name))&&is.isHandledType(w)){let T=gn.initial(l.getPath(m)),S=is.isHandledMethod(w,m.name);u.start(w,T,b);let M=Reflect.apply(m,u.preferredThisArg(m,x,w),S?b.map(_=>f(_)):b),E=u.isChanged(w,n),C=u.stop();if(is.isHandledType(M)&&S&&(x instanceof Map&&m.name==="get"&&(T=gn.concat(T,b[0])),M=l.getProxy(M,T,v)),E){let _={name:m.name,args:b,result:M},O=u.isCloning?gn.initial(T):T,P=u.isCloning?gn.last(T):"";d(gn.get(i,O),P,w,C,_)?p(O,P,w,C,_):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Lv(M)?Nv(M,m,x,T,g):M}return Reflect.apply(m,x,b)}},y=l.getProxy(i,t.pathAsArray?[]:"",v);return e=e.bind(y),c&&(t.onValidate=t.onValidate.bind(y)),y};Bv.target=i=>i&&i[eh]||i;Bv.unsubscribe=i=>i[Cv]||i;var Fv=Bv;var Mo;(function(t){t[t.FULLSCREEN=1]="FULLSCREEN",t[t.CUSTOM=2]="CUSTOM"})(Mo||(Mo={}));var bU=class{constructor(e,{autoRender:t=!1}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._skipRender=!0;this.autoRender=!1;this.requestRender=()=>{this._skipRender=!1};this.render=()=>{var t;if(!this._renderer)return;this._rafId=requestAnimationFrame(this.render);let e=xo.isAllAnimationsEnded;!this.autoRender&&this._skipRender&&(e===void 0||e)||(this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this._skipRender=!this._controls.update():this._skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._transmissionRenderTarget&&(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3)),((t=this._scene.postprocessing)==null?void 0:t.enabled)?(this._renderer.autoClear=!1,this._scene.postprocessing.render()):(this._renderer.autoClear=!0,this._renderer.render(this._scene,this._camera))))};this.resize=()=>{var e,t,r,n;!this._renderer||(this._viewportMode===1&&(this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._frameView&&(this._frameView.frameSize=new F(this._viewportWidth,this._viewportHeight))),(e=this._frameView)==null||e.updateRenderer(),((t=this._scene)==null?void 0:t.postprocessing)&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._viewportMode!==1&&((r=this._frameView)==null||r.updateViewport()),this._camera&&((n=this._frameView)==null||n.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())};this.canvas=e,this.autoRender=t,window.addEventListener("resize",Yc(this.resize,200))}async load(e){let r=await(await fetch(e,{credentials:"include",mode:"no-cors"})).arrayBuffer();this.start(r)}start(e){var a;let t=sf.deserialize(new Uint8Array(e));this._publishData=t.scene.publish;let n=new Ev(t).scene;this._scene=n,this._sharedAssetsManager=new $u(t.shared),this._sharedAssetsManager.onImageLoad=()=>{this.requestRender()},BT(t.scene,this._scene,this._sharedAssetsManager),this._camera=this._scene.activeCamera;let s=Object.values(t.frames)[0];s&&(s.preset==="fullscreen"?(this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.size[1])),((a=this._scene.postprocessing)==null?void 0:a.enabled)?(this._renderer=new _t({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene}).then(this.requestRender)):this._renderer=new _t({canvas:this.canvas,antialias:!0,alpha:!0,stencil:!0,depth:!0,powerPreference:"high-performance"}),this._scene.needsTransmission(void 0)&&(this._transmissionRenderTarget=new xt(2048,2048,{generateMipmaps:!0,minFilter:Li,magFilter:tt,wrapS:ar,wrapT:ar}),this._transmissionRenderTarget.depthTexture=new fs(2048,2048),this._scene.needsTransmission(this._transmissionRenderTarget)),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=Lp,this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._frameView=new Tv(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),!0&&(this._controls=new iy(this._camera,this._renderer.domElement),this._publishData&&(this._controls.fromJSON(this._publishData.orbitControls),this._controls.useKeyEvents=!1),this._controls.addEventListener("change",this.requestRender),this._controls.addEventListener("start",this.requestRender)),this._playmode=new Av(this._renderer.domElement,this._scene,this._camera,this),this.resize(),this.render()}findObjectById(e){var r;let t=(r=this._scene)==null?void 0:r.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){var r;let t=(r=this._scene)==null?void 0:r.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){var e;return(e=this._playmode)==null?void 0:e.splineEvents}emitEvent(e,t){let r=this.findObjectById(t);r==null||r.emitEvent(e)}emitEventReverse(e,t){let r=this.findObjectById(t);r==null||r.emitEventReverse(e)}addEventListener(e,t){var r;(r=this._renderer)==null||r.domElement.addEventListener(e,t)}removeEventListener(e,t){var r;(r=this._renderer)==null||r.domElement.removeEventListener(e,t)}setZoom(e){var t;(t=this._controls)==null||t.zoomOut(e)}dispose(){var e,t,r,n,s,o,a;(e=this._playmode)==null||e.deactivate(),(t=this._scene)==null||t.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(l=>{Fv.unsubscribe(l)}),(r=this._renderer)==null||r.dispose(),(n=this._transmissionRenderTarget)==null||n.dispose(),(o=(s=this._transmissionRenderTarget)==null?void 0:s.depthTexture)==null||o.dispose(),(a=this._sharedAssetsManager)==null||a.dispose()}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(n){var o;let s=(o=e.interactionCache)==null?void 0:o[n];Array.isArray(s)?s.forEach(a=>{a==null||a.dispatch()}):s==null||s.dispatch()},emitEventReverse(n){var o;let s=(o=e.interactionCache)==null?void 0:o[n];Array.isArray(s)?s.forEach(a=>{a==null||a.dispatchReverse()}):s==null||s.dispatchReverse()}},r=Fv(t,(n,s)=>{var a;typeof e[n]!="object"&&((a=Object.getOwnPropertyDescriptor(e,n))==null?void 0:a.writable)&&(e[n]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};en.FONTS_PATH="_assets/_fonts/";export{bU as Application};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splinetool/runtime",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "main": "build/runtime.js",
5
5
  "files": [
6
6
  "build",