@needle-tools/engine 3.36.1-beta โ†’ 3.36.2-beta

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.
@@ -4341,7 +4341,7 @@ void main() {
4341
4341
  `;a+=n(o);const l=Object.keys(r);let c="";for(let u=0;u<l.length;u++){const d=l[u],f=r[d];if(Dm.has(f)){c+="";continue}Dm.set(f,!0),c+=d+":"+i(f,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
4342
4342
  `,c+=n(o),a+=c,c="")}return a+=c,a+=`
4343
4343
  }`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const dY=ne("nodevlogs");function un(s,e=co.Log){sl(e,s)}function tn(s){un(s,co.Warn)}function DI(s){un(s,co.Error)}let B1;function At(){return dY?!1:B1!==void 0?B1:Hr()}function fY(s){B1=s}const fu=new bd,Js=new w,Vc=new w,Ki=new Ce,H2={X:new w(1,0,0),Y:new w(0,1,0),Z:new w(0,0,1)},rC={type:"change"},Q2={type:"mouseDown"},V2={type:"mouseUp",mode:null},W2={type:"objectChange"};class pY extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const i=new OI;this._gizmo=i,this.add(i);const n=new _Y;this._plane=n,this.add(n);const r=this;function o(_,y){let b=y;Object.defineProperty(r,_,{get:function(){return b!==void 0?b:y},set:function(E){b!==E&&(b=E,n[_]=E,i[_]=E,r.dispatchEvent({type:_+"-changed",value:E}),r.dispatchEvent(rC))}}),r[_]=y,n[_]=y,i[_]=y}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new w,l=new w,c=new Ce,u=new Ce,d=new w,f=new Ce,p=new w,m=new w,A=new w,v=0,g=new w;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",p),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new w,this._startNorm=new w,this._endNorm=new w,this._cameraScale=new w,this._parentPosition=new w,this._parentQuaternion=new Ce,this._parentQuaternionInv=new Ce,this._parentScale=new w,this._worldScaleStart=new w,this._worldQuaternionInv=new Ce,this._worldScale=new w,this._positionStart=new w,this._quaternionStart=new Ce,this._scaleStart=new w,this._getPointer=mY.bind(this),this._onPointerDown=vY.bind(this),this._onPointerHover=gY.bind(this),this._onPointerMove=AY.bind(this),this._onPointerUp=yY.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&fu.setFromCamera(e,this.camera);const t=oC(this._gizmo.picker[this.mode],fu);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&fu.setFromCamera(e,this.camera);const t=oC(this._plane,fu,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Q2.mode=this.mode,this.dispatchEvent(Q2)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&fu.setFromCamera(e,this.camera);const o=oC(this._plane,fu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(Ki.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(Js.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Js.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Vc.set(a,a,a)}else Js.copy(this.pointStart),Vc.copy(this.pointEnd),Js.applyQuaternion(this._worldQuaternionInv),Vc.applyQuaternion(this._worldQuaternionInv),Vc.divide(Js),t.search("X")===-1&&(Vc.x=1),t.search("Y")===-1&&(Vc.y=1),t.search("Z")===-1&&(Vc.z=1);n.scale.copy(this._scaleStart).multiply(Vc),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Js.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Js.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(H2[t]),Js.copy(H2[t]),r==="local"&&Js.applyQuaternion(this.worldQuaternion),Js.cross(this.eye),Js.length()===0?l=!0:this.rotationAngle=this._offset.dot(Js.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(Ki.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Ki.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(rC),this.dispatchEvent(W2)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(V2.mode=this.mode,this.dispatchEvent(V2)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(rC),this.dispatchEvent(W2),this.pointStart.copy(this.pointEnd))}getRaycaster(){return fu}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function mY(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function gY(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function vY(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function AY(s){this.enabled&&this.pointerMove(this._getPointer(s))}function yY(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function oC(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const w0=new Vi,Pi=new w(0,1,0),j2=new w(0,0,0),q2=new we,S0=new Ce,C_=new Ce,La=new w,X2=new we,hg=new w(1,0,0),Ru=new w(0,1,0),ug=new w(0,0,1),C0=new w,Om=new w,Lm=new w;class OI extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new ci({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Bn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const A=new Mn(0,.04,.1,12);A.translate(0,.05,0);const v=new ki(.08,.08,.08);v.translate(0,.04,0);const g=new mt;g.setAttribute("position",new ut([0,0,0,1,0,0],3));const _=new Mn(.0075,.0075,.5,3);_.translate(0,.25,0);function y(V,L){const k=new $l(V,.0075,3,64,L*Math.PI*2);return k.rotateY(Math.PI/2),k.rotateX(Math.PI/2),k}function b(){const V=new mt;return V.setAttribute("position",new ut([0,0,0,1,1,1],3)),V}const E={X:[[new de(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new de(A,r),[-.5,0,0],[0,0,Math.PI/2]],[new de(_,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new de(A,o),[0,.5,0]],[new de(A,o),[0,-.5,0],[Math.PI,0,0]],[new de(_,o)]],Z:[[new de(A,a),[0,0,.5],[Math.PI/2,0,0]],[new de(A,a),[0,0,-.5],[-Math.PI/2,0,0]],[new de(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new de(new oc(.1,0),d.clone()),[0,0,0]]],XY:[[new de(new ki(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new de(new ki(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new de(new Mn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new de(new Mn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new de(new Mn(.2,0,.6,4),i),[0,.3,0]],[new de(new Mn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new de(new Mn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new de(new Mn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new de(new oc(.2,0),i)]],XY:[[new de(new ki(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new de(new ki(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},T={START:[[new de(new oc(.01,2),n),null,null,null,"helper"]],END:[[new de(new oc(.01,2),n),null,null,null,"helper"]],DELTA:[[new In(b(),n),null,null,null,"helper"]],X:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new In(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new In(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new de(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new de(y(.5,.5),r)]],Y:[[new de(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new de(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new de(y(.75,1),f),null,[0,Math.PI/2,0]]]},B={AXIS:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new de(new Ta(.25,10,8),i)]],X:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new de(new $l(.75,.1,2,24),i)]]},I={X:[[new de(v,r),[.5,0,0],[0,0,-Math.PI/2]],[new de(_,r),[0,0,0],[0,0,-Math.PI/2]],[new de(v,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new de(v,o),[0,.5,0]],[new de(_,o)],[new de(v,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new de(v,a),[0,0,.5],[Math.PI/2,0,0]],[new de(_,a),[0,0,0],[Math.PI/2,0,0]],[new de(v,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new de(new ki(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new de(new ki(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new de(new ki(.1,.1,.1),d.clone())]]},Q={X:[[new de(new Mn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new de(new Mn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new de(new Mn(.2,0,.6,4),i),[0,.3,0]],[new de(new Mn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new de(new Mn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new de(new Mn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new de(new ki(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new de(new ki(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new de(new ki(.2,.2,.2),i),[0,0,0]]]},N={X:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new In(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new In(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function O(V){const L=new ge;for(const k in V)for(let G=V[k].length;G--;){const J=V[k][G][0].clone(),$=V[k][G][1],re=V[k][G][2],ce=V[k][G][3],Re=V[k][G][4];J.name=k,J.tag=Re,$&&J.position.set($[0],$[1],$[2]),re&&J.rotation.set(re[0],re[1],re[2]),ce&&J.scale.set(ce[0],ce[1],ce[2]),J.updateMatrix();const ie=J.geometry.clone();ie.applyMatrix4(J.matrix),J.geometry=ie,J.renderOrder=1/0,J.position.set(0,0,0),J.rotation.set(0,0,0),J.scale.set(1,1,1),L.add(J)}return L}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=O(E)),this.add(this.gizmo.rotate=O(C)),this.add(this.gizmo.scale=O(I)),this.add(this.picker.translate=O(M)),this.add(this.picker.rotate=O(S)),this.add(this.picker.scale=O(Q)),this.add(this.helper.translate=O(T)),this.add(this.helper.rotate=O(B)),this.add(this.helper.scale=O(N)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:C_;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const o=n[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Ki.setFromEuler(w0.set(0,0,0)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(hg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Ki.setFromEuler(w0.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Ki.setFromEuler(w0.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(ug).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Ki.setFromEuler(w0.set(0,Math.PI/2,0)),Pi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(q2.lookAt(j2,Pi,Ru)),o.quaternion.multiply(Ki),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Js.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Js.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Js),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Pi.copy(hg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Pi.copy(ug).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Pi.copy(ug).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Pi.copy(hg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(S0.copy(i),Pi.copy(this.eye).applyQuaternion(Ki.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(q2.lookAt(this.eye,j2,Ru)),o.name==="X"&&(Ki.setFromAxisAngle(hg,Math.atan2(-Pi.y,Pi.z)),Ki.multiplyQuaternions(S0,Ki),o.quaternion.copy(Ki)),o.name==="Y"&&(Ki.setFromAxisAngle(Ru,Math.atan2(Pi.x,Pi.z)),Ki.multiplyQuaternions(S0,Ki),o.quaternion.copy(Ki)),o.name==="Z"&&(Ki.setFromAxisAngle(ug,Math.atan2(Pi.y,Pi.x)),Ki.multiplyQuaternions(S0,Ki),o.quaternion.copy(Ki))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class _Y extends de{constructor(){super(new Gn(1e5,1e5,2,2),new ci({visible:!1,wireframe:!0,side:mi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),C0.copy(hg).applyQuaternion(t==="local"?this.worldQuaternion:C_),Om.copy(Ru).applyQuaternion(t==="local"?this.worldQuaternion:C_),Lm.copy(ug).applyQuaternion(t==="local"?this.worldQuaternion:C_),Pi.copy(Om),this.mode){case"translate":case"scale":switch(this.axis){case"X":Pi.copy(this.eye).cross(C0),La.copy(C0).cross(Pi);break;case"Y":Pi.copy(this.eye).cross(Om),La.copy(Om).cross(Pi);break;case"Z":Pi.copy(this.eye).cross(Lm),La.copy(Lm).cross(Pi);break;case"XY":La.copy(Lm);break;case"YZ":La.copy(C0);break;case"XZ":Pi.copy(Lm),La.copy(Om);break;case"XYZ":case"E":La.set(0,0,0);break}break;case"rotate":default:La.set(0,0,0)}La.length()===0?this.quaternion.copy(this.cameraQuaternion):(X2.lookAt(Js.set(0,0,0),La,Pi),this.quaternion.setFromRotationMatrix(X2)),super.updateMatrixWorld(e)}}const bY=ne("debugpatch");function Jx(s,e,t,i){const n=bY===e;if(!t&&!i)return;const r=e+"___needle";wY(s,e,t,i);const o=Object.getOwnPropertyDescriptor(s,e),a=s[e];n&&console.log("Patch",s.constructor.name,e,o,a),o?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,e,o),typeof o.value=="function"&&(s[e]=J2(o.value,s,e))):(n&&console.log("Create patch with new property",s.constructor.name,e,o),Object.defineProperty(s,e,{set:function(l){if(typeof l=="function")this[r]=J2(l,s,e);else{const c=this[r];kN(s,e,this,c,l),this[r]=l,FN(s,e,this,c,l)}},get:function(){const l=this[r];return typeof l=="function"&&l[r]?l[r]:l}}))}function xY(s,e,t){const i=LI(s,e);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(n,1)}}const Y2=Symbol("Needle:Patches:WrappedFunction");function J2(s,e,t){if(s[Y2])return s;const i=function(...n){kN(e,t,this,...n);const r=s.apply(this,n);return FN(e,t,this,r,...n),r};return i[Y2]=!0,i}const E_="Needle:Patches";function D1(){return globalThis[E_]||(globalThis[E_]=new WeakMap),globalThis[E_]}function LI(s,e){const t=D1().get(s);return t?t.get(e):null}function wY(s,e,t,i){let n=D1().get(s);n||(n=new Map,D1().set(s,n));let r=n.get(e);r||(r=[],n.set(e,r)),r.push({prefix:t,postfix:i})}function kN(s,e,t,...i){var r;if(!t)return;const n=LI(s,e);if(n)for(const o of n)(r=o.prefix)==null||r.call(t,...i)}function FN(s,e,t,i,...n){var o;if(!t)return;const r=LI(s,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...n)}const K2=Symbol("gltf-loader-internal-usage-tracker"),SY=ne("debugusers"),iv=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return iv._loadingProcesses>0}beforeRoot(){iv._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const r=t.call(this,i,n);return r.then(o=>(o&&(e._loadedObjects.add(o),o[K2]=e._loadingId),o)),r},null}afterRoot(e){iv._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[K2],t instanceof ge&&(t.parent||t instanceof de&&setTimeout(()=>{SY&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}};let kg=iv;h(kg,"_loadingProcesses",0);class UN{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const n=t[0];n&&n.tagName==="IMG"&&(console.warn(`Could not load image:
4344
- `+n.src),e.preventDefault())}})}}const Kx=ne("trackresources");function NN(){return Kx==="dispose"}let wd=!0;Kx===0&&(wd=!1);function CY(s){wd=s}function zN(){return wd}const GN=Symbol("disposable");function kI(s,e){s&&(s[GN]=e,Ju&&console.warn("Set disposable",e,s))}const HN=Symbol("disposed");function EY(s){return s[HN]===!0}function Oi(s){var e;if(s){if(s[GN]===!1){Ju&&console.warn("Object is marked as not disposable",s);return}if(s[HN]=!0,s instanceof ir)Oi(s.environment),Oi(s.background),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial);else if(s instanceof Ho)Oi(s.geometry),Oi(s.material),Oi(s.skeleton),Oi(s.bindMatrix),Oi(s.bindMatrixInverse),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof de)Oi(s.geometry),Oi(s.material),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof mt){_f(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Oi(i)}}else if(s instanceof tt||s instanceof wr)Ju&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Ot&&Oi(t);else if(s instanceof Ot){_f(s);for(const i of Object.keys(s)){const n=s[i];n instanceof xt&&(Oi(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof xt?(Oi(n),t[i]=null):n instanceof _e&&(Oi(n.value),n.value=null)}}else s instanceof xt?(_f(s),_f(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&_f(s.source.data)):s instanceof Hp?(_f(s.boneTexture),s.boneTexture=null):s instanceof aA||!(s instanceof ge)&&Ju&&console.warn("Unknown object type",s)}}function _f(s){s&&((Ju||NN()||Kx)&&console.warn("๐Ÿงจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof rc?s.data=null:s.dispose())}function QN(s){(s instanceof de||s instanceof Ho)&&(s.material=null,s.geometry=null)}const MY=new Set;function Zx(s,e,t=null,i){if(i||(i=MY,i.clear()),!s)return i;const n=s[Rv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&Zx(r,!0,t,i));return i}function TY(s){return s[dg]}const Ju=ne("debugresourceusers")||ne("debugmemory"),Rv=Symbol("needle-resource-users"),dg=Symbol("needle-resource-users-count");function cr(s,e){Jx(s,e,function(t,i){wd&&(wb(Rv,this,t,!1),wb(Rv,this,i,!0))})}wd&&(cr(de.prototype,"material"),cr(de.prototype,"geometry"),cr(Ot.prototype,"map"),cr(Ot.prototype,"bumpMap"),cr(Ot.prototype,"alphaMap"),cr(Ot.prototype,"normalMap"),cr(Ot.prototype,"displacementMap"),cr(Ot.prototype,"roughnessMap"),cr(Ot.prototype,"metalnessMap"),cr(Ot.prototype,"emissiveMap"),cr(Ot.prototype,"specularMap"),cr(Ot.prototype,"envMap"),cr(Ot.prototype,"lightMap"),cr(Ot.prototype,"aoMap"),cr(Ot.prototype,"gradientMap"));function IY(s){if(wd===!1)return;const e=s[Rv];if(e)for(const t of e)wb(Rv,t,s,!1)}wd&&Jx(Ot.prototype,"dispose",function(){IY(this)});let O1=0;function wb(s,e,t,i){if(O1>0)return;if(Array.isArray(t)){for(const r of t)wb(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[dg]||0;r+=1,t[dg]=r,Ju&&console.warn(`๐ŸŸข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[dg]||0;r>0&&(r-=1,t[dg]=r),Ju&&console.warn(`๐Ÿ”ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(kg.isLoading(t)||(Kx&&console.warn(`๐Ÿ”ด Removed all user of "${t.type}"`,t),NN()&&Oi(t)))}t[s]=n}try{Jx(xc.prototype,"render",function(){O1++},function(){O1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var yA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(yA||{});const Z2=ne("debugcomponentevents");class _A{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),Z2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(Z2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(_A,"eventListeners",new Map);const VN=ne("debugdefines");Wp('if(!globalThis[""3.36.1-beta""]) globalThis[""3.36.1-beta""] = "0.0.0";');Wp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Wp('if(!globalThis[""Wed Apr 03 2024 09:14:19 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 03 2024 09:14:19 GMT+0200 (Central European Summer Time)""] = "unknown";');Wp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.1-beta";');Wp('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Wp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 03 2024 09:14:19 GMT+0200 (Central European Summer Time)";');const ol="3.36.1-beta",$x="undefined",FI="Wed Apr 03 2024 09:14:19 GMT+0200 (Central European Summer Time)";VN&&console.log(`Engine version: ${ol} (generator: ${$x})
4344
+ `+n.src),e.preventDefault())}})}}const Kx=ne("trackresources");function NN(){return Kx==="dispose"}let wd=!0;Kx===0&&(wd=!1);function CY(s){wd=s}function zN(){return wd}const GN=Symbol("disposable");function kI(s,e){s&&(s[GN]=e,Ju&&console.warn("Set disposable",e,s))}const HN=Symbol("disposed");function EY(s){return s[HN]===!0}function Oi(s){var e;if(s){if(s[GN]===!1){Ju&&console.warn("Object is marked as not disposable",s);return}if(s[HN]=!0,s instanceof ir)Oi(s.environment),Oi(s.background),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial);else if(s instanceof Ho)Oi(s.geometry),Oi(s.material),Oi(s.skeleton),Oi(s.bindMatrix),Oi(s.bindMatrixInverse),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof de)Oi(s.geometry),Oi(s.material),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof mt){_f(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Oi(i)}}else if(s instanceof tt||s instanceof wr)Ju&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Ot&&Oi(t);else if(s instanceof Ot){_f(s);for(const i of Object.keys(s)){const n=s[i];n instanceof xt&&(Oi(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof xt?(Oi(n),t[i]=null):n instanceof _e&&(Oi(n.value),n.value=null)}}else s instanceof xt?(_f(s),_f(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&_f(s.source.data)):s instanceof Hp?(_f(s.boneTexture),s.boneTexture=null):s instanceof aA||!(s instanceof ge)&&Ju&&console.warn("Unknown object type",s)}}function _f(s){s&&((Ju||NN()||Kx)&&console.warn("๐Ÿงจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof rc?s.data=null:s.dispose())}function QN(s){(s instanceof de||s instanceof Ho)&&(s.material=null,s.geometry=null)}const MY=new Set;function Zx(s,e,t=null,i){if(i||(i=MY,i.clear()),!s)return i;const n=s[Rv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&Zx(r,!0,t,i));return i}function TY(s){return s[dg]}const Ju=ne("debugresourceusers")||ne("debugmemory"),Rv=Symbol("needle-resource-users"),dg=Symbol("needle-resource-users-count");function cr(s,e){Jx(s,e,function(t,i){wd&&(wb(Rv,this,t,!1),wb(Rv,this,i,!0))})}wd&&(cr(de.prototype,"material"),cr(de.prototype,"geometry"),cr(Ot.prototype,"map"),cr(Ot.prototype,"bumpMap"),cr(Ot.prototype,"alphaMap"),cr(Ot.prototype,"normalMap"),cr(Ot.prototype,"displacementMap"),cr(Ot.prototype,"roughnessMap"),cr(Ot.prototype,"metalnessMap"),cr(Ot.prototype,"emissiveMap"),cr(Ot.prototype,"specularMap"),cr(Ot.prototype,"envMap"),cr(Ot.prototype,"lightMap"),cr(Ot.prototype,"aoMap"),cr(Ot.prototype,"gradientMap"));function IY(s){if(wd===!1)return;const e=s[Rv];if(e)for(const t of e)wb(Rv,t,s,!1)}wd&&Jx(Ot.prototype,"dispose",function(){IY(this)});let O1=0;function wb(s,e,t,i){if(O1>0)return;if(Array.isArray(t)){for(const r of t)wb(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[dg]||0;r+=1,t[dg]=r,Ju&&console.warn(`๐ŸŸข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[dg]||0;r>0&&(r-=1,t[dg]=r),Ju&&console.warn(`๐Ÿ”ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(kg.isLoading(t)||(Kx&&console.warn(`๐Ÿ”ด Removed all user of "${t.type}"`,t),NN()&&Oi(t)))}t[s]=n}try{Jx(xc.prototype,"render",function(){O1++},function(){O1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var yA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(yA||{});const Z2=ne("debugcomponentevents");class _A{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),Z2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(Z2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(_A,"eventListeners",new Map);const VN=ne("debugdefines");Wp('if(!globalThis[""3.36.2-beta""]) globalThis[""3.36.2-beta""] = "0.0.0";');Wp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Wp('if(!globalThis[""Wed Apr 03 2024 13:37:08 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 03 2024 13:37:08 GMT+0200 (Central European Summer Time)""] = "unknown";');Wp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.2-beta";');Wp('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Wp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 03 2024 13:37:08 GMT+0200 (Central European Summer Time)";');const ol="3.36.2-beta",$x="undefined",FI="Wed Apr 03 2024 13:37:08 GMT+0200 (Central European Summer Time)";VN&&console.log(`Engine version: ${ol} (generator: ${$x})
4345
4345
  Project built at ${FI}`);const dc="needle_isActiveInHierarchy",Du="builtin_components",Fg="needle_editor_guid";function Wp(s){try{(0,eval)(s)}catch(e){VN&&console.error(e)}}const Pv=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),WN=Symbol("isUsingInstancing"),jN=Symbol("instancingRenderer"),fg=Symbol("instancingAutoUpdateBounds");class Qo{static isUsingInstancing(e){return e[WN]===!0}static getRenderer(e){return e[jN]||null}setAutoUpdateBounds(e,t){const i=Qo.getRenderer(e);i&&(i[fg]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[Pv]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)Qo.markDirty(i,!0)}}function Ku(s,e){try{e?s(e):s()}catch(t){return console.error(t),!1}return!0}const L1=ne("debugnewscripts"),RY=ne("debughierarchy"),Yi=[];function PY(){return Yi.length>0}function Sb(s){if(!(s.new_scripts.length<=0)){if(L1&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}Yi.length=0,s.new_scripts.length>0&&Yi.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.isComponent!==!0){(At()||L1)&&console.error(`Registered script is not a Needle Engine component.
4346
4346
  The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
4347
4347
  `,t),Yi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Yi.splice(e,1),e--;continue}t.context=s,Ug(t.gameObject),UI(t,s)}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed){ec(Yi[e],s),Yi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),Ug(t.gameObject),t.activeAndEnabled&&Ku(t.__internalAwake.bind(t)))}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed||t.enabled===!1||(Ug(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,Ku(t.__internalEnable.bind(t)))}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed||!t.gameObject)continue;s.new_script_start.push(t)}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}Yi.length=0;for(const e of s.new_scripts_post_setup_callbacks)e&&e();s.new_scripts_post_setup_callbacks.length=0}}function BY(s){s&&(s.__internalDisable(!0),ec(s,s.context))}function qN(s,e){for(let t=0;t<s.new_script_start.length;t++)try{const i=s.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;Ku(i.__internalAwake.bind(i)),i.enabled&&(Ku(i.__internalEnable.bind(i)),Ku(i.__internalStart.bind(i)),s.new_script_start.splice(t,1),t--)}catch(i){console.error(i),ec(s.new_script_start[t],s),s.new_script_start.splice(t,1),t--}}function UI(s,e){e.scripts.indexOf(s)===-1&&(e.scripts.push(s),s.earlyUpdate&&e.scripts_earlyUpdate.push(s),s.update&&e.scripts_update.push(s),s.lateUpdate&&e.scripts_lateUpdate.push(s),s.onBeforeRender&&e.scripts_onBeforeRender.push(s),s.onAfterRender&&e.scripts_onAfterRender.push(s),s.onPausedChanged&&e.scripts_pausedChanged.push(s),aC(s,null)&&e.new_scripts_xr.push(s),aC(s,"immersive-vr")&&e.scripts_immersive_vr.push(s),aC(s,"immersive-ar")&&e.scripts_immersive_ar.push(s))}function ec(s,e){Mo(s,e.new_scripts),Mo(s,e.new_script_start),Mo(s,e.scripts),Mo(s,e.scripts_earlyUpdate),Mo(s,e.scripts_update),Mo(s,e.scripts_lateUpdate),Mo(s,e.scripts_onBeforeRender),Mo(s,e.scripts_onAfterRender),Mo(s,e.scripts_pausedChanged),Mo(s,e.new_scripts_xr),Mo(s,e.scripts_immersive_vr),Mo(s,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(s)}function Mo(s,e){const t=e.indexOf(s);t>=0&&e.splice(t,1)}function aC(s,e){var t;if(s){const i=s;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(e!=null&&((t=i.supportsXR)==null?void 0:t.call(i,e))===!1)}return!1}function M_(s){if(s||(s=oi.Current.scene),!s){console.trace("Invalid call - no current context.");return}const e=Xp(s);XN(s,e,!0)||(L1||At()?console.error(`Error updating hierarchy
@@ -6213,7 +6213,7 @@ Texture:`,i),this.setLightmapDebugMaterial()),this.applyLightmap())}updateLightm
6213
6213
  gl_FragColor = lightMapTexel;
6214
6214
  gl_FragColor.a = 1.;
6215
6215
  }
6216
- `,defines:{USE_LIGHTMAP:""}})}}var cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,Mc=(s,e,t,i)=>{for(var n=i>1?void 0:i?hre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cre(e,t,n),n};const wg=ne("debugrenderer"),ure=ne("debugskinnedmesh"),nL=ne("noinstancing"),_u=ne("debugprogressive"),sL=ne("noprogressive"),dre=ne("wireframe");class VR{constructor(){h(this,"path",null);h(this,"asset",null);h(this,"default")}}class fre{constructor(e,t){h(this,"_renderer");h(this,"_targets",[]);h(this,"_indexMapMaxIndex");h(this,"_indexMap");h(this,"_changed",!1);this._renderer=e;const i=this.setMaterial.bind(this),n=this.getMaterial.bind(this),r=e.gameObject;if(this._targets=[],r)switch(r.type){case"Group":this._targets=[...r.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(r);break}let o=!1,a,l=0;for(let c=0;c<this._targets.length;c++){const u=this._targets[c];if(!u)continue;const d=u.material;if(d){d.shadowSide=d.side;for(let f=0;f<t.length;f++){const p=t[f];if(!p){o=!0;continue}if(d.name===p.name){a===void 0&&(a=new Map),a.set(f,c),l=Math.max(l,f);break}}}}if(o){this._indexMapMaxIndex=l,this._indexMap=a;const c=`Renderer ${e.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(c),Hr()&&tn("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(c,u){if(typeof u=="string"){const d=parseInt(u);if(!isNaN(d))return n(d)}return c[u]},set(c,u,d){return typeof u=="string"&&i(d,Number.parseInt(u)),Reflect.set(c,u,d)?(d instanceof Ot&&(c.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(e){e===!0&&wg&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=e}is(e){return this._renderer===e}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.getMaterial(e)}resolveIndex(e){const t=this._indexMap;return t&&t.has(e)?t.get(e):e}setMaterial(e,t){if(t=this.resolveIndex(t),t<0||t>=this._targets.length)return;const i=this._targets[t];!i||i.material===void 0||(i.material=e,this.changed=!0)}getMaterial(e){if(e=this.resolveIndex(e),e<0)return null;const t=this._targets;if(e>=t.length)return null;const i=t[e];return i?i.material:null}}var DE;const Sg=(DE=class extends Me{constructor(){super(...arguments);h(this,"receiveShadows",!1);h(this,"shadowCastingMode",0);h(this,"lightmapIndex",-1);h(this,"lightmapScaleOffset",new Ze(1,1,0,0));h(this,"enableInstancing");h(this,"renderOrder");h(this,"allowOcclusionWhenDynamic",!0);h(this,"probeAnchor");h(this,"reflectionProbeUsage",0);h(this,"_lightmaps");h(this,"_sharedMeshes",[]);h(this,"_sharedMaterials");h(this,"_originalMaterials");h(this,"_lightmapTextureOverride");h(this,"allowProgressiveLoading",!0);h(this,"_firstFrame",-1);h(this,"_isInstancingEnabled",!1);h(this,"handles");h(this,"_wasVisible",!1);h(this,"onBeforeRenderThree",(e,t,i,n,r,o)=>{var a;if(!this._wasVisible&&this.context.time.frame>this._firstFrame+1&&(_u&&console.debug("onBeforeRenderThree: Object becomes visible for the first time",this.name,this.context.time.frame),this._wasVisible=!0),r.envMapIntensity!==void 0){const l=this.hasLightmap?Math.PI:1,c=((a=this.context.mainCameraComponent)==null?void 0:a.environmentIntensity)??1;r.envMapIntensity=Math.max(0,c*this.context.sceneLighting.environmentIntensity/l)}if(this._lightmaps)for(const l of this._lightmaps)l.updateLightmapUniforms(r)});h(this,"automaticallyUpdateLODLevel",!0);h(this,"hasTextureLODs",!0);h(this,"hasMeshLODs",!0);h(this,"_lastLodLevel",-1);h(this,"_nextLodTestTime",0);h(this,"_randomLodLevelCheckFrameOffset",Math.floor(Math.random()*100));h(this,"_sphere",new wn);h(this,"_box",new xi);h(this,"_reflectionProbe",null)}static setInstanced(e,t){const i=TA(e,Sg);return i.setInstancingEnabled(t),i}static isInstanced(e){const t=Cd(e,Sg);return t?t.isInstancingActive:Qo.isUsingInstancing(e)}static setVisible(e,t){Nf(e,t)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const e of this.gameObject.children)(e.type==="Mesh"||e.type==="SkinnedMesh")&&this._sharedMeshes.push(e);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(e){this.sharedMaterials[0]!==e&&(this.sharedMaterials[0]=e,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(e){this.sharedMaterial=e}set sharedMaterials(e){if(!this._originalMaterials)this._originalMaterials=e;else if(e){let t=!1;for(let i=0;i<this._sharedMaterials.length;i++){const n=i<e.length?e[i]:null;n&&n instanceof Ot?this.sharedMaterials[i]=n:t||(t=!0,console.warn("Can not assign null as material: "+this.name,n))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new fre(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return nL}get lightmap(){var e;return(e=this._lightmaps)!=null&&e.length?this._lightmaps[0].lightmap:null}set lightmap(e){var t;if(this._lightmapTextureOverride=e,e===void 0&&(e=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(t=this._lightmaps)!=null&&t.length)for(const i of this._lightmaps)i.lightmap=e}get hasLightmap(){const e=this.lightmap;return e!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(this._firstFrame=this.context.time.frame,wg&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&wg&&this.probeAnchor.add(new Wo(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const e of this.gameObject.children)this.context.addBeforeRenderListener(e,this.onBeforeRenderThree),e.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let e=0;for(let t=0;t<this.gameObject.children.length;t++){const i=this.gameObject.children[t];if(!(!this.isMeshOrSkinnedMesh(i)||oe.getComponent(i,Sg))){if(this.renderOrder.length<=e){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+e,"ChildElement:",i);continue}i.renderOrder=this.renderOrder[e],e+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),dre)for(let e=0;e<this.sharedMaterials.length;e++){const t=this.sharedMaterials[e];t&&(t.wireframe=!0)}}applyLightmapping(){var e;if(this.lightmapIndex>=0){const t=this.gameObject.type,i=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(i){if(this._lightmaps||(this._lightmaps=[]),t==="Mesh"){const n=this.gameObject.material;if(n!=null&&n.isMeshBasicMaterial)n&&console.warn("Lightmapping is not supported on MeshBasicMaterial",n.name);else{if(this._lightmaps.length<=0){const o=new Qv(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,i)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let n=0;n<this.gameObject.children.length;n++){const r=this.gameObject.children[n];if(!((e=r.material)!=null&&e.isMeshBasicMaterial)){let o;n>=this._lightmaps.length?(o=new Qv(r,this.context),this._lightmaps.push(o)):o=this._lightmaps[n],o.init(this.lightmapIndex,this.lightmapScaleOffset,i)}}}else wg&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}get isInstancingActive(){return this.handles!=null&&this.handles.length>0&&this._isInstancingEnabled}setInstancingEnabled(e){if(this._isInstancingEnabled===e)return e&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=e,e){if(this.enableInstancing===void 0&&(this.enableInstancing=!0),this.handles===void 0){if(this.handles=id.instance.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return oe.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const t of this.handles)t.updateInstanceMatrix(!0),t.add();return oe.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const t of this.handles)t.remove(this.destroyed);return!0}return!1}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!nL&&(this.setInstancingEnabled(!0),Qo.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];t.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled||this.enableInstancing?this.__internalDidAwakeAndStart&&this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe(),this.testIfLODLevelsAreAvailable()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const e of this.gameObject.children)this.context.removeBeforeRenderListener(e,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}onBeforeRender(){var e,t;if(this.gameObject){if(wg==this.name&&this.gameObject instanceof de){this.gameObject.geometry.computeBoundingSphere();const i=cn(this.gameObject.geometry.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);Ct.DrawWireSphere(i,this.gameObject.geometry.boundingSphere.radius,56831)}if(this.isMultiMaterialObject(this.gameObject)&&((e=this.gameObject.children)==null?void 0:e.length)>0)for(const i of this.gameObject.children)this.applySettings(i);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(t=this.handles)!=null&&t.length&&this.gameObject[Pv]===!0){this.gameObject[Pv]=!1;for(let n=this.handles.length-1;n>=0;n--)this.handles[n].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&oe.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let i=0;i<this.handles.length;i++){const n=this.handles[i];Nf(n.object,!1)}this._wasVisible&&this.allowProgressiveLoading&&this.automaticallyUpdateLODLevel&&this.updateLODs(),this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const t=this.handles[e];this._wasVisible=!0,Nf(t.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this),_u&&this._lastLodLevel>=0&&this.drawGizmoLodLevel(!1)}testIfLODLevelsAreAvailable(){this.automaticallyUpdateLODLevel=!1,this.hasMeshLODs=!1,this.hasTextureLODs=!1;for(const e of this.sharedMeshes)if(Di.hasLODLevelAvailable(e)){this.automaticallyUpdateLODLevel=!0,this.hasMeshLODs=!0;break}for(const e of this.sharedMaterials)if(e&&Di.hasLODLevelAvailable(e)){this.automaticallyUpdateLODLevel=!0,this.hasTextureLODs=!0;break}_u&&console.log(`${this.name}
6216
+ `,defines:{USE_LIGHTMAP:""}})}}var cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,Mc=(s,e,t,i)=>{for(var n=i>1?void 0:i?hre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cre(e,t,n),n};const wg=ne("debugrenderer"),ure=ne("debugskinnedmesh"),nL=ne("noinstancing"),_u=ne("debugprogressive"),sL=ne("noprogressive"),dre=ne("wireframe");class VR{constructor(){h(this,"path",null);h(this,"asset",null);h(this,"default")}}class fre{constructor(e,t){h(this,"_renderer");h(this,"_targets",[]);h(this,"_indexMapMaxIndex");h(this,"_indexMap");h(this,"_changed",!1);this._renderer=e;const i=this.setMaterial.bind(this),n=this.getMaterial.bind(this),r=e.gameObject;if(this._targets=[],r)switch(r.type){case"Group":this._targets=[...r.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(r);break}let o=!1,a,l=0;for(let c=0;c<this._targets.length;c++){const u=this._targets[c];if(!u)continue;const d=u.material;if(d){d.shadowSide=d.side;for(let f=0;f<t.length;f++){const p=t[f];if(!p){o=!0;continue}if(d.name===p.name){a===void 0&&(a=new Map),a.set(f,c),l=Math.max(l,f);break}}}}if(o){this._indexMapMaxIndex=l,this._indexMap=a;const c=`Renderer ${e.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(c),Hr()&&tn("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(c,u){if(typeof u=="string"){const d=parseInt(u);if(!isNaN(d))return n(d)}return c[u]},set(c,u,d){return typeof u=="string"&&i(d,Number.parseInt(u)),Reflect.set(c,u,d)?(d instanceof Ot&&(c.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(e){e===!0&&wg&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=e}is(e){return this._renderer===e}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.getMaterial(e)}resolveIndex(e){const t=this._indexMap;return t&&t.has(e)?t.get(e):e}setMaterial(e,t){if(t=this.resolveIndex(t),t<0||t>=this._targets.length)return;const i=this._targets[t];!i||i.material===void 0||(i.material=e,this.changed=!0)}getMaterial(e){if(e=this.resolveIndex(e),e<0)return null;const t=this._targets;if(e>=t.length)return null;const i=t[e];return i?i.material:null}}var DE;const Sg=(DE=class extends Me{constructor(){super(...arguments);h(this,"receiveShadows",!1);h(this,"shadowCastingMode",0);h(this,"lightmapIndex",-1);h(this,"lightmapScaleOffset",new Ze(1,1,0,0));h(this,"enableInstancing");h(this,"renderOrder");h(this,"allowOcclusionWhenDynamic",!0);h(this,"probeAnchor");h(this,"reflectionProbeUsage",0);h(this,"_lightmaps");h(this,"_sharedMeshes",[]);h(this,"_sharedMaterials");h(this,"_originalMaterials");h(this,"_lightmapTextureOverride");h(this,"allowProgressiveLoading",!0);h(this,"_firstFrame",-1);h(this,"_isInstancingEnabled",!1);h(this,"handles");h(this,"_wasVisible",!1);h(this,"onBeforeRenderThree",(e,t,i,n,r,o)=>{var a;if(!this._wasVisible&&this.context.time.frame>this._firstFrame+1&&(_u&&console.debug("onBeforeRenderThree: Object becomes visible for the first time",this.name,this.context.time.frame),this._wasVisible=!0),r.envMapIntensity!==void 0){const l=this.hasLightmap?Math.PI:1,c=((a=this.context.mainCameraComponent)==null?void 0:a.environmentIntensity)??1;r.envMapIntensity=Math.max(0,c*this.context.sceneLighting.environmentIntensity/l)}if(this._lightmaps)for(const l of this._lightmaps)l.updateLightmapUniforms(r)});h(this,"automaticallyUpdateLODLevel",!0);h(this,"hasTextureLODs",!0);h(this,"hasMeshLODs",!0);h(this,"_lastLodLevel",-1);h(this,"_nextLodTestTime",0);h(this,"_randomLodLevelCheckFrameOffset",Math.floor(Math.random()*100));h(this,"_sphere",new wn);h(this,"_box",new xi);h(this,"_reflectionProbe",null)}static setInstanced(e,t){const i=TA(e,Sg);return i.setInstancingEnabled(t),i}static isInstanced(e){const t=Cd(e,Sg);return t?t.isInstancingActive:Qo.isUsingInstancing(e)}static setVisible(e,t){Nf(e,t)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const e of this.gameObject.children)(e.type==="Mesh"||e.type==="SkinnedMesh")&&this._sharedMeshes.push(e);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(e){this.sharedMaterials[0]!==e&&(this.sharedMaterials[0]=e,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(e){this.sharedMaterial=e}set sharedMaterials(e){if(!this._originalMaterials)this._originalMaterials=e;else if(e){let t=!1;for(let i=0;i<this._sharedMaterials.length;i++){const n=i<e.length?e[i]:null;n&&n instanceof Ot?this.sharedMaterials[i]=n:t||(t=!0,console.warn("Can not assign null as material: "+this.name,n))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new fre(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return nL}get lightmap(){var e;return(e=this._lightmaps)!=null&&e.length?this._lightmaps[0].lightmap:null}set lightmap(e){var t;if(this._lightmapTextureOverride=e,e===void 0&&(e=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(t=this._lightmaps)!=null&&t.length)for(const i of this._lightmaps)i.lightmap=e}get hasLightmap(){const e=this.lightmap;return e!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(this._firstFrame=this.context.time.frame,wg&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&wg&&this.probeAnchor.add(new Wo(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const e of this.gameObject.children)this.context.addBeforeRenderListener(e,this.onBeforeRenderThree),e.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let e=0;for(let t=0;t<this.gameObject.children.length;t++){const i=this.gameObject.children[t];if(!(!this.isMeshOrSkinnedMesh(i)||oe.getComponent(i,Sg))){if(this.renderOrder.length<=e){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+e,"ChildElement:",i);continue}i.renderOrder=this.renderOrder[e],e+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),dre)for(let e=0;e<this.sharedMaterials.length;e++){const t=this.sharedMaterials[e];t&&(t.wireframe=!0)}}applyLightmapping(){var e;if(this.lightmapIndex>=0){const t=this.gameObject.type,i=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(i){if(this._lightmaps||(this._lightmaps=[]),t==="Mesh"){const n=this.gameObject.material;if(n!=null&&n.isMeshBasicMaterial)n&&console.warn("Lightmapping is not supported on MeshBasicMaterial",n.name);else{if(this._lightmaps.length<=0){const o=new Qv(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,i)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let n=0;n<this.gameObject.children.length;n++){const r=this.gameObject.children[n];if(!((e=r.material)!=null&&e.isMeshBasicMaterial)){let o;n>=this._lightmaps.length?(o=new Qv(r,this.context),this._lightmaps.push(o)):o=this._lightmaps[n],o.init(this.lightmapIndex,this.lightmapScaleOffset,i)}}}else wg&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}get isInstancingActive(){return this.handles!=null&&this.handles.length>0&&this._isInstancingEnabled}setInstancingEnabled(e){if(this._isInstancingEnabled===e)return e&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=e,e){if(this.enableInstancing===void 0&&(this.enableInstancing=!0),this.handles===void 0){if(this.handles=id.instance.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return oe.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const t of this.handles)t.updateInstanceMatrix(!0),t.add();return oe.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const t of this.handles)t.remove(this.destroyed);return!0}return!1}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!nL&&(this.setInstancingEnabled(!0),Qo.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];t.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled||this.enableInstancing==!0||Array.isArray(this.enableInstancing)&&this.enableInstancing.some(t=>t)?this.__internalDidAwakeAndStart&&this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe(),this.testIfLODLevelsAreAvailable()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const e of this.gameObject.children)this.context.removeBeforeRenderListener(e,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}onBeforeRender(){var e,t;if(this.gameObject){if(wg==this.name&&this.gameObject instanceof de){this.gameObject.geometry.computeBoundingSphere();const i=cn(this.gameObject.geometry.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);Ct.DrawWireSphere(i,this.gameObject.geometry.boundingSphere.radius,56831)}if(this.isMultiMaterialObject(this.gameObject)&&((e=this.gameObject.children)==null?void 0:e.length)>0)for(const i of this.gameObject.children)this.applySettings(i);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(t=this.handles)!=null&&t.length&&this.gameObject[Pv]===!0){this.gameObject[Pv]=!1;for(let n=this.handles.length-1;n>=0;n--)this.handles[n].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&oe.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let i=0;i<this.handles.length;i++){const n=this.handles[i];Nf(n.object,!1)}this._wasVisible&&this.allowProgressiveLoading&&this.automaticallyUpdateLODLevel&&this.updateLODs(),this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const t=this.handles[e];this._wasVisible=!0,Nf(t.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this),_u&&this._lastLodLevel>=0&&this.drawGizmoLodLevel(!1)}testIfLODLevelsAreAvailable(){this.automaticallyUpdateLODLevel=!1,this.hasMeshLODs=!1,this.hasTextureLODs=!1;for(const e of this.sharedMeshes)if(Di.hasLODLevelAvailable(e)){this.automaticallyUpdateLODLevel=!0,this.hasMeshLODs=!0;break}for(const e of this.sharedMaterials)if(e&&Di.hasLODLevelAvailable(e)){this.automaticallyUpdateLODLevel=!0,this.hasTextureLODs=!0;break}_u&&console.log(`${this.name}
6217
6217
  Mesh LODs available? ${this.hasMeshLODs?"YES":"NO"}
6218
6218
  Texture LODs available? ${this.hasTextureLODs?"YES":"NO"}`)}updateLODs(){let e=0;this.hasMeshLODs&&(e=this.calculateLodLevel());const t=0;for(const i of this.sharedMaterials)i&&this.loadProgressiveTextures(i,t);if(e>=0)for(let i=0;i<this.sharedMeshes.length;i++){const n=this.sharedMeshes[i];n&&this.loadProgressiveMeshes(n,e)}}calculateLodLevel(e=!1){var r;if(!e&&(this.context.time.frame+this._randomLodLevelCheckFrameOffset)%3!=0)return this._lastLodLevel;if(this.context.time.realtimeSinceStartup<this._nextLodTestTime)return this._lastLodLevel;const i=10;let n=i+1;if(this.context.mainCamera){const a=Ra()?.6:.4;for(const l of this.sharedMeshes){if(n<=0)break;if(!l)continue;if(_u&&l["DEBUG:LOD"]!=null)return this._lastLodLevel=l["DEBUG:LOD"];let c=0;const u=Di.getMeshLODInformation(l.geometry);(u==null?void 0:u.density)!=null&&(c=Math.log2(u.density||0)/2-6);const d=(r=this.context.mainCameraComponent)==null?void 0:r.getFrustum();if(!(d!=null&&d.intersectsObject(l))){if(_u&&l.geometry.boundingSphere){const p=l.geometry.boundingSphere;this._sphere.copy(p),this._sphere.applyMatrix4(l.matrixWorld),Ct.DrawWireSphere(this._sphere.center,this._sphere.radius*1.01,16733525,.5)}continue}const f=l.geometry.boundingBox;if(f&&this.context.mainCamera instanceof zt){if(l.geometry.attributes.color&&l.geometry.attributes.color.count<100&&l.geometry.boundingSphere&&(this._sphere.copy(l.geometry.boundingSphere),this._sphere.applyMatrix4(l.matrixWorld),this._sphere.containsPoint(Lt(this.context.mainCamera)))){n=0;break}this._box.copy(f),this._box.applyMatrix4(l.matrixWorld),this._box.applyMatrix4(this.context.mainCameraComponent.getProjectionScreenMatrix(Sg.tempMatrix));let m=this._box.getSize(cn()).y/2;m/=Math.pow(2,c-.5);let A=999,v=a;for(let _=0;_<i;_++){if(m>v){A=_;break}v/=2}A<n&&(n=A)}}}return n=Math.round(n),this._lastLodLevel!=n&&(this._nextLodTestTime=this.context.time.realtimeSinceStartup+.5,_u&&(_u=="verbose"&&console.warn(`LOD Level changed from ${this._lastLodLevel} to ${n} for ${this.name}`),this.drawGizmoLodLevel(!0))),this._lastLodLevel=n,n}drawGizmoLodLevel(e){const t=this._lastLodLevel,i=this.context.mainCamera.worldForward,n=this.context.mainCamera.worldPosition;for(const r of this.sharedMeshes)if(r&&r.geometry.boundingSphere){const o=r.geometry.boundingSphere;this._sphere.copy(o),this._sphere.applyMatrix4(r.matrixWorld);const a=this._sphere.center,l=this._sphere.radius,c=["#76c43e","#bcc43e","#c4ac3e","#c4673e","#ff3e3e"];if(e)Ct.DrawWireSphere(a,l,c[t],.1);else{const u="LOD "+t+`
6219
6219
  `+r.geometry.index.count/3,d=cn(i).multiplyScalar(l*.7).add(a),f=d.distanceTo(n);r.geometry.index.count/3;const p=c[Math.min(c.length-1,t)]+"88",m=Math.min(10,l);Ct.DrawLabel(d,u,f*.001+m*.03,void 0,16777215,p)}}}applyStencil(){Yg.applyStencil(this)}loadProgressiveTextures(e,t){return!sL&&e&&this.allowProgressiveLoading&&(e.userData||(e.userData={}),e.userData.LOD!==t)?(e.userData.LOD=t,Di.assignTextureLOD(this.context,this.sourceId,e,t)):Promise.resolve(!0)}loadProgressiveMeshes(e,t){if(!sL&&e&&this.allowProgressiveLoading&&(e.userData||(e.userData={}),e.userData.LOD!==t)){e.userData.LOD=t;const i=e.geometry;return Di.assignMeshLOD(this.context,this.sourceId,e,t).then(n=>{if(n&&e.userData.LOD==t&&i!=e.geometry&&(this.applyLightmapping(),this.handles))for(const r of this.handles)r.setGeometry(e.geometry)})}return!0}applySettings(e){e.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?e.castShadow=!0:e.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),Nn.LateUpdate)}}*_updateReflectionProbe(){const e=this.probeAnchor||this.gameObject,t=!!this.probeAnchor;this._reflectionProbe=um.get(e,this.context,t,this.probeAnchor)}setVisibility(e){if(!this.isMultiMaterialObject(this.gameObject))Nf(this.gameObject,e);else for(const t of this.gameObject.children)this.isMeshOrSkinnedMesh(t)&&Nf(t,e)}isMultiMaterialObject(e){return e.type==="Group"}isMeshOrSkinnedMesh(e){return e.type==="Mesh"||e.type==="SkinnedMesh"}},h(DE,"tempMatrix",new we),DE);let Dn=Sg;Mc([x()],Dn.prototype,"receiveShadows",2);Mc([x()],Dn.prototype,"shadowCastingMode",2);Mc([x()],Dn.prototype,"lightmapIndex",2);Mc([x(Ze)],Dn.prototype,"lightmapScaleOffset",2);Mc([x()],Dn.prototype,"enableInstancing",2);Mc([x()],Dn.prototype,"renderOrder",2);Mc([x()],Dn.prototype,"allowOcclusionWhenDynamic",2);Mc([x(ge)],Dn.prototype,"probeAnchor",2);Mc([x()],Dn.prototype,"reflectionProbeUsage",2);class ey extends Dn{}class WR extends ey{constructor(){super(...arguments);h(this,"_needUpdateBoundingSphere",!1)}awake(){var t;super.awake(),this.allowOcclusionWhenDynamic=!1,(t=this.gameObject.parent)==null||t.updateWorldMatrix(!1,!0),this.markBoundsDirty()}onAfterRender(){if(super.onAfterRender(),this.gameObject instanceof Ho&&this._needUpdateBoundingSphere){this._needUpdateBoundingSphere=!1;const t=this.gameObject.geometry,i=kv(this.gameObject);i&&(this.gameObject.geometry=i),this.gameObject.computeBoundingSphere(),this.gameObject.geometry=t}if(ure&&this.gameObject instanceof Ho&&this.gameObject.boundingSphere){const t=cn(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);Ct.DrawWireSphere(t,this.gameObject.boundingSphere.radius,"red")}}markBoundsDirty(){this._needUpdateBoundingSphere=!0}}var pre=Object.defineProperty,mre=Object.getOwnPropertyDescriptor,se=(s,e,t,i)=>{for(var n=i>1?void 0:i?mre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&pre(e,t,n),n};const Y0=ne("debugparticles");var Jl=(s=>(s[s.Billboard=0]="Billboard",s[s.Stretch=1]="Stretch",s[s.HorizontalBillboard=2]="HorizontalBillboard",s[s.VerticalBillboard=3]="VerticalBillboard",s[s.Mesh=4]="Mesh",s))(Jl||{});let qh=class{constructor(){h(this,"alphaKeys");h(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,n=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const l=this.alphaKeys[a];(l.time<e||!i)&&(i=l,n=a)}for(let a=0;a<this.colorKeys.length;a++){const l=this.colorKeys[a];(l.time<e||!r)&&(r=l,o=a)}if(r)if(o+1<this.colorKeys.length){const l=this.colorKeys[o+1],c=et.remap(e,r.time,l.time,0,1);t.r=et.lerp(r.color.r,l.color.r,c),t.g=et.lerp(r.color.g,l.color.g,c),t.b=et.lerp(r.color.b,l.color.b,c)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(n+1<this.alphaKeys.length){const l=this.alphaKeys[n+1],c=et.remap(e,i.time,l.time,0,1);t.alpha=et.lerp(i.alpha,l.alpha,c)}else t.alpha=i.alpha;return t}};se([x()],qh.prototype,"alphaKeys",2);se([x()],qh.prototype,"colorKeys",2);var Vv=(s=>(s[s.Local=0]="Local",s[s.World=1]="World",s[s.Custom=2]="Custom",s))(Vv||{}),Wb=(s=>(s[s.Sphere=0]="Sphere",s[s.SphereShell=1]="SphereShell",s[s.Hemisphere=2]="Hemisphere",s[s.HemisphereShell=3]="HemisphereShell",s[s.Cone=4]="Cone",s[s.Box=5]="Box",s[s.Mesh=6]="Mesh",s[s.ConeShell=7]="ConeShell",s[s.ConeVolume=8]="ConeVolume",s[s.ConeVolumeShell=9]="ConeVolumeShell",s[s.Circle=10]="Circle",s[s.CircleEdge=11]="CircleEdge",s[s.SingleSidedEdge=12]="SingleSidedEdge",s[s.MeshRenderer=13]="MeshRenderer",s[s.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",s[s.BoxShell=15]="BoxShell",s[s.BoxEdge=16]="BoxEdge",s[s.Donut=17]="Donut",s[s.Rectangle=18]="Rectangle",s[s.Sprite=19]="Sprite",s[s.SpriteRenderer=20]="SpriteRenderer",s))(Wb||{});const bG=class{constructor(){h(this,"mode");h(this,"constant");h(this,"constantMin");h(this,"constantMax");h(this,"curve");h(this,"curveMin");h(this,"curveMax");h(this,"curveMultiplier")}clone(){var e,t,i;const s=new bG;return s.mode=this.mode,s.constant=this.constant,s.constantMin=this.constantMin,s.constantMax=this.constantMax,s.curve=(e=this.curve)==null?void 0:e.clone(),s.curveMin=(t=this.curveMin)==null?void 0:t.clone(),s.curveMax=(i=this.curveMax)==null?void 0:i.clone(),s.curveMultiplier=this.curveMultiplier,s}evaluate(s,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return s=et.clamp01(s),this.curve.evaluate(s)*this.curveMultiplier;case 2:const i=s*this.curveMin.duration,n=s*this.curveMax.duration;return et.lerp(this.curveMin.evaluate(i),this.curveMax.evaluate(n),t%1)*this.curveMultiplier;case 3:return et.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(s)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(s){if(!s)return 0;let e=Number.MIN_VALUE;for(let t=0;t<s.keys.length;t++){const i=s.keys[t];i.value>e&&(e=i.value)}return e}};let ft=bG;se([x()],ft.prototype,"mode",2);se([x()],ft.prototype,"constant",2);se([x()],ft.prototype,"constantMin",2);se([x()],ft.prototype,"constantMax",2);se([x(Md)],ft.prototype,"curve",2);se([x(Md)],ft.prototype,"curveMin",2);se([x(Md)],ft.prototype,"curveMax",2);se([x()],ft.prototype,"curveMultiplier",2);var m_;const ua=(m_=class{constructor(){h(this,"mode");h(this,"color");h(this,"colorMin");h(this,"colorMax");h(this,"gradient");h(this,"gradientMin");h(this,"gradientMax")}evaluate(s,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(s,ua._temp),ua._temp;case 2:return ua._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(s,ua._temp),this.gradientMax.evaluate(s,ua._temp2),ua._temp.lerp(ua._temp2,t)}return ua._temp.set(16711935),ua._temp.alpha=1,ua._temp}},h(m_,"_temp",new wi(0,0,0,1)),h(m_,"_temp2",new wi(0,0,0,1)),m_);let jr=ua;se([x(wi)],jr.prototype,"color",2);se([x(wi)],jr.prototype,"colorMin",2);se([x(wi)],jr.prototype,"colorMax",2);se([x(qh)],jr.prototype,"gradient",2);se([x(qh)],jr.prototype,"gradientMin",2);se([x(qh)],jr.prototype,"gradientMax",2);var RM=(s=>(s[s.Hierarchy=0]="Hierarchy",s[s.Local=1]="Local",s[s.Shape=2]="Shape",s))(RM||{});class Gs{constructor(){h(this,"cullingMode");h(this,"duration");h(this,"emitterVelocityMode");h(this,"flipRotation");h(this,"gravityModifier");h(this,"gravityModifierMultiplier");h(this,"loop");h(this,"maxParticles");h(this,"playOnAwake");h(this,"prewarm");h(this,"ringBufferLoopRange");h(this,"ringBufferMode");h(this,"scalingMode");h(this,"simulationSpace");h(this,"simulationSpeed");h(this,"startColor");h(this,"startDelay");h(this,"startDelayMultiplier");h(this,"startLifetime");h(this,"startLifetimeMultiplier");h(this,"startRotation");h(this,"startRotationMultiplier");h(this,"startRotation3D");h(this,"startRotationX");h(this,"startRotationXMultiplier");h(this,"startRotationY");h(this,"startRotationYMultiplier");h(this,"startRotationZ");h(this,"startRotationZMultiplier");h(this,"startSize");h(this,"startSize3D");h(this,"startSizeMultiplier");h(this,"startSizeX");h(this,"startSizeXMultiplier");h(this,"startSizeY");h(this,"startSizeYMultiplier");h(this,"startSizeZ");h(this,"startSizeZMultiplier");h(this,"startSpeed");h(this,"startSpeedMultiplier");h(this,"stopAction");h(this,"useUnscaledTime")}}se([x(ft)],Gs.prototype,"gravityModifier",2);se([x(jr)],Gs.prototype,"startColor",2);se([x(ft)],Gs.prototype,"startDelay",2);se([x(ft)],Gs.prototype,"startLifetime",2);se([x(ft)],Gs.prototype,"startRotation",2);se([x(ft)],Gs.prototype,"startRotationX",2);se([x(ft)],Gs.prototype,"startRotationY",2);se([x(ft)],Gs.prototype,"startRotationZ",2);se([x(ft)],Gs.prototype,"startSize",2);se([x(ft)],Gs.prototype,"startSizeX",2);se([x(ft)],Gs.prototype,"startSizeY",2);se([x(ft)],Gs.prototype,"startSizeZ",2);se([x(ft)],Gs.prototype,"startSpeed",2);class Wv{constructor(){h(this,"cycleCount");h(this,"maxCount");h(this,"minCount");h(this,"probability");h(this,"repeatInterval");h(this,"time");h(this,"count");h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(e>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=et.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const n=Math.random();t=et.lerp(this.count.curveMin.evaluate(n),this.count.curveMax.evaluate(n),Math.random());break}}return t}}class wl{constructor(){h(this,"enabled");h(this,"bursts");h(this,"rateOverTime");h(this,"rateOverTimeMultiplier");h(this,"rateOverDistance");h(this,"rateOverDistanceMultiplier");h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}se([x()],wl.prototype,"enabled",2);se([x()],wl.prototype,"bursts",2);se([x(ft)],wl.prototype,"rateOverTime",2);se([x()],wl.prototype,"rateOverTimeMultiplier",2);se([x(ft)],wl.prototype,"rateOverDistance",2);se([x()],wl.prototype,"rateOverDistanceMultiplier",2);class ty{constructor(){h(this,"enabled");h(this,"color")}}se([x(jr)],ty.prototype,"color",2);class Xh{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_time",0);h(this,"_temp",new w)}evaluate(e,t,i){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const n=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=n}return t}}se([x(ft)],Xh.prototype,"size",2);se([x(ft)],Xh.prototype,"x",2);se([x(ft)],Xh.prototype,"y",2);se([x(ft)],Xh.prototype,"z",2);var g_;const Cg=(g_=class{constructor(){h(this,"shapeType",5);h(this,"enabled",!0);h(this,"alignToDirection",!1);h(this,"angle",0);h(this,"arc",360);h(this,"arcSpread");h(this,"arcSpeedMultiplier");h(this,"arcMode");h(this,"boxThickness");h(this,"position");h(this,"rotation");h(this,"_rotation",new Vi);h(this,"scale");h(this,"radius");h(this,"radiusThickness");h(this,"sphericalDirectionAmount");h(this,"randomDirectionAmount");h(this,"randomPositionAmount");h(this,"meshShapeType");h(this,"meshRenderer");h(this,"_meshObj");h(this,"_meshGeometry");h(this,"system");h(this,"_space");h(this,"_worldSpaceMatrix",new we);h(this,"_worldSpaceMatrixInverse",new we);h(this,"_vector",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_triangle",new _r);h(this,"_dir",new w);h(this,"_loopTime",0);h(this,"_loopDirection",1);Y0&&console.log(this)}get type(){return Wb[this.shapeType]}initialize(s){this.onInitialize(s),s.position.copy(this._vector)}toJSON(){return this}clone(){return new Cg}setMesh(s){this.meshRenderer=s,s?(this._meshObj=s.sharedMeshes[Math.floor(Math.random()*s.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(s,e,t,i){this.system=s,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(s){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=et.toRadians(this.rotation.x),this._rotation.y=et.toRadians(this.rotation.y),this._rotation.z=et.toRadians(this.rotation.z),this._rotation.order="ZYX",s.applyEuler(this._rotation)),e}onInitialize(s){this._vector.set(0,0,0),s.mesh=void 0,s.mesh_geometry=void 0;const e=this._temp.copy(this.position),t=this._space===1;t&&e.applyQuaternion(this.system.worldQuaternion);let i=this.radius;if(t&&(i*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Y0&&Ct.DrawWireBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(e);break;case 4:this.randomConePoint(this.position,this.angle,i,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,i,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,i,this.radiusThickness,this.arc,this._vector);break;case 13:const n=this.meshRenderer;(n==null?void 0:n.destroyed)==!1&&this.setMesh(n);const r=s.mesh=this._meshObj,o=s.mesh_geometry=this._meshGeometry;if(r&&o)switch(this.meshShapeType){case 0:{const a=o.getAttribute("position"),l=Math.floor(Math.random()*a.count);this._vector.fromBufferAttribute(a,l),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=l}break;case 1:break;case 2:{const a=o.index;if(a){let l=Math.random(),c=Math.random();l+c>1&&(l=1-l,c=1-c);const u=Math.floor(Math.random()*(a.count/3));let d=u*3,f=u*3+1,p=u*3+2;d=a.getX(d),f=a.getX(f),p=a.getX(p);const m=o.getAttribute("position");this._triangle.a.fromBufferAttribute(m,d),this._triangle.b.fromBufferAttribute(m,f),this._triangle.c.fromBufferAttribute(m,p),this._vector.set(0,0,0).addScaledVector(this._triangle.a,l).addScaledVector(this._triangle.b,c).addScaledVector(this._triangle.c,1-(l+c)),this._vector.applyMatrix4(r.matrixWorld),s.mesh_normal=u}}break}break;default:this._vector.set(0,0,0),At()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",Wb[this.shapeType]),globalThis.__particlesystem_shapetype_unsupported=!0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),t&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Y0&&Ct.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(s,e){var t;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const i=e.x,n=e.y,r=e.z;this._dir.set(i,n,r),(t=this.system)!=null&&t.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const o=s.mesh,a=s.mesh_geometry;if(o&&a)switch(this.meshShapeType){case 0:{const l=a.getAttribute("normal"),c=s.mesh_normal;this._dir.fromBufferAttribute(l,c)}break;case 1:break;case 2:{const l=a.index;if(l){const c=s.mesh_normal,u=l.getX(c*3),d=l.getX(c*3+1),f=l.getX(c*3+2),p=a.getAttribute("position"),m=cn(),A=cn(),v=cn();m.fromBufferAttribute(p,u),A.fromBufferAttribute(p,d),v.fromBufferAttribute(p,f),m.sub(A),v.sub(A),m.cross(v),this._dir.copy(m).multiplyScalar(-1);const g=Ti(o);this._dir.applyQuaternion(g)}}break}break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Y0&&(Ct.DrawSphere(e,.01,8925952,.5,!0),Ct.DrawDirection(e,this._dir,8925952,.5,!0)),this._dir}randomizePosition(s,e){if(e<=0)return;const t=Cg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,s.add(t)}randomizeDirection(s,e){if(e===0)return;const t=Cg._randomQuat,i=Cg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),s.applyQuaternion(t)}spherizeDirection(s,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),n=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new w(n,r,o);s.lerp(a,e)}randomSpherePoint(s,e,t,i,n){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),l=Math.acos(2*o-1),c=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=s.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=s.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),f=s.z+this.scale.z*(c*Math.cos(l));n.x=u,n.y=d,n.z=f}randomCirclePoint(s,e,t,i,n){const r=Math.random(),o=2*Math.PI*r*(i/360),a=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=s.x+this.scale.x*a*Math.cos(o),c=s.y+this.scale.y*a*Math.sin(o),u=s.z;n.x=l,n.y=c,n.z=u}randomConePoint(s,e,t,i,n,r,o){let a=0,l=0;switch(r){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(n/360);switch(r){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=et.toRadians(n);break}const u=Math.acos(2*l-1),d=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=s.x+-d*Math.sin(u)*Math.cos(c),p=s.y+d*Math.sin(u)*Math.sin(c),m=s.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=m*this.scale.z}},h(g_,"_randomQuat",new Ce),h(g_,"_tempVec",new w),g_);let mn=Cg;se([x()],mn.prototype,"shapeType",2);se([x()],mn.prototype,"enabled",2);se([x()],mn.prototype,"alignToDirection",2);se([x()],mn.prototype,"angle",2);se([x()],mn.prototype,"arc",2);se([x()],mn.prototype,"arcSpread",2);se([x()],mn.prototype,"arcSpeedMultiplier",2);se([x()],mn.prototype,"arcMode",2);se([x(w)],mn.prototype,"boxThickness",2);se([x(w)],mn.prototype,"position",2);se([x(w)],mn.prototype,"rotation",2);se([x(w)],mn.prototype,"scale",2);se([x()],mn.prototype,"radius",2);se([x()],mn.prototype,"radiusThickness",2);se([x()],mn.prototype,"sphericalDirectionAmount",2);se([x()],mn.prototype,"randomDirectionAmount",2);se([x()],mn.prototype,"randomPositionAmount",2);se([x()],mn.prototype,"meshShapeType",2);se([x(ey)],mn.prototype,"meshRenderer",2);class Ei{constructor(){h(this,"damping");h(this,"enabled");h(this,"frequency");h(this,"octaveCount");h(this,"octaveMultiplier");h(this,"octaveScale");h(this,"positionAmount");h(this,"quality");h(this,"remap");h(this,"remapEnabled");h(this,"remapMultiplier");h(this,"remapX");h(this,"remapXMultiplier");h(this,"remapY");h(this,"remapYMultiplier");h(this,"remapZ");h(this,"remapZMultiplier");h(this,"scrollSpeedMultiplier");h(this,"separateAxes");h(this,"strengthMultiplier");h(this,"strengthX");h(this,"strengthXMultiplier");h(this,"strengthY");h(this,"strengthYMultiplier");h(this,"strengthZ");h(this,"strengthZMultiplier");h(this,"_noise");h(this,"_time",0);h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,n,r,o){if(!this.enabled)return;this._noise||(this._noise=Use(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,u).normalize();const d=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}se([x()],Ei.prototype,"damping",2);se([x()],Ei.prototype,"enabled",2);se([x()],Ei.prototype,"frequency",2);se([x()],Ei.prototype,"octaveCount",2);se([x()],Ei.prototype,"octaveMultiplier",2);se([x()],Ei.prototype,"octaveScale",2);se([x(ft)],Ei.prototype,"positionAmount",2);se([x()],Ei.prototype,"quality",2);se([x(ft)],Ei.prototype,"remap",2);se([x()],Ei.prototype,"remapEnabled",2);se([x()],Ei.prototype,"remapMultiplier",2);se([x(ft)],Ei.prototype,"remapX",2);se([x()],Ei.prototype,"remapXMultiplier",2);se([x(ft)],Ei.prototype,"remapY",2);se([x()],Ei.prototype,"remapYMultiplier",2);se([x(ft)],Ei.prototype,"remapZ",2);se([x()],Ei.prototype,"remapZMultiplier",2);se([x()],Ei.prototype,"scrollSpeedMultiplier",2);se([x()],Ei.prototype,"separateAxes",2);se([x()],Ei.prototype,"strengthMultiplier",2);se([x(ft)],Ei.prototype,"strengthX",2);se([x()],Ei.prototype,"strengthXMultiplier",2);se([x(ft)],Ei.prototype,"strengthY",2);se([x()],Ei.prototype,"strengthYMultiplier",2);se([x(ft)],Ei.prototype,"strengthZ",2);se([x()],Ei.prototype,"strengthZMultiplier",2);class sn{constructor(){h(this,"enabled");h(this,"attachRibbonToTransform",!1);h(this,"colorOverLifetime");h(this,"colorOverTrail");h(this,"dieWithParticles",!0);h(this,"inheritParticleColor",!0);h(this,"lifetime");h(this,"lifetimeMultiplier");h(this,"minVertexDistance",.2);h(this,"mode",0);h(this,"ratio",1);h(this,"ribbonCount",1);h(this,"shadowBias",0);h(this,"sizeAffectsLifetime",!1);h(this,"sizeAffectsWidth",!1);h(this,"splitSubEmitterRibbons",!1);h(this,"textureMode",0);h(this,"widthOverTrail");h(this,"widthOverTrailMultiplier");h(this,"worldSpace",!1)}getWidth(e,t,i,n){const r=this.widthOverTrail.evaluate(i,n);return e*=r,e}getColor(e,t,i){const n=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=n.r*r.r,e.y*=n.g*r.g,e.z*=n.b*r.b,e.w*=n.alpha*r.alpha}}se([x()],sn.prototype,"enabled",2);se([x()],sn.prototype,"attachRibbonToTransform",2);se([x(jr)],sn.prototype,"colorOverLifetime",2);se([x(jr)],sn.prototype,"colorOverTrail",2);se([x()],sn.prototype,"dieWithParticles",2);se([x()],sn.prototype,"inheritParticleColor",2);se([x(ft)],sn.prototype,"lifetime",2);se([x()],sn.prototype,"lifetimeMultiplier",2);se([x()],sn.prototype,"minVertexDistance",2);se([x()],sn.prototype,"mode",2);se([x()],sn.prototype,"ratio",2);se([x()],sn.prototype,"ribbonCount",2);se([x()],sn.prototype,"shadowBias",2);se([x()],sn.prototype,"sizeAffectsLifetime",2);se([x()],sn.prototype,"sizeAffectsWidth",2);se([x()],sn.prototype,"splitSubEmitterRibbons",2);se([x()],sn.prototype,"textureMode",2);se([x(ft)],sn.prototype,"widthOverTrail",2);se([x()],sn.prototype,"widthOverTrailMultiplier",2);se([x()],sn.prototype,"worldSpace",2);class gn{constructor(){h(this,"enabled");h(this,"space",0);h(this,"orbitalX");h(this,"orbitalY");h(this,"orbitalZ");h(this,"orbitalXMultiplier");h(this,"orbitalYMultiplier");h(this,"orbitalZMultiplier");h(this,"orbitalOffsetX");h(this,"orbitalOffsetY");h(this,"orbitalOffsetZ");h(this,"speedModifier");h(this,"speedModifierMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_system");h(this,"_temp",new w);h(this,"_temp2",new w);h(this,"_temp3",new w);h(this,"_hasOrbital",!1);h(this,"_index",0);h(this,"_orbitalMatrix",new we)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,i,n,r,o,a){var p;if(!this.enabled)return;const l=o/a,c=this.speedModifier.evaluate(l)*this.speedModifierMultiplier,u=this.x.evaluate(l),d=this.y.evaluate(l),f=this.z.evaluate(l);if(this._temp.set(-u,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,g=this.orbitalYMultiplier,_=this.orbitalZMultiplier,y=c*Math.PI*2*10,b=Math.cos(y*v),E=Math.sin(y*v),M=Math.cos(y*g),T=Math.sin(y*g),C=Math.cos(y*_),B=Math.sin(y*_),S=A.x*(M*C)+A.y*(M*B)+A.z*-T,I=A.x*(E*T*C-b*B)+A.y*(E*T*B+b*C)+A.z*(E*M),Q=A.x*(b*T*C+E*B)+A.y*(b*T*B-E*C)+A.z*(b*M),N=this._temp3.set(A.x-S,A.y-I,A.z-Q);N.normalize(),N.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),n.x+=N.x,n.y+=N.y,n.z+=N.z}n.x+=this._temp.x,n.y+=this._temp.y,n.z+=this._temp.z,n.x*=c,n.y*=c,n.z*=c}}se([x()],gn.prototype,"enabled",2);se([x()],gn.prototype,"space",2);se([x(ft)],gn.prototype,"orbitalX",2);se([x(ft)],gn.prototype,"orbitalY",2);se([x(ft)],gn.prototype,"orbitalZ",2);se([x()],gn.prototype,"orbitalXMultiplier",2);se([x()],gn.prototype,"orbitalYMultiplier",2);se([x()],gn.prototype,"orbitalZMultiplier",2);se([x()],gn.prototype,"orbitalOffsetX",2);se([x()],gn.prototype,"orbitalOffsetY",2);se([x()],gn.prototype,"orbitalOffsetZ",2);se([x(ft)],gn.prototype,"speedModifier",2);se([x()],gn.prototype,"speedModifierMultiplier",2);se([x(ft)],gn.prototype,"x",2);se([x()],gn.prototype,"xMultiplier",2);se([x(ft)],gn.prototype,"y",2);se([x()],gn.prototype,"yMultiplier",2);se([x(ft)],gn.prototype,"z",2);se([x()],gn.prototype,"zMultiplier",2);class Hs{constructor(){h(this,"animation");h(this,"enabled");h(this,"cycleCount");h(this,"frameOverTime");h(this,"frameOverTimeMultiplier");h(this,"numTilesX");h(this,"numTilesY");h(this,"startFrame");h(this,"startFrameMultiplier");h(this,"rowMode");h(this,"rowIndex");h(this,"spriteCount");h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}se([x()],Hs.prototype,"animation",2);se([x()],Hs.prototype,"enabled",2);se([x()],Hs.prototype,"cycleCount",2);se([x(ft)],Hs.prototype,"frameOverTime",2);se([x()],Hs.prototype,"frameOverTimeMultiplier",2);se([x()],Hs.prototype,"numTilesX",2);se([x()],Hs.prototype,"numTilesY",2);se([x(ft)],Hs.prototype,"startFrame",2);se([x()],Hs.prototype,"startFrameMultiplier",2);se([x()],Hs.prototype,"rowMode",2);se([x()],Hs.prototype,"rowIndex",2);se([x()],Hs.prototype,"spriteCount",2);se([x()],Hs.prototype,"timeMode",2);class ia{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}se([x()],ia.prototype,"enabled",2);se([x()],ia.prototype,"separateAxes",2);se([x(ft)],ia.prototype,"x",2);se([x()],ia.prototype,"xMultiplier",2);se([x(ft)],ia.prototype,"y",2);se([x()],ia.prototype,"yMultiplier",2);se([x(ft)],ia.prototype,"z",2);se([x()],ia.prototype,"zMultiplier",2);class wo{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=et.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}se([x()],wo.prototype,"enabled",2);se([x()],wo.prototype,"range",2);se([x()],wo.prototype,"separateAxes",2);se([x(ft)],wo.prototype,"x",2);se([x()],wo.prototype,"xMultiplier",2);se([x(ft)],wo.prototype,"y",2);se([x()],wo.prototype,"yMultiplier",2);se([x(ft)],wo.prototype,"z",2);se([x()],wo.prototype,"zMultiplier",2);class Vn{constructor(){h(this,"enabled");h(this,"dampen");h(this,"drag");h(this,"dragMultiplier");h(this,"limit");h(this,"limitMultiplier");h(this,"separateAxes");h(this,"limitX");h(this,"limitXMultiplier");h(this,"limitY");h(this,"limitYMultiplier");h(this,"limitZ");h(this,"limitZMultiplier");h(this,"multiplyDragByParticleSize",!1);h(this,"multiplyDragByParticleVelocity",!1);h(this,"space");h(this,"_temp",new w);h(this,"_temp2",new w)}apply(e,t,i,n,r,o,a){if(this.enabled){const l=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);const u=this.dampen*.5;t.x=et.lerp(t.x,this._temp.x,u),t.y=et.lerp(t.y,this._temp.y,u),t.z=et.lerp(t.z,this._temp.z,u),i.x=et.lerp(i.x,this._temp.x,u),i.y=et.lerp(i.y,this._temp.y,u),i.z=et.lerp(i.z,this._temp.z,u)}}}}se([x()],Vn.prototype,"enabled",2);se([x()],Vn.prototype,"dampen",2);se([x(ft)],Vn.prototype,"drag",2);se([x()],Vn.prototype,"dragMultiplier",2);se([x(ft)],Vn.prototype,"limit",2);se([x()],Vn.prototype,"limitMultiplier",2);se([x()],Vn.prototype,"separateAxes",2);se([x(ft)],Vn.prototype,"limitX",2);se([x()],Vn.prototype,"limitXMultiplier",2);se([x(ft)],Vn.prototype,"limitY",2);se([x()],Vn.prototype,"limitYMultiplier",2);se([x(ft)],Vn.prototype,"limitZ",2);se([x()],Vn.prototype,"limitZMultiplier",2);se([x()],Vn.prototype,"multiplyDragByParticleSize",2);se([x()],Vn.prototype,"multiplyDragByParticleVelocity",2);se([x()],Vn.prototype,"space",2);const xG=class{constructor(){h(this,"enabled");h(this,"curve");h(this,"curveMultiplier");h(this,"mode");h(this,"system");h(this,"_temp",new w);h(this,"_firstUpdate",!0);h(this,"_frames",0)}clone(){var e;const s=new xG;return s.enabled=this.enabled,s.curve=(e=this.curve)==null?void 0:e.clone(),s.curveMultiplier=this.curveMultiplier,s.mode=this.mode,s}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new w),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new w),this.system._iv_velocity}awake(s){this.system=s,this.reset()}reset(){this._firstUpdate=!0}update(s){this.enabled&&this.system.worldspace!==!1&&(this._firstUpdate?(this._firstUpdate=!1,this._velocity.set(0,0,0),this._lastWorldPosition.copy(this.system.worldPos)):this._lastWorldPosition&&(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)))}applyInitial(s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),s.add(this._temp)}}applyCurrent(s,e,t){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const i=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(i),s.add(this._temp)}}};let Yh=xG;se([x()],Yh.prototype,"enabled",2);se([x(ft)],Yh.prototype,"curve",2);se([x()],Yh.prototype,"curveMultiplier",2);se([x()],Yh.prototype,"mode",2);class Rr{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t,i,n){const r=e.length(),o=et.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return n*a}}se([x()],Rr.prototype,"enabled",2);se([x(te)],Rr.prototype,"range",2);se([x()],Rr.prototype,"separateAxes",2);se([x(ft)],Rr.prototype,"size",2);se([x()],Rr.prototype,"sizeMultiplier",2);se([x(ft)],Rr.prototype,"x",2);se([x()],Rr.prototype,"xMultiplier",2);se([x(ft)],Rr.prototype,"y",2);se([x()],Rr.prototype,"yMultiplier",2);se([x(ft)],Rr.prototype,"z",2);se([x()],Rr.prototype,"zMultiplier",2);class Fd{constructor(){h(this,"enabled");h(this,"range");h(this,"color")}evaluate(e,t,i){const n=e.length(),r=et.remap(n,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}se([x()],Fd.prototype,"enabled",2);se([x(te)],Fd.prototype,"range",2);se([x(jr)],Fd.prototype,"color",2);const gre={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
@@ -4341,7 +4341,7 @@ void main() {
4341
4341
  `;s+=g(o);const C=Object.keys(I);let a="";for(let r=0;r<C.length;r++){const B=C[r],Q=I[B];if(xc.has(Q)){a+="";continue}xc.set(Q,!0),a+=B+":"+i(Q,o+1),r<C.length-1&&(a+=", "),a.length>=60&&(a+=`
4342
4342
  `,a+=g(o),s+=a,a="")}return s+=a,s+=`
4343
4343
  }`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const Y9=tA("nodevlogs");function Ii(t,A=to.Log){Ps(A,t)}function Zt(t){Ii(t,to.Warn)}function xM(t){Ii(t,to.Error)}let YM;function Ee(){return Y9?!1:YM!==void 0?YM:TI()}function T9(t){YM=t}const zr=new Yr,AI=new S,Cn=new S,Vt=new UA,GL={X:new S(1,0,0),Y:new S(0,1,0),Z:new S(0,0,1)},TM={type:"change"},RL={type:"mouseDown"},UL={type:"mouseUp",mode:null},NL={type:"objectChange"};class H9 extends pA{constructor(A,e){super(),e===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const i=new _M;this._gizmo=i,this.add(i);const g=new z9;this._plane=g,this.add(g);const I=this;function o(u,p){let D=p;Object.defineProperty(I,u,{get:function(){return D!==void 0?D:p},set:function(k){D!==k&&(D=k,g[u]=k,i[u]=k,I.dispatchEvent({type:u+"-changed",value:k}),I.dispatchEvent(TM))}}),I[u]=p,g[u]=p,i[u]=p}o("camera",A),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const s=new S,C=new S,a=new UA,r=new UA,B=new S,Q=new UA,E=new S,h=new S,d=new S,l=0,c=new S;o("worldPosition",s),o("worldPositionStart",C),o("worldQuaternion",a),o("worldQuaternionStart",r),o("cameraPosition",B),o("cameraQuaternion",Q),o("pointStart",E),o("pointEnd",h),o("rotationAxis",d),o("rotationAngle",l),o("eye",c),this._offset=new S,this._startNorm=new S,this._endNorm=new S,this._cameraScale=new S,this._parentPosition=new S,this._parentQuaternion=new UA,this._parentQuaternionInv=new UA,this._parentScale=new S,this._worldScaleStart=new S,this._worldQuaternionInv=new UA,this._worldScale=new S,this._positionStart=new S,this._quaternionStart=new UA,this._scaleStart=new S,this._getPointer=_9.bind(this),this._onPointerDown=P9.bind(this),this._onPointerHover=O9.bind(this),this._onPointerMove=j9.bind(this),this._onPointerUp=W9.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(A){if(this.object===void 0||this.dragging===!0)return;A!==null&&zr.setFromCamera(A,this.camera);const e=HM(this._gizmo.picker[this.mode],zr);e?this.axis=e.object.name:this.axis=null}pointerDown(A){if(!(this.object===void 0||this.dragging===!0||A!=null&&A.button!==0)&&this.axis!==null){A!==null&&zr.setFromCamera(A,this.camera);const e=HM(this._plane,zr,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,RL.mode=this.mode,this.dispatchEvent(RL)}}pointerMove(A){const e=this.axis,i=this.mode,g=this.object;let I=this.space;if(i==="scale"?I="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(I="world"),g===void 0||e===null||this.dragging===!1||A!==null&&A.button!==-1)return;A!==null&&zr.setFromCamera(A,this.camera);const o=HM(this._plane,zr,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),I==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),I==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),g.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(I==="local"&&(g.position.applyQuaternion(Vt.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(g.position.x=Math.round(g.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(g.position.y=Math.round(g.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(g.position.z=Math.round(g.position.z/this.translationSnap)*this.translationSnap),g.position.applyQuaternion(this._quaternionStart)),I==="world"&&(g.parent&&g.position.add(AI.setFromMatrixPosition(g.parent.matrixWorld)),e.search("X")!==-1&&(g.position.x=Math.round(g.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(g.position.y=Math.round(g.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(g.position.z=Math.round(g.position.z/this.translationSnap)*this.translationSnap),g.parent&&g.position.sub(AI.setFromMatrixPosition(g.parent.matrixWorld))));else if(i==="scale"){if(e.search("XYZ")!==-1){let s=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(s*=-1),Cn.set(s,s,s)}else AI.copy(this.pointStart),Cn.copy(this.pointEnd),AI.applyQuaternion(this._worldQuaternionInv),Cn.applyQuaternion(this._worldQuaternionInv),Cn.divide(AI),e.search("X")===-1&&(Cn.x=1),e.search("Y")===-1&&(Cn.y=1),e.search("Z")===-1&&(Cn.z=1);g.scale.copy(this._scaleStart).multiply(Cn),this.scaleSnap&&(e.search("X")!==-1&&(g.scale.x=Math.round(g.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(g.scale.y=Math.round(g.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(g.scale.z=Math.round(g.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const s=20/this.worldPosition.distanceTo(AI.setFromMatrixPosition(this.camera.matrixWorld));let C=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(AI.copy(this.rotationAxis).cross(this.eye))*s):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(GL[e]),AI.copy(GL[e]),I==="local"&&AI.applyQuaternion(this.worldQuaternion),AI.cross(this.eye),AI.length()===0?C=!0:this.rotationAngle=this._offset.dot(AI.normalize())*s),(e==="E"||C)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),I==="local"&&e!=="E"&&e!=="XYZE"?(g.quaternion.copy(this._quaternionStart),g.quaternion.multiply(Vt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),g.quaternion.copy(Vt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),g.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(TM),this.dispatchEvent(NL)}}pointerUp(A){A!==null&&A.button!==0||(this.dragging&&this.axis!==null&&(UL.mode=this.mode,this.dispatchEvent(UL)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(A){A.geometry&&A.geometry.dispose(),A.material&&A.material.dispose()})}attach(A){return this.object=A,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(TM),this.dispatchEvent(NL),this.pointStart.copy(this.pointEnd))}getRaycaster(){return zr}getMode(){return this.mode}setMode(A){this.mode=A}setTranslationSnap(A){this.translationSnap=A}setRotationSnap(A){this.rotationSnap=A}setScaleSnap(A){this.scaleSnap=A}setSize(A){this.size=A}setSpace(A){this.space=A}}function _9(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const A=this.domElement.getBoundingClientRect();return{x:(t.clientX-A.left)/A.width*2-1,y:-(t.clientY-A.top)/A.height*2+1,button:t.button}}}function O9(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t));break}}function P9(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function j9(t){this.enabled&&this.pointerMove(this._getPointer(t))}function W9(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function HM(t,A,e){const i=A.intersectObject(t,!0);for(let g=0;g<i.length;g++)if(i[g].object.visible||e)return i[g];return!1}const zD=new Ot,Ft=new S(0,1,0),FL=new S(0,0,0),KL=new GA,ZD=new UA,VD=new UA,Ws=new S,JL=new GA,Yc=new S(1,0,0),Zr=new S(0,1,0),Tc=new S(0,0,1),XD=new S,Hc=new S,_c=new S;class _M extends pA{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const A=new at({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new ki({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=A.clone();i.opacity=.15;const g=e.clone();g.opacity=.5;const I=A.clone();I.color.setHex(16711680);const o=A.clone();o.color.setHex(65280);const s=A.clone();s.color.setHex(255);const C=A.clone();C.color.setHex(16711680),C.opacity=.5;const a=A.clone();a.color.setHex(65280),a.opacity=.5;const r=A.clone();r.color.setHex(255),r.opacity=.5;const B=A.clone();B.opacity=.25;const Q=A.clone();Q.color.setHex(16776960),Q.opacity=.25,A.clone().color.setHex(16776960);const E=A.clone();E.color.setHex(7895160);const h=new Ji(0,.04,.1,12);h.translate(0,.05,0);const d=new Lt(.08,.08,.08);d.translate(0,.04,0);const l=new Be;l.setAttribute("position",new Ce([0,0,0,1,0,0],3));const c=new Ji(.0075,.0075,.5,3);c.translate(0,.25,0);function u(v,j){const q=new Na(v,.0075,3,64,j*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function p(){const v=new Be;return v.setAttribute("position",new Ce([0,0,0,1,1,1],3)),v}const D={X:[[new hA(h,I),[.5,0,0],[0,0,-Math.PI/2]],[new hA(h,I),[-.5,0,0],[0,0,Math.PI/2]],[new hA(c,I),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new hA(h,o),[0,.5,0]],[new hA(h,o),[0,-.5,0],[Math.PI,0,0]],[new hA(c,o)]],Z:[[new hA(h,s),[0,0,.5],[Math.PI/2,0,0]],[new hA(h,s),[0,0,-.5],[-Math.PI/2,0,0]],[new hA(c,s),null,[Math.PI/2,0,0]]],XYZ:[[new hA(new Ua(.1,0),B.clone()),[0,0,0]]],XY:[[new hA(new Lt(.15,.15,.01),r.clone()),[.15,.15,0]]],YZ:[[new hA(new Lt(.15,.15,.01),C.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new hA(new Lt(.15,.15,.01),a.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},k={X:[[new hA(new Ji(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new hA(new Ji(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new hA(new Ji(.2,0,.6,4),i),[0,.3,0]],[new hA(new Ji(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new hA(new Ji(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new hA(new Ji(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new hA(new Ua(.2,0),i)]],XY:[[new hA(new Lt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new hA(new Lt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new hA(new Lt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},G={START:[[new hA(new Ua(.01,2),g),null,null,null,"helper"]],END:[[new hA(new Ua(.01,2),g),null,null,null,"helper"]],DELTA:[[new Mi(p(),g),null,null,null,"helper"]],X:[[new Mi(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mi(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mi(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new hA(u(.5,1),E),null,[0,Math.PI/2,0]]],X:[[new hA(u(.5,.5),I)]],Y:[[new hA(u(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new hA(u(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new hA(u(.75,1),Q),null,[0,Math.PI/2,0]]]},m={AXIS:[[new Mi(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},K={XYZE:[[new hA(new Ks(.25,10,8),i)]],X:[[new hA(new Na(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new hA(new Na(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new hA(new Na(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new hA(new Na(.75,.1,2,24),i)]]},f={X:[[new hA(d,I),[.5,0,0],[0,0,-Math.PI/2]],[new hA(c,I),[0,0,0],[0,0,-Math.PI/2]],[new hA(d,I),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new hA(d,o),[0,.5,0]],[new hA(c,o)],[new hA(d,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new hA(d,s),[0,0,.5],[Math.PI/2,0,0]],[new hA(c,s),[0,0,0],[Math.PI/2,0,0]],[new hA(d,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new hA(new Lt(.15,.15,.01),r),[.15,.15,0]]],YZ:[[new hA(new Lt(.15,.15,.01),C),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new hA(new Lt(.15,.15,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new hA(new Lt(.1,.1,.1),B.clone())]]},N={X:[[new hA(new Ji(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new hA(new Ji(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new hA(new Ji(.2,0,.6,4),i),[0,.3,0]],[new hA(new Ji(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new hA(new Ji(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new hA(new Ji(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new hA(new Lt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new hA(new Lt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new hA(new Lt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new hA(new Lt(.2,.2,.2),i),[0,0,0]]]},H={X:[[new Mi(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mi(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mi(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function _(v){const j=new pA;for(const q in v)for(let L=v[q].length;L--;){const Y=v[q][L][0].clone(),$=v[q][L][1],X=v[q][L][2],sA=v[q][L][3],yA=v[q][L][4];Y.name=q,Y.tag=yA,$&&Y.position.set($[0],$[1],$[2]),X&&Y.rotation.set(X[0],X[1],X[2]),sA&&Y.scale.set(sA[0],sA[1],sA[2]),Y.updateMatrix();const KA=Y.geometry.clone();KA.applyMatrix4(Y.matrix),Y.geometry=KA,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),j.add(Y)}return j}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=_(D)),this.add(this.gizmo.rotate=_(M)),this.add(this.gizmo.scale=_(f)),this.add(this.picker.translate=_(k)),this.add(this.picker.rotate=_(K)),this.add(this.picker.scale=_(N)),this.add(this.helper.translate=_(G)),this.add(this.helper.rotate=_(m)),this.add(this.helper.scale=_(H)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(A){const e=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:VD;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let g=0;g<i.length;g++){const I=i[g];I.visible=!0,I.rotation.set(0,0,0),I.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),I.scale.set(1,1,1).multiplyScalar(o*this.size/4),I.tag==="helper"){I.visible=!1,I.name==="AXIS"?(I.visible=!!this.axis,this.axis==="X"&&(Vt.setFromEuler(zD.set(0,0,0)),I.quaternion.copy(e).multiply(Vt),Math.abs(Ft.copy(Yc).applyQuaternion(e).dot(this.eye))>.9&&(I.visible=!1)),this.axis==="Y"&&(Vt.setFromEuler(zD.set(0,0,Math.PI/2)),I.quaternion.copy(e).multiply(Vt),Math.abs(Ft.copy(Zr).applyQuaternion(e).dot(this.eye))>.9&&(I.visible=!1)),this.axis==="Z"&&(Vt.setFromEuler(zD.set(0,Math.PI/2,0)),I.quaternion.copy(e).multiply(Vt),Math.abs(Ft.copy(Tc).applyQuaternion(e).dot(this.eye))>.9&&(I.visible=!1)),this.axis==="XYZE"&&(Vt.setFromEuler(zD.set(0,Math.PI/2,0)),Ft.copy(this.rotationAxis),I.quaternion.setFromRotationMatrix(KL.lookAt(FL,Ft,Zr)),I.quaternion.multiply(Vt),I.visible=this.dragging),this.axis==="E"&&(I.visible=!1)):I.name==="START"?(I.position.copy(this.worldPositionStart),I.visible=this.dragging):I.name==="END"?(I.position.copy(this.worldPosition),I.visible=this.dragging):I.name==="DELTA"?(I.position.copy(this.worldPositionStart),I.quaternion.copy(this.worldQuaternionStart),AI.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),AI.applyQuaternion(this.worldQuaternionStart.clone().invert()),I.scale.copy(AI),I.visible=this.dragging):(I.quaternion.copy(e),this.dragging?I.position.copy(this.worldPositionStart):I.position.copy(this.worldPosition),this.axis&&(I.visible=this.axis.search(I.name)!==-1));continue}I.quaternion.copy(e),this.mode==="translate"||this.mode==="scale"?(I.name==="X"&&Math.abs(Ft.copy(Yc).applyQuaternion(e).dot(this.eye))>.99&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1),I.name==="Y"&&Math.abs(Ft.copy(Zr).applyQuaternion(e).dot(this.eye))>.99&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1),I.name==="Z"&&Math.abs(Ft.copy(Tc).applyQuaternion(e).dot(this.eye))>.99&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1),I.name==="XY"&&Math.abs(Ft.copy(Tc).applyQuaternion(e).dot(this.eye))<.2&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1),I.name==="YZ"&&Math.abs(Ft.copy(Yc).applyQuaternion(e).dot(this.eye))<.2&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1),I.name==="XZ"&&Math.abs(Ft.copy(Zr).applyQuaternion(e).dot(this.eye))<.2&&(I.scale.set(1e-10,1e-10,1e-10),I.visible=!1)):this.mode==="rotate"&&(ZD.copy(e),Ft.copy(this.eye).applyQuaternion(Vt.copy(e).invert()),I.name.search("E")!==-1&&I.quaternion.setFromRotationMatrix(KL.lookAt(this.eye,FL,Zr)),I.name==="X"&&(Vt.setFromAxisAngle(Yc,Math.atan2(-Ft.y,Ft.z)),Vt.multiplyQuaternions(ZD,Vt),I.quaternion.copy(Vt)),I.name==="Y"&&(Vt.setFromAxisAngle(Zr,Math.atan2(Ft.x,Ft.z)),Vt.multiplyQuaternions(ZD,Vt),I.quaternion.copy(Vt)),I.name==="Z"&&(Vt.setFromAxisAngle(Tc,Math.atan2(Ft.y,Ft.x)),Vt.multiplyQuaternions(ZD,Vt),I.quaternion.copy(Vt))),I.visible=I.visible&&(I.name.indexOf("X")===-1||this.showX),I.visible=I.visible&&(I.name.indexOf("Y")===-1||this.showY),I.visible=I.visible&&(I.name.indexOf("Z")===-1||this.showZ),I.visible=I.visible&&(I.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),I.material._color=I.material._color||I.material.color.clone(),I.material._opacity=I.material._opacity||I.material.opacity,I.material.color.copy(I.material._color),I.material.opacity=I.material._opacity,this.enabled&&this.axis&&(I.name===this.axis||this.axis.split("").some(function(s){return I.name===s}))&&(I.material.color.setHex(16776960),I.material.opacity=1)}super.updateMatrixWorld(A)}}class z9 extends hA{constructor(){super(new zi(1e5,1e5,2,2),new at({visible:!1,wireframe:!0,side:Et,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(A){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),XD.copy(Yc).applyQuaternion(e==="local"?this.worldQuaternion:VD),Hc.copy(Zr).applyQuaternion(e==="local"?this.worldQuaternion:VD),_c.copy(Tc).applyQuaternion(e==="local"?this.worldQuaternion:VD),Ft.copy(Hc),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ft.copy(this.eye).cross(XD),Ws.copy(XD).cross(Ft);break;case"Y":Ft.copy(this.eye).cross(Hc),Ws.copy(Hc).cross(Ft);break;case"Z":Ft.copy(this.eye).cross(_c),Ws.copy(_c).cross(Ft);break;case"XY":Ws.copy(_c);break;case"YZ":Ws.copy(XD);break;case"XZ":Ft.copy(_c),Ws.copy(Hc);break;case"XYZ":case"E":Ws.set(0,0,0);break}break;case"rotate":default:Ws.set(0,0,0)}Ws.length()===0?this.quaternion.copy(this.cameraQuaternion):(JL.lookAt(AI.set(0,0,0),Ws,Ft),this.quaternion.setFromRotationMatrix(JL)),super.updateMatrixWorld(A)}}const Z9=tA("debugpatch");function $D(t,A,e,i){const g=Z9===A;if(!e&&!i)return;const I=A+"___needle";X9(t,A,e,i);const o=Object.getOwnPropertyDescriptor(t,A),s=t[A];g&&console.log("Patch",t.constructor.name,A,o,s),o?(g&&console.log("Apply patch with existing descriptor",t.constructor.name,A,o),typeof o.value=="function"&&(t[A]=bL(o.value,t,A))):(g&&console.log("Create patch with new property",t.constructor.name,A,o),Object.defineProperty(t,A,{set:function(C){if(typeof C=="function")this[I]=bL(C,t,A);else{const a=this[I];qL(t,A,this,a,C),this[I]=C,LL(t,A,this,a,C)}},get:function(){const C=this[I];return typeof C=="function"&&C[I]?C[I]:C}}))}function V9(t,A,e){const i=PM(t,A);if(i)for(let g=i.length-1;g>=0;g--){const I=i[g];I.prefix===e&&(I.prefix=null),I.postfix===e&&(I.postfix=null),!I.prefix&&!I.postfix&&i.splice(g,1)}}const vL=Symbol("Needle:Patches:WrappedFunction");function bL(t,A,e){if(t[vL])return t;const i=function(...g){qL(A,e,this,...g);const I=t.apply(this,g);return LL(A,e,this,I,...g),I};return i[vL]=!0,i}const Ay="Needle:Patches";function OM(){return globalThis[Ay]||(globalThis[Ay]=new WeakMap),globalThis[Ay]}function PM(t,A){const e=OM().get(t);return e?e.get(A):null}function X9(t,A,e,i){let g=OM().get(t);g||(g=new Map,OM().set(t,g));let I=g.get(A);I||(I=[],g.set(A,I)),I.push({prefix:e,postfix:i})}function qL(t,A,e,...i){var g;if(!e)return;const I=PM(t,A);if(I)for(const o of I)(g=o.prefix)==null||g.call(e,...i)}function LL(t,A,e,i,...g){var I;if(!e)return;const o=PM(t,A);if(o)for(const s of o)(I=s.postfix)==null||I.call(e,i,...g)}const xL=Symbol("gltf-loader-internal-usage-tracker"),$9=tA("debugusers"),ey=class{constructor(t){n(this,"parser"),n(this,"_getDependency"),n(this,"_loadingId"),n(this,"_loadedObjects",new Set),this.parser=t,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(t){return ey._loadingProcesses>0}beforeRoot(){ey._loadingProcesses++;const t=this,A=this._getDependency;return this.parser.getDependency=function(e,i){const g=A.call(this,e,i);return g.then(I=>(I&&(t._loadedObjects.add(I),I[xL]=t._loadingId),I)),g},null}afterRoot(t){ey._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const A of this._loadedObjects)delete A[xL],A instanceof pA&&(A.parent||A instanceof hA&&setTimeout(()=>{$9&&console.warn("> GLTF LOADER: Mesh not used in scene!",A),A.material=null,A.geometry=null},1e3));return null}};let jM=ey;n(jM,"_loadingProcesses",0);class YL{constructor(){window.addEventListener("unhandledrejection",A=>{var e;if(A.defaultPrevented)return;const i=(e=A?.reason)==null?void 0:e.path;if(i){const g=i[0];g&&g.tagName==="IMG"&&(console.warn(`Could not load image:
4344
- `+g.src),A.preventDefault())}})}}const ty=tA("trackresources");function TL(){return ty==="dispose"}let Vr=!0;ty===0&&(Vr=!1);function A6(t){Vr=t}function HL(){return Vr}const _L=Symbol("disposable");function WM(t,A){t&&(t[_L]=A,Xr&&console.warn("Set disposable",A,t))}const OL=Symbol("disposed");function e6(t){return t[OL]===!0}function Jt(t){var A;if(t){if(t[_L]===!1){Xr&&console.warn("Object is marked as not disposable",t);return}if(t[OL]=!0,t instanceof Vg)Jt(t.environment),Jt(t.background),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial);else if(t instanceof Mo)Jt(t.geometry),Jt(t.material),Jt(t.skeleton),Jt(t.bindMatrix),Jt(t.bindMatrixInverse),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial),t.geometry=null,t.material=null;else if(t instanceof hA)Jt(t.geometry),Jt(t.material),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial),t.geometry=null,t.material=null;else if(t instanceof Be){AE(t);for(const e of Object.keys(t.attributes)){const i=t.attributes[e];Jt(i)}}else if(t instanceof ee||t instanceof JI)Xr&&console.warn("BufferAttribute dispose not supported",t.count);else if(t instanceof Array)for(const e of t)e instanceof Ue&&Jt(e);else if(t instanceof Ue){AE(t);for(const i of Object.keys(t)){const g=t[i];g instanceof de&&(Jt(g),t[i]=null)}const e=t.uniforms;if(e)for(const i of Object.keys(e)){const g=e[i];g instanceof de?(Jt(g),e[i]=null):g instanceof SA&&(Jt(g.value),g.value=null)}}else t instanceof de?(AE(t),AE(t.source),((A=t.source)==null?void 0:A.data)instanceof ImageBitmap&&AE(t.source.data)):t instanceof mh?(AE(t.boneTexture),t.boneTexture=null):t instanceof Qc||!(t instanceof pA)&&Xr&&console.warn("Unknown object type",t)}}function AE(t){t&&((Xr||TL()||ty)&&console.warn("\u{1F9E8} FREE",t),t instanceof ImageBitmap?t.close():t instanceof vC?t.data=null:t.dispose())}function PL(t){(t instanceof hA||t instanceof Mo)&&(t.material=null,t.geometry=null)}const t6=new Set;function iy(t,A,e=null,i){if(i||(i=t6,i.clear()),!t)return i;const g=t[Oc];if(g)for(const I of g)i.has(I)||e?.call(null,I)!==!1&&(i.add(I),A&&iy(I,!0,e,i));return i}function i6(t){return t[Pc]}const Xr=tA("debugresourceusers")||tA("debugmemory"),Oc=Symbol("needle-resource-users"),Pc=Symbol("needle-resource-users-count");function uI(t,A){$D(t,A,function(e,i){Vr&&(gy(Oc,this,e,!1),gy(Oc,this,i,!0))})}Vr&&(uI(hA.prototype,"material"),uI(hA.prototype,"geometry"),uI(Ue.prototype,"map"),uI(Ue.prototype,"bumpMap"),uI(Ue.prototype,"alphaMap"),uI(Ue.prototype,"normalMap"),uI(Ue.prototype,"displacementMap"),uI(Ue.prototype,"roughnessMap"),uI(Ue.prototype,"metalnessMap"),uI(Ue.prototype,"emissiveMap"),uI(Ue.prototype,"specularMap"),uI(Ue.prototype,"envMap"),uI(Ue.prototype,"lightMap"),uI(Ue.prototype,"aoMap"),uI(Ue.prototype,"gradientMap"));function g6(t){if(Vr===!1)return;const A=t[Oc];if(A)for(const e of A)gy(Oc,e,t,!1)}Vr&&$D(Ue.prototype,"dispose",function(){g6(this)});let zM=0;function gy(t,A,e,i){if(zM>0)return;if(Array.isArray(e)){for(const I of e)gy(t,A,I,i);return}if(!e)return;let g=e[t];if(g||(g=new Set),i){if(A&&!g.has(A)){g.add(A);let I=e[Pc]||0;I+=1,e[Pc]=I,Xr&&console.warn(`\u{1F7E2} Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[Pc]||0;I>0&&(I-=1,e[Pc]=I),Xr&&console.warn(`\u{1F534} Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(jM.isLoading(e)||(ty&&console.warn(`\u{1F534} Removed all user of "${e.type}"`,e),TL()&&Jt(e)))}e[t]=g}try{$D(_C.prototype,"render",function(){zM++},function(){zM--})}catch(t){console.warn("Could not wrap WebGLRenderer.render",t)}var jc=(t=>(t.Added="component-added",t.Removing="removing-component",t))(jc||{});const jL=tA("debugcomponentevents");class Wc{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let i=this.eventListeners.get(A);i||(i=[]),i.push(e),this.eventListeners.set(A,i),jL&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const i=this.eventListeners.get(A);if(!i)return;const g=i.indexOf(e);g<0||i.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const i=this.eventListeners.get(A);if(jL&&console.log("Dispatching event "+A,i),!!i)for(const g of i)g(e)}}n(Wc,"eventListeners",new Map);const WL=tA("debugdefines");eE('if(!globalThis[""3.36.1-beta""]) globalThis[""3.36.1-beta""] = "0.0.0";'),eE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),eE('if(!globalThis[""Wed Apr 03 2024 09:14:09 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 03 2024 09:14:09 GMT+0200 (Central European Summer Time)""] = "unknown";'),eE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.1-beta";'),eE('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),eE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 03 2024 09:14:09 GMT+0200 (Central European Summer Time)";');const VC="3.36.1-beta",Iy="undefined",ZM="Wed Apr 03 2024 09:14:09 GMT+0200 (Central European Summer Time)";WL&&console.log(`Engine version: ${VC} (generator: ${Iy})
4344
+ `+g.src),A.preventDefault())}})}}const ty=tA("trackresources");function TL(){return ty==="dispose"}let Vr=!0;ty===0&&(Vr=!1);function A6(t){Vr=t}function HL(){return Vr}const _L=Symbol("disposable");function WM(t,A){t&&(t[_L]=A,Xr&&console.warn("Set disposable",A,t))}const OL=Symbol("disposed");function e6(t){return t[OL]===!0}function Jt(t){var A;if(t){if(t[_L]===!1){Xr&&console.warn("Object is marked as not disposable",t);return}if(t[OL]=!0,t instanceof Vg)Jt(t.environment),Jt(t.background),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial);else if(t instanceof Mo)Jt(t.geometry),Jt(t.material),Jt(t.skeleton),Jt(t.bindMatrix),Jt(t.bindMatrixInverse),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial),t.geometry=null,t.material=null;else if(t instanceof hA)Jt(t.geometry),Jt(t.material),Jt(t.customDepthMaterial),Jt(t.customDistanceMaterial),t.geometry=null,t.material=null;else if(t instanceof Be){AE(t);for(const e of Object.keys(t.attributes)){const i=t.attributes[e];Jt(i)}}else if(t instanceof ee||t instanceof JI)Xr&&console.warn("BufferAttribute dispose not supported",t.count);else if(t instanceof Array)for(const e of t)e instanceof Ue&&Jt(e);else if(t instanceof Ue){AE(t);for(const i of Object.keys(t)){const g=t[i];g instanceof de&&(Jt(g),t[i]=null)}const e=t.uniforms;if(e)for(const i of Object.keys(e)){const g=e[i];g instanceof de?(Jt(g),e[i]=null):g instanceof SA&&(Jt(g.value),g.value=null)}}else t instanceof de?(AE(t),AE(t.source),((A=t.source)==null?void 0:A.data)instanceof ImageBitmap&&AE(t.source.data)):t instanceof mh?(AE(t.boneTexture),t.boneTexture=null):t instanceof Qc||!(t instanceof pA)&&Xr&&console.warn("Unknown object type",t)}}function AE(t){t&&((Xr||TL()||ty)&&console.warn("\u{1F9E8} FREE",t),t instanceof ImageBitmap?t.close():t instanceof vC?t.data=null:t.dispose())}function PL(t){(t instanceof hA||t instanceof Mo)&&(t.material=null,t.geometry=null)}const t6=new Set;function iy(t,A,e=null,i){if(i||(i=t6,i.clear()),!t)return i;const g=t[Oc];if(g)for(const I of g)i.has(I)||e?.call(null,I)!==!1&&(i.add(I),A&&iy(I,!0,e,i));return i}function i6(t){return t[Pc]}const Xr=tA("debugresourceusers")||tA("debugmemory"),Oc=Symbol("needle-resource-users"),Pc=Symbol("needle-resource-users-count");function uI(t,A){$D(t,A,function(e,i){Vr&&(gy(Oc,this,e,!1),gy(Oc,this,i,!0))})}Vr&&(uI(hA.prototype,"material"),uI(hA.prototype,"geometry"),uI(Ue.prototype,"map"),uI(Ue.prototype,"bumpMap"),uI(Ue.prototype,"alphaMap"),uI(Ue.prototype,"normalMap"),uI(Ue.prototype,"displacementMap"),uI(Ue.prototype,"roughnessMap"),uI(Ue.prototype,"metalnessMap"),uI(Ue.prototype,"emissiveMap"),uI(Ue.prototype,"specularMap"),uI(Ue.prototype,"envMap"),uI(Ue.prototype,"lightMap"),uI(Ue.prototype,"aoMap"),uI(Ue.prototype,"gradientMap"));function g6(t){if(Vr===!1)return;const A=t[Oc];if(A)for(const e of A)gy(Oc,e,t,!1)}Vr&&$D(Ue.prototype,"dispose",function(){g6(this)});let zM=0;function gy(t,A,e,i){if(zM>0)return;if(Array.isArray(e)){for(const I of e)gy(t,A,I,i);return}if(!e)return;let g=e[t];if(g||(g=new Set),i){if(A&&!g.has(A)){g.add(A);let I=e[Pc]||0;I+=1,e[Pc]=I,Xr&&console.warn(`\u{1F7E2} Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[Pc]||0;I>0&&(I-=1,e[Pc]=I),Xr&&console.warn(`\u{1F534} Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(jM.isLoading(e)||(ty&&console.warn(`\u{1F534} Removed all user of "${e.type}"`,e),TL()&&Jt(e)))}e[t]=g}try{$D(_C.prototype,"render",function(){zM++},function(){zM--})}catch(t){console.warn("Could not wrap WebGLRenderer.render",t)}var jc=(t=>(t.Added="component-added",t.Removing="removing-component",t))(jc||{});const jL=tA("debugcomponentevents");class Wc{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let i=this.eventListeners.get(A);i||(i=[]),i.push(e),this.eventListeners.set(A,i),jL&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const i=this.eventListeners.get(A);if(!i)return;const g=i.indexOf(e);g<0||i.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const i=this.eventListeners.get(A);if(jL&&console.log("Dispatching event "+A,i),!!i)for(const g of i)g(e)}}n(Wc,"eventListeners",new Map);const WL=tA("debugdefines");eE('if(!globalThis[""3.36.2-beta""]) globalThis[""3.36.2-beta""] = "0.0.0";'),eE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),eE('if(!globalThis[""Wed Apr 03 2024 13:36:57 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 03 2024 13:36:57 GMT+0200 (Central European Summer Time)""] = "unknown";'),eE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.2-beta";'),eE('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),eE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 03 2024 13:36:57 GMT+0200 (Central European Summer Time)";');const VC="3.36.2-beta",Iy="undefined",ZM="Wed Apr 03 2024 13:36:57 GMT+0200 (Central European Summer Time)";WL&&console.log(`Engine version: ${VC} (generator: ${Iy})
4345
4345
  Project built at ${ZM}`);const XC="needle_isActiveInHierarchy",$r="builtin_components",zc="needle_editor_guid";function eE(t){try{(0,eval)(t)}catch(A){WL&&console.error(A)}}const Zc=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),zL=Symbol("isUsingInstancing"),ZL=Symbol("instancingRenderer"),Vc=Symbol("instancingAutoUpdateBounds");class is{static isUsingInstancing(A){return A[zL]===!0}static getRenderer(A){return A[ZL]||null}setAutoUpdateBounds(A,e){const i=is.getRenderer(A);i&&(i[Vc]=e)}static markDirty(A,e=!0){if(A&&(this.isUsingInstancing(A)&&(A[Zc]=!0,A.matrixWorldNeedsUpdate=!0),e))for(const i of A.children)is.markDirty(i,!0)}}function AB(t,A){try{A?t(A):t()}catch(e){return console.error(e),!1}return!0}const VM=tA("debugnewscripts"),I6=tA("debughierarchy"),Xt=[];function o6(){return Xt.length>0}function oy(t){if(!(t.new_scripts.length<=0)){if(VM&&console.log("Register new components",t.new_scripts.length,[...t.new_scripts],t.alias?"element: "+t.alias:t.hash,t),t.new_scripts_pre_setup_callbacks.length>0){for(const A of t.new_scripts_pre_setup_callbacks)A&&A();t.new_scripts_pre_setup_callbacks.length=0}Xt.length=0,t.new_scripts.length>0&&Xt.push(...t.new_scripts),t.new_scripts.length=0;for(let A=0;A<Xt.length;A++)try{const e=Xt[A];if(e.isComponent!==!0){(Ee()||VM)&&console.error(`Registered script is not a Needle Engine component.
4346
4346
  The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
4347
4347
  `,e),Xt.splice(A,1),A--;continue}if(e.destroyed)continue;if(!e.gameObject){console.error("MISSING GAMEOBJECT - will ignore",e),Xt.splice(A,1),A--;continue}e.context=t,Xc(e.gameObject),XM(e,t)}catch(e){console.error(e),$C(Xt[A],t),Xt.splice(A,1),A--}for(let A=0;A<Xt.length;A++)try{const e=Xt[A];if(e.destroyed){$C(Xt[A],t),Xt.splice(A,1),A--;continue}if(e.registering)try{e.registering()}catch(i){console.error(i)}e.__internalAwake!==void 0&&(e.gameObject||console.error("MISSING GAMEOBJECT",e,e.gameObject),Xc(e.gameObject),e.activeAndEnabled&&AB(e.__internalAwake.bind(e)))}catch(e){console.error(e),$C(Xt[A],t),Xt.splice(A,1),A--}for(let A=0;A<Xt.length;A++)try{const e=Xt[A];if(e.destroyed||e.enabled===!1||(Xc(e.gameObject),e.activeAndEnabled===!1))continue;e.__internalEnable!==void 0&&(e.enabled=!0,AB(e.__internalEnable.bind(e)))}catch(e){console.error(e),$C(Xt[A],t),Xt.splice(A,1),A--}for(let A=0;A<Xt.length;A++)try{const e=Xt[A];if(e.destroyed||!e.gameObject)continue;t.new_script_start.push(e)}catch(e){console.error(e),$C(Xt[A],t),Xt.splice(A,1),A--}Xt.length=0;for(const A of t.new_scripts_post_setup_callbacks)A&&A();t.new_scripts_post_setup_callbacks.length=0}}function s6(t){t&&(t.__internalDisable(!0),$C(t,t.context))}function VL(t,A){for(let e=0;e<t.new_script_start.length;e++)try{const i=t.new_script_start[e];if(A!==void 0&&i.gameObject!==A||i.destroyed||i.activeAndEnabled===!1)continue;AB(i.__internalAwake.bind(i)),i.enabled&&(AB(i.__internalEnable.bind(i)),AB(i.__internalStart.bind(i)),t.new_script_start.splice(e,1),e--)}catch(i){console.error(i),$C(t.new_script_start[e],t),t.new_script_start.splice(e,1),e--}}function XM(t,A){A.scripts.indexOf(t)===-1&&(A.scripts.push(t),t.earlyUpdate&&A.scripts_earlyUpdate.push(t),t.update&&A.scripts_update.push(t),t.lateUpdate&&A.scripts_lateUpdate.push(t),t.onBeforeRender&&A.scripts_onBeforeRender.push(t),t.onAfterRender&&A.scripts_onAfterRender.push(t),t.onPausedChanged&&A.scripts_pausedChanged.push(t),$M(t,null)&&A.new_scripts_xr.push(t),$M(t,"immersive-vr")&&A.scripts_immersive_vr.push(t),$M(t,"immersive-ar")&&A.scripts_immersive_ar.push(t))}function $C(t,A){Jo(t,A.new_scripts),Jo(t,A.new_script_start),Jo(t,A.scripts),Jo(t,A.scripts_earlyUpdate),Jo(t,A.scripts_update),Jo(t,A.scripts_lateUpdate),Jo(t,A.scripts_onBeforeRender),Jo(t,A.scripts_onAfterRender),Jo(t,A.scripts_pausedChanged),Jo(t,A.new_scripts_xr),Jo(t,A.scripts_immersive_vr),Jo(t,A.scripts_immersive_ar),A.stopAllCoroutinesFrom(t)}function Jo(t,A){const e=A.indexOf(t);e>=0&&A.splice(e,1)}function $M(t,A){var e;if(t){const i=t;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(A!=null&&((e=i.supportsXR)==null?void 0:e.call(i,A))===!1)}return!1}function sy(t){if(t||(t=tt.Current.scene),!t){console.trace("Invalid call - no current context.");return}const A=QE(t);XL(t,A,!0)||(VM||Ee()?console.error(`Error updating hierarchy
@@ -6213,7 +6213,7 @@ Texture:`,i),this.setLightmapDebugMaterial()),this.applyLightmap())}updateLightm
6213
6213
  gl_FragColor = lightMapTexel;
6214
6214
  gl_FragColor.a = 1.;
6215
6215
  }
6216
- `,defines:{USE_LIGHTMAP:""}})}}var qoA=Object.defineProperty,LoA=Object.getOwnPropertyDescriptor,wa=(t,A,e,i)=>{for(var g=i>1?void 0:i?LoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&qoA(A,e,g),g};const Rd=tA("debugrenderer"),xoA=tA("debugskinnedmesh"),F_=tA("noinstancing"),KB=tA("debugprogressive"),K_=tA("noprogressive"),YoA=tA("wireframe");class iN{constructor(){n(this,"path",null),n(this,"asset",null),n(this,"default")}}class ToA{constructor(A,e){n(this,"_renderer"),n(this,"_targets",[]),n(this,"_indexMapMaxIndex"),n(this,"_indexMap"),n(this,"_changed",!1),this._renderer=A;const i=this.setMaterial.bind(this),g=this.getMaterial.bind(this),I=A.gameObject;if(this._targets=[],I)switch(I.type){case"Group":this._targets=[...I.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(I);break}let o=!1,s,C=0;for(let a=0;a<this._targets.length;a++){const r=this._targets[a];if(!r)continue;const B=r.material;if(B){B.shadowSide=B.side;for(let Q=0;Q<e.length;Q++){const E=e[Q];if(!E){o=!0;continue}if(B.name===E.name){s===void 0&&(s=new Map),s.set(Q,a),C=Math.max(C,Q);break}}}}if(o){this._indexMapMaxIndex=C,this._indexMap=s;const a=`Renderer ${A.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(a),TI()&&Zt("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(a,r){if(typeof r=="string"){const B=parseInt(r);if(!isNaN(B))return g(B)}return a[r]},set(a,r,B){return typeof r=="string"&&i(B,Number.parseInt(r)),Reflect.set(a,r,B)?(B instanceof Ue&&(a.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(A){A===!0&&Rd&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=A}is(A){return this._renderer===A}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let A=0;A<this.length;A++)yield this.getMaterial(A)}resolveIndex(A){const e=this._indexMap;return e&&e.has(A)?e.get(A):A}setMaterial(A,e){if(e=this.resolveIndex(e),e<0||e>=this._targets.length)return;const i=this._targets[e];!i||i.material===void 0||(i.material=A,this.changed=!0)}getMaterial(A){if(A=this.resolveIndex(A),A<0)return null;const e=this._targets;if(A>=e.length)return null;const i=e[A];return i?i.material:null}}var gN;const Ud=(gN=class extends FA{constructor(){super(...arguments),n(this,"receiveShadows",!1),n(this,"shadowCastingMode",0),n(this,"lightmapIndex",-1),n(this,"lightmapScaleOffset",new VA(1,1,0,0)),n(this,"enableInstancing"),n(this,"renderOrder"),n(this,"allowOcclusionWhenDynamic",!0),n(this,"probeAnchor"),n(this,"reflectionProbeUsage",0),n(this,"_lightmaps"),n(this,"_sharedMeshes",[]),n(this,"_sharedMaterials"),n(this,"_originalMaterials"),n(this,"_lightmapTextureOverride"),n(this,"allowProgressiveLoading",!0),n(this,"_firstFrame",-1),n(this,"_isInstancingEnabled",!1),n(this,"handles"),n(this,"_wasVisible",!1),n(this,"onBeforeRenderThree",(t,A,e,i,g,I)=>{var o;if(!this._wasVisible&&this.context.time.frame>this._firstFrame+1&&(KB&&console.debug("onBeforeRenderThree: Object becomes visible for the first time",this.name,this.context.time.frame),this._wasVisible=!0),g.envMapIntensity!==void 0){const s=this.hasLightmap?Math.PI:1,C=((o=this.context.mainCameraComponent)==null?void 0:o.environmentIntensity)??1;g.envMapIntensity=Math.max(0,C*this.context.sceneLighting.environmentIntensity/s)}if(this._lightmaps)for(const s of this._lightmaps)s.updateLightmapUniforms(g)}),n(this,"automaticallyUpdateLODLevel",!0),n(this,"hasTextureLODs",!0),n(this,"hasMeshLODs",!0),n(this,"_lastLodLevel",-1),n(this,"_nextLodTestTime",0),n(this,"_randomLodLevelCheckFrameOffset",Math.floor(Math.random()*100)),n(this,"_sphere",new di),n(this,"_box",new pt),n(this,"_reflectionProbe",null)}static setInstanced(t,A){const e=Ml(t,Ud);return e.setInstancingEnabled(A),e}static isInstanced(t){const A=BB(t,Ud);return A?A.isInstancingActive:is.isUsingInstancing(t)}static setVisible(t,A){zE(t,A)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const t of this.gameObject.children)(t.type==="Mesh"||t.type==="SkinnedMesh")&&this._sharedMeshes.push(t);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(t){this.sharedMaterials[0]!==t&&(this.sharedMaterials[0]=t,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(t){this.sharedMaterial=t}set sharedMaterials(t){if(!this._originalMaterials)this._originalMaterials=t;else if(t){let A=!1;for(let e=0;e<this._sharedMaterials.length;e++){const i=e<t.length?t[e]:null;i&&i instanceof Ue?this.sharedMaterials[e]=i:A||(A=!0,console.warn("Can not assign null as material: "+this.name,i))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new ToA(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return F_}get lightmap(){var t;return(t=this._lightmaps)!=null&&t.length?this._lightmaps[0].lightmap:null}set lightmap(t){var A;if(this._lightmapTextureOverride=t,t===void 0&&(t=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(A=this._lightmaps)!=null&&A.length)for(const e of this._lightmaps)e.lightmap=t}get hasLightmap(){return this.lightmap!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(this._firstFrame=this.context.time.frame,Rd&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&Rd&&this.probeAnchor.add(new Go(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const t of this.gameObject.children)this.context.addBeforeRenderListener(t,this.onBeforeRenderThree),t.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let t=0;for(let A=0;A<this.gameObject.children.length;A++){const e=this.gameObject.children[A];if(!(!this.isMeshOrSkinnedMesh(e)||oA.getComponent(e,Ud))){if(this.renderOrder.length<=t){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+t,"ChildElement:",e);continue}e.renderOrder=this.renderOrder[t],t+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),YoA)for(let t=0;t<this.sharedMaterials.length;t++){const A=this.sharedMaterials[t];A&&(A.wireframe=!0)}}applyLightmapping(){var t;if(this.lightmapIndex>=0){const A=this.gameObject.type,e=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(e){if(this._lightmaps||(this._lightmaps=[]),A==="Mesh"){const i=this.gameObject.material;if(i!=null&&i.isMeshBasicMaterial)i&&console.warn("Lightmapping is not supported on MeshBasicMaterial",i.name);else{if(this._lightmaps.length<=0){const g=new Gd(this.gameObject,this.context);this._lightmaps.push(g)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,e)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let i=0;i<this.gameObject.children.length;i++){const g=this.gameObject.children[i];if(!((t=g.material)!=null&&t.isMeshBasicMaterial)){let I;i>=this._lightmaps.length?(I=new Gd(g,this.context),this._lightmaps.push(I)):I=this._lightmaps[i],I.init(this.lightmapIndex,this.lightmapScaleOffset,e)}}}else Rd&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}get isInstancingActive(){return this.handles!=null&&this.handles.length>0&&this._isInstancingEnabled}setInstancingEnabled(t){if(this._isInstancingEnabled===t)return t&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=t,t){if(this.enableInstancing===void 0&&(this.enableInstancing=!0),this.handles===void 0){if(this.handles=kd.instance.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return oA.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const A of this.handles)A.updateInstanceMatrix(!0),A.add();return oA.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const A of this.handles)A.remove(this.destroyed);return!0}return!1}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!F_&&(this.setInstancingEnabled(!0),is.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let t=0;t<this.gameObject.children.length;t++){const A=this.gameObject.children[t];A.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled||this.enableInstancing?this.__internalDidAwakeAndStart&&this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe(),this.testIfLODLevelsAreAvailable()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const t of this.gameObject.children)this.context.removeBeforeRenderListener(t,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}onBeforeRender(){var t,A;if(this.gameObject){if(Rd==this.name&&this.gameObject instanceof hA){this.gameObject.geometry.computeBoundingSphere();const e=gi(this.gameObject.geometry.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);me.DrawWireSphere(e,this.gameObject.geometry.boundingSphere.radius,56831)}if(this.isMultiMaterialObject(this.gameObject)&&((t=this.gameObject.children)==null?void 0:t.length)>0)for(const e of this.gameObject.children)this.applySettings(e);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(A=this.handles)!=null&&A.length&&this.gameObject[Zc]===!0){this.gameObject[Zc]=!1;for(let e=this.handles.length-1;e>=0;e--)this.handles[e].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&oA.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const i=this.handles[e];zE(i.object,!1)}this._wasVisible&&this.allowProgressiveLoading&&this.automaticallyUpdateLODLevel&&this.updateLODs(),this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let t=0;t<this.handles.length;t++){const A=this.handles[t];this._wasVisible=!0,zE(A.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this),KB&&this._lastLodLevel>=0&&this.drawGizmoLodLevel(!1)}testIfLODLevelsAreAvailable(){this.automaticallyUpdateLODLevel=!1,this.hasMeshLODs=!1,this.hasTextureLODs=!1;for(const t of this.sharedMeshes)if(_t.hasLODLevelAvailable(t)){this.automaticallyUpdateLODLevel=!0,this.hasMeshLODs=!0;break}for(const t of this.sharedMaterials)if(t&&_t.hasLODLevelAvailable(t)){this.automaticallyUpdateLODLevel=!0,this.hasTextureLODs=!0;break}KB&&console.log(`${this.name}
6216
+ `,defines:{USE_LIGHTMAP:""}})}}var qoA=Object.defineProperty,LoA=Object.getOwnPropertyDescriptor,wa=(t,A,e,i)=>{for(var g=i>1?void 0:i?LoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&qoA(A,e,g),g};const Rd=tA("debugrenderer"),xoA=tA("debugskinnedmesh"),F_=tA("noinstancing"),KB=tA("debugprogressive"),K_=tA("noprogressive"),YoA=tA("wireframe");class iN{constructor(){n(this,"path",null),n(this,"asset",null),n(this,"default")}}class ToA{constructor(A,e){n(this,"_renderer"),n(this,"_targets",[]),n(this,"_indexMapMaxIndex"),n(this,"_indexMap"),n(this,"_changed",!1),this._renderer=A;const i=this.setMaterial.bind(this),g=this.getMaterial.bind(this),I=A.gameObject;if(this._targets=[],I)switch(I.type){case"Group":this._targets=[...I.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(I);break}let o=!1,s,C=0;for(let a=0;a<this._targets.length;a++){const r=this._targets[a];if(!r)continue;const B=r.material;if(B){B.shadowSide=B.side;for(let Q=0;Q<e.length;Q++){const E=e[Q];if(!E){o=!0;continue}if(B.name===E.name){s===void 0&&(s=new Map),s.set(Q,a),C=Math.max(C,Q);break}}}}if(o){this._indexMapMaxIndex=C,this._indexMap=s;const a=`Renderer ${A.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(a),TI()&&Zt("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(a,r){if(typeof r=="string"){const B=parseInt(r);if(!isNaN(B))return g(B)}return a[r]},set(a,r,B){return typeof r=="string"&&i(B,Number.parseInt(r)),Reflect.set(a,r,B)?(B instanceof Ue&&(a.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(A){A===!0&&Rd&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=A}is(A){return this._renderer===A}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let A=0;A<this.length;A++)yield this.getMaterial(A)}resolveIndex(A){const e=this._indexMap;return e&&e.has(A)?e.get(A):A}setMaterial(A,e){if(e=this.resolveIndex(e),e<0||e>=this._targets.length)return;const i=this._targets[e];!i||i.material===void 0||(i.material=A,this.changed=!0)}getMaterial(A){if(A=this.resolveIndex(A),A<0)return null;const e=this._targets;if(A>=e.length)return null;const i=e[A];return i?i.material:null}}var gN;const Ud=(gN=class extends FA{constructor(){super(...arguments),n(this,"receiveShadows",!1),n(this,"shadowCastingMode",0),n(this,"lightmapIndex",-1),n(this,"lightmapScaleOffset",new VA(1,1,0,0)),n(this,"enableInstancing"),n(this,"renderOrder"),n(this,"allowOcclusionWhenDynamic",!0),n(this,"probeAnchor"),n(this,"reflectionProbeUsage",0),n(this,"_lightmaps"),n(this,"_sharedMeshes",[]),n(this,"_sharedMaterials"),n(this,"_originalMaterials"),n(this,"_lightmapTextureOverride"),n(this,"allowProgressiveLoading",!0),n(this,"_firstFrame",-1),n(this,"_isInstancingEnabled",!1),n(this,"handles"),n(this,"_wasVisible",!1),n(this,"onBeforeRenderThree",(t,A,e,i,g,I)=>{var o;if(!this._wasVisible&&this.context.time.frame>this._firstFrame+1&&(KB&&console.debug("onBeforeRenderThree: Object becomes visible for the first time",this.name,this.context.time.frame),this._wasVisible=!0),g.envMapIntensity!==void 0){const s=this.hasLightmap?Math.PI:1,C=((o=this.context.mainCameraComponent)==null?void 0:o.environmentIntensity)??1;g.envMapIntensity=Math.max(0,C*this.context.sceneLighting.environmentIntensity/s)}if(this._lightmaps)for(const s of this._lightmaps)s.updateLightmapUniforms(g)}),n(this,"automaticallyUpdateLODLevel",!0),n(this,"hasTextureLODs",!0),n(this,"hasMeshLODs",!0),n(this,"_lastLodLevel",-1),n(this,"_nextLodTestTime",0),n(this,"_randomLodLevelCheckFrameOffset",Math.floor(Math.random()*100)),n(this,"_sphere",new di),n(this,"_box",new pt),n(this,"_reflectionProbe",null)}static setInstanced(t,A){const e=Ml(t,Ud);return e.setInstancingEnabled(A),e}static isInstanced(t){const A=BB(t,Ud);return A?A.isInstancingActive:is.isUsingInstancing(t)}static setVisible(t,A){zE(t,A)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const t of this.gameObject.children)(t.type==="Mesh"||t.type==="SkinnedMesh")&&this._sharedMeshes.push(t);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(t){this.sharedMaterials[0]!==t&&(this.sharedMaterials[0]=t,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(t){this.sharedMaterial=t}set sharedMaterials(t){if(!this._originalMaterials)this._originalMaterials=t;else if(t){let A=!1;for(let e=0;e<this._sharedMaterials.length;e++){const i=e<t.length?t[e]:null;i&&i instanceof Ue?this.sharedMaterials[e]=i:A||(A=!0,console.warn("Can not assign null as material: "+this.name,i))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new ToA(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return F_}get lightmap(){var t;return(t=this._lightmaps)!=null&&t.length?this._lightmaps[0].lightmap:null}set lightmap(t){var A;if(this._lightmapTextureOverride=t,t===void 0&&(t=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(A=this._lightmaps)!=null&&A.length)for(const e of this._lightmaps)e.lightmap=t}get hasLightmap(){return this.lightmap!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(this._firstFrame=this.context.time.frame,Rd&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&Rd&&this.probeAnchor.add(new Go(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const t of this.gameObject.children)this.context.addBeforeRenderListener(t,this.onBeforeRenderThree),t.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let t=0;for(let A=0;A<this.gameObject.children.length;A++){const e=this.gameObject.children[A];if(!(!this.isMeshOrSkinnedMesh(e)||oA.getComponent(e,Ud))){if(this.renderOrder.length<=t){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+t,"ChildElement:",e);continue}e.renderOrder=this.renderOrder[t],t+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),YoA)for(let t=0;t<this.sharedMaterials.length;t++){const A=this.sharedMaterials[t];A&&(A.wireframe=!0)}}applyLightmapping(){var t;if(this.lightmapIndex>=0){const A=this.gameObject.type,e=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(e){if(this._lightmaps||(this._lightmaps=[]),A==="Mesh"){const i=this.gameObject.material;if(i!=null&&i.isMeshBasicMaterial)i&&console.warn("Lightmapping is not supported on MeshBasicMaterial",i.name);else{if(this._lightmaps.length<=0){const g=new Gd(this.gameObject,this.context);this._lightmaps.push(g)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,e)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let i=0;i<this.gameObject.children.length;i++){const g=this.gameObject.children[i];if(!((t=g.material)!=null&&t.isMeshBasicMaterial)){let I;i>=this._lightmaps.length?(I=new Gd(g,this.context),this._lightmaps.push(I)):I=this._lightmaps[i],I.init(this.lightmapIndex,this.lightmapScaleOffset,e)}}}else Rd&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}get isInstancingActive(){return this.handles!=null&&this.handles.length>0&&this._isInstancingEnabled}setInstancingEnabled(t){if(this._isInstancingEnabled===t)return t&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=t,t){if(this.enableInstancing===void 0&&(this.enableInstancing=!0),this.handles===void 0){if(this.handles=kd.instance.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return oA.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const A of this.handles)A.updateInstanceMatrix(!0),A.add();return oA.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const A of this.handles)A.remove(this.destroyed);return!0}return!1}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!F_&&(this.setInstancingEnabled(!0),is.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let t=0;t<this.gameObject.children.length;t++){const A=this.gameObject.children[t];A.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled||this.enableInstancing==!0||Array.isArray(this.enableInstancing)&&this.enableInstancing.some(t=>t)?this.__internalDidAwakeAndStart&&this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe(),this.testIfLODLevelsAreAvailable()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const t of this.gameObject.children)this.context.removeBeforeRenderListener(t,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}onBeforeRender(){var t,A;if(this.gameObject){if(Rd==this.name&&this.gameObject instanceof hA){this.gameObject.geometry.computeBoundingSphere();const e=gi(this.gameObject.geometry.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);me.DrawWireSphere(e,this.gameObject.geometry.boundingSphere.radius,56831)}if(this.isMultiMaterialObject(this.gameObject)&&((t=this.gameObject.children)==null?void 0:t.length)>0)for(const e of this.gameObject.children)this.applySettings(e);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(A=this.handles)!=null&&A.length&&this.gameObject[Zc]===!0){this.gameObject[Zc]=!1;for(let e=this.handles.length-1;e>=0;e--)this.handles[e].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&oA.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const i=this.handles[e];zE(i.object,!1)}this._wasVisible&&this.allowProgressiveLoading&&this.automaticallyUpdateLODLevel&&this.updateLODs(),this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let t=0;t<this.handles.length;t++){const A=this.handles[t];this._wasVisible=!0,zE(A.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this),KB&&this._lastLodLevel>=0&&this.drawGizmoLodLevel(!1)}testIfLODLevelsAreAvailable(){this.automaticallyUpdateLODLevel=!1,this.hasMeshLODs=!1,this.hasTextureLODs=!1;for(const t of this.sharedMeshes)if(_t.hasLODLevelAvailable(t)){this.automaticallyUpdateLODLevel=!0,this.hasMeshLODs=!0;break}for(const t of this.sharedMaterials)if(t&&_t.hasLODLevelAvailable(t)){this.automaticallyUpdateLODLevel=!0,this.hasTextureLODs=!0;break}KB&&console.log(`${this.name}
6217
6217
  Mesh LODs available? ${this.hasMeshLODs?"YES":"NO"}
6218
6218
  Texture LODs available? ${this.hasTextureLODs?"YES":"NO"}`)}updateLODs(){let t=0;this.hasMeshLODs&&(t=this.calculateLodLevel());const A=0;for(const e of this.sharedMaterials)e&&this.loadProgressiveTextures(e,A);if(t>=0)for(let e=0;e<this.sharedMeshes.length;e++){const i=this.sharedMeshes[e];i&&this.loadProgressiveMeshes(i,t)}}calculateLodLevel(t=!1){var A;if(!t&&(this.context.time.frame+this._randomLodLevelCheckFrameOffset)%3!=0)return this._lastLodLevel;if(this.context.time.realtimeSinceStartup<this._nextLodTestTime)return this._lastLodLevel;const e=10;let i=e+1;if(this.context.mainCamera){const g=hs()?.6:.4;for(const I of this.sharedMeshes){if(i<=0)break;if(!I)continue;if(KB&&I["DEBUG:LOD"]!=null)return this._lastLodLevel=I["DEBUG:LOD"];let o=0;const s=_t.getMeshLODInformation(I.geometry);s?.density!=null&&(o=Math.log2(s.density||0)/2-6);const C=(A=this.context.mainCameraComponent)==null?void 0:A.getFrustum();if(!(C!=null&&C.intersectsObject(I))){if(KB&&I.geometry.boundingSphere){const r=I.geometry.boundingSphere;this._sphere.copy(r),this._sphere.applyMatrix4(I.matrixWorld),me.DrawWireSphere(this._sphere.center,this._sphere.radius*1.01,16733525,.5)}continue}const a=I.geometry.boundingBox;if(a&&this.context.mainCamera instanceof be){if(I.geometry.attributes.color&&I.geometry.attributes.color.count<100&&I.geometry.boundingSphere&&(this._sphere.copy(I.geometry.boundingSphere),this._sphere.applyMatrix4(I.matrixWorld),this._sphere.containsPoint(Ne(this.context.mainCamera)))){i=0;break}this._box.copy(a),this._box.applyMatrix4(I.matrixWorld),this._box.applyMatrix4(this.context.mainCameraComponent.getProjectionScreenMatrix(Ud.tempMatrix));let r=this._box.getSize(gi()).y/2;r/=Math.pow(2,o-.5);let B=999,Q=g;for(let E=0;E<e;E++){if(r>Q){B=E;break}Q/=2}B<i&&(i=B)}}}return i=Math.round(i),this._lastLodLevel!=i&&(this._nextLodTestTime=this.context.time.realtimeSinceStartup+.5,KB&&(KB=="verbose"&&console.warn(`LOD Level changed from ${this._lastLodLevel} to ${i} for ${this.name}`),this.drawGizmoLodLevel(!0))),this._lastLodLevel=i,i}drawGizmoLodLevel(t){const A=this._lastLodLevel,e=this.context.mainCamera.worldForward,i=this.context.mainCamera.worldPosition;for(const g of this.sharedMeshes)if(g&&g.geometry.boundingSphere){const I=g.geometry.boundingSphere;this._sphere.copy(I),this._sphere.applyMatrix4(g.matrixWorld);const o=this._sphere.center,s=this._sphere.radius,C=["#76c43e","#bcc43e","#c4ac3e","#c4673e","#ff3e3e"];if(t)me.DrawWireSphere(o,s,C[A],.1);else{const a="LOD "+A+`
6219
6219
  `+g.geometry.index.count/3,r=gi(e).multiplyScalar(s*.7).add(o),B=r.distanceTo(i);g.geometry.index.count/3;const Q=C[Math.min(C.length-1,A)]+"88",E=Math.min(10,s);me.DrawLabel(r,a,B*.001+E*.03,void 0,16777215,Q)}}}applyStencil(){VU.applyStencil(this)}loadProgressiveTextures(t,A){return!K_&&t&&this.allowProgressiveLoading&&(t.userData||(t.userData={}),t.userData.LOD!==A)?(t.userData.LOD=A,_t.assignTextureLOD(this.context,this.sourceId,t,A)):Promise.resolve(!0)}loadProgressiveMeshes(t,A){if(!K_&&t&&this.allowProgressiveLoading&&(t.userData||(t.userData={}),t.userData.LOD!==A)){t.userData.LOD=A;const e=t.geometry;return _t.assignMeshLOD(this.context,this.sourceId,t,A).then(i=>{if(i&&t.userData.LOD==A&&e!=t.geometry&&(this.applyLightmapping(),this.handles))for(const g of this.handles)g.setGeometry(t.geometry)})}return!0}applySettings(t){t.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?t.castShadow=!0:t.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),Yi.LateUpdate)}}*_updateReflectionProbe(){const t=this.probeAnchor||this.gameObject,A=!!this.probeAnchor;this._reflectionProbe=ZE.get(t,this.context,A,this.probeAnchor)}setVisibility(t){if(!this.isMultiMaterialObject(this.gameObject))zE(this.gameObject,t);else for(const A of this.gameObject.children)this.isMeshOrSkinnedMesh(A)&&zE(A,t)}isMultiMaterialObject(t){return t.type==="Group"}isMeshOrSkinnedMesh(t){return t.type==="Mesh"||t.type==="SkinnedMesh"}},n(gN,"tempMatrix",new GA),gN);let Fi=Ud;wa([y()],Fi.prototype,"receiveShadows",2),wa([y()],Fi.prototype,"shadowCastingMode",2),wa([y()],Fi.prototype,"lightmapIndex",2),wa([y(VA)],Fi.prototype,"lightmapScaleOffset",2),wa([y()],Fi.prototype,"enableInstancing",2),wa([y()],Fi.prototype,"renderOrder",2),wa([y()],Fi.prototype,"allowOcclusionWhenDynamic",2),wa([y(pA)],Fi.prototype,"probeAnchor",2),wa([y()],Fi.prototype,"reflectionProbeUsage",2);class Nd extends Fi{}class IN extends Nd{constructor(){super(...arguments),n(this,"_needUpdateBoundingSphere",!1)}awake(){var A;super.awake(),this.allowOcclusionWhenDynamic=!1,(A=this.gameObject.parent)==null||A.updateWorldMatrix(!1,!0),this.markBoundsDirty()}onAfterRender(){if(super.onAfterRender(),this.gameObject instanceof Mo&&this._needUpdateBoundingSphere){this._needUpdateBoundingSphere=!1;const A=this.gameObject.geometry,e=Sl(this.gameObject);e&&(this.gameObject.geometry=e),this.gameObject.computeBoundingSphere(),this.gameObject.geometry=A}if(xoA&&this.gameObject instanceof Mo&&this.gameObject.boundingSphere){const A=gi(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);me.DrawWireSphere(A,this.gameObject.boundingSphere.radius,"red")}}markBoundsDirty(){this._needUpdateBoundingSphere=!0}}var HoA=Object.defineProperty,_oA=Object.getOwnPropertyDescriptor,gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?_oA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HoA(A,e,g),g};const eS=tA("debugparticles");var Sa=(t=>(t[t.Billboard=0]="Billboard",t[t.Stretch=1]="Stretch",t[t.HorizontalBillboard=2]="HorizontalBillboard",t[t.VerticalBillboard=3]="VerticalBillboard",t[t.Mesh=4]="Mesh",t))(Sa||{});let Tn=class{constructor(){n(this,"alphaKeys"),n(this,"colorKeys")}get duration(){return 1}evaluate(t,A){let e,i=0,g=null,I=0;for(let o=0;o<this.alphaKeys.length;o++){const s=this.alphaKeys[o];(s.time<t||!e)&&(e=s,i=o)}for(let o=0;o<this.colorKeys.length;o++){const s=this.colorKeys[o];(s.time<t||!g)&&(g=s,I=o)}if(g)if(I+1<this.colorKeys.length){const o=this.colorKeys[I+1],s=Ae.remap(t,g.time,o.time,0,1);A.r=Ae.lerp(g.color.r,o.color.r,s),A.g=Ae.lerp(g.color.g,o.color.g,s),A.b=Ae.lerp(g.color.b,o.color.b,s)}else A.r=g.color.r,A.g=g.color.g,A.b=g.color.b;if(e)if(i+1<this.alphaKeys.length){const o=this.alphaKeys[i+1],s=Ae.remap(t,e.time,o.time,0,1);A.alpha=Ae.lerp(e.alpha,o.alpha,s)}else A.alpha=e.alpha;return A}};gA([y()],Tn.prototype,"alphaKeys",2),gA([y()],Tn.prototype,"colorKeys",2);var Fd=(t=>(t[t.Local=0]="Local",t[t.World=1]="World",t[t.Custom=2]="Custom",t))(Fd||{}),tS=(t=>(t[t.Sphere=0]="Sphere",t[t.SphereShell=1]="SphereShell",t[t.Hemisphere=2]="Hemisphere",t[t.HemisphereShell=3]="HemisphereShell",t[t.Cone=4]="Cone",t[t.Box=5]="Box",t[t.Mesh=6]="Mesh",t[t.ConeShell=7]="ConeShell",t[t.ConeVolume=8]="ConeVolume",t[t.ConeVolumeShell=9]="ConeVolumeShell",t[t.Circle=10]="Circle",t[t.CircleEdge=11]="CircleEdge",t[t.SingleSidedEdge=12]="SingleSidedEdge",t[t.MeshRenderer=13]="MeshRenderer",t[t.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",t[t.BoxShell=15]="BoxShell",t[t.BoxEdge=16]="BoxEdge",t[t.Donut=17]="Donut",t[t.Rectangle=18]="Rectangle",t[t.Sprite=19]="Sprite",t[t.SpriteRenderer=20]="SpriteRenderer",t))(tS||{});const J_=class{constructor(){n(this,"mode"),n(this,"constant"),n(this,"constantMin"),n(this,"constantMax"),n(this,"curve"),n(this,"curveMin"),n(this,"curveMax"),n(this,"curveMultiplier")}clone(){var t,A,e;const i=new J_;return i.mode=this.mode,i.constant=this.constant,i.constantMin=this.constantMin,i.constantMax=this.constantMax,i.curve=(t=this.curve)==null?void 0:t.clone(),i.curveMin=(A=this.curveMin)==null?void 0:A.clone(),i.curveMax=(e=this.curveMax)==null?void 0:e.clone(),i.curveMultiplier=this.curveMultiplier,i}evaluate(t,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.constant;case 1:return t=Ae.clamp01(t),this.curve.evaluate(t)*this.curveMultiplier;case 2:const i=t*this.curveMin.duration,g=t*this.curveMax.duration;return Ae.lerp(this.curveMin.evaluate(i),this.curveMax.evaluate(g),e%1)*this.curveMultiplier;case 3:return Ae.lerp(this.constantMin,this.constantMax,e%1);default:this.curveMax.evaluate(t)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(t){if(!t)return 0;let A=Number.MIN_VALUE;for(let e=0;e<t.keys.length;e++){const i=t.keys[e];i.value>A&&(A=i.value)}return A}};let ne=J_;gA([y()],ne.prototype,"mode",2),gA([y()],ne.prototype,"constant",2),gA([y()],ne.prototype,"constantMin",2),gA([y()],ne.prototype,"constantMax",2),gA([y(lB)],ne.prototype,"curve",2),gA([y(lB)],ne.prototype,"curveMin",2),gA([y(lB)],ne.prototype,"curveMax",2),gA([y()],ne.prototype,"curveMultiplier",2);var iS;const Us=(iS=class{constructor(){n(this,"mode"),n(this,"color"),n(this,"colorMin"),n(this,"colorMax"),n(this,"gradient"),n(this,"gradientMin"),n(this,"gradientMax")}evaluate(t,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(t,Us._temp),Us._temp;case 2:return Us._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(t,Us._temp),this.gradientMax.evaluate(t,Us._temp2),Us._temp.lerp(Us._temp2,e)}return Us._temp.set(16711935),Us._temp.alpha=1,Us._temp}},n(iS,"_temp",new wt(0,0,0,1)),n(iS,"_temp2",new wt(0,0,0,1)),iS);let PI=Us;gA([y(wt)],PI.prototype,"color",2),gA([y(wt)],PI.prototype,"colorMin",2),gA([y(wt)],PI.prototype,"colorMax",2),gA([y(Tn)],PI.prototype,"gradient",2),gA([y(Tn)],PI.prototype,"gradientMin",2),gA([y(Tn)],PI.prototype,"gradientMax",2);var oN=(t=>(t[t.Hierarchy=0]="Hierarchy",t[t.Local=1]="Local",t[t.Shape=2]="Shape",t))(oN||{});class Lg{constructor(){n(this,"cullingMode"),n(this,"duration"),n(this,"emitterVelocityMode"),n(this,"flipRotation"),n(this,"gravityModifier"),n(this,"gravityModifierMultiplier"),n(this,"loop"),n(this,"maxParticles"),n(this,"playOnAwake"),n(this,"prewarm"),n(this,"ringBufferLoopRange"),n(this,"ringBufferMode"),n(this,"scalingMode"),n(this,"simulationSpace"),n(this,"simulationSpeed"),n(this,"startColor"),n(this,"startDelay"),n(this,"startDelayMultiplier"),n(this,"startLifetime"),n(this,"startLifetimeMultiplier"),n(this,"startRotation"),n(this,"startRotationMultiplier"),n(this,"startRotation3D"),n(this,"startRotationX"),n(this,"startRotationXMultiplier"),n(this,"startRotationY"),n(this,"startRotationYMultiplier"),n(this,"startRotationZ"),n(this,"startRotationZMultiplier"),n(this,"startSize"),n(this,"startSize3D"),n(this,"startSizeMultiplier"),n(this,"startSizeX"),n(this,"startSizeXMultiplier"),n(this,"startSizeY"),n(this,"startSizeYMultiplier"),n(this,"startSizeZ"),n(this,"startSizeZMultiplier"),n(this,"startSpeed"),n(this,"startSpeedMultiplier"),n(this,"stopAction"),n(this,"useUnscaledTime")}}gA([y(ne)],Lg.prototype,"gravityModifier",2),gA([y(PI)],Lg.prototype,"startColor",2),gA([y(ne)],Lg.prototype,"startDelay",2),gA([y(ne)],Lg.prototype,"startLifetime",2),gA([y(ne)],Lg.prototype,"startRotation",2),gA([y(ne)],Lg.prototype,"startRotationX",2),gA([y(ne)],Lg.prototype,"startRotationY",2),gA([y(ne)],Lg.prototype,"startRotationZ",2),gA([y(ne)],Lg.prototype,"startSize",2),gA([y(ne)],Lg.prototype,"startSizeX",2),gA([y(ne)],Lg.prototype,"startSizeY",2),gA([y(ne)],Lg.prototype,"startSizeZ",2),gA([y(ne)],Lg.prototype,"startSpeed",2);class Kd{constructor(){n(this,"cycleCount"),n(this,"maxCount"),n(this,"minCount"),n(this,"probability"),n(this,"repeatInterval"),n(this,"time"),n(this,"count"),n(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(A>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=Ae.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=Ae.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class BC{constructor(){n(this,"enabled"),n(this,"bursts"),n(this,"rateOverTime"),n(this,"rateOverTimeMultiplier"),n(this,"rateOverDistance"),n(this,"rateOverDistanceMultiplier"),n(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const i=this.bursts[e];this.system.main.loop&&i.time>=this.system.time&&i.reset(),A+=Math.round(i.run(this.system.time))}return A}}gA([y()],BC.prototype,"enabled",2),gA([y()],BC.prototype,"bursts",2),gA([y(ne)],BC.prototype,"rateOverTime",2),gA([y()],BC.prototype,"rateOverTimeMultiplier",2),gA([y(ne)],BC.prototype,"rateOverDistance",2),gA([y()],BC.prototype,"rateOverDistanceMultiplier",2);class Jd{constructor(){n(this,"enabled"),n(this,"color")}}gA([y(PI)],Jd.prototype,"color",2);class Hn{constructor(){n(this,"enabled"),n(this,"separateAxes"),n(this,"size"),n(this,"sizeMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier"),n(this,"_time",0),n(this,"_temp",new S)}evaluate(A,e,i){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,i)*this.xMultiplier,e.y=this.y.evaluate(A,i)*this.yMultiplier,e.z=this.z.evaluate(A,i)*this.zMultiplier;else{const g=this.size.evaluate(A,i)*this.sizeMultiplier;e.x=g}return e}}gA([y(ne)],Hn.prototype,"size",2),gA([y(ne)],Hn.prototype,"x",2),gA([y(ne)],Hn.prototype,"y",2),gA([y(ne)],Hn.prototype,"z",2);var gS;const vd=(gS=class{constructor(){n(this,"shapeType",5),n(this,"enabled",!0),n(this,"alignToDirection",!1),n(this,"angle",0),n(this,"arc",360),n(this,"arcSpread"),n(this,"arcSpeedMultiplier"),n(this,"arcMode"),n(this,"boxThickness"),n(this,"position"),n(this,"rotation"),n(this,"_rotation",new Ot),n(this,"scale"),n(this,"radius"),n(this,"radiusThickness"),n(this,"sphericalDirectionAmount"),n(this,"randomDirectionAmount"),n(this,"randomPositionAmount"),n(this,"meshShapeType"),n(this,"meshRenderer"),n(this,"_meshObj"),n(this,"_meshGeometry"),n(this,"system"),n(this,"_space"),n(this,"_worldSpaceMatrix",new GA),n(this,"_worldSpaceMatrixInverse",new GA),n(this,"_vector",new S(0,0,0)),n(this,"_temp",new S(0,0,0)),n(this,"_triangle",new vI),n(this,"_dir",new S),n(this,"_loopTime",0),n(this,"_loopDirection",1),eS&&console.log(this)}get type(){return tS[this.shapeType]}initialize(t){this.onInitialize(t),t.position.copy(this._vector)}toJSON(){return this}clone(){return new vd}setMesh(t){this.meshRenderer=t,t?(this._meshObj=t.sharedMeshes[Math.floor(Math.random()*t.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(t,A,e,i){this.system=t,this._space=e,e===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(t){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=Ae.toRadians(this.rotation.x),this._rotation.y=Ae.toRadians(this.rotation.y),this._rotation.z=Ae.toRadians(this.rotation.z),this._rotation.order="ZYX",t.applyEuler(this._rotation)),A}onInitialize(t){this._vector.set(0,0,0),t.mesh=void 0,t.mesh_geometry=void 0;const A=this._temp.copy(this.position),e=this._space===1;e&&A.applyQuaternion(this.system.worldQuaternion);let i=this.radius;if(e&&(i*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:eS&&me.DrawWireBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(A);break;case 4:this.randomConePoint(this.position,this.angle,i,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,i,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,i,this.radiusThickness,this.arc,this._vector);break;case 13:const g=this.meshRenderer;g?.destroyed==!1&&this.setMesh(g);const I=t.mesh=this._meshObj,o=t.mesh_geometry=this._meshGeometry;if(I&&o)switch(this.meshShapeType){case 0:{const s=o.getAttribute("position"),C=Math.floor(Math.random()*s.count);this._vector.fromBufferAttribute(s,C),this._vector.applyMatrix4(I.matrixWorld),t.mesh_normal=C}break;case 1:break;case 2:{const s=o.index;if(s){let C=Math.random(),a=Math.random();C+a>1&&(C=1-C,a=1-a);const r=Math.floor(Math.random()*(s.count/3));let B=r*3,Q=r*3+1,E=r*3+2;B=s.getX(B),Q=s.getX(Q),E=s.getX(E);const h=o.getAttribute("position");this._triangle.a.fromBufferAttribute(h,B),this._triangle.b.fromBufferAttribute(h,Q),this._triangle.c.fromBufferAttribute(h,E),this._vector.set(0,0,0).addScaledVector(this._triangle.a,C).addScaledVector(this._triangle.b,a).addScaledVector(this._triangle.c,1-(C+a)),this._vector.applyMatrix4(I.matrixWorld),t.mesh_normal=r}}break}break;default:this._vector.set(0,0,0),Ee()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",tS[this.shapeType]),globalThis.__particlesystem_shapetype_unsupported=!0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),eS&&me.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(t,A){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const i=A.x,g=A.y,I=A.z;this._dir.set(i,g,I),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const o=t.mesh,s=t.mesh_geometry;if(o&&s)switch(this.meshShapeType){case 0:{const C=s.getAttribute("normal"),a=t.mesh_normal;this._dir.fromBufferAttribute(C,a)}break;case 1:break;case 2:{const C=s.index;if(C){const a=t.mesh_normal,r=C.getX(a*3),B=C.getX(a*3+1),Q=C.getX(a*3+2),E=s.getAttribute("position"),h=gi(),d=gi(),l=gi();h.fromBufferAttribute(E,r),d.fromBufferAttribute(E,B),l.fromBufferAttribute(E,Q),h.sub(d),l.sub(d),h.cross(l),this._dir.copy(h).multiplyScalar(-1);const c=kt(o);this._dir.applyQuaternion(c)}}break}break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),eS&&(me.DrawSphere(A,.01,8925952,.5,!0),me.DrawDirection(A,this._dir,8925952,.5,!0)),this._dir}randomizePosition(t,A){if(A<=0)return;const e=vd._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,t.add(e)}randomizeDirection(t,A){if(A===0)return;const e=vd._randomQuat,i=vd._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(i,A*Math.random()*Math.PI),t.applyQuaternion(e)}spherizeDirection(t,A){if(A===0)return;const e=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(e),I=Math.sin(i)*Math.sin(e),o=Math.cos(i),s=new S(g,I,o);t.lerp(s,A)}randomSpherePoint(t,A,e,i,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(i/360),C=Math.acos(2*o-1),a=Ae.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,r=t.x+this.scale.x*(-a*Math.sin(C)*Math.cos(s)),B=t.y+this.scale.y*(a*Math.sin(C)*Math.sin(s)),Q=t.z+this.scale.z*(a*Math.cos(C));g.x=r,g.y=B,g.z=Q}randomCirclePoint(t,A,e,i,g){const I=Math.random(),o=2*Math.PI*I*(i/360),s=Ae.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=t.x+this.scale.x*s*Math.cos(o),a=t.y+this.scale.y*s*Math.sin(o),r=t.z;g.x=C,g.y=a,g.z=r}randomConePoint(t,A,e,i,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let a=2*Math.PI*s*(g/360);switch(I){case 2:case 1:a+=Math.PI+.5,a+=this._loopTime*Math.PI*2,a%=Ae.toRadians(g);break}const r=Math.acos(2*C-1),B=Ae.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*e,Q=t.x+-B*Math.sin(r)*Math.cos(a),E=t.y+B*Math.sin(r)*Math.sin(a),h=t.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},n(gS,"_randomQuat",new UA),n(gS,"_tempVec",new S),gS);let ni=vd;gA([y()],ni.prototype,"shapeType",2),gA([y()],ni.prototype,"enabled",2),gA([y()],ni.prototype,"alignToDirection",2),gA([y()],ni.prototype,"angle",2),gA([y()],ni.prototype,"arc",2),gA([y()],ni.prototype,"arcSpread",2),gA([y()],ni.prototype,"arcSpeedMultiplier",2),gA([y()],ni.prototype,"arcMode",2),gA([y(S)],ni.prototype,"boxThickness",2),gA([y(S)],ni.prototype,"position",2),gA([y(S)],ni.prototype,"rotation",2),gA([y(S)],ni.prototype,"scale",2),gA([y()],ni.prototype,"radius",2),gA([y()],ni.prototype,"radiusThickness",2),gA([y()],ni.prototype,"sphericalDirectionAmount",2),gA([y()],ni.prototype,"randomDirectionAmount",2),gA([y()],ni.prototype,"randomPositionAmount",2),gA([y()],ni.prototype,"meshShapeType",2),gA([y(Nd)],ni.prototype,"meshRenderer",2);class ft{constructor(){n(this,"damping"),n(this,"enabled"),n(this,"frequency"),n(this,"octaveCount"),n(this,"octaveMultiplier"),n(this,"octaveScale"),n(this,"positionAmount"),n(this,"quality"),n(this,"remap"),n(this,"remapEnabled"),n(this,"remapMultiplier"),n(this,"remapX"),n(this,"remapXMultiplier"),n(this,"remapY"),n(this,"remapYMultiplier"),n(this,"remapZ"),n(this,"remapZMultiplier"),n(this,"scrollSpeedMultiplier"),n(this,"separateAxes"),n(this,"strengthMultiplier"),n(this,"strengthX"),n(this,"strengthXMultiplier"),n(this,"strengthY"),n(this,"strengthYMultiplier"),n(this,"strengthZ"),n(this,"strengthZMultiplier"),n(this,"_noise"),n(this,"_time",0),n(this,"_temp",new S)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,i,g,I,o){if(!this.enabled)return;this._noise||(this._noise=QoA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),a=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),r=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,a,r).normalize();const B=I/o;let Q=this.positionAmount.evaluate(B);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(B)*1.5),this._temp.multiplyScalar(Q)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}gA([y()],ft.prototype,"damping",2),gA([y()],ft.prototype,"enabled",2),gA([y()],ft.prototype,"frequency",2),gA([y()],ft.prototype,"octaveCount",2),gA([y()],ft.prototype,"octaveMultiplier",2),gA([y()],ft.prototype,"octaveScale",2),gA([y(ne)],ft.prototype,"positionAmount",2),gA([y()],ft.prototype,"quality",2),gA([y(ne)],ft.prototype,"remap",2),gA([y()],ft.prototype,"remapEnabled",2),gA([y()],ft.prototype,"remapMultiplier",2),gA([y(ne)],ft.prototype,"remapX",2),gA([y()],ft.prototype,"remapXMultiplier",2),gA([y(ne)],ft.prototype,"remapY",2),gA([y()],ft.prototype,"remapYMultiplier",2),gA([y(ne)],ft.prototype,"remapZ",2),gA([y()],ft.prototype,"remapZMultiplier",2),gA([y()],ft.prototype,"scrollSpeedMultiplier",2),gA([y()],ft.prototype,"separateAxes",2),gA([y()],ft.prototype,"strengthMultiplier",2),gA([y(ne)],ft.prototype,"strengthX",2),gA([y()],ft.prototype,"strengthXMultiplier",2),gA([y(ne)],ft.prototype,"strengthY",2),gA([y()],ft.prototype,"strengthYMultiplier",2),gA([y(ne)],ft.prototype,"strengthZ",2),gA([y()],ft.prototype,"strengthZMultiplier",2);class ei{constructor(){n(this,"enabled"),n(this,"attachRibbonToTransform",!1),n(this,"colorOverLifetime"),n(this,"colorOverTrail"),n(this,"dieWithParticles",!0),n(this,"inheritParticleColor",!0),n(this,"lifetime"),n(this,"lifetimeMultiplier"),n(this,"minVertexDistance",.2),n(this,"mode",0),n(this,"ratio",1),n(this,"ribbonCount",1),n(this,"shadowBias",0),n(this,"sizeAffectsLifetime",!1),n(this,"sizeAffectsWidth",!1),n(this,"splitSubEmitterRibbons",!1),n(this,"textureMode",0),n(this,"widthOverTrail"),n(this,"widthOverTrailMultiplier"),n(this,"worldSpace",!1)}getWidth(A,e,i,g){const I=this.widthOverTrail.evaluate(i,g);return A*=I,A}getColor(A,e,i){const g=this.colorOverTrail.evaluate(i),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}gA([y()],ei.prototype,"enabled",2),gA([y()],ei.prototype,"attachRibbonToTransform",2),gA([y(PI)],ei.prototype,"colorOverLifetime",2),gA([y(PI)],ei.prototype,"colorOverTrail",2),gA([y()],ei.prototype,"dieWithParticles",2),gA([y()],ei.prototype,"inheritParticleColor",2),gA([y(ne)],ei.prototype,"lifetime",2),gA([y()],ei.prototype,"lifetimeMultiplier",2),gA([y()],ei.prototype,"minVertexDistance",2),gA([y()],ei.prototype,"mode",2),gA([y()],ei.prototype,"ratio",2),gA([y()],ei.prototype,"ribbonCount",2),gA([y()],ei.prototype,"shadowBias",2),gA([y()],ei.prototype,"sizeAffectsLifetime",2),gA([y()],ei.prototype,"sizeAffectsWidth",2),gA([y()],ei.prototype,"splitSubEmitterRibbons",2),gA([y()],ei.prototype,"textureMode",2),gA([y(ne)],ei.prototype,"widthOverTrail",2),gA([y()],ei.prototype,"widthOverTrailMultiplier",2),gA([y()],ei.prototype,"worldSpace",2);class ri{constructor(){n(this,"enabled"),n(this,"space",0),n(this,"orbitalX"),n(this,"orbitalY"),n(this,"orbitalZ"),n(this,"orbitalXMultiplier"),n(this,"orbitalYMultiplier"),n(this,"orbitalZMultiplier"),n(this,"orbitalOffsetX"),n(this,"orbitalOffsetY"),n(this,"orbitalOffsetZ"),n(this,"speedModifier"),n(this,"speedModifierMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier"),n(this,"_system"),n(this,"_temp",new S),n(this,"_temp2",new S),n(this,"_temp3",new S),n(this,"_hasOrbital",!1),n(this,"_index",0),n(this,"_orbitalMatrix",new GA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,i,g,I,o,s){var C;if(!this.enabled)return;const a=o/s,r=this.speedModifier.evaluate(a)*this.speedModifierMultiplier,B=this.x.evaluate(a),Q=this.y.evaluate(a),E=this.z.evaluate(a);if(this._temp.set(-B,Q,E),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((C=this._system)==null?void 0:C.worldPos)){const h=this._temp2.set(i.x,i.y,i.z),d=this.orbitalXMultiplier,l=this.orbitalYMultiplier,c=this.orbitalZMultiplier,u=r*Math.PI*2*10,p=Math.cos(u*d),D=Math.sin(u*d),k=Math.cos(u*l),G=Math.sin(u*l),M=Math.cos(u*c),m=Math.sin(u*c),K=h.x*(k*M)+h.y*(k*m)+h.z*-G,f=h.x*(D*G*M-p*m)+h.y*(D*G*m+p*M)+h.z*(D*k),N=h.x*(p*G*M+D*m)+h.y*(p*G*m-D*M)+h.z*(p*k),H=this._temp3.set(h.x-K,h.y-f,h.z-N);H.normalize(),H.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=H.x,g.y+=H.y,g.z+=H.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=r,g.y*=r,g.z*=r}}gA([y()],ri.prototype,"enabled",2),gA([y()],ri.prototype,"space",2),gA([y(ne)],ri.prototype,"orbitalX",2),gA([y(ne)],ri.prototype,"orbitalY",2),gA([y(ne)],ri.prototype,"orbitalZ",2),gA([y()],ri.prototype,"orbitalXMultiplier",2),gA([y()],ri.prototype,"orbitalYMultiplier",2),gA([y()],ri.prototype,"orbitalZMultiplier",2),gA([y()],ri.prototype,"orbitalOffsetX",2),gA([y()],ri.prototype,"orbitalOffsetY",2),gA([y()],ri.prototype,"orbitalOffsetZ",2),gA([y(ne)],ri.prototype,"speedModifier",2),gA([y()],ri.prototype,"speedModifierMultiplier",2),gA([y(ne)],ri.prototype,"x",2),gA([y()],ri.prototype,"xMultiplier",2),gA([y(ne)],ri.prototype,"y",2),gA([y()],ri.prototype,"yMultiplier",2),gA([y(ne)],ri.prototype,"z",2),gA([y()],ri.prototype,"zMultiplier",2);class xg{constructor(){n(this,"animation"),n(this,"enabled"),n(this,"cycleCount"),n(this,"frameOverTime"),n(this,"frameOverTimeMultiplier"),n(this,"numTilesX"),n(this,"numTilesY"),n(this,"startFrame"),n(this,"startFrameMultiplier"),n(this,"rowMode"),n(this,"rowIndex"),n(this,"spriteCount"),n(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let i=this.frameOverTime.evaluate(A%1);return i*=this.frameOverTimeMultiplier,i*=e,i=i%e,i=Math.floor(i),i}}gA([y()],xg.prototype,"animation",2),gA([y()],xg.prototype,"enabled",2),gA([y()],xg.prototype,"cycleCount",2),gA([y(ne)],xg.prototype,"frameOverTime",2),gA([y()],xg.prototype,"frameOverTimeMultiplier",2),gA([y()],xg.prototype,"numTilesX",2),gA([y()],xg.prototype,"numTilesY",2),gA([y(ne)],xg.prototype,"startFrame",2),gA([y()],xg.prototype,"startFrameMultiplier",2),gA([y()],xg.prototype,"rowMode",2),gA([y()],xg.prototype,"rowIndex",2),gA([y()],xg.prototype,"spriteCount",2),gA([y()],xg.prototype,"timeMode",2);class Vo{constructor(){n(this,"enabled"),n(this,"separateAxes"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}gA([y()],Vo.prototype,"enabled",2),gA([y()],Vo.prototype,"separateAxes",2),gA([y(ne)],Vo.prototype,"x",2),gA([y()],Vo.prototype,"xMultiplier",2),gA([y(ne)],Vo.prototype,"y",2),gA([y()],Vo.prototype,"yMultiplier",2),gA([y(ne)],Vo.prototype,"z",2),gA([y()],Vo.prototype,"zMultiplier",2);class Bo{constructor(){n(this,"enabled"),n(this,"range"),n(this,"separateAxes"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const i=Ae.lerp(this.range.x,this.range.y,e);return this.z.evaluate(i)*-1}return 0}}gA([y()],Bo.prototype,"enabled",2),gA([y()],Bo.prototype,"range",2),gA([y()],Bo.prototype,"separateAxes",2),gA([y(ne)],Bo.prototype,"x",2),gA([y()],Bo.prototype,"xMultiplier",2),gA([y(ne)],Bo.prototype,"y",2),gA([y()],Bo.prototype,"yMultiplier",2),gA([y(ne)],Bo.prototype,"z",2),gA([y()],Bo.prototype,"zMultiplier",2);class Hi{constructor(){n(this,"enabled"),n(this,"dampen"),n(this,"drag"),n(this,"dragMultiplier"),n(this,"limit"),n(this,"limitMultiplier"),n(this,"separateAxes"),n(this,"limitX"),n(this,"limitXMultiplier"),n(this,"limitY"),n(this,"limitYMultiplier"),n(this,"limitZ"),n(this,"limitZMultiplier"),n(this,"multiplyDragByParticleSize",!1),n(this,"multiplyDragByParticleVelocity",!1),n(this,"space"),n(this,"_temp",new S),n(this,"_temp2",new S)}apply(A,e,i,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);const a=this.dampen*.5;e.x=Ae.lerp(e.x,this._temp.x,a),e.y=Ae.lerp(e.y,this._temp.y,a),e.z=Ae.lerp(e.z,this._temp.z,a),i.x=Ae.lerp(i.x,this._temp.x,a),i.y=Ae.lerp(i.y,this._temp.y,a),i.z=Ae.lerp(i.z,this._temp.z,a)}}}}gA([y()],Hi.prototype,"enabled",2),gA([y()],Hi.prototype,"dampen",2),gA([y(ne)],Hi.prototype,"drag",2),gA([y()],Hi.prototype,"dragMultiplier",2),gA([y(ne)],Hi.prototype,"limit",2),gA([y()],Hi.prototype,"limitMultiplier",2),gA([y()],Hi.prototype,"separateAxes",2),gA([y(ne)],Hi.prototype,"limitX",2),gA([y()],Hi.prototype,"limitXMultiplier",2),gA([y(ne)],Hi.prototype,"limitY",2),gA([y()],Hi.prototype,"limitYMultiplier",2),gA([y(ne)],Hi.prototype,"limitZ",2),gA([y()],Hi.prototype,"limitZMultiplier",2),gA([y()],Hi.prototype,"multiplyDragByParticleSize",2),gA([y()],Hi.prototype,"multiplyDragByParticleVelocity",2),gA([y()],Hi.prototype,"space",2);const v_=class{constructor(){n(this,"enabled"),n(this,"curve"),n(this,"curveMultiplier"),n(this,"mode"),n(this,"system"),n(this,"_temp",new S),n(this,"_firstUpdate",!0),n(this,"_frames",0)}clone(){var t;const A=new v_;return A.enabled=this.enabled,A.curve=(t=this.curve)==null?void 0:t.clone(),A.curveMultiplier=this.curveMultiplier,A.mode=this.mode,A}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new S),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new S),this.system._iv_velocity}awake(t){this.system=t,this.reset()}reset(){this._firstUpdate=!0}update(t){this.enabled&&this.system.worldspace!==!1&&(this._firstUpdate?(this._firstUpdate=!1,this._velocity.set(0,0,0),this._lastWorldPosition.copy(this.system.worldPos)):this._lastWorldPosition&&(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)))}applyInitial(t){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const A=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(A),t.add(this._temp)}}applyCurrent(t,A,e){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const i=this.curve.evaluate(A,e);this._temp.copy(this._velocity).multiplyScalar(i),t.add(this._temp)}}};let _n=v_;gA([y()],_n.prototype,"enabled",2),gA([y(ne)],_n.prototype,"curve",2),gA([y()],_n.prototype,"curveMultiplier",2),gA([y()],_n.prototype,"mode",2);class RI{constructor(){n(this,"enabled"),n(this,"range"),n(this,"separateAxes"),n(this,"size"),n(this,"sizeMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e,i,g){const I=A.length(),o=Ae.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,i);return g*s}}gA([y()],RI.prototype,"enabled",2),gA([y(AA)],RI.prototype,"range",2),gA([y()],RI.prototype,"separateAxes",2),gA([y(ne)],RI.prototype,"size",2),gA([y()],RI.prototype,"sizeMultiplier",2),gA([y(ne)],RI.prototype,"x",2),gA([y()],RI.prototype,"xMultiplier",2),gA([y(ne)],RI.prototype,"y",2),gA([y()],RI.prototype,"yMultiplier",2),gA([y(ne)],RI.prototype,"z",2),gA([y()],RI.prototype,"zMultiplier",2);class JB{constructor(){n(this,"enabled"),n(this,"range"),n(this,"color")}evaluate(A,e,i){const g=A.length(),I=Ae.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}gA([y()],JB.prototype,"enabled",2),gA([y(AA)],JB.prototype,"range",2),gA([y(PI)],JB.prototype,"color",2);const OoA={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`