@needle-tools/engine 3.1.0-alpha.1 → 3.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.1.0-alpha.2] - 2023-04-18
8
+ - Fix: UI font style resolving
9
+
7
10
  ## [3.1.0-alpha.1] - 2023-04-18
8
11
  - Fix: RemoteSkybox not being able to load locally reference dimage
9
12
  - Fix: ParticleSystem sphere scale not being applied anymore
@@ -65034,19 +65034,20 @@ class Mi extends $n {
65034
65034
  if (!this.font)
65035
65035
  return null;
65036
65036
  let I = this.font;
65037
- if (I.endsWith("-regular")) {
65037
+ const e = I.toLowerCase();
65038
+ if (e.endsWith("-regular")) {
65038
65039
  if (g === 0)
65039
65040
  return Qt(this.sourceId, I);
65040
65041
  I = I.substring(0, I.length - 8);
65041
- } else if (I.endsWith("-bold")) {
65042
+ } else if (e.endsWith("-bold")) {
65042
65043
  if (g === 1)
65043
65044
  return Qt(this.sourceId, I);
65044
65045
  I = I.substring(0, I.length - 5);
65045
- } else if (I.endsWith("-italic")) {
65046
+ } else if (e.endsWith("-italic")) {
65046
65047
  if (g === 2)
65047
65048
  return Qt(this.sourceId, I);
65048
65049
  I = I.substring(0, I.length - 7);
65049
- } else if (I.endsWith("-bolditalic")) {
65050
+ } else if (e.endsWith("-bolditalic")) {
65050
65051
  if (g === 3)
65051
65052
  return Qt(this.sourceId, I);
65052
65053
  I = I.substring(0, I.length - 11);
@@ -4456,7 +4456,7 @@ See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type
4456
4456
  #include <encodings_fragment>
4457
4457
 
4458
4458
  }
4459
- `,r={map:{value:I},height:{value:A?.height||15},radius:{value:A?.radius||100}},E=new dn(1,16),h=new xg({uniforms:r,fragmentShader:n,vertexShader:a,side:nI});super(E,h)}set radius(I){this.material.uniforms.radius.value=I}get radius(){return this.material.uniforms.radius.value}set height(I){this.material.uniforms.height.value=I}get height(){return this.material.uniforms.height.value}};var jV=Object.defineProperty,WV=Object.getOwnPropertyDescriptor,Pd=(I,A,g,e)=>{for(var i=e>1?void 0:e?WV(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&jV(A,g,i),i};class $B extends vA{constructor(){super(...arguments),Q(this,"applyOnAwake",!1),Q(this,"_scale",20),Q(this,"_radius",100),Q(this,"_height",100),Q(this,"_lastEnvironment"),Q(this,"env"),Q(this,"_watcher")}set scale(A){var g;this._scale=A,(g=this.env)==null||g.scale.setScalar(A)}get scale(){return this._scale}set radius(A){this._radius=A,this.env&&(this.env.height=A)}get radius(){return this._radius}set height(A){this._height=A,this.env&&(this.env.height=A)}get height(){return this._height}awake(){this.applyOnAwake&&this.updateAndCreate()}onEnable(){this.context.time.frameCount>0&&this.applyOnAwake&&this.updateAndCreate(),this._watcher||(this._watcher=new Uh(this.context.scene,"environment"),this._watcher.subscribeWrite(A=>{this.updateProjection()}))}onDisable(){var A,g;(A=this._watcher)==null||A.revoke(),(g=this.env)==null||g.removeFromParent()}updateAndCreate(){var A;this.updateProjection(),(A=this._watcher)==null||A.apply()}updateProjection(){var A;if(!this.context.scene.environment){(A=this.env)==null||A.removeFromParent();return}(!this.env||this.context.scene.environment!==this._lastEnvironment)&&(console.log("Create/Update Ground Projection",this.context.scene.environment.name),this.env=new PV(this.context.scene.environment)),this._lastEnvironment=this.context.scene.environment,this.env.parent||this.gameObject.add(this.env),this.env.scale.setScalar(this._scale),this.env.radius=this._radius,this.env.height=this._height,this.env.isObject3D===!0&&this.env.layers.set(2)}}Pd([m()],$B.prototype,"applyOnAwake",2),Pd([m()],$B.prototype,"scale",1),Pd([m()],$B.prototype,"radius",1),Pd([m()],$B.prototype,"height",1);var ZV=Object.defineProperty,VV=Object.getOwnPropertyDescriptor,DC=(I,A,g,e)=>{for(var i=e>1?void 0:e?VV(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&ZV(A,g,i),i};const zV=EA("debugtext");class ii extends Ns{constructor(){super(...arguments),Q(this,"canvas"),Q(this,"alignment",0),Q(this,"verticalOverflow",0),Q(this,"horizontalOverflow",0),Q(this,"lineSpacing",1),Q(this,"supportRichText",!1),Q(this,"font"),Q(this,"fontStyle",0),Q(this,"_isWaitingForRebuild",!1),Q(this,"_text",""),Q(this,"_fontSize",12),Q(this,"_textMeshUi",null),Q(this,"_textContainer",null),Q(this,"_didHandleTextRenderOnTop",!1)}get text(){return this._text}set text(A){if(this._text=A,!this._textMeshUi&&this._text.length>0&&this.context.time.frame>0&&this.createText(A,this.getTextOpts(),this.supportRichText),this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({content:A}),this.markDirty()}}set_text(A){this.text=A}get fontSize(){return this._fontSize}set fontSize(A){if(this._fontSize=A,this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({fontSize:A}),this.markDirty()}}onColorChanged(){if(this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}const A=this.color;this._textMeshUi[0].set({fontColor:A,fontOpacity:A.alpha}),this.markDirty()}}requestRebuild(){this._isWaitingForRebuild||(this._isWaitingForRebuild=!0,this.startCoroutine(this.rebuildDelayedRoutine(),ri.EarlyUpdate))}*rebuildDelayedRoutine(){if(this._isWaitingForRebuild=!1,this._textMeshUi){for(const A of this._textMeshUi)A.removeFromParent();this._textMeshUi.length=0}this.createText(this.text,this.getTextOpts(),this.supportRichText),this.markDirty()}onCreate(A){zV&&console.log(this);const g=this.verticalOverflow==0&&this.horizontalOverflow==0;g&&(this.context.renderer.localClippingEnabled=!0);const e=this.rectTransform;this._textContainer=this.uiObject=this.createBlock(e,g,null,!0),this.createText(this.text,this.getTextOpts(),this.supportRichText),this.uiObject,this.uiObject=this.createBlock(e,g,this.uiObject,!1)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let A=this.fontSize;const g={content:this.text,fontColor:this.color,fontOpacity:this.color.alpha,fontSize:A,fontKerning:"normal"};return this.setFont(g,this.fontStyle),g}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&(this.uiObject.onAfterUpdate=()=>{this.updateWidth(),this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}createBlock(A,g,e,i=!1){const t={};t.hiddenOverflow=g,t.interLine=(this.lineSpacing-1)*this.fontSize*1.333,this.getAlignment(t,i);const C=A.createNewBlock(t),o=C.backgroundMaterial;return o&&(o.depthWrite=!1),e&&(Array.isArray(e)?C.add(...e):C.add(e)),C}getAlignment(A,g=!1){if(!g)switch(A.contentDirection="row",this.alignment){case 0:case 3:case 6:A.textAlign="left";break;case 1:case 4:case 7:A.textAlign="center";break;case 2:case 5:case 8:A.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:A.justifyContent="start";break;case 3:case 4:case 5:A.justifyContent="center";break;case 6:case 7:case 8:A.justifyContent="end";break}switch(this.alignment){case 0:case 3:case 6:A.alignItems="start";break;case 1:case 4:case 7:A.alignItems="center";break;case 2:case 5:case 8:A.alignItems="end";break}return A}updateWidth(){this.horizontalOverflow===1&&setTimeout(()=>{if(!this._textMeshUi)return;const A=this._textMeshUi[0].parent;if(A&&A.lines){let g=A.lines.reduce((e,i)=>e+i.width,0);g+=A.getFontSize()*5,g+=A.padding*2||0,g+=this.fontSize*1.5,A.set({width:g}),this.ensureShadowComponentOwner()}},1)}ensureShadowComponentOwner(){this.shadowComponent&&this.shadowComponent.traverse(A=>{A[Kt]===void 0&&(A[Kt]=this)})}createText(A,g,e){if(!(!A||A.length<=0))if(this._textMeshUi||(this._textMeshUi=[]),e){let i=this.getNextTag(A);if(i)i.startIndex>0&&this.createText(A.substring(0,i.startIndex),g,!1);else return this.createText(A,g,!1);const t=[];for(;i;){const C=this.getNextTag(A,i.endIndex);if(C){const o=this.getText(A,i,C);this.handleTag(i,g,t),this.createText(o,g,!1)}else{const o=A.substring(i.endIndex);this.handleTag(i,g,t),this.createText(o,g,!1)}i=C}}else{const i={...g};i.content=A;const t=new iJ(i);this._textMeshUi.push(t),this._textContainer&&this._textContainer.add(t)}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const A=[],g=this.canvas,e={renderOnTop:g.renderOnTop,depthWrite:g.depthWrite,doubleSided:g.doubleSided};for(;;){let i=!1;if(this._textMeshUi)for(let t=0;t<this._textMeshUi.length;t++){if(A[t]===!0)continue;i=!0;const C=this._textMeshUi[t];C.textContent&&(Sd(C,e),A[t]=!0)}if(!i)break;yield}}handleTag(A,g,e){if(A.isEndTag){if(e.length>0){const i=e.pop();if(i)for(const t in i.previousValues){const C=i.previousValues[t];g[t]=C}}}else if(A.type.includes("color")){const i=new Pk(A,{fontColor:g.fontColor});if(e.push(i),A.type.length>6){const t=A.type.substring(6);g.fontColor=new yA(t)}else g.fontColor=new yA(1,1,1)}else if(A.type=="b"){const i=new Pk(A,{fontFamily:g.fontFamily,fontTexture:g.fontTexture});e.push(i),this.setFont(g,1)}else if(A.type=="i"){const i=new Pk(A,{fontFamily:g.fontFamily,fontTexture:g.fontTexture});e.push(i),this.setFont(g,2)}}getText(A,g,e){return A.substring(g.endIndex,e.startIndex)}getNextTag(A,g=0){const e=A.indexOf("<",g),i=A.indexOf(">",e);if(e>=0&&i>=0){const t=A.substring(e+1,i);return{type:t,startIndex:e,endIndex:i+1,isEndTag:t.startsWith("/")}}return null}setFont(A,g){const e=this.getFontStyleName(g);let i=e;i!=null&&i.endsWith("-msdf.json")||(i+="-msdf.json"),A.fontFamily=i;let t=e;t!=null&&t.endsWith(".png")||(t+=".png"),A.fontTexture=t}getFontStyleName(A){if(!this.font)return null;let g=this.font;if(g.endsWith("-regular")){if(A===0)return zi(this.sourceId,g);g=g.substring(0,g.length-8)}else if(g.endsWith("-bold")){if(A===1)return zi(this.sourceId,g);g=g.substring(0,g.length-5)}else if(g.endsWith("-italic")){if(A===2)return zi(this.sourceId,g);g=g.substring(0,g.length-7)}else if(g.endsWith("-bolditalic")){if(A===3)return zi(this.sourceId,g);g=g.substring(0,g.length-11)}else return zi(this.sourceId,g);switch(A){case 0:g+="-regular";break;case 1:g+="-bold";break;case 2:g+="-italic";break;case 3:g+="-bolditalic";break}return zi(this.sourceId,g)}}DC([m(_i)],ii.prototype,"canvas",2),DC([m()],ii.prototype,"alignment",2),DC([m()],ii.prototype,"verticalOverflow",2),DC([m()],ii.prototype,"horizontalOverflow",2),DC([m()],ii.prototype,"lineSpacing",2),DC([m()],ii.prototype,"supportRichText",2),DC([m()],ii.prototype,"font",2),DC([m()],ii.prototype,"fontStyle",2),DC([m()],ii.prototype,"text",1),DC([m()],ii.prototype,"fontSize",1);class Pk{constructor(A,g){Q(this,"tag"),Q(this,"previousValues"),this.tag=A,this.previousValues=g}}var XV=Object.defineProperty,$V=Object.getOwnPropertyDescriptor,jd=(I,A,g,e)=>{for(var i=e>1?void 0:e?$V(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&XV(A,g,i),i};const Aa=EA("debuginputfield");var ZE;const Sg=(ZE=class extends vA{constructor(){super(...arguments),Q(this,"textComponent"),Q(this,"placeholder"),Q(this,"onValueChanged"),Q(this,"onEndEdit"),Q(this,"inputEventFn"),Q(this,"_iosEventFn")}get text(){var I;return((I=this.textComponent)==null?void 0:I.text)??""}get isFocused(){return Sg.active===this}start(){Aa&&console.log(this.name,this)}onEnable(){var I;Sg.htmlField||(Sg.htmlField=document.createElement("input"),Sg.htmlField.style.caretColor="transparent",Sg.htmlField.classList.add("ar"),document.body.appendChild(Sg.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),Sg.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&(I=this.textComponent)!=null&&I.text.length&&iA.setActive(this.placeholder.gameObject,!1),Xh()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("touchend",this._iosEventFn))}onDisable(){var I;(I=Sg.htmlField)==null||I.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("touchend",this._iosEventFn)}onPointerClick(I){Aa&&console.log("CLICK",I,Sg.active),Sg.activeTime=this.context.time.time,Sg.active!==this&&this.startCoroutine(this.activeLoop(),ri.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();Sg.active===this&&!(this.context.input.getPointerUp(0)&&this.context.time.time-Sg.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){var I,A,g,e;if(Sg.active!==this&&(Aa&&console.log("Select",this.name,this,Sg.htmlField,this.context.isInXR,this.context.arOverlayElement,(I=this.textComponent)==null?void 0:I.text,(A=Sg.htmlField)==null?void 0:A.value),(g=Sg.active)==null||g.onDeselected(),Sg.active=this,this.placeholder&&iA.setActive(this.placeholder.gameObject,!1),Sg.htmlField)){if(Sg.htmlField.value=((e=this.textComponent)==null?void 0:e.text)||"",Aa&&console.log("set input field value",Sg.htmlField.value),this.context.isInXR){const i=this.context.arOverlayElement;i&&(Sg.htmlField.style.width="0px",Sg.htmlField.style.height="0px",i.append(Sg.htmlField))}this.selectInputField()}}onDeselected(){var I;Sg.active===this&&(Sg.active=null,Aa&&console.log("Deselect",this.name,this),Sg.htmlField&&(Sg.htmlField.blur(),document.body.append(Sg.htmlField),Sg.htmlField.style.width="",Sg.htmlField.style.height=""),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&iA.setActive(this.placeholder.gameObject,!0),(I=this.onEndEdit)==null||I.invoke())}onInput(I){var A,g;if(Sg.active===this){if(Aa&&console.log(I.code,I,(A=Sg.htmlField)==null?void 0:A.value,(g=this.textComponent)==null?void 0:g.text),I.code==="Escape"||I.code==="Enter"){this.onDeselected();return}Sg.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&iA.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){var I;if(this.textComponent&&Sg.htmlField){if(this.textComponent.text!==Sg.htmlField.value){Aa&&console.log("VALUE CHANGED");const A=this.textComponent.text,g=Sg.htmlField.value;(I=this.onValueChanged)==null||I.invoke(g,A)}this.textComponent.text=Sg.htmlField.value}}selectInputField(){Sg.htmlField&&(Sg.htmlField.setSelectionRange(Sg.htmlField.value.length,Sg.htmlField.value.length),Sg.htmlField.focus())}processInputOniOS(){const I=this.context.physics.raycast();if(!I.length)return;const A=I[0].object,g=EJ(A);(g?.gameObject===this.gameObject||g?.gameObject.parent===this.gameObject)&&this.selectInputField()}},Q(ZE,"active",null),Q(ZE,"activeTime",-1),Q(ZE,"htmlField",null),ZE);let ga=Sg;jd([m(ii)],ga.prototype,"textComponent",2),jd([m(ii)],ga.prototype,"placeholder",2),jd([m(li)],ga.prototype,"onValueChanged",2),jd([m(li)],ga.prototype,"onEndEdit",2);var _J=(I=>(I[I.fr=0]="fr",I[I.ru=1]="ru",I[I.de=2]="de",I[I.es=3]="es",I[I.el=4]="el",I[I.nord=5]="nord",I[I.eng=6]="eng",I))(_J||{});class jk extends MC{constructor(){super(...arguments),Q(this,"font"),Q(this,"text"),Q(this,"keymap"),Q(this,"padding"),Q(this,"margin"),Q(this,"fontSize"),Q(this,"borderRadius"),Q(this,"colors",{keyboardBack:8750469,panelBack:2500134,button:3552822,hovered:1842204,selected:1088605}),Q(this,"keyboard",null),Q(this,"_lastKeyPressed"),Q(this,"_lastKeyPressedStartTime",0),Q(this,"_lastKeyPressedTime",0)}awake(){super.awake();const A=_J[this.keymap||6];this.makeKeyboard(A)}onEnable(){this.addShadowComponent(this.keyboard)}onDisable(){this.removeShadowComponent()}makeKeyboard(A){!A&&!navigator.language&&(A="en");const g=this.font?this.font:"arial",e=iA.getComponent(this.gameObject,Do);if(!e){console.error("Missing rect transform, please add this component inside a canvas");return}const i={...e.getBasicOptions(),margin:this.margin||0,padding:this.padding||0,language:A,fontFamily:hE+"/"+g+"-msdf.json",fontTexture:hE+"/"+g+".png",fontSize:this.fontSize||6,backgroundColor:new yA(this.colors.keyboardBack),backspaceTexture:hE+"/backspace.png",shiftTexture:hE+"/shift.png",enterTexture:hE+"/enter.png",borderRadius:this.borderRadius||0,autoLayout:!1},t=this.gameObject.scale;i.width*=this.gameObject.scale.x,i.height*=this.gameObject.scale.y,i.fontSize*=Math.max(t.x,t.y),this.keyboard=new eJ(i),this.gameObject.scale.set(1,1,1),this.keyboard.keys.forEach(C=>{C.setupState({state:"normal",attributes:{offset:.003,backgroundColor:new yA(this.colors.button),backgroundOpacity:1}}),C.setState("normal"),C.setupState({state:"hovered",attributes:{offset:.3,backgroundColor:new yA(this.colors.hovered),backgroundOpacity:1}}),C.setupState({state:"pressed",attributes:{offset:.1,backgroundColor:new yA(this.colors.selected),backgroundOpacity:1},onSet:()=>{var o,s,B;const a=C.info.input,n=C.info.command;if(this._lastKeyPressed!==a)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedTime>.05)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedStartTime<.5||n=="switch"||n=="shift"||n=="switch-set"){this._lastKeyPressedTime=this.context.time.time;return}if(this._lastKeyPressedTime=this.context.time.time,this._lastKeyPressed=a,n)switch(n){case"switch":this.keyboard.setNextPanel();break;case"switch-set":this.keyboard.setNextCharset();break;case"enter":this.tryAppend(`
4459
+ `,r={map:{value:I},height:{value:A?.height||15},radius:{value:A?.radius||100}},E=new dn(1,16),h=new xg({uniforms:r,fragmentShader:n,vertexShader:a,side:nI});super(E,h)}set radius(I){this.material.uniforms.radius.value=I}get radius(){return this.material.uniforms.radius.value}set height(I){this.material.uniforms.height.value=I}get height(){return this.material.uniforms.height.value}};var jV=Object.defineProperty,WV=Object.getOwnPropertyDescriptor,Pd=(I,A,g,e)=>{for(var i=e>1?void 0:e?WV(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&jV(A,g,i),i};class $B extends vA{constructor(){super(...arguments),Q(this,"applyOnAwake",!1),Q(this,"_scale",20),Q(this,"_radius",100),Q(this,"_height",100),Q(this,"_lastEnvironment"),Q(this,"env"),Q(this,"_watcher")}set scale(A){var g;this._scale=A,(g=this.env)==null||g.scale.setScalar(A)}get scale(){return this._scale}set radius(A){this._radius=A,this.env&&(this.env.height=A)}get radius(){return this._radius}set height(A){this._height=A,this.env&&(this.env.height=A)}get height(){return this._height}awake(){this.applyOnAwake&&this.updateAndCreate()}onEnable(){this.context.time.frameCount>0&&this.applyOnAwake&&this.updateAndCreate(),this._watcher||(this._watcher=new Uh(this.context.scene,"environment"),this._watcher.subscribeWrite(A=>{this.updateProjection()}))}onDisable(){var A,g;(A=this._watcher)==null||A.revoke(),(g=this.env)==null||g.removeFromParent()}updateAndCreate(){var A;this.updateProjection(),(A=this._watcher)==null||A.apply()}updateProjection(){var A;if(!this.context.scene.environment){(A=this.env)==null||A.removeFromParent();return}(!this.env||this.context.scene.environment!==this._lastEnvironment)&&(console.log("Create/Update Ground Projection",this.context.scene.environment.name),this.env=new PV(this.context.scene.environment)),this._lastEnvironment=this.context.scene.environment,this.env.parent||this.gameObject.add(this.env),this.env.scale.setScalar(this._scale),this.env.radius=this._radius,this.env.height=this._height,this.env.isObject3D===!0&&this.env.layers.set(2)}}Pd([m()],$B.prototype,"applyOnAwake",2),Pd([m()],$B.prototype,"scale",1),Pd([m()],$B.prototype,"radius",1),Pd([m()],$B.prototype,"height",1);var ZV=Object.defineProperty,VV=Object.getOwnPropertyDescriptor,DC=(I,A,g,e)=>{for(var i=e>1?void 0:e?VV(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&ZV(A,g,i),i};const zV=EA("debugtext");class ii extends Ns{constructor(){super(...arguments),Q(this,"canvas"),Q(this,"alignment",0),Q(this,"verticalOverflow",0),Q(this,"horizontalOverflow",0),Q(this,"lineSpacing",1),Q(this,"supportRichText",!1),Q(this,"font"),Q(this,"fontStyle",0),Q(this,"_isWaitingForRebuild",!1),Q(this,"_text",""),Q(this,"_fontSize",12),Q(this,"_textMeshUi",null),Q(this,"_textContainer",null),Q(this,"_didHandleTextRenderOnTop",!1)}get text(){return this._text}set text(A){if(this._text=A,!this._textMeshUi&&this._text.length>0&&this.context.time.frame>0&&this.createText(A,this.getTextOpts(),this.supportRichText),this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({content:A}),this.markDirty()}}set_text(A){this.text=A}get fontSize(){return this._fontSize}set fontSize(A){if(this._fontSize=A,this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({fontSize:A}),this.markDirty()}}onColorChanged(){if(this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}const A=this.color;this._textMeshUi[0].set({fontColor:A,fontOpacity:A.alpha}),this.markDirty()}}requestRebuild(){this._isWaitingForRebuild||(this._isWaitingForRebuild=!0,this.startCoroutine(this.rebuildDelayedRoutine(),ri.EarlyUpdate))}*rebuildDelayedRoutine(){if(this._isWaitingForRebuild=!1,this._textMeshUi){for(const A of this._textMeshUi)A.removeFromParent();this._textMeshUi.length=0}this.createText(this.text,this.getTextOpts(),this.supportRichText),this.markDirty()}onCreate(A){zV&&console.log(this);const g=this.verticalOverflow==0&&this.horizontalOverflow==0;g&&(this.context.renderer.localClippingEnabled=!0);const e=this.rectTransform;this._textContainer=this.uiObject=this.createBlock(e,g,null,!0),this.createText(this.text,this.getTextOpts(),this.supportRichText),this.uiObject,this.uiObject=this.createBlock(e,g,this.uiObject,!1)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let A=this.fontSize;const g={content:this.text,fontColor:this.color,fontOpacity:this.color.alpha,fontSize:A,fontKerning:"normal"};return this.setFont(g,this.fontStyle),g}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&(this.uiObject.onAfterUpdate=()=>{this.updateWidth(),this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}createBlock(A,g,e,i=!1){const t={};t.hiddenOverflow=g,t.interLine=(this.lineSpacing-1)*this.fontSize*1.333,this.getAlignment(t,i);const C=A.createNewBlock(t),o=C.backgroundMaterial;return o&&(o.depthWrite=!1),e&&(Array.isArray(e)?C.add(...e):C.add(e)),C}getAlignment(A,g=!1){if(!g)switch(A.contentDirection="row",this.alignment){case 0:case 3:case 6:A.textAlign="left";break;case 1:case 4:case 7:A.textAlign="center";break;case 2:case 5:case 8:A.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:A.justifyContent="start";break;case 3:case 4:case 5:A.justifyContent="center";break;case 6:case 7:case 8:A.justifyContent="end";break}switch(this.alignment){case 0:case 3:case 6:A.alignItems="start";break;case 1:case 4:case 7:A.alignItems="center";break;case 2:case 5:case 8:A.alignItems="end";break}return A}updateWidth(){this.horizontalOverflow===1&&setTimeout(()=>{if(!this._textMeshUi)return;const A=this._textMeshUi[0].parent;if(A&&A.lines){let g=A.lines.reduce((e,i)=>e+i.width,0);g+=A.getFontSize()*5,g+=A.padding*2||0,g+=this.fontSize*1.5,A.set({width:g}),this.ensureShadowComponentOwner()}},1)}ensureShadowComponentOwner(){this.shadowComponent&&this.shadowComponent.traverse(A=>{A[Kt]===void 0&&(A[Kt]=this)})}createText(A,g,e){if(!(!A||A.length<=0))if(this._textMeshUi||(this._textMeshUi=[]),e){let i=this.getNextTag(A);if(i)i.startIndex>0&&this.createText(A.substring(0,i.startIndex),g,!1);else return this.createText(A,g,!1);const t=[];for(;i;){const C=this.getNextTag(A,i.endIndex);if(C){const o=this.getText(A,i,C);this.handleTag(i,g,t),this.createText(o,g,!1)}else{const o=A.substring(i.endIndex);this.handleTag(i,g,t),this.createText(o,g,!1)}i=C}}else{const i={...g};i.content=A;const t=new iJ(i);this._textMeshUi.push(t),this._textContainer&&this._textContainer.add(t)}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const A=[],g=this.canvas,e={renderOnTop:g.renderOnTop,depthWrite:g.depthWrite,doubleSided:g.doubleSided};for(;;){let i=!1;if(this._textMeshUi)for(let t=0;t<this._textMeshUi.length;t++){if(A[t]===!0)continue;i=!0;const C=this._textMeshUi[t];C.textContent&&(Sd(C,e),A[t]=!0)}if(!i)break;yield}}handleTag(A,g,e){if(A.isEndTag){if(e.length>0){const i=e.pop();if(i)for(const t in i.previousValues){const C=i.previousValues[t];g[t]=C}}}else if(A.type.includes("color")){const i=new Pk(A,{fontColor:g.fontColor});if(e.push(i),A.type.length>6){const t=A.type.substring(6);g.fontColor=new yA(t)}else g.fontColor=new yA(1,1,1)}else if(A.type=="b"){const i=new Pk(A,{fontFamily:g.fontFamily,fontTexture:g.fontTexture});e.push(i),this.setFont(g,1)}else if(A.type=="i"){const i=new Pk(A,{fontFamily:g.fontFamily,fontTexture:g.fontTexture});e.push(i),this.setFont(g,2)}}getText(A,g,e){return A.substring(g.endIndex,e.startIndex)}getNextTag(A,g=0){const e=A.indexOf("<",g),i=A.indexOf(">",e);if(e>=0&&i>=0){const t=A.substring(e+1,i);return{type:t,startIndex:e,endIndex:i+1,isEndTag:t.startsWith("/")}}return null}setFont(A,g){const e=this.getFontStyleName(g);let i=e;i!=null&&i.endsWith("-msdf.json")||(i+="-msdf.json"),A.fontFamily=i;let t=e;t!=null&&t.endsWith(".png")||(t+=".png"),A.fontTexture=t}getFontStyleName(A){if(!this.font)return null;let g=this.font;const e=g.toLowerCase();if(e.endsWith("-regular")){if(A===0)return zi(this.sourceId,g);g=g.substring(0,g.length-8)}else if(e.endsWith("-bold")){if(A===1)return zi(this.sourceId,g);g=g.substring(0,g.length-5)}else if(e.endsWith("-italic")){if(A===2)return zi(this.sourceId,g);g=g.substring(0,g.length-7)}else if(e.endsWith("-bolditalic")){if(A===3)return zi(this.sourceId,g);g=g.substring(0,g.length-11)}else return zi(this.sourceId,g);switch(A){case 0:g+="-regular";break;case 1:g+="-bold";break;case 2:g+="-italic";break;case 3:g+="-bolditalic";break}return zi(this.sourceId,g)}}DC([m(_i)],ii.prototype,"canvas",2),DC([m()],ii.prototype,"alignment",2),DC([m()],ii.prototype,"verticalOverflow",2),DC([m()],ii.prototype,"horizontalOverflow",2),DC([m()],ii.prototype,"lineSpacing",2),DC([m()],ii.prototype,"supportRichText",2),DC([m()],ii.prototype,"font",2),DC([m()],ii.prototype,"fontStyle",2),DC([m()],ii.prototype,"text",1),DC([m()],ii.prototype,"fontSize",1);class Pk{constructor(A,g){Q(this,"tag"),Q(this,"previousValues"),this.tag=A,this.previousValues=g}}var XV=Object.defineProperty,$V=Object.getOwnPropertyDescriptor,jd=(I,A,g,e)=>{for(var i=e>1?void 0:e?$V(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&XV(A,g,i),i};const Aa=EA("debuginputfield");var ZE;const Sg=(ZE=class extends vA{constructor(){super(...arguments),Q(this,"textComponent"),Q(this,"placeholder"),Q(this,"onValueChanged"),Q(this,"onEndEdit"),Q(this,"inputEventFn"),Q(this,"_iosEventFn")}get text(){var I;return((I=this.textComponent)==null?void 0:I.text)??""}get isFocused(){return Sg.active===this}start(){Aa&&console.log(this.name,this)}onEnable(){var I;Sg.htmlField||(Sg.htmlField=document.createElement("input"),Sg.htmlField.style.caretColor="transparent",Sg.htmlField.classList.add("ar"),document.body.appendChild(Sg.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),Sg.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&(I=this.textComponent)!=null&&I.text.length&&iA.setActive(this.placeholder.gameObject,!1),Xh()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("touchend",this._iosEventFn))}onDisable(){var I;(I=Sg.htmlField)==null||I.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("touchend",this._iosEventFn)}onPointerClick(I){Aa&&console.log("CLICK",I,Sg.active),Sg.activeTime=this.context.time.time,Sg.active!==this&&this.startCoroutine(this.activeLoop(),ri.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();Sg.active===this&&!(this.context.input.getPointerUp(0)&&this.context.time.time-Sg.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){var I,A,g,e;if(Sg.active!==this&&(Aa&&console.log("Select",this.name,this,Sg.htmlField,this.context.isInXR,this.context.arOverlayElement,(I=this.textComponent)==null?void 0:I.text,(A=Sg.htmlField)==null?void 0:A.value),(g=Sg.active)==null||g.onDeselected(),Sg.active=this,this.placeholder&&iA.setActive(this.placeholder.gameObject,!1),Sg.htmlField)){if(Sg.htmlField.value=((e=this.textComponent)==null?void 0:e.text)||"",Aa&&console.log("set input field value",Sg.htmlField.value),this.context.isInXR){const i=this.context.arOverlayElement;i&&(Sg.htmlField.style.width="0px",Sg.htmlField.style.height="0px",i.append(Sg.htmlField))}this.selectInputField()}}onDeselected(){var I;Sg.active===this&&(Sg.active=null,Aa&&console.log("Deselect",this.name,this),Sg.htmlField&&(Sg.htmlField.blur(),document.body.append(Sg.htmlField),Sg.htmlField.style.width="",Sg.htmlField.style.height=""),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&iA.setActive(this.placeholder.gameObject,!0),(I=this.onEndEdit)==null||I.invoke())}onInput(I){var A,g;if(Sg.active===this){if(Aa&&console.log(I.code,I,(A=Sg.htmlField)==null?void 0:A.value,(g=this.textComponent)==null?void 0:g.text),I.code==="Escape"||I.code==="Enter"){this.onDeselected();return}Sg.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&iA.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){var I;if(this.textComponent&&Sg.htmlField){if(this.textComponent.text!==Sg.htmlField.value){Aa&&console.log("VALUE CHANGED");const A=this.textComponent.text,g=Sg.htmlField.value;(I=this.onValueChanged)==null||I.invoke(g,A)}this.textComponent.text=Sg.htmlField.value}}selectInputField(){Sg.htmlField&&(Sg.htmlField.setSelectionRange(Sg.htmlField.value.length,Sg.htmlField.value.length),Sg.htmlField.focus())}processInputOniOS(){const I=this.context.physics.raycast();if(!I.length)return;const A=I[0].object,g=EJ(A);(g?.gameObject===this.gameObject||g?.gameObject.parent===this.gameObject)&&this.selectInputField()}},Q(ZE,"active",null),Q(ZE,"activeTime",-1),Q(ZE,"htmlField",null),ZE);let ga=Sg;jd([m(ii)],ga.prototype,"textComponent",2),jd([m(ii)],ga.prototype,"placeholder",2),jd([m(li)],ga.prototype,"onValueChanged",2),jd([m(li)],ga.prototype,"onEndEdit",2);var _J=(I=>(I[I.fr=0]="fr",I[I.ru=1]="ru",I[I.de=2]="de",I[I.es=3]="es",I[I.el=4]="el",I[I.nord=5]="nord",I[I.eng=6]="eng",I))(_J||{});class jk extends MC{constructor(){super(...arguments),Q(this,"font"),Q(this,"text"),Q(this,"keymap"),Q(this,"padding"),Q(this,"margin"),Q(this,"fontSize"),Q(this,"borderRadius"),Q(this,"colors",{keyboardBack:8750469,panelBack:2500134,button:3552822,hovered:1842204,selected:1088605}),Q(this,"keyboard",null),Q(this,"_lastKeyPressed"),Q(this,"_lastKeyPressedStartTime",0),Q(this,"_lastKeyPressedTime",0)}awake(){super.awake();const A=_J[this.keymap||6];this.makeKeyboard(A)}onEnable(){this.addShadowComponent(this.keyboard)}onDisable(){this.removeShadowComponent()}makeKeyboard(A){!A&&!navigator.language&&(A="en");const g=this.font?this.font:"arial",e=iA.getComponent(this.gameObject,Do);if(!e){console.error("Missing rect transform, please add this component inside a canvas");return}const i={...e.getBasicOptions(),margin:this.margin||0,padding:this.padding||0,language:A,fontFamily:hE+"/"+g+"-msdf.json",fontTexture:hE+"/"+g+".png",fontSize:this.fontSize||6,backgroundColor:new yA(this.colors.keyboardBack),backspaceTexture:hE+"/backspace.png",shiftTexture:hE+"/shift.png",enterTexture:hE+"/enter.png",borderRadius:this.borderRadius||0,autoLayout:!1},t=this.gameObject.scale;i.width*=this.gameObject.scale.x,i.height*=this.gameObject.scale.y,i.fontSize*=Math.max(t.x,t.y),this.keyboard=new eJ(i),this.gameObject.scale.set(1,1,1),this.keyboard.keys.forEach(C=>{C.setupState({state:"normal",attributes:{offset:.003,backgroundColor:new yA(this.colors.button),backgroundOpacity:1}}),C.setState("normal"),C.setupState({state:"hovered",attributes:{offset:.3,backgroundColor:new yA(this.colors.hovered),backgroundOpacity:1}}),C.setupState({state:"pressed",attributes:{offset:.1,backgroundColor:new yA(this.colors.selected),backgroundOpacity:1},onSet:()=>{var o,s,B;const a=C.info.input,n=C.info.command;if(this._lastKeyPressed!==a)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedTime>.05)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedStartTime<.5||n=="switch"||n=="shift"||n=="switch-set"){this._lastKeyPressedTime=this.context.time.time;return}if(this._lastKeyPressedTime=this.context.time.time,this._lastKeyPressed=a,n)switch(n){case"switch":this.keyboard.setNextPanel();break;case"switch-set":this.keyboard.setNextCharset();break;case"enter":this.tryAppend(`
4460
4460
  `);break;case"space":this.tryAppend(" ");break;case"backspace":if(!((s=(o=this.text)==null?void 0:o.text)!=null&&s.length))break;(B=this.text)!=null&&B.text&&(this.text.text=this.text.text.substring(0,this.text.text.length-1)||"");break;case"shift":this.keyboard.toggleCase();break}else C.info.input!==void 0&&this.tryAppend(C.info.input)}})})}tryAppend(A){this.text&&(this.text.text+=A,this.markDirty())}}var Az=Object.defineProperty,gz=Object.getOwnPropertyDescriptor,dC=(I,A,g,e)=>{for(var i=e>1?void 0:e?gz(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&Az(A,g,i),i};function Wk(I){return I*Math.PI/180}const PJ=300,tn=EA("debuglights");class ui extends vA{constructor(){super(...arguments),Q(this,"type",0),Q(this,"range",1),Q(this,"spotAngle",1),Q(this,"innerSpotAngle",1),Q(this,"_color",new yA(16777215)),Q(this,"_shadowNearPlane",.1),Q(this,"_shadowBias",0),Q(this,"_shadowNormalBias",0),Q(this,"_overrideShadowBiasSettings",!1),Q(this,"_shadows",1),Q(this,"lightmapBakeType",4),Q(this,"_intensity",-1),Q(this,"_shadowDistance"),Q(this,"shadowWidth"),Q(this,"shadowHeight"),Q(this,"_shadowResolution"),Q(this,"light"),Q(this,"_webXRStartedListener"),Q(this,"_webXREndedListener"),Q(this,"_webARRoot")}set color(A){this._color=A,this.light!==void 0&&(this.light.color=A)}get color(){return this.light?this.light.color:this._color}set shadowNearPlane(A){var g,e;if(A!==this._shadowNearPlane&&(this._shadowNearPlane=A,((e=(g=this.light)==null?void 0:g.shadow)==null?void 0:e.camera)!==void 0)){const i=this.light.shadow.camera;i.near=A}}get shadowNearPlane(){return this._shadowNearPlane}set shadowBias(A){var g,e;A!==this._shadowBias&&(this._shadowBias=A,((e=(g=this.light)==null?void 0:g.shadow)==null?void 0:e.bias)!==void 0&&(this.light.shadow.bias=A,this.light.shadow.needsUpdate=!0))}get shadowBias(){return this._shadowBias}set shadowNormalBias(A){var g,e;A!==this._shadowNormalBias&&(this._shadowNormalBias=A,((e=(g=this.light)==null?void 0:g.shadow)==null?void 0:e.normalBias)!==void 0&&(this.light.shadow.normalBias=A,this.light.shadow.needsUpdate=!0))}get shadowNormalBias(){return this._shadowNormalBias}set shadows(A){this._shadows=A,this.light&&(this.light.castShadow=A!==0,this.updateShadowSoftHard())}get shadows(){return this._shadows}set intensity(A){var g;if(this._intensity=A,this.light){let e=1;if(this.context.isInXR&&this._webARRoot){const i=(g=this._webARRoot)==null?void 0:g.arScale;typeof i=="number"&&i>0&&(e/=i)}this.light.intensity=A*e}}get intensity(){return this._intensity}get shadowDistance(){const A=this.light;return A?A.shadow.camera.far:-1}set shadowDistance(A){this._shadowDistance=A;const g=this.light;if(g){const e=g.shadow.camera;e.far=A,e.updateProjectionMatrix()}}get shadowResolution(){const A=this.light;return A?A.shadow.mapSize.x:-1}set shadowResolution(A){if(A===this._shadowResolution)return;this._shadowResolution=A;const g=this.light;g&&(g.shadow.mapSize.set(A,A),g.shadow.needsUpdate=!0)}get isBaked(){return this.lightmapBakeType===2}get selfIsLight(){if(this.gameObject.isLight===!0)return!0;switch(this.gameObject.type){case"SpotLight":case"PointLight":case"DirectionalLight":return!0}return!1}getWorldPosition(A){return this.light?this.type===1?this.light.getWorldPosition(A).multiplyScalar(1):this.light.getWorldPosition(A):A}awake(){this.color=new yA(this.color??16777215),tn&&console.log(this.name,this)}onEnable(){tn&&console.log("ENABLE LIGHT",this.name),this.createLight(),!this.isBaked&&(this.light&&(this.light.visible=!0,this.light.intensity=this._intensity,this.selfIsLight||this.light.parent!==this.gameObject&&this.gameObject.add(this.light)),this.type===1&&this.startCoroutine(this.updateMainLightRoutine(),ri.LateUpdate),this._webXRStartedListener=Ug.addEventListener(Me.XRStarted,this.onWebXRStarted.bind(this)),this._webXREndedListener=Ug.addEventListener(Me.XRStopped,this.onWebXREnded.bind(this)))}onDisable(){tn&&console.log("DISABLE LIGHT",this.name),this.light&&(this.selfIsLight?this.light.intensity=0:this.light.visible=!1),Ug.removeEventListener(Me.XRStarted,this._webXRStartedListener),Ug.removeEventListener(Me.XRStopped,this._webXREndedListener)}onWebXRStarted(){this._webARRoot=iA.getComponentInParent(this.gameObject,Ss)??void 0}onWebXREnded(){}createLight(){const A=this.selfIsLight;if(A&&!this.light)switch(this.light=this.gameObject,this.light.name=this.name,this._intensity=this.light.intensity,this.type){case 1:this.setDirectionalLight(this.light);break}else if(!this.light)switch(this.type){case 1:const g=new rl(this.color,this.intensity*Math.PI);if(g.position.set(0,0,-PJ*.5).applyQuaternion(this.gameObject.quaternion),this.gameObject.add(g.target),rr(g.target,0,0,0),this.light=g,this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),tn){const C=new $m(this.light,.2,this.color);this.context.scene.add(C)}break;case 0:const e=new Ql(this.color,this.intensity*Math.PI,this.range,Wk(this.spotAngle/2),1-Wk(this.innerSpotAngle/2)/Wk(this.spotAngle/2),2);e.position.set(0,0,0),e.rotation.set(0,0,0),this.light=e;const i=e.target;e.add(i),i.position.set(0,0,this.range),i.rotation.set(0,0,0);break;case 2:const t=new nl(this.color,this.intensity*Math.PI,this.range);this.light=t;break}if(this.light){this._intensity>=0?this.light.intensity=this._intensity:this._intensity=this.light.intensity,this.shadows!==0?this.light.castShadow=!0:this.light.castShadow=!1,this._shadowResolution!==void 0&&this._shadowResolution>4?(this.light.shadow.mapSize.width=this._shadowResolution,this.light.shadow.mapSize.height=this._shadowResolution):(this.light.shadow.mapSize.width=2048,this.light.shadow.mapSize.height=2048),tn&&console.log("Override shadow bias?",this._overrideShadowBiasSettings,this.shadowBias,this.shadowNormalBias),this.light.shadow.bias=this.shadowBias,this.light.shadow.normalBias=this.shadowNormalBias,this.updateShadowSoftHard();const g=this.light.shadow.camera;if(g.near=this.shadowNearPlane,this._shadowDistance!==void 0&&typeof this._shadowDistance=="number"?g.far=this._shadowDistance:g.far=PJ*Math.abs(this.gameObject.scale.z),this.gameObject.scale.set(1,1,1),this.shadowWidth!==void 0)g.left=-this.shadowWidth/2,g.right=this.shadowWidth/2;else{const e=this.gameObject.scale.x;g.left*=e,g.right*=e}if(this.shadowHeight!==void 0)g.top=this.shadowHeight/2,g.bottom=-this.shadowHeight/2;else{const e=this.gameObject.scale.y;g.top*=e,g.bottom*=e}this.light.shadow.needsUpdate=!0,tn&&this.context.scene.add(new AU(g)),this.isBaked?this.light.removeFromParent():A||this.gameObject.add(this.light)}}*updateMainLightRoutine(){for(;;){this.type===1&&((!this.context.mainLight||this.intensity>this.context.mainLight.intensity)&&(this.context.mainLight=this),yield);break}}updateShadowSoftHard(){this.light&&(this.shadows===2||(this.light.shadow.radius=1,this.light.shadow.blurSamples=1))}setDirectionalLight(A){A.add(A.target),A.target.position.set(0,0,-1)}}Q(ui,"allowChangingRendererShadowMapType",!0),dC([m()],ui.prototype,"type",2),dC([m(yA)],ui.prototype,"color",1),dC([m()],ui.prototype,"shadowNearPlane",1),dC([m()],ui.prototype,"shadowBias",1),dC([m()],ui.prototype,"shadowNormalBias",1),dC([m()],ui.prototype,"shadows",1),dC([m()],ui.prototype,"lightmapBakeType",2),dC([m()],ui.prototype,"intensity",1),dC([m()],ui.prototype,"shadowDistance",1),dC([m()],ui.prototype,"shadowResolution",1),new M(0,0,0);var Iz=Object.defineProperty,ez=Object.getOwnPropertyDescriptor,VE=(I,A,g,e)=>{for(var i=e>1?void 0:e?ez(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&Iz(A,g,i),i};const Cn=EA("debugLODs"),iz=EA("noLODs");class Ia{constructor(){Q(this,"screenRelativeTransitionHeight"),Q(this,"distance"),Q(this,"renderers")}}VE([m()],Ia.prototype,"screenRelativeTransitionHeight",2),VE([m()],Ia.prototype,"distance",2),VE([m()],Ia.prototype,"renderers",2);class tz{constructor(A,g){Q(this,"model"),Q(this,"renderers"),this.model=g,this.renderers=[];for(const e of g.renderers){const i=this.findRenderer(e,A.gameObject);i&&i.gameObject?this.renderers.push(i):Cn&&console.warn("Renderer not found: "+e,A.gameObject)}}findRenderer(A,g){const e=iA.foreachComponent(g,i=>{var t;return i.guid===A||((t=Object.getPrototypeOf(i))==null?void 0:t.guid)===A?i:null});if(e)return e;for(const i of g.children){const t=this.findRenderer(A,i);if(t)return t}return null}}class zE extends vA{constructor(){super(...arguments),Q(this,"fadeMode",0),Q(this,"localReferencePoint"),Q(this,"lodCount",0),Q(this,"size",0),Q(this,"animateCrossFading",!1),Q(this,"lodModels"),Q(this,"_lods",[]),Q(this,"_settings",[]),Q(this,"_lodsHandler"),Q(this,"_distanceFactor",1)}start(){if(!iz&&!this._lodsHandler&&this.gameObject&&(Cn&&console.log(this),this.lodModels&&Array.isArray(this.lodModels))){let A=0,g=[];for(const i of this.lodModels){A=Math.max(i.distance,A);const t=new tz(this,i);this._lods.push(t);for(const C of t.renderers)g.includes(C)||g.push(C)}this._lodsHandler=new Array;for(let i=0;i<g.length;i++){const t=new dw;this._lodsHandler.push(t),this.gameObject.add(t)}const e=new NA;e.name="Cull "+this.name,Cn&&console.log(g);for(let i=0;i<g.length;i++){const t=g[i],C=this._lodsHandler[i],o=t.gameObject;let s=0,B=0;Cn&&console.log(i,o.name);for(const n of this._lods){let r=null;n.renderers.includes(t)?r=o:r=e,Cn&&console.log("add",n.model.distance,r.name);const E=n.model.distance;if(B=E-s,s=Math.max(E,s),r.type==="Group"){console.warn("LODGroup: Group is not supported as LOD object",o.name,r);continue}this.onAddLodLevel(C,r,E)}const a=s+B;Cn&&console.log("cull",a),this.onAddLodLevel(C,e,a)}}}update(){if(!this.gameObject||!this._lodsHandler)return;const A=this.context.mainCamera;if(A)for(const g of this._lodsHandler)g.update(A)}onAddLodLevel(A,g,e){if(g===this.gameObject){console.warn("LODGroup component must be on parent object and not mesh directly at the moment",g.name,g);return}A.addLevel(g,e*this._distanceFactor);const i={lod:A,levelIndex:A.levels.length-1,distance:e};this._settings.push(i)}distanceFactor(A){if(A!==this._distanceFactor){this._distanceFactor=A;for(const g of this._settings){const e=g.lod.levels[g.levelIndex];e.distance=g.distance*A}}}}VE([m(M)],zE.prototype,"localReferencePoint",2),VE([m(Ia)],zE.prototype,"lodModels",2);const Cz=EA("logstats");class Zk extends vA{onEnable(){console.log(this),Cz&&this.startCoroutine(this.run(),ri.OnAfterRender)}*run(){for(;this.enabled;){const A=this.context.renderer.info;console.log(A.memory,A.render,A.programs),yield}}}var oz=Object.defineProperty,sz=Object.getOwnPropertyDescriptor,Bz=(I,A,g,e)=>{for(var i=e>1?void 0:e?sz(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&oz(A,g,i),i};const Vk=EA("debugnestedgltf");class Wd extends vA{constructor(){super(...arguments),Q(this,"filePath"),Q(this,"_isLoadingOrDoneLoading",!1)}listenToProgress(A){var g;(g=this.filePath)==null||g.beginListenDownload(A)}preload(){var A;(A=this.filePath)==null||A.preload()}async start(){var A,g,e,i;if(this._isLoadingOrDoneLoading)return;Vk&&console.log(this,this.guid);const t=this.gameObject.parent;if(t){this._isLoadingOrDoneLoading=!0;const C=new Vt;C.idProvider=new Si(this.hash(this.guid)),C.parent=t,this.gameObject.updateMatrix();const o=this.gameObject.matrix;Vk&&console.log("Load nested:",((A=this.filePath)==null?void 0:A.uri)??this.filePath,this.gameObject.position);const s=await((e=(g=this.filePath)==null?void 0:g.instantiate)==null?void 0:e.call(this.filePath,C));s&&(s.matrixAutoUpdate=!1,s.matrix.identity(),s.applyMatrix4(o),s.matrixAutoUpdate=!0,s.layers.disableAll(),s.layers.set(this.layer)),this.destroy(),Vk&&console.log("Nested loading done:",((i=this.filePath)==null?void 0:i.uri)??this.filePath,s)}}hash(A){let g=0;for(let e=0;e<A.length;e++)g=A.charCodeAt(e)+((g<<5)-g);return g}}Bz([m(eo)],Wd.prototype,"filePath",2);var az=Object.defineProperty,Qz=Object.getOwnPropertyDescriptor,Zd=(I,A,g,e)=>{for(var i=e>1?void 0:e?Qz(A,g):A,t=I.length-1,C;t>=0;t--)(C=I[t])&&(i=(e?C(A,g,i):C(i))||i);return e&&i&&az(A,g,i),i};class ea extends vA{constructor(){super(...arguments),Q(this,"referenceSpace"),Q(this,"from"),Q(this,"affectPosition",!1),Q(this,"affectRotation",!1),Q(this,"alignLookDirection",!1),Q(this,"levelLookDirection",!1),Q(this,"levelPosition",!1),Q(this,"positionOffset",new M(0,0,0)),Q(this,"rotationOffset",new M(0,0,0)),Q(this,"offset",new M(0,0,0))}update(){if(!this.from)return;var A=wg(this.from),g=Ji(this.from);this.offset.copy(this.positionOffset);const e=this.offset.length();if(this.referenceSpace&&this.offset.transformDirection(this.referenceSpace.matrixWorld).multiplyScalar(e),A.add(this.offset),this.levelPosition&&this.referenceSpace){const o=new It(this.gameObject.up,0),s=wg(this.referenceSpace);o.setFromNormalAndCoplanarPoint(this.gameObject.up,s);const B=new M(0,0,0);o.projectPoint(A,B),A.copy(B)}this.affectPosition&&ue(this.gameObject,A);const i=new XI(this.rotationOffset.x,this.rotationOffset.y,this.rotationOffset.z),t=new RA().setFromEuler(i);this.affectRotation&&Zt(this.gameObject,g.multiply(t));let C=new M;this.from.getWorldDirection(C).multiplyScalar(50),this.levelLookDirection&&(C.y=0),this.alignLookDirection&&this.gameObject.lookAt(C)}}Zd([m(iA)],ea.prototype,"referenceSpace",2),Zd([m(iA)],ea.prototype,"from",2),Zd([m(M)],ea.prototype,"positionOffset",2),Zd([m(M)],ea.prototype,"rotationOffset",2);function Lg(I,A){if(!(I instanceof A))throw new TypeError("Cannot call a class as a function")}function jJ(I,A){for(var g=0;g<A.length;g++){var e=A[g];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(I,e.key,e)}}function vg(I,A,g){return A&&jJ(I.prototype,A),g&&jJ(I,g),Object.defineProperty(I,"prototype",{writable:!1}),I}function oA(I,A,g){return A in I?Object.defineProperty(I,A,{value:g,enumerable:!0,configurable:!0,writable:!0}):I[A]=g,I}function on(I,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(A&&A.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),Object.defineProperty(I,"prototype",{writable:!1}),A&&zk(I,A)}function Vd(I){return Vd=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)},Vd(I)}function zk(I,A){return zk=Object.setPrototypeOf||function(g,e){return g.__proto__=e,g},zk(I,A)}function nz(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Pg(I){if(I===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return I}function rz(I,A){if(A&&(typeof A=="object"||typeof A=="function"))return A;if(A!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pg(I)}function sn(I){var A=nz();return function(){var g=Vd(I),e;if(A){var i=Vd(this).constructor;e=Reflect.construct(g,arguments,i)}else e=g.apply(this,arguments);return rz(this,e)}}function WJ(I,A){return Ez(I)||hz(I,A)||ZJ(I,A)||cz()}function Ez(I){if(Array.isArray(I))return I}function hz(I,A){var g=I==null?null:typeof Symbol<"u"&&I[Symbol.iterator]||I["@@iterator"];if(g!=null){var e=[],i=!0,t=!1,C,o;try{for(g=g.call(I);!(i=(C=g.next()).done)&&(e.push(C.value),!(A&&e.length===A));i=!0);}catch(s){t=!0,o=s}finally{try{!i&&g.return!=null&&g.return()}finally{if(t)throw o}}return e}}function ZJ(I,A){if(I){if(typeof I=="string")return VJ(I,A);var g=Object.prototype.toString.call(I).slice(8,-1);if(g==="Object"&&I.constructor&&(g=I.constructor.name),g==="Map"||g==="Set")return Array.from(I);if(g==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g))return VJ(I,A)}}function VJ(I,A){(A==null||A>I.length)&&(A=I.length);for(var g=0,e=new Array(A);g<A;g++)e[g]=I[g];return e}function cz(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4461
4461
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zJ(I,A){var g=typeof Symbol<"u"&&I[Symbol.iterator]||I["@@iterator"];if(!g){if(Array.isArray(I)||(g=ZJ(I))||A&&I&&typeof I.length=="number"){g&&(I=g);var e=0,i=function(){};return{s:i,n:function(){return e>=I.length?{done:!0}:{done:!1,value:I[e++]}},e:function(s){throw s},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4462
4462
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,C=!1,o;return{s:function(){g=g.call(I)},n:function(){var s=g.next();return t=s.done,s},e:function(s){C=!0,o=s},f:function(){try{!t&&g.return!=null&&g.return()}finally{if(C)throw o}}}}var lz=function(I){on(g,I);var A=sn(g);function g(e){var i;return Lg(this,g),i=A.call(this),oA(Pg(i),"type","ParticleEmitter"),oA(Pg(i),"system",void 0),i.system=e,i}return vg(g,[{key:"clone",value:function(){var e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}},{key:"dispose",value:function(){}},{key:"extractFromCache",value:function(e){var i=[];for(var t in e){var C=e[t];delete C.metadata,i.push(C)}return i}},{key:"toJSON",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e===void 0||typeof e=="string",C={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},C.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var o={};if(o.uuid=this.uuid,o.type=this.type,this.name!==""&&(o.name=this.name),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),this.renderOrder!==0&&(o.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(o.userData=this.userData),o.layers=this.layers.mask,o.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(o.matrixAutoUpdate=!1),this.system!==null&&(o.ps=this.system.toJSON(e,i)),this.children.length>0){o.children=[];for(var s=0;s<this.children.length;s++)this.children[s].type!=="ParticleSystemPreview"&&o.children.push(this.children[s].toJSON(e).object)}if(t){var B=this.extractFromCache(e.geometries),a=this.extractFromCache(e.materials),n=this.extractFromCache(e.textures),r=this.extractFromCache(e.images);B.length>0&&(C.geometries=B),a.length>0&&(C.materials=a),n.length>0&&(C.textures=n),r.length>0&&(C.images=r)}return C.object=o,C}}]),g}(NA),XE=function(){function I(){Lg(this,I),oA(this,"parentMatrix",void 0),oA(this,"startSpeed",0),oA(this,"startColor",new eg),oA(this,"startSize",1),oA(this,"position",new M),oA(this,"velocity",new M),oA(this,"age",0),oA(this,"life",1),oA(this,"size",1),oA(this,"angularVelocity",void 0),oA(this,"rotation",0),oA(this,"color",new eg),oA(this,"uvTile",0)}return vg(I,[{key:"died",get:function(){return this.age>=this.life}}]),I}(),Dz=vg(function I(A,g,e){Lg(this,I),this.position=A,this.size=g,this.color=e}),zd=function(){function I(){Lg(this,I),oA(this,"parentMatrix",void 0),oA(this,"startSpeed",0),oA(this,"startColor",new eg),oA(this,"startSize",1),oA(this,"position",new M),oA(this,"localPosition",void 0),oA(this,"velocity",new M),oA(this,"age",0),oA(this,"life",1),oA(this,"size",1),oA(this,"length",100),oA(this,"color",new eg),oA(this,"previous",[]),oA(this,"uvTile",0)}return vg(I,[{key:"recordCurrentState",value:function(){for(this.previous.push(new Dz(this.position.clone(),this.size,this.color.clone()));this.previous.length>this.length;)this.previous.shift()}},{key:"died",get:function(){return this.age>=this.life}},{key:"reset",value:function(){this.previous.length=0}}]),I}(),ti=function(){function I(A){Lg(this,I),this.value=A,oA(this,"type",void 0),this.type="value"}return vg(I,[{key:"genValue",value:function(){return this.value}},{key:"toJSON",value:function(){return{type:"ConstantValue",value:this.value}}},{key:"clone",value:function(){return new I(this.value)}}],[{key:"fromJSON",value:function(A){return new I(A.value)}}]),I}(),dz=function(){function I(A,g){Lg(this,I),this.a=A,this.b=g,oA(this,"type",void 0),this.type="value"}return vg(I,[{key:"genValue",value:function(){return si.lerp(this.a,this.b,Math.random())}},{key:"toJSON",value:function(){return{type:"IntervalValue",a:this.a,b:this.b}}},{key:"clone",value:function(){return new I(this.a,this.b)}}],[{key:"fromJSON",value:function(A){return new I(A.a,A.b)}}]),I}(),pz=function(){function I(){Lg(this,I),oA(this,"functions",void 0),this.functions=new Array}return vg(I,[{key:"findFunction",value:function(A){for(var g=0,e=0,i=this.functions.length-1;e+1<i;)if(g=Math.floor((e+i)/2),A<this.getStartX(g))i=g-1;else if(A>this.getEndX(g))e=g+1;else return g;for(var t=e;t<=i;t++)if(A>=this.functions[t][1]&&A<=this.getEndX(t))return t;return-1}},{key:"getStartX",value:function(A){return this.functions[A][1]}},{key:"setStartX",value:function(A,g){A>0&&(this.functions[A][1]=g)}},{key:"getEndX",value:function(A){return A+1<this.functions.length?this.functions[A+1][1]:1}},{key:"setEndX",value:function(A,g){A+1<this.functions.length&&(this.functions[A+1][1]=g)}},{key:"insertFunction",value:function(A,g){var e=this.findFunction(A);this.functions.splice(e+1,0,[g,A])}},{key:"removeFunction",value:function(A){return this.functions.splice(A,1)[0][0]}},{key:"getFunction",value:function(A){return this.functions[A][0]}},{key:"setFunction",value:function(A,g){this.functions[A][0]=g}},{key:"numOfFunctions",get:function(){return this.functions.length}}]),I}(),XJ=function(){function I(A,g,e,i){Lg(this,I),oA(this,"p",void 0),this.p=[A,g,e,i]}return vg(I,[{key:"genValue",value:function(A){var g=A*A,e=A*A*A,i=1-A,t=i*i,C=t*i;return this.p[0]*C+this.p[1]*t*A*3+this.p[2]*i*g*3+this.p[3]*e}},{key:"derivativeCoefficients",value:function(A){for(var g=[],e=A,i=e.length-1;i>0;i--){for(var t=[],C=0;C<i;C++){var o=i*(e[C+1]-e[C]);t.push(o)}g.push(t),e=t}return g}},{key:"getSlope",value:function(A){var g=this.derivativeCoefficients(this.p)[0],e=1-A,i=e*e,t=e*A*2,C=A*A;return i*g[0]+t*g[1]+C*g[2]}},{key:"controlCurve",value:function(A,g){this.p[1]=A/3+this.p[0],this.p[2]=this.p[3]-g/3}},{key:"hull",value:function(A){var g=this.p,e=[],i,t=[],C=0,o=0,s=0;for(t[C++]=g[0],t[C++]=g[1],t[C++]=g[2],t[C++]=g[3];g.length>1;){for(e=[],o=0,s=g.length-1;o<s;o++)i=A*g[o]+(1-A)*g[o+1],t[C++]=i,e.push(i);g=e}return t}},{key:"split",value:function(A){var g=this.hull(A),e={left:new I(g[0],g[4],g[7],g[9]),right:new I(g[9],g[8],g[6],g[3]),span:g};return e}},{key:"clone",value:function(){return new I(this.p[0],this.p[1],this.p[2],this.p[3])}},{key:"toJSON",value:function(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}}],[{key:"fromJSON",value:function(A){return new I(A.p0,A.p1,A.p2,A.p3)}}]),I}(),uz=function(I){on(g,I);var A=sn(g);function g(){var e,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[[new XJ(0,.3333333333333333,.6666666666666666,1),0]];return Lg(this,g),e=A.call(this),oA(Pg(e),"type",void 0),e.type="function",e.functions=i,e}return vg(g,[{key:"genValue",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=this.findFunction(e);return i===-1?(console.error(e),0):this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}},{key:"toSVG",value:function(e,i){if(i<1)return"";for(var t=["M",0,this.functions[0][0].p[0]].join(" "),C=1/i;C<=1;C+=1/i)t=[t,"L",C*e,this.genValue(C)].join(" ");return t}},{key:"toJSON",value:function(){return{type:"PiecewiseBezier",functions:this.functions.map(function(e){var i=WJ(e,2),t=i[0],C=i[1];return{function:t.toJSON(),start:C}})}}},{key:"clone",value:function(){return new g(this.functions.map(function(e){var i=WJ(e,2),t=i[0],C=i[1];return[t.clone(),C]}))}}],[{key:"fromJSON",value:function(e){return new g(e.functions.map(function(i){return[XJ.fromJSON(i.function),i.start]}))}}]),g}(pz),$J=function(){function I(){Lg(this,I),oA(this,"type",void 0),this.type="rotation"}return vg(I,[{key:"genValue",value:function(A,g){var e,i,t,C,o,s,B;do e=Math.random()*2-1,i=Math.random()*2-1,t=e*e+i*i;while(t>1);do C=Math.random()*2-1,o=Math.random()*2-1,s=C*C+o*o;while(s>1);return B=Math.sqrt((1-t)/s),A.set(e,i,B*C,B*o),A}},{key:"toJSON",value:function(){return{type:"RandomQuat"}}},{key:"clone",value:function(){return new I}}],[{key:"fromJSON",value:function(A){return new I}}]),I}(),Aq=function(){function I(A,g){Lg(this,I),this.axis=A,this.angle=g,oA(this,"type",void 0),this.type="rotation"}return vg(I,[{key:"genValue",value:function(A,g){return A.setFromAxisAngle(this.axis,this.angle.genValue(g))}},{key:"toJSON",value:function(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}},{key:"clone",value:function(){return new I(this.axis.clone(),this.angle.clone())}}],[{key:"fromJSON",value:function(A){return new I(A.axis,Fe(A.angle))}}]),I}();function gq(I){switch(I.type){case"AxisAngle":return Aq.fromJSON(I);case"RandomQuat":return $J.fromJSON(I);default:return new $J}}function Fe(I){switch(I.type){case"ConstantValue":return ti.fromJSON(I);case"IntervalValue":return dz.fromJSON(I);case"PiecewiseBezier":return uz.fromJSON(I);default:return new ti(0)}}function wz(I){switch(I.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Fe(I);case"AxisAngle":case"RandomQuat":return gq(I);default:return new ti(0)}}var $E=function(I){return{r:I.x,g:I.y,b:I.z,a:I.w}},Ah=function(I){return new eg(I.r,I.g,I.b,I.a)},yz=function(){function I(A,g){Lg(this,I),this.a=A,this.b=g,oA(this,"type",void 0),this.type="value"}return vg(I,[{key:"genColor",value:function(A){var g=Math.random();return A.copy(this.a).lerp(this.b,g)}},{key:"toJSON",value:function(){return{type:"RandomColor",a:$E(this.a),b:$E(this.b)}}},{key:"clone",value:function(){return new I(this.a.clone(),this.b.clone())}}],[{key:"fromJSON",value:function(A){return new I(Ah(A.a),Ah(A.b))}}]),I}(),Sz=function(){function I(A,g){Lg(this,I),this.a=A,this.b=g,oA(this,"type",void 0),this.type="function"}return vg(I,[{key:"genColor",value:function(A,g){return A.copy(this.a).lerp(this.b,g)}},{key:"toJSON",value:function(){return{type:"ColorRange",a:$E(this.a),b:$E(this.b)}}},{key:"clone",value:function(){return new I(this.a.clone(),this.b.clone())}}],[{key:"fromJSON",value:function(A){return new I(Ah(A.a),Ah(A.b))}}]),I}(),Xd=function(){function I(A){Lg(this,I),this.color=A,oA(this,"type",void 0),this.type="value"}return vg(I,[{key:"genColor",value:function(A){return A.copy(this.color)}},{key:"toJSON",value:function(){return{type:"ConstantColor",color:$E(this.color)}}},{key:"clone",value:function(){return new I(this.color.clone())}}],[{key:"fromJSON",value:function(A){return new I(Ah(A.color))}}]),I}();function Iq(I){switch(I.type){case"ConstantColor":return Xd.fromJSON(I);case"ColorRange":return Sz.fromJSON(I);case"RandomColor":return yz.fromJSON(I);default:return new Xd(new eg(1,1,1,1))}}var eq=function(){function I(A){Lg(this,I),this.color=A,oA(this,"type","ColorOverLife")}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A,g){this.color.genColor(A.color,A.age/A.life),A.color.x*=A.startColor.x,A.color.y*=A.startColor.y,A.color.z*=A.startColor.z,A.color.w*=A.startColor.w}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,color:this.color.toJSON()}}},{key:"clone",value:function(){return new I(this.color.clone())}}],[{key:"fromJSON",value:function(A){return new I(Iq(A.color))}}]),I}(),iq=function(){function I(A,g){Lg(this,I),this.angularVelocity=A,this.dynamic=g,oA(this,"type","RotationOverLife"),oA(this,"tempQuat",new RA)}return vg(I,[{key:"initialize",value:function(A){!this.dynamic&&A instanceof XE&&(A.angularVelocity=this.angularVelocity.genValue())}},{key:"update",value:function(A,g){this.dynamic?A.rotation+=g*this.angularVelocity.genValue(A.age/A.life):A instanceof XE&&(A.rotation+=g*A.angularVelocity)}},{key:"toJSON",value:function(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),dynamic:this.dynamic}}},{key:"frameUpdate",value:function(A){}},{key:"clone",value:function(){return new I(this.angularVelocity.clone(),this.dynamic)}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.angularVelocity),A.dynamic)}}]),I}(),tq=function(){function I(A){Lg(this,I),this.size=A,oA(this,"type","SizeOverLife")}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A){A.size=A.startSize*this.size.genValue(A.age/A.life)}},{key:"toJSON",value:function(){return{type:this.type,size:this.size.toJSON()}}},{key:"frameUpdate",value:function(A){}},{key:"clone",value:function(){return new I(this.size.clone())}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.size))}}]),I}(),Cq=function(){function I(A){Lg(this,I),this.speed=A,oA(this,"type","SpeedOverLife")}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A){A.velocity.normalize().multiplyScalar(A.startSpeed*this.speed.genValue(A.age/A.life))}},{key:"toJSON",value:function(){return{type:this.type,speed:this.speed.toJSON()}}},{key:"frameUpdate",value:function(A){}},{key:"clone",value:function(){return new I(this.speed.clone())}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.speed))}}]),I}(),oq=function(){function I(A){Lg(this,I),this.frame=A,oA(this,"type","FrameOverLife")}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A,g){A.uvTile=Math.floor(this.frame.genValue(A.age/A.life))}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,frame:this.frame.toJSON()}}},{key:"clone",value:function(){return new I(this.frame.clone())}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.frame))}}]),I}();new M(0,0,1);var sq=function(){function I(A){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:new M(0,1,0);Lg(this,I),this.orbitSpeed=A,this.axis=g,oA(this,"type","OrbitOverLife"),oA(this,"rotation",void 0),oA(this,"line",void 0),oA(this,"temp",new M),this.rotation=new RA,this.line=new _m}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A,g){this.line.set(new M(0,0,0),this.axis),this.line.closestPointToPoint(A.position,!1,this.temp),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(A.age/A.life)*g),A.position.sub(this.temp),A.position.applyQuaternion(this.rotation),A.position.add(this.temp)}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}},{key:"clone",value:function(){return new I(this.orbitSpeed.clone())}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.orbitSpeed),A.axis?new M(A.axis[0],A.axis[1],A.axis[2]):void 0)}}]),I}(),Bq=function(){function I(A,g){Lg(this,I),this.direction=A,this.force=g,oA(this,"type","ApplyForce")}return vg(I,[{key:"initialize",value:function(A){A.force=this.force.genValue()}},{key:"update",value:function(A,g){A.velocity.addScaledVector(this.direction,A.force*g)}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],force:this.force.toJSON()}}},{key:"clone",value:function(){return new I(this.direction.clone(),this.force.clone())}}],[{key:"fromJSON",value:function(A){return new I(new M(A.direction[0],A.direction[1],A.direction[2]),Fe(A.force))}}]),I}(),aq=function(){function I(A,g){Lg(this,I),this.center=A,this.magnitude=g,oA(this,"type","GravityForce"),oA(this,"temp",new M)}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A,g){this.temp.copy(this.center).sub(A.position).normalize(),A.velocity.addScaledVector(this.temp,this.magnitude/A.position.distanceToSquared(this.center)*g)}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}},{key:"clone",value:function(){return new I(this.center.clone(),this.magnitude)}}],[{key:"fromJSON",value:function(A){return new I(new M(A.center[0],A.center[1],A.center[2]),A.magnitude)}}]),I}(),Qq=function(){function I(A){Lg(this,I),this.width=A,oA(this,"type","WidthOverLength")}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A){if(A instanceof zd)for(var g=0;g<A.previous.length;g++)A.previous[g].size=this.width.genValue((A.previous.length-g)/A.length)}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,width:this.width.toJSON()}}},{key:"clone",value:function(){return new I(this.width.clone())}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.width))}}]),I}();new M(0,0,1);var nq=function(){function I(A){Lg(this,I),this.angle=A,oA(this,"type","ChangeEmitDirection"),oA(this,"_temp",new M),oA(this,"_q",new RA)}return vg(I,[{key:"initialize",value:function(A){var g=A.velocity.length();g!=0&&(A.velocity.normalize(),A.velocity.x===0&&A.velocity.y===0?this._temp.set(0,A.velocity.z,0):this._temp.set(-A.velocity.y,A.velocity.x,0),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue()),this._temp.copy(A.velocity),A.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),A.velocity.applyQuaternion(this._q),A.velocity.setLength(g))}},{key:"update",value:function(A,g){}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,angle:this.angle.toJSON()}}},{key:"clone",value:function(){return new I(this.angle)}}],[{key:"fromJSON",value:function(A){return new I(Fe(A.angle))}}]),I}(),kz=new M(1,1,1),rq=new M(0,0,1),Eq=function(){function I(A,g,e){Lg(this,I),this.particleSystem=A,this.useVelocityAsBasis=g,this.subParticleSystem=e,oA(this,"type","EmitSubParticleSystem"),oA(this,"q_",new RA),oA(this,"v_",new M),oA(this,"v2_",new M),this.subParticleSystem&&(this.subParticleSystem.system.onlyUsedByOther=!0)}return vg(I,[{key:"initialize",value:function(A){A.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:new jA}}},{key:"update",value:function(A,g){if(!(!this.subParticleSystem||!A.emissionState)){var e=A.emissionState.matrix,i;if(A.rotation===void 0||this.useVelocityAsBasis)if(A.velocity.x===0&&A.velocity.y===0&&(A.velocity.z===1||A.velocity.z===0))e.set(1,0,0,A.position.x,0,1,0,A.position.y,0,0,1,A.position.z,0,0,0,1);else{this.v_.copy(rq).cross(A.velocity),this.v2_.copy(A.velocity).cross(this.v_);var t=this.v_.length(),C=this.v2_.length();e.set(this.v_.x/t,this.v2_.x/C,A.velocity.x,A.position.x,this.v_.y/t,this.v2_.y/C,A.velocity.y,A.position.y,this.v_.z/t,this.v2_.z/C,A.velocity.z,A.position.z,0,0,0,1)}else A.rotation instanceof RA?i=A.rotation:(this.q_.setFromAxisAngle(rq,A.rotation),i=this.q_),e.compose(A.position,i,kz);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e),this.subParticleSystem.system.emit(g,A.emissionState,e)}}},{key:"frameUpdate",value:function(A){}},{key:"toJSON",value:function(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis}}},{key:"clone",value:function(){return new I(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem)}}],[{key:"fromJSON",value:function(A,g){return new I(g,A.useVelocityAsBasis,void 0)}}]),I}(),Gz=.5*(Math.sqrt(3)-1),gh=(3-Math.sqrt(3))/6,fz=1/3,pC=1/6,Mz=(Math.sqrt(5)-1)/4,Ne=(5-Math.sqrt(5))/20,le=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),WI=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),mz=function(){function I(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Math.random;Lg(this,I),oA(this,"p",void 0),oA(this,"perm",void 0),oA(this,"permMod12",void 0);var g=typeof A=="function"?A:Rz(A);this.p=Uz(g),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(var e=0;e<512;e++)this.perm[e]=this.p[e&255],this.permMod12[e]=this.perm[e]%12}return vg(I,[{key:"noise2D",value:function(A,g){var e=this.permMod12,i=this.perm,t=0,C=0,o=0,s=(A+g)*Gz,B=Math.floor(A+s),a=Math.floor(g+s),n=(B+a)*gh,r=B-n,E=a-n,h=A-r,c=g-E,D,d;h>c?(D=1,d=0):(D=0,d=1);var w=h-D+gh,l=c-d+gh,p=h-1+2*gh,u=c-1+2*gh,y=B&255,k=a&255,S=.5-h*h-c*c;if(S>=0){var G=e[y+i[k]]*3;S*=S,t=S*S*(le[G]*h+le[G+1]*c)}var f=.5-w*w-l*l;if(f>=0){var K=e[y+D+i[k+d]]*3;f*=f,C=f*f*(le[K]*w+le[K+1]*l)}var q=.5-p*p-u*u;if(q>=0){var F=e[y+1+i[k+1]]*3;q*=q,o=q*q*(le[F]*p+le[F+1]*u)}return 70*(t+C+o)}},{key:"noise3D",value:function(A,g,e){var i=this.permMod12,t=this.perm,C,o,s,B,a=(A+g+e)*fz,n=Math.floor(A+a),r=Math.floor(g+a),E=Math.floor(e+a),h=(n+r+E)*pC,c=n-h,D=r-h,d=E-h,w=A-c,l=g-D,p=e-d,u,y,k,S,G,f;w>=l?l>=p?(u=1,y=0,k=0,S=1,G=1,f=0):w>=p?(u=1,y=0,k=0,S=1,G=0,f=1):(u=0,y=0,k=1,S=1,G=0,f=1):l<p?(u=0,y=0,k=1,S=0,G=1,f=1):w<p?(u=0,y=1,k=0,S=0,G=1,f=1):(u=0,y=1,k=0,S=1,G=1,f=0);var K=w-u+pC,q=l-y+pC,F=p-k+pC,J=w-S+2*pC,H=l-G+2*pC,O=p-f+2*pC,z=w-1+3*pC,W=l-1+3*pC,BA=p-1+3*pC,aA=n&255,DA=r&255,MA=E&255,eA=.6-w*w-l*l-p*p;if(eA<0)C=0;else{var rA=i[aA+t[DA+t[MA]]]*3;eA*=eA,C=eA*eA*(le[rA]*w+le[rA+1]*l+le[rA+2]*p)}var mA=.6-K*K-q*q-F*F;if(mA<0)o=0;else{var $=i[aA+u+t[DA+y+t[MA+k]]]*3;mA*=mA,o=mA*mA*(le[$]*K+le[$+1]*q+le[$+2]*F)}var YA=.6-J*J-H*H-O*O;if(YA<0)s=0;else{var qA=i[aA+S+t[DA+G+t[MA+f]]]*3;YA*=YA,s=YA*YA*(le[qA]*J+le[qA+1]*H+le[qA+2]*O)}var xA=.6-z*z-W*W-BA*BA;if(xA<0)B=0;else{var wA=i[aA+1+t[DA+1+t[MA+1]]]*3;xA*=xA,B=xA*xA*(le[wA]*z+le[wA+1]*W+le[wA+2]*BA)}return 32*(C+o+s+B)}},{key:"noise4D",value:function(A,g,e,i){var t=this.perm,C,o,s,B,a,n=(A+g+e+i)*Mz,r=Math.floor(A+n),E=Math.floor(g+n),h=Math.floor(e+n),c=Math.floor(i+n),D=(r+E+h+c)*Ne,d=r-D,w=E-D,l=h-D,p=c-D,u=A-d,y=g-w,k=e-l,S=i-p,G=0,f=0,K=0,q=0;u>y?G++:f++,u>k?G++:K++,u>S?G++:q++,y>k?f++:K++,y>S?f++:q++,k>S?K++:q++;var F=G>=3?1:0,J=f>=3?1:0,H=K>=3?1:0,O=q>=3?1:0,z=G>=2?1:0,W=f>=2?1:0,BA=K>=2?1:0,aA=q>=2?1:0,DA=G>=1?1:0,MA=f>=1?1:0,eA=K>=1?1:0,rA=q>=1?1:0,mA=u-F+Ne,$=y-J+Ne,YA=k-H+Ne,qA=S-O+Ne,xA=u-z+2*Ne,wA=y-W+2*Ne,lA=k-BA+2*Ne,uA=S-aA+2*Ne,cA=u-DA+3*Ne,bA=y-MA+3*Ne,UA=k-eA+3*Ne,gg=S-rA+3*Ne,dA=u-1+4*Ne,zA=y-1+4*Ne,tg=k-1+4*Ne,pg=S-1+4*Ne,Og=r&255,Y=E&255,L=h&255,QA=c&255,FA=.6-u*u-y*y-k*k-S*S;if(FA<0)C=0;else{var KA=t[Og+t[Y+t[L+t[QA]]]]%32*4;FA*=FA,C=FA*FA*(WI[KA]*u+WI[KA+1]*y+WI[KA+2]*k+WI[KA+3]*S)}var TA=.6-mA*mA-$*$-YA*YA-qA*qA;if(TA<0)o=0;else{var ig=t[Og+F+t[Y+J+t[L+H+t[QA+O]]]]%32*4;TA*=TA,o=TA*TA*(WI[ig]*mA+WI[ig+1]*$+WI[ig+2]*YA+WI[ig+3]*qA)}var T=.6-xA*xA-wA*wA-lA*lA-uA*uA;if(T<0)s=0;else{var X=t[Og+z+t[Y+W+t[L+BA+t[QA+aA]]]]%32*4;T*=T,s=T*T*(WI[X]*xA+WI[X+1]*wA+WI[X+2]*lA+WI[X+3]*uA)}var _A=.6-cA*cA-bA*bA-UA*UA-gg*gg;if(_A<0)B=0;else{var WA=t[Og+DA+t[Y+MA+t[L+eA+t[QA+rA]]]]%32*4;_A*=_A,B=_A*_A*(WI[WA]*cA+WI[WA+1]*bA+WI[WA+2]*UA+WI[WA+3]*gg)}var HA=.6-dA*dA-zA*zA-tg*tg-pg*pg;if(HA<0)a=0;else{var pA=t[Og+1+t[Y+1+t[L+1+t[QA+1]]]]%32*4;HA*=HA,a=HA*HA*(WI[pA]*dA+WI[pA+1]*zA+WI[pA+2]*tg+WI[pA+3]*pg)}return 27*(C+o+s+B+a)}}]),I}();function Uz(I){for(var A=new Uint8Array(256),g=0;g<256;g++)A[g]=g;for(var e=0;e<255;e++){var i=e+~~(I()*(256-e)),t=A[e];A[e]=A[i],A[i]=t}return A}function Rz(I){var A=0,g=0,e=0,i=1,t=Fz();return A=t(" "),g=t(" "),e=t(" "),A-=t(I),A<0&&(A+=1),g-=t(I),g<0&&(g+=1),e-=t(I),e<0&&(e+=1),function(){var C=2091639*A+i*23283064365386963e-26;return A=g,g=e,e=C-(i=C|0)}}function Fz(){var I=4022871197;return function(A){A=A.toString();for(var g=0;g<A.length;g++){I+=A.charCodeAt(g);var e=.02519603282416938*I;I=e>>>0,e-=I,e*=I,I=e>>>0,e-=I,I+=e*4294967296}return(I>>>0)*23283064365386963e-26}}var hq=function(){function I(A,g,e){Lg(this,I),this.scale=A,this.power=g,this.fieldShift=e,oA(this,"type","TurbulenceField"),oA(this,"generator",new mz),oA(this,"offset",[new M,new M,new M]),oA(this,"temp",new M),this.offset[0].x=Math.random()/this.scale.x,this.offset[1].x=Math.random()/this.scale.x,this.offset[2].x=Math.random()/this.scale.x,this.offset[0].y=Math.random()/this.scale.y,this.offset[1].y=Math.random()/this.scale.y,this.offset[2].y=Math.random()/this.scale.y,this.offset[0].z=Math.random()/this.scale.z,this.offset[1].z=Math.random()/this.scale.z,this.offset[2].z=Math.random()/this.scale.z}return vg(I,[{key:"initialize",value:function(A){}},{key:"update",value:function(A,g){var e=A.position.x/this.scale.x,i=A.position.y/this.scale.y,t=A.position.z/this.scale.z;this.temp.set(this.generator.noise3D(this.offset[0].x+e,this.offset[0].y+i,this.offset[0].z+t),this.generator.noise3D(this.offset[1].x+e,this.offset[1].y+i,this.offset[1].z+t),this.generator.noise3D(this.offset[2].x+e,this.offset[2].y+i,this.offset[2].z+t)).multiply(this.power),A.velocity.addScaledVector(this.temp,g)}},{key:"toJSON",value:function(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],power:[this.power.x,this.power.y,this.power.z],fieldShift:[this.fieldShift.x,this.fieldShift.y,this.fieldShift.z]}}},{key:"frameUpdate",value:function(A){this.offset[0].x+=A*this.fieldShift.x,this.offset[0].y+=A*this.fieldShift.y,this.offset[0].z+=A*this.fieldShift.z,this.offset[1].x+=A*this.fieldShift.x,this.offset[1].y+=A*this.fieldShift.y,this.offset[1].z+=A*this.fieldShift.z,this.offset[2].x+=A*this.fieldShift.x,this.offset[2].y+=A*this.fieldShift.y,this.offset[2].z+=A*this.fieldShift.z}},{key:"clone",value:function(){return new I(this.scale.clone(),this.power.clone(),this.fieldShift.clone())}}],[{key:"fromJSON",value:function(A){return new I(new M(A.scale[0],A.scale[1],A.scale[2]),new M(A.power[0],A.power[1],A.power[2]),new M(A.fieldShift[0],A.fieldShift[1],A.fieldShift[2]))}}]),I}(),cq=new RA,lq=function(){function I(A,g){Lg(this,I),this.angularVelocity=A,this.dynamic=g,oA(this,"type","Rotation3DOverLife"),oA(this,"tempQuat",new RA)}return vg(I,[{key:"initialize",value:function(A){!this.dynamic&&A instanceof XE&&(A.angularVelocity=new RA,this.angularVelocity.genValue(A.angularVelocity))}},{key:"update",value:function(A,g){this.dynamic?(this.angularVelocity.genValue(this.tempQuat,A.age/A.life),this.tempQuat.slerpQuaternions(cq,this.tempQuat,g),A.rotation.multiply(this.tempQuat)):A instanceof XE&&(this.tempQuat.slerpQuaternions(cq,A.angularVelocity,g),A.rotation.multiply(this.tempQuat))}},{key:"toJSON",value:function(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),dynamic:this.dynamic}}},{key:"frameUpdate",value:function(A){}},{key:"clone",value:function(){return new I(this.angularVelocity.clone(),this.dynamic)}}],[{key:"fromJSON",value:function(A){return new I(gq(A.angularVelocity),A.dynamic)}}]),I}(),Nz={ApplyForce:{type:"ApplyForce",constructor:Bq,params:[["direction","vec3"],["force","value"]],loadJSON:Bq.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:hq,params:[["scale","vec3"],["power","vec3"],["fieldShift","vec3"]],loadJSON:hq.fromJSON},GravityForce:{type:"GravityForce",constructor:aq,params:[["center","vec3"],["magnitude","number"]],loadJSON:aq.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:eq,params:[["color","colorFunc"]],loadJSON:eq.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:iq,params:[["angularVelocity","valueFunc"],["dynamic","boolean"]],loadJSON:iq.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:lq,params:[["angularVelocity","rotationFunc"],["dynamic","boolean"]],loadJSON:lq.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:tq,params:[["size","valueFunc"]],loadJSON:tq.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Cq,params:[["speed","valueFunc"]],loadJSON:Cq.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:oq,params:[["frame","valueFunc"]],loadJSON:oq.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:sq,params:[["orbitSpeed","valueFunc"],["axis","vec3"]],loadJSON:sq.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Qq,params:[["width","valueFunc"]],loadJSON:Qq.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:nq,params:[["angle","value"]],loadJSON:nq.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Eq,params:[["particleSystem","self"],["useVelocityAsBasis","boolean"],["subParticleSystem","particleSystem"]],loadJSON:Eq.fromJSON}};function Kz(I,A){return Nz[I.type].loadJSON(I,A)}var Dq=function(){function I(){var A,g,e,i,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lg(this,I),oA(this,"type","cone"),oA(this,"radius",void 0),oA(this,"arc",void 0),oA(this,"thickness",void 0),oA(this,"angle",void 0),this.radius=(A=t.radius)!==null&&A!==void 0?A:10,this.arc=(g=t.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(e=t.thickness)!==null&&e!==void 0?e:1,this.angle=(i=t.angle)!==null&&i!==void 0?i:Math.PI/6}return vg(I,[{key:"initialize",value:function(A){var g=Math.random(),e=si.lerp(1-this.thickness,1,Math.random()),i=g*this.arc,t=Math.sqrt(e),C=Math.sin(i),o=Math.cos(i);A.position.x=t*o,A.position.y=t*C,A.position.z=0;var s=this.angle*t;A.velocity.set(0,0,Math.cos(s)).addScaledVector(A.position,Math.sin(s)).multiplyScalar(A.startSpeed),A.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle}}},{key:"clone",value:function(){return new I({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle})}}],[{key:"fromJSON",value:function(A){return new I(A)}}]),I}(),dq=function(){function I(){var A,g,e,i,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lg(this,I),oA(this,"type","donut"),oA(this,"radius",void 0),oA(this,"arc",void 0),oA(this,"thickness",void 0),oA(this,"angle",void 0),this.radius=(A=t.radius)!==null&&A!==void 0?A:10,this.arc=(g=t.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(e=t.thickness)!==null&&e!==void 0?e:1,this.angle=(i=t.angle)!==null&&i!==void 0?i:Math.PI/6}return vg(I,[{key:"initialize",value:function(A){var g=Math.random(),e=si.lerp(this.thickness,1,Math.random()),i=g*this.arc,t=Math.sqrt(e),C=Math.sin(i),o=Math.cos(i);A.position.x=t*o,A.position.y=t*C,A.position.z=0;var s=this.angle*t;A.velocity.set(0,0,Math.cos(s)).addScaledVector(A.position,Math.sin(s)).multiplyScalar(A.startSpeed),A.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle}}},{key:"clone",value:function(){return new I({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle})}}],[{key:"fromJSON",value:function(A){return new I(A)}}]),I}(),pq=function(){function I(){Lg(this,I),oA(this,"type","point")}return vg(I,[{key:"initialize",value:function(A){var g=Math.random(),e=Math.random(),i=g*Math.PI*2,t=Math.acos(2*e-1),C=Math.cbrt(Math.random()),o=Math.sin(i),s=Math.cos(i),B=Math.sin(t),a=Math.cos(t);A.velocity.x=C*B*s,A.velocity.y=C*B*o,A.velocity.z=C*a,A.velocity.multiplyScalar(A.startSpeed),A.position.setScalar(0)}},{key:"toJSON",value:function(){return{type:"point"}}},{key:"clone",value:function(){return new I}}],[{key:"fromJSON",value:function(A){return new I}}]),I}(),Xk=function(){function I(){var A,g,e,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lg(this,I),oA(this,"type","sphere"),oA(this,"radius",void 0),oA(this,"arc",void 0),oA(this,"thickness",void 0),this.radius=(A=i.radius)!==null&&A!==void 0?A:10,this.arc=(g=i.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(e=i.thickness)!==null&&e!==void 0?e:1}return vg(I,[{key:"initialize",value:function(A){var g=Math.random(),e=Math.random(),i=si.lerp(1-this.thickness,1,Math.random()),t=g*this.arc,C=Math.acos(2*e-1),o=Math.cbrt(i),s=Math.sin(t),B=Math.cos(t),a=Math.sin(C),n=Math.cos(C);A.position.x=o*a*B,A.position.y=o*a*s,A.position.z=o*n,A.velocity.setScalar(0).addScaledVector(A.position,A.startSpeed),A.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness}}},{key:"clone",value:function(){return new I({radius:this.radius,arc:this.arc,thickness:this.thickness})}}],[{key:"fromJSON",value:function(A){return new I(A)}}]),I}(),uq=function(){function I(A){Lg(this,I),oA(this,"type","mesh_surface"),oA(this,"_triangleIndexToArea",[]),oA(this,"_mesh",void 0),oA(this,"_tempA",new M),oA(this,"_tempB",new M),oA(this,"_tempC",new M),A&&(this.mesh=A)}return vg(I,[{key:"mesh",get:function(){return this._mesh},set:function(A){this._mesh=A;var g=new Vi;this._triangleIndexToArea.length=0;var e=0,i=A.geometry;if(i.getIndex()){var t=i.getIndex().array,C=t.length/3;this._triangleIndexToArea.push(0);for(var o=0;o<C;o++)g.setFromAttributeAndIndices(i.getAttribute("position"),t[o*3],t[o*3+1],t[o*3+2]),e+=g.getArea(),this._triangleIndexToArea.push(e);A.userData.triangleIndexToArea=this._triangleIndexToArea}}},{key:"initialize",value:function(A){if(!this._mesh){A.position.set(0,0,0),A.velocity.set(0,0,1).multiplyScalar(A.startSpeed);return}for(var g=this._triangleIndexToArea.length-1,e=0,i=g,t=Math.random()*this._triangleIndexToArea[g];e+1<i;){var C=Math.floor((e+i)/2);t<this._triangleIndexToArea[C]?i=C:e=C}var o=Math.random(),s=Math.random();o+s>1&&(o=1-o,s=1-s);var B=this._mesh.geometry,a=B.getIndex().array[e*3],n=B.getIndex().array[e*3+1],r=B.getIndex().array[e*3+2],E=B.getAttribute("position");this._tempA.fromBufferAttribute(E,a),this._tempB.fromBufferAttribute(E,n),this._tempC.fromBufferAttribute(E,r),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,s),A.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),A.velocity.copy(this._tempA).normalize().multiplyScalar(A.startSpeed)}},{key:"toJSON",value:function(){return{type:"mesh_surface",mesh:this._mesh?this._mesh.uuid:""}}},{key:"clone",value:function(){return new I(this._mesh)}}],[{key:"fromJSON",value:function(A){return new I}}]),I}(),Jz={cone:{type:"cone",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:Dq,loadJSON:Dq.fromJSON},donut:{type:"donut",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:dq,loadJSON:dq.fromJSON},point:{type:"point",params:[],constructor:pq,loadJSON:pq.fromJSON},sphere:{type:"sphere",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:Xk,loadJSON:Xk.fromJSON},mesh_surface:{type:"mesh_surface",params:[["mesh","mesh"]],constructor:uq,loadJSON:uq.fromJSON}};function qz(I){return Jz[I.type].loadJSON(I)}var cg;(function(I){I[I.BillBoard=0]="BillBoard",I[I.StretchedBillBoard=1]="StretchedBillBoard",I[I.LocalSpace=2]="LocalSpace",I[I.Trail=3]="Trail"})(cg||(cg={}));var wq=function(I){on(g,I);var A=sn(g);function g(e){var i;return Lg(this,g),i=A.call(this),oA(Pg(i),"type","ParticleSystemBatch"),oA(Pg(i),"systems",void 0),oA(Pg(i),"material",void 0),oA(Pg(i),"settings",void 0),oA(Pg(i),"maxParticles",void 0),i.maxParticles=1e3,i.systems=new Set,i.settings={blending:e.blending,instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,texture:e.texture,uTileCount:e.uTileCount,vTileCount:e.vTileCount,transparent:e.transparent},i.frustumCulled=!1,i.renderOrder=i.settings.renderOrder,i}return vg(g,[{key:"addSystem",value:function(e){this.systems.add(e)}},{key:"removeSystem",value:function(e){this.systems.delete(e)}}]),g}(fA),bz=new M(0,0,1),yq=new RA,Lz=new Ke(1,1,1,1),vz=function(){function I(A,g){var e,i,t,C,o,s,B,a,n,r,E,h,c,D,d,w,l,p,u,y,k,S;Lg(this,I),oA(this,"autoDestroy",void 0),oA(this,"looping",void 0),oA(this,"duration",void 0),oA(this,"startLife",void 0),oA(this,"startSpeed",void 0),oA(this,"startRotation",void 0),oA(this,"startSize",void 0),oA(this,"startColor",void 0),oA(this,"startTileIndex",void 0),oA(this,"rendererEmitterSettings",void 0),oA(this,"emissionOverTime",void 0),oA(this,"emissionOverDistance",void 0),oA(this,"emissionBursts",void 0),oA(this,"onlyUsedByOther",void 0),oA(this,"worldSpace",void 0),oA(this,"speedFactor",void 0),oA(this,"particleNum",void 0),oA(this,"paused",void 0),oA(this,"emissionState",void 0),oA(this,"emitEnded",void 0),oA(this,"markForDestroy",void 0),oA(this,"normalMatrix",new zI),oA(this,"behaviors",void 0),oA(this,"particles",void 0),oA(this,"emitterShape",void 0),oA(this,"emitter",void 0),oA(this,"rendererSettings",void 0),oA(this,"renderer",void 0),oA(this,"neededToUpdateRender",void 0),this.renderer=A,this.autoDestroy=g.autoDestroy===void 0?!1:g.autoDestroy,this.duration=(e=g.duration)!==null&&e!==void 0?e:1,this.looping=g.looping===void 0?!0:g.looping,this.startLife=(i=g.startLife)!==null&&i!==void 0?i:new ti(5),this.startSpeed=(t=g.startSpeed)!==null&&t!==void 0?t:new ti(0),this.startRotation=(C=g.startRotation)!==null&&C!==void 0?C:new ti(0),this.startSize=(o=g.startSize)!==null&&o!==void 0?o:new ti(1),this.startColor=(s=g.startColor)!==null&&s!==void 0?s:new Xd(new eg(1,1,1,1)),this.emissionOverTime=(B=g.emissionOverTime)!==null&&B!==void 0?B:new ti(10),this.emissionOverDistance=(a=g.emissionOverDistance)!==null&&a!==void 0?a:new ti(0),this.emissionBursts=(n=g.emissionBursts)!==null&&n!==void 0?n:[],this.onlyUsedByOther=(r=g.onlyUsedByOther)!==null&&r!==void 0?r:!1,this.emitterShape=(E=g.shape)!==null&&E!==void 0?E:new Xk,this.behaviors=(h=g.behaviors)!==null&&h!==void 0?h:new Array,this.worldSpace=(c=g.worldSpace)!==null&&c!==void 0?c:!1,this.speedFactor=(D=g.speedFactor)!==null&&D!==void 0?D:0,this.rendererEmitterSettings=(d=g.rendererEmitterSettings)!==null&&d!==void 0?d:{},this.rendererSettings={blending:(w=g.blending)!==null&&w!==void 0?w:KC,transparent:(l=g.transparent)!==null&&l!==void 0?l:!0,instancingGeometry:(p=g.instancingGeometry)!==null&&p!==void 0?p:Lz,renderMode:(u=g.renderMode)!==null&&u!==void 0?u:cg.BillBoard,renderOrder:(y=g.renderOrder)!==null&&y!==void 0?y:0,texture:g.texture,uTileCount:(k=g.uTileCount)!==null&&k!==void 0?k:1,vTileCount:(S=g.vTileCount)!==null&&S!==void 0?S:1},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=g.startTileIndex||new ti(0),this.emitter=new lz(this),this.paused=!1,this.particleNum=0,this.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this.emitEnded=!1,this.markForDestroy=!1,this.renderer.addSystem(this)}return vg(I,[{key:"texture",get:function(){return this.rendererSettings.texture},set:function(A){this.rendererSettings.texture=A,this.neededToUpdateRender=!0}},{key:"uTileCount",get:function(){return this.rendererSettings.uTileCount},set:function(A){this.rendererSettings.uTileCount=A,this.neededToUpdateRender=!0}},{key:"vTileCount",get:function(){return this.rendererSettings.vTileCount},set:function(A){this.rendererSettings.vTileCount=A,this.neededToUpdateRender=!0}},{key:"instancingGeometry",get:function(){return this.rendererSettings.instancingGeometry},set:function(A){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=A,this.neededToUpdateRender=!0}},{key:"renderMode",get:function(){return this.rendererSettings.renderMode},set:function(A){if((this.rendererSettings.renderMode!=cg.Trail&&A===cg.Trail||this.rendererSettings.renderMode==cg.Trail&&A!==cg.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==A)switch(A){case cg.Trail:this.rendererEmitterSettings={startLength:new ti(30),followLocalOrigin:!1};break;case cg.LocalSpace:this.rendererEmitterSettings={geometry:new Ke(1,1)},this.startRotation=new Aq(new M(0,1,0),new ti(0));break;case cg.BillBoard:case cg.StretchedBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===cg.LocalSpace&&(this.startRotation=new ti(0));break}this.rendererSettings.renderMode=A,this.neededToUpdateRender=!0}},{key:"renderOrder",get:function(){return this.rendererSettings.renderOrder},set:function(A){this.rendererSettings.renderOrder=A,this.neededToUpdateRender=!0}},{key:"blending",get:function(){return this.rendererSettings.blending},set:function(A){this.rendererSettings.blending=A,this.neededToUpdateRender=!0}},{key:"pause",value:function(){this.paused=!0}},{key:"play",value:function(){this.paused=!1}},{key:"spawn",value:function(A,g,e){yq.setFromRotationMatrix(e);for(var i=0;i<A;i++){for(this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===cg.Trail?this.particles.push(new zd):this.particles.push(new XE);var t=this.particles[this.particleNum-1];if(this.startColor.genColor(t.startColor,g.time),t.color.copy(t.startColor),t.startSpeed=this.startSpeed.genValue(g.time/this.duration),t.life=this.startLife.genValue(g.time/this.duration),t.age=0,t.startSize=this.startSize.genValue(g.time/this.duration),t.uvTile=Math.floor(this.startTileIndex.genValue()),t.size=t.startSize,this.rendererSettings.renderMode===cg.LocalSpace||this.rendererSettings.renderMode===cg.BillBoard||this.rendererSettings.renderMode===cg.StretchedBillBoard){var C=t;this.rendererSettings.renderMode===cg.LocalSpace?(C.rotation instanceof RA||(C.rotation=new RA),this.startRotation.type==="rotation"?this.startRotation.genValue(C.rotation,g.time/this.duration):C.rotation.setFromAxisAngle(bz,this.startRotation.genValue(g.time/this.duration))):this.startRotation.type==="rotation"?C.rotation=0:C.rotation=this.startRotation.genValue(g.time/this.duration)}else if(this.rendererSettings.renderMode===cg.Trail){var o=t;o.length=this.rendererEmitterSettings.startLength.genValue(g.time/this.duration),o.reset()}if(this.emitterShape.initialize(t),this.rendererSettings.renderMode===cg.Trail&&this.rendererEmitterSettings.followLocalOrigin){var s=t;s.localPosition=new M().copy(s.position)}this.worldSpace?(t.position.applyMatrix4(e),t.velocity.applyMatrix3(this.normalMatrix),t.rotation&&t.rotation instanceof RA&&t.rotation.multiplyQuaternions(yq,t.rotation)):this.onlyUsedByOther&&(t.parentMatrix=e);for(var B=0;B<this.behaviors.length;B++)this.behaviors[B].initialize(t)}}},{key:"endEmit",value:function(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0)}},{key:"dispose",value:function(){this.renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter)}},{key:"restart",value:function(){this.paused=!1,this.particleNum=0,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.emitEnded=!1,this.markForDestroy=!1}},{key:"update",value:function(A){if(A>.1&&(A=.1),!this.paused){if(this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}this.neededToUpdateRender&&(this.renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(A,this.emissionState,this.emitter.matrixWorld);for(var g=0;g<this.behaviors.length;g++){for(var e=0;e<this.particleNum;e++)this.behaviors[g].update(this.particles[e],A);this.behaviors[g].frameUpdate(A)}for(var i=0;i<this.particleNum;i++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[i].localPosition?(this.particles[i].position.copy(this.particles[i].localPosition),this.particles[i].parentMatrix?this.particles[i].position.applyMatrix4(this.particles[i].parentMatrix):this.particles[i].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[i].position.addScaledVector(this.particles[i].velocity,A),this.particles[i].age+=A;if(this.rendererSettings.renderMode===cg.Trail)for(var t=0;t<this.particleNum;t++){var C=this.particles[t];C.recordCurrentState()}for(var o=0;o<this.particleNum;o++){var s=this.particles[o];s.age>=s.life&&(this.particles[o]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=s,this.particleNum--,o--)}}}},{key:"emit",value:function(A,g,e){if(g.time>this.duration&&(this.looping?(g.time-=this.duration,g.burstIndex=0):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(e),!this.emitEnded){var i=Math.ceil(g.waitEmiting);this.spawn(i,g,e),g.waitEmiting-=i}for(;g.burstIndex<this.emissionBursts.length&&this.emissionBursts[g.burstIndex].time<=g.time;){if(Math.random()<this.emissionBursts[g.burstIndex].probability){var t=this.emissionBursts[g.burstIndex].count;this.spawn(t,g,e)}g.burstIndex++}this.emitEnded||(g.waitEmiting+=A*this.emissionOverTime.genValue(g.time/this.duration)),g.time+=A}},{key:"toJSON",value:function(A){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=A===void 0||typeof A=="string";if(e&&(A={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),this.texture.toJSON(A),g.useUrlForImage&&this.texture.source!==void 0){var i=this.texture.source;A.images[i.uuid]={uuid:i.uuid,url:this.texture.image.url}}var t;this.renderMode===cg.Trail?t={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===cg.LocalSpace?t={}:t={};var C=this.rendererSettings.instancingGeometry;return A.geometries&&!A.geometries[C.uuid]&&(A.geometries[C.uuid]=C.toJSON()),{autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:t,speedFactor:this.renderMode===cg.StretchedBillBoard?this.speedFactor:0,texture:this.texture.uuid,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blending:this.blending,behaviors:this.behaviors.map(function(o){return o.toJSON()}),worldSpace:this.worldSpace}}},{key:"addBehavior",value:function(A){this.behaviors.push(A)}},{key:"getRendererSettings",value:function(){return this.rendererSettings}},{key:"clone",value:function(){var A=[],g=zJ(this.emissionBursts),e;try{for(g.s();!(e=g.n()).done;){var i=e.value,t={};Object.assign(t,i),A.push(t)}}catch(n){g.e(n)}finally{g.f()}var C=[],o=zJ(this.behaviors),s;try{for(o.s();!(s=o.n()).done;){var B=s.value;C.push(B.clone())}}catch(n){o.e(n)}finally{o.f()}var a;return this.renderMode===cg.Trail?a={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:a={},new I(this.renderer,{autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:A,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,rendererEmitterSettings:a,speedFactor:this.speedFactor,texture:this.texture,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blending:this.blending,behaviors:C,worldSpace:this.worldSpace})}}],[{key:"fromJSON",value:function(A,g,e,i){var t=qz(A.shape),C;A.renderMode===cg.Trail?C={startLength:Fe(A.rendererEmitterSettings.startLength),followLocalOrigin:A.rendererEmitterSettings.followLocalOrigin}:A.renderMode===cg.LocalSpace?C={}:C={};var o=new I(i,{autoDestroy:A.autoDestroy,looping:A.looping,duration:A.duration,shape:t,startLife:Fe(A.startLife),startSpeed:Fe(A.startSpeed),startRotation:wz(A.startRotation),startSize:Fe(A.startSize),startColor:Iq(A.startColor),emissionOverTime:Fe(A.emissionOverTime),emissionOverDistance:Fe(A.emissionOverDistance),emissionBursts:A.emissionBursts,onlyUsedByOther:A.onlyUsedByOther,instancingGeometry:g.geometries[A.instancingGeometry],renderMode:A.renderMode,rendererEmitterSettings:C,renderOrder:A.renderOrder,speedFactor:A.speedFactor,texture:g.textures[A.texture],startTileIndex:typeof A.startTileIndex=="number"?new ti(A.startTileIndex):Fe(A.startTileIndex),uTileCount:A.uTileCount,vTileCount:A.vTileCount,blending:A.blending,behaviors:[],worldSpace:A.worldSpace});return o.behaviors=A.behaviors.map(function(s){var B=Kz(s,o);return B.type==="EmitSubParticleSystem"&&(e[s.subParticleSystem]=B),B}),o}}]),I}(),Sq=`
@@ -4456,7 +4456,7 @@ See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type
4456
4456
  #include <encodings_fragment>
4457
4457
 
4458
4458
  }
4459
- `,E={map:{value:A},height:{value:(g==null?void 0:g.height)||15},radius:{value:(g==null?void 0:g.radius)||100}},c=new BQ(1,16),h=new Og({uniforms:E,fragmentShader:a,vertexShader:r,side:fI});super(c,h)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}};var Xz=Object.defineProperty,$z=Object.getOwnPropertyDescriptor,zu=(i,A,g,I)=>{for(var e=I>1?void 0:I?$z(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&Xz(A,g,e),e};class GB extends TA{constructor(){super(...arguments);Q(this,"applyOnAwake",!1);Q(this,"_scale",20);Q(this,"_radius",100);Q(this,"_height",100);Q(this,"_lastEnvironment");Q(this,"env");Q(this,"_watcher")}set scale(g){var I;this._scale=g,(I=this.env)==null||I.scale.setScalar(g)}get scale(){return this._scale}set radius(g){this._radius=g,this.env&&(this.env.height=g)}get radius(){return this._radius}set height(g){this._height=g,this.env&&(this.env.height=g)}get height(){return this._height}awake(){this.applyOnAwake&&this.updateAndCreate()}onEnable(){this.context.time.frameCount>0&&this.applyOnAwake&&this.updateAndCreate(),this._watcher||(this._watcher=new lE(this.context.scene,"environment"),this._watcher.subscribeWrite(g=>{this.updateProjection()}))}onDisable(){var g,I;(g=this._watcher)==null||g.revoke(),(I=this.env)==null||I.removeFromParent()}updateAndCreate(){var g;this.updateProjection(),(g=this._watcher)==null||g.apply()}updateProjection(){var g;if(!this.context.scene.environment){(g=this.env)==null||g.removeFromParent();return}(!this.env||this.context.scene.environment!==this._lastEnvironment)&&(console.log("Create/Update Ground Projection",this.context.scene.environment.name),this.env=new Vz(this.context.scene.environment)),this._lastEnvironment=this.context.scene.environment,this.env.parent||this.gameObject.add(this.env),this.env.scale.setScalar(this._scale),this.env.radius=this._radius,this.env.height=this._height,this.env.isObject3D===!0&&this.env.layers.set(2)}}zu([U()],GB.prototype,"applyOnAwake",2);zu([U()],GB.prototype,"scale",1);zu([U()],GB.prototype,"radius",1);zu([U()],GB.prototype,"height",1);var AV=Object.defineProperty,gV=Object.getOwnPropertyDescriptor,ZC=(i,A,g,I)=>{for(var e=I>1?void 0:I?gV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&AV(A,g,e),e};const IV=EA("debugtext");class ci extends $s{constructor(){super(...arguments);Q(this,"canvas");Q(this,"alignment",0);Q(this,"verticalOverflow",0);Q(this,"horizontalOverflow",0);Q(this,"lineSpacing",1);Q(this,"supportRichText",!1);Q(this,"font");Q(this,"fontStyle",0);Q(this,"_isWaitingForRebuild",!1);Q(this,"_text","");Q(this,"_fontSize",12);Q(this,"_textMeshUi",null);Q(this,"_textContainer",null);Q(this,"_didHandleTextRenderOnTop",!1)}get text(){return this._text}set text(g){if(this._text=g,!this._textMeshUi&&this._text.length>0&&this.context.time.frame>0&&this.createText(g,this.getTextOpts(),this.supportRichText),this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({content:g}),this.markDirty()}}set_text(g){this.text=g}get fontSize(){return this._fontSize}set fontSize(g){if(this._fontSize=g,this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({fontSize:g}),this.markDirty()}}onColorChanged(){if(this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}const g=this.color;this._textMeshUi[0].set({fontColor:g,fontOpacity:g.alpha}),this.markDirty()}}requestRebuild(){this._isWaitingForRebuild||(this._isWaitingForRebuild=!0,this.startCoroutine(this.rebuildDelayedRoutine(),Ri.EarlyUpdate))}*rebuildDelayedRoutine(){if(this._isWaitingForRebuild=!1,this._textMeshUi){for(const g of this._textMeshUi)g.removeFromParent();this._textMeshUi.length=0}this.createText(this.text,this.getTextOpts(),this.supportRichText),this.markDirty()}onCreate(g){IV&&console.log(this);const I=this.verticalOverflow==0&&this.horizontalOverflow==0;I&&(this.context.renderer.localClippingEnabled=!0);const e=this.rectTransform;this._textContainer=this.uiObject=this.createBlock(e,I,null,!0),this.createText(this.text,this.getTextOpts(),this.supportRichText),this.uiObject,this.uiObject=this.createBlock(e,I,this.uiObject,!1)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let g=this.fontSize;const I={content:this.text,fontColor:this.color,fontOpacity:this.color.alpha,fontSize:g,fontKerning:"normal"};return this.setFont(I,this.fontStyle),I}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&(this.uiObject.onAfterUpdate=()=>{this.updateWidth(),this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}createBlock(g,I,e,t=!1){const C={};C.hiddenOverflow=I,C.interLine=(this.lineSpacing-1)*this.fontSize*1.333,this.getAlignment(C,t);const o=g.createNewBlock(C),s=o.backgroundMaterial;return s&&(s.depthWrite=!1),e&&(Array.isArray(e)?o.add(...e):o.add(e)),o}getAlignment(g,I=!1){if(!I)switch(g.contentDirection="row",this.alignment){case 0:case 3:case 6:g.textAlign="left";break;case 1:case 4:case 7:g.textAlign="center";break;case 2:case 5:case 8:g.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:g.justifyContent="start";break;case 3:case 4:case 5:g.justifyContent="center";break;case 6:case 7:case 8:g.justifyContent="end";break}switch(this.alignment){case 0:case 3:case 6:g.alignItems="start";break;case 1:case 4:case 7:g.alignItems="center";break;case 2:case 5:case 8:g.alignItems="end";break}return g}updateWidth(){this.horizontalOverflow===1&&setTimeout(()=>{if(!this._textMeshUi)return;const g=this._textMeshUi[0].parent;if(g&&g.lines){let I=g.lines.reduce((e,t)=>e+t.width,0);I+=g.getFontSize()*5,I+=g.padding*2||0,I+=this.fontSize*1.5,g.set({width:I}),this.ensureShadowComponentOwner()}},1)}ensureShadowComponentOwner(){this.shadowComponent&&this.shadowComponent.traverse(g=>{g[Pt]===void 0&&(g[Pt]=this)})}createText(g,I,e){if(!(!g||g.length<=0))if(this._textMeshUi||(this._textMeshUi=[]),e){let t=this.getNextTag(g);if(t)t.startIndex>0&&this.createText(g.substring(0,t.startIndex),I,!1);else return this.createText(g,I,!1);const C=[];for(;t;){const o=this.getNextTag(g,t.endIndex);if(o){const s=this.getText(g,t,o);this.handleTag(t,I,C),this.createText(s,I,!1)}else{const s=g.substring(t.endIndex);this.handleTag(t,I,C),this.createText(s,I,!1)}t=o}}else{const t={...I};t.content=g;const C=new Mq(t);this._textMeshUi.push(C),this._textContainer&&this._textContainer.add(C)}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const g=[],I=this.canvas,e={renderOnTop:I.renderOnTop,depthWrite:I.depthWrite,doubleSided:I.doubleSided};for(;;){let t=!1;if(this._textMeshUi)for(let C=0;C<this._textMeshUi.length;C++){if(g[C]===!0)continue;t=!0;const o=this._textMeshUi[C];o.textContent&&(tD(o,e),g[C]=!0)}if(!t)break;yield}}handleTag(g,I,e){if(g.isEndTag){if(e.length>0){const t=e.pop();if(t)for(const C in t.previousValues){const o=t.previousValues[C];I[C]=o}}}else if(g.type.includes("color")){const t=new Hw(g,{fontColor:I.fontColor});if(e.push(t),g.type.length>6){const C=g.type.substring(6);I.fontColor=new wA(C)}else I.fontColor=new wA(1,1,1)}else if(g.type=="b"){const t=new Hw(g,{fontFamily:I.fontFamily,fontTexture:I.fontTexture});e.push(t),this.setFont(I,1)}else if(g.type=="i"){const t=new Hw(g,{fontFamily:I.fontFamily,fontTexture:I.fontTexture});e.push(t),this.setFont(I,2)}}getText(g,I,e){return g.substring(I.endIndex,e.startIndex)}getNextTag(g,I=0){const e=g.indexOf("<",I),t=g.indexOf(">",e);if(e>=0&&t>=0){const C=g.substring(e+1,t);return{type:C,startIndex:e,endIndex:t+1,isEndTag:C.startsWith("/")}}return null}setFont(g,I){const e=this.getFontStyleName(I);let t=e;t!=null&&t.endsWith("-msdf.json")||(t+="-msdf.json"),g.fontFamily=t;let C=e;C!=null&&C.endsWith(".png")||(C+=".png"),g.fontTexture=C}getFontStyleName(g){if(!this.font)return null;let I=this.font;if(I.endsWith("-regular")){if(g===0)return lt(this.sourceId,I);I=I.substring(0,I.length-8)}else if(I.endsWith("-bold")){if(g===1)return lt(this.sourceId,I);I=I.substring(0,I.length-5)}else if(I.endsWith("-italic")){if(g===2)return lt(this.sourceId,I);I=I.substring(0,I.length-7)}else if(I.endsWith("-bolditalic")){if(g===3)return lt(this.sourceId,I);I=I.substring(0,I.length-11)}else return lt(this.sourceId,I);switch(g){case 0:I+="-regular";break;case 1:I+="-bold";break;case 2:I+="-italic";break;case 3:I+="-bolditalic";break}return lt(this.sourceId,I)}}ZC([U(gt)],ci.prototype,"canvas",2);ZC([U()],ci.prototype,"alignment",2);ZC([U()],ci.prototype,"verticalOverflow",2);ZC([U()],ci.prototype,"horizontalOverflow",2);ZC([U()],ci.prototype,"lineSpacing",2);ZC([U()],ci.prototype,"supportRichText",2);ZC([U()],ci.prototype,"font",2);ZC([U()],ci.prototype,"fontStyle",2);ZC([U()],ci.prototype,"text",1);ZC([U()],ci.prototype,"fontSize",1);class Hw{constructor(A,g){Q(this,"tag");Q(this,"previousValues");this.tag=A,this.previousValues=g}}var eV=Object.defineProperty,iV=Object.getOwnPropertyDescriptor,Vu=(i,A,g,I)=>{for(var e=I>1?void 0:I?iV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&eV(A,g,e),e};const ln=EA("debuginputfield");var Gr;const kg=(Gr=class extends TA{constructor(){super(...arguments);Q(this,"textComponent");Q(this,"placeholder");Q(this,"onValueChanged");Q(this,"onEndEdit");Q(this,"inputEventFn");Q(this,"_iosEventFn")}get text(){var A;return((A=this.textComponent)==null?void 0:A.text)??""}get isFocused(){return kg.active===this}start(){ln&&console.log(this.name,this)}onEnable(){var A;kg.htmlField||(kg.htmlField=document.createElement("input"),kg.htmlField.style.caretColor="transparent",kg.htmlField.classList.add("ar"),document.body.appendChild(kg.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),kg.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&((A=this.textComponent)!=null&&A.text.length)&&CA.setActive(this.placeholder.gameObject,!1),dD()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("touchend",this._iosEventFn))}onDisable(){var A;(A=kg.htmlField)==null||A.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("touchend",this._iosEventFn)}onPointerClick(A){ln&&console.log("CLICK",A,kg.active),kg.activeTime=this.context.time.time,kg.active!==this&&this.startCoroutine(this.activeLoop(),Ri.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();kg.active===this&&!(this.context.input.getPointerUp(0)&&this.context.time.time-kg.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){var A,g,I,e;if(kg.active!==this&&(ln&&console.log("Select",this.name,this,kg.htmlField,this.context.isInXR,this.context.arOverlayElement,(A=this.textComponent)==null?void 0:A.text,(g=kg.htmlField)==null?void 0:g.value),(I=kg.active)==null||I.onDeselected(),kg.active=this,this.placeholder&&CA.setActive(this.placeholder.gameObject,!1),kg.htmlField)){if(kg.htmlField.value=((e=this.textComponent)==null?void 0:e.text)||"",ln&&console.log("set input field value",kg.htmlField.value),this.context.isInXR){const t=this.context.arOverlayElement;t&&(kg.htmlField.style.width="0px",kg.htmlField.style.height="0px",t.append(kg.htmlField))}this.selectInputField()}}onDeselected(){var A;kg.active===this&&(kg.active=null,ln&&console.log("Deselect",this.name,this),kg.htmlField&&(kg.htmlField.blur(),document.body.append(kg.htmlField),kg.htmlField.style.width="",kg.htmlField.style.height=""),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&CA.setActive(this.placeholder.gameObject,!0),(A=this.onEndEdit)==null||A.invoke())}onInput(A){var g,I;if(kg.active===this){if(ln&&console.log(A.code,A,(g=kg.htmlField)==null?void 0:g.value,(I=this.textComponent)==null?void 0:I.text),A.code==="Escape"||A.code==="Enter"){this.onDeselected();return}kg.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&CA.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){var A;if(this.textComponent&&kg.htmlField){if(this.textComponent.text!==kg.htmlField.value){ln&&console.log("VALUE CHANGED");const g=this.textComponent.text,I=kg.htmlField.value;(A=this.onValueChanged)==null||A.invoke(I,g)}this.textComponent.text=kg.htmlField.value}}selectInputField(){kg.htmlField&&(kg.htmlField.setSelectionRange(kg.htmlField.value.length,kg.htmlField.value.length),kg.htmlField.focus())}processInputOniOS(){const A=this.context.physics.raycast();if(!A.length)return;const I=A[0].object,e=Kq(I);((e==null?void 0:e.gameObject)===this.gameObject||(e==null?void 0:e.gameObject.parent)===this.gameObject)&&this.selectInputField()}},Q(Gr,"active",null),Q(Gr,"activeTime",-1),Q(Gr,"htmlField",null),Gr);let kB=kg;Vu([U(ci)],kB.prototype,"textComponent",2);Vu([U(ci)],kB.prototype,"placeholder",2);Vu([U(ki)],kB.prototype,"onValueChanged",2);Vu([U(ki)],kB.prototype,"onEndEdit",2);var Wq=(i=>(i[i.fr=0]="fr",i[i.ru=1]="ru",i[i.de=2]="de",i[i.es=3]="es",i[i.el=4]="el",i[i.nord=5]="nord",i[i.eng=6]="eng",i))(Wq||{});class vG extends _C{constructor(){super(...arguments);Q(this,"font");Q(this,"text");Q(this,"keymap");Q(this,"padding");Q(this,"margin");Q(this,"fontSize");Q(this,"borderRadius");Q(this,"colors",{keyboardBack:8750469,panelBack:2500134,button:3552822,hovered:1842204,selected:1088605});Q(this,"keyboard",null);Q(this,"_lastKeyPressed");Q(this,"_lastKeyPressedStartTime",0);Q(this,"_lastKeyPressedTime",0)}awake(){super.awake();const g=Wq[this.keymap||6];this.makeKeyboard(g)}onEnable(){this.addShadowComponent(this.keyboard)}onDisable(){this.removeShadowComponent()}makeKeyboard(g){!g&&!navigator.language&&(g="en");const I=this.font?this.font:"arial",e=CA.getComponent(this.gameObject,Yo);if(!e){console.error("Missing rect transform, please add this component inside a canvas");return}const t={...e.getBasicOptions(),margin:this.margin||0,padding:this.padding||0,language:g,fontFamily:rr+"/"+I+"-msdf.json",fontTexture:rr+"/"+I+".png",fontSize:this.fontSize||6,backgroundColor:new wA(this.colors.keyboardBack),backspaceTexture:rr+"/backspace.png",shiftTexture:rr+"/shift.png",enterTexture:rr+"/enter.png",borderRadius:this.borderRadius||0,autoLayout:!1},C=this.gameObject.scale;t.width*=this.gameObject.scale.x,t.height*=this.gameObject.scale.y,t.fontSize*=Math.max(C.x,C.y),this.keyboard=new kq(t),this.gameObject.scale.set(1,1,1),this.keyboard.keys.forEach(o=>{o.setupState({state:"normal",attributes:{offset:.003,backgroundColor:new wA(this.colors.button),backgroundOpacity:1}}),o.setState("normal"),o.setupState({state:"hovered",attributes:{offset:.3,backgroundColor:new wA(this.colors.hovered),backgroundOpacity:1}}),o.setupState({state:"pressed",attributes:{offset:.1,backgroundColor:new wA(this.colors.selected),backgroundOpacity:1},onSet:()=>{var B,r,a;const s=o.info.input,n=o.info.command;if(this._lastKeyPressed!==s)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedTime>.05)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedStartTime<.5||n=="switch"||n=="shift"||n=="switch-set"){this._lastKeyPressedTime=this.context.time.time;return}if(this._lastKeyPressedTime=this.context.time.time,this._lastKeyPressed=s,n)switch(n){case"switch":this.keyboard.setNextPanel();break;case"switch-set":this.keyboard.setNextCharset();break;case"enter":this.tryAppend(`
4459
+ `,E={map:{value:A},height:{value:(g==null?void 0:g.height)||15},radius:{value:(g==null?void 0:g.radius)||100}},c=new BQ(1,16),h=new Og({uniforms:E,fragmentShader:a,vertexShader:r,side:fI});super(c,h)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}};var Xz=Object.defineProperty,$z=Object.getOwnPropertyDescriptor,zu=(i,A,g,I)=>{for(var e=I>1?void 0:I?$z(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&Xz(A,g,e),e};class GB extends TA{constructor(){super(...arguments);Q(this,"applyOnAwake",!1);Q(this,"_scale",20);Q(this,"_radius",100);Q(this,"_height",100);Q(this,"_lastEnvironment");Q(this,"env");Q(this,"_watcher")}set scale(g){var I;this._scale=g,(I=this.env)==null||I.scale.setScalar(g)}get scale(){return this._scale}set radius(g){this._radius=g,this.env&&(this.env.height=g)}get radius(){return this._radius}set height(g){this._height=g,this.env&&(this.env.height=g)}get height(){return this._height}awake(){this.applyOnAwake&&this.updateAndCreate()}onEnable(){this.context.time.frameCount>0&&this.applyOnAwake&&this.updateAndCreate(),this._watcher||(this._watcher=new lE(this.context.scene,"environment"),this._watcher.subscribeWrite(g=>{this.updateProjection()}))}onDisable(){var g,I;(g=this._watcher)==null||g.revoke(),(I=this.env)==null||I.removeFromParent()}updateAndCreate(){var g;this.updateProjection(),(g=this._watcher)==null||g.apply()}updateProjection(){var g;if(!this.context.scene.environment){(g=this.env)==null||g.removeFromParent();return}(!this.env||this.context.scene.environment!==this._lastEnvironment)&&(console.log("Create/Update Ground Projection",this.context.scene.environment.name),this.env=new Vz(this.context.scene.environment)),this._lastEnvironment=this.context.scene.environment,this.env.parent||this.gameObject.add(this.env),this.env.scale.setScalar(this._scale),this.env.radius=this._radius,this.env.height=this._height,this.env.isObject3D===!0&&this.env.layers.set(2)}}zu([U()],GB.prototype,"applyOnAwake",2);zu([U()],GB.prototype,"scale",1);zu([U()],GB.prototype,"radius",1);zu([U()],GB.prototype,"height",1);var AV=Object.defineProperty,gV=Object.getOwnPropertyDescriptor,ZC=(i,A,g,I)=>{for(var e=I>1?void 0:I?gV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&AV(A,g,e),e};const IV=EA("debugtext");class ci extends $s{constructor(){super(...arguments);Q(this,"canvas");Q(this,"alignment",0);Q(this,"verticalOverflow",0);Q(this,"horizontalOverflow",0);Q(this,"lineSpacing",1);Q(this,"supportRichText",!1);Q(this,"font");Q(this,"fontStyle",0);Q(this,"_isWaitingForRebuild",!1);Q(this,"_text","");Q(this,"_fontSize",12);Q(this,"_textMeshUi",null);Q(this,"_textContainer",null);Q(this,"_didHandleTextRenderOnTop",!1)}get text(){return this._text}set text(g){if(this._text=g,!this._textMeshUi&&this._text.length>0&&this.context.time.frame>0&&this.createText(g,this.getTextOpts(),this.supportRichText),this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({content:g}),this.markDirty()}}set_text(g){this.text=g}get fontSize(){return this._fontSize}set fontSize(g){if(this._fontSize=g,this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}this._textMeshUi[0].set({fontSize:g}),this.markDirty()}}onColorChanged(){if(this._textMeshUi){if(this._textMeshUi.length>1){this.requestRebuild();return}const g=this.color;this._textMeshUi[0].set({fontColor:g,fontOpacity:g.alpha}),this.markDirty()}}requestRebuild(){this._isWaitingForRebuild||(this._isWaitingForRebuild=!0,this.startCoroutine(this.rebuildDelayedRoutine(),Ri.EarlyUpdate))}*rebuildDelayedRoutine(){if(this._isWaitingForRebuild=!1,this._textMeshUi){for(const g of this._textMeshUi)g.removeFromParent();this._textMeshUi.length=0}this.createText(this.text,this.getTextOpts(),this.supportRichText),this.markDirty()}onCreate(g){IV&&console.log(this);const I=this.verticalOverflow==0&&this.horizontalOverflow==0;I&&(this.context.renderer.localClippingEnabled=!0);const e=this.rectTransform;this._textContainer=this.uiObject=this.createBlock(e,I,null,!0),this.createText(this.text,this.getTextOpts(),this.supportRichText),this.uiObject,this.uiObject=this.createBlock(e,I,this.uiObject,!1)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let g=this.fontSize;const I={content:this.text,fontColor:this.color,fontOpacity:this.color.alpha,fontSize:g,fontKerning:"normal"};return this.setFont(I,this.fontStyle),I}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&(this.uiObject.onAfterUpdate=()=>{this.updateWidth(),this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}createBlock(g,I,e,t=!1){const C={};C.hiddenOverflow=I,C.interLine=(this.lineSpacing-1)*this.fontSize*1.333,this.getAlignment(C,t);const o=g.createNewBlock(C),s=o.backgroundMaterial;return s&&(s.depthWrite=!1),e&&(Array.isArray(e)?o.add(...e):o.add(e)),o}getAlignment(g,I=!1){if(!I)switch(g.contentDirection="row",this.alignment){case 0:case 3:case 6:g.textAlign="left";break;case 1:case 4:case 7:g.textAlign="center";break;case 2:case 5:case 8:g.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:g.justifyContent="start";break;case 3:case 4:case 5:g.justifyContent="center";break;case 6:case 7:case 8:g.justifyContent="end";break}switch(this.alignment){case 0:case 3:case 6:g.alignItems="start";break;case 1:case 4:case 7:g.alignItems="center";break;case 2:case 5:case 8:g.alignItems="end";break}return g}updateWidth(){this.horizontalOverflow===1&&setTimeout(()=>{if(!this._textMeshUi)return;const g=this._textMeshUi[0].parent;if(g&&g.lines){let I=g.lines.reduce((e,t)=>e+t.width,0);I+=g.getFontSize()*5,I+=g.padding*2||0,I+=this.fontSize*1.5,g.set({width:I}),this.ensureShadowComponentOwner()}},1)}ensureShadowComponentOwner(){this.shadowComponent&&this.shadowComponent.traverse(g=>{g[Pt]===void 0&&(g[Pt]=this)})}createText(g,I,e){if(!(!g||g.length<=0))if(this._textMeshUi||(this._textMeshUi=[]),e){let t=this.getNextTag(g);if(t)t.startIndex>0&&this.createText(g.substring(0,t.startIndex),I,!1);else return this.createText(g,I,!1);const C=[];for(;t;){const o=this.getNextTag(g,t.endIndex);if(o){const s=this.getText(g,t,o);this.handleTag(t,I,C),this.createText(s,I,!1)}else{const s=g.substring(t.endIndex);this.handleTag(t,I,C),this.createText(s,I,!1)}t=o}}else{const t={...I};t.content=g;const C=new Mq(t);this._textMeshUi.push(C),this._textContainer&&this._textContainer.add(C)}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const g=[],I=this.canvas,e={renderOnTop:I.renderOnTop,depthWrite:I.depthWrite,doubleSided:I.doubleSided};for(;;){let t=!1;if(this._textMeshUi)for(let C=0;C<this._textMeshUi.length;C++){if(g[C]===!0)continue;t=!0;const o=this._textMeshUi[C];o.textContent&&(tD(o,e),g[C]=!0)}if(!t)break;yield}}handleTag(g,I,e){if(g.isEndTag){if(e.length>0){const t=e.pop();if(t)for(const C in t.previousValues){const o=t.previousValues[C];I[C]=o}}}else if(g.type.includes("color")){const t=new Hw(g,{fontColor:I.fontColor});if(e.push(t),g.type.length>6){const C=g.type.substring(6);I.fontColor=new wA(C)}else I.fontColor=new wA(1,1,1)}else if(g.type=="b"){const t=new Hw(g,{fontFamily:I.fontFamily,fontTexture:I.fontTexture});e.push(t),this.setFont(I,1)}else if(g.type=="i"){const t=new Hw(g,{fontFamily:I.fontFamily,fontTexture:I.fontTexture});e.push(t),this.setFont(I,2)}}getText(g,I,e){return g.substring(I.endIndex,e.startIndex)}getNextTag(g,I=0){const e=g.indexOf("<",I),t=g.indexOf(">",e);if(e>=0&&t>=0){const C=g.substring(e+1,t);return{type:C,startIndex:e,endIndex:t+1,isEndTag:C.startsWith("/")}}return null}setFont(g,I){const e=this.getFontStyleName(I);let t=e;t!=null&&t.endsWith("-msdf.json")||(t+="-msdf.json"),g.fontFamily=t;let C=e;C!=null&&C.endsWith(".png")||(C+=".png"),g.fontTexture=C}getFontStyleName(g){if(!this.font)return null;let I=this.font;const e=I.toLowerCase();if(e.endsWith("-regular")){if(g===0)return lt(this.sourceId,I);I=I.substring(0,I.length-8)}else if(e.endsWith("-bold")){if(g===1)return lt(this.sourceId,I);I=I.substring(0,I.length-5)}else if(e.endsWith("-italic")){if(g===2)return lt(this.sourceId,I);I=I.substring(0,I.length-7)}else if(e.endsWith("-bolditalic")){if(g===3)return lt(this.sourceId,I);I=I.substring(0,I.length-11)}else return lt(this.sourceId,I);switch(g){case 0:I+="-regular";break;case 1:I+="-bold";break;case 2:I+="-italic";break;case 3:I+="-bolditalic";break}return lt(this.sourceId,I)}}ZC([U(gt)],ci.prototype,"canvas",2);ZC([U()],ci.prototype,"alignment",2);ZC([U()],ci.prototype,"verticalOverflow",2);ZC([U()],ci.prototype,"horizontalOverflow",2);ZC([U()],ci.prototype,"lineSpacing",2);ZC([U()],ci.prototype,"supportRichText",2);ZC([U()],ci.prototype,"font",2);ZC([U()],ci.prototype,"fontStyle",2);ZC([U()],ci.prototype,"text",1);ZC([U()],ci.prototype,"fontSize",1);class Hw{constructor(A,g){Q(this,"tag");Q(this,"previousValues");this.tag=A,this.previousValues=g}}var eV=Object.defineProperty,iV=Object.getOwnPropertyDescriptor,Vu=(i,A,g,I)=>{for(var e=I>1?void 0:I?iV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&eV(A,g,e),e};const ln=EA("debuginputfield");var Gr;const kg=(Gr=class extends TA{constructor(){super(...arguments);Q(this,"textComponent");Q(this,"placeholder");Q(this,"onValueChanged");Q(this,"onEndEdit");Q(this,"inputEventFn");Q(this,"_iosEventFn")}get text(){var A;return((A=this.textComponent)==null?void 0:A.text)??""}get isFocused(){return kg.active===this}start(){ln&&console.log(this.name,this)}onEnable(){var A;kg.htmlField||(kg.htmlField=document.createElement("input"),kg.htmlField.style.caretColor="transparent",kg.htmlField.classList.add("ar"),document.body.appendChild(kg.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),kg.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&((A=this.textComponent)!=null&&A.text.length)&&CA.setActive(this.placeholder.gameObject,!1),dD()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("touchend",this._iosEventFn))}onDisable(){var A;(A=kg.htmlField)==null||A.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("touchend",this._iosEventFn)}onPointerClick(A){ln&&console.log("CLICK",A,kg.active),kg.activeTime=this.context.time.time,kg.active!==this&&this.startCoroutine(this.activeLoop(),Ri.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();kg.active===this&&!(this.context.input.getPointerUp(0)&&this.context.time.time-kg.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){var A,g,I,e;if(kg.active!==this&&(ln&&console.log("Select",this.name,this,kg.htmlField,this.context.isInXR,this.context.arOverlayElement,(A=this.textComponent)==null?void 0:A.text,(g=kg.htmlField)==null?void 0:g.value),(I=kg.active)==null||I.onDeselected(),kg.active=this,this.placeholder&&CA.setActive(this.placeholder.gameObject,!1),kg.htmlField)){if(kg.htmlField.value=((e=this.textComponent)==null?void 0:e.text)||"",ln&&console.log("set input field value",kg.htmlField.value),this.context.isInXR){const t=this.context.arOverlayElement;t&&(kg.htmlField.style.width="0px",kg.htmlField.style.height="0px",t.append(kg.htmlField))}this.selectInputField()}}onDeselected(){var A;kg.active===this&&(kg.active=null,ln&&console.log("Deselect",this.name,this),kg.htmlField&&(kg.htmlField.blur(),document.body.append(kg.htmlField),kg.htmlField.style.width="",kg.htmlField.style.height=""),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&CA.setActive(this.placeholder.gameObject,!0),(A=this.onEndEdit)==null||A.invoke())}onInput(A){var g,I;if(kg.active===this){if(ln&&console.log(A.code,A,(g=kg.htmlField)==null?void 0:g.value,(I=this.textComponent)==null?void 0:I.text),A.code==="Escape"||A.code==="Enter"){this.onDeselected();return}kg.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&CA.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){var A;if(this.textComponent&&kg.htmlField){if(this.textComponent.text!==kg.htmlField.value){ln&&console.log("VALUE CHANGED");const g=this.textComponent.text,I=kg.htmlField.value;(A=this.onValueChanged)==null||A.invoke(I,g)}this.textComponent.text=kg.htmlField.value}}selectInputField(){kg.htmlField&&(kg.htmlField.setSelectionRange(kg.htmlField.value.length,kg.htmlField.value.length),kg.htmlField.focus())}processInputOniOS(){const A=this.context.physics.raycast();if(!A.length)return;const I=A[0].object,e=Kq(I);((e==null?void 0:e.gameObject)===this.gameObject||(e==null?void 0:e.gameObject.parent)===this.gameObject)&&this.selectInputField()}},Q(Gr,"active",null),Q(Gr,"activeTime",-1),Q(Gr,"htmlField",null),Gr);let kB=kg;Vu([U(ci)],kB.prototype,"textComponent",2);Vu([U(ci)],kB.prototype,"placeholder",2);Vu([U(ki)],kB.prototype,"onValueChanged",2);Vu([U(ki)],kB.prototype,"onEndEdit",2);var Wq=(i=>(i[i.fr=0]="fr",i[i.ru=1]="ru",i[i.de=2]="de",i[i.es=3]="es",i[i.el=4]="el",i[i.nord=5]="nord",i[i.eng=6]="eng",i))(Wq||{});class vG extends _C{constructor(){super(...arguments);Q(this,"font");Q(this,"text");Q(this,"keymap");Q(this,"padding");Q(this,"margin");Q(this,"fontSize");Q(this,"borderRadius");Q(this,"colors",{keyboardBack:8750469,panelBack:2500134,button:3552822,hovered:1842204,selected:1088605});Q(this,"keyboard",null);Q(this,"_lastKeyPressed");Q(this,"_lastKeyPressedStartTime",0);Q(this,"_lastKeyPressedTime",0)}awake(){super.awake();const g=Wq[this.keymap||6];this.makeKeyboard(g)}onEnable(){this.addShadowComponent(this.keyboard)}onDisable(){this.removeShadowComponent()}makeKeyboard(g){!g&&!navigator.language&&(g="en");const I=this.font?this.font:"arial",e=CA.getComponent(this.gameObject,Yo);if(!e){console.error("Missing rect transform, please add this component inside a canvas");return}const t={...e.getBasicOptions(),margin:this.margin||0,padding:this.padding||0,language:g,fontFamily:rr+"/"+I+"-msdf.json",fontTexture:rr+"/"+I+".png",fontSize:this.fontSize||6,backgroundColor:new wA(this.colors.keyboardBack),backspaceTexture:rr+"/backspace.png",shiftTexture:rr+"/shift.png",enterTexture:rr+"/enter.png",borderRadius:this.borderRadius||0,autoLayout:!1},C=this.gameObject.scale;t.width*=this.gameObject.scale.x,t.height*=this.gameObject.scale.y,t.fontSize*=Math.max(C.x,C.y),this.keyboard=new kq(t),this.gameObject.scale.set(1,1,1),this.keyboard.keys.forEach(o=>{o.setupState({state:"normal",attributes:{offset:.003,backgroundColor:new wA(this.colors.button),backgroundOpacity:1}}),o.setState("normal"),o.setupState({state:"hovered",attributes:{offset:.3,backgroundColor:new wA(this.colors.hovered),backgroundOpacity:1}}),o.setupState({state:"pressed",attributes:{offset:.1,backgroundColor:new wA(this.colors.selected),backgroundOpacity:1},onSet:()=>{var B,r,a;const s=o.info.input,n=o.info.command;if(this._lastKeyPressed!==s)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedTime>.05)this._lastKeyPressedStartTime=this.context.time.time;else if(this.context.time.time-this._lastKeyPressedStartTime<.5||n=="switch"||n=="shift"||n=="switch-set"){this._lastKeyPressedTime=this.context.time.time;return}if(this._lastKeyPressedTime=this.context.time.time,this._lastKeyPressed=s,n)switch(n){case"switch":this.keyboard.setNextPanel();break;case"switch-set":this.keyboard.setNextCharset();break;case"enter":this.tryAppend(`
4460
4460
  `);break;case"space":this.tryAppend(" ");break;case"backspace":if(!((r=(B=this.text)==null?void 0:B.text)!=null&&r.length))break;(a=this.text)!=null&&a.text&&(this.text.text=this.text.text.substring(0,this.text.text.length-1)||"");break;case"shift":this.keyboard.toggleCase();break}else o.info.input!==void 0&&this.tryAppend(o.info.input)}})})}tryAppend(g){this.text&&(this.text.text+=g,this.markDirty())}}var tV=Object.defineProperty,CV=Object.getOwnPropertyDescriptor,zC=(i,A,g,I)=>{for(var e=I>1?void 0:I?CV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&tV(A,g,e),e};function Tw(i){return i*Math.PI/180}const dR=300,ta=EA("debuglights");class Ki extends TA{constructor(){super(...arguments);Q(this,"type",0);Q(this,"range",1);Q(this,"spotAngle",1);Q(this,"innerSpotAngle",1);Q(this,"_color",new wA(16777215));Q(this,"_shadowNearPlane",.1);Q(this,"_shadowBias",0);Q(this,"_shadowNormalBias",0);Q(this,"_overrideShadowBiasSettings",!1);Q(this,"_shadows",1);Q(this,"lightmapBakeType",4);Q(this,"_intensity",-1);Q(this,"_shadowDistance");Q(this,"shadowWidth");Q(this,"shadowHeight");Q(this,"_shadowResolution");Q(this,"light");Q(this,"_webXRStartedListener");Q(this,"_webXREndedListener");Q(this,"_webARRoot")}set color(g){this._color=g,this.light!==void 0&&(this.light.color=g)}get color(){return this.light?this.light.color:this._color}set shadowNearPlane(g){var I,e;if(g!==this._shadowNearPlane&&(this._shadowNearPlane=g,((e=(I=this.light)==null?void 0:I.shadow)==null?void 0:e.camera)!==void 0)){const t=this.light.shadow.camera;t.near=g}}get shadowNearPlane(){return this._shadowNearPlane}set shadowBias(g){var I,e;g!==this._shadowBias&&(this._shadowBias=g,((e=(I=this.light)==null?void 0:I.shadow)==null?void 0:e.bias)!==void 0&&(this.light.shadow.bias=g,this.light.shadow.needsUpdate=!0))}get shadowBias(){return this._shadowBias}set shadowNormalBias(g){var I,e;g!==this._shadowNormalBias&&(this._shadowNormalBias=g,((e=(I=this.light)==null?void 0:I.shadow)==null?void 0:e.normalBias)!==void 0&&(this.light.shadow.normalBias=g,this.light.shadow.needsUpdate=!0))}get shadowNormalBias(){return this._shadowNormalBias}set shadows(g){this._shadows=g,this.light&&(this.light.castShadow=g!==0,this.updateShadowSoftHard())}get shadows(){return this._shadows}set intensity(g){var I;if(this._intensity=g,this.light){let e=1;if(this.context.isInXR&&this._webARRoot){const t=(I=this._webARRoot)==null?void 0:I.arScale;typeof t=="number"&&t>0&&(e/=t)}this.light.intensity=g*e}}get intensity(){return this._intensity}get shadowDistance(){const g=this.light;return g?g.shadow.camera.far:-1}set shadowDistance(g){this._shadowDistance=g;const I=this.light;if(I){const e=I.shadow.camera;e.far=g,e.updateProjectionMatrix()}}get shadowResolution(){const g=this.light;return g?g.shadow.mapSize.x:-1}set shadowResolution(g){if(g===this._shadowResolution)return;this._shadowResolution=g;const I=this.light;I&&(I.shadow.mapSize.set(g,g),I.shadow.needsUpdate=!0)}get isBaked(){return this.lightmapBakeType===2}get selfIsLight(){if(this.gameObject.isLight===!0)return!0;switch(this.gameObject.type){case"SpotLight":case"PointLight":case"DirectionalLight":return!0}return!1}getWorldPosition(g){return this.light?this.type===1?this.light.getWorldPosition(g).multiplyScalar(1):this.light.getWorldPosition(g):g}awake(){this.color=new wA(this.color??16777215),ta&&console.log(this.name,this)}onEnable(){ta&&console.log("ENABLE LIGHT",this.name),this.createLight(),!this.isBaked&&(this.light&&(this.light.visible=!0,this.light.intensity=this._intensity,this.selfIsLight||this.light.parent!==this.gameObject&&this.gameObject.add(this.light)),this.type===1&&this.startCoroutine(this.updateMainLightRoutine(),Ri.LateUpdate),this._webXRStartedListener=Ng.addEventListener(be.XRStarted,this.onWebXRStarted.bind(this)),this._webXREndedListener=Ng.addEventListener(be.XRStopped,this.onWebXREnded.bind(this)))}onDisable(){ta&&console.log("DISABLE LIGHT",this.name),this.light&&(this.selfIsLight?this.light.intensity=0:this.light.visible=!1),Ng.removeEventListener(be.XRStarted,this._webXRStartedListener),Ng.removeEventListener(be.XRStopped,this._webXREndedListener)}onWebXRStarted(){this._webARRoot=CA.getComponentInParent(this.gameObject,Vs)??void 0}onWebXREnded(){}createLight(){const g=this.selfIsLight;if(g&&!this.light)switch(this.light=this.gameObject,this.light.name=this.name,this._intensity=this.light.intensity,this.type){case 1:this.setDirectionalLight(this.light);break}else if(!this.light)switch(this.type){case 1:const I=new xD(this.color,this.intensity*Math.PI);if(I.position.set(0,0,-dR*.5).applyQuaternion(this.gameObject.quaternion),this.gameObject.add(I.target),UE(I.target,0,0,0),this.light=I,this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),ta){const o=new XF(this.light,.2,this.color);this.context.scene.add(o)}break;case 0:const e=new bD(this.color,this.intensity*Math.PI,this.range,Tw(this.spotAngle/2),1-Tw(this.innerSpotAngle/2)/Tw(this.spotAngle/2),2);e.position.set(0,0,0),e.rotation.set(0,0,0),this.light=e;const t=e.target;e.add(t),t.position.set(0,0,this.range),t.rotation.set(0,0,0);break;case 2:const C=new vD(this.color,this.intensity*Math.PI,this.range);this.light=C;break}if(this.light){this._intensity>=0?this.light.intensity=this._intensity:this._intensity=this.light.intensity,this.shadows!==0?this.light.castShadow=!0:this.light.castShadow=!1,this._shadowResolution!==void 0&&this._shadowResolution>4?(this.light.shadow.mapSize.width=this._shadowResolution,this.light.shadow.mapSize.height=this._shadowResolution):(this.light.shadow.mapSize.width=2048,this.light.shadow.mapSize.height=2048),ta&&console.log("Override shadow bias?",this._overrideShadowBiasSettings,this.shadowBias,this.shadowNormalBias),this.light.shadow.bias=this.shadowBias,this.light.shadow.normalBias=this.shadowNormalBias,this.updateShadowSoftHard();const I=this.light.shadow.camera;if(I.near=this.shadowNearPlane,this._shadowDistance!==void 0&&typeof this._shadowDistance=="number"?I.far=this._shadowDistance:I.far=dR*Math.abs(this.gameObject.scale.z),this.gameObject.scale.set(1,1,1),this.shadowWidth!==void 0)I.left=-this.shadowWidth/2,I.right=this.shadowWidth/2;else{const e=this.gameObject.scale.x;I.left*=e,I.right*=e}if(this.shadowHeight!==void 0)I.top=this.shadowHeight/2,I.bottom=-this.shadowHeight/2;else{const e=this.gameObject.scale.y;I.top*=e,I.bottom*=e}this.light.shadow.needsUpdate=!0,ta&&this.context.scene.add(new $F(I)),this.isBaked?this.light.removeFromParent():g||this.gameObject.add(this.light)}}*updateMainLightRoutine(){for(;;){this.type===1&&((!this.context.mainLight||this.intensity>this.context.mainLight.intensity)&&(this.context.mainLight=this),yield);break}}updateShadowSoftHard(){this.light&&(this.shadows===2||(this.light.shadow.radius=1,this.light.shadow.blurSamples=1))}setDirectionalLight(g){g.add(g.target),g.target.position.set(0,0,-1)}}Q(Ki,"allowChangingRendererShadowMapType",!0);zC([U()],Ki.prototype,"type",2);zC([U(wA)],Ki.prototype,"color",1);zC([U()],Ki.prototype,"shadowNearPlane",1);zC([U()],Ki.prototype,"shadowBias",1);zC([U()],Ki.prototype,"shadowNormalBias",1);zC([U()],Ki.prototype,"shadows",1);zC([U()],Ki.prototype,"lightmapBakeType",2);zC([U()],Ki.prototype,"intensity",1);zC([U()],Ki.prototype,"shadowDistance",1);zC([U()],Ki.prototype,"shadowResolution",1);new M(0,0,0);var oV=Object.defineProperty,sV=Object.getOwnPropertyDescriptor,Ih=(i,A,g,I)=>{for(var e=I>1?void 0:I?sV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&oV(A,g,e),e};const ca=EA("debugLODs"),nV=EA("noLODs");class MB{constructor(){Q(this,"screenRelativeTransitionHeight");Q(this,"distance");Q(this,"renderers")}}Ih([U()],MB.prototype,"screenRelativeTransitionHeight",2);Ih([U()],MB.prototype,"distance",2);Ih([U()],MB.prototype,"renderers",2);class BV{constructor(A,g){Q(this,"model");Q(this,"renderers");this.model=g,this.renderers=[];for(const I of g.renderers){const e=this.findRenderer(I,A.gameObject);e&&e.gameObject?this.renderers.push(e):ca&&console.warn("Renderer not found: "+I,A.gameObject)}}findRenderer(A,g){const I=CA.foreachComponent(g,e=>{var C;return e.guid===A||((C=Object.getPrototypeOf(e))==null?void 0:C.guid)===A?e:null});if(I)return I;for(const e of g.children){const t=this.findRenderer(A,e);if(t)return t}return null}}class eh extends TA{constructor(){super(...arguments);Q(this,"fadeMode",0);Q(this,"localReferencePoint");Q(this,"lodCount",0);Q(this,"size",0);Q(this,"animateCrossFading",!1);Q(this,"lodModels");Q(this,"_lods",[]);Q(this,"_settings",[]);Q(this,"_lodsHandler");Q(this,"_distanceFactor",1)}start(){if(!nV&&!this._lodsHandler&&this.gameObject&&(ca&&console.log(this),this.lodModels&&Array.isArray(this.lodModels))){let g=0,I=[];for(const t of this.lodModels){g=Math.max(t.distance,g);const C=new BV(this,t);this._lods.push(C);for(const o of C.renderers)I.includes(o)||I.push(o)}this._lodsHandler=new Array;for(let t=0;t<I.length;t++){const C=new uS;this._lodsHandler.push(C),this.gameObject.add(C)}const e=new LA;e.name="Cull "+this.name,ca&&console.log(I);for(let t=0;t<I.length;t++){const C=I[t],o=this._lodsHandler[t],s=C.gameObject;let n=0,B=0;ca&&console.log(t,s.name);for(const a of this._lods){let E=null;a.renderers.includes(C)?E=s:E=e,ca&&console.log("add",a.model.distance,E.name);const c=a.model.distance;if(B=c-n,n=Math.max(c,n),E.type==="Group"){console.warn("LODGroup: Group is not supported as LOD object",s.name,E);continue}this.onAddLodLevel(o,E,c)}const r=n+B;ca&&console.log("cull",r),this.onAddLodLevel(o,e,r)}}}update(){if(!this.gameObject||!this._lodsHandler)return;const g=this.context.mainCamera;if(g)for(const I of this._lodsHandler)I.update(g)}onAddLodLevel(g,I,e){if(I===this.gameObject){console.warn("LODGroup component must be on parent object and not mesh directly at the moment",I.name,I);return}g.addLevel(I,e*this._distanceFactor);const t={lod:g,levelIndex:g.levels.length-1,distance:e};this._settings.push(t)}distanceFactor(g){if(g!==this._distanceFactor){this._distanceFactor=g;for(const I of this._settings){const e=I.lod.levels[I.levelIndex];e.distance=I.distance*g}}}}Ih([U(M)],eh.prototype,"localReferencePoint",2);Ih([U(MB)],eh.prototype,"lodModels",2);const aV=EA("logstats");class xG extends TA{onEnable(){console.log(this),aV&&this.startCoroutine(this.run(),Ri.OnAfterRender)}*run(){for(;this.enabled;){const A=this.context.renderer.info;console.log(A.memory,A.render,A.programs),yield}}}var QV=Object.defineProperty,rV=Object.getOwnPropertyDescriptor,EV=(i,A,g,I)=>{for(var e=I>1?void 0:I?rV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&QV(A,g,e),e};const Ow=EA("debugnestedgltf");class Xu extends TA{constructor(){super(...arguments);Q(this,"filePath");Q(this,"_isLoadingOrDoneLoading",!1)}listenToProgress(g){var I;(I=this.filePath)==null||I.beginListenDownload(g)}preload(){var g;(g=this.filePath)==null||g.preload()}async start(){var I,e,t,C;if(this._isLoadingOrDoneLoading)return;Ow&&console.log(this,this.guid);const g=this.gameObject.parent;if(g){this._isLoadingOrDoneLoading=!0;const o=new qC;o.idProvider=new yi(this.hash(this.guid)),o.parent=g,this.gameObject.updateMatrix();const s=this.gameObject.matrix;Ow&&console.log("Load nested:",((I=this.filePath)==null?void 0:I.uri)??this.filePath,this.gameObject.position);const n=await((t=(e=this.filePath)==null?void 0:e.instantiate)==null?void 0:t.call(this.filePath,o));n&&(n.matrixAutoUpdate=!1,n.matrix.identity(),n.applyMatrix4(s),n.matrixAutoUpdate=!0,n.layers.disableAll(),n.layers.set(this.layer)),this.destroy(),Ow&&console.log("Nested loading done:",((C=this.filePath)==null?void 0:C.uri)??this.filePath,n)}}hash(g){let I=0;for(let e=0;e<g.length;e++)I=g.charCodeAt(e)+((I<<5)-I);return I}}EV([U(Vt)],Xu.prototype,"filePath",2);var cV=Object.defineProperty,hV=Object.getOwnPropertyDescriptor,$u=(i,A,g,I)=>{for(var e=I>1?void 0:I?hV(A,g):A,t=i.length-1,C;t>=0;t--)(C=i[t])&&(e=(I?C(A,g,e):C(e))||e);return I&&e&&cV(A,g,e),e};class UB extends TA{constructor(){super(...arguments);Q(this,"referenceSpace");Q(this,"from");Q(this,"affectPosition",!1);Q(this,"affectRotation",!1);Q(this,"alignLookDirection",!1);Q(this,"levelLookDirection",!1);Q(this,"levelPosition",!1);Q(this,"positionOffset",new M(0,0,0));Q(this,"rotationOffset",new M(0,0,0));Q(this,"offset",new M(0,0,0))}update(){if(!this.from)return;var g=Sg(this.from),I=zi(this.from);this.offset.copy(this.positionOffset);const e=this.offset.length();if(this.referenceSpace&&this.offset.transformDirection(this.referenceSpace.matrixWorld).multiplyScalar(e),g.add(this.offset),this.levelPosition&&this.referenceSpace){const s=new dt(this.gameObject.up,0),n=Sg(this.referenceSpace);s.setFromNormalAndCoplanarPoint(this.gameObject.up,n);const B=new M(0,0,0);s.projectPoint(g,B),g.copy(B)}this.affectPosition&&ve(this.gameObject,g);const t=new te(this.rotationOffset.x,this.rotationOffset.y,this.rotationOffset.z),C=new UA().setFromEuler(t);this.affectRotation&&JC(this.gameObject,I.multiply(C));let o=new M;this.from.getWorldDirection(o).multiplyScalar(50),this.levelLookDirection&&(o.y=0),this.alignLookDirection&&this.gameObject.lookAt(o)}}$u([U(CA)],UB.prototype,"referenceSpace",2);$u([U(CA)],UB.prototype,"from",2);$u([U(M)],UB.prototype,"positionOffset",2);$u([U(M)],UB.prototype,"rotationOffset",2);function xg(i,A){if(!(i instanceof A))throw new TypeError("Cannot call a class as a function")}function DR(i,A){for(var g=0;g<A.length;g++){var I=A[g];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(i,I.key,I)}}function Yg(i,A,g){return A&&DR(i.prototype,A),g&&DR(i,g),Object.defineProperty(i,"prototype",{writable:!1}),i}function nA(i,A,g){return A in i?Object.defineProperty(i,A,{value:g,enumerable:!0,configurable:!0,writable:!0}):i[A]=g,i}function TQ(i,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(A&&A.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),A&&vy(i,A)}function CD(i){return CD=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)},CD(i)}function vy(i,A){return vy=Object.setPrototypeOf||function(I,e){return I.__proto__=e,I},vy(i,A)}function lV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function jg(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function dV(i,A){if(A&&(typeof A=="object"||typeof A=="function"))return A;if(A!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jg(i)}function OQ(i){var A=lV();return function(){var I=CD(i),e;if(A){var t=CD(this).constructor;e=Reflect.construct(I,arguments,t)}else e=I.apply(this,arguments);return dV(this,e)}}function uR(i,A){return DV(i)||uV(i,A)||jq(i,A)||pV()}function DV(i){if(Array.isArray(i))return i}function uV(i,A){var g=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(g!=null){var I=[],e=!0,t=!1,C,o;try{for(g=g.call(i);!(e=(C=g.next()).done)&&(I.push(C.value),!(A&&I.length===A));e=!0);}catch(s){t=!0,o=s}finally{try{!e&&g.return!=null&&g.return()}finally{if(t)throw o}}return I}}function jq(i,A){if(i){if(typeof i=="string")return pR(i,A);var g=Object.prototype.toString.call(i).slice(8,-1);if(g==="Object"&&i.constructor&&(g=i.constructor.name),g==="Map"||g==="Set")return Array.from(i);if(g==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g))return pR(i,A)}}function pR(i,A){(A==null||A>i.length)&&(A=i.length);for(var g=0,I=new Array(A);g<A;g++)I[g]=i[g];return I}function pV(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4461
4461
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wR(i,A){var g=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!g){if(Array.isArray(i)||(g=jq(i))||A&&i&&typeof i.length=="number"){g&&(i=g);var I=0,e=function(){};return{s:e,n:function(){return I>=i.length?{done:!0}:{done:!1,value:i[I++]}},e:function(s){throw s},f:e}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4462
4462
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,C=!1,o;return{s:function(){g=g.call(i)},n:function(){var s=g.next();return t=s.done,s},e:function(s){C=!0,o=s},f:function(){try{!t&&g.return!=null&&g.return()}finally{if(C)throw o}}}}var wV=function(i){TQ(g,i);var A=OQ(g);function g(I){var e;return xg(this,g),e=A.call(this),nA(jg(e),"type","ParticleEmitter"),nA(jg(e),"system",void 0),e.system=I,e}return Yg(g,[{key:"clone",value:function(){var e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}},{key:"dispose",value:function(){}},{key:"extractFromCache",value:function(e){var t=[];for(var C in e){var o=e[C];delete o.metadata,t.push(o)}return t}},{key:"toJSON",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=e===void 0||typeof e=="string",o={};C&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},o.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var s={};if(s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),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),JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.system!==null&&(s.ps=this.system.toJSON(e,t)),this.children.length>0){s.children=[];for(var n=0;n<this.children.length;n++)this.children[n].type!=="ParticleSystemPreview"&&s.children.push(this.children[n].toJSON(e).object)}if(C){var B=this.extractFromCache(e.geometries),r=this.extractFromCache(e.materials),a=this.extractFromCache(e.textures),E=this.extractFromCache(e.images);B.length>0&&(o.geometries=B),r.length>0&&(o.materials=r),a.length>0&&(o.textures=a),E.length>0&&(o.images=E)}return o.object=s,o}}]),g}(LA),VE=function(){function i(){xg(this,i),nA(this,"parentMatrix",void 0),nA(this,"startSpeed",0),nA(this,"startColor",new sg),nA(this,"startSize",1),nA(this,"position",new M),nA(this,"velocity",new M),nA(this,"age",0),nA(this,"life",1),nA(this,"size",1),nA(this,"angularVelocity",void 0),nA(this,"rotation",0),nA(this,"color",new sg),nA(this,"uvTile",0)}return Yg(i,[{key:"died",get:function(){return this.age>=this.life}}]),i}(),fV=Yg(function i(A,g,I){xg(this,i),this.position=A,this.size=g,this.color=I}),oD=function(){function i(){xg(this,i),nA(this,"parentMatrix",void 0),nA(this,"startSpeed",0),nA(this,"startColor",new sg),nA(this,"startSize",1),nA(this,"position",new M),nA(this,"localPosition",void 0),nA(this,"velocity",new M),nA(this,"age",0),nA(this,"life",1),nA(this,"size",1),nA(this,"length",100),nA(this,"color",new sg),nA(this,"previous",[]),nA(this,"uvTile",0)}return Yg(i,[{key:"recordCurrentState",value:function(){for(this.previous.push(new fV(this.position.clone(),this.size,this.color.clone()));this.previous.length>this.length;)this.previous.shift()}},{key:"died",get:function(){return this.age>=this.life}},{key:"reset",value:function(){this.previous.length=0}}]),i}(),ni=function(){function i(A){xg(this,i),this.value=A,nA(this,"type",void 0),this.type="value"}return Yg(i,[{key:"genValue",value:function(){return this.value}},{key:"toJSON",value:function(){return{type:"ConstantValue",value:this.value}}},{key:"clone",value:function(){return new i(this.value)}}],[{key:"fromJSON",value:function(g){return new i(g.value)}}]),i}(),yV=function(){function i(A,g){xg(this,i),this.a=A,this.b=g,nA(this,"type",void 0),this.type="value"}return Yg(i,[{key:"genValue",value:function(){return Ui.lerp(this.a,this.b,Math.random())}},{key:"toJSON",value:function(){return{type:"IntervalValue",a:this.a,b:this.b}}},{key:"clone",value:function(){return new i(this.a,this.b)}}],[{key:"fromJSON",value:function(g){return new i(g.a,g.b)}}]),i}(),SV=function(){function i(){xg(this,i),nA(this,"functions",void 0),this.functions=new Array}return Yg(i,[{key:"findFunction",value:function(g){for(var I=0,e=0,t=this.functions.length-1;e+1<t;)if(I=Math.floor((e+t)/2),g<this.getStartX(I))t=I-1;else if(g>this.getEndX(I))e=I+1;else return I;for(var C=e;C<=t;C++)if(g>=this.functions[C][1]&&g<=this.getEndX(C))return C;return-1}},{key:"getStartX",value:function(g){return this.functions[g][1]}},{key:"setStartX",value:function(g,I){g>0&&(this.functions[g][1]=I)}},{key:"getEndX",value:function(g){return g+1<this.functions.length?this.functions[g+1][1]:1}},{key:"setEndX",value:function(g,I){g+1<this.functions.length&&(this.functions[g+1][1]=I)}},{key:"insertFunction",value:function(g,I){var e=this.findFunction(g);this.functions.splice(e+1,0,[I,g])}},{key:"removeFunction",value:function(g){return this.functions.splice(g,1)[0][0]}},{key:"getFunction",value:function(g){return this.functions[g][0]}},{key:"setFunction",value:function(g,I){this.functions[g][0]=I}},{key:"numOfFunctions",get:function(){return this.functions.length}}]),i}(),fR=function(){function i(A,g,I,e){xg(this,i),nA(this,"p",void 0),this.p=[A,g,I,e]}return Yg(i,[{key:"genValue",value:function(g){var I=g*g,e=g*g*g,t=1-g,C=t*t,o=C*t;return this.p[0]*o+this.p[1]*C*g*3+this.p[2]*t*I*3+this.p[3]*e}},{key:"derivativeCoefficients",value:function(g){for(var I=[],e=g,t=e.length-1;t>0;t--){for(var C=[],o=0;o<t;o++){var s=t*(e[o+1]-e[o]);C.push(s)}I.push(C),e=C}return I}},{key:"getSlope",value:function(g){var I=this.derivativeCoefficients(this.p)[0],e=1-g,t=e*e,C=e*g*2,o=g*g;return t*I[0]+C*I[1]+o*I[2]}},{key:"controlCurve",value:function(g,I){this.p[1]=g/3+this.p[0],this.p[2]=this.p[3]-I/3}},{key:"hull",value:function(g){var I=this.p,e=[],t,C=[],o=0,s=0,n=0;for(C[o++]=I[0],C[o++]=I[1],C[o++]=I[2],C[o++]=I[3];I.length>1;){for(e=[],s=0,n=I.length-1;s<n;s++)t=g*I[s]+(1-g)*I[s+1],C[o++]=t,e.push(t);I=e}return C}},{key:"split",value:function(g){var I=this.hull(g),e={left:new i(I[0],I[4],I[7],I[9]),right:new i(I[9],I[8],I[6],I[3]),span:I};return e}},{key:"clone",value:function(){return new i(this.p[0],this.p[1],this.p[2],this.p[3])}},{key:"toJSON",value:function(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}}],[{key:"fromJSON",value:function(g){return new i(g.p0,g.p1,g.p2,g.p3)}}]),i}(),GV=function(i){TQ(g,i);var A=OQ(g);function g(){var I,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[[new fR(0,.3333333333333333,.6666666666666666,1),0]];return xg(this,g),I=A.call(this),nA(jg(I),"type",void 0),I.type="function",I.functions=e,I}return Yg(g,[{key:"genValue",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=this.findFunction(e);return t===-1?(console.error(e),0):this.functions[t][0].genValue((e-this.getStartX(t))/(this.getEndX(t)-this.getStartX(t)))}},{key:"toSVG",value:function(e,t){if(t<1)return"";for(var C=["M",0,this.functions[0][0].p[0]].join(" "),o=1/t;o<=1;o+=1/t)C=[C,"L",o*e,this.genValue(o)].join(" ");return C}},{key:"toJSON",value:function(){return{type:"PiecewiseBezier",functions:this.functions.map(function(e){var t=uR(e,2),C=t[0],o=t[1];return{function:C.toJSON(),start:o}})}}},{key:"clone",value:function(){return new g(this.functions.map(function(e){var t=uR(e,2),C=t[0],o=t[1];return[C.clone(),o]}))}}],[{key:"fromJSON",value:function(e){return new g(e.functions.map(function(t){return[fR.fromJSON(t.function),t.start]}))}}]),g}(SV),yR=function(){function i(){xg(this,i),nA(this,"type",void 0),this.type="rotation"}return Yg(i,[{key:"genValue",value:function(g,I){var e,t,C,o,s,n,B;do e=Math.random()*2-1,t=Math.random()*2-1,C=e*e+t*t;while(C>1);do o=Math.random()*2-1,s=Math.random()*2-1,n=o*o+s*s;while(n>1);return B=Math.sqrt((1-C)/n),g.set(e,t,B*o,B*s),g}},{key:"toJSON",value:function(){return{type:"RandomQuat"}}},{key:"clone",value:function(){return new i}}],[{key:"fromJSON",value:function(g){return new i}}]),i}(),Zq=function(){function i(A,g){xg(this,i),this.axis=A,this.angle=g,nA(this,"type",void 0),this.type="rotation"}return Yg(i,[{key:"genValue",value:function(g,I){return g.setFromAxisAngle(this.axis,this.angle.genValue(I))}},{key:"toJSON",value:function(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}},{key:"clone",value:function(){return new i(this.axis.clone(),this.angle.clone())}}],[{key:"fromJSON",value:function(g){return new i(g.axis,qe(g.angle))}}]),i}();function zq(i){switch(i.type){case"AxisAngle":return Zq.fromJSON(i);case"RandomQuat":return yR.fromJSON(i);default:return new yR}}function qe(i){switch(i.type){case"ConstantValue":return ni.fromJSON(i);case"IntervalValue":return yV.fromJSON(i);case"PiecewiseBezier":return GV.fromJSON(i);default:return new ni(0)}}function kV(i){switch(i.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return qe(i);case"AxisAngle":case"RandomQuat":return zq(i);default:return new ni(0)}}var XE=function(A){return{r:A.x,g:A.y,b:A.z,a:A.w}},$E=function(A){return new sg(A.r,A.g,A.b,A.a)},MV=function(){function i(A,g){xg(this,i),this.a=A,this.b=g,nA(this,"type",void 0),this.type="value"}return Yg(i,[{key:"genColor",value:function(g){var I=Math.random();return g.copy(this.a).lerp(this.b,I)}},{key:"toJSON",value:function(){return{type:"RandomColor",a:XE(this.a),b:XE(this.b)}}},{key:"clone",value:function(){return new i(this.a.clone(),this.b.clone())}}],[{key:"fromJSON",value:function(g){return new i($E(g.a),$E(g.b))}}]),i}(),UV=function(){function i(A,g){xg(this,i),this.a=A,this.b=g,nA(this,"type",void 0),this.type="function"}return Yg(i,[{key:"genColor",value:function(g,I){return g.copy(this.a).lerp(this.b,I)}},{key:"toJSON",value:function(){return{type:"ColorRange",a:XE(this.a),b:XE(this.b)}}},{key:"clone",value:function(){return new i(this.a.clone(),this.b.clone())}}],[{key:"fromJSON",value:function(g){return new i($E(g.a),$E(g.b))}}]),i}(),sD=function(){function i(A){xg(this,i),this.color=A,nA(this,"type",void 0),this.type="value"}return Yg(i,[{key:"genColor",value:function(g){return g.copy(this.color)}},{key:"toJSON",value:function(){return{type:"ConstantColor",color:XE(this.color)}}},{key:"clone",value:function(){return new i(this.color.clone())}}],[{key:"fromJSON",value:function(g){return new i($E(g.color))}}]),i}();function Vq(i){switch(i.type){case"ConstantColor":return sD.fromJSON(i);case"ColorRange":return UV.fromJSON(i);case"RandomColor":return MV.fromJSON(i);default:return new sD(new sg(1,1,1,1))}}var SR=function(){function i(A){xg(this,i),this.color=A,nA(this,"type","ColorOverLife")}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g,I){this.color.genColor(g.color,g.age/g.life),g.color.x*=g.startColor.x,g.color.y*=g.startColor.y,g.color.z*=g.startColor.z,g.color.w*=g.startColor.w}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,color:this.color.toJSON()}}},{key:"clone",value:function(){return new i(this.color.clone())}}],[{key:"fromJSON",value:function(g){return new i(Vq(g.color))}}]),i}(),GR=function(){function i(A,g){xg(this,i),this.angularVelocity=A,this.dynamic=g,nA(this,"type","RotationOverLife"),nA(this,"tempQuat",new UA)}return Yg(i,[{key:"initialize",value:function(g){!this.dynamic&&g instanceof VE&&(g.angularVelocity=this.angularVelocity.genValue())}},{key:"update",value:function(g,I){this.dynamic?g.rotation+=I*this.angularVelocity.genValue(g.age/g.life):g instanceof VE&&(g.rotation+=I*g.angularVelocity)}},{key:"toJSON",value:function(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),dynamic:this.dynamic}}},{key:"frameUpdate",value:function(g){}},{key:"clone",value:function(){return new i(this.angularVelocity.clone(),this.dynamic)}}],[{key:"fromJSON",value:function(g){return new i(qe(g.angularVelocity),g.dynamic)}}]),i}(),kR=function(){function i(A){xg(this,i),this.size=A,nA(this,"type","SizeOverLife")}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g){g.size=g.startSize*this.size.genValue(g.age/g.life)}},{key:"toJSON",value:function(){return{type:this.type,size:this.size.toJSON()}}},{key:"frameUpdate",value:function(g){}},{key:"clone",value:function(){return new i(this.size.clone())}}],[{key:"fromJSON",value:function(g){return new i(qe(g.size))}}]),i}(),MR=function(){function i(A){xg(this,i),this.speed=A,nA(this,"type","SpeedOverLife")}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g){g.velocity.normalize().multiplyScalar(g.startSpeed*this.speed.genValue(g.age/g.life))}},{key:"toJSON",value:function(){return{type:this.type,speed:this.speed.toJSON()}}},{key:"frameUpdate",value:function(g){}},{key:"clone",value:function(){return new i(this.speed.clone())}}],[{key:"fromJSON",value:function(g){return new i(qe(g.speed))}}]),i}(),UR=function(){function i(A){xg(this,i),this.frame=A,nA(this,"type","FrameOverLife")}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g,I){g.uvTile=Math.floor(this.frame.genValue(g.age/g.life))}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,frame:this.frame.toJSON()}}},{key:"clone",value:function(){return new i(this.frame.clone())}}],[{key:"fromJSON",value:function(g){return new i(qe(g.frame))}}]),i}();new M(0,0,1);var RR=function(){function i(A){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:new M(0,1,0);xg(this,i),this.orbitSpeed=A,this.axis=g,nA(this,"type","OrbitOverLife"),nA(this,"rotation",void 0),nA(this,"line",void 0),nA(this,"temp",new M),this.rotation=new UA,this.line=new ZF}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g,I){this.line.set(new M(0,0,0),this.axis),this.line.closestPointToPoint(g.position,!1,this.temp),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(g.age/g.life)*I),g.position.sub(this.temp),g.position.applyQuaternion(this.rotation),g.position.add(this.temp)}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}},{key:"clone",value:function(){return new i(this.orbitSpeed.clone())}}],[{key:"fromJSON",value:function(g){return new i(qe(g.orbitSpeed),g.axis?new M(g.axis[0],g.axis[1],g.axis[2]):void 0)}}]),i}(),mR=function(){function i(A,g){xg(this,i),this.direction=A,this.force=g,nA(this,"type","ApplyForce")}return Yg(i,[{key:"initialize",value:function(g){g.force=this.force.genValue()}},{key:"update",value:function(g,I){g.velocity.addScaledVector(this.direction,g.force*I)}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],force:this.force.toJSON()}}},{key:"clone",value:function(){return new i(this.direction.clone(),this.force.clone())}}],[{key:"fromJSON",value:function(g){return new i(new M(g.direction[0],g.direction[1],g.direction[2]),qe(g.force))}}]),i}(),FR=function(){function i(A,g){xg(this,i),this.center=A,this.magnitude=g,nA(this,"type","GravityForce"),nA(this,"temp",new M)}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g,I){this.temp.copy(this.center).sub(g.position).normalize(),g.velocity.addScaledVector(this.temp,this.magnitude/g.position.distanceToSquared(this.center)*I)}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}},{key:"clone",value:function(){return new i(this.center.clone(),this.magnitude)}}],[{key:"fromJSON",value:function(g){return new i(new M(g.center[0],g.center[1],g.center[2]),g.magnitude)}}]),i}(),NR=function(){function i(A){xg(this,i),this.width=A,nA(this,"type","WidthOverLength")}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g){if(g instanceof oD)for(var I=0;I<g.previous.length;I++)g.previous[I].size=this.width.genValue((g.previous.length-I)/g.length)}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,width:this.width.toJSON()}}},{key:"clone",value:function(){return new i(this.width.clone())}}],[{key:"fromJSON",value:function(g){return new i(qe(g.width))}}]),i}();new M(0,0,1);var KR=function(){function i(A){xg(this,i),this.angle=A,nA(this,"type","ChangeEmitDirection"),nA(this,"_temp",new M),nA(this,"_q",new UA)}return Yg(i,[{key:"initialize",value:function(g){var I=g.velocity.length();I!=0&&(g.velocity.normalize(),g.velocity.x===0&&g.velocity.y===0?this._temp.set(0,g.velocity.z,0):this._temp.set(-g.velocity.y,g.velocity.x,0),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue()),this._temp.copy(g.velocity),g.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),g.velocity.applyQuaternion(this._q),g.velocity.setLength(I))}},{key:"update",value:function(g,I){}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,angle:this.angle.toJSON()}}},{key:"clone",value:function(){return new i(this.angle)}}],[{key:"fromJSON",value:function(g){return new i(qe(g.angle))}}]),i}(),RV=new M(1,1,1),JR=new M(0,0,1),qR=function(){function i(A,g,I){xg(this,i),this.particleSystem=A,this.useVelocityAsBasis=g,this.subParticleSystem=I,nA(this,"type","EmitSubParticleSystem"),nA(this,"q_",new UA),nA(this,"v_",new M),nA(this,"v2_",new M),this.subParticleSystem&&(this.subParticleSystem.system.onlyUsedByOther=!0)}return Yg(i,[{key:"initialize",value:function(g){g.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:new XA}}},{key:"update",value:function(g,I){if(!(!this.subParticleSystem||!g.emissionState)){var e=g.emissionState.matrix,t;if(g.rotation===void 0||this.useVelocityAsBasis)if(g.velocity.x===0&&g.velocity.y===0&&(g.velocity.z===1||g.velocity.z===0))e.set(1,0,0,g.position.x,0,1,0,g.position.y,0,0,1,g.position.z,0,0,0,1);else{this.v_.copy(JR).cross(g.velocity),this.v2_.copy(g.velocity).cross(this.v_);var C=this.v_.length(),o=this.v2_.length();e.set(this.v_.x/C,this.v2_.x/o,g.velocity.x,g.position.x,this.v_.y/C,this.v2_.y/o,g.velocity.y,g.position.y,this.v_.z/C,this.v2_.z/o,g.velocity.z,g.position.z,0,0,0,1)}else g.rotation instanceof UA?t=g.rotation:(this.q_.setFromAxisAngle(JR,g.rotation),t=this.q_),e.compose(g.position,t,RV);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e),this.subParticleSystem.system.emit(I,g.emissionState,e)}}},{key:"frameUpdate",value:function(g){}},{key:"toJSON",value:function(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis}}},{key:"clone",value:function(){return new i(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem)}}],[{key:"fromJSON",value:function(g,I){return new i(I,g.useVelocityAsBasis,void 0)}}]),i}(),mV=.5*(Math.sqrt(3)-1),hr=(3-Math.sqrt(3))/6,FV=1/3,rC=1/6,NV=(Math.sqrt(5)-1)/4,me=(5-Math.sqrt(5))/20,ue=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),$I=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),KV=function(){function i(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Math.random;xg(this,i),nA(this,"p",void 0),nA(this,"perm",void 0),nA(this,"permMod12",void 0);var g=typeof A=="function"?A:qV(A);this.p=JV(g),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(var I=0;I<512;I++)this.perm[I]=this.p[I&255],this.permMod12[I]=this.perm[I]%12}return Yg(i,[{key:"noise2D",value:function(g,I){var e=this.permMod12,t=this.perm,C=0,o=0,s=0,n=(g+I)*mV,B=Math.floor(g+n),r=Math.floor(I+n),a=(B+r)*hr,E=B-a,c=r-a,h=g-E,l=I-c,u,w;h>l?(u=1,w=0):(u=0,w=1);var d=h-u+hr,D=l-w+hr,p=h-1+2*hr,f=l-1+2*hr,S=B&255,y=r&255,G=.5-h*h-l*l;if(G>=0){var k=e[S+t[y]]*3;G*=G,C=G*G*(ue[k]*h+ue[k+1]*l)}var F=.5-d*d-D*D;if(F>=0){var J=e[S+u+t[y+w]]*3;F*=F,o=F*F*(ue[J]*d+ue[J+1]*D)}var N=.5-p*p-f*f;if(N>=0){var K=e[S+1+t[y+1]]*3;N*=N,s=N*N*(ue[K]*p+ue[K+1]*f)}return 70*(C+o+s)}},{key:"noise3D",value:function(g,I,e){var t=this.permMod12,C=this.perm,o,s,n,B,r=(g+I+e)*FV,a=Math.floor(g+r),E=Math.floor(I+r),c=Math.floor(e+r),h=(a+E+c)*rC,l=a-h,u=E-h,w=c-h,d=g-l,D=I-u,p=e-w,f,S,y,G,k,F;d>=D?D>=p?(f=1,S=0,y=0,G=1,k=1,F=0):d>=p?(f=1,S=0,y=0,G=1,k=0,F=1):(f=0,S=0,y=1,G=1,k=0,F=1):D<p?(f=0,S=0,y=1,G=0,k=1,F=1):d<p?(f=0,S=1,y=0,G=0,k=1,F=1):(f=0,S=1,y=0,G=1,k=1,F=0);var J=d-f+rC,N=D-S+rC,K=p-y+rC,x=d-G+2*rC,T=D-k+2*rC,O=p-F+2*rC,_=d-1+3*rC,gA=D-1+3*rC,rA=p-1+3*rC,cA=a&255,DA=E&255,IA=c&255,BA=.6-d*d-D*D-p*p;if(BA<0)o=0;else{var fA=t[cA+C[DA+C[IA]]]*3;BA*=BA,o=BA*BA*(ue[fA]*d+ue[fA+1]*D+ue[fA+2]*p)}var Z=.6-J*J-N*N-K*K;if(Z<0)s=0;else{var KA=t[cA+f+C[DA+S+C[IA+y]]]*3;Z*=Z,s=Z*Z*(ue[KA]*J+ue[KA+1]*N+ue[KA+2]*K)}var mA=.6-x*x-T*T-O*O;if(mA<0)n=0;else{var ZA=t[cA+G+C[DA+k+C[IA+F]]]*3;mA*=mA,n=mA*mA*(ue[ZA]*x+ue[ZA+1]*T+ue[ZA+2]*O)}var yA=.6-_*_-gA*gA-rA*rA;if(yA<0)B=0;else{var Cg=t[cA+1+C[DA+1+C[IA+1]]]*3;yA*=yA,B=yA*yA*(ue[Cg]*_+ue[Cg+1]*gA+ue[Cg+2]*rA)}return 32*(o+s+n+B)}},{key:"noise4D",value:function(g,I,e,t){var C=this.perm,o,s,n,B,r,a=(g+I+e+t)*NV,E=Math.floor(g+a),c=Math.floor(I+a),h=Math.floor(e+a),l=Math.floor(t+a),u=(E+c+h+l)*me,w=E-u,d=c-u,D=h-u,p=l-u,f=g-w,S=I-d,y=e-D,G=t-p,k=0,F=0,J=0,N=0;f>S?k++:F++,f>y?k++:J++,f>G?k++:N++,S>y?F++:J++,S>G?F++:N++,y>G?J++:N++;var K=k>=3?1:0,x=F>=3?1:0,T=J>=3?1:0,O=N>=3?1:0,_=k>=2?1:0,gA=F>=2?1:0,rA=J>=2?1:0,cA=N>=2?1:0,DA=k>=1?1:0,IA=F>=1?1:0,BA=J>=1?1:0,fA=N>=1?1:0,Z=f-K+me,KA=S-x+me,mA=y-T+me,ZA=G-O+me,yA=f-_+2*me,Cg=S-gA+2*me,dA=y-rA+2*me,hA=G-cA+2*me,FA=f-DA+3*me,zA=S-IA+3*me,xA=y-BA+3*me,ng=G-fA+3*me,$A=f-1+4*me,Ig=S-1+4*me,Ug=y-1+4*me,wg=G-1+4*me,Y=E&255,L=c&255,aA=h&255,MA=l&255,NA=.6-f*f-S*S-y*y-G*G;if(NA<0)o=0;else{var _A=C[Y+C[L+C[aA+C[MA]]]]%32*4;NA*=NA,o=NA*NA*($I[_A]*f+$I[_A+1]*S+$I[_A+2]*y+$I[_A+3]*G)}var og=.6-Z*Z-KA*KA-mA*mA-ZA*ZA;if(og<0)s=0;else{var OA=C[Y+K+C[L+x+C[aA+T+C[MA+O]]]]%32*4;og*=og,s=og*og*($I[OA]*Z+$I[OA+1]*KA+$I[OA+2]*mA+$I[OA+3]*ZA)}var b=.6-yA*yA-Cg*Cg-dA*dA-hA*hA;if(b<0)n=0;else{var pA=C[Y+_+C[L+gA+C[aA+rA+C[MA+cA]]]]%32*4;b*=b,n=b*b*($I[pA]*yA+$I[pA+1]*Cg+$I[pA+2]*dA+$I[pA+3]*hA)}var VA=.6-FA*FA-zA*zA-xA*xA-ng*ng;if(VA<0)B=0;else{var YA=C[Y+DA+C[L+IA+C[aA+BA+C[MA+fA]]]]%32*4;VA*=VA,B=VA*VA*($I[YA]*FA+$I[YA+1]*zA+$I[YA+2]*xA+$I[YA+3]*ng)}var PA=.6-$A*$A-Ig*Ig-Ug*Ug-wg*wg;if(PA<0)r=0;else{var bA=C[Y+1+C[L+1+C[aA+1+C[MA+1]]]]%32*4;PA*=PA,r=PA*PA*($I[bA]*$A+$I[bA+1]*Ig+$I[bA+2]*Ug+$I[bA+3]*wg)}return 27*(o+s+n+B+r)}}]),i}();function JV(i){for(var A=new Uint8Array(256),g=0;g<256;g++)A[g]=g;for(var I=0;I<255;I++){var e=I+~~(i()*(256-I)),t=A[I];A[I]=A[e],A[e]=t}return A}function qV(i){var A=0,g=0,I=0,e=1,t=LV();return A=t(" "),g=t(" "),I=t(" "),A-=t(i),A<0&&(A+=1),g-=t(i),g<0&&(g+=1),I-=t(i),I<0&&(I+=1),function(){var C=2091639*A+e*23283064365386963e-26;return A=g,g=I,I=C-(e=C|0)}}function LV(){var i=4022871197;return function(A){A=A.toString();for(var g=0;g<A.length;g++){i+=A.charCodeAt(g);var I=.02519603282416938*i;i=I>>>0,I-=i,I*=i,i=I>>>0,I-=i,i+=I*4294967296}return(i>>>0)*23283064365386963e-26}}var LR=function(){function i(A,g,I){xg(this,i),this.scale=A,this.power=g,this.fieldShift=I,nA(this,"type","TurbulenceField"),nA(this,"generator",new KV),nA(this,"offset",[new M,new M,new M]),nA(this,"temp",new M),this.offset[0].x=Math.random()/this.scale.x,this.offset[1].x=Math.random()/this.scale.x,this.offset[2].x=Math.random()/this.scale.x,this.offset[0].y=Math.random()/this.scale.y,this.offset[1].y=Math.random()/this.scale.y,this.offset[2].y=Math.random()/this.scale.y,this.offset[0].z=Math.random()/this.scale.z,this.offset[1].z=Math.random()/this.scale.z,this.offset[2].z=Math.random()/this.scale.z}return Yg(i,[{key:"initialize",value:function(g){}},{key:"update",value:function(g,I){var e=g.position.x/this.scale.x,t=g.position.y/this.scale.y,C=g.position.z/this.scale.z;this.temp.set(this.generator.noise3D(this.offset[0].x+e,this.offset[0].y+t,this.offset[0].z+C),this.generator.noise3D(this.offset[1].x+e,this.offset[1].y+t,this.offset[1].z+C),this.generator.noise3D(this.offset[2].x+e,this.offset[2].y+t,this.offset[2].z+C)).multiply(this.power),g.velocity.addScaledVector(this.temp,I)}},{key:"toJSON",value:function(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],power:[this.power.x,this.power.y,this.power.z],fieldShift:[this.fieldShift.x,this.fieldShift.y,this.fieldShift.z]}}},{key:"frameUpdate",value:function(g){this.offset[0].x+=g*this.fieldShift.x,this.offset[0].y+=g*this.fieldShift.y,this.offset[0].z+=g*this.fieldShift.z,this.offset[1].x+=g*this.fieldShift.x,this.offset[1].y+=g*this.fieldShift.y,this.offset[1].z+=g*this.fieldShift.z,this.offset[2].x+=g*this.fieldShift.x,this.offset[2].y+=g*this.fieldShift.y,this.offset[2].z+=g*this.fieldShift.z}},{key:"clone",value:function(){return new i(this.scale.clone(),this.power.clone(),this.fieldShift.clone())}}],[{key:"fromJSON",value:function(g){return new i(new M(g.scale[0],g.scale[1],g.scale[2]),new M(g.power[0],g.power[1],g.power[2]),new M(g.fieldShift[0],g.fieldShift[1],g.fieldShift[2]))}}]),i}(),bR=new UA,vR=function(){function i(A,g){xg(this,i),this.angularVelocity=A,this.dynamic=g,nA(this,"type","Rotation3DOverLife"),nA(this,"tempQuat",new UA)}return Yg(i,[{key:"initialize",value:function(g){!this.dynamic&&g instanceof VE&&(g.angularVelocity=new UA,this.angularVelocity.genValue(g.angularVelocity))}},{key:"update",value:function(g,I){this.dynamic?(this.angularVelocity.genValue(this.tempQuat,g.age/g.life),this.tempQuat.slerpQuaternions(bR,this.tempQuat,I),g.rotation.multiply(this.tempQuat)):g instanceof VE&&(this.tempQuat.slerpQuaternions(bR,g.angularVelocity,I),g.rotation.multiply(this.tempQuat))}},{key:"toJSON",value:function(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),dynamic:this.dynamic}}},{key:"frameUpdate",value:function(g){}},{key:"clone",value:function(){return new i(this.angularVelocity.clone(),this.dynamic)}}],[{key:"fromJSON",value:function(g){return new i(zq(g.angularVelocity),g.dynamic)}}]),i}(),bV={ApplyForce:{type:"ApplyForce",constructor:mR,params:[["direction","vec3"],["force","value"]],loadJSON:mR.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:LR,params:[["scale","vec3"],["power","vec3"],["fieldShift","vec3"]],loadJSON:LR.fromJSON},GravityForce:{type:"GravityForce",constructor:FR,params:[["center","vec3"],["magnitude","number"]],loadJSON:FR.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:SR,params:[["color","colorFunc"]],loadJSON:SR.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:GR,params:[["angularVelocity","valueFunc"],["dynamic","boolean"]],loadJSON:GR.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:vR,params:[["angularVelocity","rotationFunc"],["dynamic","boolean"]],loadJSON:vR.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:kR,params:[["size","valueFunc"]],loadJSON:kR.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:MR,params:[["speed","valueFunc"]],loadJSON:MR.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:UR,params:[["frame","valueFunc"]],loadJSON:UR.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:RR,params:[["orbitSpeed","valueFunc"],["axis","vec3"]],loadJSON:RR.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:NR,params:[["width","valueFunc"]],loadJSON:NR.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:KR,params:[["angle","value"]],loadJSON:KR.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:qR,params:[["particleSystem","self"],["useVelocityAsBasis","boolean"],["subParticleSystem","particleSystem"]],loadJSON:qR.fromJSON}};function vV(i,A){return bV[i.type].loadJSON(i,A)}var xR=function(){function i(){var A,g,I,e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xg(this,i),nA(this,"type","cone"),nA(this,"radius",void 0),nA(this,"arc",void 0),nA(this,"thickness",void 0),nA(this,"angle",void 0),this.radius=(A=t.radius)!==null&&A!==void 0?A:10,this.arc=(g=t.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(I=t.thickness)!==null&&I!==void 0?I:1,this.angle=(e=t.angle)!==null&&e!==void 0?e:Math.PI/6}return Yg(i,[{key:"initialize",value:function(g){var I=Math.random(),e=Ui.lerp(1-this.thickness,1,Math.random()),t=I*this.arc,C=Math.sqrt(e),o=Math.sin(t),s=Math.cos(t);g.position.x=C*s,g.position.y=C*o,g.position.z=0;var n=this.angle*C;g.velocity.set(0,0,Math.cos(n)).addScaledVector(g.position,Math.sin(n)).multiplyScalar(g.startSpeed),g.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle}}},{key:"clone",value:function(){return new i({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle})}}],[{key:"fromJSON",value:function(g){return new i(g)}}]),i}(),YR=function(){function i(){var A,g,I,e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xg(this,i),nA(this,"type","donut"),nA(this,"radius",void 0),nA(this,"arc",void 0),nA(this,"thickness",void 0),nA(this,"angle",void 0),this.radius=(A=t.radius)!==null&&A!==void 0?A:10,this.arc=(g=t.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(I=t.thickness)!==null&&I!==void 0?I:1,this.angle=(e=t.angle)!==null&&e!==void 0?e:Math.PI/6}return Yg(i,[{key:"initialize",value:function(g){var I=Math.random(),e=Ui.lerp(this.thickness,1,Math.random()),t=I*this.arc,C=Math.sqrt(e),o=Math.sin(t),s=Math.cos(t);g.position.x=C*s,g.position.y=C*o,g.position.z=0;var n=this.angle*C;g.velocity.set(0,0,Math.cos(n)).addScaledVector(g.position,Math.sin(n)).multiplyScalar(g.startSpeed),g.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle}}},{key:"clone",value:function(){return new i({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle})}}],[{key:"fromJSON",value:function(g){return new i(g)}}]),i}(),HR=function(){function i(){xg(this,i),nA(this,"type","point")}return Yg(i,[{key:"initialize",value:function(g){var I=Math.random(),e=Math.random(),t=I*Math.PI*2,C=Math.acos(2*e-1),o=Math.cbrt(Math.random()),s=Math.sin(t),n=Math.cos(t),B=Math.sin(C),r=Math.cos(C);g.velocity.x=o*B*n,g.velocity.y=o*B*s,g.velocity.z=o*r,g.velocity.multiplyScalar(g.startSpeed),g.position.setScalar(0)}},{key:"toJSON",value:function(){return{type:"point"}}},{key:"clone",value:function(){return new i}}],[{key:"fromJSON",value:function(g){return new i}}]),i}(),xy=function(){function i(){var A,g,I,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xg(this,i),nA(this,"type","sphere"),nA(this,"radius",void 0),nA(this,"arc",void 0),nA(this,"thickness",void 0),this.radius=(A=e.radius)!==null&&A!==void 0?A:10,this.arc=(g=e.arc)!==null&&g!==void 0?g:2*Math.PI,this.thickness=(I=e.thickness)!==null&&I!==void 0?I:1}return Yg(i,[{key:"initialize",value:function(g){var I=Math.random(),e=Math.random(),t=Ui.lerp(1-this.thickness,1,Math.random()),C=I*this.arc,o=Math.acos(2*e-1),s=Math.cbrt(t),n=Math.sin(C),B=Math.cos(C),r=Math.sin(o),a=Math.cos(o);g.position.x=s*r*B,g.position.y=s*r*n,g.position.z=s*a,g.velocity.setScalar(0).addScaledVector(g.position,g.startSpeed),g.position.multiplyScalar(this.radius)}},{key:"toJSON",value:function(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness}}},{key:"clone",value:function(){return new i({radius:this.radius,arc:this.arc,thickness:this.thickness})}}],[{key:"fromJSON",value:function(g){return new i(g)}}]),i}(),TR=function(){function i(A){xg(this,i),nA(this,"type","mesh_surface"),nA(this,"_triangleIndexToArea",[]),nA(this,"_mesh",void 0),nA(this,"_tempA",new M),nA(this,"_tempB",new M),nA(this,"_tempC",new M),A&&(this.mesh=A)}return Yg(i,[{key:"mesh",get:function(){return this._mesh},set:function(g){this._mesh=g;var I=new Oi;this._triangleIndexToArea.length=0;var e=0,t=g.geometry;if(t.getIndex()){var C=t.getIndex().array,o=C.length/3;this._triangleIndexToArea.push(0);for(var s=0;s<o;s++)I.setFromAttributeAndIndices(t.getAttribute("position"),C[s*3],C[s*3+1],C[s*3+2]),e+=I.getArea(),this._triangleIndexToArea.push(e);g.userData.triangleIndexToArea=this._triangleIndexToArea}}},{key:"initialize",value:function(g){if(!this._mesh){g.position.set(0,0,0),g.velocity.set(0,0,1).multiplyScalar(g.startSpeed);return}for(var I=this._triangleIndexToArea.length-1,e=0,t=I,C=Math.random()*this._triangleIndexToArea[I];e+1<t;){var o=Math.floor((e+t)/2);C<this._triangleIndexToArea[o]?t=o:e=o}var s=Math.random(),n=Math.random();s+n>1&&(s=1-s,n=1-n);var B=this._mesh.geometry,r=B.getIndex().array[e*3],a=B.getIndex().array[e*3+1],E=B.getIndex().array[e*3+2],c=B.getAttribute("position");this._tempA.fromBufferAttribute(c,r),this._tempB.fromBufferAttribute(c,a),this._tempC.fromBufferAttribute(c,E),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,s).addScaledVector(this._tempC,n),g.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),g.velocity.copy(this._tempA).normalize().multiplyScalar(g.startSpeed)}},{key:"toJSON",value:function(){return{type:"mesh_surface",mesh:this._mesh?this._mesh.uuid:""}}},{key:"clone",value:function(){return new i(this._mesh)}}],[{key:"fromJSON",value:function(g){return new i}}]),i}(),xV={cone:{type:"cone",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:xR,loadJSON:xR.fromJSON},donut:{type:"donut",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:YR,loadJSON:YR.fromJSON},point:{type:"point",params:[],constructor:HR,loadJSON:HR.fromJSON},sphere:{type:"sphere",params:[["radius","number"],["arc","radian"],["thickness","number"],["angle","radian"]],constructor:xy,loadJSON:xy.fromJSON},mesh_surface:{type:"mesh_surface",params:[["mesh","mesh"]],constructor:TR,loadJSON:TR.fromJSON}};function YV(i){return xV[i.type].loadJSON(i)}var hg;(function(i){i[i.BillBoard=0]="BillBoard",i[i.StretchedBillBoard=1]="StretchedBillBoard",i[i.LocalSpace=2]="LocalSpace",i[i.Trail=3]="Trail"})(hg||(hg={}));var Xq=function(i){TQ(g,i);var A=OQ(g);function g(I){var e;return xg(this,g),e=A.call(this),nA(jg(e),"type","ParticleSystemBatch"),nA(jg(e),"systems",void 0),nA(jg(e),"material",void 0),nA(jg(e),"settings",void 0),nA(jg(e),"maxParticles",void 0),e.maxParticles=1e3,e.systems=new Set,e.settings={blending:I.blending,instancingGeometry:I.instancingGeometry,renderMode:I.renderMode,renderOrder:I.renderOrder,texture:I.texture,uTileCount:I.uTileCount,vTileCount:I.vTileCount,transparent:I.transparent},e.frustumCulled=!1,e.renderOrder=e.settings.renderOrder,e}return Yg(g,[{key:"addSystem",value:function(e){this.systems.add(e)}},{key:"removeSystem",value:function(e){this.systems.delete(e)}}]),g}(GA),HV=new M(0,0,1),OR=new UA,TV=new Te(1,1,1,1),OV=function(){function i(A,g){var I,e,t,C,o,s,n,B,r,a,E,c,h,l,u,w,d,D,p,f,S,y;xg(this,i),nA(this,"autoDestroy",void 0),nA(this,"looping",void 0),nA(this,"duration",void 0),nA(this,"startLife",void 0),nA(this,"startSpeed",void 0),nA(this,"startRotation",void 0),nA(this,"startSize",void 0),nA(this,"startColor",void 0),nA(this,"startTileIndex",void 0),nA(this,"rendererEmitterSettings",void 0),nA(this,"emissionOverTime",void 0),nA(this,"emissionOverDistance",void 0),nA(this,"emissionBursts",void 0),nA(this,"onlyUsedByOther",void 0),nA(this,"worldSpace",void 0),nA(this,"speedFactor",void 0),nA(this,"particleNum",void 0),nA(this,"paused",void 0),nA(this,"emissionState",void 0),nA(this,"emitEnded",void 0),nA(this,"markForDestroy",void 0),nA(this,"normalMatrix",new ie),nA(this,"behaviors",void 0),nA(this,"particles",void 0),nA(this,"emitterShape",void 0),nA(this,"emitter",void 0),nA(this,"rendererSettings",void 0),nA(this,"renderer",void 0),nA(this,"neededToUpdateRender",void 0),this.renderer=A,this.autoDestroy=g.autoDestroy===void 0?!1:g.autoDestroy,this.duration=(I=g.duration)!==null&&I!==void 0?I:1,this.looping=g.looping===void 0?!0:g.looping,this.startLife=(e=g.startLife)!==null&&e!==void 0?e:new ni(5),this.startSpeed=(t=g.startSpeed)!==null&&t!==void 0?t:new ni(0),this.startRotation=(C=g.startRotation)!==null&&C!==void 0?C:new ni(0),this.startSize=(o=g.startSize)!==null&&o!==void 0?o:new ni(1),this.startColor=(s=g.startColor)!==null&&s!==void 0?s:new sD(new sg(1,1,1,1)),this.emissionOverTime=(n=g.emissionOverTime)!==null&&n!==void 0?n:new ni(10),this.emissionOverDistance=(B=g.emissionOverDistance)!==null&&B!==void 0?B:new ni(0),this.emissionBursts=(r=g.emissionBursts)!==null&&r!==void 0?r:[],this.onlyUsedByOther=(a=g.onlyUsedByOther)!==null&&a!==void 0?a:!1,this.emitterShape=(E=g.shape)!==null&&E!==void 0?E:new xy,this.behaviors=(c=g.behaviors)!==null&&c!==void 0?c:new Array,this.worldSpace=(h=g.worldSpace)!==null&&h!==void 0?h:!1,this.speedFactor=(l=g.speedFactor)!==null&&l!==void 0?l:0,this.rendererEmitterSettings=(u=g.rendererEmitterSettings)!==null&&u!==void 0?u:{},this.rendererSettings={blending:(w=g.blending)!==null&&w!==void 0?w:So,transparent:(d=g.transparent)!==null&&d!==void 0?d:!0,instancingGeometry:(D=g.instancingGeometry)!==null&&D!==void 0?D:TV,renderMode:(p=g.renderMode)!==null&&p!==void 0?p:hg.BillBoard,renderOrder:(f=g.renderOrder)!==null&&f!==void 0?f:0,texture:g.texture,uTileCount:(S=g.uTileCount)!==null&&S!==void 0?S:1,vTileCount:(y=g.vTileCount)!==null&&y!==void 0?y:1},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=g.startTileIndex||new ni(0),this.emitter=new wV(this),this.paused=!1,this.particleNum=0,this.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this.emitEnded=!1,this.markForDestroy=!1,this.renderer.addSystem(this)}return Yg(i,[{key:"texture",get:function(){return this.rendererSettings.texture},set:function(g){this.rendererSettings.texture=g,this.neededToUpdateRender=!0}},{key:"uTileCount",get:function(){return this.rendererSettings.uTileCount},set:function(g){this.rendererSettings.uTileCount=g,this.neededToUpdateRender=!0}},{key:"vTileCount",get:function(){return this.rendererSettings.vTileCount},set:function(g){this.rendererSettings.vTileCount=g,this.neededToUpdateRender=!0}},{key:"instancingGeometry",get:function(){return this.rendererSettings.instancingGeometry},set:function(g){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=g,this.neededToUpdateRender=!0}},{key:"renderMode",get:function(){return this.rendererSettings.renderMode},set:function(g){if((this.rendererSettings.renderMode!=hg.Trail&&g===hg.Trail||this.rendererSettings.renderMode==hg.Trail&&g!==hg.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==g)switch(g){case hg.Trail:this.rendererEmitterSettings={startLength:new ni(30),followLocalOrigin:!1};break;case hg.LocalSpace:this.rendererEmitterSettings={geometry:new Te(1,1)},this.startRotation=new Zq(new M(0,1,0),new ni(0));break;case hg.BillBoard:case hg.StretchedBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===hg.LocalSpace&&(this.startRotation=new ni(0));break}this.rendererSettings.renderMode=g,this.neededToUpdateRender=!0}},{key:"renderOrder",get:function(){return this.rendererSettings.renderOrder},set:function(g){this.rendererSettings.renderOrder=g,this.neededToUpdateRender=!0}},{key:"blending",get:function(){return this.rendererSettings.blending},set:function(g){this.rendererSettings.blending=g,this.neededToUpdateRender=!0}},{key:"pause",value:function(){this.paused=!0}},{key:"play",value:function(){this.paused=!1}},{key:"spawn",value:function(g,I,e){OR.setFromRotationMatrix(e);for(var t=0;t<g;t++){for(this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===hg.Trail?this.particles.push(new oD):this.particles.push(new VE);var C=this.particles[this.particleNum-1];if(this.startColor.genColor(C.startColor,I.time),C.color.copy(C.startColor),C.startSpeed=this.startSpeed.genValue(I.time/this.duration),C.life=this.startLife.genValue(I.time/this.duration),C.age=0,C.startSize=this.startSize.genValue(I.time/this.duration),C.uvTile=Math.floor(this.startTileIndex.genValue()),C.size=C.startSize,this.rendererSettings.renderMode===hg.LocalSpace||this.rendererSettings.renderMode===hg.BillBoard||this.rendererSettings.renderMode===hg.StretchedBillBoard){var o=C;this.rendererSettings.renderMode===hg.LocalSpace?(o.rotation instanceof UA||(o.rotation=new UA),this.startRotation.type==="rotation"?this.startRotation.genValue(o.rotation,I.time/this.duration):o.rotation.setFromAxisAngle(HV,this.startRotation.genValue(I.time/this.duration))):this.startRotation.type==="rotation"?o.rotation=0:o.rotation=this.startRotation.genValue(I.time/this.duration)}else if(this.rendererSettings.renderMode===hg.Trail){var s=C;s.length=this.rendererEmitterSettings.startLength.genValue(I.time/this.duration),s.reset()}if(this.emitterShape.initialize(C),this.rendererSettings.renderMode===hg.Trail&&this.rendererEmitterSettings.followLocalOrigin){var n=C;n.localPosition=new M().copy(n.position)}this.worldSpace?(C.position.applyMatrix4(e),C.velocity.applyMatrix3(this.normalMatrix),C.rotation&&C.rotation instanceof UA&&C.rotation.multiplyQuaternions(OR,C.rotation)):this.onlyUsedByOther&&(C.parentMatrix=e);for(var B=0;B<this.behaviors.length;B++)this.behaviors[B].initialize(C)}}},{key:"endEmit",value:function(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0)}},{key:"dispose",value:function(){this.renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter)}},{key:"restart",value:function(){this.paused=!1,this.particleNum=0,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.emitEnded=!1,this.markForDestroy=!1}},{key:"update",value:function(g){if(g>.1&&(g=.1),!this.paused){if(this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}this.neededToUpdateRender&&(this.renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(g,this.emissionState,this.emitter.matrixWorld);for(var I=0;I<this.behaviors.length;I++){for(var e=0;e<this.particleNum;e++)this.behaviors[I].update(this.particles[e],g);this.behaviors[I].frameUpdate(g)}for(var t=0;t<this.particleNum;t++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[t].localPosition?(this.particles[t].position.copy(this.particles[t].localPosition),this.particles[t].parentMatrix?this.particles[t].position.applyMatrix4(this.particles[t].parentMatrix):this.particles[t].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[t].position.addScaledVector(this.particles[t].velocity,g),this.particles[t].age+=g;if(this.rendererSettings.renderMode===hg.Trail)for(var C=0;C<this.particleNum;C++){var o=this.particles[C];o.recordCurrentState()}for(var s=0;s<this.particleNum;s++){var n=this.particles[s];n.age>=n.life&&(this.particles[s]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=n,this.particleNum--,s--)}}}},{key:"emit",value:function(g,I,e){if(I.time>this.duration&&(this.looping?(I.time-=this.duration,I.burstIndex=0):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(e),!this.emitEnded){var t=Math.ceil(I.waitEmiting);this.spawn(t,I,e),I.waitEmiting-=t}for(;I.burstIndex<this.emissionBursts.length&&this.emissionBursts[I.burstIndex].time<=I.time;){if(Math.random()<this.emissionBursts[I.burstIndex].probability){var C=this.emissionBursts[I.burstIndex].count;this.spawn(C,I,e)}I.burstIndex++}this.emitEnded||(I.waitEmiting+=g*this.emissionOverTime.genValue(I.time/this.duration)),I.time+=g}},{key:"toJSON",value:function(g){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=g===void 0||typeof g=="string";if(e&&(g={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),this.texture.toJSON(g),I.useUrlForImage&&this.texture.source!==void 0){var t=this.texture.source;g.images[t.uuid]={uuid:t.uuid,url:this.texture.image.url}}var C;this.renderMode===hg.Trail?C={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===hg.LocalSpace?C={}:C={};var o=this.rendererSettings.instancingGeometry;return g.geometries&&!g.geometries[o.uuid]&&(g.geometries[o.uuid]=o.toJSON()),{autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:C,speedFactor:this.renderMode===hg.StretchedBillBoard?this.speedFactor:0,texture:this.texture.uuid,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blending:this.blending,behaviors:this.behaviors.map(function(s){return s.toJSON()}),worldSpace:this.worldSpace}}},{key:"addBehavior",value:function(g){this.behaviors.push(g)}},{key:"getRendererSettings",value:function(){return this.rendererSettings}},{key:"clone",value:function(){var g=[],I=wR(this.emissionBursts),e;try{for(I.s();!(e=I.n()).done;){var t=e.value,C={};Object.assign(C,t),g.push(C)}}catch(a){I.e(a)}finally{I.f()}var o=[],s=wR(this.behaviors),n;try{for(s.s();!(n=s.n()).done;){var B=n.value;o.push(B.clone())}}catch(a){s.e(a)}finally{s.f()}var r;return this.renderMode===hg.Trail?r={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:r={},new i(this.renderer,{autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:g,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,rendererEmitterSettings:r,speedFactor:this.speedFactor,texture:this.texture,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blending:this.blending,behaviors:o,worldSpace:this.worldSpace})}}],[{key:"fromJSON",value:function(g,I,e,t){var C=YV(g.shape),o;g.renderMode===hg.Trail?o={startLength:qe(g.rendererEmitterSettings.startLength),followLocalOrigin:g.rendererEmitterSettings.followLocalOrigin}:g.renderMode===hg.LocalSpace?o={}:o={};var s=new i(t,{autoDestroy:g.autoDestroy,looping:g.looping,duration:g.duration,shape:C,startLife:qe(g.startLife),startSpeed:qe(g.startSpeed),startRotation:kV(g.startRotation),startSize:qe(g.startSize),startColor:Vq(g.startColor),emissionOverTime:qe(g.emissionOverTime),emissionOverDistance:qe(g.emissionOverDistance),emissionBursts:g.emissionBursts,onlyUsedByOther:g.onlyUsedByOther,instancingGeometry:I.geometries[g.instancingGeometry],renderMode:g.renderMode,rendererEmitterSettings:o,renderOrder:g.renderOrder,speedFactor:g.speedFactor,texture:I.textures[g.texture],startTileIndex:typeof g.startTileIndex=="number"?new ni(g.startTileIndex):qe(g.startTileIndex),uTileCount:g.uTileCount,vTileCount:g.vTileCount,blending:g.blending,behaviors:[],worldSpace:g.worldSpace});return s.behaviors=g.behaviors.map(function(n){var B=vV(n,s);return B.type==="EmitSubParticleSystem"&&(e[n.subParticleSystem]=B),B}),s}}]),i}(),_R=`
@@ -450,22 +450,23 @@ export class Text extends Graphic {
450
450
  return null;
451
451
  let fontName = this.font;
452
452
  // if a font path has a known suffix we remove it
453
- if (fontName.endsWith("-regular")) {
453
+ const fontNameLower = fontName.toLowerCase();
454
+ if (fontNameLower.endsWith("-regular")) {
454
455
  if (style === FontStyle.Normal)
455
456
  return resolveUrl(this.sourceId, fontName);
456
457
  fontName = fontName.substring(0, fontName.length - "-regular".length);
457
458
  }
458
- else if (fontName.endsWith("-bold")) {
459
+ else if (fontNameLower.endsWith("-bold")) {
459
460
  if (style === FontStyle.Bold)
460
461
  return resolveUrl(this.sourceId, fontName);
461
462
  fontName = fontName.substring(0, fontName.length - "-bold".length);
462
463
  }
463
- else if (fontName.endsWith("-italic")) {
464
+ else if (fontNameLower.endsWith("-italic")) {
464
465
  if (style === FontStyle.Italic)
465
466
  return resolveUrl(this.sourceId, fontName);
466
467
  fontName = fontName.substring(0, fontName.length - "-italic".length);
467
468
  }
468
- else if (fontName.endsWith("-bolditalic")) {
469
+ else if (fontNameLower.endsWith("-bolditalic")) {
469
470
  if (style === FontStyle.BoldAndItalic)
470
471
  return resolveUrl(this.sourceId, fontName);
471
472
  fontName = fontName.substring(0, fontName.length - "-bolditalic".length);