@needle-tools/engine 3.32.18-alpha โ 3.32.19-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +14 -12
- package/dist/needle-engine.light.js +14 -12
- package/dist/needle-engine.light.min.js +7 -5
- package/dist/needle-engine.light.umd.cjs +7 -5
- package/dist/needle-engine.min.js +7 -5
- package/dist/needle-engine.umd.cjs +7 -5
- package/lib/engine/engine_context.d.ts +2 -1
- package/lib/engine/engine_context.js +4 -3
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine-components/ui/CanvasGroup.js +1 -0
- package/lib/engine-components/ui/CanvasGroup.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/dependency-watcher.js +3 -2
- package/src/engine/engine_context.ts +4 -3
- package/src/engine-components/ui/CanvasGroup.ts +1 -0
|
@@ -3944,7 +3944,7 @@ Open this page console: `+A.toString())}const i=xn()||_w()&&Ge();if(i&&(nZ(),KT(
|
|
|
3944
3944
|
}
|
|
3945
3945
|
}
|
|
3946
3946
|
`,co==null||co.prepend(e),i===!0&&SU()<=0&&cZ(),console.log("๐ต Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function pZ(){const i=document.querySelector("#__vconsole .vc-switch");return i||null}function fZ(){const i=document.querySelector("#__vconsole");return i||null}const DZ=oA("nodevlogs");function Ui(i,A=ss.Log){NC(A,i)}function fi(i){Ui(i,ss.Warn)}function vT(i){Ui(i,ss.Error)}let XG;function Ge(){return DZ?!1:XG!==void 0?XG:vI()}function yZ(i){XG=i}const Hr=new dc,aI=new y,ca=new y,oi=new RA,Rv={X:new y(1,0,0),Y:new y(0,1,0),Z:new y(0,0,1)},Dm={type:"change"},Uv={type:"mouseDown"},Nv={type:"mouseUp",mode:null},Fv={type:"objectChange"};class wZ 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 t=new kU;this._gizmo=t,this.add(t);const g=new RZ;this._plane=g,this.add(g);const I=this;function o(d,p){let f=p;Object.defineProperty(I,d,{get:function(){return f!==void 0?f:p},set:function(S){f!==S&&(f=S,g[d]=S,t[d]=S,I.dispatchEvent({type:d+"-changed",value:S}),I.dispatchEvent(Dm))}}),I[d]=p,g[d]=p,t[d]=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 y,n=new y,C=new RA,a=new RA,B=new y,Q=new RA,E=new y,c=new y,h=new y,u=0,l=new y;o("worldPosition",s),o("worldPositionStart",n),o("worldQuaternion",C),o("worldQuaternionStart",a),o("cameraPosition",B),o("cameraQuaternion",Q),o("pointStart",E),o("pointEnd",c),o("rotationAxis",h),o("rotationAngle",u),o("eye",l),this._offset=new y,this._startNorm=new y,this._endNorm=new y,this._cameraScale=new y,this._parentPosition=new y,this._parentQuaternion=new RA,this._parentQuaternionInv=new RA,this._parentScale=new y,this._worldScaleStart=new y,this._worldQuaternionInv=new RA,this._worldScale=new y,this._positionStart=new y,this._quaternionStart=new RA,this._scaleStart=new y,this._getPointer=SZ.bind(this),this._onPointerDown=kZ.bind(this),this._onPointerHover=mZ.bind(this),this._onPointerMove=GZ.bind(this),this._onPointerUp=MZ.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;Hr.setFromCamera(A,this.camera);const e=ym(this._gizmo.picker[this.mode],Hr);e?this.axis=e.object.name:this.axis=null}pointerDown(A){if(!(this.object===void 0||this.dragging===!0||A.button!==0)&&this.axis!==null){Hr.setFromCamera(A,this.camera);const e=ym(this._plane,Hr,!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,Uv.mode=this.mode,this.dispatchEvent(Uv)}}pointerMove(A){const e=this.axis,t=this.mode,g=this.object;let I=this.space;if(t==="scale"?I="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(I="world"),g===void 0||e===null||this.dragging===!1||A.button!==-1)return;Hr.setFromCamera(A,this.camera);const o=ym(this._plane,Hr,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),t==="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(oi.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(t==="scale"){if(e.search("XYZ")!==-1){let s=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(s*=-1),ca.set(s,s,s)}else aI.copy(this.pointStart),ca.copy(this.pointEnd),aI.applyQuaternion(this._worldQuaternionInv),ca.applyQuaternion(this._worldQuaternionInv),ca.divide(aI),e.search("X")===-1&&(ca.x=1),e.search("Y")===-1&&(ca.y=1),e.search("Z")===-1&&(ca.z=1);g.scale.copy(this._scaleStart).multiply(ca),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(t==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const s=20/this.worldPosition.distanceTo(aI.setFromMatrixPosition(this.camera.matrixWorld));let n=!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(Rv[e]),aI.copy(Rv[e]),I==="local"&&aI.applyQuaternion(this.worldQuaternion),aI.cross(this.eye),aI.length()===0?n=!0:this.rotationAngle=this._offset.dot(aI.normalize())*s),(e==="E"||n)&&(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(oi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),g.quaternion.copy(oi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),g.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Dm),this.dispatchEvent(Fv)}}pointerUp(A){A.button===0&&(this.dragging&&this.axis!==null&&(Nv.mode=this.mode,this.dispatchEvent(Nv)),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(Dm),this.dispatchEvent(Fv),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Hr}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 SZ(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const A=this.domElement.getBoundingClientRect();return{x:(i.clientX-A.left)/A.width*2-1,y:-(i.clientY-A.top)/A.height*2+1,button:i.button}}}function mZ(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function kZ(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function GZ(i){this.enabled&&this.pointerMove(this._getPointer(i))}function MZ(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function ym(i,A,e){const t=A.intersectObject(i,!0);for(let g=0;g<t.length;g++)if(t[g].object.visible||e)return t[g];return!1}const tf=new Og,Ht=new y(0,1,0),Kv=new y(0,0,0),Jv=new GA,gf=new RA,gD=new RA,An=new y,vv=new GA,Ph=new y(1,0,0),oB=new y(0,1,0),Wh=new y(0,0,1),If=new y,hh=new y,lh=new y;class kU extends pA{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const A=new rt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Oi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=A.clone();t.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 n=A.clone();n.color.setHex(16711680),n.opacity=.5;const C=A.clone();C.color.setHex(65280),C.opacity=.5;const a=A.clone();a.color.setHex(255),a.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 c=A.clone();c.color.setHex(7895160);const h=new xi(0,.04,.1,12);h.translate(0,.05,0);const u=new zt(.08,.08,.08);u.translate(0,.04,0);const l=new fe;l.setAttribute("position",new Qe([0,0,0,1,0,0],3));const d=new xi(.0075,.0075,.5,3);d.translate(0,.25,0);function p(_,J){const L=new uC(_,.0075,3,64,J*Math.PI*2);return L.rotateY(Math.PI/2),L.rotateX(Math.PI/2),L}function f(){const _=new fe;return _.setAttribute("position",new Qe([0,0,0,1,1,1],3)),_}const S={X:[[new uA(h,I),[.5,0,0],[0,0,-Math.PI/2]],[new uA(h,I),[-.5,0,0],[0,0,Math.PI/2]],[new uA(d,I),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new uA(h,o),[0,.5,0]],[new uA(h,o),[0,-.5,0],[Math.PI,0,0]],[new uA(d,o)]],Z:[[new uA(h,s),[0,0,.5],[Math.PI/2,0,0]],[new uA(h,s),[0,0,-.5],[-Math.PI/2,0,0]],[new uA(d,s),null,[Math.PI/2,0,0]]],XYZ:[[new uA(new SC(.1,0),B.clone()),[0,0,0]]],XY:[[new uA(new zt(.15,.15,.01),a.clone()),[.15,.15,0]]],YZ:[[new uA(new zt(.15,.15,.01),n.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new zt(.15,.15,.01),C.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},m={X:[[new uA(new xi(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new uA(new xi(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new uA(new xi(.2,0,.6,4),t),[0,.3,0]],[new uA(new xi(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new uA(new xi(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new uA(new xi(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new uA(new SC(.2,0),t)]],XY:[[new uA(new zt(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new uA(new zt(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new zt(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]]},G={START:[[new uA(new SC(.01,2),g),null,null,null,"helper"]],END:[[new uA(new SC(.01,2),g),null,null,null,"helper"]],DELTA:[[new Ti(f(),g),null,null,null,"helper"]],X:[[new Ti(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ti(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ti(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new uA(p(.5,1),c),null,[0,Math.PI/2,0]]],X:[[new uA(p(.5,.5),I)]],Y:[[new uA(p(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new uA(p(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new uA(p(.75,1),Q),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Ti(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},k={XYZE:[[new uA(new Os(.25,10,8),t)]],X:[[new uA(new uC(.5,.1,4,24),t),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new uA(new uC(.5,.1,4,24),t),[0,0,0],[Math.PI/2,0,0]]],Z:[[new uA(new uC(.5,.1,4,24),t),[0,0,0],[0,0,-Math.PI/2]]],E:[[new uA(new uC(.75,.1,2,24),t)]]},K={X:[[new uA(u,I),[.5,0,0],[0,0,-Math.PI/2]],[new uA(d,I),[0,0,0],[0,0,-Math.PI/2]],[new uA(u,I),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new uA(u,o),[0,.5,0]],[new uA(d,o)],[new uA(u,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new uA(u,s),[0,0,.5],[Math.PI/2,0,0]],[new uA(d,s),[0,0,0],[Math.PI/2,0,0]],[new uA(u,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new uA(new zt(.15,.15,.01),a),[.15,.15,0]]],YZ:[[new uA(new zt(.15,.15,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new zt(.15,.15,.01),C),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new uA(new zt(.1,.1,.1),B.clone())]]},T={X:[[new uA(new xi(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new uA(new xi(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new uA(new xi(.2,0,.6,4),t),[0,.3,0]],[new uA(new xi(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new uA(new xi(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new uA(new xi(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new uA(new zt(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new uA(new zt(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new zt(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new uA(new zt(.2,.2,.2),t),[0,0,0]]]},O={X:[[new Ti(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ti(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ti(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function b(_){const J=new pA;for(const L in _)for(let H=_[L].length;H--;){const Z=_[L][H][0].clone(),X=_[L][H][1],nA=_[L][H][2],lA=_[L][H][3],SA=_[L][H][4];Z.name=L,Z.tag=SA,X&&Z.position.set(X[0],X[1],X[2]),nA&&Z.rotation.set(nA[0],nA[1],nA[2]),lA&&Z.scale.set(lA[0],lA[1],lA[2]),Z.updateMatrix();const qA=Z.geometry.clone();qA.applyMatrix4(Z.matrix),Z.geometry=qA,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),J.add(Z)}return J}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=b(S)),this.add(this.gizmo.rotate=b(R)),this.add(this.gizmo.scale=b(K)),this.add(this.picker.translate=b(m)),this.add(this.picker.rotate=b(k)),this.add(this.picker.scale=b(T)),this.add(this.helper.translate=b(G)),this.add(this.helper.rotate=b(w)),this.add(this.helper.scale=b(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(A){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:gD;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 g=[];g=g.concat(this.picker[this.mode].children),g=g.concat(this.gizmo[this.mode].children),g=g.concat(this.helper[this.mode].children);for(let I=0;I<g.length;I++){const o=g[I];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let s;if(this.camera.isOrthographicCamera?s=(this.camera.top-this.camera.bottom)/this.camera.zoom:s=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(s*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(oi.setFromEuler(tf.set(0,0,0)),o.quaternion.copy(t).multiply(oi),Math.abs(Ht.copy(Ph).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(oi.setFromEuler(tf.set(0,0,Math.PI/2)),o.quaternion.copy(t).multiply(oi),Math.abs(Ht.copy(oB).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(oi.setFromEuler(tf.set(0,Math.PI/2,0)),o.quaternion.copy(t).multiply(oi),Math.abs(Ht.copy(Wh).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(oi.setFromEuler(tf.set(0,Math.PI/2,0)),Ht.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Jv.lookAt(Kv,Ht,oB)),o.quaternion.multiply(oi),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),aI.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),aI.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(aI),o.visible=this.dragging):(o.quaternion.copy(t),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(t),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Ht.copy(Ph).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Ht.copy(oB).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Ht.copy(Wh).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Ht.copy(Wh).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Ht.copy(Ph).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Ht.copy(oB).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(gf.copy(t),Ht.copy(this.eye).applyQuaternion(oi.copy(t).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Jv.lookAt(this.eye,Kv,oB)),o.name==="X"&&(oi.setFromAxisAngle(Ph,Math.atan2(-Ht.y,Ht.z)),oi.multiplyQuaternions(gf,oi),o.quaternion.copy(oi)),o.name==="Y"&&(oi.setFromAxisAngle(oB,Math.atan2(Ht.x,Ht.z)),oi.multiplyQuaternions(gf,oi),o.quaternion.copy(oi)),o.name==="Z"&&(oi.setFromAxisAngle(Wh,Math.atan2(Ht.y,Ht.x)),oi.multiplyQuaternions(gf,oi),o.quaternion.copy(oi))),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(n){return o.name===n}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(A)}}class RZ extends uA{constructor(){super(new lg(1e5,1e5,2,2),new rt({visible:!1,wireframe:!0,side:wt,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"),If.copy(Ph).applyQuaternion(e==="local"?this.worldQuaternion:gD),hh.copy(oB).applyQuaternion(e==="local"?this.worldQuaternion:gD),lh.copy(Wh).applyQuaternion(e==="local"?this.worldQuaternion:gD),Ht.copy(hh),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ht.copy(this.eye).cross(If),An.copy(If).cross(Ht);break;case"Y":Ht.copy(this.eye).cross(hh),An.copy(hh).cross(Ht);break;case"Z":Ht.copy(this.eye).cross(lh),An.copy(lh).cross(Ht);break;case"XY":An.copy(lh);break;case"YZ":An.copy(If);break;case"XZ":Ht.copy(lh),An.copy(hh);break;case"XYZ":case"E":An.set(0,0,0);break}break;case"rotate":default:An.set(0,0,0)}An.length()===0?this.quaternion.copy(this.cameraQuaternion):(vv.lookAt(aI.set(0,0,0),An,Ht),this.quaternion.setFromRotationMatrix(vv)),super.updateMatrixWorld(A)}}const UZ=oA("debugpatch");function Hw(i,A,e,t){const g=UZ===A;if(!e&&!t)return;const I=A+"___needle";FZ(i,A,e,t);const o=Object.getOwnPropertyDescriptor(i,A),s=i[A];g&&console.log("Patch",i.constructor.name,A,o,s),o?(g&&console.log("Apply patch with existing descriptor",i.constructor.name,A,o),typeof o.value=="function"&&(i[A]=qv(o.value,i,A))):(g&&console.log("Create patch with new property",i.constructor.name,A,o),Object.defineProperty(i,A,{set:function(n){if(typeof n=="function")this[I]=qv(n,i,A);else{const C=this[I];bT(i,A,this,C,n),this[I]=n,qT(i,A,this,C,n)}},get:function(){const n=this[I];return typeof n=="function"&&n[I]?n[I]:n}}))}function NZ(i,A,e){const t=GU(i,A);if(t)for(let g=t.length-1;g>=0;g--){const I=t[g];I.prefix===e&&(I.prefix=null),I.postfix===e&&(I.postfix=null),!I.prefix&&!I.postfix&&t.splice(g,1)}}const bv=Symbol("Needle:Patches:WrappedFunction");function qv(i,A,e){if(i[bv])return i;const t=function(...g){bT(A,e,this,...g);const I=i.apply(this,g);return qT(A,e,this,I,...g),I};return t[bv]=!0,t}const ID="Needle:Patches";function $G(){return globalThis[ID]||(globalThis[ID]=new WeakMap),globalThis[ID]}function GU(i,A){const e=$G().get(i);return e?e.get(A):null}function FZ(i,A,e,t){let g=$G().get(i);g||(g=new Map,$G().set(i,g));let I=g.get(A);I||(I=[],g.set(A,I)),I.push({prefix:e,postfix:t})}function bT(i,A,e,...t){var I;if(!e)return;const g=GU(i,A);if(g)for(const o of g)(I=o.prefix)==null||I.call(e,...t)}function qT(i,A,e,t,...g){var o;if(!e)return;const I=GU(i,A);if(I)for(const s of I)(o=s.postfix)==null||o.call(e,t,...g)}const Lv=Symbol("gltf-loader-internal-usage-tracker"),KZ=oA("debugusers"),Nl=class{constructor(A){r(this,"parser");r(this,"_getDependency");r(this,"_loadingId");r(this,"_loadedObjects",new Set);this.parser=A,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(A){return Nl._loadingProcesses>0}beforeRoot(){Nl._loadingProcesses++;const A=this,e=this._getDependency;return this.parser.getDependency=function(t,g){const I=e.call(this,t,g);return I.then(o=>(o&&(A._loadedObjects.add(o),o[Lv]=A._loadingId),o)),I},null}afterRoot(A){Nl._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[Lv],e instanceof pA&&(e.parent||e instanceof uA&&(KZ&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null));return null}};let Ql=Nl;r(Ql,"_loadingProcesses",0);class LT{constructor(){window.addEventListener("unhandledrejection",A=>{var t;if(A.defaultPrevented)return;const e=(t=A==null?void 0:A.reason)==null?void 0:t.path;if(e){const g=e[0];g&&g.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
3947
|
-
`+g.src),A.preventDefault())}})}}const Ow=oA("trackresources");function xT(){return Ow==="dispose"}let ZB=!0;Ow===0&&(ZB=!1);function JZ(i){ZB=i}function YT(){return ZB}const TT=Symbol("disposable");function MU(i,A){i&&(i[TT]=A,kB&&console.warn("Set disposable",A,i))}const _T=Symbol("disposed");function vZ(i){return i[_T]===!0}function Wt(i){var A;if(i){if(i[TT]===!1){kB&&console.warn("Object is marked as not disposable",i);return}if(i[_T]=!0,i instanceof EI)Wt(i.environment),Wt(i.background),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial);else if(i instanceof qs)Wt(i.geometry),Wt(i.material),Wt(i.skeleton),Wt(i.bindMatrix),Wt(i.bindMatrixInverse),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof uA)Wt(i.geometry),Wt(i.material),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof fe){WQ(i);for(const e of Object.keys(i.attributes)){const t=i.attributes[e];Wt(t)}}else if(i instanceof ie||i instanceof FI)kB&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const e of i)e instanceof _e&&Wt(e);else if(i instanceof _e){WQ(i);for(const t of Object.keys(i)){const g=i[t];g instanceof He&&(Wt(g),i[t]=null)}const e=i.uniforms;if(e)for(const t of Object.keys(e)){const g=e[t];g instanceof He?(Wt(g),e[t]=null):g instanceof kA&&(Wt(g.value),g.value=null)}}else i instanceof He?(WQ(i),WQ(i.source),((A=i.source)==null?void 0:A.data)instanceof ImageBitmap&&WQ(i.source.data)):i instanceof hc?(WQ(i.boneTexture),i.boneTexture=null):i instanceof Od||!(i instanceof pA)&&kB&&console.warn("Unknown object type",i)}}function WQ(i){i&&((kB||xT()||Ow)&&console.warn("๐งจ FREE",i),i instanceof ImageBitmap?i.close():i instanceof wC?i.data=null:i.dispose())}function HT(i){(i instanceof uA||i instanceof qs)&&(i.material=null,i.geometry=null)}const bZ=new Set;function RU(i,A,e=null,t){if(t||(t=bZ,t.clear()),!i)return t;const g=i[Ad];if(g)for(const I of g)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&RU(I,!0,e,t));return t}function qZ(i){return i[jh]}const kB=oA("debugresourceusers")||oA("debugmemory"),Ad=Symbol("needle-resource-users"),jh=Symbol("needle-resource-users-count");function pI(i,A){Hw(i,A,function(e,t){ZB&&(Iy(Ad,this,e,!1),Iy(Ad,this,t,!0))})}ZB&&(pI(uA.prototype,"material"),pI(uA.prototype,"geometry"),pI(_e.prototype,"map"),pI(_e.prototype,"bumpMap"),pI(_e.prototype,"alphaMap"),pI(_e.prototype,"normalMap"),pI(_e.prototype,"displacementMap"),pI(_e.prototype,"roughnessMap"),pI(_e.prototype,"metalnessMap"),pI(_e.prototype,"emissiveMap"),pI(_e.prototype,"specularMap"),pI(_e.prototype,"envMap"),pI(_e.prototype,"lightMap"),pI(_e.prototype,"aoMap"),pI(_e.prototype,"gradientMap"));function LZ(i){if(ZB===!1)return;const A=i[Ad];if(A)for(const e of A)Iy(Ad,e,i,!1)}ZB&&Hw(_e.prototype,"dispose",function(){LZ(this)});let AM=0;function Iy(i,A,e,t){if(AM>0)return;if(Array.isArray(e)){for(const I of e)Iy(i,A,I,t);return}if(!e)return;let g=e[i];if(g||(g=new Set),t){if(A&&!g.has(A)){g.add(A);let I=e[jh]||0;I+=1,e[jh]=I,kB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[jh]||0;I>0&&(I-=1,e[jh]=I),kB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(Ql.isLoading(e)||(Ow&&console.warn(`๐ด Removed all user of "${e.type}"`,e),xT()&&Wt(e)))}e[i]=g}try{Hw(VC.prototype,"render",function(){AM++},function(){AM--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var Zd=(i=>(i.Added="component-added",i.Removing="removing-component",i))(Zd||{});const xv=oA("debugcomponentevents");class Xd{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let t=this.eventListeners.get(A);t||(t=[]),t.push(e),this.eventListeners.set(A,t),xv&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const g=t.indexOf(e);g<0||t.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(xv&&console.log("Dispatching event "+A,t),!!t)for(const g of t)g(e)}}r(Xd,"eventListeners",new Map);const OT=oA("debugdefines");pc('if(!globalThis[""3.32.
|
|
3947
|
+
`+g.src),A.preventDefault())}})}}const Ow=oA("trackresources");function xT(){return Ow==="dispose"}let ZB=!0;Ow===0&&(ZB=!1);function JZ(i){ZB=i}function YT(){return ZB}const TT=Symbol("disposable");function MU(i,A){i&&(i[TT]=A,kB&&console.warn("Set disposable",A,i))}const _T=Symbol("disposed");function vZ(i){return i[_T]===!0}function Wt(i){var A;if(i){if(i[TT]===!1){kB&&console.warn("Object is marked as not disposable",i);return}if(i[_T]=!0,i instanceof EI)Wt(i.environment),Wt(i.background),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial);else if(i instanceof qs)Wt(i.geometry),Wt(i.material),Wt(i.skeleton),Wt(i.bindMatrix),Wt(i.bindMatrixInverse),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof uA)Wt(i.geometry),Wt(i.material),Wt(i.customDepthMaterial),Wt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof fe){WQ(i);for(const e of Object.keys(i.attributes)){const t=i.attributes[e];Wt(t)}}else if(i instanceof ie||i instanceof FI)kB&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const e of i)e instanceof _e&&Wt(e);else if(i instanceof _e){WQ(i);for(const t of Object.keys(i)){const g=i[t];g instanceof He&&(Wt(g),i[t]=null)}const e=i.uniforms;if(e)for(const t of Object.keys(e)){const g=e[t];g instanceof He?(Wt(g),e[t]=null):g instanceof kA&&(Wt(g.value),g.value=null)}}else i instanceof He?(WQ(i),WQ(i.source),((A=i.source)==null?void 0:A.data)instanceof ImageBitmap&&WQ(i.source.data)):i instanceof hc?(WQ(i.boneTexture),i.boneTexture=null):i instanceof Od||!(i instanceof pA)&&kB&&console.warn("Unknown object type",i)}}function WQ(i){i&&((kB||xT()||Ow)&&console.warn("๐งจ FREE",i),i instanceof ImageBitmap?i.close():i instanceof wC?i.data=null:i.dispose())}function HT(i){(i instanceof uA||i instanceof qs)&&(i.material=null,i.geometry=null)}const bZ=new Set;function RU(i,A,e=null,t){if(t||(t=bZ,t.clear()),!i)return t;const g=i[Ad];if(g)for(const I of g)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&RU(I,!0,e,t));return t}function qZ(i){return i[jh]}const kB=oA("debugresourceusers")||oA("debugmemory"),Ad=Symbol("needle-resource-users"),jh=Symbol("needle-resource-users-count");function pI(i,A){Hw(i,A,function(e,t){ZB&&(Iy(Ad,this,e,!1),Iy(Ad,this,t,!0))})}ZB&&(pI(uA.prototype,"material"),pI(uA.prototype,"geometry"),pI(_e.prototype,"map"),pI(_e.prototype,"bumpMap"),pI(_e.prototype,"alphaMap"),pI(_e.prototype,"normalMap"),pI(_e.prototype,"displacementMap"),pI(_e.prototype,"roughnessMap"),pI(_e.prototype,"metalnessMap"),pI(_e.prototype,"emissiveMap"),pI(_e.prototype,"specularMap"),pI(_e.prototype,"envMap"),pI(_e.prototype,"lightMap"),pI(_e.prototype,"aoMap"),pI(_e.prototype,"gradientMap"));function LZ(i){if(ZB===!1)return;const A=i[Ad];if(A)for(const e of A)Iy(Ad,e,i,!1)}ZB&&Hw(_e.prototype,"dispose",function(){LZ(this)});let AM=0;function Iy(i,A,e,t){if(AM>0)return;if(Array.isArray(e)){for(const I of e)Iy(i,A,I,t);return}if(!e)return;let g=e[i];if(g||(g=new Set),t){if(A&&!g.has(A)){g.add(A);let I=e[jh]||0;I+=1,e[jh]=I,kB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[jh]||0;I>0&&(I-=1,e[jh]=I),kB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(Ql.isLoading(e)||(Ow&&console.warn(`๐ด Removed all user of "${e.type}"`,e),xT()&&Wt(e)))}e[i]=g}try{Hw(VC.prototype,"render",function(){AM++},function(){AM--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var Zd=(i=>(i.Added="component-added",i.Removing="removing-component",i))(Zd||{});const xv=oA("debugcomponentevents");class Xd{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let t=this.eventListeners.get(A);t||(t=[]),t.push(e),this.eventListeners.set(A,t),xv&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const g=t.indexOf(e);g<0||t.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(xv&&console.log("Dispatching event "+A,t),!!t)for(const g of t)g(e)}}r(Xd,"eventListeners",new Map);const OT=oA("debugdefines");pc('if(!globalThis[""3.32.19-alpha""]) globalThis[""3.32.19-alpha""] = "0.0.0";');pc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');pc('if(!globalThis[""Fri Feb 09 2024 21:56:34 GMT+0800 (Pacific Standard Time)""]) globalThis[""Fri Feb 09 2024 21:56:34 GMT+0800 (Pacific Standard Time)""] = "unknown";');pc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.32.19-alpha";');pc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');pc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Feb 09 2024 21:56:34 GMT+0800 (Pacific Standard Time)";');const wn="3.32.19-alpha",Pw="undefined",xZ="Fri Feb 09 2024 21:56:34 GMT+0800 (Pacific Standard Time)";OT&&console.log(`Engine version: ${wn} (generator: ${Pw})
|
|
3948
3948
|
Project built at ${xZ}`);const KC="needle_isActiveInHierarchy",nB="builtin_components",El="needle_editor_guid";function pc(i){try{(0,eval)(i)}catch(A){OT&&console.error(A)}}const ed=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),PT=Symbol("isUsingInstancing"),WT=Symbol("instancingRenderer"),eM=Symbol("instancingAutoUpdateBounds");class Ls{static isUsingInstancing(A){return A[PT]===!0}static getRenderer(A){return A[WT]||null}setAutoUpdateBounds(A,e){const t=Ls.getRenderer(A);t&&(t[eM]=e)}static markDirty(A,e=!0){if(A&&(this.isUsingInstancing(A)&&(A[ed]=!0,A.matrixWorldNeedsUpdate=!0),e))for(const t of A.children)Ls.markDirty(t,!0)}}function GB(i,A){try{A?i(A):i()}catch(e){return console.error(e),!1}return!0}const tM=oA("debugnewscripts"),YZ=oA("debughierarchy"),gi=[];function TZ(){return gi.length>0}function oy(i){if(!(i.new_scripts.length<=0)){if(tM&&console.log("Register new components",i.new_scripts.length,[...i.new_scripts],i.alias?"element: "+i.alias:i.hash,i),i.new_scripts_pre_setup_callbacks.length>0){for(const A of i.new_scripts_pre_setup_callbacks)A&&A();i.new_scripts_pre_setup_callbacks.length=0}gi.length=0,i.new_scripts.length>0&&gi.push(...i.new_scripts),i.new_scripts.length=0;for(let A=0;A<gi.length;A++)try{const e=gi[A];if(e.isComponent!==!0){(Ge()||tM)&&console.error(`Registered script is not a Needle Engine component.
|
|
3949
3949
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
3950
3950
|
`,e),gi.splice(A,1),A--;continue}if(e.destroyed)continue;if(!e.gameObject){console.error("MISSING GAMEOBJECT - will ignore",e),gi.splice(A,1),A--;continue}e.context=i,cl(e.gameObject),UU(e,i)}catch(e){console.error(e),pC(gi[A],i),gi.splice(A,1),A--}for(let A=0;A<gi.length;A++)try{const e=gi[A];if(e.destroyed){pC(gi[A],i),gi.splice(A,1),A--;continue}if(e.registering)try{e.registering()}catch(t){console.error(t)}e.__internalAwake!==void 0&&(e.gameObject||console.error("MISSING GAMEOBJECT",e,e.gameObject),cl(e.gameObject),e.activeAndEnabled&&GB(e.__internalAwake.bind(e)))}catch(e){console.error(e),pC(gi[A],i),gi.splice(A,1),A--}for(let A=0;A<gi.length;A++)try{const e=gi[A];if(e.destroyed||e.enabled===!1||(cl(e.gameObject),e.activeAndEnabled===!1))continue;e.__internalEnable!==void 0&&(e.enabled=!0,GB(e.__internalEnable.bind(e)))}catch(e){console.error(e),pC(gi[A],i),gi.splice(A,1),A--}for(let A=0;A<gi.length;A++)try{const e=gi[A];if(e.destroyed||!e.gameObject)continue;i.new_script_start.push(e)}catch(e){console.error(e),pC(gi[A],i),gi.splice(A,1),A--}gi.length=0;for(const A of i.new_scripts_post_setup_callbacks)A&&A();i.new_scripts_post_setup_callbacks.length=0}}function _Z(i){i&&(i.__internalDisable(!0),pC(i,i.context))}function jT(i,A){for(let e=0;e<i.new_script_start.length;e++)try{const t=i.new_script_start[e];if(A!==void 0&&t.gameObject!==A||t.destroyed||t.activeAndEnabled===!1)continue;GB(t.__internalAwake.bind(t)),t.enabled&&(GB(t.__internalEnable.bind(t)),GB(t.__internalStart.bind(t)),i.new_script_start.splice(e,1),e--)}catch(t){console.error(t),pC(i.new_script_start[e],i),i.new_script_start.splice(e,1),e--}}function UU(i,A){A.scripts.indexOf(i)===-1&&(A.scripts.push(i),i.earlyUpdate&&A.scripts_earlyUpdate.push(i),i.update&&A.scripts_update.push(i),i.lateUpdate&&A.scripts_lateUpdate.push(i),i.onBeforeRender&&A.scripts_onBeforeRender.push(i),i.onAfterRender&&A.scripts_onAfterRender.push(i),i.onPausedChanged&&A.scripts_pausedChanged.push(i),wm(i,null)&&A.new_scripts_xr.push(i),wm(i,"immersive-vr")&&A.scripts_immersive_vr.push(i),wm(i,"immersive-ar")&&A.scripts_immersive_ar.push(i))}function pC(i,A){Yo(i,A.new_scripts),Yo(i,A.new_script_start),Yo(i,A.scripts),Yo(i,A.scripts_earlyUpdate),Yo(i,A.scripts_update),Yo(i,A.scripts_lateUpdate),Yo(i,A.scripts_onBeforeRender),Yo(i,A.scripts_onAfterRender),Yo(i,A.scripts_pausedChanged),Yo(i,A.new_scripts_xr),Yo(i,A.scripts_immersive_vr),Yo(i,A.scripts_immersive_ar),A.stopAllCoroutinesFrom(i)}function Yo(i,A){const e=A.indexOf(i);e>=0&&A.splice(e,1)}function wm(i,A){var e;if(i){const t=i;if(t.onBeforeXR||t.onEnterXR||t.onUpdateXR||t.onLeaveXR||t.onXRControllerAdded||t.onXRControllerRemoved)return!(A!=null&&((e=t.supportsXR)==null?void 0:e.call(t,A))===!1)}return!1}function oD(i){if(i||(i=Nt.Current.scene),!i){console.trace("Invalid call - no current context.");return}const A=kc(i);VT(i,A,!0)||(tM||Ge()?console.error(`Error updating hierarchy
|
|
@@ -4988,10 +4988,12 @@ Pinch: ${(g=this.getGesture("pinch"))==null?void 0:g.value.toFixed(3)}`),t+=`
|
|
|
4988
4988
|
`+t.uuid,.01,5,0,new Kt(1,1,1,.1))}this.emitPointerEvent(Q,0,"pinch",!1,null,E)}}}}}onUpdateMove(){var t,g;let A=!1;if(this._lastPointerMovePosition.distanceTo(this.gripWorldPosition)>.02&&(A=!0),A||this._lastPointerMoveQuaternion.angleTo(this.gripWorldQuaternion)>.02&&(A=!0),A){this._didMoveLastFrame=!0,this._lastPointerMovePosition.copy(this.gripWorldPosition),this._lastPointerMoveQuaternion.copy(this.gripWorldQuaternion),fa&&Ue.DrawLabel(this.rayWorldPosition.add(this.object.worldForward.multiplyScalar(.1)),"move",.01);let I=this.xr.context.input.getFirstPressedButtonForPointer(this.index);I===void 0&&(I=0);const o=(g=(t=this.gamepad)==null?void 0:t.buttons[I])==null?void 0:g.value;this.emitPointerEvent("pointermove",I,"none",!1,null,o)}else this._didMoveLastFrame=!1}emitPointerEvent(A,e,t,g,I=null,o){if(!this.emitEvents){fa&&A!==si.PointerMove&&console.warn("Pointer events are disabled for this controller",this.index,A,e);return}if(this.xr.mode==="immersive-vr"||this.xr.isPassThrough){this.pointerInit.origin=this,this.pointerInit.pointerId=this.index*10+e,this.pointerInit.pointerType=this.hand?"hand":"controller",this.pointerInit.button=e,this.pointerInit.buttonName=t,this.pointerInit.isPrimary=g,this.pointerInit.mode=this.inputSource.targetRayMode,this.pointerInit.ray=this.ray,this.pointerInit.device=this.object,this.pointerInit.pressure=o;const s=ve.Current;ve.Current=this.xr.context,fa&&A!=="pointermove"&&console.warn("Pointer event",A,e,t,{...this.pointerInit}),this.xr.context.input.createInputEvent(new QC(A,I,this.pointerInit)),ve.Current=s}}}class eq{constructor(){r(this,"isDown",!1);r(this,"isUp",!1);r(this,"pressed",!1);r(this,"value",0)}}class tq{constructor(){r(this,"touched",!1);r(this,"pressed",!1);r(this,"value",0);r(this,"isDown",!1);r(this,"isUp",!1)}}const fl=oA("debugwebxr");class Wm{constructor(A,e){r(this,"controllerStates",[]);r(this,"userId");r(this,"context");r(this,"userStateEvtName");r(this,"onReceivedControllerState",A=>{fl&&console.log(`XRSync: Received change for ${this.userId}: ${A.type} ${A.handedness}; tracked=${A.isTracking}`);let e=!1;for(let t=0;t<this.controllerStates.length;t++)if(this.controllerStates[t].index===A.index){this.controllerStates[t]=A,e=!0;break}e||this.controllerStates.push(A)});this.userId=A,this.context=e,this.userStateEvtName="xr-sync-user-state-"+A,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(A){if(this.context.connection.isConnected!=!1){for(let e=this.controllerStates.length-1;e>=0;e--){const t=this.controllerStates[e];let g=!1;for(let I=0;I<A.controllers.length;I++)A.controllers[I].index===t.index&&(g=!0);g||(fl&&console.log(`XRSync: ${t.type} ${t.handedness} removed`,t.index),this.controllerStates.splice(e,1),this.sendControllerRemoved(t))}for(const e of A.controllers)this.updateControllerStates(e)}}onExitXR(A){for(const e of this.controllerStates)this.sendControllerRemoved(e);this.controllerStates.length=0}sendControllerRemoved(A){A.isTracking=!1,A.guid="",this.context.connection.send(this.userStateEvtName,A),this.context.connection.sendDeleteRemoteState(A.guid)}updateControllerStates(A){const e=this.controllerStates.find(t=>t.index===A.index);if(e){let t=!1;t||(t=e.isTracking!=A.isTracking),t&&(e.isTracking=A.isTracking,this.context.connection.send(this.userStateEvtName,e))}else{const t={guid:this.userId+"-"+A.index,isTracking:A.isTracking,handedness:A.side,index:A.index,type:A.hand?"hand":"controller"};this.controllerStates.push(t),this.context.connection.send(this.userStateEvtName,t),fl&&console.log(`XRSync: ${t.type} ${t.handedness} added`,t.index)}}}class tO{constructor(A){r(this,"context");r(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(fl&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new Wm(this.context.connection.connectionId,this.context)));for(const A of this.context.connection.usersInRoom())this._states.has(A)||this._states.set(A,new Wm(A,this.context))}});r(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const A=this._states.get(this.context.connection.connectionId);A==null||A.dispose(),this._states.delete(this.context.connection.connectionId)}});r(this,"onOtherUserJoinedRoom",A=>{const e=A.userId;this._states.has(e)||(fl&&console.log("XRSync: Remote user joined room",e),this._states.set(e,new Wm(e,this.context)))});r(this,"onOtherUserLeftRoom",A=>{const e=A.userId;if(!this._states.has(e)){const t=this._states.get(e);t==null||t.dispose(),this._states.delete(e)}});r(this,"_states",new Map);this.context=A,this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(dt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(dt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(dt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(A){return A?this._states.has(A):!1}isTracking(A,e){if(!A)return;const t=this._states.get(A);if(!t)return;const g=t.controllerStates.find(I=>I.handedness===e);return(g==null?void 0:g.isTracking)||!1}getDeviceType(A,e){if(!A)return;const t=this._states.get(A);if(!t)return;const g=t.controllerStates.find(I=>I.handedness===e);return(g==null?void 0:g.type)||"unknown"}destroy(){this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(dt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(dt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(dt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e==null||e.update(A)}}onExitXR(A){if(this.context.connection.isConnected&&this.context.connection.connectionId){const e=this._states.get(this.context.connection.connectionId);e==null||e.onExitXR(A)}}}class iq{constructor(){r(this,"_fadeToColorQuad");r(this,"_fadeToColorMaterial");r(this,"_requestedFadeValue",0);r(this,"_transitionPromise",null);r(this,"_transitionResolve",null);this._fadeToColorMaterial=new rt({color:0,transparent:!0,depthTest:!1,fog:!1,side:wt}),this._fadeToColorQuad=new uA(new lg(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(A,e){const t=this._fadeToColorQuad,g=this._fadeToColorMaterial;t.parent!==A&&g.opacity>0?A.add(t):g.opacity===0&&t.removeFromParent(),t.layers.set(2),t.material=this._fadeToColorMaterial,t.position.z=-1,t.renderOrder=1/0;const I=this._requestedFadeValue;g.opacity=se.lerp(g.opacity,I,e/.03),Math.abs(g.opacity-I)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const A=new Promise(e=>{this._transitionResolve=e});return this._transitionPromise=A,A}}var _B=(i=>(i[i.Quad=0]="Quad",i[i.Cube=1]="Cube",i[i.Sphere=2]="Sphere",i))(_B||{});class ec{static createPrimitive(A,e){let t;switch(A){case 0:const I=new lg(1,1,1,1),o=(e==null?void 0:e.material)??new io({color:16777215});t=new uA(I,o);break;case 1:const s=new zt(1,1,1),n=(e==null?void 0:e.material)??new io({color:16777215});t=new uA(s,n);break;case 2:const C=new Os(.5,16,16),a=(e==null?void 0:e.material)??new io({color:16777215});t=new uA(C,a);break}return e!=null&&e.name&&(t.name=e.name),e!=null&&e.position&&t.position.set(e.position.x,e.position.y,e.position.z),e!=null&&e.rotation&&t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e!=null&&e.scale&&t.scale.set(e.scale.x,e.scale.y,e.scale.z),t}}const bK=class{constructor(A,e,t){r(this,"_session");r(this,"_mode");r(this,"_init");r(this,"_renderer");r(this,"_camera");r(this,"_scene");r(this,"onEnd",()=>{var A;(A=this._session)==null||A.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()});r(this,"_lastTime",0);r(this,"onFrame",(A,e)=>{const t=A-this._lastTime;this.update(A,t),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)});r(this,"_spheres",[]);this._mode=A,this._init=e,this._session=t,this._session.addEventListener("end",this.onEnd),this._renderer=new VC({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(t),this._renderer.xr.enabled=!0,this._camera=new Ze,this._scene=new EI,this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(A,e){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!e)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const t=await navigator.xr.requestSession(A,e);return t.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new bK(A,e,t),this._active):(t.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await os(100)),this._active=null}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const A={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,A}async onBeforeHandoff(){const A=ec.createPrimitive(_B.Cube);A.position.z=-3,A.position.y=.5,this._scene.add(A),await os(4e3),this._scene.clear(),await os(100)}setupScene(){this._scene.background=new yA(0),this._scene.add(new Yw(5,10,1118481,2236962));const A=new jE(16777215,1);A.position.set(2,2,2),A.castShadow=!1,this._scene.add(A);const e=new jE(16777215,1);e.position.set(-2,-2,-2),e.castShadow=!1,this._scene.add(e);const t=50;for(let g=0;g<100;g++){const I=ec.createPrimitive(_B.Sphere,{material:new io({color:2236962,metalness:1,roughness:.8})});I.position.x=se.random(-t,t),I.position.y=se.random(3,40),I.position.z=se.random(-t,t),I.scale.multiplyScalar(2),this._spheres.push(I),this._scene.add(I)}}update(A,e){const t=A*4e-4;for(let g=0;g<this._spheres.length;g++){const I=this._spheres[g];I.position.y+=Math.sin(t+g*.5)*.002}}};let pB=bK;r(pB,"_active",null),r(pB,"_requestInFlight",!1);const nI=oA("debugwebxr"),QtA=oA("stats");function EtA(i){let A=null;const e=i;return e.getAROverlayContainer?A=e.getAROverlayContainer():A=i,A}ctA();function ctA(){var i;if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(i=navigator.xr)==null||i.addEventListener("sessiongranted",()=>{console.log("Received Session Granted...");const A=sessionStorage.getItem("needle_xr_session_mode"),e=sessionStorage.getItem("needle_xr_session_init");if(A&&e){console.log("Session Granted: Restore last session");const t=JSON.parse(e);pe.start(A,t).catch(g=>console.warn(g))}else pe.start("immersive-vr").catch(t=>console.warn("Session Granted failed:",t))})}}function htA(i,A){sessionStorage.setItem("needle_xr_session_mode",i),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(A))}function ltA(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}$l()&&Ge()&&window.addEventListener("keydown",i=>{i.key==="x"&&pe.active&&pe.stop()});if(oA("simulatewebxrloading")){Nt.registerCallback(Xi.ContextCreationStart,async A=>{await os(3e3),setTimeout(async()=>{const e=await pB.handoff();e?pe.setSession(e.mode,e.session,e.init,ve.Current):pe.start("immersive-vr")},6e3)});let i=!1;window.addEventListener("click",()=>{i||(i=!0,pB.start("immersive-vr",pe.getDefaultSessionInit("immersive-vr")))})}const Ja=class{constructor(A,e,t,g){r(this,"context");r(this,"session");r(this,"mode");r(this,"controllers",[]);r(this,"_rigScale",1);r(this,"_lastRigScaleUpdate",-1);r(this,"_rigs",[]);r(this,"_viewerHitTestSource",null);r(this,"_defaultRig");r(this,"_xr_scripts");r(this,"_xr_update_scripts",[]);r(this,"_inactive_scripts",[]);r(this,"_controllerAdded");r(this,"_controllerRemoved");r(this,"_originalCameraWorldPosition");r(this,"_originalCameraWorldRotation");r(this,"_originalCameraWorldScale");r(this,"_originalCameraParent");r(this,"_mainCamera",null);r(this,"onRendererSessionSet",()=>{this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera))});r(this,"onInputSourceAdded",A=>{if(A.targetRayMode==="screen")return;let e=0;for(let g=0;g<this.session.inputSources.length;g++)if(this.session.inputSources[g]===A){e=g;break}if(this.controllers.find(g=>g.inputSource===A))return;const t=new qN(this,A,e);this.controllers.push(t),this.controllers.sort((g,I)=>g.index-I.index),this._newControllers.push(t),this.invokeControllerEvent(t,this._controllerAdded,"added")});r(this,"_ended",!1);r(this,"_newControllers",[]);r(this,"onEnd",A=>{var g,I,o,s;if(this._ended)return;this._ended=!0,nI&&console.log("XR Session ended"),ltA(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,m9(this.onBefore,eg.LateUpdate);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);e>=0&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRender);t>=0&&this.context.post_render_callbacks.splice(t,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,(g=this.context.mainCameraComponent)==null||g.applyClearFlags();for(const n of Ja._xrEndListeners)n({xr:this});for(let n=0;n<this.controllers.length;n++)this.disconnectInputSource(this.controllers[n].inputSource);for(const n of this._xr_scripts)(I=n==null?void 0:n.onLeaveXR)==null||I.call(n,{xr:this});(o=this.sync)==null||o.onExitXR(this),this.context.mainCamera&&((s=this._originalCameraParent)==null||s.add(this.context.mainCamera),this._originalCameraWorldPosition&&QI(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&rs(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&Bd(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent()});r(this,"_didStart",!1);r(this,"onBefore",A=>{var g,I,o,s,n,C,a,B;const e=A.xrFrame;if(!e)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((g=this.rig)==null?void 0:g.isActive)==!1&&(nI&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&((I=this._mainCamera)!=null&&I.gameObject)&&((s=(o=this._mainCamera)==null?void 0:o.gameObject)==null?void 0:s.parent)!==this.rig.gameObject&&this.rig.gameObject.add((n=this._mainCamera)==null?void 0:n.gameObject),this.internalUpdateState(),this.applyCustomForward();const t={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const Q=[...this.context.new_scripts_xr];for(let E=0;E<Q.length;E++){const c=this.context.new_scripts_xr[E];if(!c||c.destroyed||((C=c.supportsXR)==null?void 0:C.call(c,this.mode))==!1){this.context.new_scripts_xr.splice(E,1);continue}if(!c.activeAndEnabled){this.context.new_scripts_xr.splice(E,1),this.markInactive(c);continue}if(this.addScript(c)){this.invokeCallback_EnterXR(c);for(const h of this.controllers)this.invokeCallback_ControllerAdded(c,h)}}}}else{this._didStart=!0;for(const E of Ja._xrStartListeners)E(t);const Q=[...this._xr_scripts];nI&&console.log("NeedleXRSession start, handle scripts:",Q);for(const E of Q){if(E.destroyed){this._script_to_remove.push(E);continue}if(!E.activeAndEnabled){this.markInactive(E);continue}this.invokeCallback_EnterXR(E);for(const c of this.controllers)this.invokeCallback_ControllerAdded(E,c)}}this.syncCameraCullingMask();for(const Q of this.controllers)Q.onUpdate(e);for(const Q of this._newControllers)for(const E of this._xr_scripts){if(E.destroyed){this._script_to_remove.push(E);continue}E.onXRControllerAdded&&E.onXRControllerAdded({xr:this,controller:Q,change:"added"})}this._newControllers.length=0;for(const Q of this._xr_update_scripts){if(Q.destroyed===!0){this._script_to_remove.push(Q);continue}if(Q.activeAndEnabled===!1){this.markInactive(Q);continue}Q.onUpdateXR&&Q.onUpdateXR(t)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const Q=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const E of Q)!E.destroyed&&this.running&&((a=E.onLeaveXR)==null||a.call(E,t)),this.removeScript(E)}(B=this.sync)==null||B.onUpdate(this),this.onRenderDebug()});r(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)});r(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),$l()){const A=this.context.renderer;if(A.xr.isPresenting&&this.context.mainCamera){const e=A.xr.enabled,t=A.getRenderTarget();A.xr.enabled=!1,A.setRenderTarget(null),A.render(this.context.scene,this.context.mainCamera),A.xr.enabled=e,A.setRenderTarget(t)}}});r(this,"_script_to_remove",[]);r(this,"_camera");r(this,"_cameraRenderParent",new pA().rotateY(Math.PI));r(this,"_previousCameraParent");r(this,"_customforward",!0);r(this,"originalCameraNearPlane");r(this,"_viewerPose");r(this,"_transformOrientation",new RA);r(this,"_transformPosition",new y);r(this,"_transition");var I,o,s;htA(A,g.init),this.session=e,this.mode=A,this.context=t,this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet),this._xr_scripts=[...g.scripts],this._xr_update_scripts=this._xr_scripts.filter(n=>typeof n.onUpdateXR=="function"),this._controllerAdded=g.controller_added,this._controllerRemoved=g.controller_removed,Au(this.onBefore,eg.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((I=g.init.optionalFeatures)!=null&&I.includes("hit-test")||(o=g.init.requiredFeatures)!=null&&o.includes("hit-test"))&&e.requestReferenceSpace("viewer").then(n=>{var C,a;return(a=(C=e.requestHitTestSource)==null?void 0:C.call(e,{space:n}))==null?void 0:a.then(B=>this._viewerHitTestSource=B)}).catch(n=>console.warn(n)),this.context.mainCamera&&(this._originalCameraWorldPosition=Je(this.context.mainCamera,new y),this._originalCameraWorldRotation=qt(this.context.mainCamera,new RA),this._originalCameraWorldScale=li(this.context.mainCamera,new y),this._originalCameraParent=this.context.mainCamera.parent),(s=this.context.mainCameraComponent)==null||s.applyClearFlags(),this._defaultRig=new atA,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(const n of this.session.inputSources)this.onInputSourceAdded(n);this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",n=>{for(const C of n.removed)this.disconnectInputSource(C);for(const C of n.added)this.onInputSourceAdded(C)})}static getXRSync(A){return this._sync||(this._sync=new tO(A)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var A;return((A=this._activeSession)==null?void 0:A.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(A=>A.some(e=>e)).catch(()=>!1)}static isVRSupported(){var A;return((A=this.xrSystem)==null?void 0:A.isSessionSupported("immersive-vr").catch(e=>(nI&&console.error(e),!1)))??Promise.resolve(!1)}static isARSupported(){var A;return((A=this.xrSystem)==null?void 0:A.isSessionSupported("immersive-ar").catch(e=>(nI&&console.error(e),!1)))??Promise.resolve(!1)}static onSessionRequestStart(A){this._sessionRequestStartListeners.push(A)}static offSessionRequestStart(A){const e=this._sessionRequestStartListeners.indexOf(A);e>=0&&this._sessionRequestStartListeners.splice(e,1)}static onSessionRequestEnd(A){this._sessionRequestEndListeners.push(A)}static offSessionRequestEnd(A){const e=this._sessionRequestEndListeners.indexOf(A);e>=0&&this._sessionRequestEndListeners.splice(e,1)}static onXRSessionStart(A){this._xrStartListeners.push(A)}static offXRSessionStart(A){const e=this._xrStartListeners.indexOf(A);e>=0&&this._xrStartListeners.splice(e,1)}static onXRSessionEnd(A){this._xrEndListeners.push(A)}static offXRSessionEnd(A){const e=this._xrEndListeners.indexOf(A);e>=0&&this._xrEndListeners.splice(e,1)}static onControllerAdded(A){this._controllerAddedListeners.push(A)}static offControllerAdded(A){const e=this._controllerAddedListeners.indexOf(A);e>=0&&this._controllerAddedListeners.splice(e,1)}static onControllerRemoved(A){this._controllerRemovedListeners.push(A)}static offControllerRemoved(A){const e=this._controllerRemovedListeners.indexOf(A);e>=0&&this._controllerRemovedListeners.splice(e,1)}static offerSession(A,e,t){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+A),e=="default"&&(e=this.getDefaultSessionInit(A)),navigator.xr.offerSession(A,{...e}).then(g=>Ja.setSession(A,g,e,t)).catch(g=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(A){switch(A){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",A),{}}}static async start(A,e,t){var o,s,n,C;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(nI||Ge())&&fi("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(t||(t=ve.Current),t||(t=Nt.All[0]),!t)throw new Error("No Needle Engine Context found");switch(e||(e={}),A){case"immersive-ar":{if(await((o=this.xrSystem)==null?void 0:o.isSessionSupported("immersive-ar"))!==!0)return console.error(A+" is not supported by this browser."),null;const B=this.getDefaultSessionInit(A),Q=EtA(t.domElement);Q&&!_w()&&(B.domOverlay={root:Q},B.optionalFeatures.push("dom-overlay")),e={...B,...e}}break;case"immersive-vr":{if(await((s=this.xrSystem)==null?void 0:s.isSessionSupported("immersive-vr"))!==!0)return console.error(A+" is not supported by this browser."),null;e={...this.getDefaultSessionInit(A),...e}}break;default:console.warn("No default session init for mode",A);break}await pB.stop();const g=A=="immersive-ar"?t.scripts_immersive_ar:t.scripts_immersive_vr;nI?console.log(`%cRequesting ${A} session`,"font-weight:bold;",e,g):console.log(`%cRequesting ${A} session`,"font-weight:bold;");for(const a of g)a.onBeforeXR&&a.onBeforeXR(A,e);for(const a of this._sessionRequestStartListeners)a({mode:A,init:e});nI&&Ui("Requesting "+A+" session ("+Date.now()+")"),this._currentSessionRequest=(n=navigator.xr)==null?void 0:n.requestSession(A,e),this._currentSessionRequestMode=A;const I=await((C=this._currentSessionRequest)==null?void 0:C.catch(a=>{console.error(a,"Code: "+a.code),a.code===9&&fi("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&fi("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const a of this._sessionRequestEndListeners)a({mode:A,init:e,newSession:I||null});return I?this.setSession(A,I,e,t):(console.warn("XR Session request was rejected"),null)}static setSession(A,e,t,g){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const I=A=="immersive-ar"?g.scripts_immersive_ar:g.scripts_immersive_vr;return this._activeSession=new Ja(A,e,g,{scripts:I,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:t}),e.addEventListener("end",this.onEnd),nI?console.log(`%cStarted ${A} session`,"font-weight:bold;",I):console.log(`%cStarted ${A} session`,"font-weight:bold;"),this._activeSession}static stop(){var A;(A=this._activeSession)==null||A.end()}get sync(){return Ja._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(A=>A.isLeft)}get rightController(){return this.controllers.find(A=>A.isRight)}getController(A){return this.controllers.find(e=>e.side===A)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(A=>A.inputSource.targetRayMode==="tracked-pointer")||Ge()&&$l()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const A=this.frame.getImageTrackingResults();for(const e of A)if(e.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const A=this._rigs[0]??null;return A!=null&&A.gameObject&&HB(A.gameObject)||(A==null?void 0:A.isActive)===!1?(this.updateActiveXRRig(),this._rigs[0]??null):A}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(A){this._rigs.indexOf(A)>=0||(A.priority===void 0&&(A.priority=0),this._rigs.push(A),this.updateActiveXRRig())}removeRig(A){const e=this._rigs.indexOf(A);e!==-1&&(this._rigs.splice(e,1),this.updateActiveXRRig())}setRigActive(A){const e=this._rigs.indexOf(A);this._rigs.splice(e,1),this._rigs.unshift(A),this.updateActiveXRRig()}updateActiveXRRig(){const A=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let e=this._rigs[0];e&&e.priority===void 0&&(e.priority=0);for(let t=1;t<this._rigs.length;t++){const g=this._rigs[t];if(g.isActive){if(HB(g.gameObject)){this._rigs.splice(t,1),t--;continue}(!e||e.isActive===!1||g.priority!==void 0&&g.priority>e.priority)&&(e=g)}}if(A!==e){const t=this._rigs.indexOf(e);t>=0&&this._rigs.splice(t,1),this._rigs.unshift(e)}nI&&(A===e?console.log("Updated Active XR Rig:",e,"prev:",A):console.log("Updated Active XRRig:",e," (the same as before)"))}getHitTest(A){if(A)return this.getControllerHitTest(A);if(!this._viewerHitTestSource)return null;const e=this._viewerHitTestSource,t=this.frame.getHitTestResults(e);if(t.length>0){const g=t[0];return this.convertHitTestResult(g)}return null}getControllerHitTest(A){const e=A.hitTestSource;if(!e)return null;const t=this.frame.getHitTestResultsForTransientInput(e);for(const g of t)if(g.inputSource===A.inputSource)for(const I of g.results)return this.convertHitTestResult(I);return null}convertHitTestResult(A){const e=this.context.renderer.xr.getReferenceSpace(),t=e&&A.getPose(e);if(t){const g=Zi(t.transform.position),I=uB(t.transform.orientation),o=this.context.mainCamera;if((o==null?void 0:o.parent)!==this._cameraRenderParent&&g.applyMatrix4(wy),o!=null&&o.parent){g.applyMatrix4(o.parent.matrixWorld),I.multiply(Us);const s=qt(o.parent);s.premultiply(Us),I.premultiply(s)}return{hit:A,position:g,quaternion:I}}return null}convertSpace(A){const e=Zi(A.position);e.applyMatrix4(wy);const t=uB(A.orientation);return t.premultiply(Us),{position:e,quaternion:t}}end(){this._ended||this.session.end().catch(A=>console.warn(A))}disconnectInputSource(A){for(let e=this.controllers.length-1;e>=0;e--){const t=this.controllers[e];if(t.inputSource===A){this.controllers.splice(e,1),this.invokeControllerEvent(t,this._controllerRemoved,"removed");const g={xr:this,controller:t,change:"removed"};for(const I of this._xr_scripts)I.onXRControllerRemoved&&I.onXRControllerRemoved(g);t.onDisconnected()}}}onRenderDebug(){if(nI)for(const A of this.controllers)A.onRenderDebug();if((nI||QtA)&&this.rig){const A=this.rig.gameObject.worldPosition,e=this.rig.gameObject.worldForward;A.add(e.multiplyScalar(1.5));const t=this.rig.gameObject.worldUp;A.add(t.multiplyScalar(2.5));let g="";if(g+=this.context.time.smoothedFps.toFixed(1),nI)for(const I of this.controllers)g+=`
|
|
4989
4989
|
${I.hand?"hand":"ctrl"} ${I.inputSource.handedness}[${I.index}] con:${I.connected} tr:${I.isTracking}`;Ue.DrawLabel(A,g)}}addScript(A){return this._xr_scripts.includes(A)?!1:(nI&&console.log("Register new XRScript",A),this._xr_scripts.push(A),typeof A.onUpdateXR=="function"&&this._xr_update_scripts.push(A),!0)}markInactive(A){if(!(this._inactive_scripts.indexOf(A)>=0)){this.removeScript(A,!1),this._inactive_scripts.push(A);for(const e of this.controllers)this.invokeCallback_ControllerRemoved(A,e);this.invokeCallback_LeaveXR(A)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let A=this._inactive_scripts.length-1;A>=0;A--){const e=this._inactive_scripts[A];if(e.activeAndEnabled){this._inactive_scripts.splice(A,1),this.addScript(e),this.invokeCallback_EnterXR(e);for(const t of this.controllers)this.invokeCallback_ControllerAdded(e,t)}}}removeScript(A,e=!0){nI&&console.log("Remove XRScript",A);const t=this._xr_scripts.indexOf(A);t>=0&&this._xr_scripts.splice(t,1);const g=this._xr_update_scripts.indexOf(A);if(g>=0&&this._xr_update_scripts.splice(g,1),e){const I=this._inactive_scripts.indexOf(A);I>=0&&this._inactive_scripts.splice(I,1)}}invokeCallback_EnterXR(A){A.onEnterXR&&A.onEnterXR({xr:this})}invokeCallback_ControllerAdded(A,e){A.onXRControllerAdded&&A.onXRControllerAdded({xr:this,controller:e,change:"added"})}invokeCallback_ControllerRemoved(A,e){A.onXRControllerRemoved&&A.onXRControllerRemoved({xr:this,controller:e,change:"removed"})}invokeCallback_LeaveXR(A){A.onLeaveXR&&!A.destroyed&&A.onLeaveXR({xr:this})}syncCameraCullingMask(){var t;const A=this.context.xrCamera,e=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(A&&e!==void 0){for(const g of A.cameras)g.layers.mask=e;A.layers.mask=e}else if(A){for(const g of A.cameras)g.layers.enableAll();A.layers.enableAll()}}invokeControllerEvent(A,e,t){for(let g=e.length-1;g>=0;g--){const I=e[g];if(I)try{I({xr:this,controller:A,change:t})}catch(o){console.error(o)}}}applyCustomForward(){var A;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(A=this._previousCameraParent)==null||A.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let e=.02;if(this.rig){const t=li(this.rig.gameObject);e*=t.x}this._camera instanceof Ze&&this._camera.near>e&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=e)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Ze&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const A=this.context.renderer.xr.getReferenceSpace();if(!A){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(A),this._viewerPose){const e=this._viewerPose.transform;this._transformPosition.set(e.position.x,e.position.y,e.position.z),this._transformOrientation.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w)}}get transition(){return this._transition||(this._transition=new iq),this._transition}fadeTransition(){return this._transition||(this._transition=new iq),this._transition.fadeTransition()}updateFade(A){this._transition&&A instanceof Ze&&this._transition.update(A,this.context.time.deltaTime)}onUpdateFade_PostRender(){var A;(A=this._transition)==null||A.remove()}};let pe=Ja;r(pe,"_sync",null),r(pe,"_currentSessionRequestMode",null),r(pe,"_currentSessionRequest"),r(pe,"_activeSession"),r(pe,"_sessionRequestStartListeners",[]),r(pe,"_sessionRequestEndListeners",[]),r(pe,"_xrStartListeners",[]),r(pe,"_xrEndListeners",[]),r(pe,"_controllerAddedListeners",[]),r(pe,"_controllerRemovedListeners",[]),r(pe,"onEnd",()=>{nI&&console.log("XR Session ended"),Ja._activeSession=null});const jm=oA("debugwebxr");class iO{static tryFindAvatarObjects(A,e,t){if(t.head&&t.leftHand&&t.rightHand)return;const g=A.name.toLocaleLowerCase();!t.head&&g.includes("head")&&(jm&&console.log("FOUND AVATAR HEAD",A.name),t.head=new It("",e,A)),g.includes("hand")&&(!t.leftHand&&g.includes("left")&&(jm&&console.log("FOUND AVATAR LEFT HAND",A.name),t.leftHand=new It("",e,A)),!t.rightHand&&g.includes("right")&&(jm&&console.log("FOUND AVATAR RIGHT HAND",A.name),t.rightHand=new It("",e,A)));for(let I=0;I<A.children.length;I++){if(t.head&&t.leftHand&&t.rightHand)return;const o=A.children[I];this.tryFindAvatarObjects(o,e,t)}}}const fI=new y,gq=new y,Iq=new RA,dtA=oA("debuggizmos"),iC=8947848,Gs=class{static isGizmo(A){return A[KM]!==void 0}static DrawLabel(A,e,t=.05,g=0,I,o,s){var a;if(!Gs.enabled)return null;I||(I=iC);const n=((a=pe.active)==null?void 0:a.rigScale)??1,C=zi.getTextLabel(g,e,t*n,I,o);return s instanceof pA&&s.add(C),C.position.x=A.x,C.position.y=A.y,C.position.z=A.z,C}static DrawRay(A,e,t=iC,g=0,I=!0){if(!Gs.enabled)return;const o=zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),fI.set(e.x,e.y,e.z).multiplyScalar(999999999),s.setXYZ(1,A.x+fI.x,A.y+fI.y,A.z+fI.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawDirection(A,e,t=iC,g=0,I=!0,o=1){if(!Gs.enabled)return;const s=zi.getLine(g),n=s.geometry.getAttribute("position");n.setXYZ(0,A.x,A.y,A.z),e.w!==void 0?(fI.set(0,0,-o),Iq.set(e.x,e.y,e.z,e.w),fI.applyQuaternion(Iq)):(fI.set(e.x,e.y,e.z),fI.multiplyScalar(o)),n.setXYZ(1,A.x+fI.x,A.y+fI.y,A.z+fI.z),n.needsUpdate=!0,s.material.color.set(t),s.material.depthTest=I,s.material.depthWrite=!1}static DrawLine(A,e,t=iC,g=0,I=!0){if(!Gs.enabled)return;const o=zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),s.setXYZ(1,e.x,e.y,e.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireSphere(A,e,t=iC,g=0,I=!0){if(!Gs.enabled)return;const o=zi.getSphere(e,g,!0);TB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawSphere(A,e,t=iC,g=0,I=!0){if(!Gs.enabled)return;const o=zi.getSphere(e,g,!1);TB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireBox(A,e,t=iC,g=0,I=!0){if(!Gs.enabled)return;const o=zi.getBox(g);o.position.set(A.x,A.y,A.z),o.scale.set(e.x,e.y,e.z),o.material.color.set(t),o.material.depthTest=I,o.material.wireframe=!0,o.material.depthWrite=!1}static DrawWireBox3(A,e=iC,t=0,g=!0){if(!Gs.enabled)return;const I=zi.getBox(t);I.position.copy(A.getCenter(fI)),I.scale.copy(A.getSize(fI)),I.material.color.set(e),I.material.depthTest=g,I.material.wireframe=!0,I.material.depthWrite=!1}static DrawArrow(A,e,t=iC,g=0,I=!0,o=!1){if(!Gs.enabled)return;const s=zi.getArrowHead(g);s.position.set(e.x,e.y,e.z),s.quaternion.setFromUnitVectors(this._up.set(0,1,0),fI.set(e.x,e.y,e.z).sub(gq.set(A.x,A.y,A.z)).normalize());const C=fI.set(e.x,e.y,e.z).sub(gq.set(A.x,A.y,A.z)).length()*.1;s.scale.set(C,C,C),s.material.color.set(t),s.material.depthTest=I,s.material.wireframe=o,this.DrawLine(A,e,t,g,I)}};let Ue=Gs;r(Ue,"enabled",!0),r(Ue,"_up",new y(0,1,0));const utA=new zt(1,1,1);function LN(i=null){const A=new yA(i??14540253),e=new sU(utA);return new No(e,new Oi({color:A}))}const KM=Symbol("GizmoCache");class zi{static ensureFont(){let A=sE.FontLibrary.getFontFamily(this.familyName);if(!A){A=sE.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{sE.update()})}}static getTextLabel(A,e,t,g,I){this.ensureFont();let o=this.textLabelCache.pop(),s=1;I&&typeof I=="string"&&(I==null?void 0:I.length)>=8&&I.startsWith("#")?(s=parseInt(I.substring(7),16)/255,I=I.substring(0,7),dtA&&console.log(I,s)):typeof I=="object"&&I.a!==void 0&&(s=I.a);const n={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:t,color:g,lineHeight:1,backgroundColor:I??void 0,backgroundOpacity:s,textContent:e,borderRadius:.5*t,padding:.8*t,whiteSpace:"pre"};if(o)o.set(n);else{o=new RN(n);const C=this,a=o;a.setText=function(B){this.set({textContent:B}),C.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(ve.Current,o,A,this.textLabelCache),o}static getBox(A){let e=this.boxesCache.pop();if(!e){const t=new zt(1,1,1);e=new uA(t)}return this.registerTimedObject(ve.Current,e,A,this.boxesCache),e}static getLine(A){let e=this.linesCache.pop();if(!e){e=new Ti;let t=e.geometry.getAttribute("position");t||(t=new ie(new Float32Array(2*3),3),e.geometry.setAttribute("position",t))}return e.frustumCulled=!1,this.registerTimedObject(ve.Current,e,A,this.linesCache),e}static getSphere(A,e,t){let g=this.spheresCache.pop();return g||(g=new uA(new Os(1,8,8))),g.scale.set(A,A,A),g.material.wireframe=t,this.registerTimedObject(ve.Current,g,e,this.spheresCache),g}static getArrowHead(A){let e=this.arrowHeadsCache.pop();return e||(e=new uA(new xi(0,.5,1,8))),this.registerTimedObject(ve.Current,e,A,this.arrowHeadsCache),e}static registerTimedObject(A,e,t,g){const I=this.contextBeforeRenderCallbacks.get(A),o=this.contextPostRenderCallbacks.get(A);if(I){if(A.pre_render_callbacks[A.pre_render_callbacks.length-1]!==I){const s=A.pre_render_callbacks.indexOf(I);s>=0&&A.pre_render_callbacks.splice(s,1),A.pre_render_callbacks.push(I)}}else{const s=()=>{this.onBeforeRender(A,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(A,s),A.pre_render_callbacks.push(s)}if(o){if(A.post_render_callbacks[A.post_render_callbacks.length-1]!==o){const s=A.post_render_callbacks.indexOf(o);s>=0&&A.post_render_callbacks.splice(s,1),A.post_render_callbacks.push(o)}}else{const s=()=>{this.onPostRender(A,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(A,s),A.post_render_callbacks.push(s)}e.traverse(s=>{s.layers.disableAll(),s.layers.enable(2)}),e.renderOrder=999999,e[KM]=g,this.timedObjectsBuffer.push(e),this.timesBuffer.push(ve.Current.time.realtimeSinceStartup+t),A.scene.add(e)}static onBeforeRender(A,e){this.tmuiNeedsUpdate&&sE.update();for(let t=0;t<e.length;t++){const g=e[t];if(A.mainCamera&&g instanceof sE.MeshUIBaseElement){if(HB(g))continue;const I=A.isInVR,o=!1,s=!I;UN(g,A.mainCamera,o,s)}}}static onPostRender(A,e,t){const g=A.time.realtimeSinceStartup;for(let I=e.length-1;I>=0;I--){const o=e[I];g>t[I]&&(e.splice(I,1),t.splice(I,1),o.removeFromParent(),HB(o)!=!0&&o[KM].push(o))}}}r(zi,"familyName","needle-gizmos"),r(zi,"linesCache",[]),r(zi,"spheresCache",[]),r(zi,"boxesCache",[]),r(zi,"arrowHeadsCache",[]),r(zi,"textLabelCache",[]),r(zi,"timedObjectsBuffer",new Array),r(zi,"timesBuffer",new Array),r(zi,"contextPostRenderCallbacks",new Map),r(zi,"contextBeforeRenderCallbacks",new Map),r(zi,"tmuiNeedsUpdate",!1);const ptA=oA("debugphysics"),oq=new JI;class Bs{constructor(){r(this,"ray");r(this,"cam");r(this,"screenPoint");r(this,"raycaster");r(this,"results");r(this,"targets");r(this,"recursive",!0);r(this,"minDistance");r(this,"maxDistance");r(this,"lineThreshold");r(this,"layerMask");r(this,"ignore");r(this,"testObject")}screenPointFromOffset(A,e){this.screenPoint===void 0&&(this.screenPoint=new gA),this.screenPoint.x=A/window.innerWidth*2-1,this.screenPoint.y=-(e/window.innerHeight)*2+1}setLayer(A){oq.set(A),this.layerMask=oq}setMask(A){this.layerMask||(this.layerMask=new JI);const e=this.layerMask;e?e.mask=A:this.layerMask=A}}r(Bs,"AllLayers",4294967295);class gO{constructor(A,e,t){r(this,"distance");r(this,"point");r(this,"object");this.object=A,this.distance=e,this.point=t}}class IO{constructor(A){r(this,"context");r(this,"engine");r(this,"raycaster",new dc);r(this,"defaultRaycastOptions",new Bs);r(this,"targetBuffer",new Array(1));r(this,"defaultThresholds",{Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}});r(this,"sphereResults",new Array);r(this,"sphereMask",new JI);r(this,"tempBoundingBox",new Lt);this.context=A}raycastPhysicsFast(A,e=void 0,t=1/0,g=!0){var I;return((I=this.context.physics.engine)==null?void 0:I.raycast(A,e,t,g))??null}raycastPhysicsFastAndGetNormal(A,e=void 0,t=1/0,g=!0){var I;return((I=this.context.physics.engine)==null?void 0:I.raycastAndGetNormal(A,e,t,g))??null}sphereOverlapPhysics(A,e){var t;return((t=this.context.physics.engine)==null?void 0:t.sphereOverlap(A,e))??null}sphereOverlap(A,e,t=!0){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const g=new Hi(A,e),I=this.sphereMask;I.enableAll(),I.disable(2);for(const o of this.context.scene.children)this.onSphereOverlap(o,g,I,this.sphereResults,t);return this.sphereResults.sort((o,s)=>o.distance-s.distance)}onSphereOverlap(A,e,t,g,I){if(A.type==="Mesh"&&A.layers.test(t)&&!Ue.isGizmo(A)){const o=A,s=o.geometry;if(s&&(s.boundingBox||s.computeBoundingBox(),s.boundingBox)){o.matrixWorldNeedsUpdate&&o.updateMatrixWorld();const n=this.tempBoundingBox.copy(s.boundingBox).applyMatrix4(o.matrixWorld);if(e.intersectsBox(n)){const C=Je(A),a=C.distanceTo(e.center),B=new gO(A,a,C);if(g.push(B),!I)return}}}if(A.children)for(const o of A.children){const s=g.length;if(this.onSphereOverlap(o,e,t,g,I),s!=g.length&&!I)return}}raycastFromRay(A,e=null){const t=e??this.defaultRaycastOptions;t.ray=A;const g=this.raycast(t);return t===this.defaultRaycastOptions&&(t.ray=void 0),g}raycast(A=null){A||(A=this.defaultRaycastOptions);const e=A.screenPoint??this.context.input.mousePositionRC,t=A.raycaster??this.raycaster;if(t.near=A.minDistance??0,t.far=A.maxDistance??1/0,t.params=this.defaultThresholds,A.lineThreshold===void 0&&(A.lineThreshold=-1),t.params.Line={threshold:A.lineThreshold},A.ray)t.ray.copy(A.ray);else{const s=A.cam??this.context.mainCamera;if(!s)return ptA&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];t.setFromCamera(e,s)}let g=A.targets;g||(g=this.targetBuffer,g.length=1,g[0]=this.context.scene);let I=A.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),I||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),I=this.defaultRaycastOptions.results),A.layerMask!==void 0?A.layerMask instanceof JI?t.layers.mask=A.layerMask.mask:t.layers.mask=A.layerMask:(t.layers.enableAll(),t.layers.disable(2)),I.length=0,this.intersect(this.raycaster,g,I,A),I.sort((s,n)=>s.distance-n.distance);const o=A.ignore;return o!==void 0&&o.length>0&&(I=I.filter(s=>!o.includes(s.object))),I}intersect(A,e,t,g){var I;for(const o of e){if(o.visible===!1||Ue.isGizmo(o)||g.lineThreshold!==void 0&&g.lineThreshold<0&&o instanceof Ti)continue;const s=(I=g.testObject)==null?void 0:I.call(g,o);if(s===!1)continue;s!=="continue in children"&&A.intersectObject(o,!1,t),g.recursive!==!1&&this.intersect(A,o.children,t,g)}return t}}const ftA=oA("debugplayerview");var Va=(i=>(i.Browser="browser",i.Headset="headset",i.Handheld="handheld",i))(Va||{});class oO{constructor(A,e){r(this,"userId");r(this,"context");r(this,"viewDevice","browser");r(this,"removed",!1);r(this,"_object");this.userId=A,this.context=e}get currentObject(){return this._object}set currentObject(A){this._object=A}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class sO{constructor(A){r(this,"context");r(this,"playerViews",new Map);this.context=A}setPlayerView(A,e,t){let g=this.playerViews.get(A);g||(g=new oO(A,this.context),this.playerViews.set(A,g)),g.viewDevice=t,g.currentObject=e,g.removed=!1}getPlayerView(A){if(!A)return;if(!this.context.connection.userIsInRoom(A)){this.playerViews.delete(A);return}return this.playerViews.get(A)}removePlayerView(A,e){const t=this.playerViews.get(A);(t==null?void 0:t.viewDevice)===e&&(ftA&&console.log("REMOVE",A),t.removed=!0,this.playerViews.delete(A))}}new Qg;const au=new Uint8Array(4);au[0]=255;au[1]=255;au[2]=255;au[3]=255;const DtA=new wo(au,1,1,Mt);function nO(i,A=1){const e="alpha"in i,t=A*A,g=new Uint8Array(4*t),I=Math.floor(i.r*255),o=Math.floor(i.g*255),s=Math.floor(i.b*255);for(let C=0;C<t;C++){const a=C*4;g[a+0]=I,g[a+1]=o,g[a+2]=s,e?g[a+3]=Math.floor(i.alpha*255):g[a+3]=255}const n=new wo(g,A,A);return n.needsUpdate=!0,n}function ytA(i,A,e,t=1,g=3){const o=t*g,s=[i,A,e],n=s.length,C=new Uint8Array(4*n*o),a=new yA;for(let Q=0;Q<g;Q++){const E=Math.floor(Q/g*n),c=se.clamp(E+1,0,n-1),h=s[E],u=s[c],l=Q/g*n%1;a.lerpColors(h,u,l);const d=Math.floor(a.r*255),p=Math.floor(a.g*255),f=Math.floor(a.b*255);for(let S=0;S<t;S++){const m=(Q*t+S)*4;C[m+0]=d,C[m+1]=p,C[m+2]=f,C[m+3]=255}}const B=new wo(C,t,g);return B.needsUpdate=!0,B}function Sy(i,A){const e=i.elements;A||(A=[]),A.length=0;for(let t=0;t<16;t+=4){const g=e[t],I=e[t+1],o=e[t+2],s=e[t+3],n=new oe(g,I,o,s);A.push(n)}return A}const Vm=[],sq=[];function wtA(i,A){if(Vm.length===0)for(let e=0;e<27;e++)Vm.push(0);A||(A=Vm);for(let e=0;e<27;e++)sq[e]=A[e];A=sq,i.unity_SHAr={value:new oe(A[9],A[3],A[6],A[0])},i.unity_SHBr={value:new oe(A[12],A[15],A[18],A[21])},i.unity_SHAg={value:new oe(A[10],A[4],A[7],A[1])},i.unity_SHBg={value:new oe(A[13],A[16],A[19],A[22])},i.unity_SHAb={value:new oe(A[11],A[5],A[8],A[2])},i.unity_SHBb={value:new oe(A[14],A[17],A[20],A[23])},i.unity_SHC={value:new oe(A[24],A[25],A[26],1)}}class StA{constructor(A,e,t){r(this,"vertexShader");r(this,"fragmentShader");r(this,"technique");this.vertexShader=A,this.fragmentShader=e,this.technique=t}}async function mtA(i,A){if(!i)return console.error("Can not find technique: no shader data"),null;const e=i.programs[A],t=e.vertexShader,g=e.fragmentShader;if(t!==void 0&&g!==void 0){const I=i.shaders[t],o=i.shaders[g];if(I.uri&&o.uri||I.code&&o.code){if(!I.code&&I.uri&&await nq(I),!o.code&&o.uri&&await nq(o),!I.code||!o.code)return null;const s=i.techniques[A];return new StA(I.code,o.code,s)}}return console.error("Shader technique not found",A),null}async function nq(i){const A=i.uri;if(A)if(A.endsWith(".glsl")){const t=await new Qg().loadAsync(A);i.code=t.toString()}else i.code=ktA(i.uri)}function ktA(i){return decodeURIComponent(Array.prototype.map.call(atob(i),function(A){return"%"+("00"+A.charCodeAt(0).toString(16)).slice(-2)}).join(""))}const en=oA("debugenvlight");var KE=(i=>(i[i.Skybox=0]="Skybox",i[i.Trilight=1]="Trilight",i[i.Flat=3]="Flat",i[i.Custom=4]="Custom",i))(KE||{}),my=(i=>(i[i.Skybox=0]="Skybox",i[i.Custom=1]="Custom",i))(my||{});class CO{constructor(A){r(this,"context");r(this,"_currentLightSettingsId");r(this,"_sceneLightSettings");r(this,"_timevec4",new oe);r(this,"__currentReflectionId",null);r(this,"_lighting",{});this.context=A,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const A=this.context.time;this._timevec4.x=A.time,this._timevec4.y=Math.sin(A.time),this._timevec4.z=Math.cos(A.time),this._timevec4.w=A.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const A=this._sceneLightSettings.get(this._currentLightSettingsId);return A?A.ambientIntensity:1}get sceneLightSettings(){var A;return(A=this._sceneLightSettings)==null?void 0:A.values()}enable(A){var t;A instanceof It&&(A=A.uri);const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(en&&console.log("Enable scene light settings",A,e),A!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=A,e.enabled=!0,!0):!1}disable(A){var t;if(A instanceof It&&(A=A.uri),A==null)return!1;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(en&&console.log("Disable scene light settings",A,e),e.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const A=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),A}return null}internalRegisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not register:",A);return}en&&console.log("Register "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(e,A)}internalUnregisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not unregister:",A);return}en&&console.log("Unregister "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings&&this._sceneLightSettings.delete(e)}internalRegisterReflection(A,e){en&&console.log("Register reflection",A,e);const t=new aO(this.context,e,1);this._lighting[A]=t}internalGetReflection(A){return this._lighting[A]}internalEnableReflection(A){var t;this.__currentReflectionId=A;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);switch(en&&console.log("Enable reflection",A,e?KE[e.ambientMode]:"Unknown ambient mode"),e==null?void 0:e.ambientMode){case 0:case 4:const g=this.internalGetReflection(A);if(g&&g.Source){en&&console.log("Setting environment reflection",g);const I=this.context.scene,o=g.Source;o.colorSpace=We,o.mapping=Is,I.environment=o;return}else en&&console.warn("Could not find reflection for source",A);break}if((e==null?void 0:e.environmentReflectionSource)===1)switch(e==null?void 0:e.ambientMode){case 1:if(e.ambientTrilight){const g=e.ambientTrilight,I=ytA(g[0],g[1],g[2],64,64);I.colorSpace=We,I.mapping=Is,this.context.scene.environment=I}else console.error("Missing ambient trilight",e.sourceId);return;case 3:if(e.ambientLight){const g=nO(e.ambientLight,64);g.colorSpace=We,g.mapping=Is,this.context.scene.environment=g}else console.error("Missing ambientlight",e.sourceId);return;default:return}}internalDisableReflection(A){if(A&&A!==this.__currentReflectionId){en&&console.log("Not disabling reflection for",A,"because it is not the current light settings id",this.__currentReflectionId);return}en&&console.log("Disable reflection",A);const e=this.context.scene;e.environment=null}}class aO{constructor(A,e,t=1){r(this,"_context");r(this,"_source");r(this,"_sphericalHarmonics",null);r(this,"_sphericalHarmonicsArray");r(this,"_ambientScale",1);r(this,"_lightProbe");this._context=A,this._source=e,this._ambientScale=t,e.mapping=Is,e.colorSpace=We}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}}const Cq=oA("timescale");let JM=1;typeof Cq=="number"&&(JM=Cq);class rO{constructor(){r(this,"deltaTime",0);r(this,"time",0);r(this,"timeScale",1);r(this,"frame",0);r(this,"clock",new hU);r(this,"_smoothedFps",0);r(this,"_smoothedDeltaTime",0);r(this,"_fpsSamples",[]);r(this,"_fpsSampleIndex",0);typeof JM=="number"&&(this.timeScale=JM)}get realtimeSinceStartup(){return this.clock.elapsedTime}get frameCount(){return this.frame}get smoothedFps(){return this._smoothedFps}get smoothedDeltaTime(){return 1/this._smoothedFps}update(){this.deltaTime=this.clock.getDelta(),this.deltaTime=Math.min(.1,this.deltaTime),this.deltaTime*=this.timeScale,this.deltaTime<=0&&(this.deltaTime=1e-12),this.frame+=1,this.time+=this.deltaTime,this._fpsSamples.length<60?this._fpsSamples.push(this.deltaTime):this._fpsSamples[this._fpsSampleIndex++%60]=this.deltaTime;let A=0;for(let e=0;e<this._fpsSamples.length;e++)A+=this._fpsSamples[e];this._smoothedDeltaTime=A/this._fpsSamples.length,this._smoothedFps=1/this._smoothedDeltaTime}}const jI=oA("debugcontext"),GtA=oA("stats"),MtA=oA("debugactive"),RtA=oA("debugframerate"),UtA=oA("debugcoroutine"),NtA={};class FtA{constructor(){r(this,"name");r(this,"alias");r(this,"hash");r(this,"runInBackground");r(this,"domElement");r(this,"renderer");r(this,"camera");r(this,"scene")}}var eg=(i=>(i[i.Start=-1]="Start",i[i.EarlyUpdate=0]="EarlyUpdate",i[i.Update=1]="Update",i[i.LateUpdate=2]="LateUpdate",i[i.OnBeforeRender=3]="OnBeforeRender",i[i.OnAfterRender=4]="OnAfterRender",i[i.PrePhysicsStep=9]="PrePhysicsStep",i[i.PostPhysicsStep=10]="PostPhysicsStep",i[i.Undefined=-1]="Undefined",i))(eg||{});function nS(i,A){if(!i)return;if(!i.isComponent){(Ge()||jI)&&console.error(`Registered script is not a Needle Engine component.
|
|
4990
4990
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
4991
|
-
`,i);return}const e=(A==null?void 0:A.new_scripts)??ve.Current.new_scripts;e.includes(i)||e.push(i)}const $t=class{constructor(A){r(this,"name");r(this,"alias");r(this,"isManagedExternally",!1);r(this,"isPaused",!1);r(this,"runInBackground",!1);r(this,"targetFrameRate");r(this,"physicsSteps",1);r(this,"hash");r(this,"domElement");r(this,"_resolutionScaleFactor",1);r(this,"_boundingClientRectFrame",-1);r(this,"_boundingClientRect",null);r(this,"_domX");r(this,"_domY");r(this,"xr",null);r(this,"_xrFrame",null);r(this,"_currentFrameEvent",-1);r(this,"scene");r(this,"renderer");r(this,"composer",null);r(this,"scripts",[]);r(this,"scripts_pausedChanged",[]);r(this,"scripts_earlyUpdate",[]);r(this,"scripts_update",[]);r(this,"scripts_lateUpdate",[]);r(this,"scripts_onBeforeRender",[]);r(this,"scripts_onAfterRender",[]);r(this,"scripts_WithCorroutines",[]);r(this,"scripts_immersive_vr",[]);r(this,"scripts_immersive_ar",[]);r(this,"coroutines",{});r(this,"post_setup_callbacks",[]);r(this,"pre_update_callbacks",[]);r(this,"pre_render_callbacks",[]);r(this,"post_render_callbacks",[]);r(this,"pre_update_oneshot_callbacks",[]);r(this,"new_scripts",[]);r(this,"new_script_start",[]);r(this,"new_scripts_pre_setup_callbacks",[]);r(this,"new_scripts_post_setup_callbacks",[]);r(this,"new_scripts_xr",[]);r(this,"mainCameraComponent");r(this,"_camera",null);r(this,"application");r(this,"time");r(this,"input");r(this,"physics");r(this,"connection");r(this,"assets");r(this,"mainLight",null);r(this,"sceneLighting");r(this,"addressables");r(this,"lightmaps");r(this,"players");r(this,"_sizeChanged",!1);r(this,"_isCreated",!1);r(this,"_isCreating",!1);r(this,"_isVisible",!1);r(this,"_stats",GtA?new A9:null);r(this,"_intersectionObserver",null);r(this,"_disposeCallbacks",[]);r(this,"_originalCreationArgs");r(this,"onUnhandledRejection",A=>{this.domElement.dispatchEvent(new CustomEvent("error",{detail:A.reason}))});r(this,"_cameraStack",[]);r(this,"_onBeforeRenderListeners",new Map);r(this,"_onAfterRenderListeners",new Map);r(this,"_requireDepthTexture",!1);r(this,"_requireColorTexture",!1);r(this,"_renderTarget");r(this,"_isRendering",!1);r(this,"_createId",0);r(this,"_renderlooperrors",0);r(this,"_lastTimestamp",0);r(this,"_accumulatedTime",0);r(this,"_dispatchReadyAfterFrame",!1);r(this,"_wasPaused",!1);this.name=(A==null?void 0:A.name)||"",this.alias=A==null?void 0:A.alias,this.domElement=(A==null?void 0:A.domElement)||document.body,this.hash=A==null?void 0:A.hash,A!=null&&A.renderer&&(this.renderer=A.renderer,this.isManagedExternally=!0),(A==null?void 0:A.runInBackground)!==void 0&&(this.runInBackground=A.runInBackground),A!=null&&A.scene?this.scene=A.scene:this.scene=new EI,A!=null&&A.camera&&(this._camera=A.camera),this.application=new S_(this),this.time=new rO,this.input=new G_(this),this.physics=new IO(this),this.connection=new RH(this),this.assets=new LT,this.sceneLighting=new CO(this),this.addressables=new y_(this),this.lightmaps=new P9(this),this.players=new sO(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(g=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.disconnect()),this._intersectionObserver=new IntersectionObserver(g=>{this._isVisible=g[0].isIntersecting}),this._disposeCallbacks.push(()=>{var g;return(g=this._intersectionObserver)==null?void 0:g.disconnect()}),Nt.register(this)}static get DefaultTargetFrameRate(){return $t._defaultTargetFramerate.value}static set DefaultTargetFrameRate(A){$t._defaultTargetFramerate.value=A}static get DefaultWebGLRendererParameters(){return $t._defaultWebglRendererParameters}get version(){return wn}static get Current(){return Nt.Current}static set Current(A){Nt.Current=A}appendHTMLElement(A){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(A):this.domElement.appendChild(A)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(A){if(A!==this._resolutionScaleFactor&&typeof A=="number"){if(A<=0){console.error("Invalid resolution scale factor",A);return}this._resolutionScaleFactor=A,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var A,e;return((e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var A;return(A=this.xr)==null?void 0:A.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var A,e;return(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var A,e;return(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getCamera()}get arOverlayElement(){const A=this.domElement;return typeof A.getAROverlayContainer=="function"?A.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._camera)return this._camera;if(this.mainCameraComponent){const A=this.mainCameraComponent;return A.cam||A.buildCamera(),A.cam}return null}set mainCamera(A){this._camera=A}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(){var e,t,g;(e=this.renderer)==null||e.dispose()
|
|
4991
|
+
`,i);return}const e=(A==null?void 0:A.new_scripts)??ve.Current.new_scripts;e.includes(i)||e.push(i)}const $t=class{constructor(A){r(this,"name");r(this,"alias");r(this,"isManagedExternally",!1);r(this,"isPaused",!1);r(this,"runInBackground",!1);r(this,"targetFrameRate");r(this,"physicsSteps",1);r(this,"hash");r(this,"domElement");r(this,"_resolutionScaleFactor",1);r(this,"_boundingClientRectFrame",-1);r(this,"_boundingClientRect",null);r(this,"_domX");r(this,"_domY");r(this,"xr",null);r(this,"_xrFrame",null);r(this,"_currentFrameEvent",-1);r(this,"scene");r(this,"renderer");r(this,"composer",null);r(this,"scripts",[]);r(this,"scripts_pausedChanged",[]);r(this,"scripts_earlyUpdate",[]);r(this,"scripts_update",[]);r(this,"scripts_lateUpdate",[]);r(this,"scripts_onBeforeRender",[]);r(this,"scripts_onAfterRender",[]);r(this,"scripts_WithCorroutines",[]);r(this,"scripts_immersive_vr",[]);r(this,"scripts_immersive_ar",[]);r(this,"coroutines",{});r(this,"post_setup_callbacks",[]);r(this,"pre_update_callbacks",[]);r(this,"pre_render_callbacks",[]);r(this,"post_render_callbacks",[]);r(this,"pre_update_oneshot_callbacks",[]);r(this,"new_scripts",[]);r(this,"new_script_start",[]);r(this,"new_scripts_pre_setup_callbacks",[]);r(this,"new_scripts_post_setup_callbacks",[]);r(this,"new_scripts_xr",[]);r(this,"mainCameraComponent");r(this,"_camera",null);r(this,"application");r(this,"time");r(this,"input");r(this,"physics");r(this,"connection");r(this,"assets");r(this,"mainLight",null);r(this,"sceneLighting");r(this,"addressables");r(this,"lightmaps");r(this,"players");r(this,"_sizeChanged",!1);r(this,"_isCreated",!1);r(this,"_isCreating",!1);r(this,"_isVisible",!1);r(this,"_stats",GtA?new A9:null);r(this,"_intersectionObserver",null);r(this,"_disposeCallbacks",[]);r(this,"_originalCreationArgs");r(this,"onUnhandledRejection",A=>{this.domElement.dispatchEvent(new CustomEvent("error",{detail:A.reason}))});r(this,"_cameraStack",[]);r(this,"_onBeforeRenderListeners",new Map);r(this,"_onAfterRenderListeners",new Map);r(this,"_requireDepthTexture",!1);r(this,"_requireColorTexture",!1);r(this,"_renderTarget");r(this,"_isRendering",!1);r(this,"_createId",0);r(this,"_renderlooperrors",0);r(this,"_lastTimestamp",0);r(this,"_accumulatedTime",0);r(this,"_dispatchReadyAfterFrame",!1);r(this,"_wasPaused",!1);this.name=(A==null?void 0:A.name)||"",this.alias=A==null?void 0:A.alias,this.domElement=(A==null?void 0:A.domElement)||document.body,this.hash=A==null?void 0:A.hash,A!=null&&A.renderer&&(this.renderer=A.renderer,this.isManagedExternally=!0),(A==null?void 0:A.runInBackground)!==void 0&&(this.runInBackground=A.runInBackground),A!=null&&A.scene?this.scene=A.scene:this.scene=new EI,A!=null&&A.camera&&(this._camera=A.camera),this.application=new S_(this),this.time=new rO,this.input=new G_(this),this.physics=new IO(this),this.connection=new RH(this),this.assets=new LT,this.sceneLighting=new CO(this),this.addressables=new y_(this),this.lightmaps=new P9(this),this.players=new sO(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(g=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.disconnect()),this._intersectionObserver=new IntersectionObserver(g=>{this._isVisible=g[0].isIntersecting}),this._disposeCallbacks.push(()=>{var g;return(g=this._intersectionObserver)==null?void 0:g.disconnect()}),Nt.register(this)}static get DefaultTargetFrameRate(){return $t._defaultTargetFramerate.value}static set DefaultTargetFrameRate(A){$t._defaultTargetFramerate.value=A}static get DefaultWebGLRendererParameters(){return $t._defaultWebglRendererParameters}get version(){return wn}static get Current(){return Nt.Current}static set Current(A){Nt.Current=A}appendHTMLElement(A){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(A):this.domElement.appendChild(A)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(A){if(A!==this._resolutionScaleFactor&&typeof A=="number"){if(A<=0){console.error("Invalid resolution scale factor",A);return}this._resolutionScaleFactor=A,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var A,e;return((e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var A;return(A=this.xr)==null?void 0:A.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var A,e;return(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var A,e;return(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getCamera()}get arOverlayElement(){const A=this.domElement;return typeof A.getAROverlayContainer=="function"?A.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._camera)return this._camera;if(this.mainCameraComponent){const A=this.mainCameraComponent;return A.cam||A.buildCamera(),A.cam}return null}set mainCamera(A){this._camera=A}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(A){var e,t,g;if((e=this.renderer)==null||e.dispose(),A={...$t.DefaultWebGLRendererParameters,...A},!A.canvas){const I=(g=(t=this.domElement)==null?void 0:t.shadowRoot)==null?void 0:g.querySelector("canvas");I&&(A.canvas=I,jI&&console.log("Using canvas from shadow root",I))}jI&&console.log("Using Renderer Parameters:",A,this.domElement),this.renderer=new VC(A),this.renderer.debug.checkShaderErrors=Ge()||oA("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=to,this.renderer.setClearColor(new yA("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=mR,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=We,this.renderer.useLegacyLights=!1,this.input.bindEvents()}internalOnUpdateVisible(){var A,e;(A=this._intersectionObserver)==null||A.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(A=!1){var e,t,g;if(A||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const I=this.resolutionScaleFactor,o=this.domWidth*I,s=this.domHeight*I,n=this.mainCamera;this.updateAspect(n),this.renderer.setSize(o,s,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((t=this.composer.setSize)==null||t.call(this.composer,o,s),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((g=this.composer.setPixelRatio)==null||g.call(this.composer,window.devicePixelRatio)))}}updateAspect(A,e,t){if(!A)return;e===void 0&&(e=this.domWidth),t===void 0&&(t=this.domHeight);const g=A.aspect;A.aspect=e/t,g!==A.aspect&&A.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(A){return this.create(A)}async create(A){try{this._isCreating=!0,A!==this._originalCreationArgs&&(this._originalCreationArgs=Vd(A)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(A);return this._isCreated=!0,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}clear(){var A,e,t,g;Nt.dispatchCallback(Xi.ContextClearing,this),Ts(this.scene,!0,!0),this.scene=new EI,(A=this.addressables)==null||A.dispose(),(e=this.lightmaps)==null||e.clear(),(g=(t=this.physics)==null?void 0:t.engine)==null||g.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),Nt.dispatchCallback(Xi.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var A,e;this.clear(),(A=this.renderer)==null||A.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(jI&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose();for(const t of this._disposeCallbacks)try{t()}catch(g){console.error("Error in on dispose callback:",g,t)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,Nt.dispatchCallback(Xi.ContextDestroyed,this),Nt.unregister(this),$t.Current===this&&($t.Current=null)}registerCoroutineUpdate(A,e,t){return typeof(e==null?void 0:e.next)!="function"?(console.error("Registered invalid coroutine function from "+A.name+`
|
|
4992
4992
|
Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
4993
4993
|
Start a coroutine from a component by calling "this.startCoroutine(myCoroutine())"`),e):(this.coroutines[t]||(this.coroutines[t]=[]),this.coroutines[t].push({comp:A,main:e}),e)}unregisterCoroutineUpdate(A,e){if(!this.coroutines[e])return;const t=this.coroutines[e].findIndex(g=>g.main===A);t>=0&&this.coroutines[e].splice(t,1)}stopAllCoroutinesFrom(A){for(const e in this.coroutines){const t=this.coroutines[e];for(let g=t.length-1;g>=0;g--)t[g].comp===A&&t.splice(g,1)}}setCurrentCamera(A){var g;if(!A)return;if(A.cam||A.buildCamera(),!A.cam){console.warn("Camera component is missing camera",A);return}const e=this._cameraStack.indexOf(A);e>=0&&this._cameraStack.splice(e,1),this._cameraStack.push(A),this.mainCameraComponent=A;const t=A.cam;t.isPerspectiveCamera&&this.updateAspect(t),(g=this.mainCameraComponent)==null||g.applyClearFlagsIfIsActiveCamera()}removeCamera(A){if(!A)return;const e=this._cameraStack.indexOf(A);if(e>=0&&this._cameraStack.splice(e,1),this.mainCameraComponent===A&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const t=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(t)}}addBeforeRenderListener(A,e){this._onBeforeRenderListeners.has(A.uuid)||(this._onBeforeRenderListeners.set(A.uuid,[]),A.onBeforeRender=this._createRenderCallbackWrapper(A,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(A.uuid).push(e)}removeBeforeRenderListener(A,e){if(this._onBeforeRenderListeners.has(A.uuid)){const t=this._onBeforeRenderListeners.get(A.uuid),g=t.indexOf(e);g>=0&&t.splice(g,1)}}addAfterRenderListener(A,e){var t;this._onAfterRenderListeners.has(A.uuid)||(this._onAfterRenderListeners.set(A.uuid,[]),A.onAfterRender=this._createRenderCallbackWrapper(A,this._onAfterRenderListeners)),(t=this._onAfterRenderListeners.get(A.uuid))==null||t.push(e)}removeAfterRenderListener(A,e){if(this._onAfterRenderListeners.has(A.uuid)){const t=this._onAfterRenderListeners.get(A.uuid),g=t.indexOf(e);g>=0&&t.splice(g,1)}}_createRenderCallbackWrapper(A,e){return(t,g,I,o,s,n)=>{const C=e.get(A.uuid);if(C)for(let a=0;a<C.length;a++){const B=C[a];B(t,g,I,o,s,n)}}}get isRendering(){return this._isRendering}setRequireDepth(A){this._requireDepthTexture=A}setRequireColor(A){this._requireColorTexture=A}get depthTexture(){var A;return((A=this._renderTarget)==null?void 0:A.depthTexture)||null}get opaqueColorTexture(){var A;return((A=this._renderTarget)==null?void 0:A.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const A=getComputedStyle(this.domElement);return A.visibility!=="hidden"&&A.display!=="none"&&A.opacity!=="0"}async internalOnCreate(A){var o,s,n,C,a;const e=++this._createId;jI&&console.log("Creating context",this.name,A),this.clear(),this.isManagedExternally===!1&&(this.createNewRenderer(),(o=this.renderer)==null||o.setAnimationLoop(null)),await os(1),$t.Current=this,await Nt.dispatchCallback(Xi.ContextCreationStart,this);let t=!0,g;try{$t.Current=this,A?g=await this.internalLoadInitialContent(e,A):g=[]}catch(B){console.error(B),t=!1}if(!t||e!==this._createId)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return jI&&console.warn("Context has no renderer (perhaps it was disconnected?",this.domElement.isConnected),!1;!this.isManagedExternally&&!this.domElement.shadowRoot&&this.domElement.prepend(this.renderer.domElement),$t.Current=this,$t.Current=this;for(let B=0;B<this.new_scripts.length;B++){const Q=this.new_scripts[B];if(Q.gameObject!==void 0&&Q.gameObject!==null){Q.gameObject.userData===void 0&&(Q.gameObject.userData={}),Q.gameObject.userData.components===void 0&&(Q.gameObject.userData.components=[]);const E=Q.gameObject.userData.components;E.includes(Q)||E.push(Q)}}if(this.post_setup_callbacks)for(let B=0;B<this.post_setup_callbacks.length;B++)$t.Current=this,await this.post_setup_callbacks[B](this);if(!this.mainCamera){$t.Current=this;let B=null;OB(this.scene,Q=>{const E=Q;if(E!=null&&E.isCamera){if(cl(E.gameObject),!E.activeAndEnabled)return;if(E.tag==="MainCamera")return B=E,!0;B=E}}),B?this.setCurrentCamera(B):!Nt.dispatchCallback(Xi.MissingCamera,this,{files:g})&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(this.input.bindEvents(),$t.Current=this,oy(this),this.physics.engine&&((s=this.physics.engine)==null||s.step(0),(n=this.physics.engine)==null||n.postStep()),!this.isManagedExternally&&this.composer&&this.mainCamera){const B=new Vw(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(B),this.composer.setSize(this.domWidth,this.domHeight)}this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(C=this.domElement.shadowRoot)==null||C.appendChild(this._stats.dom)),jI&&yy(this.scene,!0),this.targetFrameRate===void 0?(jI&&console.warn("No target framerate set, using default",$t.DefaultTargetFrameRate),this.targetFrameRate=$t._defaultTargetFramerate):jI&&console.log("Target framerate set to",this.targetFrameRate),this._dispatchReadyAfterFrame=!0;const I=Nt.dispatchCallback(Xi.ContextCreated,this,{files:g});return I&&("internalSetLoadingMessage"in this.domElement&&typeof this.domElement.internalSetLoadingMessage=="function"&&((a=this.domElement)==null||a.internalSetLoadingMessage("finish loading")),await I),Or(this,Xi.ContextCreated),jI&&console.log("Context Created...",this.renderer,this.renderer.domElement),this._isCreating=!1,this.isManagedExternally||this.restartRenderLoop(),I}async internalLoadInitialContent(A,e){var n,C;const t=new Array;if(e.files.length===0)return t;const g=[...e.files],I={name:"",progress:null,index:0,count:g.length},o=Ys(),s=0;for(let a=0;a<g.length;a++){if(A!==this._createId){jI&&console.log("Aborting loading because create id changed",A,this._createId);break}const B=g[a];if(!B.includes(".glb")&&!B.includes(".gltf")){const E=`Needle Engine: found suspicious src "${B}"`;console.warn(E),vI()&&fi(E)}(n=e==null?void 0:e.onLoadingStart)==null||n.call(this,a,B),jI&&console.log("Context Load "+B);const Q=await o.loadSync(this,B,B,s,E=>{var c;I.name=B,I.progress=E,I.index=a,I.count=g.length,(c=e.onLoadingProgress)==null||c.call(this,I)});(C=e==null?void 0:e.onLoadingFinished)==null||C.call(this,a,B,Q??null),Q?t.push({src:B,file:Q}):console.warn("Could not load file: "+B)}if(A!==this._createId){for(const a of t)if(a&&a.file)for(const B of a.file.scenes)Ts(B,!0,!0)}else for(const a of t)a&&a.file&&this.scene.add(a.file.scene);return t}restartRenderLoop(){return this.renderer?this._isCreating?(console.warn("Can not start render loop while creating context"),!1):(this.renderer.setAnimationLoop((A,e)=>{this.isManagedExternally||this.update(A,e)}),!0):(console.error("Can not start render loop without renderer"),!1)}update(A,e){if(e===void 0&&(e=null),Ge()||jI||TZ())try{this.internalStep(A,e),this._renderlooperrors=0}catch(t){this._renderlooperrors+=1,(Ge()||jI)&&(t instanceof Error||t instanceof TypeError)&&Ui("Caught unhandled exception during render-loop - see console for details.",ss.Error),console.error("Frame #"+this.time.frame+`
|
|
4994
|
-
`,t),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}else this.internalStep(A,e)}updatePhysics(A){this.internalUpdatePhysics(A)}internalStep(A,e){this.internalOnBeforeRender(A,e)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(A,e){var g;const t=e!==null&&this._xrFrame===null;if(this._xrFrame=e,t&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:e}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=A),this._accumulatedTime+=(A-this._lastTimestamp)/1e3,this._lastTimestamp=A;let I=this.targetFrameRate;if(typeof I=="object"&&(I=I.value),this._accumulatedTime<1/(I+1))return!1;this._accumulatedTime=0}if((g=this._stats)==null||g.begin(),$t.Current=this,this.onHandlePaused())return!1;for($t.Current=this,this.time.update(),RtA&&console.log("FPS",this.time.smoothedFps.toFixed(0)),oy(this),oD(this.scene),jT(this),Or(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const I=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(I)}if(this.pre_update_oneshot_callbacks){for(const I in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[I]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const I in this.pre_update_callbacks)this.pre_update_callbacks[I]();this._currentFrameEvent=0;for(let I=0;I<this.scripts_earlyUpdate.length;I++){const o=this.scripts_earlyUpdate[I];o.activeAndEnabled&&o.earlyUpdate!==void 0&&($t.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),Or(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let I=0;I<this.scripts_update.length;I++){const o=this.scripts_update[I];o.activeAndEnabled&&o.update!==void 0&&($t.Current=this,o.update())}if(this.executeCoroutines(1),Or(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let I=0;I<this.scripts_lateUpdate.length;I++){const o=this.scripts_lateUpdate[I];o.activeAndEnabled&&o.lateUpdate!==void 0&&($t.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),Or(this,2),this.onHandlePaused()||(this.physicsSteps===void 0&&(this.physicsSteps=1),this.physics.engine&&this.physicsSteps>0&&this.internalUpdatePhysics(this.physicsSteps),this.onHandlePaused()))return!1;if(this.isVisibleToUser||this.runInBackground){this._currentFrameEvent=3;for(let I=0;I<this.scripts_onBeforeRender.length;I++){const o=this.scripts_onBeforeRender[I];o.activeAndEnabled&&o.onBeforeRender!==void 0&&($t.Current=this,o.onBeforeRender(e))}if(this.executeCoroutines(3),Or(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const I in this.pre_render_callbacks)this.pre_render_callbacks[I](e)}return!0}internalUpdatePhysics(A){if(!this.physics.engine)return!1;const e=A,t=this.time.deltaTime/e;for(let g=0;g<e;g++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(t),this._currentFrameEvent=10,this.executeCoroutines(10);return this.physics.engine.postStep(),!0}internalOnRender(){this.isManagedExternally||(OZ(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let A=0;A<this.scripts_onAfterRender.length;A++){const e=this.scripts_onAfterRender[A];e.activeAndEnabled&&e.onAfterRender!==void 0&&($t.Current=this,e.onAfterRender())}if(this.executeCoroutines(4),Or(this,4),this.post_render_callbacks)for(const A in this.post_render_callbacks)this.post_render_callbacks[A]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log({...this.renderer.info.memory},{...this.renderer.info.render})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),Nt.dispatchCallback(Xi.ContextFirstFrameRendered,this))}renderNow(A){return!A&&(A=this.mainCamera,!A)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):A&&this.renderer.render(this.scene,A),this._isRendering=!1,!0)}onHandlePaused(){const A=this.evaluatePaused();if(this._wasPaused!==A){MtA&&console.log("Paused?",A,"context:"+this.alias);for(let e=0;e<this.scripts_pausedChanged.length;e++){const t=this.scripts_pausedChanged[e];t.activeAndEnabled&&t.onPausedChanged!==void 0&&($t.Current=this,t.onPausedChanged(A,this._wasPaused))}}return this._wasPaused=A,A}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new gt(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new Ec(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new He,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Pe,this._renderTarget.texture.magFilter=Pe,this._renderTarget.texture.format=Mt)}const A=this._renderTarget;A.texture&&(A.texture.colorSpace=this.renderer.outputColorSpace);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(A),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(A){var t;if(this.coroutines[A]){const g=this.coroutines[A];for(let I=0;I<g.length;I++)try{const o=g[I];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){UtA&&console.log("Removing coroutine",o.comp,o.comp.enabled),g.splice(I,1),--I;continue}const n=o.chained;if(n&&n.length>0){const Q=n[n.length-1].next();if(Q.done&&n.pop(),e(Q)&&(o.chained||(o.chained=[]),o.chained.push(Q.value)),!Q.done)continue}const C=o.main.next();if(C.done===!0){g.splice(I,1),--I;continue}const a=C.value;if(e(a)){if(a.next().done)continue;o.chained||(o.chained=[]),o.chained.push(a)}else if(a instanceof Promise){const B=a;o.chained||(o.chained=[]);const Q=k_(B);(t=o.chained)==null||t.push(Q);continue}}catch(o){console.error(o)}}function e(g){return!!(g&&g.next&&g.return)}}};let ve=$t;r(ve,"_defaultTargetFramerate",{value:60}),r(ve,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1});Nt.registerCallback(Xi.ContextCreated,i=>{const A=i.context;lO(A),cO(A)});const ky=oA("debugcomponents"),aq="eff8ba80-635d-11ec-90d6-0242ac120003";class mg{constructor(A){r(this,"_originalSeed");r(this,"_seed");typeof A=="string"&&(A=mg.hash(A)),this._originalSeed=A,this._seed=A}get seed(){return this._seed}set seed(A){this._seed=A}reset(){this._seed=this._originalSeed}generateUUID(A){if(typeof A=="string")return _v(A,aq);const e=this._seed;return this._seed-=1,_v(e.toString(),aq)}initialize(A){typeof A=="string"?this._seed=mg.hash(A):this._seed=A}static createFromString(A){return new mg(this.hash(A))}static hash(A){let e=0;for(let t=0;t<A.length;t++)e=A.charCodeAt(t)+((e<<5)-e);return e}}var BO=(i=>(i.NewInstanceCreated="new-instance-created",i.InstanceDestroyed="instance-destroyed",i))(BO||{});class QO{constructor(A){r(this,"guid");this.guid=A}}function CS(i,A,e=!0){if(!i)return;const t=i;if(Ts(i,e),!A){console.warn("Can not send destroy: No networking connection provided",i.guid);return}if(!A.isConnected){console.warn("Can not send destroy: not connected",i.guid);return}let g=i.guid;if(!g&&t.uuid&&(g=t.uuid),!g){console.warn("Can not send destroy: failed to find guid",i);return}const I=new QO(g);A.send("instance-destroyed",I,Fs.Queued)}function EO(i,A){const e=new QO(i);A.send("instance-destroyed",e,Fs.Queued)}function cO(i){i.connection.beginListen("instance-destroyed",A=>{ky&&console.log("[Remote] Destroyed",i.scene,A);const e=ru(A.guid,i.scene);e&&Ts(e)})}class KtA{constructor(A,e,t){r(this,"filename");r(this,"hash");r(this,"size");this.filename=A,this.hash=e,this.size=t}}class hO{constructor(A,e){r(this,"guid");r(this,"originalGuid");r(this,"seed");r(this,"visible");r(this,"hostData");r(this,"dontSave");r(this,"parent");r(this,"position");r(this,"rotation");r(this,"scale");r(this,"preventCreation");this.originalGuid=A,this.guid=e}}function xN(i,A,e,t){var n;const g=i;if(!g.guid)return console.warn("Can not instantiate: No guid",g),null;if(A.context||(A.context=ve.Current),!A.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const I=A?{...A}:null,{instance:o,seed:s}=JtA(g,A);if(o){const C=o;if(C.guid){ky&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const a=new hO(g.guid,C.guid);a.seed=s,I&&(I.position&&(a.position={x:I.position.x,y:I.position.y,z:I.position.z}),I.rotation&&(a.rotation={x:I.rotation.x,y:I.rotation.y,z:I.rotation.z,w:I.rotation.w}),I.scale&&(a.scale={x:I.scale.x,y:I.scale.y,z:I.scale.z})),a.position||(a.position={x:C.position.x,y:C.position.y,z:C.position.z}),a.rotation||(a.rotation={x:C.quaternion.x,y:C.quaternion.y,z:C.quaternion.z,w:C.quaternion.w}),a.scale||(a.scale={x:C.scale.x,y:C.scale.y,z:C.scale.z}),a.visible=g.visible,I!=null&&I.parent&&(typeof I.parent=="string"?a.parent=I.parent:a.parent=I.parent.guid),a.hostData=e,t===!1&&(a.dontSave=!0),(n=A==null?void 0:A.context)==null||n.connection.send("new-instance-created",a)}else console.warn("Missing guid, can not send new instance event",C)}return o}function aS(){return Math.random()*9999999}function lO(i){i.connection.beginListen("new-instance-created",async A=>{const e=await vtA(A.originalGuid,i.scene);if(A.preventCreation===!0)return;if(!e){console.warn("could not find object that was instantiated: "+A.guid);return}const t=new Vs;A.position&&(t.position=new y(A.position.x,A.position.y,A.position.z)),A.rotation&&(t.rotation=new RA(A.rotation.x,A.rotation.y,A.rotation.z,A.rotation.w)),A.scale&&(t.scale=new y(A.scale.x,A.scale.y,A.scale.z)),t.parent=A.parent,A.seed&&(t.idProvider=new mg(A.seed)),t.visible=A.visible,t.context=i,ky&&i.alias&&console.log("[Remote] instantiate in: "+i.alias);const g=Gc(e,t);g&&(A.parent==="scene"&&i.scene.add(g),ky&&console.log("[Remote] new instance","gameobject:",g==null?void 0:g.guid,e))})}function JtA(i,A){const e=aS(),t=A??new Vs;t.idProvider=new mg(e);const g=Gc(i,t);return{seed:e,instance:g}}const dO={};function uO(i,A){dO[i]=A}async function vtA(i,A){const e=dO[i];if(e!=null){const t=await e(i);if(t)return t}return pO(i,A)}function pO(i,A){if(A===null||!i)return null;if(A.guid===i)return A;if(A.children)for(const e of A.children){const t=pO(i,e);if(t)return t}return null}const hD=oA("debuggetcomponent"),lD=oA("debuginstantiate");var fO=(i=>(i[i.None=0]="None",i[i.HideInHierarchy=1]="HideInHierarchy",i[i.HideInInspector=2]="HideInInspector",i[i.DontSaveInEditor=4]="DontSaveInEditor",i[i.NotEditable=8]="NotEditable",i[i.DontSaveInBuild=16]="DontSaveInBuild",i[i.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",i[i.DontSave=52]="DontSave",i[i.HideAndDontSave=61]="HideAndDontSave",i))(fO||{});class Vs{constructor(){r(this,"idProvider");r(this,"parent");r(this,"keepWorldPosition");r(this,"position");r(this,"rotation");r(this,"scale");r(this,"visible");r(this,"context")}clone(){var e,t,g;const A=new Vs;return A.idProvider=this.idProvider,A.parent=this.parent,A.keepWorldPosition=this.keepWorldPosition,A.position=(e=this.position)==null?void 0:e.clone(),A.rotation=(t=this.rotation)==null?void 0:t.clone(),A.scale=(g=this.scale)==null?void 0:g.clone(),A}cloneAssign(A){var e,t,g;this.idProvider=A.idProvider,this.parent=A.parent,this.keepWorldPosition=A.keepWorldPosition,this.position=(e=A.position)==null?void 0:e.clone(),this.rotation=(t=A.rotation)==null?void 0:t.clone(),this.scale=(g=A.scale)==null?void 0:g.clone()}}function kc(i){return i.visible}function Dl(i,A){return typeof A=="number"&&(A=A>.5),i.visible=A,i.visible}function DO(i){return i[KC]||rS(i)}function yO(i,A){i[PT]=A}function rS(i){return Ls.isUsingInstancing(i)}function ru(i,A){return VE(i,A,!0,!0)}const wO=Symbol("isDestroyed");function HB(i){return i[wO]}function SO(i,A){i[wO]=A}const vM=Symbol("isDontDestroy");function bM(i,A=!0){i[vM]=A}const dD=[],uD=[];function Ts(i,A=!0,e=!1){dD.length=0,uD.length=0,qM(i,A,e,!0);for(const t of dD)t.gameObject=null,t.context=null;for(const t of uD)SO(t,!0),e&&Wt(t),HT(t);uD.length=0,dD.length=0}function qM(i,A=!0,e=!1,t=!0){if(i==null)return;const g=i;if(g.isComponent){if(g[vM])return;dD.push(g);const s=g.gameObject;g.__internalDisable(),g.__internalDestroy(),g.gameObject=s;return}if(i[vM])return;const I=i;hD&&console.log(I),uD.push(I);const o=I.userData.components;if(o){let s=o.length;for(let n=0;n<o.length;n++){const C=o[n];qM(C,A,e,!1),o.length<s&&(s=o.length,n--)}}if(A&&I.children)for(const s of I.children)qM(s,A,e,!1);t&&I.removeFromParent()}function OB(i,A,e=!0){return mO(i,A,e)}function*YN(i,A,e=!1,t=999,g=0){if(i!=null&&i.userData.components&&!(g>t)){for(const I of i.userData.components)A&&(I==null?void 0:I.isComponent)===!0&&I instanceof A?yield I:yield I;if(e===!0)for(const I of i.children)yield*YN(I,A,!0,t,g+1)}}function mO(i,A,e,t=0){var g;if(i){if(i.isObject3D,t>1e3){console.warn("Failed to iterate components: too many levels");return}if((g=i.userData)!=null&&g.components)for(let I=0;I<i.userData.components.length;I++){const o=i.userData.components[I];if((o==null?void 0:o.isComponent)===!0){const s=A(o);if(s!==void 0)return s}}if(e&&i.children){const I=t+1;for(let o=0;o<i.children.length;o++){const s=i.children[o];if(!s)continue;const n=mO(s,A,e,I);if(n!==void 0)return n}}}}function Gc(i,A=null){let e=null;A!==null&&(A.x!==void 0?(e=new Vs,e.position=A):e=A);let t=ve.Current;e!=null&&e.context&&(t=e.context),hD&&t.alias&&console.log("context",t.alias),e&&!e.idProvider&&(e.idProvider=new mg(Date.now()));const g=[],I={},o={},s=kO(t,i,e,g,I,o);s&&(qtA(I),btA(o,I)),hD&&(yy(i,!0),yy(s,!0));const n={};for(const C in g){const a=g[C],B=a.guid;e&&e.idProvider&&(a.guid=e.idProvider.generateUUID(),n[B]=a.guid,hD&&console.log(a.name,a.guid)),nS(a,t),a.__internalNewInstanceCreated&&a.__internalNewInstanceCreated()}for(const C in g){const a=g[C];a.resolveGuids&&a.resolveGuids(n),a.enabled!==!1&&(a.enabled=!0)}return oy(t),s}function kO(i,A,e,t,g,I){var a;if(!A)return null;const o=A.userData;A.userData={};const s=A.children;A.children=[];const n=A.clone(!1);if(BS(n),A.userData=o,A.children=s,g[A.uuid]={original:A,clone:n},lD&&console.log("ADD",A,n),A.type==="SkinnedMesh"&&(I[A.uuid]={original:A,clone:n}),(e==null?void 0:e.visible)!==void 0&&(n.visible=e.visible),e!=null&&e.idProvider){n.uuid=e.idProvider.generateUUID();const B=n;B&&(B.guid=n.uuid)}A.animations&&A.animations.length>0&&(n.animations=[...A.animations]);const C=A.parent;if(C&&C.add(n),e!=null&&e.position?QI(n,e.position):n.position.copy(A.position),e!=null&&e.rotation?rs(n,e.rotation):n.quaternion.copy(A.quaternion),e!=null&&e.scale?n.scale.copy(e.scale):n.scale.copy(A.scale),e!=null&&e.parent&&e.parent!=="scene"){let B=null;if(typeof e.parent=="string"?B=VE(e.parent,i.scene,!0):B=e.parent,B){const Q=e.keepWorldPosition===!0?B.attach:B.add;Q?Q.call(B,n):console.error("Invalid parent object",B,"received when instantiating:",A)}else console.warn("could not find parent:",e.parent)}for(const[B,Q]of Object.entries(A.userData))B!=="components"&&(n.userData[B]=Q);if((a=A.userData)!=null&&a.components){const B=A.userData.components,Q=[];n.userData.components=Q;for(let E=0;E<B.length;E++){const c=B[E],h=new c.constructor;zE(h,c),c[El]!==void 0&&(h[El]=c[El]),Q.push(h),h.gameObject=n,t.push(h),Xd.dispatchComponentLifecycleEvent(Zd.Added,h)}}e&&(e.position=void 0,e.rotation=void 0,e.scale=void 0,e.parent=void 0);for(const B in A.children){const Q=A.children[B],E=kO(i,Q,e,t,g,I);E&&n.add(E)}return n}function btA(i,A){for(const e in i){const t=i[e],g=t.original,I=g.skeleton,o=t.clone;if(!I){console.warn("Skinned mesh has no skeleton?",t);continue}const s=I.bones,n=o.skeleton.clone();o.skeleton=n,o.bindMatrix.clone().copy(g.bindMatrix),o.bindMatrixInverse.copy(g.bindMatrixInverse);const C=[];n.bones=C;for(let a=0;a<s.length;a++){const B=s[a],E=A[B.uuid].clone;C.push(E)}}for(const e in i){const t=i[e].clone;t.skeleton.update(),t.bind(t.skeleton,t.bindMatrix),t.updateMatrixWorld(!0)}}function qtA(i){var A;for(const e in i){const g=i[e].clone;if((A=g.userData)!=null&&A.components)for(let I=0;I<g.userData.components.length;I++){const o=g.userData.components[I],s=Object.entries(o);for(const[n,C]of s)if(Array.isArray(C)){const a=[];o[n]=a;for(let B=0;B<C.length;B++){const Q=C[B];if(typeof Q!="object"){a.push(Q);continue}const E=rq(o,n,Q,i);E!==void 0?a.push(E):a.push(Q)}}else if(typeof C=="object"){const a=rq(o,n,C,i);a!==void 0&&(o[n]=a)}}}}function rq(i,A,e,t){var g,I;if(e!=null)if(e.isComponent===!0){const o=e.gameObject;if(o){const s=o.uuid,n=(g=t[s])==null?void 0:g.clone;if(!n){lD&&console.log("reference did not change",A,i,e);return}const C=o.userData.components.indexOf(e);if(C>=0)return lD&&console.log(A,s),n.userData.components[C];console.warn("could not find component",A,e)}}else if(e.isObject3D===!0){if(A==="gameObject")return;const o=e;if(o){const s=o.uuid,n=(I=t[s])==null?void 0:I.clone;if(n)return lD&&console.log(A,"old",e,"new",n),n}}else{if(e.isVector4||e.isVector3||e.isVector2||e.isQuaternion||e.isEuler)return e.clone();if(e.isColor===!0)return e.clone();if(e.isEventList===!0)return new e.constructor}}const GO=new Map;function LtA(i,A){if(!i)return;if(!A){console.warn("No prototype found",i,i.prototype,i.constructor);return}const e=GO.get(A);e&&e.apply(i)}function xtA(i){const A=YtA(i.prototype);GO.set(i,A)}function YtA(i){return new TtA(i)}class TtA{constructor(A){r(this,"$symbol");r(this,"extensions");r(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(A),this.descriptors=new Array;for(let e=0;e<this.extensions.length;e++){const t=this.extensions[e],g=Object.getOwnPropertyDescriptor(A,t);g&&this.descriptors.push(g)}}apply(A){if(!A[this.$symbol]){A[this.$symbol]=!0;for(let e=0;e<this.extensions.length;e++){const t=this.extensions[e],g=this.descriptors[e];g&&Object.defineProperty(A,t,g)}}}}function BS(i){i&&i.isObject3D===!0&&LtA(i,pA)}pA.prototype.SetActive=function(i){this.visible=i};pA.prototype.setActive=function(i){this.visible=i};pA.prototype.destroy=function(){Ts(this)};pA.prototype.addComponent=function(i){return _N(this,i)};pA.prototype.addNewComponent=function(i){return dr(this,new i)};pA.prototype.removeComponent=function(i){return TN(this,i)};pA.prototype.getOrAddComponent=function(i){return QS(this,i)};pA.prototype.getComponent=function(i){return Mc(this,i)};pA.prototype.getComponents=function(i,A){return Bu(this,i,A)};pA.prototype.getComponentInChildren=function(i){return Qu(this,i)};pA.prototype.getComponentsInChildren=function(i,A){return Eu(this,i,A)};pA.prototype.getComponentInParent=function(i){return Qd(this,i)};pA.prototype.getComponentsInParent=function(i,A){return ES(this,i,A)};Object.getOwnPropertyDescriptor(pA.prototype,"activeSelf")||Object.defineProperty(pA.prototype,"activeSelf",{get:function(){return kc(this)},set:function(i){Dl(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"transform")||Object.defineProperty(pA.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(pA.prototype,"worldPosition")||Object.defineProperty(pA.prototype,"worldPosition",{get:function(){return this instanceof kU?Je(this.object):Je(this)},set:function(i){QI(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldQuaternion")||Object.defineProperty(pA.prototype,"worldQuaternion",{get:function(){return this instanceof kU?qt(this.object):qt(this)},set:function(i){rs(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldRotation")||Object.defineProperty(pA.prototype,"worldRotation",{get:function(){return nu(this)},set:function(i){bN(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldScale")||Object.defineProperty(pA.prototype,"worldScale",{get:function(){return li(this)},set:function(i){Bd(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldForward")||Object.defineProperty(pA.prototype,"worldForward",{get:function(){return Zi().set(0,0,1).applyQuaternion(qt(this))}});Object.getOwnPropertyDescriptor(pA.prototype,"worldRight")||Object.defineProperty(pA.prototype,"worldRight",{get:function(){return Zi().set(1,0,0).applyQuaternion(qt(this))}});Object.getOwnPropertyDescriptor(pA.prototype,"worldUp")||Object.defineProperty(pA.prototype,"worldUp",{get:function(){return Zi().set(0,1,0).applyQuaternion(qt(this))}});xtA(pA);const zm=oA("debuggetcomponent");function _tA(i){return i==null||i.isObject3D?i:i.object&&i.object.isObject3D?i.object:i}function TN(i,A){if(!i||!i.userData.components)return;const e=i.userData.components.indexOf(A);e<0||(Xd.dispatchComponentLifecycleEvent(Zd.Removing,A),A.gameObject=null,i.userData.components.splice(e,1))}function QS(i,A){const e=Mc(i,A);if(e)return e;const t=new A;return dr(i,t)}const MO=new mg("addComponentIdProvider");function dr(i,A,e=!0){i.userData||(i.userData={}),i.userData.components||(i.userData.components=[]),i.userData.components.push(A),A.gameObject=i,(A.guid===void 0||A.guid==="invalid")&&(A.guid=MO.generateUUID()),BS(i),nS(A);try{e&&A.__internalAwake&&(cl(i),A.activeAndEnabled&&A.__internalAwake()),Xd.dispatchComponentLifecycleEvent(Zd.Added,A)}catch(t){console.error(t)}return A}function _N(i,A){if(typeof A=="function")return dr(i,new A);if(A.destroyed)return console.warn("Can not move/add a destroyed component",A),A;if(A.gameObject===i)return A;if(A.gameObject&&A.gameObject.userData.components){const e=A.gameObject.userData.components.indexOf(A);A.gameObject.userData.components.splice(e,1)}if(!i.userData.components)i.userData.components=[];else if(i.userData.components.includes(A))return A;return i.userData.components.push(A),A.gameObject=i,(A.guid===void 0||A.guid==="invalid")&&(A.guid=MO.generateUUID()),nS(A),A}function RO(i){if(i.gameObject&&i.gameObject.userData.components){const A=i.gameObject.userData.components.indexOf(i);i.gameObject.userData.components.splice(A,1)}i.__internalDisable&&i.__internalDisable(),pC(i,i.context??ve.Current),i.destroy(),i.gameObject=null}let Bq=!1;function UO(i,A,e){var t;if(i==null)return null;if(!i.isObject3D)return console.error("Object is not object3D"),null;if(!((t=i==null?void 0:i.userData)!=null&&t.components)||(typeof A=="string"&&(Bq||(Bq=!0,console.warn(`Accessing components by name is not supported.
|
|
4994
|
+
`,t),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}else this.internalStep(A,e)}updatePhysics(A){this.internalUpdatePhysics(A)}internalStep(A,e){this.internalOnBeforeRender(A,e)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(A,e){var g;const t=e!==null&&this._xrFrame===null;if(this._xrFrame=e,t&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:e}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=A),this._accumulatedTime+=(A-this._lastTimestamp)/1e3,this._lastTimestamp=A;let I=this.targetFrameRate;if(typeof I=="object"&&(I=I.value),this._accumulatedTime<1/(I+1))return!1;this._accumulatedTime=0}if((g=this._stats)==null||g.begin(),$t.Current=this,this.onHandlePaused())return!1;for($t.Current=this,this.time.update(),RtA&&console.log("FPS",this.time.smoothedFps.toFixed(0)),oy(this),oD(this.scene),jT(this),Or(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const I=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(I)}if(this.pre_update_oneshot_callbacks){for(const I in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[I]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const I in this.pre_update_callbacks)this.pre_update_callbacks[I]();this._currentFrameEvent=0;for(let I=0;I<this.scripts_earlyUpdate.length;I++){const o=this.scripts_earlyUpdate[I];o.activeAndEnabled&&o.earlyUpdate!==void 0&&($t.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),Or(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let I=0;I<this.scripts_update.length;I++){const o=this.scripts_update[I];o.activeAndEnabled&&o.update!==void 0&&($t.Current=this,o.update())}if(this.executeCoroutines(1),Or(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let I=0;I<this.scripts_lateUpdate.length;I++){const o=this.scripts_lateUpdate[I];o.activeAndEnabled&&o.lateUpdate!==void 0&&($t.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),Or(this,2),this.onHandlePaused()||(this.physicsSteps===void 0&&(this.physicsSteps=1),this.physics.engine&&this.physicsSteps>0&&this.internalUpdatePhysics(this.physicsSteps),this.onHandlePaused()))return!1;if(this.isVisibleToUser||this.runInBackground){this._currentFrameEvent=3;for(let I=0;I<this.scripts_onBeforeRender.length;I++){const o=this.scripts_onBeforeRender[I];o.activeAndEnabled&&o.onBeforeRender!==void 0&&($t.Current=this,o.onBeforeRender(e))}if(this.executeCoroutines(3),Or(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const I in this.pre_render_callbacks)this.pre_render_callbacks[I](e)}return!0}internalUpdatePhysics(A){if(!this.physics.engine)return!1;const e=A,t=this.time.deltaTime/e;for(let g=0;g<e;g++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(t),this._currentFrameEvent=10,this.executeCoroutines(10);return this.physics.engine.postStep(),!0}internalOnRender(){this.isManagedExternally||(OZ(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let A=0;A<this.scripts_onAfterRender.length;A++){const e=this.scripts_onAfterRender[A];e.activeAndEnabled&&e.onAfterRender!==void 0&&($t.Current=this,e.onAfterRender())}if(this.executeCoroutines(4),Or(this,4),this.post_render_callbacks)for(const A in this.post_render_callbacks)this.post_render_callbacks[A]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log(this.renderer.info.render.calls+" DrawCalls",`
|
|
4995
|
+
Render:`,{...this.renderer.info.render},`
|
|
4996
|
+
Memory:`,{...this.renderer.info.memory})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),Nt.dispatchCallback(Xi.ContextFirstFrameRendered,this))}renderNow(A){return!A&&(A=this.mainCamera,!A)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):A&&this.renderer.render(this.scene,A),this._isRendering=!1,!0)}onHandlePaused(){const A=this.evaluatePaused();if(this._wasPaused!==A){MtA&&console.log("Paused?",A,"context:"+this.alias);for(let e=0;e<this.scripts_pausedChanged.length;e++){const t=this.scripts_pausedChanged[e];t.activeAndEnabled&&t.onPausedChanged!==void 0&&($t.Current=this,t.onPausedChanged(A,this._wasPaused))}}return this._wasPaused=A,A}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new gt(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new Ec(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new He,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Pe,this._renderTarget.texture.magFilter=Pe,this._renderTarget.texture.format=Mt)}const A=this._renderTarget;A.texture&&(A.texture.colorSpace=this.renderer.outputColorSpace);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(A),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(A){var t;if(this.coroutines[A]){const g=this.coroutines[A];for(let I=0;I<g.length;I++)try{const o=g[I];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){UtA&&console.log("Removing coroutine",o.comp,o.comp.enabled),g.splice(I,1),--I;continue}const n=o.chained;if(n&&n.length>0){const Q=n[n.length-1].next();if(Q.done&&n.pop(),e(Q)&&(o.chained||(o.chained=[]),o.chained.push(Q.value)),!Q.done)continue}const C=o.main.next();if(C.done===!0){g.splice(I,1),--I;continue}const a=C.value;if(e(a)){if(a.next().done)continue;o.chained||(o.chained=[]),o.chained.push(a)}else if(a instanceof Promise){const B=a;o.chained||(o.chained=[]);const Q=k_(B);(t=o.chained)==null||t.push(Q);continue}}catch(o){console.error(o)}}function e(g){return!!(g&&g.next&&g.return)}}};let ve=$t;r(ve,"_defaultTargetFramerate",{value:60}),r(ve,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1});Nt.registerCallback(Xi.ContextCreated,i=>{const A=i.context;lO(A),cO(A)});const ky=oA("debugcomponents"),aq="eff8ba80-635d-11ec-90d6-0242ac120003";class mg{constructor(A){r(this,"_originalSeed");r(this,"_seed");typeof A=="string"&&(A=mg.hash(A)),this._originalSeed=A,this._seed=A}get seed(){return this._seed}set seed(A){this._seed=A}reset(){this._seed=this._originalSeed}generateUUID(A){if(typeof A=="string")return _v(A,aq);const e=this._seed;return this._seed-=1,_v(e.toString(),aq)}initialize(A){typeof A=="string"?this._seed=mg.hash(A):this._seed=A}static createFromString(A){return new mg(this.hash(A))}static hash(A){let e=0;for(let t=0;t<A.length;t++)e=A.charCodeAt(t)+((e<<5)-e);return e}}var BO=(i=>(i.NewInstanceCreated="new-instance-created",i.InstanceDestroyed="instance-destroyed",i))(BO||{});class QO{constructor(A){r(this,"guid");this.guid=A}}function CS(i,A,e=!0){if(!i)return;const t=i;if(Ts(i,e),!A){console.warn("Can not send destroy: No networking connection provided",i.guid);return}if(!A.isConnected){console.warn("Can not send destroy: not connected",i.guid);return}let g=i.guid;if(!g&&t.uuid&&(g=t.uuid),!g){console.warn("Can not send destroy: failed to find guid",i);return}const I=new QO(g);A.send("instance-destroyed",I,Fs.Queued)}function EO(i,A){const e=new QO(i);A.send("instance-destroyed",e,Fs.Queued)}function cO(i){i.connection.beginListen("instance-destroyed",A=>{ky&&console.log("[Remote] Destroyed",i.scene,A);const e=ru(A.guid,i.scene);e&&Ts(e)})}class KtA{constructor(A,e,t){r(this,"filename");r(this,"hash");r(this,"size");this.filename=A,this.hash=e,this.size=t}}class hO{constructor(A,e){r(this,"guid");r(this,"originalGuid");r(this,"seed");r(this,"visible");r(this,"hostData");r(this,"dontSave");r(this,"parent");r(this,"position");r(this,"rotation");r(this,"scale");r(this,"preventCreation");this.originalGuid=A,this.guid=e}}function xN(i,A,e,t){var n;const g=i;if(!g.guid)return console.warn("Can not instantiate: No guid",g),null;if(A.context||(A.context=ve.Current),!A.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const I=A?{...A}:null,{instance:o,seed:s}=JtA(g,A);if(o){const C=o;if(C.guid){ky&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const a=new hO(g.guid,C.guid);a.seed=s,I&&(I.position&&(a.position={x:I.position.x,y:I.position.y,z:I.position.z}),I.rotation&&(a.rotation={x:I.rotation.x,y:I.rotation.y,z:I.rotation.z,w:I.rotation.w}),I.scale&&(a.scale={x:I.scale.x,y:I.scale.y,z:I.scale.z})),a.position||(a.position={x:C.position.x,y:C.position.y,z:C.position.z}),a.rotation||(a.rotation={x:C.quaternion.x,y:C.quaternion.y,z:C.quaternion.z,w:C.quaternion.w}),a.scale||(a.scale={x:C.scale.x,y:C.scale.y,z:C.scale.z}),a.visible=g.visible,I!=null&&I.parent&&(typeof I.parent=="string"?a.parent=I.parent:a.parent=I.parent.guid),a.hostData=e,t===!1&&(a.dontSave=!0),(n=A==null?void 0:A.context)==null||n.connection.send("new-instance-created",a)}else console.warn("Missing guid, can not send new instance event",C)}return o}function aS(){return Math.random()*9999999}function lO(i){i.connection.beginListen("new-instance-created",async A=>{const e=await vtA(A.originalGuid,i.scene);if(A.preventCreation===!0)return;if(!e){console.warn("could not find object that was instantiated: "+A.guid);return}const t=new Vs;A.position&&(t.position=new y(A.position.x,A.position.y,A.position.z)),A.rotation&&(t.rotation=new RA(A.rotation.x,A.rotation.y,A.rotation.z,A.rotation.w)),A.scale&&(t.scale=new y(A.scale.x,A.scale.y,A.scale.z)),t.parent=A.parent,A.seed&&(t.idProvider=new mg(A.seed)),t.visible=A.visible,t.context=i,ky&&i.alias&&console.log("[Remote] instantiate in: "+i.alias);const g=Gc(e,t);g&&(A.parent==="scene"&&i.scene.add(g),ky&&console.log("[Remote] new instance","gameobject:",g==null?void 0:g.guid,e))})}function JtA(i,A){const e=aS(),t=A??new Vs;t.idProvider=new mg(e);const g=Gc(i,t);return{seed:e,instance:g}}const dO={};function uO(i,A){dO[i]=A}async function vtA(i,A){const e=dO[i];if(e!=null){const t=await e(i);if(t)return t}return pO(i,A)}function pO(i,A){if(A===null||!i)return null;if(A.guid===i)return A;if(A.children)for(const e of A.children){const t=pO(i,e);if(t)return t}return null}const hD=oA("debuggetcomponent"),lD=oA("debuginstantiate");var fO=(i=>(i[i.None=0]="None",i[i.HideInHierarchy=1]="HideInHierarchy",i[i.HideInInspector=2]="HideInInspector",i[i.DontSaveInEditor=4]="DontSaveInEditor",i[i.NotEditable=8]="NotEditable",i[i.DontSaveInBuild=16]="DontSaveInBuild",i[i.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",i[i.DontSave=52]="DontSave",i[i.HideAndDontSave=61]="HideAndDontSave",i))(fO||{});class Vs{constructor(){r(this,"idProvider");r(this,"parent");r(this,"keepWorldPosition");r(this,"position");r(this,"rotation");r(this,"scale");r(this,"visible");r(this,"context")}clone(){var e,t,g;const A=new Vs;return A.idProvider=this.idProvider,A.parent=this.parent,A.keepWorldPosition=this.keepWorldPosition,A.position=(e=this.position)==null?void 0:e.clone(),A.rotation=(t=this.rotation)==null?void 0:t.clone(),A.scale=(g=this.scale)==null?void 0:g.clone(),A}cloneAssign(A){var e,t,g;this.idProvider=A.idProvider,this.parent=A.parent,this.keepWorldPosition=A.keepWorldPosition,this.position=(e=A.position)==null?void 0:e.clone(),this.rotation=(t=A.rotation)==null?void 0:t.clone(),this.scale=(g=A.scale)==null?void 0:g.clone()}}function kc(i){return i.visible}function Dl(i,A){return typeof A=="number"&&(A=A>.5),i.visible=A,i.visible}function DO(i){return i[KC]||rS(i)}function yO(i,A){i[PT]=A}function rS(i){return Ls.isUsingInstancing(i)}function ru(i,A){return VE(i,A,!0,!0)}const wO=Symbol("isDestroyed");function HB(i){return i[wO]}function SO(i,A){i[wO]=A}const vM=Symbol("isDontDestroy");function bM(i,A=!0){i[vM]=A}const dD=[],uD=[];function Ts(i,A=!0,e=!1){dD.length=0,uD.length=0,qM(i,A,e,!0);for(const t of dD)t.gameObject=null,t.context=null;for(const t of uD)SO(t,!0),e&&Wt(t),HT(t);uD.length=0,dD.length=0}function qM(i,A=!0,e=!1,t=!0){if(i==null)return;const g=i;if(g.isComponent){if(g[vM])return;dD.push(g);const s=g.gameObject;g.__internalDisable(),g.__internalDestroy(),g.gameObject=s;return}if(i[vM])return;const I=i;hD&&console.log(I),uD.push(I);const o=I.userData.components;if(o){let s=o.length;for(let n=0;n<o.length;n++){const C=o[n];qM(C,A,e,!1),o.length<s&&(s=o.length,n--)}}if(A&&I.children)for(const s of I.children)qM(s,A,e,!1);t&&I.removeFromParent()}function OB(i,A,e=!0){return mO(i,A,e)}function*YN(i,A,e=!1,t=999,g=0){if(i!=null&&i.userData.components&&!(g>t)){for(const I of i.userData.components)A&&(I==null?void 0:I.isComponent)===!0&&I instanceof A?yield I:yield I;if(e===!0)for(const I of i.children)yield*YN(I,A,!0,t,g+1)}}function mO(i,A,e,t=0){var g;if(i){if(i.isObject3D,t>1e3){console.warn("Failed to iterate components: too many levels");return}if((g=i.userData)!=null&&g.components)for(let I=0;I<i.userData.components.length;I++){const o=i.userData.components[I];if((o==null?void 0:o.isComponent)===!0){const s=A(o);if(s!==void 0)return s}}if(e&&i.children){const I=t+1;for(let o=0;o<i.children.length;o++){const s=i.children[o];if(!s)continue;const n=mO(s,A,e,I);if(n!==void 0)return n}}}}function Gc(i,A=null){let e=null;A!==null&&(A.x!==void 0?(e=new Vs,e.position=A):e=A);let t=ve.Current;e!=null&&e.context&&(t=e.context),hD&&t.alias&&console.log("context",t.alias),e&&!e.idProvider&&(e.idProvider=new mg(Date.now()));const g=[],I={},o={},s=kO(t,i,e,g,I,o);s&&(qtA(I),btA(o,I)),hD&&(yy(i,!0),yy(s,!0));const n={};for(const C in g){const a=g[C],B=a.guid;e&&e.idProvider&&(a.guid=e.idProvider.generateUUID(),n[B]=a.guid,hD&&console.log(a.name,a.guid)),nS(a,t),a.__internalNewInstanceCreated&&a.__internalNewInstanceCreated()}for(const C in g){const a=g[C];a.resolveGuids&&a.resolveGuids(n),a.enabled!==!1&&(a.enabled=!0)}return oy(t),s}function kO(i,A,e,t,g,I){var a;if(!A)return null;const o=A.userData;A.userData={};const s=A.children;A.children=[];const n=A.clone(!1);if(BS(n),A.userData=o,A.children=s,g[A.uuid]={original:A,clone:n},lD&&console.log("ADD",A,n),A.type==="SkinnedMesh"&&(I[A.uuid]={original:A,clone:n}),(e==null?void 0:e.visible)!==void 0&&(n.visible=e.visible),e!=null&&e.idProvider){n.uuid=e.idProvider.generateUUID();const B=n;B&&(B.guid=n.uuid)}A.animations&&A.animations.length>0&&(n.animations=[...A.animations]);const C=A.parent;if(C&&C.add(n),e!=null&&e.position?QI(n,e.position):n.position.copy(A.position),e!=null&&e.rotation?rs(n,e.rotation):n.quaternion.copy(A.quaternion),e!=null&&e.scale?n.scale.copy(e.scale):n.scale.copy(A.scale),e!=null&&e.parent&&e.parent!=="scene"){let B=null;if(typeof e.parent=="string"?B=VE(e.parent,i.scene,!0):B=e.parent,B){const Q=e.keepWorldPosition===!0?B.attach:B.add;Q?Q.call(B,n):console.error("Invalid parent object",B,"received when instantiating:",A)}else console.warn("could not find parent:",e.parent)}for(const[B,Q]of Object.entries(A.userData))B!=="components"&&(n.userData[B]=Q);if((a=A.userData)!=null&&a.components){const B=A.userData.components,Q=[];n.userData.components=Q;for(let E=0;E<B.length;E++){const c=B[E],h=new c.constructor;zE(h,c),c[El]!==void 0&&(h[El]=c[El]),Q.push(h),h.gameObject=n,t.push(h),Xd.dispatchComponentLifecycleEvent(Zd.Added,h)}}e&&(e.position=void 0,e.rotation=void 0,e.scale=void 0,e.parent=void 0);for(const B in A.children){const Q=A.children[B],E=kO(i,Q,e,t,g,I);E&&n.add(E)}return n}function btA(i,A){for(const e in i){const t=i[e],g=t.original,I=g.skeleton,o=t.clone;if(!I){console.warn("Skinned mesh has no skeleton?",t);continue}const s=I.bones,n=o.skeleton.clone();o.skeleton=n,o.bindMatrix.clone().copy(g.bindMatrix),o.bindMatrixInverse.copy(g.bindMatrixInverse);const C=[];n.bones=C;for(let a=0;a<s.length;a++){const B=s[a],E=A[B.uuid].clone;C.push(E)}}for(const e in i){const t=i[e].clone;t.skeleton.update(),t.bind(t.skeleton,t.bindMatrix),t.updateMatrixWorld(!0)}}function qtA(i){var A;for(const e in i){const g=i[e].clone;if((A=g.userData)!=null&&A.components)for(let I=0;I<g.userData.components.length;I++){const o=g.userData.components[I],s=Object.entries(o);for(const[n,C]of s)if(Array.isArray(C)){const a=[];o[n]=a;for(let B=0;B<C.length;B++){const Q=C[B];if(typeof Q!="object"){a.push(Q);continue}const E=rq(o,n,Q,i);E!==void 0?a.push(E):a.push(Q)}}else if(typeof C=="object"){const a=rq(o,n,C,i);a!==void 0&&(o[n]=a)}}}}function rq(i,A,e,t){var g,I;if(e!=null)if(e.isComponent===!0){const o=e.gameObject;if(o){const s=o.uuid,n=(g=t[s])==null?void 0:g.clone;if(!n){lD&&console.log("reference did not change",A,i,e);return}const C=o.userData.components.indexOf(e);if(C>=0)return lD&&console.log(A,s),n.userData.components[C];console.warn("could not find component",A,e)}}else if(e.isObject3D===!0){if(A==="gameObject")return;const o=e;if(o){const s=o.uuid,n=(I=t[s])==null?void 0:I.clone;if(n)return lD&&console.log(A,"old",e,"new",n),n}}else{if(e.isVector4||e.isVector3||e.isVector2||e.isQuaternion||e.isEuler)return e.clone();if(e.isColor===!0)return e.clone();if(e.isEventList===!0)return new e.constructor}}const GO=new Map;function LtA(i,A){if(!i)return;if(!A){console.warn("No prototype found",i,i.prototype,i.constructor);return}const e=GO.get(A);e&&e.apply(i)}function xtA(i){const A=YtA(i.prototype);GO.set(i,A)}function YtA(i){return new TtA(i)}class TtA{constructor(A){r(this,"$symbol");r(this,"extensions");r(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(A),this.descriptors=new Array;for(let e=0;e<this.extensions.length;e++){const t=this.extensions[e],g=Object.getOwnPropertyDescriptor(A,t);g&&this.descriptors.push(g)}}apply(A){if(!A[this.$symbol]){A[this.$symbol]=!0;for(let e=0;e<this.extensions.length;e++){const t=this.extensions[e],g=this.descriptors[e];g&&Object.defineProperty(A,t,g)}}}}function BS(i){i&&i.isObject3D===!0&&LtA(i,pA)}pA.prototype.SetActive=function(i){this.visible=i};pA.prototype.setActive=function(i){this.visible=i};pA.prototype.destroy=function(){Ts(this)};pA.prototype.addComponent=function(i){return _N(this,i)};pA.prototype.addNewComponent=function(i){return dr(this,new i)};pA.prototype.removeComponent=function(i){return TN(this,i)};pA.prototype.getOrAddComponent=function(i){return QS(this,i)};pA.prototype.getComponent=function(i){return Mc(this,i)};pA.prototype.getComponents=function(i,A){return Bu(this,i,A)};pA.prototype.getComponentInChildren=function(i){return Qu(this,i)};pA.prototype.getComponentsInChildren=function(i,A){return Eu(this,i,A)};pA.prototype.getComponentInParent=function(i){return Qd(this,i)};pA.prototype.getComponentsInParent=function(i,A){return ES(this,i,A)};Object.getOwnPropertyDescriptor(pA.prototype,"activeSelf")||Object.defineProperty(pA.prototype,"activeSelf",{get:function(){return kc(this)},set:function(i){Dl(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"transform")||Object.defineProperty(pA.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(pA.prototype,"worldPosition")||Object.defineProperty(pA.prototype,"worldPosition",{get:function(){return this instanceof kU?Je(this.object):Je(this)},set:function(i){QI(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldQuaternion")||Object.defineProperty(pA.prototype,"worldQuaternion",{get:function(){return this instanceof kU?qt(this.object):qt(this)},set:function(i){rs(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldRotation")||Object.defineProperty(pA.prototype,"worldRotation",{get:function(){return nu(this)},set:function(i){bN(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldScale")||Object.defineProperty(pA.prototype,"worldScale",{get:function(){return li(this)},set:function(i){Bd(this,i)}});Object.getOwnPropertyDescriptor(pA.prototype,"worldForward")||Object.defineProperty(pA.prototype,"worldForward",{get:function(){return Zi().set(0,0,1).applyQuaternion(qt(this))}});Object.getOwnPropertyDescriptor(pA.prototype,"worldRight")||Object.defineProperty(pA.prototype,"worldRight",{get:function(){return Zi().set(1,0,0).applyQuaternion(qt(this))}});Object.getOwnPropertyDescriptor(pA.prototype,"worldUp")||Object.defineProperty(pA.prototype,"worldUp",{get:function(){return Zi().set(0,1,0).applyQuaternion(qt(this))}});xtA(pA);const zm=oA("debuggetcomponent");function _tA(i){return i==null||i.isObject3D?i:i.object&&i.object.isObject3D?i.object:i}function TN(i,A){if(!i||!i.userData.components)return;const e=i.userData.components.indexOf(A);e<0||(Xd.dispatchComponentLifecycleEvent(Zd.Removing,A),A.gameObject=null,i.userData.components.splice(e,1))}function QS(i,A){const e=Mc(i,A);if(e)return e;const t=new A;return dr(i,t)}const MO=new mg("addComponentIdProvider");function dr(i,A,e=!0){i.userData||(i.userData={}),i.userData.components||(i.userData.components=[]),i.userData.components.push(A),A.gameObject=i,(A.guid===void 0||A.guid==="invalid")&&(A.guid=MO.generateUUID()),BS(i),nS(A);try{e&&A.__internalAwake&&(cl(i),A.activeAndEnabled&&A.__internalAwake()),Xd.dispatchComponentLifecycleEvent(Zd.Added,A)}catch(t){console.error(t)}return A}function _N(i,A){if(typeof A=="function")return dr(i,new A);if(A.destroyed)return console.warn("Can not move/add a destroyed component",A),A;if(A.gameObject===i)return A;if(A.gameObject&&A.gameObject.userData.components){const e=A.gameObject.userData.components.indexOf(A);A.gameObject.userData.components.splice(e,1)}if(!i.userData.components)i.userData.components=[];else if(i.userData.components.includes(A))return A;return i.userData.components.push(A),A.gameObject=i,(A.guid===void 0||A.guid==="invalid")&&(A.guid=MO.generateUUID()),nS(A),A}function RO(i){if(i.gameObject&&i.gameObject.userData.components){const A=i.gameObject.userData.components.indexOf(i);i.gameObject.userData.components.splice(A,1)}i.__internalDisable&&i.__internalDisable(),pC(i,i.context??ve.Current),i.destroy(),i.gameObject=null}let Bq=!1;function UO(i,A,e){var t;if(i==null)return null;if(!i.isObject3D)return console.error("Object is not object3D"),null;if(!((t=i==null?void 0:i.userData)!=null&&t.components)||(typeof A=="string"&&(Bq||(Bq=!0,console.warn(`Accessing components by name is not supported.
|
|
4995
4997
|
Please use the component type instead. This may keep working in local development but it will fail when bundling your application.
|
|
4996
4998
|
|
|
4997
4999
|
You can import other modules your main module to get access to types
|
|
@@ -5405,9 +5407,9 @@ ${I.join(`
|
|
|
5405
5407
|
|
|
5406
5408
|
}
|
|
5407
5409
|
`}function Yq(i){return`(${i.r}, ${i.g}, ${i.b})`}function Tq(i){return`(${i.x}, ${i.y})`}const BP=[1023,33777,33778,33779,35842,35843,37496,37808,37809,37810,37811,37812,37813,37814,37815,37816,37817,37818,37819,37820,37821,36492];oA("debugusdz");const LK=class{constructor(A,e,t){r(this,"id");r(this,"trigger");r(this,"action");r(this,"exclusive",!1);this.id="Behavior_"+hS(A)+"_"+LK.global_id++,this.trigger=e,this.action=t}makeExclusive(A){return this.exclusive=A,this}writeTo(A,e,t){if(!this.trigger||!this.action)return;t.beginBlock(`def Preliminary_Behavior "${this.id}"`),t.appendLine(`rel actions = <${this.action.id}>`),t.appendLine(`uniform bool exclusive = ${this.exclusive}`);let g="";if(Array.isArray(this.trigger)){g="[";for(let I=0;I<this.trigger.length;I++){const o=this.trigger[I];g+="<"+o.id+">",I+1<this.trigger.length&&(g+=", ")}g+="]"}else g=`<${this.trigger.id}>`;if(t.appendLine(`rel triggers = ${g} `),t.appendLine(),Array.isArray(this.trigger))for(const I of this.trigger)I.writeTo(e,t),t.appendLine();else this.trigger.writeTo(e,t);t.appendLine(),this.action.writeTo(e,t),t.closeBlock()}};let rg=LK;r(rg,"global_id",0);function WM(i,A){var t,g;let e="";if(Array.isArray(i)){let I="[ ";for(let o=0;o<i.length;o++){let s=i[o];if(typeof s=="string")I+=s;else if(typeof s=="object"){s.isObject3D&&(s=A.findById(s.uuid));const n=(t=s.getPath)==null?void 0:t.call(s);I+=n}o+1<i.length&&(I+=", ")}I+=" ]",e=I}else typeof i=="object"&&(i.isObject3D&&(i=A.findById(i.uuid)),e=(g=i.getPath)==null?void 0:g.call(i));return e}const xK=class{constructor(A,e){r(this,"id");r(this,"targetId");r(this,"tokenId");r(this,"type");r(this,"distance");A&&(this.targetId=A),e?this.id=e:this.id="Trigger_"+xK.global_id++}writeTo(A,e){e.beginBlock(`def Preliminary_Trigger "${this.id}"`),this.targetId&&(typeof this.targetId!="string"&&(this.targetId=WM(this.targetId,A)),e.appendLine("rel affectedObjects = "+this.targetId)),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.type&&e.appendLine(`token type = "${this.type}"`),typeof this.distance=="number"&&e.appendLine(`double distance = ${this.distance}`),e.closeBlock()}};let bC=xK;r(bC,"global_id",0);class Hg{static sceneStartTrigger(){const A=new bC;return A.targetId=void 0,A.tokenId="SceneTransition",A.type="enter",A}static tapTrigger(A){const e=new bC(A);return e.tokenId="TapGesture",e}static isTapTrigger(A){return(A==null?void 0:A.tokenId)==="TapGesture"}static proximityToCameraTrigger(A,e){const t=new bC(A);return t.tokenId="ProximityToCamera",t.distance=e,t}}class Ta{constructor(A,e){r(this,"id");r(this,"actions");r(this,"loops",0);r(this,"performCount",1);r(this,"type","serial");this.id=A,this.actions=e}static getId(){return this.global_id++}addAction(A){return this.actions.push(A),this}makeParallel(){return this.type="parallel",this}makeSequence(){return this.type="serial",this}makeLooping(){return this.loops=1,this}makeRepeat(A){return this.performCount=A,this}writeTo(A,e){e.beginBlock(`def Preliminary_Action "${this.id}"`),e.beginArray("rel actions");for(const t of this.actions){if(!t)continue;const g=t===this.actions[this.actions.length-1];e.appendLine("<"+t.id+">"+(g?"":", "))}e.closeArray(),e.appendLine(),e.appendLine('token info:id = "Group"'),e.appendLine(`bool loops = ${this.loops} `),e.appendLine(`int performCount = ${this.performCount} `),e.appendLine(`token type = "${this.type}"`),e.appendLine();for(const t of this.actions)t&&(t.writeTo(A,e),e.appendLine());e.closeBlock()}}r(Ta,"global_id",0);var zN=(i=>(i[i.pop=0]="pop",i[i.blink=1]="blink",i[i.bounce=2]="bounce",i[i.flip=3]="flip",i[i.float=4]="float",i[i.jiggle=5]="jiggle",i[i.pulse=6]="pulse",i[i.spin=7]="spin",i))(zN||{}),jM=(i=>(i.Relative="relative",i.Absolute="absolute",i))(jM||{}),QP=(i=>(i.Allow="allow",i.Ignore="ignore",i.Stop="stop",i))(QP||{});const ew=class{constructor(A,e){r(this,"id");r(this,"tokenId");r(this,"affectedObjects");r(this,"easeType");r(this,"motionType");r(this,"duration");r(this,"moveDistance");r(this,"style");r(this,"type");r(this,"front");r(this,"up");r(this,"start");r(this,"animationSpeed");r(this,"reversed");r(this,"pingPong");r(this,"xFormTarget");r(this,"audio");r(this,"gain");r(this,"auralMode");r(this,"multiplePerformOperation");A&&(this.affectedObjects=A),e?this.id=e:this.id="Action",this.id+="_"+ew.global_id++}clone(){const A=new ew,e=A.id;return Object.assign(A,this),A.id=e,A}writeTo(A,e){e.beginBlock(`def Preliminary_Action "${this.id}"`),this.affectedObjects&&(typeof this.affectedObjects!="string"&&(this.affectedObjects=WM(this.affectedObjects,A)),e.appendLine("rel affectedObjects = "+this.affectedObjects)),typeof this.duration=="number"&&e.appendLine(`double duration = ${this.duration} `),this.easeType&&e.appendLine(`token easeType = "${this.easeType}"`),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.motionType&&e.appendLine(`token motionType = "${this.motionType}"`),typeof this.moveDistance=="number"&&e.appendLine(`double moveDistance = ${this.moveDistance} `),this.style&&e.appendLine(`token style = "${this.style}"`),this.type&&e.appendLine(`token type = "${this.type}"`),this.front&&e.appendLine(`vector3d front = (${this.front.x}, ${this.front.y}, ${this.front.z})`),this.up&&e.appendLine(`vector3d upVector = (${this.up.x}, ${this.up.y}, ${this.up.z})`),typeof this.start=="number"&&e.appendLine(`double start = ${this.start} `),typeof this.animationSpeed=="number"&&e.appendLine(`double animationSpeed = ${this.animationSpeed} `),typeof this.reversed=="boolean"&&e.appendLine(`bool reversed = ${this.reversed}`),typeof this.pingPong=="boolean"&&e.appendLine(`bool reverses = ${this.pingPong}`),this.xFormTarget&&(typeof this.xFormTarget!="string"&&(this.xFormTarget=WM(this.xFormTarget,A)),e.appendLine(`rel xformTarget = ${this.xFormTarget}`)),typeof this.audio=="string"&&e.appendLine(`asset audio = @${this.audio}@`),typeof this.gain=="number"&&e.appendLine(`double gain = ${this.gain}`),typeof this.auralMode=="string"&&e.appendLine(`token auralMode = "${this.auralMode}"`),typeof this.multiplePerformOperation=="string"&&e.appendLine(`token multiplePerformOperation = "${this.multiplePerformOperation}"`),e.closeBlock()}};let uo=ew;r(uo,"global_id",0);let DE=class CE{constructor(A,e,t){r(this,"x",0);r(this,"y",0);r(this,"z",0);this.x=A,this.y=e,this.z=t}static get up(){return new CE(0,1,0)}static get right(){return new CE(1,0,0)}static get forward(){return new CE(0,0,1)}static get back(){return new CE(0,0,-1)}static get zero(){return new CE(0,0,0)}};var VM=(i=>(i.Play="play",i.Pause="pause",i.Stop="stop",i))(VM||{}),zM=(i=>(i.Spatial="spatial",i.NonSpatial="nonSpatial",i.Ambient="ambient",i))(zM||{});class ct{static sequence(...A){return new Ta("group_"+Ta.getId(),A).makeSequence()}static parallel(...A){return new Ta("group_"+Ta.getId(),A).makeParallel()}static fadeAction(A,e,t){const g=new uo(A);return g.tokenId="Visibility",g.type=t?"show":"hide",g.duration=e,g.style="basic",g.motionType="none",g.moveDistance=0,g.easeType="none",g}static startAnimationAction(A,e,t=0,g=1,I=!1,o=!1){const s=new uo(A);if(s.tokenId="StartAnimation",s.start=e,s.duration=t,s.animationSpeed=g,s.reversed=I,s.pingPong=o,s.multiplePerformOperation="allow",I&&(s.start-=t),o){s.pingPong=!1;const n=s.clone();return n.reversed=!I,n.start=s.start,n.reversed&&(n.start-=t),ct.sequence(s,n)}return s}static waitAction(A){const e=new uo;return e.tokenId="Wait",e.duration=A,e}static lookAtCameraAction(A,e=9999999999999,t,g){const I=new uo(A);return I.tokenId="LookAtCamera",I.duration=e,I.front=t??DE.forward,I.up=g??DE.up,I}static emphasize(A,e,t=2,g=1,I="basic"){const o=new uo(A);return o.tokenId="Emphasize",o.duration=e,o.style=I??"basic",o.motionType=zN[t],o.moveDistance=g,o}static transformAction(A,e,t,g,I="inout"){const o=new uo(A);return o.tokenId="Transform",o.duration=t,o.type=g,o.easeType=I,Array.isArray(e)&&console.error("Transform target must not be an array",e),o.xFormTarget=e,o}static playAudioAction(A,e,t="play",g=1,I="spatial"){const o=new uo(A);return o.tokenId="Audio",o.type=t,o.audio=e,o.gain=g,o.auralMode=I,o.multiplePerformOperation="allow",o}}class LgA{constructor(A){r(this,"object");r(this,"model");this.object=A}get id(){return this.object.uuid}apply(A){if(!this.model&&(this.model=A.findById(this.object.uuid),!this.model)){console.error("could not find model with id "+this.object.uuid);return}this.onApply(A)}}class ZN extends LgA{constructor(e,t,g,I){super(e);r(this,"matrix");r(this,"material");r(this,"geometry");r(this,"_enableAction");r(this,"_disableAction");this.matrix=t,this.material=g,this.geometry=I}onApply(e){var I,o;const t=this.model;if(!t)return;(I=t.parent)!=null&&I.isDynamic||Ao.createEmptyParent(t);const g=t.clone();this.matrix&&(g.matrix=this.matrix),this.material&&(g.material=this.material),this.geometry&&(g.geometry=this.geometry),(o=t.parent)==null||o.add(g)}enable(){return this._enableAction?this._enableAction:(this._enableAction=ct.fadeAction(this.object,0,!0),this._enableAction)}disable(){return this._disableAction?this._disableAction:(this._disableAction=ct.fadeAction(this.object,0,!1),this._disableAction)}}class XN{constructor(A){r(this,"actions");r(this,"sortedActions");this.actions=[...A]}organize(){this.sortedActions={};for(const A of this.actions){const e=A.id;this.sortedActions[e]||(this.sortedActions[e]=[]),this.sortedActions[e].push(A)}}getActions(A){return this.sortedActions||this.organize(),this.sortedActions[A.uuid]}}var xgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,EP=(i,A,e,t)=>{for(var g=t>1?void 0:t?YgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&xgA(A,e,g),g};class lu extends NA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"width",0);r(this,"centered",!0);r(this,"_centerPos")}awake(){this._centerPos=new y}update(){if(!this.from||!this.to)return;const e=Je(this.from).clone(),t=Je(this.to).clone(),g=e.distanceTo(t);this._centerPos.copy(e),this._centerPos.add(t),this._centerPos.multiplyScalar(.5),QI(this.gameObject,this.centered?this._centerPos:e),this.gameObject.lookAt(Je(this.to).clone()),this.gameObject.scale.set(this.width,this.width,g)}}EP([D(BA)],lu.prototype,"from",2);EP([D(BA)],lu.prototype,"to",2);var TgA=Object.defineProperty,_gA=Object.getOwnPropertyDescriptor,du=(i,A,e,t)=>{for(var g=t>1?void 0:t?_gA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&TgA(A,e,g),g};const zQ=oA("debuganimation");class Go extends NA{constructor(){super(...arguments);r(this,"playAutomatically",!0);r(this,"randomStartTime",!0);r(this,"minMaxSpeed");r(this,"minMaxOffsetNormalized");r(this,"loop",!0);r(this,"clampWhenFinished",!1);r(this,"_tempAnimationClipBeforeGameObjectExisted",null);r(this,"_tempAnimationsArray");r(this,"mixer");r(this,"_actions",[]);r(this,"_currentActions",[]);r(this,"_handles",[]);r(this,"_didInit",!1)}get clip(){var e;return(e=this.animations)!=null&&e.length?this.animations[0]:null}set clip(e){if(!this.__didAwake){zQ&&console.warn("Assign clip during serialization",e),this._tempAnimationClipBeforeGameObjectExisted=e;return}e&&(this.gameObject.animations||(this.gameObject.animations=[]),!this.animations.includes(e)&&(this.animations.length>0?this.animations.splice(0,0,e):this.animations.push(e)))}set clips(e){this.animations=e}set animations(e){e==null||!Array.isArray(e)||(this.gameObject?this.gameObject.animations=e:this._tempAnimationsArray=e)}get animations(){return this.gameObject.animations||this._tempAnimationsArray||[]}get currentAction(){return this._currentActions[0]}get currentActions(){return this._currentActions}get actions(){return this._actions}set actions(e){this._actions=e}awake(){zQ&&console.log("Animation Awake",this.name,this),this._tempAnimationsArray&&(this.animations=this._tempAnimationsArray,this._tempAnimationsArray=void 0),this._tempAnimationClipBeforeGameObjectExisted&&(this.clip=this._tempAnimationClipBeforeGameObjectExisted,this._tempAnimationClipBeforeGameObjectExisted=null),this.playAutomatically&&this.init()}onEnable(){var e;if(this.playAutomatically&&((e=this.animations)==null?void 0:e.length)>0&&this.currentActions.length<=0){const t=Math.floor(Math.random()*this.actions.length);this.play(t)}}start(){this.randomStartTime&&this.currentAction&&(this.currentAction.time=Math.random()*this.currentAction.getClip().duration)}update(){this.mixer&&this.mixer.update(this.context.time.deltaTime)}getAction(e){var t;return(t=this.actions)==null?void 0:t.find(g=>g.getClip().name===e)}get isPlaying(){for(let e=0;e<this.actions.length;e++)if(this.actions[e].isRunning())return!0;return!1}play(e=0,t){if(zQ&&console.log("PLAY",e),this.init(),!this.mixer){zQ&&console.warn("Missing mixer",this);return}e===void 0&&(e=0);let g=e;if(typeof e=="number"){if(e>=this.animations.length){zQ&&console.log("No animation at index",e);return}g=this.animations[e]}else typeof e=="string"&&(g=this.animations.find(o=>o.name===e));if(!g){console.error("Could not find clip",e);return}t||(t={}),t.minMaxOffsetNormalized||(t.minMaxOffsetNormalized=this.minMaxOffsetNormalized),t.minMaxSpeed||(t.minMaxSpeed=this.minMaxSpeed),t.loop===void 0&&(t.loop=this.loop),t.clampWhenFinished===void 0&&(t.clampWhenFinished=this.clampWhenFinished);for(const o of this.actions)if(o.getClip()===g)return this.internalOnPlay(o,t);if(!(g instanceof go)){console.warn("Clip is no AnimationClip",g,"on object: "+this.name);return}const I=this.mixer.clipAction(g);return this.actions.push(I),this.internalOnPlay(I,t)}internalOnPlay(e,t){var g=this.currentAction;if(g===e&&g.isRunning()&&g.time<g.getClip().duration){const n=this.tryFindHandle(e);if(n)return n.getPromise()}const I=(t==null?void 0:t.exclusive)??!0;t!=null&&t.fadeDuration?(I&&(g==null||g.fadeOut(t.fadeDuration)),e.fadeIn(t.fadeDuration)):I&&(g==null||g.stop()),e.reset(),e.enabled=!0,e.time=0,e.timeScale=1;const o=e.getClip();t!=null&&t.minMaxOffsetNormalized&&(e.time=se.lerp(t.minMaxOffsetNormalized.x,t.minMaxOffsetNormalized.y,Math.random())*o.duration),t!=null&&t.minMaxSpeed&&(e.timeScale=se.lerp(t.minMaxSpeed.x,t.minMaxSpeed.y,Math.random())),t!=null&&t.clampWhenFinished&&(e.clampWhenFinished=!0),(t==null?void 0:t.startTime)!==void 0&&(e.time=t.startTime),(t==null?void 0:t.loop)!==void 0?e.loop=t.loop?bR:xl:e.loop=xl,e.play(),zQ&&console.log("PLAY",e.getClip().name,e);const s=new HgA(e,this.mixer,t,n=>{this._handles.splice(this._handles.indexOf(s),1)});return this._handles.push(s),s.getPromise()}tryFindHandle(e){for(const t of this._handles)if(t.action===e)return t}init(){this._didInit||(this._didInit=!0,this.gameObject&&(this.actions=[],this.mixer=new xw(this.gameObject)))}}du([D()],Go.prototype,"playAutomatically",2);du([D()],Go.prototype,"randomStartTime",2);du([D()],Go.prototype,"loop",2);du([D()],Go.prototype,"clampWhenFinished",2);du([D(go)],Go.prototype,"clips",1);class HgA{constructor(A,e,t,g){r(this,"mixer");r(this,"action");r(this,"promise",null);r(this,"resolve",null);r(this,"reject",null);r(this,"_options");r(this,"_resolveCallback",null);r(this,"_rejectCallback",null);r(this,"_loopCallback");r(this,"_finishedCallback");r(this,"_resolvedOrRejectedCallback");this.action=A,this.mixer=e,this._resolvedOrRejectedCallback=g,this._options=t}getPromise(){return this.promise?this.promise:(this.promise=new Promise((A,e)=>{this._resolveCallback=A,this._rejectCallback=e,this.resolve=this.onResolve.bind(this),this.reject=this.onReject.bind(this)}),this._loopCallback=this.onLoop.bind(this),this._finishedCallback=this.onFinished.bind(this),this.mixer.addEventListener("loop",this._loopCallback),this.mixer.addEventListener("finished",this._finishedCallback),this.promise)}_update(){this._options&&this._options.endTime!==void 0&&this.action.time>this._options.endTime&&(this._options.loop===!0?this.action.time=this._options.startTime??0:(this.action.time=this._options.endTime,this.action.timeScale=0,this.onResolve()))}onResolve(){var A,e;this.dispose(),(A=this._resolvedOrRejectedCallback)==null||A.call(this,this),(e=this._resolveCallback)==null||e.call(this,this.action)}onReject(A){var e,t;this.dispose(),(e=this._resolvedOrRejectedCallback)==null||e.call(this,this),(t=this._rejectCallback)==null||t.call(this,A)}onLoop(A){}onFinished(A){A.action===this.action&&this.onResolve()}dispose(){this._loopCallback&&this.mixer.removeEventListener("loop",this._loopCallback),this._finishedCallback&&this.mixer.removeEventListener("finished",this._finishedCallback),this._loopCallback=void 0,this._finishedCallback=void 0}}var OgA=Object.defineProperty,PgA=Object.getOwnPropertyDescriptor,ur=(i,A,e,t)=>{for(var g=t>1?void 0:t?PgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OgA(A,e,g),g};class $C{constructor(){r(this,"time");r(this,"value");r(this,"inTangent");r(this,"inWeight");r(this,"outTangent");r(this,"outWeight");r(this,"weightedMode")}}ur([D()],$C.prototype,"time",2);ur([D()],$C.prototype,"value",2);ur([D()],$C.prototype,"inTangent",2);ur([D()],$C.prototype,"inWeight",2);ur([D()],$C.prototype,"outTangent",2);ur([D()],$C.prototype,"outWeight",2);ur([D()],$C.prototype,"weightedMode",2);const ZM=class{constructor(){r(this,"keys")}clone(){var A;const i=new ZM;return i.keys=((A=this.keys)==null?void 0:A.map(e=>{const t=new $C;return t.time=e.time,t.value=e.value,t.inTangent=e.inTangent,t.inWeight=e.inWeight,t.outTangent=e.outTangent,t.outWeight=e.outWeight,t.weightedMode=e.weightedMode,t}))||[],i}get duration(){return!this.keys||this.keys.length==0?0:this.keys[this.keys.length-1].time}evaluate(i){if(!this.keys||this.keys.length==0)return 0;if(this.keys[0].time>=i)return this.keys[0].value;for(let A=0;A<this.keys.length;A++){const e=this.keys[A];if(e.time<=i)if(A+1<this.keys.length){const g=this.keys[A+1];if(g.time<i)continue;return!isFinite(e.outTangent)||!isFinite(g.inTangent)?e.value:ZM.interpolateValue(i,e,g)}else return e.value}return this.keys[this.keys.length-1].value}static interpolateValue(i,A,e){const t=A.time,g=A.value,I=A.outTangent,o=e.time,s=e.value,n=e.inTangent,C=o-t,a=C*C,B=a*C,Q=((I+n)*C-2*(s-g))/B,E=(3*(s-g)-(n+2*I)*C)/a,c=I,h=g,u=i-t,l=u*u,d=l*u;return Q*d+E*l+c*u+h}};let $B=ZM;ur([D($C)],$B.prototype,"keys",2);class WgA extends Ti{constructor(A,e=1,t=16,g=2){const I=new fe,o=t+g*2,s=new Float32Array((o*3+3)*3);I.setAttribute("position",new ie(s,3));const n=new Oi({color:65280}),C=new Oi({color:16776960});super(I,[C,n]),this.audio=A,this.range=e,this.divisionsInnerAngle=t,this.divisionsOuterAngle=g,this.type="PositionalAudioHelper",this.update()}update(){const A=this.audio,e=this.range,t=this.divisionsInnerAngle,g=this.divisionsOuterAngle,I=Bg.degToRad(A.panner.coneInnerAngle),o=Bg.degToRad(A.panner.coneOuterAngle),s=I/2,n=o/2;let C=0,a=0,B,Q;const E=this.geometry,c=E.attributes.position;E.clearGroups();function h(u,l,d,p){const f=(l-u)/d;for(c.setXYZ(C,0,0,0),a++,B=u;B<l;B+=f)Q=C+a,c.setXYZ(Q,Math.sin(B)*e,0,Math.cos(B)*e),c.setXYZ(Q+1,Math.sin(Math.min(B+f,l))*e,0,Math.cos(Math.min(B+f,l))*e),c.setXYZ(Q+2,0,0,0),a+=3;E.addGroup(C,a,p),C+=a,a=0}h(-n,-s,g,0),h(-s,s,t,1),h(s,n,g,0),c.needsUpdate=!0,I===o&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var jgA=Object.defineProperty,VgA=Object.getOwnPropertyDescriptor,_n=(i,A,e,t)=>{for(var g=t>1?void 0:t?VgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&jgA(A,e,g),g};const CI=oA("debugaudio");let Gy=!1;const My=[];function lS(){if(Gy)return;Ge()&&console.log("User interaction registered: audio can now be played"),Gy=!0;const i=[...My];My.length=0,i.forEach(A=>A())}document.addEventListener("pointerdown",lS);document.addEventListener("click",lS);document.addEventListener("dragstart",lS);document.addEventListener("touchstart",lS);const ka=class extends NA{constructor(){super(...arguments);r(this,"clip","");r(this,"playOnAwake",!1);r(this,"preload",!1);r(this,"_spatialBlend",0);r(this,"_minDistance",1);r(this,"_maxDistance",100);r(this,"_volume",1);r(this,"rollOffMode",0);r(this,"playInBackground",!0);r(this,"_loop",!1);r(this,"sound",null);r(this,"helper",null);r(this,"wasPlaying",!1);r(this,"audioLoader",null);r(this,"shouldPlay",!1);r(this,"_lastClipStartedLoading",null);r(this,"_audioElement",null);r(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||xn())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":CI&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,ka.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&ka.userInteractionRegistered&&this.wasPlaying&&this.play();break}});r(this,"onApplicationMuteChanged",()=>{var A,e;this.context.application.muted?(A=this.sound)==null||A.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});r(this,"createAudio",A=>{CI&&console.log("AudioBuffer finished loading",A);const e=this.Sound;if(!e){CI&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),A&&e.setBuffer(A),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&ka.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),ka.registerWaitForAllowAudio(this.__onAllowAudioCallback)});r(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});r(this,"_lastContextTime",0);r(this,"_hasEnded",!0);r(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Gy}static registerWaitForAllowAudio(A){if(A!==null){if(Gy){A();return}My.indexOf(A)===-1&&My.push(A)}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(A){this._loop=A,this.sound&&this.sound.setLoop(A)}get spatialBlend(){return this._spatialBlend}set spatialBlend(A){A!==this._spatialBlend&&(this._spatialBlend=A,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(A){this._minDistance!==A&&(this._minDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(A){this._maxDistance!==A&&(this._maxDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(A){this._volume=A,this.sound&&!this.context.application.muted&&(CI&&console.log(this.name,"audio set volume",A),this.sound.setVolume(A))}get Sound(){var A;if(!this.sound&&ka.userInteractionRegistered){let e=BA.getComponent(this.context.mainCamera,Xa)??BA.findObjectOfType(Xa,this.context);!e&&this.context.mainCamera&&(e=BA.addNewComponent(this.context.mainCamera,Xa)),e!=null&&e.listener?(this.sound=new rT(e.listener),(A=this.gameObject)==null||A.add(this.sound)):CI&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var A;return(A=this.sound)==null?void 0:A.context}awake(){CI&&console.log(this),this.audioLoader=new ty,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),ka.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():ka.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(ay.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(ay.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const A=this.sound;if(!A)return;this._needUpdateSpatialDistanceSettings=!1;const e=se.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(CI&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),A.setRefDistance(e),A.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:A.setDistanceModel("exponential");break;case 1:A.setDistanceModel("linear");break}this.spatialBlend>0?CI&&!this.helper&&(this.helper=new WgA(A,A.getRefDistance()),A.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(A){if(A&&(this.clip=A),typeof A=="string")if(CI&&console.log(A),A.endsWith(".mp3")||A.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new ty),this.shouldPlay=!0,this._lastClipStartedLoading===A){CI&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=A,CI&&console.log("load audio",A);const e=await this.audioLoader.loadAsync(A).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",A);else this.shouldPlay=!0,this.createAudio()}play(A=void 0){var t,g,I;!A&&this.clip&&(A=this.clip),A!==void 0&&typeof A!="string"&&!(A instanceof MediaStream)&&(Ge()&&console.warn("Called play on AudioSource with unknown argument type:",A+`
|
|
5408
|
-
Using the assigned clip instead:`,this.clip),A=this.clip);let e=!this.sound||A&&A!==this.clip;if(typeof A=="string"&&!this.audioLoader&&(e=!0),(A instanceof MediaStream||typeof A=="string")&&(this.clip=A),e){this.shouldPlay=!0,this.onNewClip(A);return}if(this.shouldPlay=!0,this._hasEnded=!1,CI&&console.log("play",(t=this.sound)==null?void 0:t.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(g=this.gameObject)==null||g.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(I=this.context.domElement.shadowRoot)==null||I.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(o?.1:0))}}pause(){var A,e;CI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var A,e;CI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,CI&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}get isPlaying(){var A;return((A=this.sound)==null?void 0:A.isPlaying)??!1}set isPlaying(A){}get time(){var A,e;return(A=this.sound)!=null&&A.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(A){if(this.sound){if(A===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=A,e&&this.play()}}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,CI&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Ki=ka;_n([D(URL)],Ki.prototype,"clip",2);_n([D()],Ki.prototype,"playOnAwake",2);_n([D()],Ki.prototype,"preload",2);_n([D()],Ki.prototype,"loop",1);_n([D()],Ki.prototype,"spatialBlend",1);_n([D()],Ki.prototype,"minDistance",1);_n([D()],Ki.prototype,"maxDistance",1);_n([D()],Ki.prototype,"volume",1);_n([D()],Ki.prototype,"rollOffMode",2);_n([D()],Ki.prototype,"playInBackground",2);const _q={type:"change"},dk={type:"start"},Hq={type:"end"},ff=new Uo,Oq=new MI,zgA=Math.cos(70*Bg.DEG2RAD);let ZgA=class extends Rg{constructor(A,e){super(),this.object=A,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new y,this.cursor=new y,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:iB.ROTATE,MIDDLE:iB.DOLLY,RIGHT:iB.PAN},this.touches={ONE:gB.ROTATE,TWO:gB.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(P){P.addEventListener("keydown",De),this._domElementKeyEvents=P},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",De),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(_q),t.update(),I=g.NONE},this.update=function(){const P=new y,_A=new RA().setFromUnitVectors(A.up,new y(0,1,0)),IA=_A.clone().invert(),j=new y,WA=new RA,$A=new y,ae=2*Math.PI;return function(bt=null){const St=t.object.getWorldPosition(A.position);P.copy(St).sub(t.target),P.applyQuaternion(_A),s.setFromVector3(P),t.autoRotate&&I===g.NONE&&O(K(bt)),t.enableDamping?(s.theta+=n.theta*t.dampingFactor,s.phi+=n.phi*t.dampingFactor):(s.theta+=n.theta,s.phi+=n.phi);let ut=t.minAzimuthAngle,Ot=t.maxAzimuthAngle;isFinite(ut)&&isFinite(Ot)&&(ut<-Math.PI?ut+=ae:ut>Math.PI&&(ut-=ae),Ot<-Math.PI?Ot+=ae:Ot>Math.PI&&(Ot-=ae),ut<=Ot?s.theta=Math.max(ut,Math.min(Ot,s.theta)):s.theta=s.theta>(ut+Ot)/2?Math.max(ut,s.theta):Math.min(Ot,s.theta)),s.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,s.phi)),s.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(B,t.dampingFactor):t.target.add(B),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor),t.zoomToCursor&&G||t.object.isOrthographicCamera?s.radius=nA(s.radius):(t.enableDamping?a=Bg.lerp(a,C,t.dampingFactor):a=C,s.radius=nA(s.radius*a)),P.setFromSpherical(s),P.applyQuaternion(IA),St.copy(t.target).add(P),t.object.parent?t.object.parent.worldToLocal(St):t.object.position.copy(St),t.object.lookAt(t.target),t.enableDamping===!0?(n.theta*=1-t.dampingFactor,n.phi*=1-t.dampingFactor,B.multiplyScalar(1-t.dampingFactor)):(n.set(0,0,0),B.set(0,0,0));let lt=!1;if(t.zoomToCursor&&G){let Ji=null;if(t.object.isPerspectiveCamera){const Bi=P.length();Ji=nA(Bi*C);const Lo=Bi-Ji;t.object.position.addScaledVector(S,Lo),t.object.updateMatrixWorld()}else if(t.object.isOrthographicCamera){const Bi=new y(m.x,m.y,0);Bi.unproject(t.object),t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/C)),t.object.updateProjectionMatrix(),lt=!0;const Lo=new y(m.x,m.y,0);Lo.unproject(t.object),t.object.position.sub(Lo).add(Bi),t.object.updateMatrixWorld(),Ji=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;Ji!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(Ji).add(t.object.position):(ff.origin.copy(t.object.position),ff.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(ff.direction))<zgA?A.lookAt(t.target):(Oq.setFromNormalAndCoplanarPoint(t.object.up,t.target),ff.intersectPlane(Oq,t.target))))}else t.object.isOrthographicCamera&&(lt=C!==1,lt&&(t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/C)),t.object.updateProjectionMatrix()));return C=1,G=!1,lt||j.distanceToSquared(t.object.position)>o||8*(1-WA.dot(t.object.quaternion))>o||$A.distanceToSquared(t.target)>0?(t.dispatchEvent(_q),j.copy(t.object.position),WA.copy(t.object.quaternion),$A.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",he),t.domElement.removeEventListener("pointerdown",F),t.domElement.removeEventListener("pointercancel",MA),t.domElement.removeEventListener("wheel",Ie),t.domElement.removeEventListener("pointermove",aA),t.domElement.removeEventListener("pointerup",MA),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",De),t._domElementKeyEvents=null)};const t=this,g={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let I=g.NONE;const o=1e-6,s=new _G,n=new _G;let C=1,a=1;const B=new y,Q=new gA,E=new gA,c=new gA,h=new gA,u=new gA,l=new gA,d=new gA,p=new gA,f=new gA,S=new y,m=new gA;let G=!1;const R=[],w={};let k=!1;function K(P){return P!==null?2*Math.PI/60*t.autoRotateSpeed*P:2*Math.PI/60/60*t.autoRotateSpeed}function T(P){const _A=Math.abs(P*.01);return Math.pow(.95,t.zoomSpeed*_A)}function O(P){n.theta-=P}function b(P){n.phi-=P}const _=function(){const P=new y;return function(IA,j){P.setFromMatrixColumn(j,0),P.multiplyScalar(-IA),B.add(P)}}(),J=function(){const P=new y;return function(IA,j){t.screenSpacePanning===!0?P.setFromMatrixColumn(j,1):(P.setFromMatrixColumn(j,0),P.crossVectors(t.object.up,P)),P.multiplyScalar(IA),B.add(P)}}(),L=function(){const P=new y,_A=new y;return function(j,WA){const $A=t.domElement;if(t.object.isPerspectiveCamera){t.object.getWorldPosition(_A),P.copy(_A).sub(t.target);let ae=P.length();ae*=Math.tan(t.object.fov/2*Math.PI/180),_(2*j*ae/$A.clientHeight,t.object.matrixWorld),J(2*WA*ae/$A.clientHeight,t.object.matrixWorld)}else t.object.isOrthographicCamera?(_(j*(t.object.right-t.object.left)/t.object.zoom/$A.clientWidth,t.object.matrixWorld),J(WA*(t.object.top-t.object.bottom)/t.object.zoom/$A.clientHeight,t.object.matrixWorld)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function H(P){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?C/=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Z(P){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?C*=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function X(P,_A){if(!t.zoomToCursor)return;G=!0;const IA=t.domElement.getBoundingClientRect(),j=P-IA.left,WA=_A-IA.top,$A=IA.width,ae=IA.height;m.x=j/$A*2-1,m.y=-(WA/ae)*2+1,S.set(m.x,m.y,1).unproject(t.object).sub(t.object.position).normalize()}function nA(P){return Math.max(t.minDistance,Math.min(t.maxDistance,P))}function lA(P){Q.set(P.clientX,P.clientY)}function SA(P){X(P.clientX,P.clientX),d.set(P.clientX,P.clientY)}function qA(P){h.set(P.clientX,P.clientY)}function ZA(P){E.set(P.clientX,P.clientY),c.subVectors(E,Q).multiplyScalar(t.rotateSpeed);const _A=t.domElement;O(2*Math.PI*c.x/_A.clientHeight),b(2*Math.PI*c.y/_A.clientHeight),Q.copy(E),t.update()}function CA(P){p.set(P.clientX,P.clientY),f.subVectors(p,d),f.y>0?H(T(f.y)):f.y<0&&Z(T(f.y)),d.copy(p),t.update()}function DA(P){u.set(P.clientX,P.clientY),l.subVectors(u,h).multiplyScalar(t.panSpeed),L(l.x,l.y),h.copy(u),t.update()}function TA(P){X(P.clientX,P.clientY),P.deltaY<0?Z(T(P.deltaY)):P.deltaY>0&&H(T(P.deltaY)),t.update()}function OA(P){let _A=!1;switch(P.code){case t.keys.UP:P.ctrlKey||P.metaKey||P.shiftKey?b(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(0,t.keyPanSpeed),_A=!0;break;case t.keys.BOTTOM:P.ctrlKey||P.metaKey||P.shiftKey?b(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(0,-t.keyPanSpeed),_A=!0;break;case t.keys.LEFT:P.ctrlKey||P.metaKey||P.shiftKey?O(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(t.keyPanSpeed,0),_A=!0;break;case t.keys.RIGHT:P.ctrlKey||P.metaKey||P.shiftKey?O(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(-t.keyPanSpeed,0),_A=!0;break}_A&&(P.preventDefault(),t.update())}function XA(P){if(R.length===1)Q.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);Q.set(IA,j)}}function HA(P){if(R.length===1)h.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);h.set(IA,j)}}function JA(P){const _A=ue(P),IA=P.pageX-_A.x,j=P.pageY-_A.y,WA=Math.sqrt(IA*IA+j*j);d.set(0,WA)}function V(P){t.enableZoom&&JA(P),t.enablePan&&HA(P)}function fA(P){t.enableZoom&&JA(P),t.enableRotate&&XA(P)}function LA(P){if(R.length==1)E.set(P.pageX,P.pageY);else{const IA=ue(P),j=.5*(P.pageX+IA.x),WA=.5*(P.pageY+IA.y);E.set(j,WA)}c.subVectors(E,Q).multiplyScalar(t.rotateSpeed);const _A=t.domElement;O(2*Math.PI*c.x/_A.clientHeight),b(2*Math.PI*c.y/_A.clientHeight),Q.copy(E)}function wA(P){if(R.length===1)u.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);u.set(IA,j)}l.subVectors(u,h).multiplyScalar(t.panSpeed),L(l.x,l.y),h.copy(u)}function VA(P){const _A=ue(P),IA=P.pageX-_A.x,j=P.pageY-_A.y,WA=Math.sqrt(IA*IA+j*j);p.set(0,WA),f.set(0,Math.pow(p.y/d.y,t.zoomSpeed)),H(f.y),d.copy(p);const $A=(P.pageX+_A.x)*.5,ae=(P.pageY+_A.y)*.5;X($A,ae)}function re(P){t.enableZoom&&VA(P),t.enablePan&&wA(P)}function q(P){t.enableZoom&&VA(P),t.enableRotate&&LA(P)}function F(P){t.enabled!==!1&&(R.length===0&&(t.domElement.addEventListener("pointermove",aA),t.domElement.addEventListener("pointerup",MA)),le(P),P.pointerType==="touch"?UA(P):mA(P))}function aA(P){t.enabled!==!1&&(P.pointerType==="touch"?Le(P):FA(P))}function MA(P){switch(te(P),R.length){case 0:t.domElement.removeEventListener("pointermove",aA),t.domElement.removeEventListener("pointerup",MA),t.dispatchEvent(Hq),I=g.NONE;break;case 1:const _A=R[0],IA=w[_A];UA({pointerId:_A,pageX:IA.x,pageY:IA.y});break}}function mA(P){let _A;switch(P.button){case 0:_A=t.mouseButtons.LEFT;break;case 1:_A=t.mouseButtons.MIDDLE;break;case 2:_A=t.mouseButtons.RIGHT;break;default:_A=-1}switch(_A){case iB.DOLLY:if(t.enableZoom===!1)return;SA(P),I=g.DOLLY;break;case iB.ROTATE:if(P.ctrlKey||P.metaKey||P.shiftKey){if(t.enablePan===!1)return;qA(P),I=g.PAN}else{if(t.enableRotate===!1)return;lA(P),I=g.ROTATE}break;case iB.PAN:if(P.ctrlKey||P.metaKey||P.shiftKey){if(t.enableRotate===!1)return;lA(P),I=g.ROTATE}else{if(t.enablePan===!1)return;qA(P),I=g.PAN}break;default:I=g.NONE}I!==g.NONE&&t.dispatchEvent(dk)}function FA(P){switch(I){case g.ROTATE:if(t.enableRotate===!1)return;ZA(P);break;case g.DOLLY:if(t.enableZoom===!1)return;CA(P);break;case g.PAN:if(t.enablePan===!1)return;DA(P);break}}function Ie(P){t.enabled===!1||t.enableZoom===!1||I!==g.NONE||(P.preventDefault(),t.dispatchEvent(dk),TA(YA(P)),t.dispatchEvent(Hq))}function YA(P){const _A=P.deltaMode,IA={clientX:P.clientX,clientY:P.clientY,deltaY:P.deltaY};switch(_A){case 1:IA.deltaY*=16;break;case 2:IA.deltaY*=100;break}return P.ctrlKey&&!k&&(IA.deltaY*=10),IA}function ee(P){P.key==="Control"&&(k=!0,t.domElement.getRootNode().addEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ce(P){P.key==="Control"&&(k=!1,t.domElement.getRootNode().removeEventListener("keyup",Ce,{passive:!0,capture:!0}))}function De(P){t.enabled===!1||t.enablePan===!1||OA(P)}function UA(P){switch(PA(P),R.length){case 1:switch(t.touches.ONE){case gB.ROTATE:if(t.enableRotate===!1)return;XA(P),I=g.TOUCH_ROTATE;break;case gB.PAN:if(t.enablePan===!1)return;HA(P),I=g.TOUCH_PAN;break;default:I=g.NONE}break;case 2:switch(t.touches.TWO){case gB.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;V(P),I=g.TOUCH_DOLLY_PAN;break;case gB.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;fA(P),I=g.TOUCH_DOLLY_ROTATE;break;default:I=g.NONE}break;default:I=g.NONE}I!==g.NONE&&t.dispatchEvent(dk)}function Le(P){switch(PA(P),I){case g.TOUCH_ROTATE:if(t.enableRotate===!1)return;LA(P),t.update();break;case g.TOUCH_PAN:if(t.enablePan===!1)return;wA(P),t.update();break;case g.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;re(P),t.update();break;case g.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;q(P),t.update();break;default:I=g.NONE}}function he(P){t.enabled!==!1&&P.preventDefault()}function le(P){R.push(P.pointerId)}function te(P){delete w[P.pointerId];for(let _A=0;_A<R.length;_A++)if(R[_A]==P.pointerId){R.splice(_A,1);return}}function PA(P){let _A=w[P.pointerId];_A===void 0&&(_A=new gA,w[P.pointerId]=_A),_A.set(P.pageX,P.pageY)}function ue(P){const _A=P.pointerId===R[0]?R[1]:R[0];return w[_A]}t.domElement.addEventListener("contextmenu",he),t.domElement.addEventListener("pointerdown",F),t.domElement.addEventListener("pointercancel",MA),t.domElement.addEventListener("wheel",Ie,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",ee,{passive:!0,capture:!0}),this.update()}};class cP extends uA{constructor(A,e,t,g=128){if(e<=0||t<=0||g<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const I=new Os(t,2*g,g);I.scale(1,1,-1);const o=I.getAttribute("position"),s=new y;for(let n=0;n<o.count;++n)if(s.fromBufferAttribute(o,n),s.y<0){const C=-e*3/2,a=s.y<C?-e/s.y:1-s.y*s.y/(3*C*C);s.multiplyScalar(a),s.toArray(o.array,3*n)}o.needsUpdate=!0,super(I,new rt({map:A,depthWrite:!1}))}}const mD=Symbol("cameraController");function XgA(i){return i[mD]}function Pq(i,A,e){e?i[mD]=A:i[mD]===A&&(i[mD]=null)}const Wq=Symbol("camera autofit");function $gA(i){return i[Wq]===void 0?!0:i[Wq]!==!1}var AIA=Object.defineProperty,eIA=Object.getOwnPropertyDescriptor,tIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?eIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&AIA(A,e,g),g};class uu extends NA{constructor(){super(...arguments);r(this,"constraintActive",!0);r(this,"locked",!1);r(this,"sources",[])}}tIA([D(pA)],uu.prototype,"sources",2);function iIA(i){Au(i,Xi.ContextCreated)}function gIA(i){Au(i,eg.Start)}function hP(i){Au(i,eg.Update)}function IIA(i){Au(i,eg.OnBeforeRender)}class NB{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static sizeOf(){return 12}static createVec3(A,e,t,g){return A.prep(4,12),A.writeFloat32(g),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class lP{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}position(A){return(A||new NB).__init(this.bb_pos,this.bb)}rotation(A){return(A||new NB).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new NB).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,t,g,I,o,s,n,C,a){return A.prep(4,36),A.prep(4,12),A.writeFloat32(a),A.writeFloat32(C),A.writeFloat32(n),A.prep(4,12),A.writeFloat32(s),A.writeFloat32(o),A.writeFloat32(I),A.prep(4,12),A.writeFloat32(g),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class DC{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedTransformModel(A,e){return(e||new DC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+HU),(e||new DC).__init(A.readInt32(A.position())+A.position(),A)}guid(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}fast(){const A=this.bb.__offset(this.bb_pos,6);return A?!!this.bb.readInt8(this.bb_pos+A):!1}transform(A){const e=this.bb.__offset(this.bb_pos,8);return e?(A||new lP).__init(this.bb_pos+e,this.bb):null}dontSave(){const A=this.bb.__offset(this.bb_pos,10);return A?!!this.bb.readInt8(this.bb_pos+A):!1}static startSyncedTransformModel(A){A.startObject(4)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addFast(A,e){A.addFieldInt8(1,+e,0)}static addTransform(A,e){A.addFieldStruct(2,e,0)}static addDontSave(A,e){A.addFieldInt8(3,+e,0)}static endSyncedTransformModel(A){return A.endObject()}static finishSyncedTransformModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedTransformModelBuffer(A,e){A.finish(e,void 0,!0)}}var fg=(i=>(i[i.Average=0]="Average",i[i.Multiply=1]="Multiply",i[i.Minimum=2]="Minimum",i[i.Maximum=3]="Maximum",i))(fg||{}),dS=(i=>(i[i.Discrete=0]="Discrete",i[i.Continuous=1]="Continuous",i))(dS||{}),qi=(i=>(i[i.None=0]="None",i[i.FreezePositionX=2]="FreezePositionX",i[i.FreezePositionY=4]="FreezePositionY",i[i.FreezePositionZ=8]="FreezePositionZ",i[i.FreezePosition=14]="FreezePosition",i[i.FreezeRotationX=16]="FreezeRotationX",i[i.FreezeRotationY=32]="FreezeRotationY",i[i.FreezeRotationZ=64]="FreezeRotationZ",i[i.FreezeRotation=112]="FreezeRotation",i[i.FreezeAll=126]="FreezeAll",i))(qi||{}),yE=(i=>(i[i.None=0]="None",i[i.X=2]="X",i[i.Y=4]="Y",i[i.Z=8]="Z",i[i.All=-1]="All",i))(yE||{});const $g=function(i,A){return function(e,t,g){oIA(e,t,g,i,A)}};function oIA(i,A,e,t,g){if(!g&&!t&&!i.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",i,A,e),Ui("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,ss.Error);return}let I="";if(typeof A=="string"?I=A:I=A.name,i.__internalAwake){const o=Symbol(I),s=i.__internalAwake;i.__internalAwake=function(){var n;if(!this.onValidate){Ge()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((n=i.constructor)==null?void 0:n.name)+'"');return}if(this[o]===void 0){this[o]=this[I];const C=this[I];if(C instanceof gA||C instanceof y||C instanceof oe||C instanceof RA){const a=this[I];Tw(a,()=>{this.onValidate(I)})}Object.defineProperty(this,I,{set:function(a){var B;if(this[nM]===!0)this[o]=a;else{t==null||t.call(this,a);const Q=this[o];this[o]=a,(B=this.onValidate)==null||B.call(this,I,Q)}},get:function(){return g==null||g.call(this),this[o]}})}s.call(this)}}}const sIA=function(i){return function(A,e,t){let g="";typeof e=="string"?g=e:g=e.name;const I=i.prototype,o=Object.getOwnPropertyDescriptor(I,g);if(!(o!=null&&o.value)){console.warn("Can not apply prefix: type does not have method named",e,i);return}const s=o.value,n=A[g];Object.defineProperty(I,g,{value:function(...C){const a=n==null?void 0:n.call(this,...C);if(a instanceof Promise){a.then(B=>{if(B!==!1)return s.call(this,...C)});return}if(a!==!1)return s.call(this,...C)}})}};var nIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,hs=(i,A,e,t)=>{for(var g=t>1?void 0:t?CIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&nIA(A,e,g),g};class aIA{constructor(A,e){r(this,"positionChanged",!1);r(this,"rotationChanged",!1);r(this,"position");r(this,"quaternion");r(this,"_positionKeys",["x","y","z"]);r(this,"_quaternionKeys",["_x","_y","_z","_w"]);r(this,"mute",!1);r(this,"context");r(this,"obj");r(this,"_positionWatch");r(this,"_rotationWatch");this.context=e,this.obj=A}get isDirty(){return this.positionChanged||this.rotationChanged}reset(A=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,A){if(this.position)for(const e of this._positionKeys)delete this.position[e];if(this.quaternion)for(const e of this._quaternionKeys)delete this.quaternion[e]}}syncValues(){for(const A of this._positionKeys)this.position[A]=this.obj.position[A];for(const A of this._quaternionKeys)this.quaternion[A]=this.obj.quaternion[A]}applyValues(){if(this.positionChanged&&this.position)for(const A of this._positionKeys){const e=this.position[A];e!==void 0&&(this.obj.position[A]=e)}if(this.rotationChanged&&this.quaternion)for(const A of this._quaternionKeys){const e=this.quaternion[A];e!==void 0&&(this.obj.quaternion[A]=e)}}start(A,e){this.reset(),A&&(this._positionWatch||(this._positionWatch=new UC(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.position[o];Math.abs(s-I)<1e-5||(this.position[o]=I,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new UC(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.quaternion[o];Math.abs(s-I)<1e-5||(this.quaternion[o]=I,this.rotationChanged=!0)}));const t=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),g=new GA;this.obj.matrixWorld.multiplyMatrices=(I,o)=>{var s;return(s=this.context.physics.engine)!=null&&s.isUpdating||this.mute||g.equals(I)||(this.positionChanged=!0,this.rotationChanged=!0,g.copy(I)),t(I,o)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var AG;const XM=(AG=class extends NA{constructor(){super(...arguments);r(this,"autoMass",!0);r(this,"_mass",0);r(this,"useGravity",!0);r(this,"constraints",qi.None);r(this,"isKinematic",!1);r(this,"drag",0);r(this,"angularDrag",1);r(this,"detectCollisions",!0);r(this,"sleepThreshold",.01);r(this,"collisionDetectionMode",dS.Discrete);r(this,"_gravityScale",1);r(this,"dominanceGroup",0);r(this,"_propertiesChanged",!1);r(this,"_currentVelocity",new y);r(this,"_smoothedVelocity",new y);r(this,"_smoothedVelocityGetter",new y);r(this,"_lastPosition",new y);r(this,"_watch")}set mass(A){A!==this._mass&&(this._mass=A,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var A,e;return this.autoMass?((e=(A=this.context.physics.engine)==null?void 0:A.getBody(this))==null?void 0:e.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&qi.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&qi.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&qi.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&qi.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&qi.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&qi.FreezeRotationZ)!==0}set lockPositionX(A){A?this.constraints|=qi.FreezePositionX:this.constraints&=~qi.FreezePositionX}set lockPositionY(A){A?this.constraints|=qi.FreezePositionY:this.constraints&=~qi.FreezePositionY}set lockPositionZ(A){A?this.constraints|=qi.FreezePositionZ:this.constraints&=~qi.FreezePositionZ}set lockRotationX(A){A?this.constraints|=qi.FreezeRotationX:this.constraints&=~qi.FreezeRotationX}set lockRotationY(A){A?this.constraints|=qi.FreezeRotationY:this.constraints&=~qi.FreezeRotationY}set lockRotationZ(A){A?this.constraints|=qi.FreezeRotationZ:this.constraints&=~qi.FreezeRotationZ}set gravityScale(A){this._gravityScale=A}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new aIA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),eg.LateUpdate)}onDisable(){var A,e;(A=this._watch)==null||A.stop(),(e=this.context.physics.engine)==null||e.removeBody(this)}onDestroy(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){var A,e,t,g;for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,(A=this.context.physics.engine)==null||A.updateProperties(this)),(e=this._watch)!=null&&e.isDirty?(this._watch.mute=!0,this._watch.applyValues(),(t=this.context.physics.engine)==null||t.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):(g=this._watch)==null||g.syncValues(),this.captureVelocity(),yield}teleport(A,e=!0){var t;(t=this._watch)==null||t.reset(!0),e?this.gameObject.position.set(A.x,A.y,A.z):this.setWorldPosition(A.x,A.y,A.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(A=!0){var e;(e=this.context.physics.engine)==null||e.resetForces(this,A)}resetTorques(A=!0){var e;(e=this.context.physics.engine)==null||e.resetTorques(this,A)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var A;(A=this.context.physics.engine)==null||A.wakeup(this)}get isSleeping(){var A;return(A=this.context.physics.engine)==null?void 0:A.isSleeping(this)}updateProperties(){var A;return this._propertiesChanged=!1,(A=this.context.physics.engine)==null?void 0:A.updateProperties(this)}applyForce(A,e,t=!0){var g;this._propertiesChanged&&this.updateProperties(),(g=this.context.physics.engine)==null||g.addForce(this,A,t)}applyImpulse(A,e=!0){var t;this._propertiesChanged&&this.updateProperties(),(t=this.context.physics.engine)==null||t.applyImpulse(this,A,e)}setForce(A,e,t,g=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,g),typeof A=="number"?(e??(e=0),t??(t=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:A,y:e,z:t},g)):(s=this.context.physics.engine)==null||s.addForce(this,A,g)}getVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(A,e,t,g=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,g);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:A,y:e,z:t},g)}getAngularVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getAngularVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(A,e,t,g=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,g);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:A,y:e,z:t},g)}setTorque(A,e,t){this.setAngularVelocity(A,e,t)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(A=null){}captureVelocity(){const A=Je(this.gameObject);XM.tempPosition.copy(A);const e=A.sub(this._lastPosition);this._lastPosition.copy(XM.tempPosition),this._smoothedVelocity.lerp(e,this.context.time.deltaTime/.1)}},r(AG,"tempPosition",new y),AG);let ei=XM;hs([$g()],ei.prototype,"autoMass",2);hs([D()],ei.prototype,"mass",1);hs([$g(),D()],ei.prototype,"useGravity",2);hs([$g(),D()],ei.prototype,"constraints",2);hs([$g(),D()],ei.prototype,"isKinematic",2);hs([$g(),D()],ei.prototype,"drag",2);hs([$g(),D()],ei.prototype,"angularDrag",2);hs([$g(),D()],ei.prototype,"detectCollisions",2);hs([$g(),D()],ei.prototype,"sleepThreshold",2);hs([$g(),D()],ei.prototype,"collisionDetectionMode",2);hs([$g()],ei.prototype,"_gravityScale",2);hs([$g()],ei.prototype,"dominanceGroup",2);const nC=oA("debugsync"),cd="STRS";PU(cd,DC.getRootAsSyncedTransformModel);const tn=new eu;function dP(i,A,e=!0){tn.clear();const t=tn.createString(i);DC.startSyncedTransformModel(tn),DC.addGuid(tn,t),DC.addFast(tn,e);const g=A.worldPosition,I=A.worldEuler,o=A.gameObject.scale;DC.addTransform(tn,lP.createTransform(tn,g.x,g.y,g.z,I.x,I.y,I.z,o.x,o.y,o.z));const s=DC.endSyncedTransformModel(tn);return tn.finish(s,cd),tn.asUint8Array()}let $M=0,Sl=0;hP(i=>{var t;const e=((t=i.connection.currentServerUrl)==null?void 0:t.includes("glitch"))?10:40;Sl=Math.floor($M/e),$M=0,nC&&Sl>0&&console.log("Sync Transform Fast Interval",Sl)});class sr extends NA{constructor(){super(...arguments);r(this,"overridePhysics",!0);r(this,"interpolatePosition",!0);r(this,"interpolateRotation",!0);r(this,"fastMode",!1);r(this,"syncDestroy",!1);r(this,"_model",null);r(this,"_needsUpdate",!0);r(this,"rb",null);r(this,"_wasKinematic",!1);r(this,"_receivedDataBefore",!1);r(this,"_targetPosition");r(this,"_targetRotation");r(this,"_receivedFastUpdate",!1);r(this,"_shouldRequestOwnership",!1);r(this,"joinedRoomCallback",null);r(this,"receivedDataCallback",null);r(this,"tempEuler",new Og);r(this,"receivedUpdate",!1);r(this,"lastWorldPos");r(this,"lastWorldRotation")}requestOwnership(){nC&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}hasOwnership(){var e;return((e=this._model)==null?void 0:e.hasOwnership)??void 0}isOwned(){var e;return(e=this._model)==null?void 0:e.isOwned}awake(){nC&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new y,this._targetRotation=new RA,this.lastWorldPos=new y,this.lastWorldRotation=new RA,this.rb=BA.getComponentInChildren(this.gameObject,ei),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new XU(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(dt.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(cd,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&EO(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(dt.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(cd,this.receivedDataCallback)}tryGetLastState(){const e=this.context.connection.tryGetState(this.guid);e&&this.onReceivedData(e)}onReceivedData(e){var t;if(!this.destroyed&&typeof e.guid=="function"&&e.guid()===this.guid){nC&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const g=e.transform();if(g){Ls.markDirty(this.gameObject,!0);const I=g.position();I&&(this.interpolatePosition&&((t=this._targetPosition)==null||t.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=g.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&vN(this.gameObject,this.tempEuler))}this._receivedDataBefore=!0}}onEnable(){this.lastWorldPos.copy(this.worldPosition),this.lastWorldRotation.copy(this.worldQuaternion),this._needsUpdate=!0,this._model&&this._model.updateIsOwned()}onDisable(){this._model&&this._model.freeOwnership()}onBeforeRender(){if(!this.activeAndEnabled||!this.context.connection.isConnected)return;if(!this.context.connection.isInRoom||!this._model){nC&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const e=this.worldPosition,t=this.worldQuaternion;if(this._model.isOwned&&!this.receivedUpdate){const o=e.distanceTo(this.lastWorldPos),s=t.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(nC&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastWorldPos),this.worldPosition=this.lastWorldPos,e.copy(this.lastWorldPos),this.worldQuaternion=this.lastWorldRotation,t.copy(this.lastWorldRotation),Ls.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const s=this._receivedFastUpdate||this.fastMode?.5:.3;let n=!1;if(this.interpolatePosition&&this._targetPosition){const C=this.worldPosition;C.lerp(this._targetPosition,s),this.worldPosition=C,n=!0}if(this.interpolateRotation&&this._targetRotation){const C=this.worldQuaternion;C.slerp(this._targetRotation,s),this.worldQuaternion=C,n=!0}n&&Ls.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastWorldPos.copy(e),this.lastWorldRotation.copy(t),!this._model)return;if(!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership){this.rb&&(this.rb.isKinematic=this._model.isOwned??!1,this.rb.setVelocity(0,0,0));return}this.rb&&(this._wasKinematic!==void 0&&(nC&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic),this.gameObject.position.distanceTo(new y(0,0,0))>1e3&&(nC&&console.log("RESET",this.name),this.gameObject.position.set(0,1,0),this.rb.setVelocity(0,0,0)));const g=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%g===0||I)){if($M++,I&&Sl>0&&this.context.time.frameCount%Sl!==0)return;nC&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this.overridePhysics&&this.rb,this._needsUpdate=!1;const o=dP(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const rIA=oA("debugshadowcomponents");MN.prototype.interactable={get(){return this.interactive},set(i){this.interactable=i}};const es=Symbol("shadowDomOwner");class _s extends NA{constructor(){super(...arguments);r(this,"_shadowComponent",null);r(this,"_controlsChildLayout",!0);r(this,"_root");r(this,"_parentComponent")}isRoot(){var e;return((e=this.Root)==null?void 0:e.gameObject)===this.gameObject}get canvas(){const e=this.Root;return e!=null&&e.isCanvas?e:null}get Canvas(){return this.canvas}markDirty(){eo.markUIDirty(this.context)}get shadowComponent(){return this._shadowComponent}set shadowComponent(e){this._shadowComponent=e}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(e){this._controlsChildLayout=e,this.shadowComponent&&(this.shadowComponent.autoLayout=e)}get Root(){return this._root===void 0&&(this._root=BA.getComponentInParent(this.gameObject,pu)),this._root}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0}onEnable(){super.onEnable()}addShadowComponent(e,t){var o;this.removeShadowComponent();const g=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=BA.getComponentInParent(g,_s),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`,this);return}e.name=this.name+" ("+(this.constructor.name??"UI")+")",e.autoLayout=this._parentComponent.controlsChildLayout,e[es]=this,this.setShadowComponentOwner(e);let I=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(e);else{const s=this._parentComponent.shadowComponent;s&&(s==null||s.add(e),I=!0)}this.shadowComponent=e,t&&t.shadowComponent&&this.shadowComponent&&t.shadowComponent.add(this.shadowComponent),$d&&e.add(new Cs(.5)),this.onAfterAddedToScene(),I&&X2(),rIA&&console.log(this.shadowComponent)}setShadowComponentOwner(e){if(e&&(e[es]===void 0||e[es]===this)&&(e[es]=this,e.children))for(const t of e.children)this.setShadowComponentOwner(t)}traverseOwnedShadowComponents(e,t,g){if(e&&e[es]===t){g(e);for(const I of e.children)this.traverseOwnedShadowComponents(I,t,g)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(e){this.shadowComponent&&(this.shadowComponent.interactable=e)}}class pu extends _s{awake(){super.awake()}}class Fc{constructor(A,e){r(this,"event");r(this,"button");r(this,"buttonName");r(this,"_used",!1);r(this,"_propagationStopped",!1);r(this,"z__pointer_ctured",!1);r(this,"z__pointer_cture_rleased",!1);r(this,"inputSource");r(this,"object");r(this,"point");r(this,"normal");r(this,"face");r(this,"distance");r(this,"instanceId");r(this,"isDown");r(this,"isUp");r(this,"isPressed");r(this,"isClick");r(this,"isDoubleClick");r(this,"input");this.event=e,this.input=A,this.button=e.button}get deviceIndex(){return this.event.deviceIndex}get pointerId(){return this.event.pointerId}get pressure(){return this.event.pressure}get used(){return this._used}use(){this._used||(this._used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId))}get propagationStopped(){return this._propagationStopped}stopPropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}stopImmediatePropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}setPointerCapture(){this.z__pointer_ctured=!0}releasePointerCapture(){this.z__pointer_cture_rleased=!0}get mode(){return this.event.mode}clone(){const A=new Fc(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function AR(i,A){return BA.foreachComponent(i,t=>{if(!t.enabled)return;const g=t;if(A)switch(A){case"pointerdown":if(g.onPointerDown)return!0;break;case"pointerup":if(g.onPointerUp||g.onPointerClick)return!0;break;case"pointermove":if(g.onPointerEnter||g.onPointerExit||g.onPointerMove)return!0;break}else if(g.onPointerDown||g.onPointerUp||g.onPointerEnter||g.onPointerExit||g.onPointerClick)return!0},!1)===!0}var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,EIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?QIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&BIA(A,e,g),g};class fu extends NA{awake(){eo.createIfNoneExists(this.context)}onEnable(){var A;(A=eo.get(this.context))==null||A.register(this)}onDisable(){var A;(A=eo.get(this.context))==null||A.unregister(this)}}class Mo extends fu{constructor(){super(...arguments);r(this,"targets",null);r(this,"raycastHits",[]);r(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Bs),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=I=>I instanceof qs?"continue in children":t?t(I):!0);const g=this.context.physics.raycast(e);return e.testObject=t,g}}EIA([D()],Mo.prototype,"ignoreSkinnedMeshes",2);class uS extends Mo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class hd extends fu{performRaycast(A){if(!pe.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.01;return this.context.physics.sphereOverlap(e,t)}}class pS{static getObject(A){const e=A[es];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const g=OB(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&(g==null?void 0:g.isGraphic)===!0&&(e.graphic=g),!((g==null?void 0:g.raycastTarget)===!1||(g==null?void 0:g.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=OB(A,t=>{const g=t;if(g.blocksRaycasts!==void 0&&g.interactable!==void 0)return g},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function $N(i){const A=i[es];return A||(i.parent?$N(i.parent):null)}function cIA(i){return i.isUI===!0||typeof i[es]=="object"}function Ry(i,A){if(!i)return;const e=i.material;if((e==null?void 0:e.isMaterial)===!0){const t=i.parent;t&&t.isText,e.side=A.doubleSided??!0?wt:Pg,e.shadowSide=A.doubleSided?wt:Pg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of i.children)Ry(t,A)}function aE(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const t=Proxy.revocable(i[A],{set(o,s,n,C){const a=o[s],B=Reflect.set(o,s,n,C);return e(n,a),B}}),g=t.revoke,I=i[A];return t.revoke=()=>{i[A]=I,g()},i[A]=t.proxy,t}const jq=Symbol("Scheduled action");function hIA(i,A,e=eg.OnBeforeRender){let t=i[jq];t||(t=i[jq]={});const g=A.name;t[e]||(t[e]={});const I=t[e];if(I[g])return;function*s(){A==null||A.call(i),I[g]=null}const n=i.startCoroutine(s(),e);I[g]=n}const CC=oA("debugeventsystem");var eR=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(eR||{});const Bn=class extends NA{constructor(){super();r(this,"raycaster",[]);r(this,"_handleInputFn");r(this,"pressedByID",new Map);r(this,"hoveredByID",new Map);r(this,"_sortedHits",[]);r(this,"_testObjectsCache",new Map);r(this,"_currentlyActiveRaycaster",null);r(this,"_currentPointerEventName",null);r(this,"shouldRaycastObject",e=>{var I;let t=null;if(cIA(e)&&(t=(I=e[es])==null?void 0:I.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let o=AR(e,this._currentPointerEventName);if(!o&&t&&(o=AR(t,this._currentPointerEventName)),o){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});r(this,"_sortingBuffer",[]);r(this,"_noDepthTestingResults",[]);r(this,"out",{});r(this,"_capturedPointer",{});r(this,"pointerEnterSymbol",Symbol("pointerEnter"));r(this,"pointerExitSymbol",Symbol("pointerExit"));r(this,"currentActiveMeshUIComponents",[]);Bn.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Bn.systems.length<=0&&Bn.systems.push(...BA.findObjectsOfType(Bn,e)));for(const g of Bn.systems)if(g.context===e)return;const t=new pA;BA.addNewComponent(t,Bn),e.scene.add(t)}static get systems(){const e=ve.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,g=!1){qa.update(e,t,g)}static markUIDirty(e){qa.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Bn.systems.splice(Bn.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!BA.findObjectOfType(fu,this.context)){const t=BA.addNewComponent(this.context.scene,Mo);this.raycaster.push(t),(Ge()||CC)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var g,I;const t=(g=this.raycaster)==null?void 0:g.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(si.PointerDown,this._handleInputFn),this.context.input.addEventListener(si.PointerUp,this._handleInputFn),this.context.input.addEventListener(si.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(si.PointerDown,this._handleInputFn),this.context.input.removeEventListener(si.PointerUp,this._handleInputFn),this.context.input.removeEventListener(si.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(e){if(e===void 0||e.propagationStopped)return;const t=new Fc(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==si.PointerDown,t.isUp=e.type==si.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),CC&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const g=new Bs;e.ray?g.ray=e.ray:g.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const I=this.performRaycast(g);CC&&t.isClick&&Ui("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const o={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Bs),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const g=t.performRaycast(e);this._currentlyActiveRaycaster=null,g&&g.length>0&&this._sortedHits.push(...g)}return this._sortedHits.sort((t,g)=>t.distance-g.distance),this._sortedHits}assignHitInformation(e,t){t?(e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var I;if(e!=null&&e.length){e=this.sortCandidates(e);for(const o of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,o),this.handleEventOnObject(o.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const g=this.hoveredByID.get(t.pointerId);return g&&this.propagatePointerExit(g.obj,g.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((I=this.pressedByID.get(t.pointerId))==null||I.handlers.forEach(o=>this.invokeOnPointerUp(t,o)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const g=e[t],I=g.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(g);continue}this._sortingBuffer.push(g)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&CC&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return CC&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const g=e.parent;let I=!1;const o=t.isClick??!1;let s=null;if(g&&g.isUI){const Q=(t.isPressed||t.isClick)??!1;if(g[es]){const E=g[es].gameObject;if(E){if(!pS.isInteractable(E,this.out))return!1;s=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,Q),e=E,I=!0}}if(!I&&this.handleMeshUiObjectWithoutShadowDom(g,Q))return!0}o&&CC&&console.log(this.context.time.frame,e);const n=this.hoveredByID.get(t.pointerId),C=n==null?void 0:n.obj;C!==e&&C&&this.propagatePointerExit(C,n.data,e);const B=this.hoveredByID.get(t.pointerId);if(B?(B.obj=e,B.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const Q=this.pressedByID.get(t.pointerId);Q?(Q.obj=e,Q.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(s===null||s.interactable)&&this.handleMainInteraction(e,t,C??null),!0}propagate(e,t){for(;e;)BA.foreachComponent(e,g=>{t(g)},!1),e=e.parent}handleMainInteraction(e,t,g){const I=this.pressedByID.get(t.pointerId),o=g!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),C=this.context.input.getPointerPosition(t.pointerId);s=n&&!se.approximately(n,C);break}this.propagate(e,n=>{const C=n;C.interactable!==!1&&(!C.activeAndEnabled||!C.enabled||(C.onPointerEnter&&o&&this.handlePointerEnter(C,t),t.isDown&&C.onPointerDown&&(C.onPointerDown(t),I==null||I.handlers.add(C),this.handlePointerCapture(t,C)),C.onPointerMove&&(s&&C.onPointerMove(t),this.handlePointerCapture(t,C)),t.isUp&&C.onPointerUp&&(this.invokeOnPointerUp(t,C),I==null||I.handlers.delete(C)),t.isClick&&C.onPointerClick&&C.onPointerClick(t)))}),t.isUp&&(I==null||I.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,g){this.propagate(e,I=>{if(!I.gameObject||I.destroyed)return;const o=I;if(o.onPointerExit){if(g&&this.isChild(g,I.gameObject))return;this.handlePointerExit(o,t)}})}invokeOnPointerUp(e,t){var g;(g=t.onPointerUp)==null||g.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,g,I){let o=e[g];if(I)return o&&o.includes(t)?!1:(o=o||[],o.push(t),e[g]=o,!0);{if(!o||!o.includes(t))return!1;const s=o.indexOf(t);return s!==-1&&o.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const g=e.pointerId;if(t.onPointerMove){const I=this._capturedPointer[g]||[];I.push(t),this._capturedPointer[g]=I}else Ge()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const g=e.pointerId;if(this._capturedPointer[g]){const I=this._capturedPointer[g].indexOf(t);I!==-1&&(this._capturedPointer[g].splice(I,1),CC&&console.log("released pointer capture",g,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===si.PointerMove){const g=e.pointerId,I=this._capturedPointer[g];if(I){CC&&console.log("Captured",g,I);for(let o=0;o<I.length;o++){const s=I[o];if(s.destroyed){I.splice(o,1),o--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const g=qa.updateState(e,t);return g&&this.currentActiveMeshUIComponents.push(g),g!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qa.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];qa.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?BA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let eo=Bn;r(eo,"_eventSystemMap",new Map),r(eo,"didSearchEventSystem",!1);class qa{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const g=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(g===I.frame)return;I.frame=g;let o=this.needsUpdate||g<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(CC&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:g,nextUpdate:g}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}r(qa,"lastSelected",null),r(qa,"lastUpdateFrame",[]),r(qa,"needsUpdate",!1);var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,AI=(i,A,e,t)=>{for(var g=t>1?void 0:t?dIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&lIA(A,e,g),g};const uIA=oA("debugorbit"),Df=oA("freecam"),Rh=oA("debugcamerafit"),yf=oA("smoothcam"),pIA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let uk;class ld extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class ii extends NA{constructor(){super(...arguments);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"enableKeys",!0);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"useSlerp",!0);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"autoTarget",!0);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new y);r(this,"_lookTargetEndPosition",new y);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new y);r(this,"_cameraEndPosition",new y);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didStart",!1);r(this,"targetElement",null);r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const e=BA.getComponent(this.gameObject,ti);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const g=Je(e.cam).length(),I=new y(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(I,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new Bs;t.screenPoint=new gA(0,0),t.lineThreshold=.1;const g=this.context.physics.raycast(t);g.length>0&&this.setLookTargetPosition(g[0].point,!0),Rh&&console.log("OrbitControls hits",...g)}this.autoFit&&this.fitCamera()}this._eventSystem=eo.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(eR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(eR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=BA.getComponent(this.gameObject,ti);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Pq(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const g=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new ZgA(t,g),t==null||t.quaternion.copy(I),uk===void 0&&(uk={...this._controls.keys})}this._controls&&(Df&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,xn()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?Df||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Df||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=BA.getComponent(this.gameObject,sr)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Pq(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var t,g;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new ld(this,"camera"));else{const I=se.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new ld(this,"lookat"));else{const I=se.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?uk:pIA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof yf=="number"||yf===!0){this._controls.enableDamping=!0;const I=typeof yf=="number"?yf:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Df&&((g=this.lookAtConstraint)!=null&&g.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),uIA&&Ue.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof pA))return;const t=Je(e),g=KN(e);this.setTargetFromRaycast(new Uo(t,g)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var g,I;e&&(e instanceof pA&&(e=Je(e)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof pA&&(e=Je(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){var g,I;if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const o of t)if(o.distance>0&&BA.isActiveInHierarchy(o.object)){const s=$N(o.object);if(s){const n=s.canvas;if(n!=null&&n.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const C=Je(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(I=(g=this._cameraObject)==null?void 0:g.parent)==null||I.worldToLocal(C),this.setCameraTargetPosition(C)}break}}fitCamera(e,t=1.1,g=!0){const I=this._cameraObject,o=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!I||!o)return;const s=new y,n=new y,C=new Lt;C.makeEmpty();const a=[];function B(p){let f=!0;if(p.visible&&$gA(p)!==!1&&!(p.type==="TransformControlsGizmo"||p.type==="TransformControlsPlane")&&(p instanceof HG&&(f=!1),p instanceof Yw&&(f=!1),p instanceof cP&&(f=!1),p.material instanceof Nw&&(f=!1),p instanceof uA||(f=!1),p!==I&&p.isUI!==!0)){if(f){Rh&&console.log(p.name,p.type,p);const S=p.children;p.children=a;const m=p.position,G=p.scale;if(Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn(`Object "${p.name}" has NaN values in position or scale.... will ignore it`,m,G);return}C.expandByObject(p,!0),p.children=S}for(const S of p.children)B(S)}}for(const p of e)p.updateMatrixWorld(),B(p);if(I.updateMatrixWorld(),I.updateProjectionMatrix(),C.getCenter(n),C.applyMatrix4(I.matrixWorldInverse),C.getSize(s),C.setFromCenterAndSize(n,s),Number.isNaN(s.x)||Number.isNaN(s.y)||Number.isNaN(s.z)){console.warn("Camera fit size resultet in NaN",I,C,[...e]);return}if(s.length()<=1e-10){Rh&&console.warn("Camera fit size is zero",C,[...e]);return}const Q=I.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*I.aspect)/Math.PI*360,c=s.y/(2*Math.atan(Math.PI*Q/360)),h=s.x/(2*Math.atan(Math.PI*E/360)),u=t*Math.max(c,h)+s.z/2;Rh&&console.log("Fit camera to objects",c,h,"distance",u);const l=Je(I),d=o.target.clone().sub(l).normalize().multiplyScalar(u);if(o.maxDistance=u*10,o.minDistance=u*.01,this.setLookTargetPosition(n,g),this.autoTarget=!1,I.near=u/1e3,I.far=u*100,I.updateMatrixWorld(),I.updateProjectionMatrix(),I.parent){const p=I.parent.worldToLocal(o.target.clone().sub(d));this.setCameraTargetPosition(p,g)}else console.error(`Can not fit camera ${I.name} because it has no parent`);if(Rh){const p=new HG(C);this.context.scene.add(p),bN(p,nu(I)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",f=>{f.code==="KeyF"&&this.fitCamera(e)}))}o.update()}}AI([D()],ii.prototype,"autoFit",2);AI([D()],ii.prototype,"enableRotate",2);AI([D()],ii.prototype,"autoRotate",2);AI([D()],ii.prototype,"autoRotateSpeed",2);AI([D()],ii.prototype,"enableKeys",2);AI([D()],ii.prototype,"enableDamping",2);AI([D()],ii.prototype,"dampingFactor",2);AI([D()],ii.prototype,"enableZoom",2);AI([D()],ii.prototype,"minZoom",2);AI([D()],ii.prototype,"maxZoom",2);AI([D()],ii.prototype,"enablePan",2);AI([D(uu)],ii.prototype,"lookAtConstraint",2);AI([D()],ii.prototype,"lookAtConstraint01",2);AI([D()],ii.prototype,"allowInterrupt",2);AI([D()],ii.prototype,"middleClickToFocus",2);AI([D()],ii.prototype,"doubleClickToFocus",2);AI([D()],ii.prototype,"targetLerpDuration",2);var fIA=Object.defineProperty,DIA=Object.getOwnPropertyDescriptor,Fo=(i,A,e,t)=>{for(var g=t>1?void 0:t?DIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&fIA(A,e,g),g},PB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(PB||{});const aB=oA("debugcam"),Vq=oA("debugscreenpointtoray");var jf;const tl=(jf=class extends NA{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof Ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof Ze?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof Ze){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const g=this.cam,I=tl._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Vq&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=tl._direction.set(I.x,I.y,I.z),s=Je(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new Uo(s.clone(),o.clone())}awake(){Vq&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);Ue.DrawRay(g.origin,g.direction,I,10)})}onEnable(){aB&&console.log(`Camera enabled: "${this.name}". ClearFlags=${PB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),wIA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof Ze&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ze&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new jC(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){aB&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,aB){const A=`Camera "${this.name}" clear flags: ${PB[this._clearFlags]}`;console.log(A)}switch(this._clearFlags){case 1:if(tl.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;tl.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else aB&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new yIA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;aB&&Ui("Environment blend mode: "+t+" on "+navigator.userAgent);let g=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(g=!0),e._transparent=g,g}},r(jf,"_origin",new y),r(jf,"_direction",new y),jf);let ti=tl;Fo([D()],ti.prototype,"fieldOfView",1);Fo([D()],ti.prototype,"nearClipPlane",1);Fo([D()],ti.prototype,"farClipPlane",1);Fo([D()],ti.prototype,"clearFlags",1);Fo([D()],ti.prototype,"orthographic",2);Fo([D()],ti.prototype,"orthographicSize",2);Fo([D()],ti.prototype,"ARBackgroundAlpha",2);Fo([D()],ti.prototype,"cullingMask",1);Fo([D()],ti.prototype,"backgroundBlurriness",1);Fo([D()],ti.prototype,"backgroundIntensity",1);Fo([D()],ti.prototype,"environmentIntensity",1);Fo([D(Kt)],ti.prototype,"backgroundColor",1);Fo([D(Za)],ti.prototype,"targetTexture",1);class yIA{constructor(A){r(this,"_camera");r(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(aB&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=We,this._skybox.mapping=Is,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(aB||Ge())&&fi(`Camera "${this._camera.name}" has no skybox texture`))}}function wIA(i){oA("freecam")&&i.context.mainCameraComponent===i&&BA.getOrAddComponent(i.gameObject,ii)}class Xa extends NA{constructor(){super(...arguments);r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new aT),this._listener}awake(){Ki.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||BA.getComponentInParent(this.gameObject,ti);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var SIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,fS=(i,A,e,t)=>{for(var g=t>1?void 0:t?mIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&SIA(A,e,g),g};const kIA=oA("debugsignals");class Du{constructor(){r(this,"guid")}}fS([D()],Du.prototype,"guid",2);class Kc{constructor(){r(this,"signal");r(this,"reaction")}}fS([D(Du)],Kc.prototype,"signal",2);fS([D(kg)],Kc.prototype,"reaction",2);var eG;const aC=(eG=class extends NA{constructor(){super(...arguments);r(this,"events")}static invoke(A){if(aC.receivers[A]){const e=aC.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){kIA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)aC.receivers[A.signal.guid]||(aC.receivers[A.signal.guid]=[]),aC.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(aC.receivers[A.signal.guid]){const e=aC.receivers[A.signal.guid].indexOf(this);e>=0&&aC.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(g){console.error(g)}}},r(eG,"receivers",{}),eG);let Jc=aC;fS([D(Kc)],Jc.prototype,"events",2);var Bo=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Bo||{}),rn=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(rn||{}),AF=(i=>(i.Signal="SignalEmitter",i))(AF||{});const Sn=oA("debugtimeline");class yu{constructor(){r(this,"director");r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class GIA{constructor(A){r(this,"clip");r(this,"rootPositionOffset");r(this,"rootQuaternionOffset");r(this,"rootStartPosition");r(this,"rootEndPosition");r(this,"rootStartQuaternion");r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";Sn&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new y().fromArray(o.values,0),this.rootEndPosition=new y().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Sn&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new RA().fromArray(o.values,0),this.rootEndQuaternion=new RA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Sn)){const s=new Og().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class DS extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"trackOffset");r(this,"target");r(this,"mixer");r(this,"clips",[]);r(this,"actions",[]);r(this,"_actionOffsets",[]);r(this,"_didBind",!1);r(this,"_animator",null);r(this,"_useclipOffsets",!0);r(this,"_totalOffsetPosition",new y);r(this,"_totalOffsetRotation",new RA);r(this,"_totalOffsetPosition2",new y);r(this,"_totalOffsetRotation2",new RA);r(this,"_summedPos",new y);r(this,"_tempPos",new y);r(this,"_summedRot",new RA);r(this,"_tempRot",new RA);r(this,"_clipRotQuat",new RA)}onStateChanged(){this._animator&&zq(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,B;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let n=!1,C=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(C=!0,this.createRotationInterpolant(t,e,Q));if(!n||!C){const Q=(B=this.mixer)==null?void 0:B.getRoot(),E=t.tracks[0],c=E.name.lastIndexOf("."),h=E.name.substring(0,c),u=h.substring(h.lastIndexOf(".")+1),l=Q.getObjectByName(u);if(l)if(n){if(!C){const d=t.tracks[0].name.substring(0,c)+".quaternion";Sn&&console.warn("Create quaternion track",u,l);const p=l.quaternion,f=new Jn(d,[0,t.duration],[p.x,p.y,p.z,p.w,p.x,p.y,p.z,p.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const d=h+".position";Sn&&console.warn("Create position track",u,l);const p=l.position,f=new xC(d,[0,t.duration],[p.x,p.y,p.z,p.x,p.y,p.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,Sn&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new GIA(e);this._actionOffsets.push(t)}this.target&&(this._animator=BA.getComponent(this.target,jg)??null,this._animator&&zq(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new y(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new RA(I.x,I.y,I.z,I.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new y(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new RA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,C,a,B,Q,E,c;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,g=0,I=!1,o=!1,s=0;for(let h=0;h<this.clips.length;h++){const u=this.models[h],l=this.actions[h],d=u.asset;l.weight=0;const p=e>=u.start&&e<=u.end,f=u.preExtrapolationMode,S=u.postExtrapolationMode,m=h<this.clips.length-1?this.models[h+1]:null;let G=p,R=!1;if(!G&&!I&&u.end<e&&S!==rn.None?(!m||m.start>e)&&(G=!0,I=!0):h==0&&!G&&!o&&u.start>e&&f!==rn.None&&(!m||m.start<e)&&(G=!0,R=!0,o=!0),G){let w=1;w*=this.evaluateWeight(e,h,this.models,G),w*=this.director.weight;let k=p;if(R)switch(f){case rn.Hold:break;case rn.Loop:e+=u.start,k=!0;break;default:e+=u.start,k=!0;break}let K=this.getClipTime(e,u),T=0;const O=d.duration;if(R&&f===rn.Hold&&(K=0),k){if(d.loop)for(T+=Math.floor(K/(O+1e-6));K>O;)K-=O}else if(!p&&I)switch(S){case rn.Hold:K=this.getClipTime(u.end,u);break;case rn.Loop:K%=O;break;case rn.PingPong:const J=Math.floor(K/O)%2!==0;K%=O,J&&(K=O-K);break}u.reversed===!0?l.time=l.getClip().duration-K:l.time=K,l.timeScale=0;const b=Math.max(0,w);if(l.weight=b,s+=b,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const _=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,J=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-w),t+=1;const L=this._summedPos.set(0,0,0),H=this._tempPos.set(0,0,0),Z=this._summedRot.identity(),X=this._tempRot.identity(),nA=d.rotation;nA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(nA,w));const lA=this._actionOffsets[h];if(lA.hasOffsets)for(let SA=0;SA<T;SA++)lA.rootPositionOffset?H.copy(lA.rootPositionOffset):H.set(0,0,0),H.applyQuaternion(Z),this._clipRotQuat&&H.applyQuaternion(this._clipRotQuat),lA.rootQuaternionOffset&&(X.copy(lA.rootQuaternionOffset),Z.multiply(X)),L.add(H);this._clipRotQuat&&J.multiply(this._clipRotQuat),J.multiply(Z),d.position&&L.add(d.position),_.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.__mixerError===void 0&&(Sn||Ge())&&((C=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&C.mixer)&&this.mixer!==((B=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:B.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const h=Math.max(0,1-s);(c=(E=this._animator)==null?void 0:E.runtimeAnimatorController)==null||c.update(h)}else this.mixer.update(e)}createRotationInterpolant(e,t,g){var n;const I=g.createInterpolant.bind(g),o=new RA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;g.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=B=>{var E;const Q=a(B);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const c of this.director.animationCallbackReceivers)(E=c==null?void 0:c.onTimelineRotation)==null||E.call(c,this.director,this.target,B,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(e,t,g){var a,B;const I=g.createInterpolant.bind(g),o=new y;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(B=this.trackOffset)==null?void 0:B.position;let C;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=c=>{var u,l,d;const h=E(c);if(o.set(h[0],h[1],h[2]),t.removeStartOffset&&(C===void 0?(C=null,C=(l=(u=this._actionOffsets.find(p=>p.clip===e))==null?void 0:u.rootStartPosition)==null?void 0:l.clone()):C!=null&&C.isVector3&&o.sub(C)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const p of this.director.animationCallbackReceivers)(d=p==null?void 0:p.onTimelinePosition)==null||d.call(p,this.director,this.target,c,o);return h[0]=o.x,h[1]=o.y,h[2]=o.z,h},Q}}}const MIA=oA("mutetimeline"),GE=class extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"listener");r(this,"audio",[]);r(this,"audioContextTimeOffset",[]);r(this,"lastTime",0);r(this,"audioSource");r(this,"_audioLoader",null);r(this,"_playableDirectorResumed",!1)}getAudioFilePath(e){const t=this.director.sourceId;return hr(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new lU(this.listener);this.audio.push(t);const g=e;g._didTriggerPlay=!1,this.models.push(g)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(MIA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=this._playableDirectorResumed;this._playableDirectorResumed=!1;const I=t?.1:0;for(let o=0;o<this.models.length;o++){const s=this.models[o],n=this.audio[o],C=s.asset;if((!n||!n.buffer)&&this.isInTimeRange(s,e-1,e+1)&&this.handleAudioLoading(s,n),Ki.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=C.loop,e>=s.start&&e<=s.end&&e<this.director.duration){if(!n.isPlaying||!this.director.isPlaying)(g||!s._didTriggerPlay&&this.lastTime<e)&&(s.duration*s.timeScale>.3?n.offset=s.clipIn+(e-s.start)*s.timeScale:n.offset=0,Sn&&console.log("Timeline Audio ("+this.track.name+") play with offset "+n.offset+" - "+s.asset.clip),n.play(I),s._didTriggerPlay=!0);else{const B=s.clipIn+(e-s.start)*s.timeScale,Q=n.context.currentTime-n._startedAt+n.offset;Math.abs(B-Q)>.3&&(n.offset=B,n.stop(),n.play(I))}let a=C.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),t&&(a=0),s.easeInDuration>0){const B=Math.min((e-s.start)/s.easeInDuration,1);a*=B}if(s.easeOutDuration>0){const B=Math.min((s.end-e)/s.easeOutDuration,1);a*=B}n.setVolume(a*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&n.isPlaying&&n.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const C=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,C);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){GE._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new ty);const g=this.getAudioFilePath(e.asset.clip);if(GE._audioBuffers.get(g)){const o=GE._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}Sn&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return GE._audioBuffers.set(g,I),I}};let FB=GE;r(FB,"_audioBuffers",new Map);class dd extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"didTrigger",[]);r(this,"receivers",[])}evaluate(e){var g;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let C=!1;if(o.retroActive)C=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(C=!0)}if(C){if(!s)if(Sn&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)Jc.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class yS extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"timelines",[]);r(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=BA.getComponent(I.sourceObject,qC);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[g];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const ZQ=oA("debugtimeline"),tw=class extends NA{constructor(){super(...arguments);r(this,"playableAsset");r(this,"playOnAwake");r(this,"extrapolationMode",1);r(this,"waitForAudio",!0);r(this,"_visibilityChangeEvt");r(this,"_clonedPlayableAsset",!1);r(this,"_speed",1);r(this,"_guidsMap");r(this,"_isPlaying",!1);r(this,"_internalUpdateRoutine");r(this,"_isPaused",!1);r(this,"_isStopping",!1);r(this,"_time",0);r(this,"_duration",0);r(this,"_weight",1);r(this,"_animationTracks",[]);r(this,"_audioTracks",[]);r(this,"_signalTracks",[]);r(this,"_controlTracks",[]);r(this,"_customTracks",[]);r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);r(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(ZQ||vI())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,g;ZQ&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(t=this.playableAsset)==null?void 0:t.tracks,Array.isArray((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t,g;for(const I of this._audioTracks)(e=I.onEnable)==null||e.call(I);for(const I of this._customTracks)(t=I.onEnable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onEnable)==null||g.call(I);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var e,t,g;this.stop();for(const I of this._audioTracks)(e=I.onDisable)==null||e.call(I);for(const I of this._customTracks)(t=I.onDisable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onDisable)==null||g.call(I);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.loadAudio(this._time,1,0);I&&t.push(I)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Ki.userInteractionRegistered&&this.waitForAudio;)await os(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),eg.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const e of this._allTracks)for(const t of e)yield t}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const g=this._time;for(const I of this.playableAsset.tracks)if(!I.muted)switch(I.type){case Bo.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<I.outputs.length;o++){const s=I.outputs[o];if(typeof s=="object"){let n=!1;if(I.clips)for(const a of I.clips)a.start<=g&&g<=a.end&&(n=!0);const C=s;C.visible!==void 0&&C.visible!==n&&(C.visible=n,ZQ&&console.warn(this.name,"set ActivationTrack-"+o,C.name,n,g))}}break}if(!this._isStopping)for(const I of this._animationTracks)I.evaluate(g);for(const I of this._audioTracks)I.evaluate(g);for(const I of this._signalTracks)I.evaluate(g);for(const I of this._controlTracks)I.evaluate(g);for(const I of this._customTracks)I.evaluate(g)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Vd(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=BA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(ZQ&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),tw.createTrackFunctions[t.type])continue;t.type!==Bo.Audio&&t.type!==Bo.Control&&t.type!==Bo.Marker&&t.type!==Bo.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===Bo.Control&&t.clips)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=BA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(ZQ&&console.log("Resolved binding",o,"to",s),I.asset.sourceObject=s)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g,I;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=BA.findObjectOfType(Xa,this.context);for(const o of this.playableAsset.tracks){const s=o.type,n=tw.createTrackFunctions[s];if(n!=null){const C=n(this,o);if(typeof C.evaluate=="function"){C.director=this,C.track=o,this._customTracks.push(C);continue}}if(o.type===Bo.Animation){if(!o.clips||o.clips.length<=0){ZQ&&console.warn("Animation track has no clips",o);continue}for(let C=o.outputs.length-1;C>=0;C--){let a=o.outputs[C];if(a instanceof pA){const Q=BA.getOrAddComponent(a,jg);Q&&(a=Q)}const B=(t=a==null?void 0:a.gameObject)==null?void 0:t.animations;if(B){const Q=new DS;Q.trackOffset=o.trackOffset,Q.director=this,Q.track=o;for(let E=0;E<o.clips.length;E++){const c=o.clips[E],h=c.asset;if(!h){console.error(`Timeline ${this.name}: clip #${E} on track "${o.name}" has no animation data`);continue}const u=h.clip;let l=u;if((typeof l=="string"||typeof l=="number")&&(l=B.find(p=>p.name===u)),!l){console.warn("Could not find animationClip for model",c,o.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}a instanceof jg&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),Q.mixer=a.runtimeAnimatorController.mixer),Q.mixer||(Q.mixer=new xw(a.gameObject)),Q.clips.push(l),Q.mixer.uncacheAction(l),Q.createHooks(c.asset,l);const d=Q.mixer.clipAction(l);Q.actions.push(d),Q.models.push(c)}this._animationTracks.push(Q)}}}else if(o.type===Bo.Audio){if(!o.clips||o.clips.length<=0)continue;const C=new FB;C.director=this,C.track=o,C.audioSource=o.outputs.find(a=>a instanceof Ki),this._audioTracks.push(C),e||(e=(I=this.context.mainCameraComponent)==null?void 0:I.gameObject.addNewComponent(Xa)),C.listener=e.listener;for(let a=0;a<o.clips.length;a++){const B=o.clips[a];C.addModel(B)}}else if(o.type===Bo.Marker){const C=new dd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)switch(a.type){case AF.Signal:C.models.push(a),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const a=BA.getComponent(this.gameObject,Jc);a&&(C.receivers.push(a),this._signalTracks.push(C))}}else if(o.type===Bo.Signal){const C=new dd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)C.models.push(a),C.didTrigger.push(!1);for(const a of o.outputs)C.receivers.push(a);this._signalTracks.push(C)}else if(o.type===Bo.Control){const C=new yS;if(C.director=this,C.track=o,o.clips)for(const a of o.clips)C.models.push(a);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};let qC=tw;r(qC,"createTrackFunctions",{});const kD=Symbol("objectIsAnimatedData");function zq(i,A,e){if(!i)return;if(i[kD]===void 0){if(!e)return;i[kD]=new Set}const t=i[kD];e?t.add(A):t.has(A)&&t.delete(A)}function RIA(i){if(!i)return!1;const A=i[kD];return A!==void 0&&A.size>0}Nt.registerCallback(Xi.ContextCreated,i=>{const A=i.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&i.files)for(const e of i.files)BA.foreachComponent(e.file.scene,g=>{if(g.enabled!==!1){if(g instanceof Go&&g.playAutomatically||g instanceof jg||g instanceof qC&&g.playOnAwake===!0)return!0;if(g instanceof Go)return g.playAutomatically=!0,!0;if(g instanceof qC)return g.playOnAwake=!0,!0}},!0)!==!0&&UIA(e.file)});function UIA(i){if(!i||!i.animations)return;for(let e=0;e<i.animations.length;e++){const t=i.animations[e];if(!(!t.tracks||t.tracks.length<=0))for(const g in t.tracks){const I=t.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=i.scene.getObjectByName(o);if(!s&&(s=i.scene.getObjectByProperty("uuid",o),!s))continue;let n=A(s);n||(n=dr(i.scene,new Go));const C=n.animations=n.animations||[];t.name_animator=n.name,C.indexOf(t)<0&&C.push(t)}}function A(e){var g;if(!e)return;const t=(g=e.userData)==null?void 0:g.components;if(t&&t.length>0)for(let I=0;I<t.length;I++){const o=t[I];if(o instanceof jg||o instanceof Go)return e}return A(e.parent)}}class NIA{constructor(){r(this,"_context")}get context(){return this._context??ve.Current}get isStateMachineBehaviour(){return!0}}class GD{constructor(A,e,t,g){r(this,"_name");r(this,"_nameHash");r(this,"_normalizedTime");r(this,"_length");r(this,"_speed");this._name=A.name,this._nameHash=A.hash,this._normalizedTime=e,this._length=t,this._speed=g}get name(){return this._name}get nameHash(){return this._nameHash}get normalizedTime(){return this._normalizedTime}get length(){return this._length}get speed(){return this._speed}}function uP(i,A){return{name:"",isLooping:!1,guid:(A==null?void 0:A.generateUUID())??Bg.generateUUID(),index:-1,clip:new go(i,1,[])}}var Na=(i=>(i[i.If=1]="If",i[i.IfNot=2]="IfNot",i[i.Greater=3]="Greater",i[i.Less=4]="Less",i[i.Equals=6]="Equals",i[i.NotEqual=7]="NotEqual",i))(Na||{}),eF=(i=>(i[i.Float=1]="Float",i[i.Int=3]="Int",i[i.Bool=4]="Bool",i[i.Trigger=9]="Trigger",i))(eF||{});const yI=oA("debuganimatorcontroller"),wf=oA("debugrootmotion");class mo{constructor(A){r(this,"normalizedStartOffset",0);r(this,"_speed",1);r(this,"animator");r(this,"model");r(this,"_mixer");r(this,"_activeState");r(this,"_activeStates",[]);r(this,"rootMotionHandler");this.model=A,yI&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const t=[];for(let o=0;o<A.length;o++){const s=A[o],n=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,B=a/s.duration;let Q=o;(e.autoTransition===void 0||e.autoTransition===!0)&&(Q=(o+1)%A.length),n.push({exitTime:1-B,offset:0,duration:a,hasExitTime:!0,destinationState:Q,conditions:[]})}const C={name:s.name,hash:o,motion:{name:s.name,clip:s,isLooping:(e==null?void 0:e.looping)??!1},transitions:n,behaviours:[]};t.push(C)}const g={name:"AnimatorController",guid:new mg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:t}}]};return new mo(g)}play(A,e=-1,t=Number.NEGATIVE_INFINITY,g=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[e].stateMachine;for(const s of o.states)if(s.name===A||s.hash===A){yI&&console.log("transition to ",s),this.transitionTo(s,g,t);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var g,I;const t=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getBool(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??!1}setFloat(A,e){var I,o;const t=typeof A=="string"?"name":"hash",g=(o=(I=this.model)==null?void 0:I.parameters)==null?void 0:o.filter(s=>s[t]===A);return g.forEach(s=>s.value=e),(g==null?void 0:g.length)>0}getFloat(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??0}setInteger(A,e){var g,I;const t=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getInteger(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??0}setTrigger(A){var t,g;yI&&console.log("SET TRIGGER",A);const e=typeof A=="string"?"name":"hash";return(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.filter(I=>I[e]===A).forEach(I=>I.value=!0)}resetTrigger(A){var t,g;const e=typeof A=="string"?"name":"hash";return(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.filter(I=>I[e]===A).forEach(I=>I.value=!1)}getTrigger(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const t of e.stateMachine.states)if(t.name===A||t.hash==A)return t}return null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}bind(A){A?this.animator!==A&&(this.animator=A,this._mixer=new xw(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;yI&&console.warn("AnimatorController clone()",this.model);const A=Vd(this.model,(t,g,I)=>I==null?!0:!(I.type==="Object3D"||I.isObject3D===!0||$2(I)||I.tracks!==void 0||I instanceof mo));return console.assert(A!==this.model),new mo(A)}update(A){var t,g;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const e=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(A)),this._mixer.update(e),this.animator.applyRootMotion&&((g=this.rootMotionHandler)==null||g.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const t=this._activeStates[e],g=t.motion;if(!g.action)this._activeStates.splice(e,1),e--;else{const I=g.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(yI&&console.debug("REMOVE",t.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){for(const A of this.model.layers){const e=A.stateMachine;e.defaultState===void 0&&(yI&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",A),e.defaultState=0);const t=e.states[e.defaultState];this.transitionTo(t,0,this.normalizedStartOffset)}}evaluateTransitions(){var I;let A=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;A=!0}const e=this._activeState,t=e.motion.action;for(const o of e.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const n of o.conditions)if(!this.evaluateCondition(n)){s=!1;break}if(s)if(t){const n=e.motion.clip.duration,C=n<=0?1:Math.abs(t.time/n);let a=!1;if(o.hasExitTime?t.timeScale>0?a=C>=o.exitTime:t.timeScale<0&&(a=1-C>=o.exitTime):a=!0,a){for(const B of o.conditions){const Q=this.model.parameters.find(E=>E.name===B.parameter);(Q==null?void 0:Q.type)===eF.Trigger&&Q.value&&(Q.value=!1)}t.clampWhenFinished=!0,yI&&console.log("transition to "+o.destinationState,o,C,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(t){let o=e.speed??1;e.speedParameter&&(o*=this.getFloat(e.speedParameter)),o!==void 0&&(t.timeScale=o*this._speed)}let g=!1;if(e.motion.isLooping&&t&&(t.time>=t.getClip().duration?(g=!0,t.reset(),t.time=0,t.play()):t.time<=0&&t.timeScale<0&&(g=!0,t.reset(),t.time=t.getClip().duration,t.play())),!g&&e&&!A&&t&&this.animator&&e.behaviours){const o=t==null?void 0:t.getClip().duration,s=t.time/o,n=new GD(this._activeState,s,o,this._speed);for(const C of e.behaviours)C.instance&&((I=C.instance.onStateUpdate)==null||I.call(C.instance,this.animator,n,0))}}getState(A,e){return typeof A=="number"&&(A==-1&&(A=this.model.layers[e].stateMachine.defaultState,A===void 0&&(yI&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+e),A=0)),A=this.model.layers[e].stateMachine.states[A]),A}transitionTo(A,e,t){var C,a,B,Q,E,c,h,u;if(!this.animator)return;const g=0;if(A=this.getState(A,g),!(A!=null&&A.motion)||!A.motion.clip||!(A.motion.clip instanceof go))return;const I=this._activeState===A;if(I){const l=A.motion;if(!l.action_loopback&&l.clip){const d=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(l.clip,this.animator.gameObject),d&&d.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),l.action_loopback=this.createAction(l.clip)}}if((C=this._activeState)!=null&&C.behaviours&&this._activeState.motion.action){const l=(a=this._activeState)==null?void 0:a.motion.clip.duration,d=this._activeState.motion.action.time/l,p=new GD(this._activeState,d,l,this._speed);for(const f of this._activeState.behaviours)(Q=(B=f.instance)==null?void 0:B.onStateExit)==null||Q.call(f.instance,this.animator,p,g)}const o=(E=this._activeState)==null?void 0:E.motion.action;o&&o.fadeOut(e),I&&(A.motion.action=A.motion.action_loopback,A.motion.action_loopback=o);const s=this._activeState;this._activeState=A;const n=(c=A.motion)==null?void 0:c.action;if(n){if(t=Math.max(0,Math.min(1,t)),A.cycleOffsetParameter){let d=this.getFloat(A.cycleOffsetParameter);typeof d=="number"?(d<0&&(d+=1),t+=d,t%=1):yI&&console.warn("AnimatorController cycle offset parameter is not a number",A.cycleOffsetParameter)}else typeof A.cycleOffset=="number"&&(t+=A.cycleOffset,t%=1);n.isRunning()&&n.stop(),n.reset(),n.enabled=!0;const l=A.motion.clip.duration;if(n.time=I?0:t*l,n.timeScale<0&&(n.time=l-n.time),n.clampWhenFinished=!0,n.setLoop(xl,0),e>0?n.fadeIn(e):n.weight=1,n.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(n),this._activeStates.includes(A)||this._activeStates.push(A),this._activeState.behaviours){const d=new GD(A,t,l,this._speed);for(const p of this._activeState.behaviours)(u=(h=p.instance)==null?void 0:h.onStateEnter)==null||u.call(p.instance,this.animator,d,g)}}else yI&&(A.__warned_no_motion||(A.__warned_no_motion=!0,console.warn("No action",A.motion,this)));yI&&console.log("TRANSITION FROM "+(s==null?void 0:s.name)+" TO "+A.name,e,o,n,n==null?void 0:n.getEffectiveTimeScale(),n==null?void 0:n.getEffectiveWeight(),n==null?void 0:n.isRunning(),n==null?void 0:n.isScheduled(),n==null?void 0:n.paused)}createAction(A){var t,g;if(this._mixer.existingAction(A)&&this._mixer.uncacheAction(A,(t=this.animator)==null?void 0:t.gameObject),(g=this.animator)!=null&&g.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new FIA(this));const I=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,I,A)}else return this._mixer.clipAction(A)}evaluateCondition(A){const e=this.model.parameters.find(t=>t.name===A.parameter);if(!e)return!1;switch(A.mode){case Na.If:return e.value===!0;case Na.IfNot:return e.value===!1;case Na.Greater:return e.value>A.threshold;case Na.Less:return e.value<A.threshold;case Na.Equals:return e.value===A.threshold;case Na.NotEqual:return e.value!==A.threshold}return!1}createActions(A){var e,t,g,I;yI&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const s=o.stateMachine;for(let n=0;n<s.states.length;n++){const C=s.states[n];C.transitions||(C.transitions=[]);for(const a of C.transitions)a.conditions||(a.conditions=[]);if(C.motion||(C.motion=uP(C.name)),this.animator&&C.motion.clips){const a=(e=C.motion.clips)==null?void 0:e.find(B=>{var Q,E;return B.node.name===((E=(Q=this.animator)==null?void 0:Q.gameObject)==null?void 0:E.name)});a?C.motion.clip=a.clip:(yI||Ge())&&console.warn('Could not find clip for animator "'+((g=(t=this.animator)==null?void 0:t.gameObject)==null?void 0:g.name)+'"',C.motion.clips.map(B=>B.node.name))}if(!C.motion.clip){const a=new go(void 0,void 0,[]);C.motion.clip=a}if((I=C.motion)!=null&&I.clip){const a=C.motion.clip;if(a instanceof go){const B=this.createAction(a);C.motion.action=B}else(yI||Ge())&&console.warn("No valid animationclip assigned",C)}if(C.behaviours&&Array.isArray(C.behaviours))for(const a of C.behaviours){if(!(a!=null&&a.typeName))continue;const B=AA.get(a.typeName),Q=new B;Q.isStateMachineBehaviour&&(Q._context=this.context??void 0,zE(Q,a.properties),a.instance=Q),yI&&console.log("Created animator controller behaviour",C.name,a.typeName,a.properties,Q)}}}}*enumerateActions(){if(this.model.layers)for(const A of this.model.layers){const e=A.stateMachine;for(let t=0;t<e.states.length;t++){const g=e.states[t];g!=null&&g.motion&&(g.motion.action&&(yield g.motion.action),g.motion.action_loopback&&(yield g.motion.action_loopback))}}}}class Zq{constructor(A,e){r(this,"track");r(this,"createdInterpolant");r(this,"originalEvaluate");r(this,"customEvaluate");this.track=A;const t=A,g=t.createInterpolant.bind(A);t.createInterpolant=()=>(t.createInterpolant=g,this.createdInterpolant=g(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=I=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(I);return e(I,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const Cg=class{constructor(A,e,t,g,I){r(this,"_action");r(this,"root");r(this,"clip");r(this,"positionWrapper",null);r(this,"rotationWrapper",null);r(this,"context");r(this,"positionChange",new y);r(this,"rotationChange",new RA);r(this,"_prevTime",0);if(this.context=A,this.root=e,this.clip=t,Cg.firstKeyframeRotation[this.cacheId]||(Cg.firstKeyframeRotation[this.cacheId]=new RA),I){const o=I.values;Cg.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}Cg.spaceRotation[this.cacheId]||(Cg.spaceRotation[this.cacheId]=new RA),Cg.effectiveSpaceRotation[this.cacheId]||(Cg.effectiveSpaceRotation[this.cacheId]=new RA),Cg.clipOffsetRotation[this.cacheId]=new RA,I&&Cg.clipOffsetRotation[this.cacheId].set(I.values[0],I.values[1],I.values[2],I.values[3]).invert(),this.handlePosition(t,g),this.handleRotation(t,I)}set action(A){this._action=A}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(A){if(A.getClip()!==this.clip)return;Cg.lastObjRotation[this.cacheId]||(Cg.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=Cg.lastObjRotation[this.cacheId];if(Cg.spaceRotation[this.cacheId].copy(e),wf){const t=new Og().setFromQuaternion(e);console.log("START",this.clip.name,se.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return Cg.clipOffsetRotation[this.cacheId]}handlePosition(A,e){if(e){const t=this.root;wf&&t.add(new Cs),Cg.lastObjPosition[this.cacheId]||(Cg.lastObjPosition[this.cacheId]=this.root.position.clone());const g=new y,I=new y;this.positionWrapper=new Zq(e,(o,s)=>{const n=this.action.getEffectiveWeight();return wf&&t.position.length()>8&&t.position.set(0,t.position.y,0),o>this._prevTime&&(g.set(s[0],s[1],s[2]),g.sub(I),g.multiplyScalar(n),g.applyQuaternion(this.getClipRotationOffset()),g.applyQuaternion(t.quaternion),this.positionChange.copy(g)),I.fromArray(s),this._prevTime=o,s[0]=0,s[1]=0,s[2]=0,s})}}handleRotation(A,e){if(e){if(wf){const o=e.values,s=new Og().setFromQuaternion(new RA(o[0],o[1],o[2],o[3]));console.log(A.name,e.name,"FIRST ROTATION IN TRACK",se.toDegrees(s.y));const n=e.values.length-4,C=new RA().set(o[n],o[n+1],o[n+2],o[n+3]),a=new Og().setFromQuaternion(C);console.log(A.name,e.name,"LAST ROTATION IN TRACK",se.toDegrees(a.y))}let t=0;const g=new RA,I=new RA;this.rotationWrapper=new Zq(e,(o,s)=>(o>t&&(I.set(s[0],s[1],s[2],s[3]),g.invert(),I.multiply(g),this.rotationChange.copy(I)),g.fromArray(s),t=o,s[0]=0,s[1]=0,s[2]=0,s[3]=1,s))}}onBeforeUpdate(A){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(A){return!this.action||(A*=this.action.getEffectiveWeight(),A<=0)?!1:(this.positionChange.multiplyScalar(A),this.rotationChange.slerp(Cg.identityQuaternion,1-A),!0)}};let nn=Cg;r(nn,"lastObjPosition",{}),r(nn,"lastObjRotation",{}),r(nn,"firstKeyframeRotation",{}),r(nn,"spaceRotation",{}),r(nn,"effectiveSpaceRotation",{}),r(nn,"clipOffsetRotation",{}),r(nn,"identityQuaternion",new RA);class FIA{constructor(A){r(this,"controller");r(this,"handler",[]);r(this,"root");r(this,"basePosition",new y);r(this,"baseQuaternion",new RA);r(this,"baseRotation",new Og);r(this,"summedPosition",new y);r(this,"summedRotation",new RA);this.controller=A}createClip(A,e,t){this.root=e,e&&"name"in e&&e.name;const g=this.findRootTrack(t,".position"),I=this.findRootTrack(t,".quaternion"),o=new nn(this.controller.context,e,t,g,I);this.handler.push(o);const s=A.clipAction(t);return o.action=s,s}onStart(A){for(const e of this.handler)e.onStart(A)}onBeforeUpdate(A){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const e of this.handler)e.onBeforeUpdate(A)}onAfterUpdate(A){if(!(A<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const e of this.handler)e.onAfterUpdate(A)&&(this.summedPosition.add(e.positionChange),this.summedRotation.multiply(e.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(A,e){const t=A.tracks;if(!t)return null;for(const g of t)if(g.name.endsWith(e))return g;return null}}class KIA extends zC{onSerialize(A,e){}onDeserialize(A,e){if(e.type===mo&&(A==null?void 0:A.__type)==="AnimatorController")return new mo(A)}}new KIA(mo);var JIA=Object.defineProperty,vIA=Object.getOwnPropertyDescriptor,wS=(i,A,e,t)=>{for(var g=t>1?void 0:t?vIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JIA(A,e,g),g};const Ho=oA("debuganimator");class jg extends NA{constructor(){super(...arguments);r(this,"applyRootMotion",!1);r(this,"hasRootMotion",!1);r(this,"keepAnimatorControllerStateOnDisable",!1);r(this,"_parametersAreDirty",!1);r(this,"_isDirty",!1);r(this,"speed",1);r(this,"normalizedStartOffset",0);r(this,"_animatorController",null);r(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof mo?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new mo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Ho&&console.log("Assign animator controller",e,this),this._animatorController=new mo(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){this.play(e,t,g,I)}play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,g,I),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var g,I;Ho&&console.log("setBool",e,t),((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))??!1;return Ho&&console.log("getBool",e,t),t}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))!==t&&(this._parametersAreDirty=!0),Ho&&console.log("setFloat",e,t),(I=this.runtimeAnimatorController)==null||I.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))??-1;return Ho&&console.log("getFloat",e,t),t}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))!==t&&(this._parametersAreDirty=!0),Ho&&console.log("setInteger",e,t),(I=this.runtimeAnimatorController)==null||I.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))??-1;return Ho&&console.log("getInteger",e,t),t}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Ho&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Ho&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var g;const t=(g=this.runtimeAnimatorController)==null?void 0:g.getTrigger(e);return Ho&&console.log("getTrigger",e,t),t}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this.speed&&(Ho&&console.log("setSpeed",e),this.speed=e,(t=this._animatorController)==null||t.setSpeed(e))}set minMaxSpeed(e){this.speed=se.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=se.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){Ho&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const g=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=g,g?(console.assert(this.runtimeAnimatorController!==g),this.runtimeAnimatorController=g,console.assert(this.runtimeAnimatorController===g),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!RIA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}wS([D()],jg.prototype,"applyRootMotion",2);wS([D()],jg.prototype,"hasRootMotion",2);wS([D()],jg.prototype,"keepAnimatorControllerStateOnDisable",2);wS([D()],jg.prototype,"runtimeAnimatorController",1);const LE=oA("debugusdzanimation"),tR=oA("debugusdzanimationserialization");class SS{constructor(A,e,t){r(this,"_start");r(this,"ext");r(this,"root");r(this,"clip");this.ext=A,this.root=e,this.clip=t}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class ts{constructor(A,e,t){r(this,"clip");r(this,"pos");r(this,"rot");r(this,"scale");r(this,"root");r(this,"target");r(this,"duration",0);r(this,"useRootMotion",!1);this.root=A,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=1/this.frameRate;const g=BA.getComponent(A,jg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it โ this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,t,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(t=this.rot)==null?void 0:t.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,t=!0){var n,C,a;if(!this.clip)return[0,this.duration];const g=(n=this.pos)==null?void 0:n.times,I=(C=this.rot)==null?void 0:C.times,o=(a=this.scale)==null?void 0:a.times,s=[];if(A&&g)for(const B of g)s.push(B);if(e&&I)for(const B of I)s.push(B);if(t&&o)for(const B of o)s.push(B);return s.includes(0)||s.push(0),s.sort((B,Q)=>B-Q),[...new Set(s)]}*getValues(A,e=!0,t=!0,g=!0){var Q,E,c;const I=new y,o=new RA,s=new y(1,1,1),n=this.target,C=e?(Q=this.pos)==null?void 0:Q.createInterpolant():void 0,a=t?(E=this.rot)==null?void 0:E.createInterpolant():void 0,B=g?(c=this.scale)==null?void 0:c.createInterpolant():void 0;C||I.set(n.position.x,n.position.y,n.position.z),a||o.set(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w),B||s.set(n.scale.x,n.scale.y,n.scale.z);for(let h=0;h<A.length;h++){const u=A[h];if(C){const l=C.evaluate(u);I.set(l[0],l[1],l[2])}if(a){const l=a.evaluate(u);o.set(l[0],l[1],l[2],l[3])}if(B){const l=B.evaluate(u);s.set(l[0],l[1],l[2])}if(this.useRootMotion&&n===this.root){const l=new GA;l.compose(I,o,s),l.multiply(n.matrix),l.decompose(I,o,s)}yield{time:u,translation:I,rotation:o,scale:s,index:h}}}}r(ts,"animationDurationPadding",1);class wu{constructor(A){r(this,"dict",new Map);r(this,"rootTargetMap",new Map);r(this,"rootAndClipToRegisteredAnimationMap",new Map);r(this,"rootToRegisteredClipCount",new Map);r(this,"serializers",[]);r(this,"injectRestPoses",!1);r(this,"injectImplicitBehaviours",!1);this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const t=this.rootTargetMap.get(A);if(!t)return 0;const g=this.dict.get(t[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+ts.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const t=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(t))return this.rootAndClipToRegisteredAnimationMap.get(t);LE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const C of e.tracks){const a=ze.parseTrackName(C.name),B=ze.findNode(A,a.nodeName);if(!B){console.warn("no object found for track",C.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const c=new ts(null,B,void 0);Q[0]=c}let E=Q[I];E||(E=new ts(A,B,e),Q[I]=E),E.addTrack(C),o!=null&&o.includes(B)||o==null||o.push(B)}for(const C of s){const a=this.dict.get(C);if(!a)continue;if(this.injectRestPoses&&!a[0]){const Q=new ts(null,C,void 0);a[0]=Q}let B=a[I];B||(LE&&console.log("Adding padding clip for ",C,e),B=new ts(A,C,e),a[I]=B)}const n=new SS(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(t,n),this.rootToRegisteredClipCount.set(A,I+1),n}onAfterHierarchy(A){LE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,t;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=(I==null?void 0:I.isDynamic)===!0;tR&&console.log(o,(t=g.model)==null?void 0:t.parent),o&&g.registerCallback(I)}}onExportObject(A,e,t){BA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,t)},!1);const g=new bIA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class bIA{constructor(A,e){r(this,"object");r(this,"dict");r(this,"model");r(this,"callback");this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),tR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const t=this.model,g=this.dict;if(t&&t.skinnedMesh){let I=function(G){const R=[];for(const[w,k]of G){let K=`${w} : [`;const T=[];for(const O of k)T.push(`(${Dg(O.x)}, ${Dg(O.y)}, ${Dg(O.z)})`);K=K.concat(T.join(", ")),K=K.concat("],"),R.push(K)}return R},o=function(G){const R=[];for(const[w,k]of G){let K=`${w} : [`;const T=[];for(const O of k)T.push(`(${Dg(O.w)}, ${Dg(O.x)}, ${Dg(O.y)}, ${Dg(O.z)})`);K=K.concat(T.join(", ")),K=K.concat("],"),R.push(K)}return R},s=function(G){let R=!0,w;for(const[K,T]of G)if(w===void 0&&(w=T.length),w!==T.length){R=!1;break}LE&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",w),console.assert(R,"All bones should have the same number of TransformData entries",G);const k=[];for(const[K,T]of G){const O=new Array;let b=0;for(let _=0;_<T.length;_++)O.push(b),b+=T[_].getDuration()+ts.animationDurationPadding;for(let _=0;_<T.length;_++){const J=T[_],L=O[_];k.length<=_&&k.push({pos:[],rot:[],scale:[],timeOffset:L});const H=k[_];H.pos.push(...J.getSortedTimesArray(!0,!1,!1)),H.rot.push(...J.getSortedTimesArray(!1,!0,!1)),H.scale.push(...J.getSortedTimesArray(!1,!1,!0))}}for(const K of k)K.pos.sort((T,O)=>T-O),K.rot.sort((T,O)=>T-O),K.scale.sort((T,O)=>T-O),K.pos=[...new Set(K.pos)],K.rot=[...new Set(K.rot)],K.scale=[...new Set(K.scale)];return k},n=function(G,R,w){const k=new Map,K=new Map,T=new Map,O=R.length;for(const b of w){const _=G.get(b);let J;_?console.assert(_.length===O,"We should have the same number of TransformData entries for each bone",_,R):J=new ts(null,b,void 0);for(let L=0;L<O;L++){const H=_?_[L]:J,Z=R[L];for(const{time:X,translation:nA}of H.getValues(Z.pos,!0,!1,!1)){const SA=(X+Z.timeOffset)*60;k.has(SA)||k.set(SA,new Array),k.get(SA).push(nA.clone())}for(const{time:X,rotation:nA}of H.getValues(Z.rot,!1,!0,!1)){const SA=(X+Z.timeOffset)*60;K.has(SA)||K.set(SA,new Array),K.get(SA).push(nA.clone())}for(const{time:X,scale:nA}of H.getValues(Z.scale,!1,!1,!0)){const SA=(X+Z.timeOffset)*60;T.has(SA)||T.set(SA,new Array),T.get(SA).push(nA.clone())}}}return{position:k.size==0?void 0:k,quaternion:K.size==0?void 0:K,scale:T.size==0?void 0:T}},C=function(G){const R=[];for(const w of G)R.push(`(${Dg(w.x)}, ${Dg(w.y)}, ${Dg(w.z)})`);return R.join(", ")},a=function(G){const R=[];for(const w of G)R.push(`(${Dg(w.w)}, ${Dg(w.x)}, ${Dg(w.y)}, ${Dg(w.z)})`);return R.join(", ")},B=function(G){const R=new Map;if(LE){const w=new Array;for(const[k,K]of g)w.push(k.uuid+": "+K.length+" "+K.map(T=>{var O;return(O=T.clip)==null?void 0:O.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5410
|
+
Using the assigned clip instead:`,this.clip),A=this.clip);let e=!this.sound||A&&A!==this.clip;if(typeof A=="string"&&!this.audioLoader&&(e=!0),(A instanceof MediaStream||typeof A=="string")&&(this.clip=A),e){this.shouldPlay=!0,this.onNewClip(A);return}if(this.shouldPlay=!0,this._hasEnded=!1,CI&&console.log("play",(t=this.sound)==null?void 0:t.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(g=this.gameObject)==null||g.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(I=this.context.domElement.shadowRoot)==null||I.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(o?.1:0))}}pause(){var A,e;CI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var A,e;CI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,CI&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}get isPlaying(){var A;return((A=this.sound)==null?void 0:A.isPlaying)??!1}set isPlaying(A){}get time(){var A,e;return(A=this.sound)!=null&&A.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(A){if(this.sound){if(A===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=A,e&&this.play()}}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,CI&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Ki=ka;_n([D(URL)],Ki.prototype,"clip",2);_n([D()],Ki.prototype,"playOnAwake",2);_n([D()],Ki.prototype,"preload",2);_n([D()],Ki.prototype,"loop",1);_n([D()],Ki.prototype,"spatialBlend",1);_n([D()],Ki.prototype,"minDistance",1);_n([D()],Ki.prototype,"maxDistance",1);_n([D()],Ki.prototype,"volume",1);_n([D()],Ki.prototype,"rollOffMode",2);_n([D()],Ki.prototype,"playInBackground",2);const _q={type:"change"},dk={type:"start"},Hq={type:"end"},ff=new Uo,Oq=new MI,zgA=Math.cos(70*Bg.DEG2RAD);let ZgA=class extends Rg{constructor(A,e){super(),this.object=A,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new y,this.cursor=new y,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:iB.ROTATE,MIDDLE:iB.DOLLY,RIGHT:iB.PAN},this.touches={ONE:gB.ROTATE,TWO:gB.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(P){P.addEventListener("keydown",De),this._domElementKeyEvents=P},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",De),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(_q),t.update(),I=g.NONE},this.update=function(){const P=new y,_A=new RA().setFromUnitVectors(A.up,new y(0,1,0)),IA=_A.clone().invert(),j=new y,WA=new RA,$A=new y,ae=2*Math.PI;return function(bt=null){const St=t.object.getWorldPosition(A.position);P.copy(St).sub(t.target),P.applyQuaternion(_A),s.setFromVector3(P),t.autoRotate&&I===g.NONE&&O(K(bt)),t.enableDamping?(s.theta+=n.theta*t.dampingFactor,s.phi+=n.phi*t.dampingFactor):(s.theta+=n.theta,s.phi+=n.phi);let ut=t.minAzimuthAngle,Ot=t.maxAzimuthAngle;isFinite(ut)&&isFinite(Ot)&&(ut<-Math.PI?ut+=ae:ut>Math.PI&&(ut-=ae),Ot<-Math.PI?Ot+=ae:Ot>Math.PI&&(Ot-=ae),ut<=Ot?s.theta=Math.max(ut,Math.min(Ot,s.theta)):s.theta=s.theta>(ut+Ot)/2?Math.max(ut,s.theta):Math.min(Ot,s.theta)),s.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,s.phi)),s.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(B,t.dampingFactor):t.target.add(B),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor),t.zoomToCursor&&G||t.object.isOrthographicCamera?s.radius=nA(s.radius):(t.enableDamping?a=Bg.lerp(a,C,t.dampingFactor):a=C,s.radius=nA(s.radius*a)),P.setFromSpherical(s),P.applyQuaternion(IA),St.copy(t.target).add(P),t.object.parent?t.object.parent.worldToLocal(St):t.object.position.copy(St),t.object.lookAt(t.target),t.enableDamping===!0?(n.theta*=1-t.dampingFactor,n.phi*=1-t.dampingFactor,B.multiplyScalar(1-t.dampingFactor)):(n.set(0,0,0),B.set(0,0,0));let lt=!1;if(t.zoomToCursor&&G){let Ji=null;if(t.object.isPerspectiveCamera){const Bi=P.length();Ji=nA(Bi*C);const Lo=Bi-Ji;t.object.position.addScaledVector(S,Lo),t.object.updateMatrixWorld()}else if(t.object.isOrthographicCamera){const Bi=new y(m.x,m.y,0);Bi.unproject(t.object),t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/C)),t.object.updateProjectionMatrix(),lt=!0;const Lo=new y(m.x,m.y,0);Lo.unproject(t.object),t.object.position.sub(Lo).add(Bi),t.object.updateMatrixWorld(),Ji=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;Ji!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(Ji).add(t.object.position):(ff.origin.copy(t.object.position),ff.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(ff.direction))<zgA?A.lookAt(t.target):(Oq.setFromNormalAndCoplanarPoint(t.object.up,t.target),ff.intersectPlane(Oq,t.target))))}else t.object.isOrthographicCamera&&(lt=C!==1,lt&&(t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/C)),t.object.updateProjectionMatrix()));return C=1,G=!1,lt||j.distanceToSquared(t.object.position)>o||8*(1-WA.dot(t.object.quaternion))>o||$A.distanceToSquared(t.target)>0?(t.dispatchEvent(_q),j.copy(t.object.position),WA.copy(t.object.quaternion),$A.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",he),t.domElement.removeEventListener("pointerdown",F),t.domElement.removeEventListener("pointercancel",MA),t.domElement.removeEventListener("wheel",Ie),t.domElement.removeEventListener("pointermove",aA),window.removeEventListener("pointerup",MA),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",De),t._domElementKeyEvents=null)};const t=this,g={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let I=g.NONE;const o=1e-6,s=new _G,n=new _G;let C=1,a=1;const B=new y,Q=new gA,E=new gA,c=new gA,h=new gA,u=new gA,l=new gA,d=new gA,p=new gA,f=new gA,S=new y,m=new gA;let G=!1;const R=[],w={};let k=!1;function K(P){return P!==null?2*Math.PI/60*t.autoRotateSpeed*P:2*Math.PI/60/60*t.autoRotateSpeed}function T(P){const _A=Math.abs(P*.01);return Math.pow(.95,t.zoomSpeed*_A)}function O(P){n.theta-=P}function b(P){n.phi-=P}const _=function(){const P=new y;return function(IA,j){P.setFromMatrixColumn(j,0),P.multiplyScalar(-IA),B.add(P)}}(),J=function(){const P=new y;return function(IA,j){t.screenSpacePanning===!0?P.setFromMatrixColumn(j,1):(P.setFromMatrixColumn(j,0),P.crossVectors(t.object.up,P)),P.multiplyScalar(IA),B.add(P)}}(),L=function(){const P=new y,_A=new y;return function(j,WA){const $A=t.domElement;if(t.object.isPerspectiveCamera){t.object.getWorldPosition(_A),P.copy(_A).sub(t.target);let ae=P.length();ae*=Math.tan(t.object.fov/2*Math.PI/180),_(2*j*ae/$A.clientHeight,t.object.matrixWorld),J(2*WA*ae/$A.clientHeight,t.object.matrixWorld)}else t.object.isOrthographicCamera?(_(j*(t.object.right-t.object.left)/t.object.zoom/$A.clientWidth,t.object.matrixWorld),J(WA*(t.object.top-t.object.bottom)/t.object.zoom/$A.clientHeight,t.object.matrixWorld)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function H(P){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?C/=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Z(P){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?C*=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function X(P,_A){if(!t.zoomToCursor)return;G=!0;const IA=t.domElement.getBoundingClientRect(),j=P-IA.left,WA=_A-IA.top,$A=IA.width,ae=IA.height;m.x=j/$A*2-1,m.y=-(WA/ae)*2+1,S.set(m.x,m.y,1).unproject(t.object).sub(t.object.position).normalize()}function nA(P){return Math.max(t.minDistance,Math.min(t.maxDistance,P))}function lA(P){Q.set(P.clientX,P.clientY)}function SA(P){X(P.clientX,P.clientX),d.set(P.clientX,P.clientY)}function qA(P){h.set(P.clientX,P.clientY)}function ZA(P){E.set(P.clientX,P.clientY),c.subVectors(E,Q).multiplyScalar(t.rotateSpeed);const _A=t.domElement;O(2*Math.PI*c.x/_A.clientHeight),b(2*Math.PI*c.y/_A.clientHeight),Q.copy(E),t.update()}function CA(P){p.set(P.clientX,P.clientY),f.subVectors(p,d),f.y>0?H(T(f.y)):f.y<0&&Z(T(f.y)),d.copy(p),t.update()}function DA(P){u.set(P.clientX,P.clientY),l.subVectors(u,h).multiplyScalar(t.panSpeed),L(l.x,l.y),h.copy(u),t.update()}function TA(P){X(P.clientX,P.clientY),P.deltaY<0?Z(T(P.deltaY)):P.deltaY>0&&H(T(P.deltaY)),t.update()}function OA(P){let _A=!1;switch(P.code){case t.keys.UP:P.ctrlKey||P.metaKey||P.shiftKey?b(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(0,t.keyPanSpeed),_A=!0;break;case t.keys.BOTTOM:P.ctrlKey||P.metaKey||P.shiftKey?b(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(0,-t.keyPanSpeed),_A=!0;break;case t.keys.LEFT:P.ctrlKey||P.metaKey||P.shiftKey?O(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(t.keyPanSpeed,0),_A=!0;break;case t.keys.RIGHT:P.ctrlKey||P.metaKey||P.shiftKey?O(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):L(-t.keyPanSpeed,0),_A=!0;break}_A&&(P.preventDefault(),t.update())}function XA(P){if(R.length===1)Q.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);Q.set(IA,j)}}function HA(P){if(R.length===1)h.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);h.set(IA,j)}}function JA(P){const _A=ue(P),IA=P.pageX-_A.x,j=P.pageY-_A.y,WA=Math.sqrt(IA*IA+j*j);d.set(0,WA)}function V(P){t.enableZoom&&JA(P),t.enablePan&&HA(P)}function fA(P){t.enableZoom&&JA(P),t.enableRotate&&XA(P)}function LA(P){if(R.length==1)E.set(P.pageX,P.pageY);else{const IA=ue(P),j=.5*(P.pageX+IA.x),WA=.5*(P.pageY+IA.y);E.set(j,WA)}c.subVectors(E,Q).multiplyScalar(t.rotateSpeed);const _A=t.domElement;O(2*Math.PI*c.x/_A.clientHeight),b(2*Math.PI*c.y/_A.clientHeight),Q.copy(E)}function wA(P){if(R.length===1)u.set(P.pageX,P.pageY);else{const _A=ue(P),IA=.5*(P.pageX+_A.x),j=.5*(P.pageY+_A.y);u.set(IA,j)}l.subVectors(u,h).multiplyScalar(t.panSpeed),L(l.x,l.y),h.copy(u)}function VA(P){const _A=ue(P),IA=P.pageX-_A.x,j=P.pageY-_A.y,WA=Math.sqrt(IA*IA+j*j);p.set(0,WA),f.set(0,Math.pow(p.y/d.y,t.zoomSpeed)),H(f.y),d.copy(p);const $A=(P.pageX+_A.x)*.5,ae=(P.pageY+_A.y)*.5;X($A,ae)}function re(P){t.enableZoom&&VA(P),t.enablePan&&wA(P)}function q(P){t.enableZoom&&VA(P),t.enableRotate&&LA(P)}function F(P){t.enabled!==!1&&(R.length===0&&(t.domElement.addEventListener("pointermove",aA),window.addEventListener("pointerup",MA)),le(P),P.pointerType==="touch"?UA(P):mA(P))}function aA(P){t.enabled!==!1&&(P.pointerType==="touch"?Le(P):FA(P))}function MA(P){switch(te(P),R.length){case 0:t.domElement.removeEventListener("pointermove",aA),t.domElement.removeEventListener("pointerup",MA),t.dispatchEvent(Hq),I=g.NONE;break;case 1:const _A=R[0],IA=w[_A];UA({pointerId:_A,pageX:IA.x,pageY:IA.y});break}}function mA(P){let _A;switch(P.button){case 0:_A=t.mouseButtons.LEFT;break;case 1:_A=t.mouseButtons.MIDDLE;break;case 2:_A=t.mouseButtons.RIGHT;break;default:_A=-1}switch(_A){case iB.DOLLY:if(t.enableZoom===!1)return;SA(P),I=g.DOLLY;break;case iB.ROTATE:if(P.ctrlKey||P.metaKey||P.shiftKey){if(t.enablePan===!1)return;qA(P),I=g.PAN}else{if(t.enableRotate===!1)return;lA(P),I=g.ROTATE}break;case iB.PAN:if(P.ctrlKey||P.metaKey||P.shiftKey){if(t.enableRotate===!1)return;lA(P),I=g.ROTATE}else{if(t.enablePan===!1)return;qA(P),I=g.PAN}break;default:I=g.NONE}I!==g.NONE&&t.dispatchEvent(dk)}function FA(P){switch(I){case g.ROTATE:if(t.enableRotate===!1)return;ZA(P);break;case g.DOLLY:if(t.enableZoom===!1)return;CA(P);break;case g.PAN:if(t.enablePan===!1)return;DA(P);break}}function Ie(P){t.enabled===!1||t.enableZoom===!1||I!==g.NONE||(P.preventDefault(),t.dispatchEvent(dk),TA(YA(P)),t.dispatchEvent(Hq))}function YA(P){const _A=P.deltaMode,IA={clientX:P.clientX,clientY:P.clientY,deltaY:P.deltaY};switch(_A){case 1:IA.deltaY*=16;break;case 2:IA.deltaY*=100;break}return P.ctrlKey&&!k&&(IA.deltaY*=10),IA}function ee(P){P.key==="Control"&&(k=!0,t.domElement.getRootNode().addEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ce(P){P.key==="Control"&&(k=!1,t.domElement.getRootNode().removeEventListener("keyup",Ce,{passive:!0,capture:!0}))}function De(P){t.enabled===!1||t.enablePan===!1||OA(P)}function UA(P){switch(PA(P),R.length){case 1:switch(t.touches.ONE){case gB.ROTATE:if(t.enableRotate===!1)return;XA(P),I=g.TOUCH_ROTATE;break;case gB.PAN:if(t.enablePan===!1)return;HA(P),I=g.TOUCH_PAN;break;default:I=g.NONE}break;case 2:switch(t.touches.TWO){case gB.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;V(P),I=g.TOUCH_DOLLY_PAN;break;case gB.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;fA(P),I=g.TOUCH_DOLLY_ROTATE;break;default:I=g.NONE}break;default:I=g.NONE}I!==g.NONE&&t.dispatchEvent(dk)}function Le(P){switch(PA(P),I){case g.TOUCH_ROTATE:if(t.enableRotate===!1)return;LA(P),t.update();break;case g.TOUCH_PAN:if(t.enablePan===!1)return;wA(P),t.update();break;case g.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;re(P),t.update();break;case g.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;q(P),t.update();break;default:I=g.NONE}}function he(P){t.enabled!==!1&&P.preventDefault()}function le(P){R.push(P.pointerId)}function te(P){delete w[P.pointerId];for(let _A=0;_A<R.length;_A++)if(R[_A]==P.pointerId){R.splice(_A,1);return}}function PA(P){let _A=w[P.pointerId];_A===void 0&&(_A=new gA,w[P.pointerId]=_A),_A.set(P.pageX,P.pageY)}function ue(P){const _A=P.pointerId===R[0]?R[1]:R[0];return w[_A]}t.domElement.addEventListener("contextmenu",he),t.domElement.addEventListener("pointerdown",F),t.domElement.addEventListener("pointercancel",MA),t.domElement.addEventListener("wheel",Ie,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",ee,{passive:!0,capture:!0}),this.update()}};class cP extends uA{constructor(A,e,t,g=128){if(e<=0||t<=0||g<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const I=new Os(t,2*g,g);I.scale(1,1,-1);const o=I.getAttribute("position"),s=new y;for(let n=0;n<o.count;++n)if(s.fromBufferAttribute(o,n),s.y<0){const C=-e*3/2,a=s.y<C?-e/s.y:1-s.y*s.y/(3*C*C);s.multiplyScalar(a),s.toArray(o.array,3*n)}o.needsUpdate=!0,super(I,new rt({map:A,depthWrite:!1}))}}const mD=Symbol("cameraController");function XgA(i){return i[mD]}function Pq(i,A,e){e?i[mD]=A:i[mD]===A&&(i[mD]=null)}const Wq=Symbol("camera autofit");function $gA(i){return i[Wq]===void 0?!0:i[Wq]!==!1}var AIA=Object.defineProperty,eIA=Object.getOwnPropertyDescriptor,tIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?eIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&AIA(A,e,g),g};class uu extends NA{constructor(){super(...arguments);r(this,"constraintActive",!0);r(this,"locked",!1);r(this,"sources",[])}}tIA([D(pA)],uu.prototype,"sources",2);function iIA(i){Au(i,Xi.ContextCreated)}function gIA(i){Au(i,eg.Start)}function hP(i){Au(i,eg.Update)}function IIA(i){Au(i,eg.OnBeforeRender)}class NB{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static sizeOf(){return 12}static createVec3(A,e,t,g){return A.prep(4,12),A.writeFloat32(g),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class lP{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}position(A){return(A||new NB).__init(this.bb_pos,this.bb)}rotation(A){return(A||new NB).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new NB).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,t,g,I,o,s,n,C,a){return A.prep(4,36),A.prep(4,12),A.writeFloat32(a),A.writeFloat32(C),A.writeFloat32(n),A.prep(4,12),A.writeFloat32(s),A.writeFloat32(o),A.writeFloat32(I),A.prep(4,12),A.writeFloat32(g),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class DC{constructor(){r(this,"bb",null);r(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedTransformModel(A,e){return(e||new DC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+HU),(e||new DC).__init(A.readInt32(A.position())+A.position(),A)}guid(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}fast(){const A=this.bb.__offset(this.bb_pos,6);return A?!!this.bb.readInt8(this.bb_pos+A):!1}transform(A){const e=this.bb.__offset(this.bb_pos,8);return e?(A||new lP).__init(this.bb_pos+e,this.bb):null}dontSave(){const A=this.bb.__offset(this.bb_pos,10);return A?!!this.bb.readInt8(this.bb_pos+A):!1}static startSyncedTransformModel(A){A.startObject(4)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addFast(A,e){A.addFieldInt8(1,+e,0)}static addTransform(A,e){A.addFieldStruct(2,e,0)}static addDontSave(A,e){A.addFieldInt8(3,+e,0)}static endSyncedTransformModel(A){return A.endObject()}static finishSyncedTransformModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedTransformModelBuffer(A,e){A.finish(e,void 0,!0)}}var fg=(i=>(i[i.Average=0]="Average",i[i.Multiply=1]="Multiply",i[i.Minimum=2]="Minimum",i[i.Maximum=3]="Maximum",i))(fg||{}),dS=(i=>(i[i.Discrete=0]="Discrete",i[i.Continuous=1]="Continuous",i))(dS||{}),qi=(i=>(i[i.None=0]="None",i[i.FreezePositionX=2]="FreezePositionX",i[i.FreezePositionY=4]="FreezePositionY",i[i.FreezePositionZ=8]="FreezePositionZ",i[i.FreezePosition=14]="FreezePosition",i[i.FreezeRotationX=16]="FreezeRotationX",i[i.FreezeRotationY=32]="FreezeRotationY",i[i.FreezeRotationZ=64]="FreezeRotationZ",i[i.FreezeRotation=112]="FreezeRotation",i[i.FreezeAll=126]="FreezeAll",i))(qi||{}),yE=(i=>(i[i.None=0]="None",i[i.X=2]="X",i[i.Y=4]="Y",i[i.Z=8]="Z",i[i.All=-1]="All",i))(yE||{});const $g=function(i,A){return function(e,t,g){oIA(e,t,g,i,A)}};function oIA(i,A,e,t,g){if(!g&&!t&&!i.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",i,A,e),Ui("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,ss.Error);return}let I="";if(typeof A=="string"?I=A:I=A.name,i.__internalAwake){const o=Symbol(I),s=i.__internalAwake;i.__internalAwake=function(){var n;if(!this.onValidate){Ge()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((n=i.constructor)==null?void 0:n.name)+'"');return}if(this[o]===void 0){this[o]=this[I];const C=this[I];if(C instanceof gA||C instanceof y||C instanceof oe||C instanceof RA){const a=this[I];Tw(a,()=>{this.onValidate(I)})}Object.defineProperty(this,I,{set:function(a){var B;if(this[nM]===!0)this[o]=a;else{t==null||t.call(this,a);const Q=this[o];this[o]=a,(B=this.onValidate)==null||B.call(this,I,Q)}},get:function(){return g==null||g.call(this),this[o]}})}s.call(this)}}}const sIA=function(i){return function(A,e,t){let g="";typeof e=="string"?g=e:g=e.name;const I=i.prototype,o=Object.getOwnPropertyDescriptor(I,g);if(!(o!=null&&o.value)){console.warn("Can not apply prefix: type does not have method named",e,i);return}const s=o.value,n=A[g];Object.defineProperty(I,g,{value:function(...C){const a=n==null?void 0:n.call(this,...C);if(a instanceof Promise){a.then(B=>{if(B!==!1)return s.call(this,...C)});return}if(a!==!1)return s.call(this,...C)}})}};var nIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,hs=(i,A,e,t)=>{for(var g=t>1?void 0:t?CIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&nIA(A,e,g),g};class aIA{constructor(A,e){r(this,"positionChanged",!1);r(this,"rotationChanged",!1);r(this,"position");r(this,"quaternion");r(this,"_positionKeys",["x","y","z"]);r(this,"_quaternionKeys",["_x","_y","_z","_w"]);r(this,"mute",!1);r(this,"context");r(this,"obj");r(this,"_positionWatch");r(this,"_rotationWatch");this.context=e,this.obj=A}get isDirty(){return this.positionChanged||this.rotationChanged}reset(A=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,A){if(this.position)for(const e of this._positionKeys)delete this.position[e];if(this.quaternion)for(const e of this._quaternionKeys)delete this.quaternion[e]}}syncValues(){for(const A of this._positionKeys)this.position[A]=this.obj.position[A];for(const A of this._quaternionKeys)this.quaternion[A]=this.obj.quaternion[A]}applyValues(){if(this.positionChanged&&this.position)for(const A of this._positionKeys){const e=this.position[A];e!==void 0&&(this.obj.position[A]=e)}if(this.rotationChanged&&this.quaternion)for(const A of this._quaternionKeys){const e=this.quaternion[A];e!==void 0&&(this.obj.quaternion[A]=e)}}start(A,e){this.reset(),A&&(this._positionWatch||(this._positionWatch=new UC(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.position[o];Math.abs(s-I)<1e-5||(this.position[o]=I,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new UC(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.quaternion[o];Math.abs(s-I)<1e-5||(this.quaternion[o]=I,this.rotationChanged=!0)}));const t=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),g=new GA;this.obj.matrixWorld.multiplyMatrices=(I,o)=>{var s;return(s=this.context.physics.engine)!=null&&s.isUpdating||this.mute||g.equals(I)||(this.positionChanged=!0,this.rotationChanged=!0,g.copy(I)),t(I,o)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var AG;const XM=(AG=class extends NA{constructor(){super(...arguments);r(this,"autoMass",!0);r(this,"_mass",0);r(this,"useGravity",!0);r(this,"constraints",qi.None);r(this,"isKinematic",!1);r(this,"drag",0);r(this,"angularDrag",1);r(this,"detectCollisions",!0);r(this,"sleepThreshold",.01);r(this,"collisionDetectionMode",dS.Discrete);r(this,"_gravityScale",1);r(this,"dominanceGroup",0);r(this,"_propertiesChanged",!1);r(this,"_currentVelocity",new y);r(this,"_smoothedVelocity",new y);r(this,"_smoothedVelocityGetter",new y);r(this,"_lastPosition",new y);r(this,"_watch")}set mass(A){A!==this._mass&&(this._mass=A,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var A,e;return this.autoMass?((e=(A=this.context.physics.engine)==null?void 0:A.getBody(this))==null?void 0:e.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&qi.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&qi.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&qi.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&qi.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&qi.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&qi.FreezeRotationZ)!==0}set lockPositionX(A){A?this.constraints|=qi.FreezePositionX:this.constraints&=~qi.FreezePositionX}set lockPositionY(A){A?this.constraints|=qi.FreezePositionY:this.constraints&=~qi.FreezePositionY}set lockPositionZ(A){A?this.constraints|=qi.FreezePositionZ:this.constraints&=~qi.FreezePositionZ}set lockRotationX(A){A?this.constraints|=qi.FreezeRotationX:this.constraints&=~qi.FreezeRotationX}set lockRotationY(A){A?this.constraints|=qi.FreezeRotationY:this.constraints&=~qi.FreezeRotationY}set lockRotationZ(A){A?this.constraints|=qi.FreezeRotationZ:this.constraints&=~qi.FreezeRotationZ}set gravityScale(A){this._gravityScale=A}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new aIA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),eg.LateUpdate)}onDisable(){var A,e;(A=this._watch)==null||A.stop(),(e=this.context.physics.engine)==null||e.removeBody(this)}onDestroy(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){var A,e,t,g;for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,(A=this.context.physics.engine)==null||A.updateProperties(this)),(e=this._watch)!=null&&e.isDirty?(this._watch.mute=!0,this._watch.applyValues(),(t=this.context.physics.engine)==null||t.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):(g=this._watch)==null||g.syncValues(),this.captureVelocity(),yield}teleport(A,e=!0){var t;(t=this._watch)==null||t.reset(!0),e?this.gameObject.position.set(A.x,A.y,A.z):this.setWorldPosition(A.x,A.y,A.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(A=!0){var e;(e=this.context.physics.engine)==null||e.resetForces(this,A)}resetTorques(A=!0){var e;(e=this.context.physics.engine)==null||e.resetTorques(this,A)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var A;(A=this.context.physics.engine)==null||A.wakeup(this)}get isSleeping(){var A;return(A=this.context.physics.engine)==null?void 0:A.isSleeping(this)}updateProperties(){var A;return this._propertiesChanged=!1,(A=this.context.physics.engine)==null?void 0:A.updateProperties(this)}applyForce(A,e,t=!0){var g;this._propertiesChanged&&this.updateProperties(),(g=this.context.physics.engine)==null||g.addForce(this,A,t)}applyImpulse(A,e=!0){var t;this._propertiesChanged&&this.updateProperties(),(t=this.context.physics.engine)==null||t.applyImpulse(this,A,e)}setForce(A,e,t,g=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,g),typeof A=="number"?(e??(e=0),t??(t=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:A,y:e,z:t},g)):(s=this.context.physics.engine)==null||s.addForce(this,A,g)}getVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(A,e,t,g=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,g);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:A,y:e,z:t},g)}getAngularVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getAngularVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(A,e,t,g=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,g);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:A,y:e,z:t},g)}setTorque(A,e,t){this.setAngularVelocity(A,e,t)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(A=null){}captureVelocity(){const A=Je(this.gameObject);XM.tempPosition.copy(A);const e=A.sub(this._lastPosition);this._lastPosition.copy(XM.tempPosition),this._smoothedVelocity.lerp(e,this.context.time.deltaTime/.1)}},r(AG,"tempPosition",new y),AG);let ei=XM;hs([$g()],ei.prototype,"autoMass",2);hs([D()],ei.prototype,"mass",1);hs([$g(),D()],ei.prototype,"useGravity",2);hs([$g(),D()],ei.prototype,"constraints",2);hs([$g(),D()],ei.prototype,"isKinematic",2);hs([$g(),D()],ei.prototype,"drag",2);hs([$g(),D()],ei.prototype,"angularDrag",2);hs([$g(),D()],ei.prototype,"detectCollisions",2);hs([$g(),D()],ei.prototype,"sleepThreshold",2);hs([$g(),D()],ei.prototype,"collisionDetectionMode",2);hs([$g()],ei.prototype,"_gravityScale",2);hs([$g()],ei.prototype,"dominanceGroup",2);const nC=oA("debugsync"),cd="STRS";PU(cd,DC.getRootAsSyncedTransformModel);const tn=new eu;function dP(i,A,e=!0){tn.clear();const t=tn.createString(i);DC.startSyncedTransformModel(tn),DC.addGuid(tn,t),DC.addFast(tn,e);const g=A.worldPosition,I=A.worldEuler,o=A.gameObject.scale;DC.addTransform(tn,lP.createTransform(tn,g.x,g.y,g.z,I.x,I.y,I.z,o.x,o.y,o.z));const s=DC.endSyncedTransformModel(tn);return tn.finish(s,cd),tn.asUint8Array()}let $M=0,Sl=0;hP(i=>{var t;const e=((t=i.connection.currentServerUrl)==null?void 0:t.includes("glitch"))?10:40;Sl=Math.floor($M/e),$M=0,nC&&Sl>0&&console.log("Sync Transform Fast Interval",Sl)});class sr extends NA{constructor(){super(...arguments);r(this,"overridePhysics",!0);r(this,"interpolatePosition",!0);r(this,"interpolateRotation",!0);r(this,"fastMode",!1);r(this,"syncDestroy",!1);r(this,"_model",null);r(this,"_needsUpdate",!0);r(this,"rb",null);r(this,"_wasKinematic",!1);r(this,"_receivedDataBefore",!1);r(this,"_targetPosition");r(this,"_targetRotation");r(this,"_receivedFastUpdate",!1);r(this,"_shouldRequestOwnership",!1);r(this,"joinedRoomCallback",null);r(this,"receivedDataCallback",null);r(this,"tempEuler",new Og);r(this,"receivedUpdate",!1);r(this,"lastWorldPos");r(this,"lastWorldRotation")}requestOwnership(){nC&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}hasOwnership(){var e;return((e=this._model)==null?void 0:e.hasOwnership)??void 0}isOwned(){var e;return(e=this._model)==null?void 0:e.isOwned}awake(){nC&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new y,this._targetRotation=new RA,this.lastWorldPos=new y,this.lastWorldRotation=new RA,this.rb=BA.getComponentInChildren(this.gameObject,ei),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new XU(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(dt.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(cd,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&EO(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(dt.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(cd,this.receivedDataCallback)}tryGetLastState(){const e=this.context.connection.tryGetState(this.guid);e&&this.onReceivedData(e)}onReceivedData(e){var t;if(!this.destroyed&&typeof e.guid=="function"&&e.guid()===this.guid){nC&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const g=e.transform();if(g){Ls.markDirty(this.gameObject,!0);const I=g.position();I&&(this.interpolatePosition&&((t=this._targetPosition)==null||t.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=g.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&vN(this.gameObject,this.tempEuler))}this._receivedDataBefore=!0}}onEnable(){this.lastWorldPos.copy(this.worldPosition),this.lastWorldRotation.copy(this.worldQuaternion),this._needsUpdate=!0,this._model&&this._model.updateIsOwned()}onDisable(){this._model&&this._model.freeOwnership()}onBeforeRender(){if(!this.activeAndEnabled||!this.context.connection.isConnected)return;if(!this.context.connection.isInRoom||!this._model){nC&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const e=this.worldPosition,t=this.worldQuaternion;if(this._model.isOwned&&!this.receivedUpdate){const o=e.distanceTo(this.lastWorldPos),s=t.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(nC&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastWorldPos),this.worldPosition=this.lastWorldPos,e.copy(this.lastWorldPos),this.worldQuaternion=this.lastWorldRotation,t.copy(this.lastWorldRotation),Ls.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const s=this._receivedFastUpdate||this.fastMode?.5:.3;let n=!1;if(this.interpolatePosition&&this._targetPosition){const C=this.worldPosition;C.lerp(this._targetPosition,s),this.worldPosition=C,n=!0}if(this.interpolateRotation&&this._targetRotation){const C=this.worldQuaternion;C.slerp(this._targetRotation,s),this.worldQuaternion=C,n=!0}n&&Ls.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastWorldPos.copy(e),this.lastWorldRotation.copy(t),!this._model)return;if(!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership){this.rb&&(this.rb.isKinematic=this._model.isOwned??!1,this.rb.setVelocity(0,0,0));return}this.rb&&(this._wasKinematic!==void 0&&(nC&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic),this.gameObject.position.distanceTo(new y(0,0,0))>1e3&&(nC&&console.log("RESET",this.name),this.gameObject.position.set(0,1,0),this.rb.setVelocity(0,0,0)));const g=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%g===0||I)){if($M++,I&&Sl>0&&this.context.time.frameCount%Sl!==0)return;nC&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this.overridePhysics&&this.rb,this._needsUpdate=!1;const o=dP(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const rIA=oA("debugshadowcomponents");MN.prototype.interactable={get(){return this.interactive},set(i){this.interactable=i}};const es=Symbol("shadowDomOwner");class _s extends NA{constructor(){super(...arguments);r(this,"_shadowComponent",null);r(this,"_controlsChildLayout",!0);r(this,"_root");r(this,"_parentComponent")}isRoot(){var e;return((e=this.Root)==null?void 0:e.gameObject)===this.gameObject}get canvas(){const e=this.Root;return e!=null&&e.isCanvas?e:null}get Canvas(){return this.canvas}markDirty(){eo.markUIDirty(this.context)}get shadowComponent(){return this._shadowComponent}set shadowComponent(e){this._shadowComponent=e}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(e){this._controlsChildLayout=e,this.shadowComponent&&(this.shadowComponent.autoLayout=e)}get Root(){return this._root===void 0&&(this._root=BA.getComponentInParent(this.gameObject,pu)),this._root}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0}onEnable(){super.onEnable()}addShadowComponent(e,t){var o;this.removeShadowComponent();const g=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=BA.getComponentInParent(g,_s),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`,this);return}e.name=this.name+" ("+(this.constructor.name??"UI")+")",e.autoLayout=this._parentComponent.controlsChildLayout,e[es]=this,this.setShadowComponentOwner(e);let I=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(e);else{const s=this._parentComponent.shadowComponent;s&&(s==null||s.add(e),I=!0)}this.shadowComponent=e,t&&t.shadowComponent&&this.shadowComponent&&t.shadowComponent.add(this.shadowComponent),$d&&e.add(new Cs(.5)),this.onAfterAddedToScene(),I&&X2(),rIA&&console.log(this.shadowComponent)}setShadowComponentOwner(e){if(e&&(e[es]===void 0||e[es]===this)&&(e[es]=this,e.children))for(const t of e.children)this.setShadowComponentOwner(t)}traverseOwnedShadowComponents(e,t,g){if(e&&e[es]===t){g(e);for(const I of e.children)this.traverseOwnedShadowComponents(I,t,g)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(e){this.shadowComponent&&(this.shadowComponent.interactable=e)}}class pu extends _s{awake(){super.awake()}}class Fc{constructor(A,e){r(this,"event");r(this,"button");r(this,"buttonName");r(this,"_used",!1);r(this,"_propagationStopped",!1);r(this,"z__pointer_ctured",!1);r(this,"z__pointer_cture_rleased",!1);r(this,"inputSource");r(this,"object");r(this,"point");r(this,"normal");r(this,"face");r(this,"distance");r(this,"instanceId");r(this,"isDown");r(this,"isUp");r(this,"isPressed");r(this,"isClick");r(this,"isDoubleClick");r(this,"input");this.event=e,this.input=A,this.button=e.button}get deviceIndex(){return this.event.deviceIndex}get pointerId(){return this.event.pointerId}get pressure(){return this.event.pressure}get used(){return this._used}use(){this._used||(this._used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId))}get propagationStopped(){return this._propagationStopped}stopPropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}stopImmediatePropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}setPointerCapture(){this.z__pointer_ctured=!0}releasePointerCapture(){this.z__pointer_cture_rleased=!0}get mode(){return this.event.mode}clone(){const A=new Fc(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function AR(i,A){return BA.foreachComponent(i,t=>{if(!t.enabled)return;const g=t;if(A)switch(A){case"pointerdown":if(g.onPointerDown)return!0;break;case"pointerup":if(g.onPointerUp||g.onPointerClick)return!0;break;case"pointermove":if(g.onPointerEnter||g.onPointerExit||g.onPointerMove)return!0;break}else if(g.onPointerDown||g.onPointerUp||g.onPointerEnter||g.onPointerExit||g.onPointerClick)return!0},!1)===!0}var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,EIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?QIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&BIA(A,e,g),g};class fu extends NA{awake(){eo.createIfNoneExists(this.context)}onEnable(){var A;(A=eo.get(this.context))==null||A.register(this)}onDisable(){var A;(A=eo.get(this.context))==null||A.unregister(this)}}class Mo extends fu{constructor(){super(...arguments);r(this,"targets",null);r(this,"raycastHits",[]);r(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Bs),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=I=>I instanceof qs?"continue in children":t?t(I):!0);const g=this.context.physics.raycast(e);return e.testObject=t,g}}EIA([D()],Mo.prototype,"ignoreSkinnedMeshes",2);class uS extends Mo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class hd extends fu{performRaycast(A){if(!pe.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.01;return this.context.physics.sphereOverlap(e,t)}}class pS{static getObject(A){const e=A[es];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const g=OB(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&(g==null?void 0:g.isGraphic)===!0&&(e.graphic=g),!((g==null?void 0:g.raycastTarget)===!1||(g==null?void 0:g.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=OB(A,t=>{const g=t;if(g.blocksRaycasts!==void 0&&g.interactable!==void 0)return g},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function $N(i){const A=i[es];return A||(i.parent?$N(i.parent):null)}function cIA(i){return i.isUI===!0||typeof i[es]=="object"}function Ry(i,A){if(!i)return;const e=i.material;if((e==null?void 0:e.isMaterial)===!0){const t=i.parent;t&&t.isText,e.side=A.doubleSided??!0?wt:Pg,e.shadowSide=A.doubleSided?wt:Pg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of i.children)Ry(t,A)}function aE(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const t=Proxy.revocable(i[A],{set(o,s,n,C){const a=o[s],B=Reflect.set(o,s,n,C);return e(n,a),B}}),g=t.revoke,I=i[A];return t.revoke=()=>{i[A]=I,g()},i[A]=t.proxy,t}const jq=Symbol("Scheduled action");function hIA(i,A,e=eg.OnBeforeRender){let t=i[jq];t||(t=i[jq]={});const g=A.name;t[e]||(t[e]={});const I=t[e];if(I[g])return;function*s(){A==null||A.call(i),I[g]=null}const n=i.startCoroutine(s(),e);I[g]=n}const CC=oA("debugeventsystem");var eR=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(eR||{});const Bn=class extends NA{constructor(){super();r(this,"raycaster",[]);r(this,"_handleInputFn");r(this,"pressedByID",new Map);r(this,"hoveredByID",new Map);r(this,"_sortedHits",[]);r(this,"_testObjectsCache",new Map);r(this,"_currentlyActiveRaycaster",null);r(this,"_currentPointerEventName",null);r(this,"shouldRaycastObject",e=>{var I;let t=null;if(cIA(e)&&(t=(I=e[es])==null?void 0:I.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let o=AR(e,this._currentPointerEventName);if(!o&&t&&(o=AR(t,this._currentPointerEventName)),o){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});r(this,"_sortingBuffer",[]);r(this,"_noDepthTestingResults",[]);r(this,"out",{});r(this,"_capturedPointer",{});r(this,"pointerEnterSymbol",Symbol("pointerEnter"));r(this,"pointerExitSymbol",Symbol("pointerExit"));r(this,"currentActiveMeshUIComponents",[]);Bn.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Bn.systems.length<=0&&Bn.systems.push(...BA.findObjectsOfType(Bn,e)));for(const g of Bn.systems)if(g.context===e)return;const t=new pA;BA.addNewComponent(t,Bn),e.scene.add(t)}static get systems(){const e=ve.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,g=!1){qa.update(e,t,g)}static markUIDirty(e){qa.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Bn.systems.splice(Bn.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!BA.findObjectOfType(fu,this.context)){const t=BA.addNewComponent(this.context.scene,Mo);this.raycaster.push(t),(Ge()||CC)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var g,I;const t=(g=this.raycaster)==null?void 0:g.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(si.PointerDown,this._handleInputFn),this.context.input.addEventListener(si.PointerUp,this._handleInputFn),this.context.input.addEventListener(si.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(si.PointerDown,this._handleInputFn),this.context.input.removeEventListener(si.PointerUp,this._handleInputFn),this.context.input.removeEventListener(si.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(e){if(e===void 0||e.propagationStopped)return;const t=new Fc(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==si.PointerDown,t.isUp=e.type==si.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),CC&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const g=new Bs;e.ray?g.ray=e.ray:g.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const I=this.performRaycast(g);CC&&t.isClick&&Ui("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const o={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Bs),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const g=t.performRaycast(e);this._currentlyActiveRaycaster=null,g&&g.length>0&&this._sortedHits.push(...g)}return this._sortedHits.sort((t,g)=>t.distance-g.distance),this._sortedHits}assignHitInformation(e,t){t?(e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var I;if(e!=null&&e.length){e=this.sortCandidates(e);for(const o of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,o),this.handleEventOnObject(o.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const g=this.hoveredByID.get(t.pointerId);return g&&this.propagatePointerExit(g.obj,g.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((I=this.pressedByID.get(t.pointerId))==null||I.handlers.forEach(o=>this.invokeOnPointerUp(t,o)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const g=e[t],I=g.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(g);continue}this._sortingBuffer.push(g)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&CC&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return CC&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const g=e.parent;let I=!1;const o=t.isClick??!1;let s=null;if(g&&g.isUI){const Q=(t.isPressed||t.isClick)??!1;if(g[es]){const E=g[es].gameObject;if(E){if(!pS.isInteractable(E,this.out))return!1;s=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,Q),e=E,I=!0}}if(!I&&this.handleMeshUiObjectWithoutShadowDom(g,Q))return!0}o&&CC&&console.log(this.context.time.frame,e);const n=this.hoveredByID.get(t.pointerId),C=n==null?void 0:n.obj;C!==e&&C&&this.propagatePointerExit(C,n.data,e);const B=this.hoveredByID.get(t.pointerId);if(B?(B.obj=e,B.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const Q=this.pressedByID.get(t.pointerId);Q?(Q.obj=e,Q.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(s===null||s.interactable)&&this.handleMainInteraction(e,t,C??null),!0}propagate(e,t){for(;e;)BA.foreachComponent(e,g=>{t(g)},!1),e=e.parent}handleMainInteraction(e,t,g){const I=this.pressedByID.get(t.pointerId),o=g!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),C=this.context.input.getPointerPosition(t.pointerId);s=n&&!se.approximately(n,C);break}this.propagate(e,n=>{const C=n;C.interactable!==!1&&(!C.activeAndEnabled||!C.enabled||(C.onPointerEnter&&o&&this.handlePointerEnter(C,t),t.isDown&&C.onPointerDown&&(C.onPointerDown(t),I==null||I.handlers.add(C),this.handlePointerCapture(t,C)),C.onPointerMove&&(s&&C.onPointerMove(t),this.handlePointerCapture(t,C)),t.isUp&&C.onPointerUp&&(this.invokeOnPointerUp(t,C),I==null||I.handlers.delete(C)),t.isClick&&C.onPointerClick&&C.onPointerClick(t)))}),t.isUp&&(I==null||I.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,g){this.propagate(e,I=>{if(!I.gameObject||I.destroyed)return;const o=I;if(o.onPointerExit){if(g&&this.isChild(g,I.gameObject))return;this.handlePointerExit(o,t)}})}invokeOnPointerUp(e,t){var g;(g=t.onPointerUp)==null||g.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,g,I){let o=e[g];if(I)return o&&o.includes(t)?!1:(o=o||[],o.push(t),e[g]=o,!0);{if(!o||!o.includes(t))return!1;const s=o.indexOf(t);return s!==-1&&o.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const g=e.pointerId;if(t.onPointerMove){const I=this._capturedPointer[g]||[];I.push(t),this._capturedPointer[g]=I}else Ge()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const g=e.pointerId;if(this._capturedPointer[g]){const I=this._capturedPointer[g].indexOf(t);I!==-1&&(this._capturedPointer[g].splice(I,1),CC&&console.log("released pointer capture",g,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===si.PointerMove){const g=e.pointerId,I=this._capturedPointer[g];if(I){CC&&console.log("Captured",g,I);for(let o=0;o<I.length;o++){const s=I[o];if(s.destroyed){I.splice(o,1),o--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const g=qa.updateState(e,t);return g&&this.currentActiveMeshUIComponents.push(g),g!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qa.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];qa.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?BA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let eo=Bn;r(eo,"_eventSystemMap",new Map),r(eo,"didSearchEventSystem",!1);class qa{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const g=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(g===I.frame)return;I.frame=g;let o=this.needsUpdate||g<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(CC&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:g,nextUpdate:g}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}r(qa,"lastSelected",null),r(qa,"lastUpdateFrame",[]),r(qa,"needsUpdate",!1);var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,AI=(i,A,e,t)=>{for(var g=t>1?void 0:t?dIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&lIA(A,e,g),g};const uIA=oA("debugorbit"),Df=oA("freecam"),Rh=oA("debugcamerafit"),yf=oA("smoothcam"),pIA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let uk;class ld extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class ii extends NA{constructor(){super(...arguments);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"enableKeys",!0);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"useSlerp",!0);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"autoTarget",!0);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new y);r(this,"_lookTargetEndPosition",new y);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new y);r(this,"_cameraEndPosition",new y);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didStart",!1);r(this,"targetElement",null);r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const e=BA.getComponent(this.gameObject,ti);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const g=Je(e.cam).length(),I=new y(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(I,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new Bs;t.screenPoint=new gA(0,0),t.lineThreshold=.1;const g=this.context.physics.raycast(t);g.length>0&&this.setLookTargetPosition(g[0].point,!0),Rh&&console.log("OrbitControls hits",...g)}this.autoFit&&this.fitCamera()}this._eventSystem=eo.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(eR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(eR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=BA.getComponent(this.gameObject,ti);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Pq(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const g=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new ZgA(t,g),t==null||t.quaternion.copy(I),uk===void 0&&(uk={...this._controls.keys})}this._controls&&(Df&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,xn()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?Df||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Df||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=BA.getComponent(this.gameObject,sr)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Pq(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var t,g;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new ld(this,"camera"));else{const I=se.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new ld(this,"lookat"));else{const I=se.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?uk:pIA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof yf=="number"||yf===!0){this._controls.enableDamping=!0;const I=typeof yf=="number"?yf:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Df&&((g=this.lookAtConstraint)!=null&&g.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),uIA&&Ue.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof pA))return;const t=Je(e),g=KN(e);this.setTargetFromRaycast(new Uo(t,g)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var g,I;e&&(e instanceof pA&&(e=Je(e)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof pA&&(e=Je(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){var g,I;if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const o of t)if(o.distance>0&&BA.isActiveInHierarchy(o.object)){const s=$N(o.object);if(s){const n=s.canvas;if(n!=null&&n.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const C=Je(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(I=(g=this._cameraObject)==null?void 0:g.parent)==null||I.worldToLocal(C),this.setCameraTargetPosition(C)}break}}fitCamera(e,t=1.1,g=!0){const I=this._cameraObject,o=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!I||!o)return;const s=new y,n=new y,C=new Lt;C.makeEmpty();const a=[];function B(p){let f=!0;if(p.visible&&$gA(p)!==!1&&!(p.type==="TransformControlsGizmo"||p.type==="TransformControlsPlane")&&(p instanceof HG&&(f=!1),p instanceof Yw&&(f=!1),p instanceof cP&&(f=!1),p.material instanceof Nw&&(f=!1),p instanceof uA||(f=!1),p!==I&&p.isUI!==!0)){if(f){Rh&&console.log(p.name,p.type,p);const S=p.children;p.children=a;const m=p.position,G=p.scale;if(Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn(`Object "${p.name}" has NaN values in position or scale.... will ignore it`,m,G);return}C.expandByObject(p,!0),p.children=S}for(const S of p.children)B(S)}}for(const p of e)p.updateMatrixWorld(),B(p);if(I.updateMatrixWorld(),I.updateProjectionMatrix(),C.getCenter(n),C.applyMatrix4(I.matrixWorldInverse),C.getSize(s),C.setFromCenterAndSize(n,s),Number.isNaN(s.x)||Number.isNaN(s.y)||Number.isNaN(s.z)){console.warn("Camera fit size resultet in NaN",I,C,[...e]);return}if(s.length()<=1e-10){Rh&&console.warn("Camera fit size is zero",C,[...e]);return}const Q=I.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*I.aspect)/Math.PI*360,c=s.y/(2*Math.atan(Math.PI*Q/360)),h=s.x/(2*Math.atan(Math.PI*E/360)),u=t*Math.max(c,h)+s.z/2;Rh&&console.log("Fit camera to objects",c,h,"distance",u);const l=Je(I),d=o.target.clone().sub(l).normalize().multiplyScalar(u);if(o.maxDistance=u*10,o.minDistance=u*.01,this.setLookTargetPosition(n,g),this.autoTarget=!1,I.near=u/1e3,I.far=u*100,I.updateMatrixWorld(),I.updateProjectionMatrix(),I.parent){const p=I.parent.worldToLocal(o.target.clone().sub(d));this.setCameraTargetPosition(p,g)}else console.error(`Can not fit camera ${I.name} because it has no parent`);if(Rh){const p=new HG(C);this.context.scene.add(p),bN(p,nu(I)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",f=>{f.code==="KeyF"&&this.fitCamera(e)}))}o.update()}}AI([D()],ii.prototype,"autoFit",2);AI([D()],ii.prototype,"enableRotate",2);AI([D()],ii.prototype,"autoRotate",2);AI([D()],ii.prototype,"autoRotateSpeed",2);AI([D()],ii.prototype,"enableKeys",2);AI([D()],ii.prototype,"enableDamping",2);AI([D()],ii.prototype,"dampingFactor",2);AI([D()],ii.prototype,"enableZoom",2);AI([D()],ii.prototype,"minZoom",2);AI([D()],ii.prototype,"maxZoom",2);AI([D()],ii.prototype,"enablePan",2);AI([D(uu)],ii.prototype,"lookAtConstraint",2);AI([D()],ii.prototype,"lookAtConstraint01",2);AI([D()],ii.prototype,"allowInterrupt",2);AI([D()],ii.prototype,"middleClickToFocus",2);AI([D()],ii.prototype,"doubleClickToFocus",2);AI([D()],ii.prototype,"targetLerpDuration",2);var fIA=Object.defineProperty,DIA=Object.getOwnPropertyDescriptor,Fo=(i,A,e,t)=>{for(var g=t>1?void 0:t?DIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&fIA(A,e,g),g},PB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(PB||{});const aB=oA("debugcam"),Vq=oA("debugscreenpointtoray");var jf;const tl=(jf=class extends NA{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof Ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof Ze?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof Ze){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const g=this.cam,I=tl._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Vq&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=tl._direction.set(I.x,I.y,I.z),s=Je(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new Uo(s.clone(),o.clone())}awake(){Vq&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);Ue.DrawRay(g.origin,g.direction,I,10)})}onEnable(){aB&&console.log(`Camera enabled: "${this.name}". ClearFlags=${PB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),wIA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof Ze&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ze&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new jC(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){aB&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,aB){const A=`Camera "${this.name}" clear flags: ${PB[this._clearFlags]}`;console.log(A)}switch(this._clearFlags){case 1:if(tl.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;tl.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else aB&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new yIA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;aB&&Ui("Environment blend mode: "+t+" on "+navigator.userAgent);let g=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(g=!0),e._transparent=g,g}},r(jf,"_origin",new y),r(jf,"_direction",new y),jf);let ti=tl;Fo([D()],ti.prototype,"fieldOfView",1);Fo([D()],ti.prototype,"nearClipPlane",1);Fo([D()],ti.prototype,"farClipPlane",1);Fo([D()],ti.prototype,"clearFlags",1);Fo([D()],ti.prototype,"orthographic",2);Fo([D()],ti.prototype,"orthographicSize",2);Fo([D()],ti.prototype,"ARBackgroundAlpha",2);Fo([D()],ti.prototype,"cullingMask",1);Fo([D()],ti.prototype,"backgroundBlurriness",1);Fo([D()],ti.prototype,"backgroundIntensity",1);Fo([D()],ti.prototype,"environmentIntensity",1);Fo([D(Kt)],ti.prototype,"backgroundColor",1);Fo([D(Za)],ti.prototype,"targetTexture",1);class yIA{constructor(A){r(this,"_camera");r(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(aB&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=We,this._skybox.mapping=Is,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(aB||Ge())&&fi(`Camera "${this._camera.name}" has no skybox texture`))}}function wIA(i){oA("freecam")&&i.context.mainCameraComponent===i&&BA.getOrAddComponent(i.gameObject,ii)}class Xa extends NA{constructor(){super(...arguments);r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new aT),this._listener}awake(){Ki.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||BA.getComponentInParent(this.gameObject,ti);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var SIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,fS=(i,A,e,t)=>{for(var g=t>1?void 0:t?mIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&SIA(A,e,g),g};const kIA=oA("debugsignals");class Du{constructor(){r(this,"guid")}}fS([D()],Du.prototype,"guid",2);class Kc{constructor(){r(this,"signal");r(this,"reaction")}}fS([D(Du)],Kc.prototype,"signal",2);fS([D(kg)],Kc.prototype,"reaction",2);var eG;const aC=(eG=class extends NA{constructor(){super(...arguments);r(this,"events")}static invoke(A){if(aC.receivers[A]){const e=aC.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){kIA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)aC.receivers[A.signal.guid]||(aC.receivers[A.signal.guid]=[]),aC.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(aC.receivers[A.signal.guid]){const e=aC.receivers[A.signal.guid].indexOf(this);e>=0&&aC.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(g){console.error(g)}}},r(eG,"receivers",{}),eG);let Jc=aC;fS([D(Kc)],Jc.prototype,"events",2);var Bo=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Bo||{}),rn=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(rn||{}),AF=(i=>(i.Signal="SignalEmitter",i))(AF||{});const Sn=oA("debugtimeline");class yu{constructor(){r(this,"director");r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class GIA{constructor(A){r(this,"clip");r(this,"rootPositionOffset");r(this,"rootQuaternionOffset");r(this,"rootStartPosition");r(this,"rootEndPosition");r(this,"rootStartQuaternion");r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";Sn&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new y().fromArray(o.values,0),this.rootEndPosition=new y().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Sn&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new RA().fromArray(o.values,0),this.rootEndQuaternion=new RA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Sn)){const s=new Og().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class DS extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"trackOffset");r(this,"target");r(this,"mixer");r(this,"clips",[]);r(this,"actions",[]);r(this,"_actionOffsets",[]);r(this,"_didBind",!1);r(this,"_animator",null);r(this,"_useclipOffsets",!0);r(this,"_totalOffsetPosition",new y);r(this,"_totalOffsetRotation",new RA);r(this,"_totalOffsetPosition2",new y);r(this,"_totalOffsetRotation2",new RA);r(this,"_summedPos",new y);r(this,"_tempPos",new y);r(this,"_summedRot",new RA);r(this,"_tempRot",new RA);r(this,"_clipRotQuat",new RA)}onStateChanged(){this._animator&&zq(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,B;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let n=!1,C=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(C=!0,this.createRotationInterpolant(t,e,Q));if(!n||!C){const Q=(B=this.mixer)==null?void 0:B.getRoot(),E=t.tracks[0],c=E.name.lastIndexOf("."),h=E.name.substring(0,c),u=h.substring(h.lastIndexOf(".")+1),l=Q.getObjectByName(u);if(l)if(n){if(!C){const d=t.tracks[0].name.substring(0,c)+".quaternion";Sn&&console.warn("Create quaternion track",u,l);const p=l.quaternion,f=new Jn(d,[0,t.duration],[p.x,p.y,p.z,p.w,p.x,p.y,p.z,p.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const d=h+".position";Sn&&console.warn("Create position track",u,l);const p=l.position,f=new xC(d,[0,t.duration],[p.x,p.y,p.z,p.x,p.y,p.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,Sn&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new GIA(e);this._actionOffsets.push(t)}this.target&&(this._animator=BA.getComponent(this.target,jg)??null,this._animator&&zq(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new y(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new RA(I.x,I.y,I.z,I.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new y(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new RA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,C,a,B,Q,E,c;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,g=0,I=!1,o=!1,s=0;for(let h=0;h<this.clips.length;h++){const u=this.models[h],l=this.actions[h],d=u.asset;l.weight=0;const p=e>=u.start&&e<=u.end,f=u.preExtrapolationMode,S=u.postExtrapolationMode,m=h<this.clips.length-1?this.models[h+1]:null;let G=p,R=!1;if(!G&&!I&&u.end<e&&S!==rn.None?(!m||m.start>e)&&(G=!0,I=!0):h==0&&!G&&!o&&u.start>e&&f!==rn.None&&(!m||m.start<e)&&(G=!0,R=!0,o=!0),G){let w=1;w*=this.evaluateWeight(e,h,this.models,G),w*=this.director.weight;let k=p;if(R)switch(f){case rn.Hold:break;case rn.Loop:e+=u.start,k=!0;break;default:e+=u.start,k=!0;break}let K=this.getClipTime(e,u),T=0;const O=d.duration;if(R&&f===rn.Hold&&(K=0),k){if(d.loop)for(T+=Math.floor(K/(O+1e-6));K>O;)K-=O}else if(!p&&I)switch(S){case rn.Hold:K=this.getClipTime(u.end,u);break;case rn.Loop:K%=O;break;case rn.PingPong:const J=Math.floor(K/O)%2!==0;K%=O,J&&(K=O-K);break}u.reversed===!0?l.time=l.getClip().duration-K:l.time=K,l.timeScale=0;const b=Math.max(0,w);if(l.weight=b,s+=b,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const _=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,J=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-w),t+=1;const L=this._summedPos.set(0,0,0),H=this._tempPos.set(0,0,0),Z=this._summedRot.identity(),X=this._tempRot.identity(),nA=d.rotation;nA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(nA,w));const lA=this._actionOffsets[h];if(lA.hasOffsets)for(let SA=0;SA<T;SA++)lA.rootPositionOffset?H.copy(lA.rootPositionOffset):H.set(0,0,0),H.applyQuaternion(Z),this._clipRotQuat&&H.applyQuaternion(this._clipRotQuat),lA.rootQuaternionOffset&&(X.copy(lA.rootQuaternionOffset),Z.multiply(X)),L.add(H);this._clipRotQuat&&J.multiply(this._clipRotQuat),J.multiply(Z),d.position&&L.add(d.position),_.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.__mixerError===void 0&&(Sn||Ge())&&((C=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&C.mixer)&&this.mixer!==((B=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:B.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const h=Math.max(0,1-s);(c=(E=this._animator)==null?void 0:E.runtimeAnimatorController)==null||c.update(h)}else this.mixer.update(e)}createRotationInterpolant(e,t,g){var n;const I=g.createInterpolant.bind(g),o=new RA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;g.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=B=>{var E;const Q=a(B);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const c of this.director.animationCallbackReceivers)(E=c==null?void 0:c.onTimelineRotation)==null||E.call(c,this.director,this.target,B,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(e,t,g){var a,B;const I=g.createInterpolant.bind(g),o=new y;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(B=this.trackOffset)==null?void 0:B.position;let C;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=c=>{var u,l,d;const h=E(c);if(o.set(h[0],h[1],h[2]),t.removeStartOffset&&(C===void 0?(C=null,C=(l=(u=this._actionOffsets.find(p=>p.clip===e))==null?void 0:u.rootStartPosition)==null?void 0:l.clone()):C!=null&&C.isVector3&&o.sub(C)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const p of this.director.animationCallbackReceivers)(d=p==null?void 0:p.onTimelinePosition)==null||d.call(p,this.director,this.target,c,o);return h[0]=o.x,h[1]=o.y,h[2]=o.z,h},Q}}}const MIA=oA("mutetimeline"),GE=class extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"listener");r(this,"audio",[]);r(this,"audioContextTimeOffset",[]);r(this,"lastTime",0);r(this,"audioSource");r(this,"_audioLoader",null);r(this,"_playableDirectorResumed",!1)}getAudioFilePath(e){const t=this.director.sourceId;return hr(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new lU(this.listener);this.audio.push(t);const g=e;g._didTriggerPlay=!1,this.models.push(g)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(MIA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=this._playableDirectorResumed;this._playableDirectorResumed=!1;const I=t?.1:0;for(let o=0;o<this.models.length;o++){const s=this.models[o],n=this.audio[o],C=s.asset;if((!n||!n.buffer)&&this.isInTimeRange(s,e-1,e+1)&&this.handleAudioLoading(s,n),Ki.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=C.loop,e>=s.start&&e<=s.end&&e<this.director.duration){if(!n.isPlaying||!this.director.isPlaying)(g||!s._didTriggerPlay&&this.lastTime<e)&&(s.duration*s.timeScale>.3?n.offset=s.clipIn+(e-s.start)*s.timeScale:n.offset=0,Sn&&console.log("Timeline Audio ("+this.track.name+") play with offset "+n.offset+" - "+s.asset.clip),n.play(I),s._didTriggerPlay=!0);else{const B=s.clipIn+(e-s.start)*s.timeScale,Q=n.context.currentTime-n._startedAt+n.offset;Math.abs(B-Q)>.3&&(n.offset=B,n.stop(),n.play(I))}let a=C.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),t&&(a=0),s.easeInDuration>0){const B=Math.min((e-s.start)/s.easeInDuration,1);a*=B}if(s.easeOutDuration>0){const B=Math.min((s.end-e)/s.easeOutDuration,1);a*=B}n.setVolume(a*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&n.isPlaying&&n.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const C=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,C);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){GE._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new ty);const g=this.getAudioFilePath(e.asset.clip);if(GE._audioBuffers.get(g)){const o=GE._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}Sn&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return GE._audioBuffers.set(g,I),I}};let FB=GE;r(FB,"_audioBuffers",new Map);class dd extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"didTrigger",[]);r(this,"receivers",[])}evaluate(e){var g;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let C=!1;if(o.retroActive)C=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(C=!0)}if(C){if(!s)if(Sn&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)Jc.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class yS extends yu{constructor(){super(...arguments);r(this,"models",[]);r(this,"timelines",[]);r(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=BA.getComponent(I.sourceObject,qC);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[g];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const ZQ=oA("debugtimeline"),tw=class extends NA{constructor(){super(...arguments);r(this,"playableAsset");r(this,"playOnAwake");r(this,"extrapolationMode",1);r(this,"waitForAudio",!0);r(this,"_visibilityChangeEvt");r(this,"_clonedPlayableAsset",!1);r(this,"_speed",1);r(this,"_guidsMap");r(this,"_isPlaying",!1);r(this,"_internalUpdateRoutine");r(this,"_isPaused",!1);r(this,"_isStopping",!1);r(this,"_time",0);r(this,"_duration",0);r(this,"_weight",1);r(this,"_animationTracks",[]);r(this,"_audioTracks",[]);r(this,"_signalTracks",[]);r(this,"_controlTracks",[]);r(this,"_customTracks",[]);r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);r(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(ZQ||vI())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,g;ZQ&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(t=this.playableAsset)==null?void 0:t.tracks,Array.isArray((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t,g;for(const I of this._audioTracks)(e=I.onEnable)==null||e.call(I);for(const I of this._customTracks)(t=I.onEnable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onEnable)==null||g.call(I);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var e,t,g;this.stop();for(const I of this._audioTracks)(e=I.onDisable)==null||e.call(I);for(const I of this._customTracks)(t=I.onDisable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onDisable)==null||g.call(I);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.loadAudio(this._time,1,0);I&&t.push(I)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Ki.userInteractionRegistered&&this.waitForAudio;)await os(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),eg.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const e of this._allTracks)for(const t of e)yield t}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const g=this._time;for(const I of this.playableAsset.tracks)if(!I.muted)switch(I.type){case Bo.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<I.outputs.length;o++){const s=I.outputs[o];if(typeof s=="object"){let n=!1;if(I.clips)for(const a of I.clips)a.start<=g&&g<=a.end&&(n=!0);const C=s;C.visible!==void 0&&C.visible!==n&&(C.visible=n,ZQ&&console.warn(this.name,"set ActivationTrack-"+o,C.name,n,g))}}break}if(!this._isStopping)for(const I of this._animationTracks)I.evaluate(g);for(const I of this._audioTracks)I.evaluate(g);for(const I of this._signalTracks)I.evaluate(g);for(const I of this._controlTracks)I.evaluate(g);for(const I of this._customTracks)I.evaluate(g)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Vd(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=BA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(ZQ&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),tw.createTrackFunctions[t.type])continue;t.type!==Bo.Audio&&t.type!==Bo.Control&&t.type!==Bo.Marker&&t.type!==Bo.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===Bo.Control&&t.clips)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=BA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(ZQ&&console.log("Resolved binding",o,"to",s),I.asset.sourceObject=s)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g,I;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=BA.findObjectOfType(Xa,this.context);for(const o of this.playableAsset.tracks){const s=o.type,n=tw.createTrackFunctions[s];if(n!=null){const C=n(this,o);if(typeof C.evaluate=="function"){C.director=this,C.track=o,this._customTracks.push(C);continue}}if(o.type===Bo.Animation){if(!o.clips||o.clips.length<=0){ZQ&&console.warn("Animation track has no clips",o);continue}for(let C=o.outputs.length-1;C>=0;C--){let a=o.outputs[C];if(a instanceof pA){const Q=BA.getOrAddComponent(a,jg);Q&&(a=Q)}const B=(t=a==null?void 0:a.gameObject)==null?void 0:t.animations;if(B){const Q=new DS;Q.trackOffset=o.trackOffset,Q.director=this,Q.track=o;for(let E=0;E<o.clips.length;E++){const c=o.clips[E],h=c.asset;if(!h){console.error(`Timeline ${this.name}: clip #${E} on track "${o.name}" has no animation data`);continue}const u=h.clip;let l=u;if((typeof l=="string"||typeof l=="number")&&(l=B.find(p=>p.name===u)),!l){console.warn("Could not find animationClip for model",c,o.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}a instanceof jg&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),Q.mixer=a.runtimeAnimatorController.mixer),Q.mixer||(Q.mixer=new xw(a.gameObject)),Q.clips.push(l),Q.mixer.uncacheAction(l),Q.createHooks(c.asset,l);const d=Q.mixer.clipAction(l);Q.actions.push(d),Q.models.push(c)}this._animationTracks.push(Q)}}}else if(o.type===Bo.Audio){if(!o.clips||o.clips.length<=0)continue;const C=new FB;C.director=this,C.track=o,C.audioSource=o.outputs.find(a=>a instanceof Ki),this._audioTracks.push(C),e||(e=(I=this.context.mainCameraComponent)==null?void 0:I.gameObject.addNewComponent(Xa)),C.listener=e.listener;for(let a=0;a<o.clips.length;a++){const B=o.clips[a];C.addModel(B)}}else if(o.type===Bo.Marker){const C=new dd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)switch(a.type){case AF.Signal:C.models.push(a),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const a=BA.getComponent(this.gameObject,Jc);a&&(C.receivers.push(a),this._signalTracks.push(C))}}else if(o.type===Bo.Signal){const C=new dd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)C.models.push(a),C.didTrigger.push(!1);for(const a of o.outputs)C.receivers.push(a);this._signalTracks.push(C)}else if(o.type===Bo.Control){const C=new yS;if(C.director=this,C.track=o,o.clips)for(const a of o.clips)C.models.push(a);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};let qC=tw;r(qC,"createTrackFunctions",{});const kD=Symbol("objectIsAnimatedData");function zq(i,A,e){if(!i)return;if(i[kD]===void 0){if(!e)return;i[kD]=new Set}const t=i[kD];e?t.add(A):t.has(A)&&t.delete(A)}function RIA(i){if(!i)return!1;const A=i[kD];return A!==void 0&&A.size>0}Nt.registerCallback(Xi.ContextCreated,i=>{const A=i.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&i.files)for(const e of i.files)BA.foreachComponent(e.file.scene,g=>{if(g.enabled!==!1){if(g instanceof Go&&g.playAutomatically||g instanceof jg||g instanceof qC&&g.playOnAwake===!0)return!0;if(g instanceof Go)return g.playAutomatically=!0,!0;if(g instanceof qC)return g.playOnAwake=!0,!0}},!0)!==!0&&UIA(e.file)});function UIA(i){if(!i||!i.animations)return;for(let e=0;e<i.animations.length;e++){const t=i.animations[e];if(!(!t.tracks||t.tracks.length<=0))for(const g in t.tracks){const I=t.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=i.scene.getObjectByName(o);if(!s&&(s=i.scene.getObjectByProperty("uuid",o),!s))continue;let n=A(s);n||(n=dr(i.scene,new Go));const C=n.animations=n.animations||[];t.name_animator=n.name,C.indexOf(t)<0&&C.push(t)}}function A(e){var g;if(!e)return;const t=(g=e.userData)==null?void 0:g.components;if(t&&t.length>0)for(let I=0;I<t.length;I++){const o=t[I];if(o instanceof jg||o instanceof Go)return e}return A(e.parent)}}class NIA{constructor(){r(this,"_context")}get context(){return this._context??ve.Current}get isStateMachineBehaviour(){return!0}}class GD{constructor(A,e,t,g){r(this,"_name");r(this,"_nameHash");r(this,"_normalizedTime");r(this,"_length");r(this,"_speed");this._name=A.name,this._nameHash=A.hash,this._normalizedTime=e,this._length=t,this._speed=g}get name(){return this._name}get nameHash(){return this._nameHash}get normalizedTime(){return this._normalizedTime}get length(){return this._length}get speed(){return this._speed}}function uP(i,A){return{name:"",isLooping:!1,guid:(A==null?void 0:A.generateUUID())??Bg.generateUUID(),index:-1,clip:new go(i,1,[])}}var Na=(i=>(i[i.If=1]="If",i[i.IfNot=2]="IfNot",i[i.Greater=3]="Greater",i[i.Less=4]="Less",i[i.Equals=6]="Equals",i[i.NotEqual=7]="NotEqual",i))(Na||{}),eF=(i=>(i[i.Float=1]="Float",i[i.Int=3]="Int",i[i.Bool=4]="Bool",i[i.Trigger=9]="Trigger",i))(eF||{});const yI=oA("debuganimatorcontroller"),wf=oA("debugrootmotion");class mo{constructor(A){r(this,"normalizedStartOffset",0);r(this,"_speed",1);r(this,"animator");r(this,"model");r(this,"_mixer");r(this,"_activeState");r(this,"_activeStates",[]);r(this,"rootMotionHandler");this.model=A,yI&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const t=[];for(let o=0;o<A.length;o++){const s=A[o],n=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,B=a/s.duration;let Q=o;(e.autoTransition===void 0||e.autoTransition===!0)&&(Q=(o+1)%A.length),n.push({exitTime:1-B,offset:0,duration:a,hasExitTime:!0,destinationState:Q,conditions:[]})}const C={name:s.name,hash:o,motion:{name:s.name,clip:s,isLooping:(e==null?void 0:e.looping)??!1},transitions:n,behaviours:[]};t.push(C)}const g={name:"AnimatorController",guid:new mg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:t}}]};return new mo(g)}play(A,e=-1,t=Number.NEGATIVE_INFINITY,g=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[e].stateMachine;for(const s of o.states)if(s.name===A||s.hash===A){yI&&console.log("transition to ",s),this.transitionTo(s,g,t);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var g,I;const t=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getBool(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??!1}setFloat(A,e){var I,o;const t=typeof A=="string"?"name":"hash",g=(o=(I=this.model)==null?void 0:I.parameters)==null?void 0:o.filter(s=>s[t]===A);return g.forEach(s=>s.value=e),(g==null?void 0:g.length)>0}getFloat(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??0}setInteger(A,e){var g,I;const t=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getInteger(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??0}setTrigger(A){var t,g;yI&&console.log("SET TRIGGER",A);const e=typeof A=="string"?"name":"hash";return(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.filter(I=>I[e]===A).forEach(I=>I.value=!0)}resetTrigger(A){var t,g;const e=typeof A=="string"?"name":"hash";return(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.filter(I=>I[e]===A).forEach(I=>I.value=!1)}getTrigger(A){var t,g,I;const e=typeof A=="string"?"name":"hash";return((I=(g=(t=this.model)==null?void 0:t.parameters)==null?void 0:g.find(o=>o[e]===A))==null?void 0:I.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const t of e.stateMachine.states)if(t.name===A||t.hash==A)return t}return null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}bind(A){A?this.animator!==A&&(this.animator=A,this._mixer=new xw(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;yI&&console.warn("AnimatorController clone()",this.model);const A=Vd(this.model,(t,g,I)=>I==null?!0:!(I.type==="Object3D"||I.isObject3D===!0||$2(I)||I.tracks!==void 0||I instanceof mo));return console.assert(A!==this.model),new mo(A)}update(A){var t,g;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const e=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(A)),this._mixer.update(e),this.animator.applyRootMotion&&((g=this.rootMotionHandler)==null||g.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const t=this._activeStates[e],g=t.motion;if(!g.action)this._activeStates.splice(e,1),e--;else{const I=g.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(yI&&console.debug("REMOVE",t.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){for(const A of this.model.layers){const e=A.stateMachine;e.defaultState===void 0&&(yI&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",A),e.defaultState=0);const t=e.states[e.defaultState];this.transitionTo(t,0,this.normalizedStartOffset)}}evaluateTransitions(){var I;let A=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;A=!0}const e=this._activeState,t=e.motion.action;for(const o of e.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const n of o.conditions)if(!this.evaluateCondition(n)){s=!1;break}if(s)if(t){const n=e.motion.clip.duration,C=n<=0?1:Math.abs(t.time/n);let a=!1;if(o.hasExitTime?t.timeScale>0?a=C>=o.exitTime:t.timeScale<0&&(a=1-C>=o.exitTime):a=!0,a){for(const B of o.conditions){const Q=this.model.parameters.find(E=>E.name===B.parameter);(Q==null?void 0:Q.type)===eF.Trigger&&Q.value&&(Q.value=!1)}t.clampWhenFinished=!0,yI&&console.log("transition to "+o.destinationState,o,C,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(t){let o=e.speed??1;e.speedParameter&&(o*=this.getFloat(e.speedParameter)),o!==void 0&&(t.timeScale=o*this._speed)}let g=!1;if(e.motion.isLooping&&t&&(t.time>=t.getClip().duration?(g=!0,t.reset(),t.time=0,t.play()):t.time<=0&&t.timeScale<0&&(g=!0,t.reset(),t.time=t.getClip().duration,t.play())),!g&&e&&!A&&t&&this.animator&&e.behaviours){const o=t==null?void 0:t.getClip().duration,s=t.time/o,n=new GD(this._activeState,s,o,this._speed);for(const C of e.behaviours)C.instance&&((I=C.instance.onStateUpdate)==null||I.call(C.instance,this.animator,n,0))}}getState(A,e){return typeof A=="number"&&(A==-1&&(A=this.model.layers[e].stateMachine.defaultState,A===void 0&&(yI&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+e),A=0)),A=this.model.layers[e].stateMachine.states[A]),A}transitionTo(A,e,t){var C,a,B,Q,E,c,h,u;if(!this.animator)return;const g=0;if(A=this.getState(A,g),!(A!=null&&A.motion)||!A.motion.clip||!(A.motion.clip instanceof go))return;const I=this._activeState===A;if(I){const l=A.motion;if(!l.action_loopback&&l.clip){const d=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(l.clip,this.animator.gameObject),d&&d.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),l.action_loopback=this.createAction(l.clip)}}if((C=this._activeState)!=null&&C.behaviours&&this._activeState.motion.action){const l=(a=this._activeState)==null?void 0:a.motion.clip.duration,d=this._activeState.motion.action.time/l,p=new GD(this._activeState,d,l,this._speed);for(const f of this._activeState.behaviours)(Q=(B=f.instance)==null?void 0:B.onStateExit)==null||Q.call(f.instance,this.animator,p,g)}const o=(E=this._activeState)==null?void 0:E.motion.action;o&&o.fadeOut(e),I&&(A.motion.action=A.motion.action_loopback,A.motion.action_loopback=o);const s=this._activeState;this._activeState=A;const n=(c=A.motion)==null?void 0:c.action;if(n){if(t=Math.max(0,Math.min(1,t)),A.cycleOffsetParameter){let d=this.getFloat(A.cycleOffsetParameter);typeof d=="number"?(d<0&&(d+=1),t+=d,t%=1):yI&&console.warn("AnimatorController cycle offset parameter is not a number",A.cycleOffsetParameter)}else typeof A.cycleOffset=="number"&&(t+=A.cycleOffset,t%=1);n.isRunning()&&n.stop(),n.reset(),n.enabled=!0;const l=A.motion.clip.duration;if(n.time=I?0:t*l,n.timeScale<0&&(n.time=l-n.time),n.clampWhenFinished=!0,n.setLoop(xl,0),e>0?n.fadeIn(e):n.weight=1,n.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(n),this._activeStates.includes(A)||this._activeStates.push(A),this._activeState.behaviours){const d=new GD(A,t,l,this._speed);for(const p of this._activeState.behaviours)(u=(h=p.instance)==null?void 0:h.onStateEnter)==null||u.call(p.instance,this.animator,d,g)}}else yI&&(A.__warned_no_motion||(A.__warned_no_motion=!0,console.warn("No action",A.motion,this)));yI&&console.log("TRANSITION FROM "+(s==null?void 0:s.name)+" TO "+A.name,e,o,n,n==null?void 0:n.getEffectiveTimeScale(),n==null?void 0:n.getEffectiveWeight(),n==null?void 0:n.isRunning(),n==null?void 0:n.isScheduled(),n==null?void 0:n.paused)}createAction(A){var t,g;if(this._mixer.existingAction(A)&&this._mixer.uncacheAction(A,(t=this.animator)==null?void 0:t.gameObject),(g=this.animator)!=null&&g.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new FIA(this));const I=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,I,A)}else return this._mixer.clipAction(A)}evaluateCondition(A){const e=this.model.parameters.find(t=>t.name===A.parameter);if(!e)return!1;switch(A.mode){case Na.If:return e.value===!0;case Na.IfNot:return e.value===!1;case Na.Greater:return e.value>A.threshold;case Na.Less:return e.value<A.threshold;case Na.Equals:return e.value===A.threshold;case Na.NotEqual:return e.value!==A.threshold}return!1}createActions(A){var e,t,g,I;yI&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const s=o.stateMachine;for(let n=0;n<s.states.length;n++){const C=s.states[n];C.transitions||(C.transitions=[]);for(const a of C.transitions)a.conditions||(a.conditions=[]);if(C.motion||(C.motion=uP(C.name)),this.animator&&C.motion.clips){const a=(e=C.motion.clips)==null?void 0:e.find(B=>{var Q,E;return B.node.name===((E=(Q=this.animator)==null?void 0:Q.gameObject)==null?void 0:E.name)});a?C.motion.clip=a.clip:(yI||Ge())&&console.warn('Could not find clip for animator "'+((g=(t=this.animator)==null?void 0:t.gameObject)==null?void 0:g.name)+'"',C.motion.clips.map(B=>B.node.name))}if(!C.motion.clip){const a=new go(void 0,void 0,[]);C.motion.clip=a}if((I=C.motion)!=null&&I.clip){const a=C.motion.clip;if(a instanceof go){const B=this.createAction(a);C.motion.action=B}else(yI||Ge())&&console.warn("No valid animationclip assigned",C)}if(C.behaviours&&Array.isArray(C.behaviours))for(const a of C.behaviours){if(!(a!=null&&a.typeName))continue;const B=AA.get(a.typeName),Q=new B;Q.isStateMachineBehaviour&&(Q._context=this.context??void 0,zE(Q,a.properties),a.instance=Q),yI&&console.log("Created animator controller behaviour",C.name,a.typeName,a.properties,Q)}}}}*enumerateActions(){if(this.model.layers)for(const A of this.model.layers){const e=A.stateMachine;for(let t=0;t<e.states.length;t++){const g=e.states[t];g!=null&&g.motion&&(g.motion.action&&(yield g.motion.action),g.motion.action_loopback&&(yield g.motion.action_loopback))}}}}class Zq{constructor(A,e){r(this,"track");r(this,"createdInterpolant");r(this,"originalEvaluate");r(this,"customEvaluate");this.track=A;const t=A,g=t.createInterpolant.bind(A);t.createInterpolant=()=>(t.createInterpolant=g,this.createdInterpolant=g(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=I=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(I);return e(I,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const Cg=class{constructor(A,e,t,g,I){r(this,"_action");r(this,"root");r(this,"clip");r(this,"positionWrapper",null);r(this,"rotationWrapper",null);r(this,"context");r(this,"positionChange",new y);r(this,"rotationChange",new RA);r(this,"_prevTime",0);if(this.context=A,this.root=e,this.clip=t,Cg.firstKeyframeRotation[this.cacheId]||(Cg.firstKeyframeRotation[this.cacheId]=new RA),I){const o=I.values;Cg.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}Cg.spaceRotation[this.cacheId]||(Cg.spaceRotation[this.cacheId]=new RA),Cg.effectiveSpaceRotation[this.cacheId]||(Cg.effectiveSpaceRotation[this.cacheId]=new RA),Cg.clipOffsetRotation[this.cacheId]=new RA,I&&Cg.clipOffsetRotation[this.cacheId].set(I.values[0],I.values[1],I.values[2],I.values[3]).invert(),this.handlePosition(t,g),this.handleRotation(t,I)}set action(A){this._action=A}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(A){if(A.getClip()!==this.clip)return;Cg.lastObjRotation[this.cacheId]||(Cg.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=Cg.lastObjRotation[this.cacheId];if(Cg.spaceRotation[this.cacheId].copy(e),wf){const t=new Og().setFromQuaternion(e);console.log("START",this.clip.name,se.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return Cg.clipOffsetRotation[this.cacheId]}handlePosition(A,e){if(e){const t=this.root;wf&&t.add(new Cs),Cg.lastObjPosition[this.cacheId]||(Cg.lastObjPosition[this.cacheId]=this.root.position.clone());const g=new y,I=new y;this.positionWrapper=new Zq(e,(o,s)=>{const n=this.action.getEffectiveWeight();return wf&&t.position.length()>8&&t.position.set(0,t.position.y,0),o>this._prevTime&&(g.set(s[0],s[1],s[2]),g.sub(I),g.multiplyScalar(n),g.applyQuaternion(this.getClipRotationOffset()),g.applyQuaternion(t.quaternion),this.positionChange.copy(g)),I.fromArray(s),this._prevTime=o,s[0]=0,s[1]=0,s[2]=0,s})}}handleRotation(A,e){if(e){if(wf){const o=e.values,s=new Og().setFromQuaternion(new RA(o[0],o[1],o[2],o[3]));console.log(A.name,e.name,"FIRST ROTATION IN TRACK",se.toDegrees(s.y));const n=e.values.length-4,C=new RA().set(o[n],o[n+1],o[n+2],o[n+3]),a=new Og().setFromQuaternion(C);console.log(A.name,e.name,"LAST ROTATION IN TRACK",se.toDegrees(a.y))}let t=0;const g=new RA,I=new RA;this.rotationWrapper=new Zq(e,(o,s)=>(o>t&&(I.set(s[0],s[1],s[2],s[3]),g.invert(),I.multiply(g),this.rotationChange.copy(I)),g.fromArray(s),t=o,s[0]=0,s[1]=0,s[2]=0,s[3]=1,s))}}onBeforeUpdate(A){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(A){return!this.action||(A*=this.action.getEffectiveWeight(),A<=0)?!1:(this.positionChange.multiplyScalar(A),this.rotationChange.slerp(Cg.identityQuaternion,1-A),!0)}};let nn=Cg;r(nn,"lastObjPosition",{}),r(nn,"lastObjRotation",{}),r(nn,"firstKeyframeRotation",{}),r(nn,"spaceRotation",{}),r(nn,"effectiveSpaceRotation",{}),r(nn,"clipOffsetRotation",{}),r(nn,"identityQuaternion",new RA);class FIA{constructor(A){r(this,"controller");r(this,"handler",[]);r(this,"root");r(this,"basePosition",new y);r(this,"baseQuaternion",new RA);r(this,"baseRotation",new Og);r(this,"summedPosition",new y);r(this,"summedRotation",new RA);this.controller=A}createClip(A,e,t){this.root=e,e&&"name"in e&&e.name;const g=this.findRootTrack(t,".position"),I=this.findRootTrack(t,".quaternion"),o=new nn(this.controller.context,e,t,g,I);this.handler.push(o);const s=A.clipAction(t);return o.action=s,s}onStart(A){for(const e of this.handler)e.onStart(A)}onBeforeUpdate(A){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const e of this.handler)e.onBeforeUpdate(A)}onAfterUpdate(A){if(!(A<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const e of this.handler)e.onAfterUpdate(A)&&(this.summedPosition.add(e.positionChange),this.summedRotation.multiply(e.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(A,e){const t=A.tracks;if(!t)return null;for(const g of t)if(g.name.endsWith(e))return g;return null}}class KIA extends zC{onSerialize(A,e){}onDeserialize(A,e){if(e.type===mo&&(A==null?void 0:A.__type)==="AnimatorController")return new mo(A)}}new KIA(mo);var JIA=Object.defineProperty,vIA=Object.getOwnPropertyDescriptor,wS=(i,A,e,t)=>{for(var g=t>1?void 0:t?vIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JIA(A,e,g),g};const Ho=oA("debuganimator");class jg extends NA{constructor(){super(...arguments);r(this,"applyRootMotion",!1);r(this,"hasRootMotion",!1);r(this,"keepAnimatorControllerStateOnDisable",!1);r(this,"_parametersAreDirty",!1);r(this,"_isDirty",!1);r(this,"speed",1);r(this,"normalizedStartOffset",0);r(this,"_animatorController",null);r(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof mo?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new mo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Ho&&console.log("Assign animator controller",e,this),this._animatorController=new mo(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){this.play(e,t,g,I)}play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,g,I),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var g,I;Ho&&console.log("setBool",e,t),((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))??!1;return Ho&&console.log("getBool",e,t),t}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))!==t&&(this._parametersAreDirty=!0),Ho&&console.log("setFloat",e,t),(I=this.runtimeAnimatorController)==null||I.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))??-1;return Ho&&console.log("getFloat",e,t),t}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))!==t&&(this._parametersAreDirty=!0),Ho&&console.log("setInteger",e,t),(I=this.runtimeAnimatorController)==null||I.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var g;const t=((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))??-1;return Ho&&console.log("getInteger",e,t),t}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Ho&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Ho&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var g;const t=(g=this.runtimeAnimatorController)==null?void 0:g.getTrigger(e);return Ho&&console.log("getTrigger",e,t),t}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this.speed&&(Ho&&console.log("setSpeed",e),this.speed=e,(t=this._animatorController)==null||t.setSpeed(e))}set minMaxSpeed(e){this.speed=se.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=se.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){Ho&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const g=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=g,g?(console.assert(this.runtimeAnimatorController!==g),this.runtimeAnimatorController=g,console.assert(this.runtimeAnimatorController===g),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!RIA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}wS([D()],jg.prototype,"applyRootMotion",2);wS([D()],jg.prototype,"hasRootMotion",2);wS([D()],jg.prototype,"keepAnimatorControllerStateOnDisable",2);wS([D()],jg.prototype,"runtimeAnimatorController",1);const LE=oA("debugusdzanimation"),tR=oA("debugusdzanimationserialization");class SS{constructor(A,e,t){r(this,"_start");r(this,"ext");r(this,"root");r(this,"clip");this.ext=A,this.root=e,this.clip=t}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class ts{constructor(A,e,t){r(this,"clip");r(this,"pos");r(this,"rot");r(this,"scale");r(this,"root");r(this,"target");r(this,"duration",0);r(this,"useRootMotion",!1);this.root=A,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=1/this.frameRate;const g=BA.getComponent(A,jg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it โ this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,t,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(t=this.rot)==null?void 0:t.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,t=!0){var n,C,a;if(!this.clip)return[0,this.duration];const g=(n=this.pos)==null?void 0:n.times,I=(C=this.rot)==null?void 0:C.times,o=(a=this.scale)==null?void 0:a.times,s=[];if(A&&g)for(const B of g)s.push(B);if(e&&I)for(const B of I)s.push(B);if(t&&o)for(const B of o)s.push(B);return s.includes(0)||s.push(0),s.sort((B,Q)=>B-Q),[...new Set(s)]}*getValues(A,e=!0,t=!0,g=!0){var Q,E,c;const I=new y,o=new RA,s=new y(1,1,1),n=this.target,C=e?(Q=this.pos)==null?void 0:Q.createInterpolant():void 0,a=t?(E=this.rot)==null?void 0:E.createInterpolant():void 0,B=g?(c=this.scale)==null?void 0:c.createInterpolant():void 0;C||I.set(n.position.x,n.position.y,n.position.z),a||o.set(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w),B||s.set(n.scale.x,n.scale.y,n.scale.z);for(let h=0;h<A.length;h++){const u=A[h];if(C){const l=C.evaluate(u);I.set(l[0],l[1],l[2])}if(a){const l=a.evaluate(u);o.set(l[0],l[1],l[2],l[3])}if(B){const l=B.evaluate(u);s.set(l[0],l[1],l[2])}if(this.useRootMotion&&n===this.root){const l=new GA;l.compose(I,o,s),l.multiply(n.matrix),l.decompose(I,o,s)}yield{time:u,translation:I,rotation:o,scale:s,index:h}}}}r(ts,"animationDurationPadding",1);class wu{constructor(A){r(this,"dict",new Map);r(this,"rootTargetMap",new Map);r(this,"rootAndClipToRegisteredAnimationMap",new Map);r(this,"rootToRegisteredClipCount",new Map);r(this,"serializers",[]);r(this,"injectRestPoses",!1);r(this,"injectImplicitBehaviours",!1);this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const t=this.rootTargetMap.get(A);if(!t)return 0;const g=this.dict.get(t[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+ts.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const t=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(t))return this.rootAndClipToRegisteredAnimationMap.get(t);LE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const C of e.tracks){const a=ze.parseTrackName(C.name),B=ze.findNode(A,a.nodeName);if(!B){console.warn("no object found for track",C.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const c=new ts(null,B,void 0);Q[0]=c}let E=Q[I];E||(E=new ts(A,B,e),Q[I]=E),E.addTrack(C),o!=null&&o.includes(B)||o==null||o.push(B)}for(const C of s){const a=this.dict.get(C);if(!a)continue;if(this.injectRestPoses&&!a[0]){const Q=new ts(null,C,void 0);a[0]=Q}let B=a[I];B||(LE&&console.log("Adding padding clip for ",C,e),B=new ts(A,C,e),a[I]=B)}const n=new SS(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(t,n),this.rootToRegisteredClipCount.set(A,I+1),n}onAfterHierarchy(A){LE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,t;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=(I==null?void 0:I.isDynamic)===!0;tR&&console.log(o,(t=g.model)==null?void 0:t.parent),o&&g.registerCallback(I)}}onExportObject(A,e,t){BA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,t)},!1);const g=new bIA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class bIA{constructor(A,e){r(this,"object");r(this,"dict");r(this,"model");r(this,"callback");this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),tR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const t=this.model,g=this.dict;if(t&&t.skinnedMesh){let I=function(G){const R=[];for(const[w,k]of G){let K=`${w} : [`;const T=[];for(const O of k)T.push(`(${Dg(O.x)}, ${Dg(O.y)}, ${Dg(O.z)})`);K=K.concat(T.join(", ")),K=K.concat("],"),R.push(K)}return R},o=function(G){const R=[];for(const[w,k]of G){let K=`${w} : [`;const T=[];for(const O of k)T.push(`(${Dg(O.w)}, ${Dg(O.x)}, ${Dg(O.y)}, ${Dg(O.z)})`);K=K.concat(T.join(", ")),K=K.concat("],"),R.push(K)}return R},s=function(G){let R=!0,w;for(const[K,T]of G)if(w===void 0&&(w=T.length),w!==T.length){R=!1;break}LE&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",w),console.assert(R,"All bones should have the same number of TransformData entries",G);const k=[];for(const[K,T]of G){const O=new Array;let b=0;for(let _=0;_<T.length;_++)O.push(b),b+=T[_].getDuration()+ts.animationDurationPadding;for(let _=0;_<T.length;_++){const J=T[_],L=O[_];k.length<=_&&k.push({pos:[],rot:[],scale:[],timeOffset:L});const H=k[_];H.pos.push(...J.getSortedTimesArray(!0,!1,!1)),H.rot.push(...J.getSortedTimesArray(!1,!0,!1)),H.scale.push(...J.getSortedTimesArray(!1,!1,!0))}}for(const K of k)K.pos.sort((T,O)=>T-O),K.rot.sort((T,O)=>T-O),K.scale.sort((T,O)=>T-O),K.pos=[...new Set(K.pos)],K.rot=[...new Set(K.rot)],K.scale=[...new Set(K.scale)];return k},n=function(G,R,w){const k=new Map,K=new Map,T=new Map,O=R.length;for(const b of w){const _=G.get(b);let J;_?console.assert(_.length===O,"We should have the same number of TransformData entries for each bone",_,R):J=new ts(null,b,void 0);for(let L=0;L<O;L++){const H=_?_[L]:J,Z=R[L];for(const{time:X,translation:nA}of H.getValues(Z.pos,!0,!1,!1)){const SA=(X+Z.timeOffset)*60;k.has(SA)||k.set(SA,new Array),k.get(SA).push(nA.clone())}for(const{time:X,rotation:nA}of H.getValues(Z.rot,!1,!0,!1)){const SA=(X+Z.timeOffset)*60;K.has(SA)||K.set(SA,new Array),K.get(SA).push(nA.clone())}for(const{time:X,scale:nA}of H.getValues(Z.scale,!1,!1,!0)){const SA=(X+Z.timeOffset)*60;T.has(SA)||T.set(SA,new Array),T.get(SA).push(nA.clone())}}}return{position:k.size==0?void 0:k,quaternion:K.size==0?void 0:K,scale:T.size==0?void 0:T}},C=function(G){const R=[];for(const w of G)R.push(`(${Dg(w.x)}, ${Dg(w.y)}, ${Dg(w.z)})`);return R.join(", ")},a=function(G){const R=[];for(const w of G)R.push(`(${Dg(w.w)}, ${Dg(w.x)}, ${Dg(w.y)}, ${Dg(w.z)})`);return R.join(", ")},B=function(G){const R=new Map;if(LE){const w=new Array;for(const[k,K]of g)w.push(k.uuid+": "+K.length+" "+K.map(T=>{var O;return(O=T.clip)==null?void 0:O.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5409
5411
|
`+w.join(`
|
|
5410
|
-
`))}for(const w of G){const k=g.get(w);k&&R.set(w,k)}return R},Q=function(G){const R=B(G),w=s(R);return n(R,w,G)};const E=t.skinnedMesh.skeleton,c=new Array;for(const G in E.bones){const R=E.bones[G],w=E.boneInverses[G];c.push({bone:R,inverse:w})}for(const G of sP(E.bones))c.push({bone:G,inverse:G.matrixWorld.clone().invert()});const h=c[0].bone.parent;h||console.error("No bone parent found for skinned mesh during USDZ export",t.skinnedMesh),c.sort((G,R)=>qE(G.bone,h)>qE(R.bone,h)?1:-1);const u=[],l=[],d=[],p=[];for(const{bone:G}of c)u.push(G.matrix.clone()),l.push(G.position),d.push(G.quaternion),p.push(G.scale);const f=c.map(G=>'"'+qE(G.bone,h)+'"').join(", "),S=c.map(G=>fE(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${S}]`),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${u.map(G=>fE(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${fE(new GA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const m=Q(c.map(G=>G.bone));if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine(`quatf[] rotations = [${a(d)}]`),m&&m.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=o(m.quaternion);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`half3[] scales = [${C(p)}]`),m&&m.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=I(m.scale);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`float3[] translations = [${C(l)}]`),m&&m.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=I(m.position);for(const R of G)A.appendLine(R);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var n;if(!this.model)return;this.skinnedMeshExport(A,e);const t=this.object,g=this.dict.get(t);if(!g||t.isSkinnedMesh)return;tR&&console.log("SERIALIZE",this.model.name,this.object.type,g);const I=new GA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const o=new Array;let s=0;for(let C=0;C<g.length;C++)o.push(s),s+=g[C].getDuration()+ts.animationDurationPadding;for(let C=0;C<g.length;C++){const a=g[C];if(!a)continue;const B=o[C];{const Q=a.getSortedTimesArray();if(!Q||Q.length===0){console.error("got an animated object but no time values?",t,a);continue}if(LE){const E=((n=a.clip)==null?void 0:n.name)??"rest",c=a.getDuration();console.log("Write .timeSamples:",E,B,c,g),A.appendLine("# "+E+": start="+(B*a.frameRate).toFixed(3)+", length="+(c*a.frameRate).toFixed(3)+", frames="+a.getFrames())}for(const{time:E,translation:c,rotation:h,scale:u}of a.getValues(Q)){I.compose(c,h,u);const l=`${(B+E)*a.frameRate}: ${fE(I)},`;A.appendLine(l)}}}A.indent--,A.appendLine("}")}}var qIA=Object.defineProperty,LIA=Object.getOwnPropertyDescriptor,pP=(i,A,e,t)=>{for(var g=t>1?void 0:t?LIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&qIA(A,e,g),g};const Xq=oA("debugpost");class be{constructor(A){r(this,"_active",!0);r(this,"_value");r(this,"_valueRaw");r(this,"_defaultValue");r(this,"valueProcessor");r(this,"onValueChanged");this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;Xq&&console.log("VolumeParameter: value changed from",t,"to",A),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,t,this):Xq&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}pP([D()],be.prototype,"overrideState",1);pP([D()],be.prototype,"value",1);var xIA=Object.defineProperty,YIA=Object.getOwnPropertyDescriptor,TIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?YIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&xIA(A,e,g),g};const _IA=oA("debugpost");class lI extends NA{constructor(e=void 0){super();r(this,"active",!0);r(this,"_result");r(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const g=e[t],I=this[t];I instanceof be&&(I.value=g)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){_IA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const g=this[t];g instanceof be&&g.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const g=this.$serializedTypes;if(g){for(const I of Object.keys(g))if(g[I]===be){const s=e[I];if(s!==void 0){const n=this[I];n.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof be){const g=e.value;return this[t].value=g,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===be&&(this[t]||(this[t]=new be))}}TIA([D()],lI.prototype,"active",2);var HIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,PIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?OIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&HIA(A,e,g),g};const WIA=oA("debugpost"),iR={};function ls(i,A){iR[i]=A}function jIA(i){return i.__type in iR?iR[i.__type]:(WIA&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),lI)}class Su{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}PIA([Uc([i=>jIA(i),lI])],Su.prototype,"components",2);var VIA=Object.defineProperty,zIA=Object.getOwnPropertyDescriptor,ZIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?zIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VIA(A,e,g),g};class mu extends lI{constructor(){super(...arguments);r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new jX({preset:oE.HIGH,edgeDetectionMode:NU.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}ZIA([D(be)],mu.prototype,"preset",2);ls("Antialiasing",mu);class mS{constructor(){r(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,t){const g=BA.getComponents(A,Ki);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,n)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t=e.split("/").pop(),o=await(await(await fetch(e)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files["audio/"+t]=s}}}const fB=oA("debugautosync"),pk=Symbol("syncerId");class XIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new $IA(A);return e[pk]=A.guid,this._syncers[e[pk]]=e,e}removeSyncer(A){delete this._syncers[A[pk]]}}const tF=new XIA;class $IA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_boundEvent");r(this,"_handleReceivingMethod");r(this,"_isReceiving",!1);r(this,"_isInit",!1);this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(fB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(fB&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){fB&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const g=A[t];this.comp[t]=g,fB&&console.log("SET",t,g)}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function AoA(i,A){let e=A!==i;return!e&&i&&A&&(Array.isArray(i)&&Array.isArray(A)||typeof i=="object"&&typeof A=="object")&&(e=!0),e}const ml=Symbol("AutoSyncHandler");function eoA(i){if(i[ml])return i[ml];const A=tF.getOrCreateSyncer(i);return A==null||A.init(i),i[ml]=A,A}function toA(i){const A=i[ml];A&&(tF.removeSyncer(A),A.destroy(),delete i[ml])}const iF=function(i){return function(A,e){var a;let t="";typeof e=="string"?t=e:t=e.name;let g=null,I;typeof i=="string"?I=A[i]:typeof i=="function"&&(I=i);const o=A,s=o.__internalAwake;if(typeof s!="function"){(fB||Ge())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((a=A==null?void 0:A.constructor)==null?void 0:a.name)+'" is not supported',A);return}fB&&console.log(t);const n=Symbol(t);o.__internalAwake=function(){if(this[n]!==void 0)return;this[n]=this[t],g=tF.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,t);if((B==null?void 0:B.set)===void 0){let Q=!1;Object.defineProperty(this,t,{set:function(E){var h;const c=this[n];if(this[n]=E,Q){Ge()&&console.warn("Recursive call detected",t);return}Q=!0;try{const u=AoA(E,c);fB&&console.log("SyncField assignment",t,"changed?",u,E),u&&(I==null?void 0:I.call(this,E,c))!==!1&&((h=eoA(this))==null||h.notifyChanged(t,E))}finally{Q=!1}},get:function(){return this[n]},configurable:!0,enumerable:!0})}g==null||g.init(this),s.call(this)};const C=o.__internalDestroy;o.__internalDestroy=function(){toA(this),C.call(this)}}};var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,kS=(i,A,e,t)=>{for(var g=t>1?void 0:t?goA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ioA(A,e,g),g};const zo=oA("debugplayersync");class vc extends NA{constructor(){super(...arguments);r(this,"autoSync",!0);r(this,"asset");r(this,"onPlayerSpawned");r(this,"_localInstance");r(this,"onJoinedRoom",()=>{zo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new kg)}onEnable(){this.context.connection.beginListen(dt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(dt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom)}async getInstance(){var t,g,I,o,s,n;if(this._localInstance)return this._localInstance;if(zo&&console.log("PlayerSync.createInstance",(t=this.asset)==null?void 0:t.uri),!((g=this.asset)!=null&&g.asset)&&!((I=this.asset)!=null&&I.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const e=await this._localInstance;if(e){const C=BA.getComponent(e,gs);C?(C.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(e)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((n=this.asset)==null?void 0:n.uri)+"</strong>: please make sure the asset has a PlayerState component!"),BA.destroySynced(e))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(zo&&console.log("PlayerSync.destroyInstance",t),BA.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=gs.all.length-1;t>=0;t--){const g=gs.all[t];(!g.owner||!this.context.connection.userIsInRoom(g.owner))&&g.doDestroy()}})}}kS([D()],vc.prototype,"autoSync",2);kS([D(It)],vc.prototype,"asset",2);kS([D(kg)],vc.prototype,"onPlayerSpawned",2);var fP=(i=>(i.OwnerChanged="ownerChanged",i))(fP||{}),Th;const bg=(Th=class extends NA{constructor(){super(...arguments);r(this,"onOwnerChangeEvent",new kg);r(this,"onFirstOwnerChangeEvent",new kg);r(this,"hasOwner",!1);r(this,"owner");r(this,"dontDestroy",!1);r(this,"onUserLeftRoom",A=>{if(A.userId===this.owner){zo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return bg._all}static get local(){return bg._local}static getFor(A){if(A instanceof pA)return BA.getComponentInParent(A,bg);if(A instanceof NA)return BA.getComponentInParent(A.gameObject,bg)}static isLocalPlayer(A){const e=bg.getFor(A);return(e==null?void 0:e.isLocalPlayer)??!1}static addEventListener(A,e){return this._callbacks[A]||(this._callbacks[A]=[]),this._callbacks[A].push(e),e}static removeEventListener(A,e){if(!this._callbacks[A])return;const t=this._callbacks[A].indexOf(e);t>=0&&this._callbacks[A].splice(t,1)}static dispatchEvent(A,e){if(this._callbacks[A])for(const t of this._callbacks[A])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(A,e){var o,s;zo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",A,"oldOwner",e);const t=bg._local.indexOf(this);t>=0&&bg._local.splice(t,1);const g={playerState:this,oldValue:e,newValue:A};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(g)),(s=this.onOwnerChangeEvent)==null||s.invoke(g),this.owner===this.context.connection.connectionId){bg._local.push(this);const n=new CustomEvent("local-owner-changed",{detail:g});this.dispatchEvent(n)}const I=new CustomEvent("owner-changed",{detail:g});this.dispatchEvent(I),bg.dispatchEvent("ownerChanged",I)}awake(){bg.all.push(this),zo&&console.log("Registered new PlayerState",this.guid,bg.all.length-1,bg.all),this.context.connection.beginListen(dt.UserLeftRoom,this.onUserLeftRoom)}async start(){zo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await os(300),this.context.connection.userIsInRoom(this.owner)==!1&&(zo&&console.log(`PlayerSync.start โ doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(zo&&console.warn("PlayerState.start โ owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?zo&&console.warn("PlayerState.start โ owner is still undefined but dontDestroy is set to true",this.name):(zo&&console.warn(`PlayerState.start โ owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):console.log("PlayerState.start โ owner is assigned",this.owner)},2e3))}doDestroy(){zo&&console.log("PlayerSync.doDestroy โ syncDestroy",this.name),CS(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(dt.UserLeftRoom,this.onUserLeftRoom),bg.all.splice(bg.all.indexOf(this),1),this.isLocalPlayer){const A=bg._local.indexOf(this);A>=0&&bg._local.splice(A,1)}}},r(Th,"_all",[]),r(Th,"_local",[]),r(Th,"_callbacks",{}),Th);let gs=bg;kS([iF(gs.prototype.onOwnerChange)],gs.prototype,"owner",2);const IoA=oA("debugavatar"),Ms=class extends NA{constructor(){super(...arguments);r(this,"connectionId");r(this,"avatar")}static getAvatar(e){return e>=0&&e<Ms.instances.length?Ms.instances[e]:null}static onAvatarMarkerCreated(e){return Ms._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return Ms._onAvatarMarkerDestroyed.push(e),e}awake(){Ms.instances.push(this),IoA&&console.log(this);for(const e of Ms._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Ms.instances.splice(Ms.instances.indexOf(this),1);for(const e of Ms._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ag=Ms;r(ag,"instances",[]),r(ag,"_onNewAvatarMarkerAdded",[]),r(ag,"_onAvatarMarkerDestroyed",[]);var ooA=Object.defineProperty,soA=Object.getOwnPropertyDescriptor,noA=(i,A,e,t)=>{for(var g=t>1?void 0:t?soA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ooA(A,e,g),g};const rE=oA("debugxrflags"),DP=oA("disablexrflags");DP&&console.warn("XRFlags are disabled");var ln=(i=>(i[i.Never=0]="Never",i[i.Browser=1]="Browser",i[i.AR=2]="AR",i[i.VR=4]="VR",i[i.FirstPerson=8]="FirstPerson",i[i.ThirdPerson=16]="ThirdPerson",i[i.All=4294967295]="All",i))(ln||{});const YK=class{constructor(){r(this,"Mask",17)}Has(A){return(this.Mask&A)!==0}Set(A){rE&&console.warn("Set XR flag state to",A),this.Mask=A,po.Apply()}Enable(A){this.Mask|=A,po.Apply()}Disable(A){this.Mask&=~A,po.Apply()}Toggle(A){this.Mask^=A,po.Apply()}EnableAll(){this.Mask=-1,po.Apply()}DisableAll(){this.Mask=0,po.Apply()}};let Tg=YK;r(Tg,"Global",new YK);var _h;const rC=(_h=class extends NA{constructor(){super(...arguments);r(this,"visibleIn")}static Apply(){for(const A of this.registry)A.UpdateVisible(Tg.Global)}awake(){rC.registry.push(this)}onEnable(){rC.firstApply?this.UpdateVisible(Tg.Global):(rC.firstApply=!0,rC.Apply())}onDestroy(){const A=rC.registry.indexOf(this);A>=0&&rC.registry.splice(A,1)}get isOn(){return this.gameObject.visible}UpdateVisible(A=null){if(DP)return;let e;const t=A;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),rE&&console.log(t),rC.buffer.Mask=t,A=rC.buffer),A instanceof Tg?(rE&&console.warn(this.name,"use passed in mask",A.Mask,this.visibleIn),e=A.Has(this.visibleIn)):(rE&&console.log(this.name,"use global mask"),Tg.Global.Has(this.visibleIn)),e!==void 0)if(e)rE&&console.log(this.name,"is visible",this.gameObject.uuid),BA.setActive(this.gameObject,!0);else{if(rE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},r(_h,"registry",[]),r(_h,"firstApply"),r(_h,"buffer",new Tg),_h);let po=rC;noA([D()],po.prototype,"visibleIn",2);var CoA=Object.defineProperty,aoA=Object.getOwnPropertyDescriptor,gF=(i,A,e,t)=>{for(var g=t>1?void 0:t?aoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CoA(A,e,g),g};const Uh=oA("debugwebxr"),$q=new RA().setFromAxisAngle(new y(0,1,0),Math.PI);class AQ extends NA{constructor(){super(...arguments);r(this,"head");r(this,"leftHand");r(this,"rightHand");r(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Uh&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=gs.getFor(this);if(t!=null&&t.owner){const g=this.gameObject.addNewComponent(ag);g.avatar=this.gameObject,g.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(ag);t&&t.destroy()}onUpdateXR(e){var n,C;if(!this.activeAndEnabled)return;const t=gs.isLocalPlayer(this);if(!t)return;const g=e.xr;if(g.rig&&g.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),g.rig.gameObject.add(this.gameObject)),this._syncTransforms&&t)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const B=BA.getComponentsInChildren(this.head.asset,po);for(const Q of B)Q.enabled=!1,Q.gameObject.visible=!1}}const I=e.xr.leftController,o=(n=this.leftHand)==null?void 0:n.asset;I&&o&&(o.position.copy(I.gripPosition),o.quaternion.copy(I.gripQuaternion),o.quaternion.multiply($q),o.visible=I.isTracking);const s=e.xr.rightController;if(s&&((C=this.rightHand)!=null&&C.asset)){const a=this.rightHand.asset;a.position.copy(s.gripPosition),a.quaternion.copy(s.gripQuaternion),a.quaternion.multiply($q),a.visible=s.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,g;if(this.context.connection.isConnected){const I=gs.getFor(this);if(I&&I.isLocalPlayer==!1){const o=pe.getXRSync(this.context);if(o&&o.hasState(I.owner)){this.tryFindAvatarObjectsIfMissing();const s=(e=this.leftHand)==null?void 0:e.asset;s&&(s.visible=(o==null?void 0:o.isTracking(I.owner,"left"))??!1);const n=(t=this.rightHand)==null?void 0:t.asset;n&&(n.visible=(o==null?void 0:o.isTracking(I.owner,"right"))??!1)}if((g=this.head)!=null&&g.asset){const s=BA.getComponentsInChildren(this.head.asset,po);for(const n of s)n.enabled=!1,n.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};iO.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof pA&&(this.head=new It("",this.sourceId,this.head));else{const e=new pA;e.name="Head";const t=ec.createPrimitive(_B.Cube);e.add(t),this.gameObject.add(e),this.head=new It("",this.sourceId,e),Uh&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof pA&&(this.rightHand=new It("",this.sourceId,this.rightHand));else{const e=new pA;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new It("",this.sourceId,e),Uh&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof pA&&(this.leftHand=new It("",this.sourceId,this.leftHand));else{const e=new pA;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new It("",this.sourceId,e),Uh&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),gs.isLocalPlayer(this.gameObject)&&(this._syncTransforms=BA.getComponentsInChildren(this.gameObject,sr))}async loadAvatarObjects(e,t,g){const I=e.loadAssetAsync(),o=t.loadAssetAsync(),s=g.loadAssetAsync(),n=new Array;I&&n.push(I),o&&n.push(o),s&&n.push(s);const C=await zd(n);Uh&&console.log("Avatar loaded results:",C)}}gF([D(It)],AQ.prototype,"head",2);gF([D(It)],AQ.prototype,"leftHand",2);gF([D(It)],AQ.prototype,"rightHand",2);class Nn{static Add(A,e,t=null){if(e){for(const g of this.Pois)if(g.obj===e)return;this.Pois.push({obj:e,avatar:t}),this.LastChangeTime=A.time.time}}static Remove(A,e){var t;if(e){for(const g of this.Pois)if(g.obj===e){this.Pois.splice(this.Pois.indexOf(g),1),this.LastChangeTime=(A==null?void 0:A.time.time)??((t=ve.Current)==null?void 0:t.time.time);return}}}}r(Nn,"Pois",[]),r(Nn,"LastChangeTime",0);class roA{constructor(){r(this,"guid");r(this,"position",new y)}}class ud extends NA{constructor(){super(...arguments);r(this,"target",null);r(this,"avatar",null);r(this,"_model",null);r(this,"_targetModel",new roA);r(this,"_currentTargetObject",null);r(this,"_lastUpdateTime",0);r(this,"_lookDuration",0);r(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=AA.get("MoveRandom");if(t&&this.target){const g=BA.getComponent(this.target,t);g&&g.destroy()}}awake(){if(this.avatar=BA.getComponentInParent(this.gameObject,ag),this.avatar){const e=BA.getComponentInParent(this.gameObject,ag);this._model=new XU(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&QI(this.target,e.position)})}update(){var t;if((!this.context.connection.isConnected||(t=this._model)!=null&&t.hasOwnership)&&(Nn.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Nn.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const g=Je(this._currentTargetObject);QI(this.target,g),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(g))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const t=Nn.Pois;if(t.length>0){const g=t[Math.floor(Math.random()*t.length)];if(g&&g.obj){if(g.avatar&&g.avatar===this.avatar)return;this._currentTargetObject=g.obj}}}}}const wE=oA("debugnetworkingstreams");var mn=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(mn||{});class yP{constructor(A,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=A,this.direction=e}}class wP{constructor(A,e){r(this,"type","receive-stream");r(this,"stream");r(this,"target");this.stream=A,this.target=e}}class BoA{constructor(A,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var SP=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(SP||{});class QoA extends Rg{constructor(e,t,g){super();r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.userId=e,this.call=t,this.direction=g,this._stream=null,t.on("stream",I=>{if(wE&&console.log("Receive video",I.getAudioTracks(),I.getVideoTracks()),this._stream=I,g==="incoming"){const o=new wP(I,this);this.dispatchEvent(o)}}),t.on("close",()=>{this.dispatchEvent(new yP(e,g))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),GC(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const ME=class extends Rg{constructor(e,t){super();r(this,"id");r(this,"context");r(this,"_peer");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnectFn",this.onPeerConnect.bind(this));r(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if(ME.instances.has(t))return ME.instances.get(t);const g=new ME(e,t);return ME.instances.set(t,g),g}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var o;const g={metadata:{userId:this.context.connection.connectionId}},I=(o=this._peer)==null?void 0:o.call(e,t,g);if(I)return this.registerCall(I,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(dt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(dt.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const e=this.getMyPeerId();e?this._peer=mH(e):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(e){wE&&console.log("Peer connected as",e),this.context.connection.send("peer-user-connected",new BoA(this,e))}onPeerReceivingCall(e){e.answer(),this.registerCall(e,"incoming")}registerCall(e,t){const g=e.metadata;(!g||!g.userId)&&console.error("Missing call metadata",e);const I=g.userId;t==="incoming"&&wE?console.log("Receive call from",e.metadata):wE&&console.log("Make call to",e.metadata);const o=t==="incoming"?this._incomingCalls:this._outgoingCalls,s=new QoA(I,e,t);return o.push(s),e.on("error",n=>{console.error("Call error",n)}),e.on("close",()=>{wE&&console.log("Call ended",e.metadata),e.close();const n=o.indexOf(s);n!==-1&&o.splice(n,1)}),s.addEventListener("call-ended",n=>{this.dispatchEvent(n)}),t==="incoming"&&(s.addEventListener("receive-stream",n=>{this.dispatchEvent(n)}),e.on("stream",()=>{let n=0;const C=setInterval(()=>{const a=n===0;!s.isOpen&&a&&(n+=1,clearInterval(C),s.close())},2e3)})),s}};let xE=ME;r(xE,"instances",new Map);class ku extends Rg{constructor(e,t){super();r(this,"context");r(this,"peer");r(this,"_sendingStreams",new Map);r(this,"debug",!1);r(this,"onJoinedRoom",e=>{this.debug&&console.log(`${e.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});r(this,"onReceiveStream",e=>{this.debug&&console.log("RECEIVE STREAM",e),this.dispatchEvent({type:"receive-stream",target:this,stream:e.stream,userId:e.userId})});r(this,"onCallEnded",e=>{this.dispatchEvent(e)});r(this,"onUserConnected",e=>{if(this.peer.id===e.guid){this.debug&&console.log("USER CONNECTED",e.guid,e);const t=this._sendingStreams.keys().next().value;this.peer.makeCall(e.peerId,t)}});r(this,"onUserLeft",e=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=e,this.peer=t,wE&&(this.debug=!0)}static create(e){const t=xE.getOrCreate(e.context,e.context.connection.connectionId);return new ku(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const g of t)g.close()}this._sendingStreams.delete(e),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(dt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(dt.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(dt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(dt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var g;let e=!1;const t=this.context.connection.connectionId;for(const I of this._sendingStreams.keys()){const o=this._sendingStreams.get(I)||[];for(const s of this.context.connection.usersInRoom()){if(s===t)continue;const n=o.find(C=>C.userId===s);if(!n||((g=n.stream)==null?void 0:g.active)===!1){this.debug&&console.log("Starting call to",s,t);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(s),I);C&&(e=!0,o.push(C))}}this._sendingStreams.set(I,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let g=t.length-1;g>=0;g--){const I=t[g];this.context.connection.userIsInRoom(I.userId)||(I.close(),t.splice(g,1))}}}}function GC(i){if(i&&i instanceof MediaStream)for(const A of i.getTracks())A.stop()}var EoA=Object.defineProperty,coA=Object.getOwnPropertyDescriptor,mP=(i,A,e,t)=>{for(var g=t>1?void 0:t?coA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&EoA(A,e,g),g};const hoA="noVoip",loA=oA("debugvoip");class eQ extends NA{constructor(){super(...arguments);r(this,"autoConnect",!1);r(this,"runInBackground",!0);r(this,"debug",!1);r(this,"_net");r(this,"_outputStream",null);r(this,"onJoinedRoom",async()=>{await os(300),this.autoConnect&&!this.isSending&&this.connect()});r(this,"_incomingStreams",new Map);r(this,"onReceiveStream",e=>{const t=e.target.userId,g=e.stream,I=this._incomingStreams.get(t);if(I)I.srcObject=g,I.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(t,o),o.setAttribute("autoplay","true"),o.srcObject=g}});r(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);GC(t==null?void 0:t.srcObject),this._incomingStreams.delete(e.userId)});r(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}});r(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const t=!(document.visibilityState==="visible");this.setMuted(t);for(const g of this._incomingStreams){const I=g[1];I.muted=t}})}awake(){loA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=ku.create(this)),this._net.addEventListener(mn.StreamReceived,this.onReceiveStream),this._net.addEventListener(mn.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(mn.StreamReceived,this.onReceiveStream),this._net.removeEventListener(mn.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await WG())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),GC(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await WG()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):vT("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),GC(this._outputStream),this._outputStream=null}setMuted(e){var g;const t=(g=this._outputStream)==null?void 0:g.getAudioTracks();if(t)for(const I of t)I.enabled=!e}get isMuted(){var t;if(this._outputStream===null)return!1;const e=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(e){for(const g of e)if(!g.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,Ge()&&fi("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(g=>(console.warn("VOIP failed getting audio stream",g),null)):(console.error("No getDisplayMedia support"),null)}}mP([D()],eQ.prototype,"autoConnect",2);mP([D()],eQ.prototype,"runInBackground",2);var doA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,kP=(i,A,e,t)=>{for(var g=t>1?void 0:t?uoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&doA(A,e,g),g};const poA=oA("debugmouth");class Gu extends NA{constructor(){super(...arguments);r(this,"idle",[]);r(this,"talking",[]);r(this,"marker",null);r(this,"voip",null);r(this,"lastMouthChangeTime",0);r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=BA.findObjectOfType(eQ,this.context),this.marker||(this.marker=BA.getComponentInParent(this.gameObject,ag))},3e3)}update(){var g;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((g=this.marker)==null?void 0:g.connectionId)??null;if(!e){poA&&(e=null);return}const t=this.voip.getFrequency(e)??0;this.updateLips(t)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(g=>g.visible=!1):this.talking.map(g=>g.visible=!1);for(let g=0;g<e.length;g++){const I=e[g];I&&(I.visible=g===t)}}}}kP([D(pA)],Gu.prototype,"idle",2);kP([D(pA)],Gu.prototype,"talking",2);class IF extends NA{constructor(){super(...arguments);r(this,"voip",null);r(this,"marker",null);r(this,"_startPosition",null)}awake(){this.voip=BA.findObjectOfType(eQ,this.context),this.marker=BA.getComponentInParent(this.gameObject,ag)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const g=t/100;this.gameObject.position.y=this._startPosition.y+g*.07}}var foA=Object.defineProperty,DoA=Object.getOwnPropertyDescriptor,GS=(i,A,e,t)=>{for(var g=t>1?void 0:t?DoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&foA(A,e,g),g};class tQ extends NA{constructor(){super(...arguments);r(this,"eyes",[]);r(this,"lastBlinkTime",0);r(this,"blinkLength",0);r(this,"eyesOpen",!0);r(this,"state",null)}awake(){this.state=BA.getComponentInParent(this.gameObject,po)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const t of this.eyes)t&&(t.visible=this.eyesOpen)}}}GS([D(pA)],tQ.prototype,"eyes",2);GS([D()],tQ.prototype,"lastBlinkTime",2);GS([D()],tQ.prototype,"blinkLength",2);GS([D()],tQ.prototype,"eyesOpen",2);var yoA=Object.defineProperty,woA=Object.getOwnPropertyDescriptor,oF=(i,A,e,t)=>{for(var g=t>1?void 0:t?woA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&yoA(A,e,g),g},tG;const GP=(tG=class extends NA{constructor(){super(...arguments);r(this,"head",null);r(this,"eyes",null);r(this,"target",null);r(this,"brain",null);r(this,"vec",new y);r(this,"currentTargetPoint",new y)}awake(){this.brain||(this.brain=BA.getComponentInParent(this.gameObject,ud)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=BA.addNewComponent(this.gameObject,ud)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const A=this.target;if(A&&this.head){const e=this.eyes;if(e){const t=Je(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const g=Je(this.head),I=this.vec.copy(this.currentTargetPoint).sub(g).normalize();if(I.length()<.1)return;const o=GP.forward;if(o.set(0,0,1),o.applyQuaternion(qt(this.head)),o.dot(I)>.45)for(let n=0;n<e.length;n++)e[n].lookAt(this.currentTargetPoint)}}}},r(tG,"forward",new y(0,0,1)),tG);let bc=GP;oF([D(pA)],bc.prototype,"head",2);oF([D(pA)],bc.prototype,"eyes",2);oF([D(pA)],bc.prototype,"target",2);const Nh=oA("debugavatar");class MS{constructor(A,e,t,g){r(this,"root");r(this,"head");r(this,"leftHand");r(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=t,this.rigthHand=g,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class sF{constructor(){r(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let t=null;if(typeof e=="string"){if(t=await this.loadAvatar(A,e),!t){const I=new Vs;t=BA.instantiate(VE(e,A.scene),I)}}else t=e;if(!t)return null;const g=this.findAvatar(t);return g.isValid?(Nh&&console.log("[Custom Avatar] valid config",e,Nh?g:""),g):(console.warn("[Custom Avatar] config isn't valid",e,Nh?g:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(Nh&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const g=await fetch("./"+e);let I=null;if(g.ok){const s=await g.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await LU(e,e,0,"no url here go away",!0),!I))return null;const o=await Ys().parseSync(A,I,null,0);return(o==null?void 0:o.scene)??null}const t=new Rc;return cu(t,A),new Promise((g,I)=>{const o=this.avatarRegistryUrl+"/"+e;t.load(o,async s=>{await Ys().createBuiltinComponents(A,o,s,null,void 0),g(s.scene)},s=>{Nh&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),g(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let t=e;t.children.length==1&&(t=A.children[0]);let g=this.findAvatarPart(t,["head"]);const I=this.findAvatarPart(t,["left","hand"]),o=this.findAvatarPart(t,["right","hand"]);if(!g){g=e;const n=new y;new Lt().setFromObject(g).getSize(n);const C=Math.max(n.x,n.y,n.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&g.scale.multiplyScalar(1/C*.3)}return new MS(e,g,I,o)}findAvatarPart(A,e){const t=A.name.toLowerCase();let g=!0;for(const I of e){if(!g)break;t.indexOf(I)===-1&&(g=!1)}if(g)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var SoA=Object.defineProperty,moA=Object.getOwnPropertyDescriptor,nF=(i,A,e,t)=>{for(var g=t>1?void 0:t?moA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&SoA(A,e,g),g};class qc extends NA{constructor(){super(...arguments);r(this,"length",1);r(this,"depthTest",!0);r(this,"isGizmo",!0);r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!$d)return;this._axes||(this._axes=new Cs(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}nF([D()],qc.prototype,"length",2);nF([D()],qc.prototype,"depthTest",2);nF([D()],qc.prototype,"isGizmo",2);class CF extends NA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"hint");r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=Je(this.to).clone(),t=Je(this.from).clone(),g=e.distanceTo(t),I=e.clone();I.sub(t);const o=t.clone();o.add(e),o.multiplyScalar(.5);const s=Je(this.hint).clone();s.sub(o);const n=new y;n.crossVectors(s,I),n.crossVectors(I,n),n.normalize();const C=g*.5,a=Math.max(this.desiredDistance,C),B=Math.sqrt(a*a-C*C),Q=n.clone();Q.multiplyScalar(B),Q.add(o),QI(this.gameObject,Q);const E=o.clone();E.sub(n),this.gameObject.lookAt(E)}}const koA=oA("debugusdz");class RS{constructor(){r(this,"behaviours",[]);r(this,"behaviourComponents",[]);r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{BA.foreachComponent(t,g=>{var o;const I=g;if(typeof I.createBehaviours=="function"||typeof I.beforeCreateDocument=="function"||typeof I.afterCreateDocument=="function"||typeof I.afterSerialize=="function"){this.behaviourComponents.push(I);const s=(o=I.beforeCreateDocument)==null?void 0:o.call(I,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,t){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,t)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var t;if((t=this.behaviours)!=null&&t.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){koA&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var GoA=Object.defineProperty,MoA=Object.getOwnPropertyDescriptor,aF=(i,A,e,t)=>{for(var g=t>1?void 0:t?MoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&GoA(A,e,g),g};class iQ extends lI{constructor(){super(...arguments);r(this,"threshold");r(this,"intensity");r(this,"scatter");r(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new B_(this.context.scene,this.context.mainCamera,{blendFunction:je.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new vU;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}aF([D(be)],iQ.prototype,"threshold",2);aF([D(be)],iQ.prototype,"intensity",2);aF([D(be)],iQ.prototype,"scatter",2);ls("Bloom",iQ);var RoA=Object.defineProperty,UoA=Object.getOwnPropertyDescriptor,Io=(i,A,e,t)=>{for(var g=t>1?void 0:t?UoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RoA(A,e,g),g};class ds extends NA{constructor(){super(...arguments);r(this,"attachedRigidbody",null);r(this,"isTrigger",!1);r(this,"sharedMaterial");r(this,"membership",[0]);r(this,"filter");r(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Io([D(ei)],ds.prototype,"attachedRigidbody",2);Io([D()],ds.prototype,"isTrigger",2);Io([D()],ds.prototype,"sharedMaterial",2);Io([D()],ds.prototype,"membership",2);Io([D()],ds.prototype,"filter",2);class Mu extends ds{constructor(){super(...arguments);r(this,"radius",.5);r(this,"center",new y(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),Tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),wU(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([$g(),D()],Mu.prototype,"radius",2);Io([D(y)],Mu.prototype,"center",2);class Ru extends ds{constructor(){super(...arguments);r(this,"size",new y(1,1,1));r(this,"center",new y(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size),Tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),wU(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([$g(),D(y)],Ru.prototype,"size",2);Io([D(y)],Ru.prototype,"center",2);class Lc extends ds{constructor(){super(...arguments);r(this,"sharedMesh");r(this,"convex",!1)}onEnable(){var e,t,g,I,o;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof uA&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(g=this.context.physics.engine)==null||g.addMeshCollider(this,this.sharedMesh,this.convex,li(this.gameObject));else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${((I=this.sharedMesh)==null?void 0:I.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const n in s.children){const C=s.children[n];C.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,C,this.convex,li(this.gameObject)))}}}}}Io([D()],Lc.prototype,"sharedMesh",2);Io([D()],Lc.prototype,"convex",2);class nr extends ds{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Io([D(y)],nr.prototype,"center",2);Io([D()],nr.prototype,"radius",2);Io([D()],nr.prototype,"height",2);var NoA=Object.defineProperty,FoA=Object.getOwnPropertyDescriptor,rF=(i,A,e,t)=>{for(var g=t>1?void 0:t?FoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&NoA(A,e,g),g};class gQ extends NA{constructor(){super(...arguments);r(this,"objectBounds",!1);r(this,"color");r(this,"isGizmo",!0);r(this,"_gizmoObject",null);r(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!$d||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new fU(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=LN(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),eg.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var e;for(;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}rF([D()],gQ.prototype,"objectBounds",2);rF([D(yA)],gQ.prototype,"color",2);rF([D()],gQ.prototype,"isGizmo",2);class KoA extends Z2{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const t in e)for(const g in e[t])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(t);for(const t of A._components)A._simpleState__statesProperties[t.id]&&(A._simpleState__normalStyles[t.id]=t.inline?t.inline:t._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const t=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],t.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)t.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const t in A)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=A[t]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var JoA=Object.defineProperty,voA=Object.getOwnPropertyDescriptor,MP=(i,A,e,t)=>{for(var g=t>1?void 0:t?voA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JoA(A,e,g),g};class xc extends NA{constructor(){super(...arguments);r(this,"effectColor");r(this,"effectDistance")}}MP([D(Kt)],xc.prototype,"effectColor",2);MP([D(gA)],xc.prototype,"effectDistance",2);var boA=Object.defineProperty,qoA=Object.getOwnPropertyDescriptor,Uu=(i,A,e,t)=>{for(var g=t>1?void 0:t?qoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&boA(A,e,g),g};const fk=oA("debugui"),Dk=oA("debuguilayout");class BF{constructor(){r(this,"width");r(this,"height")}}class QF{constructor(){r(this,"x");r(this,"y");r(this,"width");r(this,"height")}}const Ss=new y,Fh=new GA,Sf=new RA,RP=class extends _s{constructor(){super(...arguments);r(this,"_anchoredPosition");r(this,"sizeDelta",new gA(100,100));r(this,"pivot",new gA(.5,.5));r(this,"anchorMin",new gA(0,0));r(this,"anchorMax",new gA(1,1));r(this,"minWidth");r(this,"minHeight");r(this,"lastMatrix");r(this,"rectBlock");r(this,"_transformNeedsUpdate",!1);r(this,"_initialPosition");r(this,"_parentRectTransform");r(this,"_lastUpdateFrame",-1);r(this,"_lastAnchoring");r(this,"_createdBlocks",[]);r(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new gA),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){let A=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;A=e*t,A+=this.sizeDelta.x}return this.minWidth!==void 0&&A<this.minWidth?this.minWidth:A}get height(){let A=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;A=e*t,A+=this.sizeDelta.y}return this.minHeight!==void 0&&A<this.minHeight?this.minHeight:A}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new gA),this.lastMatrix=new GA,this.rectBlock=new pA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,aE(this,"_anchoredPosition",()=>{this.markDirty()}),aE(this,"sizeDelta",()=>{this.markDirty()}),aE(this,"pivot",()=>{this.markDirty()}),aE(this,"anchorMin",()=>{this.markDirty()}),aE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var A;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(A=this.Canvas)==null||A.registerTransform(this)}onDisable(){var A;super.onDisable(),this.removeShadowComponent(),(A=this.Canvas)==null||A.unregisterTransform(this)}onParentRectTransformChanged(A){this._transformNeedsUpdate||this.onApplyTransform(Dk?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(Dk&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(A){var g;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=BA.getComponentInParent(this.gameObject.parent,RP):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,Dk&&console.warn("RectTransform โ ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Ss.set(0,0,0),this.applyPivot(Ss),e.matrix.setPosition(Ss.x,Ss.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Sf.copy(this.gameObject.quaternion),Sf.x*=-1,Sf.z*=-1,Fh.makeRotationFromQuaternion(Sf),e.matrix.premultiply(Fh)),Ss.set(0,0,0),this.applyAnchoring(Ss),(g=this.Canvas)!=null&&g.screenspace?Ss.z+=.1:Ss.z+=.01,Fh.identity(),Fh.setPosition(Ss.x,Ss.y,Ss.z),e.matrix.premultiply(Fh),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of YN(this.gameObject,_s,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new gA);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),A.x+=this._initialPosition.x-this.gameObject.position.x,A.y+=this._initialPosition.y-this.gameObject.position.y,A.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let g=0;const I=1-this.anchorMax.y-this.anchorMin.y;g-=t.height*.5*I,A.y+=g;let o=0;const s=1-this.anchorMax.x-this.anchorMin.x;o-=t.width*.5*s,A.x+=o}}applyPivot(A){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;A.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;A.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const A={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}createNewBlock(A){A={...this.getBasicOptions(),...A},fk&&console.log(this.name,A);const e=new MN(A);return this._createdBlocks.push(e),e}createNewText(A){fk&&console.log(A),A={...this.getBasicOptions(),...A},fk&&console.log(this.name,A);const e=new RN(A);return this._createdTextBlocks.push(e),e}};let qI=RP;Uu([D(gA)],qI.prototype,"anchoredPosition",1);Uu([D(gA)],qI.prototype,"sizeDelta",2);Uu([D(gA)],qI.prototype,"pivot",2);Uu([D(gA)],qI.prototype,"anchorMin",2);Uu([D(gA)],qI.prototype,"anchorMax",2);var LoA=Object.defineProperty,xoA=Object.getOwnPropertyDescriptor,UP=(i,A,e,t)=>{for(var g=t>1?void 0:t?xoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&LoA(A,e,g),g};const mf={backgroundColor:new yA(1,1,1),backgroundOpacity:1,borderColor:new yA(1,1,1),borderOpacity:1};var iG;const MD=(iG=class extends _s{constructor(){super(...arguments);r(this,"_alphaFactor",1);r(this,"sRGBColor",new yA(1,0,1));r(this,"raycastTarget",!0);r(this,"uiObject",null);r(this,"_color",null);r(this,"_rect",null);r(this,"_stateManager",null);r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Kt(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new Kt(1,1,1,1)),this._color.copy(A),this.onColorChanged())}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),mf.backgroundColor=this.sRGBColor,mf.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(mf,this._alphaFactor),this.uiObject.set(mf),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=BA.getComponent(this.gameObject,qI)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var A;(A=this.uiObject)==null||A.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new KoA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),aE(this,"_color",()=>hIA(this,this.onColorChanged))}onEnable(){var A;super.onEnable(),this.uiObject&&((A=this.rectTransform.shadowComponent)==null||A.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const A=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:A};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var g;const t=(g=this.gameObject)==null?void 0:g.getComponent(xc);t&&(t.effectDistance&&(A.borderWidth=Math.max(Math.abs(t.effectDistance.x),Math.abs(t.effectDistance.y))),t.effectColor&&(A.borderColor=t.effectColor,A.borderOpacity=t.effectColor.alpha*e))}async setTexture(A){if(this.setOptions({backgroundOpacity:0}),A){if(MD.textureCache.has(A))A=MD.textureCache.get(A);else if(!A.isRenderTargetTexture){const e=A.clone();e.colorSpace=xt,MD.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},r(iG,"textureCache",new Map),iG);let IQ=MD;UP([D(Kt)],IQ.prototype,"color",1);UP([D()],IQ.prototype,"raycastTarget",2);class Nu extends IQ{constructor(){super(...arguments);r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var YoA=Object.defineProperty,ToA=Object.getOwnPropertyDescriptor,US=(i,A,e,t)=>{for(var g=t>1?void 0:t?ToA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&YoA(A,e,g),g};let EF=class{constructor(){r(this,"texture",null);r(this,"rect")}};US([D(He)],EF.prototype,"texture",2);let Yc=class extends Nu{constructor(){super(...arguments);r(this,"_sprite");r(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new EF),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}isBuiltinSprite(){var e,t,g,I,o,s,n,C,a,B,Q;switch((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((o=(I=(g=this.sprite)==null?void 0:g.texture)==null?void 0:I.name)!=null&&o.length)&&((C=(n=(s=this.sprite)==null?void 0:s.texture)==null?void 0:n.image)==null?void 0:C.width)===32&&((Q=(B=(a=this.sprite)==null?void 0:a.texture)==null?void 0:B.image)==null?void 0:Q.height)===32}onBeforeCreate(e){var t,g;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((g=(t=this.sprite)==null?void 0:t.texture)==null?void 0:g.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};US([D(EF)],Yc.prototype,"sprite",1);US([D()],Yc.prototype,"pixelsPerUnitMultiplier",2);class NS extends Nu{constructor(){super(...arguments);r(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}US([D(He)],NS.prototype,"mainTexture",1);var _oA=Object.defineProperty,HoA=Object.getOwnPropertyDescriptor,Ko=(i,A,e,t)=>{for(var g=t>1?void 0:t?HoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&_oA(A,e,g),g};const Vr=oA("debugbutton");class oQ{constructor(){r(this,"colorMultiplier");r(this,"disabledColor");r(this,"fadeDuration");r(this,"highlightedColor");r(this,"normalColor");r(this,"pressedColor");r(this,"selectedColor")}}Ko([D()],oQ.prototype,"colorMultiplier",2);Ko([D(Kt)],oQ.prototype,"disabledColor",2);Ko([D()],oQ.prototype,"fadeDuration",2);Ko([D(Kt)],oQ.prototype,"highlightedColor",2);Ko([D(Kt)],oQ.prototype,"normalColor",2);Ko([D(Kt)],oQ.prototype,"pressedColor",2);Ko([D(Kt)],oQ.prototype,"selectedColor",2);class Aa extends NA{constructor(){super(...arguments);r(this,"onClick");r(this,"_isHovered",0);r(this,"colors");r(this,"transition");r(this,"animationTriggers");r(this,"animator");r(this,"_interactable",!0);r(this,"_requestedAnimatorTrigger");r(this,"_isInit",!1);r(this,"_image")}onPointerEnter(e){var t,g;this._isHovered+=1,Vr&&console.warn("Button Enter",this._isHovered,(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;this._isHovered-=1,Vr&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var t,g;Vr&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("pressed")))}onPointerUp(e){var t,g;Vr&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===xU.Mouse)&&(Vr&&(console.warn("Button Click",this.onClick),Ui("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Vr))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),Ue.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Vr&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(fu)||this.gameObject.addComponent(uS)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=BA.getComponent(this.gameObject,Yc),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,c,h,u,l;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),g={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(g);const I=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.pressedColor),n={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(n);const C=this.getFinalColor(e.color,(u=this.colors)==null?void 0:u.selectedColor),a={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};e.setupState(a);const B=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.disabledColor),Q={state:"disabled",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}Ko([D(kg)],Aa.prototype,"onClick",2);Ko([D()],Aa.prototype,"colors",2);Ko([D()],Aa.prototype,"transition",2);Ko([D()],Aa.prototype,"animationTriggers",2);Ko([D(jg)],Aa.prototype,"animator",2);Ko([D()],Aa.prototype,"interactable",1);var OoA=Object.defineProperty,PoA=Object.getOwnPropertyDescriptor,gg=(i,A,e,t)=>{for(var g=t>1?void 0:t?PoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OoA(A,e,g),g};const AL=oA("debuguilayout");class pr{constructor(){r(this,"left",0);r(this,"right",0);r(this,"top",0);r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}gg([D()],pr.prototype,"left",2);gg([D()],pr.prototype,"right",2);gg([D()],pr.prototype,"top",2);gg([D()],pr.prototype,"bottom",2);class Jo extends NA{constructor(){super(...arguments);r(this,"_rectTransform",null);r(this,"_needsUpdate",!1);r(this,"childAlignment",0);r(this,"reverseArrangement",!1);r(this,"spacing",0);r(this,"padding");r(this,"minWidth",0);r(this,"minHeight",0);r(this,"flexibleHeight",0);r(this,"flexibleWidth",0);r(this,"preferredHeight",0);r(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(AL&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){AL&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(qI);const e=this.gameObject.getComponentInParent(Vg);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(Vg);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}gg([D()],Jo.prototype,"childAlignment",2);gg([D()],Jo.prototype,"reverseArrangement",2);gg([D()],Jo.prototype,"spacing",2);gg([D(pr)],Jo.prototype,"padding",2);gg([D()],Jo.prototype,"minWidth",2);gg([D()],Jo.prototype,"minHeight",2);gg([D()],Jo.prototype,"flexibleHeight",2);gg([D()],Jo.prototype,"flexibleWidth",2);gg([D()],Jo.prototype,"preferredHeight",2);gg([D()],Jo.prototype,"preferredWidth",2);class fr extends Jo{constructor(){super(...arguments);r(this,"childControlHeight",!0);r(this,"childControlWidth",!0);r(this,"childForceExpandHeight",!1);r(this,"childForceExpandWidth",!1);r(this,"childScaleHeight",!1);r(this,"childScaleWidth",!1)}onCalculateLayout(e){var R;const t=this.primaryAxis,g=e.width;let I=g;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const n=t==="x",C=n?"y":"x",a=n?this.childControlWidth:this.childControlHeight,B=n?this.childControlHeight:this.childControlWidth,Q=n?this.childForceExpandWidth:this.childForceExpandHeight,E=n?this.childForceExpandHeight:this.childForceExpandWidth,c=n?s:I,h=n?g:o,u=.5*(n?this.childAlignment%3:Math.floor(this.childAlignment/3));let l=0;n?l+=this.padding.left:l+=this.padding.top;let d=0,p=0;for(let w=0;w<this.gameObject.children.length;w++){const k=this.gameObject.children[w],K=BA.getComponent(k,qI);K!=null&&K.activeAndEnabled&&(p+=1,n?d+=K.width:d+=K.height)}let f=0;const S=this.spacing*(p-1);if(Q||a){let w=0;n?w=I-=S:w=s-=S,p>0&&(f=w/p)}let m=0;m+=this.padding.left,m-=this.padding.right,u!==0&&(l=h-d,l*=u,l-=S*u,n?(l-=this.padding.right*u,l+=this.padding.left*(1-u),l<this.padding.left&&(l=this.padding.left)):(l-=this.padding.bottom*u,l+=this.padding.top*(1-u),l<this.padding.top&&(l=this.padding.top)));let G=1;for(let w=0;w<this.gameObject.children.length;w++){const k=this.gameObject.children[w],K=BA.getComponent(k,qI);if(K!=null&&K.activeAndEnabled){(R=K.pivot)==null||R.set(.5,.5),K.anchorMin.set(0,1),K.anchorMax.set(0,1);const T=g*.5+m*.5;K.anchoredPosition.x!==T&&(K.anchoredPosition.x=T);const O=o*-.5;K.anchoredPosition.y!==O&&(K.anchoredPosition.y=O),E&&B&&K.sizeDelta[C]!==c&&(K.sizeDelta[C]=c),Q&&a&&K.sizeDelta[t]!==f&&(K.sizeDelta[t]=f);const b=n?K.width:K.height,_=b*.5;if(l+=_,Q){const L=f*G-f*.5;L>l&&(l=L-f*.5+b+this.padding.left,l-=_)}let J=l;t==="y"&&(J=-J),K.anchoredPosition[t]!==J&&(K.anchoredPosition[t]=J),l+=_,l+=this.spacing,G+=1}}}}gg([D()],fr.prototype,"childControlHeight",2);gg([D()],fr.prototype,"childControlWidth",2);gg([D()],fr.prototype,"childForceExpandHeight",2);gg([D()],fr.prototype,"childForceExpandWidth",2);gg([D()],fr.prototype,"childScaleHeight",2);gg([D()],fr.prototype,"childScaleWidth",2);class cF extends fr{get primaryAxis(){return"y"}}class hF extends fr{get primaryAxis(){return"x"}}class lF extends Jo{onCalculateLayout(){}}var WoA=Object.defineProperty,joA=Object.getOwnPropertyDescriptor,Hn=(i,A,e,t)=>{for(var g=t>1?void 0:t?joA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WoA(A,e,g),g},NP=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(NP||{});const yk=oA("debuguilayout"),FP=class extends pu{constructor(){super(...arguments);r(this,"_renderOnTop");r(this,"_depthWrite",!1);r(this,"_doubleSided",!0);r(this,"_castShadows",!1);r(this,"_receiveShadows",!1);r(this,"_renderMode",-1);r(this,"_rootCanvas");r(this,"_scaleFactor",1);r(this,"worldCamera");r(this,"planeDistance",-1);r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));r(this,"previousParent",null);r(this,"_lastMatrixWorld",null);r(this,"_rectTransforms",[]);r(this,"_layoutGroups",new Map);r(this,"_receivers",[]);r(this,"onBeforeRenderRoutine",()=>{var A,e,t,g;if(this.previousParent=this.gameObject.parent,((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(g=this.shadowComponent)==null||g.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),eo.ensureUpdateMeshUI(jb,this.context))});r(this,"onAfterRenderRoutine",()=>{var A,e,t,g,I;if(((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(t=this.previousParent)==null||t.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const n=this.context.mainCamera;n==null||n.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(g=this.shadowComponent)==null||g.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),eo.ensureUpdateMeshUI(jb,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(I=this._lastMatrixWorld)==null||I.copy(this.gameObject.matrixWorld)});r(this,"_updateRenderSettingsRoutine");r(this,"_activeRenderMode",-1);r(this,"_lastWidth",-1);r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}set rootCanvas(A){this._rootCanvas instanceof FP||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){var A;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,yk&&console.log("Canvas.Awake()",((A=this.previousParent)==null?void 0:A.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new GA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const A=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);A!==-1&&this.context.pre_render_callbacks.splice(A,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(A){this._rectTransforms.push(A)}unregisterTransform(A){const e=this._rectTransforms.indexOf(A);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(A){const e=A.gameObject;this._layoutGroups.set(e,A)}unregisterLayoutGroup(A){const e=A.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(A){this._receivers.push(A)}unregisterEventReceiver(A){const e=this._receivers.indexOf(A);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(A){this.screenspace?(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await wT(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(A){this.screenspace&&(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var A;for(const e of this._receivers)(A=e.onBeforeCanvasRender)==null||A.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new GA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);yk&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let g=this._layoutGroups.get(t.gameObject);t.isDirty&&!g&&(g=t.gameObject.getComponentInParent(Jo)),(t.isDirty||g!=null&&g.isDirty)&&(yk&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),g==null||g.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),eg.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Ry(this.shadowComponent,this);for(const A of BA.getComponentsInChildren(this.gameObject,_s))Ry(A.shadowComponent,this)}}onUpdateRenderMode(A=!1){if(!A&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=se.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const g=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-g,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(qI);let o=!1;I.sizeDelta.x!==this.context.domWidth&&(o=!0),I.sizeDelta.y!==this.context.domHeight&&(o=!0);const s=e.fieldOfView*Math.PI/180,n=2*Math.tan(s/2)*Math.abs(g);this.gameObject.scale.x=n/this.context.domHeight,this.gameObject.scale.y=n/this.context.domHeight,this.gameObject.scale.z=.01,o&&(I.sizeDelta.x=this.context.domWidth,I.sizeDelta.y=this.context.domHeight,I==null||I.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Vg=FP;Hn([D()],Vg.prototype,"renderOnTop",1);Hn([D()],Vg.prototype,"depthWrite",1);Hn([D()],Vg.prototype,"doubleSided",1);Hn([D()],Vg.prototype,"castShadows",1);Hn([D()],Vg.prototype,"receiveShadows",1);Hn([D()],Vg.prototype,"renderMode",1);Hn([D(Vg)],Vg.prototype,"rootCanvas",1);Hn([D()],Vg.prototype,"scaleFactor",1);Hn([D(ti)],Vg.prototype,"worldCamera",2);Hn([D()],Vg.prototype,"planeDistance",2);var VoA=Object.defineProperty,zoA=Object.getOwnPropertyDescriptor,dF=(i,A,e,t)=>{for(var g=t>1?void 0:t?zoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VoA(A,e,g),g};class Cr extends NA{constructor(){super(...arguments);r(this,"_alpha",1);r(this,"interactable",!0);r(this,"blocksRaycasts",!0);r(this,"_isDirty",!1);r(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),eg.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of BA.getComponentsInChildren(this.gameObject,_s,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}dF([D()],Cr.prototype,"alpha",1);dF([D()],Cr.prototype,"interactable",2);dF([D()],Cr.prototype,"blocksRaycasts",2);var ZoA=Object.defineProperty,XoA=Object.getOwnPropertyDescriptor,Di=(i,A,e,t)=>{for(var g=t>1?void 0:t?XoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ZoA(A,e,g),g};function Fu(i){i&&(i.getComponentInParent(fu)||(Ge()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(Mo)))}class sQ extends NA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new y);r(this,"targetRot",new RA);r(this,"targetScale",new y)}start(){Fu(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Je(this.object).clone(),t=Je(this.target).clone(),g=qt(this.object).clone(),I=qt(this.target).clone(),o=li(this.object).clone(),s=li(this.target).clone(),n=e.distanceTo(t),C=g.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){QI(this.object,t),rs(this.object,I),Bd(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),QI(this.object,this.targetPos),rs(this.object,this.targetRot),Bd(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),g=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(g,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new rg("Move to "+((t=this.target)==null?void 0:t.name),Hg.tapTrigger(this.gameObject),ct.transformAction(this.object,this.target,this.duration,this.relativeMotion?jM.Relative:jM.Absolute));e.addBehavior(g)}}}Di([D(pA)],sQ.prototype,"object",2);Di([D(pA)],sQ.prototype,"target",2);Di([D()],sQ.prototype,"duration",2);Di([D()],sQ.prototype,"relativeMotion",2);var Vf;const BC=(Vf=class extends NA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",[]);r(this,"selfModel");r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=BA.findObjectsOfType(Fi);for(const e of A)for(let t=0;t<e.sharedMaterials.length;t++){const g=e.sharedMaterials[t];if(g===this.materialToSwitch){if(e.gameObject instanceof uA)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof NI)for(const I of e.gameObject.children)I instanceof uA&&I.material===g&&this._objectsWithThisMaterial.push(I);break}}}}start(){Fu(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(A,e){this.targetModels=[],BC._materialTriggersPerId={},BC.variantSwitchIndex=0,this.materialToSwitch&&await lo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await lo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(BC._materialTriggersPerId[this.materialToSwitch.uuid]||(BC._materialTriggersPerId[this.materialToSwitch.uuid]=[]),BC._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=BC._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(g[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in g)s!==I.selfModel.uuid&&o.push(...g[s]);I.createAndAttachBehaviors(A,g[I.selfModel.uuid],o)}}delete BC._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);I.push(ct.fadeAction([...this.targetModels,...t],o,!1)),g.push(ct.fadeAction(e,o,!1)),I.push(ct.fadeAction(e,o,!0)),A.addBehavior(new rg("Select_"+this.selfModel.name,Hg.tapTrigger(this.selfModel),ct.parallel(...I))),A.addBehavior(new rg("StartHidden_"+this.selfModel.name,Hg.sceneStartTrigger(),ct.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+BC.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&Ao.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(Vf,"_materialTriggersPerId",{}),r(Vf,"variantSwitchIndex",0),Vf);let Tc=BC;Di([D(_e)],Tc.prototype,"materialToSwitch",2);Di([D(_e)],Tc.prototype,"variantMaterial",2);Di([D()],Tc.prototype,"fadeDuration",2);var gE;const Qi=(gE=class extends NA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"selfModelClone");r(this,"targetModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1);r(this,"targetStateBeforeCreatingDocument",!1)}start(){Fu(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[Qi.wasVisible]===void 0&&(this.gameObject[Qi.wasVisible]=this.gameObject.activeSelf),this.target[Qi.wasVisible]===void 0&&(this.target[Qi.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[Qi.wasVisible],this.targetStateBeforeCreatingDocument=this.target[Qi.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(A,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let g=this.selfModel,I=this.targetState;if(this.toggleOnClick)if(I=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&nP.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[Qi.toggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggle"+Qi.clonedToggleIndex++,t.add(n),this.gameObject[Qi.toggleClone]=n,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const s=this.gameObject[Qi.toggleClone];if(!this.gameObject[Qi.reverseToggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggleReverse"+Qi.clonedToggleIndex++,t.add(n),this.gameObject[Qi.reverseToggleClone]=n}this.toggleModel=this.gameObject[Qi.reverseToggleClone],(!this.toggleModel.geometry||!s.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),g=s,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const s=[];s.push(ct.fadeAction(g,0,!1)),s.push(ct.fadeAction(this.toggleModel,0,!0)),s.push(ct.fadeAction(this.targetModel,0,I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Hg.tapTrigger(g),ct.parallel(...s)));const n=[];n.push(ct.fadeAction(this.toggleModel,0,!1)),n.push(ct.fadeAction(g,0,!0)),n.push(ct.fadeAction(this.targetModel,0,!I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"Off":"On"),Hg.tapTrigger(this.toggleModel),ct.parallel(...n)))}}else{const s=[];this.hideSelf&&s.push(ct.fadeAction(g,0,!1)),s.push(ct.fadeAction(this.targetModel,0,I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Hg.tapTrigger(g),ct.parallel(...s)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(t),this.toggleModel&&o.push(this.toggleModel),A.addBehavior(new rg("HideOnStart_"+this.gameObject.name,Hg.sceneStartTrigger(),ct.fadeAction(o,0,!1)))}}afterSerialize(A,e){this.gameObject[Qi.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[Qi.wasVisible],delete this.gameObject[Qi.wasVisible]),this.target&&this.target[Qi.wasVisible]!==void 0&&(this.target.visible=this.target[Qi.wasVisible],delete this.target[Qi.wasVisible]),delete this.gameObject[Qi.toggleClone],delete this.gameObject[Qi.reverseToggleClone]}},r(gE,"clonedToggleIndex",0),r(gE,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),r(gE,"toggleClone",Symbol("clone for toggling")),r(gE,"reverseToggleClone",Symbol("clone for reverse toggling")),gE);let nQ=Qi;Di([D(pA)],nQ.prototype,"target",2);Di([D()],nQ.prototype,"toggleOnClick",2);Di([D()],nQ.prototype,"targetState",2);Di([D()],nQ.prototype,"hideSelf",2);class uF extends NA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new rg("HideOnStart_"+this.gameObject.name,Hg.sceneStartTrigger(),ct.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class _c extends NA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType",zN.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new rg("emphasize "+this.name,Hg.tapTrigger(this.gameObject),ct.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}Di([D()],_c.prototype,"target",2);Di([D()],_c.prototype,"duration",2);Di([D()],_c.prototype,"motionType",2);class Hc extends NA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){Fu(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(Ki);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,t,g){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=I.split("/").pop(),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?zM.NonSpatial:zM.Spatial;{let a=ct.playAudioAction(o,"audio/"+s,VM.Play,n,C);this.toggleOnClick&&(a.multiplePerformOperation=QP.Stop),this.target&&this.target.loop&&(a=ct.sequence(a).makeLooping());const B=new rg("playAudio "+this.name,Hg.tapTrigger(this.gameObject),a);e.addBehavior(B)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let a=ct.playAudioAction(o,"audio/"+s,VM.Play,n,C);this.target.loop&&(a=ct.sequence(a).makeLooping());const B=new rg("playAudioOnStart "+this.name,Hg.sceneStartTrigger(),a);e.addBehavior(B)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=g.split("/").pop(),n=await(await(await fetch(g)).blob()).arrayBuffer(),C=new Uint8Array(n);t.files["audio/"+I]=C}}Di([D(Ki)],Hc.prototype,"target",2);Di([D(URL)],Hc.prototype,"clip",2);Di([D()],Hc.prototype,"toggleOnClick",2);var zf;const Ga=(zf=class extends NA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A;return(A=this.animator)==null?void 0:A.gameObject}start(){Fu(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Ga.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';Ge()&&fi(A),console.warn(A,...Ga.rootsWithExclusivePlayback)}Ga.animationActions=[],Ga.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,g=e.extensions.find(s=>s instanceof wu);if(!g)return;const I=g.getClipCount(this.target)>1;I&&(Ge()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+g.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Ga.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=Ga.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=ct.startAnimationAction(s,n.start,n.duration),Ga.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=ct.sequence();if(this.animationSequence!==void 0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence!==void 0){const Q=a.actions.length==0?a:ct.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new rg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Hg.tapTrigger(this.selfModel):Hg.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var n,C,a,B;if(!this.target||!this.animator)return;const g=(n=this.animator)==null?void 0:n.runtimeAnimatorController;let I=g==null?void 0:g.findState(this.stateName),o=[],s=[];if(g&&I){const Q=new Array;Q.push(I);let E=!1;for(;Q.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(C=I.motion)!=null&&C.isLooping&&(E=!0);break}const c=I.transitions.find(u=>u.conditions.length===0),h=c?g.getState(c.destinationState,0):null;if(h&&Q.includes(h)){I=h,E=!0;break}else if(c){if(I=h,!I)break;Q.push(I)}else{E=((a=I.motion)==null?void 0:a.isLooping)??!1;break}}if(E&&I){const c=Q.indexOf(I);o=Q.slice(0,c),s=Q.slice(c),console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=Q,s=[],console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(Q=>{var E,c,h;return((E=Q.motion)==null?void 0:E.clip)&&((h=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)>0}),s=s.filter(Q=>{var E,c,h;return((E=Q.motion)==null?void 0:E.clip)&&((h=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((B=this.animator)==null?void 0:B.name)+", can't export animation data");return}if(this.stateAnimationModel=e,o.length>0){this.animationSequence=new Array;for(const Q of o)this.animationSequence.push(A.registerAnimation(this.target,Q.motion.clip))}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const Q of s)this.animationLoopAfterSequence.push(A.registerAnimation(this.target,Q.motion.clip))}}},r(zf,"animationActions",[]),r(zf,"rootsWithExclusivePlayback",new Set),zf);let Oc=Ga;Di([D(jg)],Oc.prototype,"animator",2);Di([D()],Oc.prototype,"stateName",2);class Pc extends NA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}Di([D(pA)],Pc.prototype,"target",2);class Ku extends NA{constructor(){super(...arguments);r(this,"target")}}Di([D(Pc)],Ku.prototype,"target",2);class Ju extends Pc{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Di([D()],Ju.prototype,"type",2);Di([D()],Ju.prototype,"duration",2);class pF extends Ku{}var $oA=Object.defineProperty,AsA=Object.getOwnPropertyDescriptor,ea=(i,A,e,t)=>{for(var g=t>1?void 0:t?AsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&$oA(A,e,g),g};const eL=oA("debugcharactercontroller");class CQ extends NA{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new y)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ei),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ei)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(nr);t||(t=this.gameObject.addNewComponent(nr)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const g=new y(0,0,1),I=new y(1,0,0),o=new y(0,1,0),s=this.gameObject.getWorldDirection(new y);s.y=0;const n=I.dot(s)<0?-1:1,C=g.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),eL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),eL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const g=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);g&&(this._contactVelocity.x+=g.x,this._contactVelocity.y+=g.y,this._contactVelocity.z+=g.z)}return this._contactVelocity}}ea([D(y)],CQ.prototype,"center",2);ea([D()],CQ.prototype,"radius",2);ea([D()],CQ.prototype,"height",2);class ta extends NA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new gA(0,0));r(this,"moveInput",new gA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new y(0,0,0));r(this,"_currentAngularSpeed",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new Bs)}awake(){this._currentRotation=new RA}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,g){var I,o,s,n,C,a,B,Q,E,c,h;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=se.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const u=this.context.mainCameraComponent.forward;u.y=0,u.normalize(),this._currentRotation.setFromUnitVectors(new y(0,0,1),u),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let u=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(u=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),u){this._jumpCount+=1;const l=this.controller.rigidbody,d=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new y(0,1,0).multiplyScalar(d))}}if(this.controller){const u=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(u<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Uo),this._raycastOptions.ray.origin.copy(Je(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const d=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(d.length&&d[0].distance>2||u<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}ea([D(CQ)],ta.prototype,"controller",2);ea([D()],ta.prototype,"movementSpeed",2);ea([D()],ta.prototype,"rotationSpeed",2);ea([D()],ta.prototype,"jumpForce",2);ea([D()],ta.prototype,"doubleJumpForce",2);ea([D(jg)],ta.prototype,"animator",2);var esA=Object.defineProperty,tsA=Object.getOwnPropertyDescriptor,isA=(i,A,e,t)=>{for(var g=t>1?void 0:t?tsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&esA(A,e,g),g};class vu extends lI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new n_;return e.offset=new gA(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}isA([D(be)],vu.prototype,"intensity",2);ls("ChromaticAberration",vu);var gsA=Object.defineProperty,IsA=Object.getOwnPropertyDescriptor,FS=(i,A,e,t)=>{for(var g=t>1?void 0:t?IsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&gsA(A,e,g),g};class Dr extends lI{constructor(){super(...arguments);r(this,"postExposure");r(this,"contrast");r(this,"hueShift");r(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===to&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=ql);const e=new s_;this.postExposure.onValueChanged=g=>{this.context.renderer.toneMapping===to&&(this.context.renderer.toneMapping=ql),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=g)},this.contrast.onValueChanged=g=>{e.contrast=g};const t=new a_;return this.hueShift.onValueChanged=g=>t.hue=g,this.saturation.onValueChanged=g=>t.saturation=g,[t,e]}}FS([D(be)],Dr.prototype,"postExposure",2);FS([D(be)],Dr.prototype,"contrast",2);FS([D(be)],Dr.prototype,"hueShift",2);FS([D(be)],Dr.prototype,"saturation",2);ls("ColorAdjustments",Dr);const osA=(Math.sqrt(5)-1)/4,Ng=(5-Math.sqrt(5))/20,kf=i=>Math.floor(i)|0,Gf=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ssA(i=Math.random){const A=nsA(i),e=new Float64Array(A).map(o=>Gf[o%32*4]),t=new Float64Array(A).map(o=>Gf[o%32*4+1]),g=new Float64Array(A).map(o=>Gf[o%32*4+2]),I=new Float64Array(A).map(o=>Gf[o%32*4+3]);return function(s,n,C,a){let B,Q,E,c,h;const u=(s+n+C+a)*osA,l=kf(s+u),d=kf(n+u),p=kf(C+u),f=kf(a+u),S=(l+d+p+f)*Ng,m=l-S,G=d-S,R=p-S,w=f-S,k=s-m,K=n-G,T=C-R,O=a-w;let b=0,_=0,J=0,L=0;k>K?b++:_++,k>T?b++:J++,k>O?b++:L++,K>T?_++:J++,K>O?_++:L++,T>O?J++:L++;const H=b>=3?1:0,Z=_>=3?1:0,X=J>=3?1:0,nA=L>=3?1:0,lA=b>=2?1:0,SA=_>=2?1:0,qA=J>=2?1:0,ZA=L>=2?1:0,CA=b>=1?1:0,DA=_>=1?1:0,TA=J>=1?1:0,OA=L>=1?1:0,XA=k-H+Ng,HA=K-Z+Ng,JA=T-X+Ng,V=O-nA+Ng,fA=k-lA+2*Ng,LA=K-SA+2*Ng,wA=T-qA+2*Ng,VA=O-ZA+2*Ng,re=k-CA+3*Ng,q=K-DA+3*Ng,F=T-TA+3*Ng,aA=O-OA+3*Ng,MA=k-1+4*Ng,mA=K-1+4*Ng,FA=T-1+4*Ng,Ie=O-1+4*Ng,YA=l&255,ee=d&255,Ce=p&255,De=f&255;let UA=.6-k*k-K*K-T*T-O*O;if(UA<0)B=0;else{const PA=YA+A[ee+A[Ce+A[De]]];UA*=UA,B=UA*UA*(e[PA]*k+t[PA]*K+g[PA]*T+I[PA]*O)}let Le=.6-XA*XA-HA*HA-JA*JA-V*V;if(Le<0)Q=0;else{const PA=YA+H+A[ee+Z+A[Ce+X+A[De+nA]]];Le*=Le,Q=Le*Le*(e[PA]*XA+t[PA]*HA+g[PA]*JA+I[PA]*V)}let he=.6-fA*fA-LA*LA-wA*wA-VA*VA;if(he<0)E=0;else{const PA=YA+lA+A[ee+SA+A[Ce+qA+A[De+ZA]]];he*=he,E=he*he*(e[PA]*fA+t[PA]*LA+g[PA]*wA+I[PA]*VA)}let le=.6-re*re-q*q-F*F-aA*aA;if(le<0)c=0;else{const PA=YA+CA+A[ee+DA+A[Ce+TA+A[De+OA]]];le*=le,c=le*le*(e[PA]*re+t[PA]*q+g[PA]*F+I[PA]*aA)}let te=.6-MA*MA-mA*mA-FA*FA-Ie*Ie;if(te<0)h=0;else{const PA=YA+1+A[ee+1+A[Ce+1+A[De+1]]];te*=te,h=te*te*(e[PA]*MA+t[PA]*mA+g[PA]*FA+I[PA]*Ie)}return 27*(B+Q+E+c+h)}}function nsA(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const g=t+~~(i()*(256-t)),I=e[t];e[t]=e[g],e[g]=I}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var CsA=Object.defineProperty,asA=Object.getOwnPropertyDescriptor,sA=(i,A,e,t)=>{for(var g=t>1?void 0:t?asA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CsA(A,e,g),g};const Mf=oA("debugparticles");var hC=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(hC||{});let yr=class{constructor(){r(this,"alphaKeys");r(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let t,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const n=this.alphaKeys[s];(n.time<A||!t)&&(t=n,g=s)}for(let s=0;s<this.colorKeys.length;s++){const n=this.colorKeys[s];(n.time<A||!I)&&(I=n,o=s)}if(I)if(o+1<this.colorKeys.length){const n=this.colorKeys[o+1],C=se.remap(A,I.time,n.time,0,1);e.r=se.lerp(I.color.r,n.color.r,C),e.g=se.lerp(I.color.g,n.color.g,C),e.b=se.lerp(I.color.b,n.color.b,C)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(t)if(g+1<this.alphaKeys.length){const n=this.alphaKeys[g+1],C=se.remap(A,t.time,n.time,0,1);e.alpha=se.lerp(t.alpha,n.alpha,C)}else e.alpha=t.alpha;return e}};sA([D()],yr.prototype,"alphaKeys",2);sA([D()],yr.prototype,"colorKeys",2);var pd=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(pd||{}),Uy=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(Uy||{});const KP=class{constructor(){r(this,"mode");r(this,"constant");r(this,"constantMin");r(this,"constantMax");r(this,"curve");r(this,"curveMin");r(this,"curveMax");r(this,"curveMultiplier")}clone(){var A,e,t;const i=new KP;return i.mode=this.mode,i.constant=this.constant,i.constantMin=this.constantMin,i.constantMax=this.constantMax,i.curve=(A=this.curve)==null?void 0:A.clone(),i.curveMin=(e=this.curveMin)==null?void 0:e.clone(),i.curveMax=(t=this.curveMax)==null?void 0:t.clone(),i.curveMultiplier=this.curveMultiplier,i}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.constant;case 1:return i=se.clamp01(i),this.curve.evaluate(i)*this.curveMultiplier;case 2:const t=i*this.curveMin.duration,g=i*this.curveMax.duration;return se.lerp(this.curveMin.evaluate(t),this.curveMax.evaluate(g),e%1)*this.curveMultiplier;case 3:return se.lerp(this.constantMin,this.constantMax,e%1);default:this.curveMax.evaluate(i)*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(i){if(!i)return 0;let A=Number.MIN_VALUE;for(let e=0;e<i.keys.length;e++){const t=i.keys[e];t.value>A&&(A=t.value)}return A}};let ce=KP;sA([D()],ce.prototype,"mode",2);sA([D()],ce.prototype,"constant",2);sA([D()],ce.prototype,"constantMin",2);sA([D()],ce.prototype,"constantMax",2);sA([D($B)],ce.prototype,"curve",2);sA([D($B)],ce.prototype,"curveMin",2);sA([D($B)],ce.prototype,"curveMax",2);sA([D()],ce.prototype,"curveMultiplier",2);var Zf;const ks=(Zf=class{constructor(){r(this,"mode");r(this,"color");r(this,"colorMin");r(this,"colorMax");r(this,"gradient");r(this,"gradientMin");r(this,"gradientMax")}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,ks._temp),ks._temp;case 2:return ks._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(i,ks._temp),this.gradientMax.evaluate(i,ks._temp2),ks._temp.lerp(ks._temp2,e)}return ks._temp.set(16711935),ks._temp.alpha=1,ks._temp}},r(Zf,"_temp",new Kt(0,0,0,1)),r(Zf,"_temp2",new Kt(0,0,0,1)),Zf);let oo=ks;sA([D(Kt)],oo.prototype,"color",2);sA([D(Kt)],oo.prototype,"colorMin",2);sA([D(Kt)],oo.prototype,"colorMax",2);sA([D(yr)],oo.prototype,"gradient",2);sA([D(yr)],oo.prototype,"gradientMin",2);sA([D(yr)],oo.prototype,"gradientMax",2);var gR=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(gR||{});class eI{constructor(){r(this,"cullingMode");r(this,"duration");r(this,"emitterVelocityMode");r(this,"flipRotation");r(this,"gravityModifier");r(this,"gravityModifierMultiplier");r(this,"loop");r(this,"maxParticles");r(this,"playOnAwake");r(this,"prewarm");r(this,"ringBufferLoopRange");r(this,"ringBufferMode");r(this,"scalingMode");r(this,"simulationSpace");r(this,"simulationSpeed");r(this,"startColor");r(this,"startDelay");r(this,"startDelayMultiplier");r(this,"startLifetime");r(this,"startLifetimeMultiplier");r(this,"startRotation");r(this,"startRotationMultiplier");r(this,"startRotation3D");r(this,"startRotationX");r(this,"startRotationXMultiplier");r(this,"startRotationY");r(this,"startRotationYMultiplier");r(this,"startRotationZ");r(this,"startRotationZMultiplier");r(this,"startSize");r(this,"startSize3D");r(this,"startSizeMultiplier");r(this,"startSizeX");r(this,"startSizeXMultiplier");r(this,"startSizeY");r(this,"startSizeYMultiplier");r(this,"startSizeZ");r(this,"startSizeZMultiplier");r(this,"startSpeed");r(this,"startSpeedMultiplier");r(this,"stopAction");r(this,"useUnscaledTime")}}sA([D(ce)],eI.prototype,"gravityModifier",2);sA([D(oo)],eI.prototype,"startColor",2);sA([D(ce)],eI.prototype,"startDelay",2);sA([D(ce)],eI.prototype,"startLifetime",2);sA([D(ce)],eI.prototype,"startRotation",2);sA([D(ce)],eI.prototype,"startRotationX",2);sA([D(ce)],eI.prototype,"startRotationY",2);sA([D(ce)],eI.prototype,"startRotationZ",2);sA([D(ce)],eI.prototype,"startSize",2);sA([D(ce)],eI.prototype,"startSizeX",2);sA([D(ce)],eI.prototype,"startSizeY",2);sA([D(ce)],eI.prototype,"startSizeZ",2);sA([D(ce)],eI.prototype,"startSpeed",2);class fd{constructor(){r(this,"cycleCount");r(this,"maxCount");r(this,"minCount");r(this,"probability");r(this,"repeatInterval");r(this,"time");r(this,"count");r(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 t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=se.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=se.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class On{constructor(){r(this,"enabled");r(this,"bursts");r(this,"rateOverTime");r(this,"rateOverTimeMultiplier");r(this,"rateOverDistance");r(this,"rateOverDistanceMultiplier");r(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 t=this.bursts[e];this.system.main.loop&&t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}}sA([D()],On.prototype,"enabled",2);sA([D()],On.prototype,"bursts",2);sA([D(ce)],On.prototype,"rateOverTime",2);sA([D()],On.prototype,"rateOverTimeMultiplier",2);sA([D(ce)],On.prototype,"rateOverDistance",2);sA([D()],On.prototype,"rateOverDistanceMultiplier",2);class bu{constructor(){r(this,"enabled");r(this,"color")}}sA([D(oo)],bu.prototype,"color",2);class wr{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_time",0);r(this,"_temp",new y)}evaluate(A,e,t){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,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{const g=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=g}return e}}sA([D(ce)],wr.prototype,"size",2);sA([D(ce)],wr.prototype,"x",2);sA([D(ce)],wr.prototype,"y",2);sA([D(ce)],wr.prototype,"z",2);var Xf;const il=(Xf=class{constructor(){r(this,"shapeType",5);r(this,"enabled",!0);r(this,"alignToDirection",!1);r(this,"angle",0);r(this,"arc",360);r(this,"arcSpread");r(this,"arcSpeedMultiplier");r(this,"arcMode");r(this,"boxThickness");r(this,"position");r(this,"rotation");r(this,"_rotation",new Og);r(this,"scale");r(this,"radius");r(this,"radiusThickness");r(this,"sphericalDirectionAmount");r(this,"randomDirectionAmount");r(this,"randomPositionAmount");r(this,"meshShapeType");r(this,"meshRenderer");r(this,"_meshObj");r(this,"_meshGeometry");r(this,"system");r(this,"_space");r(this,"_worldSpaceMatrix",new GA);r(this,"_worldSpaceMatrixInverse",new GA);r(this,"_vector",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_triangle",new UI);r(this,"_dir",new y);r(this,"_loopTime",0);r(this,"_loopDirection",1);Mf&&console.log(this)}get type(){return Uy[this.shapeType]}initialize(i){this.onInitialize(i),i.position.copy(this._vector)}toJSON(){return this}clone(){return new il}setMesh(i){this.meshRenderer=i,i?(this._meshObj=i.sharedMeshes[Math.floor(Math.random()*i.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(i,A,e,t){this.system=i,this._space=e,e===1&&(this._worldSpaceMatrix.copy(t.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=se.toRadians(this.rotation.x),this._rotation.y=se.toRadians(this.rotation.y),this._rotation.z=se.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),A}onInitialize(i){this._vector.set(0,0,0),i.mesh=void 0,i.mesh_geometry=void 0;const A=this._temp.copy(this.position),e=this._space===1;e&&A.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Mf&&Ue.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,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 13:const g=this.meshRenderer;(g==null?void 0:g.destroyed)==!1&&this.setMesh(g);const I=i.mesh=this._meshObj,o=i.mesh_geometry=this._meshGeometry;if(I&&o)switch(this.meshShapeType){case 0:{const s=o.getAttribute("position"),n=Math.floor(Math.random()*s.count);this._vector.fromBufferAttribute(s,n),this._vector.applyMatrix4(I.matrixWorld),i.mesh_normal=n}break;case 1:break;case 2:{const s=o.index;if(s){let n=Math.random(),C=Math.random();n+C>1&&(n=1-n,C=1-C);const a=Math.floor(Math.random()*(s.count/3));let B=a*3,Q=a*3+1,E=a*3+2;B=s.getX(B),Q=s.getX(Q),E=s.getX(E);const c=o.getAttribute("position");this._triangle.a.fromBufferAttribute(c,B),this._triangle.b.fromBufferAttribute(c,Q),this._triangle.c.fromBufferAttribute(c,E),this._vector.set(0,0,0).addScaledVector(this._triangle.a,n).addScaledVector(this._triangle.b,C).addScaledVector(this._triangle.c,1-(n+C)),this._vector.applyMatrix4(I.matrixWorld),i.mesh_normal=a}}break}break;default:this._vector.set(0,0,0),Ge()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",Uy[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)),Mf&&Ue.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i,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 t=A.x,g=A.y,I=A.z;this._dir.set(t,g,I),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const o=i.mesh,s=i.mesh_geometry;if(o&&s)switch(this.meshShapeType){case 0:{const n=s.getAttribute("normal"),C=i.mesh_normal;this._dir.fromBufferAttribute(n,C)}break;case 1:break;case 2:{const n=s.index;if(n){const C=i.mesh_normal,a=n.getX(C*3),B=n.getX(C*3+1),Q=n.getX(C*3+2),E=s.getAttribute("position"),c=Zi(),h=Zi(),u=Zi();c.fromBufferAttribute(E,a),h.fromBufferAttribute(E,B),u.fromBufferAttribute(E,Q),c.sub(h),u.sub(h),c.cross(u),this._dir.copy(c).multiplyScalar(-1);const l=qt(o);this._dir.applyQuaternion(l)}}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),Mf&&(Ue.DrawSphere(A,.01,8925952,.5,!0),Ue.DrawDirection(A,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,A){if(A<=0)return;const e=il._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,i.add(e)}randomizeDirection(i,A){if(A===0)return;const e=il._randomQuat,t=il._tempVec;t.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(t,A*Math.random()*Math.PI),i.applyQuaternion(e)}spherizeDirection(i,A){if(A===0)return;const e=Math.random()*Math.PI*2,t=Math.acos(1-Math.random()*2),g=Math.sin(t)*Math.cos(e),I=Math.sin(t)*Math.sin(e),o=Math.cos(t),s=new y(g,I,o);i.lerp(s,A)}randomSpherePoint(i,A,e,t,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(t/360),n=Math.acos(2*o-1),C=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,a=i.x+this.scale.x*(-C*Math.sin(n)*Math.cos(s)),B=i.y+this.scale.y*(C*Math.sin(n)*Math.sin(s)),Q=i.z+this.scale.z*(C*Math.cos(n));g.x=a,g.y=B,g.z=Q}randomCirclePoint(i,A,e,t,g){const I=Math.random(),o=2*Math.PI*I*(t/360),s=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,n=i.x+this.scale.x*s*Math.cos(o),C=i.y+this.scale.y*s*Math.sin(o),a=i.z;g.x=n,g.y=C,g.z=a}randomConePoint(i,A,e,t,g,I,o){let s=0,n=0;switch(I){case 0:s=Math.random(),n=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,n=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let C=2*Math.PI*s*(g/360);switch(I){case 2:case 1:C+=Math.PI+.5,C+=this._loopTime*Math.PI*2,C%=se.toRadians(g);break}const a=Math.acos(2*n-1),B=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,Q=i.x+-B*Math.sin(a)*Math.cos(C),E=i.y+B*Math.sin(a)*Math.sin(C),c=i.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=c*this.scale.z}},r(Xf,"_randomQuat",new RA),r(Xf,"_tempVec",new y),Xf);let yi=il;sA([D()],yi.prototype,"shapeType",2);sA([D()],yi.prototype,"enabled",2);sA([D()],yi.prototype,"alignToDirection",2);sA([D()],yi.prototype,"angle",2);sA([D()],yi.prototype,"arc",2);sA([D()],yi.prototype,"arcSpread",2);sA([D()],yi.prototype,"arcSpeedMultiplier",2);sA([D()],yi.prototype,"arcMode",2);sA([D(y)],yi.prototype,"boxThickness",2);sA([D(y)],yi.prototype,"position",2);sA([D(y)],yi.prototype,"rotation",2);sA([D(y)],yi.prototype,"scale",2);sA([D()],yi.prototype,"radius",2);sA([D()],yi.prototype,"radiusThickness",2);sA([D()],yi.prototype,"sphericalDirectionAmount",2);sA([D()],yi.prototype,"randomDirectionAmount",2);sA([D()],yi.prototype,"randomPositionAmount",2);sA([D()],yi.prototype,"meshShapeType",2);sA([D(hu)],yi.prototype,"meshRenderer",2);class vt{constructor(){r(this,"damping");r(this,"enabled");r(this,"frequency");r(this,"octaveCount");r(this,"octaveMultiplier");r(this,"octaveScale");r(this,"positionAmount");r(this,"quality");r(this,"remap");r(this,"remapEnabled");r(this,"remapMultiplier");r(this,"remapX");r(this,"remapXMultiplier");r(this,"remapY");r(this,"remapYMultiplier");r(this,"remapZ");r(this,"remapZMultiplier");r(this,"scrollSpeedMultiplier");r(this,"separateAxes");r(this,"strengthMultiplier");r(this,"strengthX");r(this,"strengthXMultiplier");r(this,"strengthY");r(this,"strengthYMultiplier");r(this,"strengthZ");r(this,"strengthZMultiplier");r(this,"_noise");r(this,"_time",0);r(this,"_temp",new y)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,t,g,I,o){if(!this.enabled)return;this._noise||(this._noise=ssA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),n=this._noise(s.x,s.y,s.z,this._time),C=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),a=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(n,C,a).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)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}}sA([D()],vt.prototype,"damping",2);sA([D()],vt.prototype,"enabled",2);sA([D()],vt.prototype,"frequency",2);sA([D()],vt.prototype,"octaveCount",2);sA([D()],vt.prototype,"octaveMultiplier",2);sA([D()],vt.prototype,"octaveScale",2);sA([D(ce)],vt.prototype,"positionAmount",2);sA([D()],vt.prototype,"quality",2);sA([D(ce)],vt.prototype,"remap",2);sA([D()],vt.prototype,"remapEnabled",2);sA([D()],vt.prototype,"remapMultiplier",2);sA([D(ce)],vt.prototype,"remapX",2);sA([D()],vt.prototype,"remapXMultiplier",2);sA([D(ce)],vt.prototype,"remapY",2);sA([D()],vt.prototype,"remapYMultiplier",2);sA([D(ce)],vt.prototype,"remapZ",2);sA([D()],vt.prototype,"remapZMultiplier",2);sA([D()],vt.prototype,"scrollSpeedMultiplier",2);sA([D()],vt.prototype,"separateAxes",2);sA([D()],vt.prototype,"strengthMultiplier",2);sA([D(ce)],vt.prototype,"strengthX",2);sA([D()],vt.prototype,"strengthXMultiplier",2);sA([D(ce)],vt.prototype,"strengthY",2);sA([D()],vt.prototype,"strengthYMultiplier",2);sA([D(ce)],vt.prototype,"strengthZ",2);sA([D()],vt.prototype,"strengthZMultiplier",2);class ri{constructor(){r(this,"enabled");r(this,"attachRibbonToTransform",!1);r(this,"colorOverLifetime");r(this,"colorOverTrail");r(this,"dieWithParticles",!0);r(this,"inheritParticleColor",!0);r(this,"lifetime");r(this,"lifetimeMultiplier");r(this,"minVertexDistance",.2);r(this,"mode",0);r(this,"ratio",1);r(this,"ribbonCount",1);r(this,"shadowBias",0);r(this,"sizeAffectsLifetime",!1);r(this,"sizeAffectsWidth",!1);r(this,"splitSubEmitterRibbons",!1);r(this,"textureMode",0);r(this,"widthOverTrail");r(this,"widthOverTrailMultiplier");r(this,"worldSpace",!1)}getWidth(A,e,t,g){const I=this.widthOverTrail.evaluate(t,g);return A*=I,A}getColor(A,e,t){const g=this.colorOverTrail.evaluate(t),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}}sA([D()],ri.prototype,"enabled",2);sA([D()],ri.prototype,"attachRibbonToTransform",2);sA([D(oo)],ri.prototype,"colorOverLifetime",2);sA([D(oo)],ri.prototype,"colorOverTrail",2);sA([D()],ri.prototype,"dieWithParticles",2);sA([D()],ri.prototype,"inheritParticleColor",2);sA([D(ce)],ri.prototype,"lifetime",2);sA([D()],ri.prototype,"lifetimeMultiplier",2);sA([D()],ri.prototype,"minVertexDistance",2);sA([D()],ri.prototype,"mode",2);sA([D()],ri.prototype,"ratio",2);sA([D()],ri.prototype,"ribbonCount",2);sA([D()],ri.prototype,"shadowBias",2);sA([D()],ri.prototype,"sizeAffectsLifetime",2);sA([D()],ri.prototype,"sizeAffectsWidth",2);sA([D()],ri.prototype,"splitSubEmitterRibbons",2);sA([D()],ri.prototype,"textureMode",2);sA([D(ce)],ri.prototype,"widthOverTrail",2);sA([D()],ri.prototype,"widthOverTrailMultiplier",2);sA([D()],ri.prototype,"worldSpace",2);class wi{constructor(){r(this,"enabled");r(this,"space",0);r(this,"orbitalX");r(this,"orbitalY");r(this,"orbitalZ");r(this,"orbitalXMultiplier");r(this,"orbitalYMultiplier");r(this,"orbitalZMultiplier");r(this,"orbitalOffsetX");r(this,"orbitalOffsetY");r(this,"orbitalOffsetZ");r(this,"speedModifier");r(this,"speedModifierMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_system");r(this,"_temp",new y);r(this,"_temp2",new y);r(this,"_temp3",new y);r(this,"_hasOrbital",!1);r(this,"_index",0);r(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,t,g,I,o,s){var E;if(!this.enabled)return;const n=o/s,C=this.speedModifier.evaluate(n)*this.speedModifierMultiplier,a=this.x.evaluate(n),B=this.y.evaluate(n),Q=this.z.evaluate(n);if(this._temp.set(-a,B,Q),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((E=this._system)==null?void 0:E.worldPos)){const h=this._temp2.set(t.x,t.y,t.z),u=this.orbitalXMultiplier,l=this.orbitalYMultiplier,d=this.orbitalZMultiplier,p=C*Math.PI*2*10,f=Math.cos(p*u),S=Math.sin(p*u),m=Math.cos(p*l),G=Math.sin(p*l),R=Math.cos(p*d),w=Math.sin(p*d),k=h.x*(m*R)+h.y*(m*w)+h.z*-G,K=h.x*(S*G*R-f*w)+h.y*(S*G*w+f*R)+h.z*(S*m),T=h.x*(f*G*R+S*w)+h.y*(f*G*w-S*R)+h.z*(f*m),O=this._temp3.set(h.x-k,h.y-K,h.z-T);O.normalize(),O.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=O.x,g.y+=O.y,g.z+=O.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=C,g.y*=C,g.z*=C}}sA([D()],wi.prototype,"enabled",2);sA([D()],wi.prototype,"space",2);sA([D(ce)],wi.prototype,"orbitalX",2);sA([D(ce)],wi.prototype,"orbitalY",2);sA([D(ce)],wi.prototype,"orbitalZ",2);sA([D()],wi.prototype,"orbitalXMultiplier",2);sA([D()],wi.prototype,"orbitalYMultiplier",2);sA([D()],wi.prototype,"orbitalZMultiplier",2);sA([D()],wi.prototype,"orbitalOffsetX",2);sA([D()],wi.prototype,"orbitalOffsetY",2);sA([D()],wi.prototype,"orbitalOffsetZ",2);sA([D(ce)],wi.prototype,"speedModifier",2);sA([D()],wi.prototype,"speedModifierMultiplier",2);sA([D(ce)],wi.prototype,"x",2);sA([D()],wi.prototype,"xMultiplier",2);sA([D(ce)],wi.prototype,"y",2);sA([D()],wi.prototype,"yMultiplier",2);sA([D(ce)],wi.prototype,"z",2);sA([D()],wi.prototype,"zMultiplier",2);class tI{constructor(){r(this,"animation");r(this,"enabled");r(this,"cycleCount");r(this,"frameOverTime");r(this,"frameOverTimeMultiplier");r(this,"numTilesX");r(this,"numTilesY");r(this,"startFrame");r(this,"startFrameMultiplier");r(this,"rowMode");r(this,"rowIndex");r(this,"spriteCount");r(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 t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}}sA([D()],tI.prototype,"animation",2);sA([D()],tI.prototype,"enabled",2);sA([D()],tI.prototype,"cycleCount",2);sA([D(ce)],tI.prototype,"frameOverTime",2);sA([D()],tI.prototype,"frameOverTimeMultiplier",2);sA([D()],tI.prototype,"numTilesX",2);sA([D()],tI.prototype,"numTilesY",2);sA([D(ce)],tI.prototype,"startFrame",2);sA([D()],tI.prototype,"startFrameMultiplier",2);sA([D()],tI.prototype,"rowMode",2);sA([D()],tI.prototype,"rowIndex",2);sA([D()],tI.prototype,"spriteCount",2);sA([D()],tI.prototype,"timeMode",2);class us{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}sA([D()],us.prototype,"enabled",2);sA([D()],us.prototype,"separateAxes",2);sA([D(ce)],us.prototype,"x",2);sA([D()],us.prototype,"xMultiplier",2);sA([D(ce)],us.prototype,"y",2);sA([D()],us.prototype,"yMultiplier",2);sA([D(ce)],us.prototype,"z",2);sA([D()],us.prototype,"zMultiplier",2);class vo{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const t=se.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}}sA([D()],vo.prototype,"enabled",2);sA([D()],vo.prototype,"range",2);sA([D()],vo.prototype,"separateAxes",2);sA([D(ce)],vo.prototype,"x",2);sA([D()],vo.prototype,"xMultiplier",2);sA([D(ce)],vo.prototype,"y",2);sA([D()],vo.prototype,"yMultiplier",2);sA([D(ce)],vo.prototype,"z",2);sA([D()],vo.prototype,"zMultiplier",2);class Ig{constructor(){r(this,"enabled");r(this,"dampen");r(this,"drag");r(this,"dragMultiplier");r(this,"limit");r(this,"limitMultiplier");r(this,"separateAxes");r(this,"limitX");r(this,"limitXMultiplier");r(this,"limitY");r(this,"limitYMultiplier");r(this,"limitZ");r(this,"limitZMultiplier");r(this,"multiplyDragByParticleSize",!1);r(this,"multiplyDragByParticleVelocity",!1);r(this,"space");r(this,"_temp",new y);r(this,"_temp2",new y)}apply(A,e,t,g,I,o,s){if(this.enabled){const n=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>n){this._temp.copy(e).normalize().multiplyScalar(n);const a=this.dampen*.5;e.x=se.lerp(e.x,this._temp.x,a),e.y=se.lerp(e.y,this._temp.y,a),e.z=se.lerp(e.z,this._temp.z,a),t.x=se.lerp(t.x,this._temp.x,a),t.y=se.lerp(t.y,this._temp.y,a),t.z=se.lerp(t.z,this._temp.z,a)}}}}sA([D()],Ig.prototype,"enabled",2);sA([D()],Ig.prototype,"dampen",2);sA([D(ce)],Ig.prototype,"drag",2);sA([D()],Ig.prototype,"dragMultiplier",2);sA([D(ce)],Ig.prototype,"limit",2);sA([D()],Ig.prototype,"limitMultiplier",2);sA([D()],Ig.prototype,"separateAxes",2);sA([D(ce)],Ig.prototype,"limitX",2);sA([D()],Ig.prototype,"limitXMultiplier",2);sA([D(ce)],Ig.prototype,"limitY",2);sA([D()],Ig.prototype,"limitYMultiplier",2);sA([D(ce)],Ig.prototype,"limitZ",2);sA([D()],Ig.prototype,"limitZMultiplier",2);sA([D()],Ig.prototype,"multiplyDragByParticleSize",2);sA([D()],Ig.prototype,"multiplyDragByParticleVelocity",2);sA([D()],Ig.prototype,"space",2);const JP=class{constructor(){r(this,"enabled");r(this,"curve");r(this,"curveMultiplier");r(this,"mode");r(this,"system");r(this,"_temp",new y);r(this,"_firstUpdate",!0);r(this,"_frames",0)}clone(){var A;const i=new JP;return i.enabled=this.enabled,i.curve=(A=this.curve)==null?void 0:A.clone(),i.curveMultiplier=this.curveMultiplier,i.mode=this.mode,i}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new y),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new y),this.system._iv_velocity}awake(i){this.system=i,this.reset()}reset(){this._firstUpdate=!0}update(i){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(i){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),i.add(this._temp)}}applyCurrent(i,A,e){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const t=this.curve.evaluate(A,e);this._temp.copy(this._velocity).multiplyScalar(t),i.add(this._temp)}}};let Sr=JP;sA([D()],Sr.prototype,"enabled",2);sA([D(ce)],Sr.prototype,"curve",2);sA([D()],Sr.prototype,"curveMultiplier",2);sA([D()],Sr.prototype,"mode",2);class xI{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e,t,g){const I=A.length(),o=se.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,t);return g*s}}sA([D()],xI.prototype,"enabled",2);sA([D(gA)],xI.prototype,"range",2);sA([D()],xI.prototype,"separateAxes",2);sA([D(ce)],xI.prototype,"size",2);sA([D()],xI.prototype,"sizeMultiplier",2);sA([D(ce)],xI.prototype,"x",2);sA([D()],xI.prototype,"xMultiplier",2);sA([D(ce)],xI.prototype,"y",2);sA([D()],xI.prototype,"yMultiplier",2);sA([D(ce)],xI.prototype,"z",2);sA([D()],xI.prototype,"zMultiplier",2);class aQ{constructor(){r(this,"enabled");r(this,"range");r(this,"color")}evaluate(A,e,t){const g=A.length(),I=se.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}}sA([D()],aQ.prototype,"enabled",2);sA([D(gA)],aQ.prototype,"range",2);sA([D(oo)],aQ.prototype,"color",2);const rsA={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
5412
|
+
`))}for(const w of G){const k=g.get(w);k&&R.set(w,k)}return R},Q=function(G){const R=B(G),w=s(R);return n(R,w,G)};const E=t.skinnedMesh.skeleton,c=new Array;for(const G in E.bones){const R=E.bones[G],w=E.boneInverses[G];c.push({bone:R,inverse:w})}for(const G of sP(E.bones))c.push({bone:G,inverse:G.matrixWorld.clone().invert()});const h=c[0].bone.parent;h||console.error("No bone parent found for skinned mesh during USDZ export",t.skinnedMesh),c.sort((G,R)=>qE(G.bone,h)>qE(R.bone,h)?1:-1);const u=[],l=[],d=[],p=[];for(const{bone:G}of c)u.push(G.matrix.clone()),l.push(G.position),d.push(G.quaternion),p.push(G.scale);const f=c.map(G=>'"'+qE(G.bone,h)+'"').join(", "),S=c.map(G=>fE(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${S}]`),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${u.map(G=>fE(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${fE(new GA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const m=Q(c.map(G=>G.bone));if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine(`quatf[] rotations = [${a(d)}]`),m&&m.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=o(m.quaternion);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`half3[] scales = [${C(p)}]`),m&&m.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=I(m.scale);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`float3[] translations = [${C(l)}]`),m&&m.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=I(m.position);for(const R of G)A.appendLine(R);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var n;if(!this.model)return;this.skinnedMeshExport(A,e);const t=this.object,g=this.dict.get(t);if(!g||t.isSkinnedMesh)return;tR&&console.log("SERIALIZE",this.model.name,this.object.type,g);const I=new GA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const o=new Array;let s=0;for(let C=0;C<g.length;C++)o.push(s),s+=g[C].getDuration()+ts.animationDurationPadding;for(let C=0;C<g.length;C++){const a=g[C];if(!a)continue;const B=o[C];{const Q=a.getSortedTimesArray();if(!Q||Q.length===0){console.error("got an animated object but no time values?",t,a);continue}if(LE){const E=((n=a.clip)==null?void 0:n.name)??"rest",c=a.getDuration();console.log("Write .timeSamples:",E,B,c,g),A.appendLine("# "+E+": start="+(B*a.frameRate).toFixed(3)+", length="+(c*a.frameRate).toFixed(3)+", frames="+a.getFrames())}for(const{time:E,translation:c,rotation:h,scale:u}of a.getValues(Q)){I.compose(c,h,u);const l=`${(B+E)*a.frameRate}: ${fE(I)},`;A.appendLine(l)}}}A.indent--,A.appendLine("}")}}var qIA=Object.defineProperty,LIA=Object.getOwnPropertyDescriptor,pP=(i,A,e,t)=>{for(var g=t>1?void 0:t?LIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&qIA(A,e,g),g};const Xq=oA("debugpost");class be{constructor(A){r(this,"_active",!0);r(this,"_value");r(this,"_valueRaw");r(this,"_defaultValue");r(this,"valueProcessor");r(this,"onValueChanged");this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;Xq&&console.log("VolumeParameter: value changed from",t,"to",A),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,t,this):Xq&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}pP([D()],be.prototype,"overrideState",1);pP([D()],be.prototype,"value",1);var xIA=Object.defineProperty,YIA=Object.getOwnPropertyDescriptor,TIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?YIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&xIA(A,e,g),g};const _IA=oA("debugpost");class lI extends NA{constructor(e=void 0){super();r(this,"active",!0);r(this,"_result");r(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const g=e[t],I=this[t];I instanceof be&&(I.value=g)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){_IA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const g=this[t];g instanceof be&&g.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const g=this.$serializedTypes;if(g){for(const I of Object.keys(g))if(g[I]===be){const s=e[I];if(s!==void 0){const n=this[I];n.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof be){const g=e.value;return this[t].value=g,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===be&&(this[t]||(this[t]=new be))}}TIA([D()],lI.prototype,"active",2);var HIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,PIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?OIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&HIA(A,e,g),g};const WIA=oA("debugpost"),iR={};function ls(i,A){iR[i]=A}function jIA(i){return i.__type in iR?iR[i.__type]:(WIA&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),lI)}class Su{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}PIA([Uc([i=>jIA(i),lI])],Su.prototype,"components",2);var VIA=Object.defineProperty,zIA=Object.getOwnPropertyDescriptor,ZIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?zIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VIA(A,e,g),g};class mu extends lI{constructor(){super(...arguments);r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new jX({preset:oE.HIGH,edgeDetectionMode:NU.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}ZIA([D(be)],mu.prototype,"preset",2);ls("Antialiasing",mu);class mS{constructor(){r(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,t){const g=BA.getComponents(A,Ki);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,n)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t=e.split("/").pop(),o=await(await(await fetch(e)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files["audio/"+t]=s}}}const fB=oA("debugautosync"),pk=Symbol("syncerId");class XIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new $IA(A);return e[pk]=A.guid,this._syncers[e[pk]]=e,e}removeSyncer(A){delete this._syncers[A[pk]]}}const tF=new XIA;class $IA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_boundEvent");r(this,"_handleReceivingMethod");r(this,"_isReceiving",!1);r(this,"_isInit",!1);this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(fB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(fB&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){fB&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const g=A[t];this.comp[t]=g,fB&&console.log("SET",t,g)}}catch(t){console.error(t)}finally{this._isReceiving=!1}}}}function AoA(i,A){let e=A!==i;return!e&&i&&A&&(Array.isArray(i)&&Array.isArray(A)||typeof i=="object"&&typeof A=="object")&&(e=!0),e}const ml=Symbol("AutoSyncHandler");function eoA(i){if(i[ml])return i[ml];const A=tF.getOrCreateSyncer(i);return A==null||A.init(i),i[ml]=A,A}function toA(i){const A=i[ml];A&&(tF.removeSyncer(A),A.destroy(),delete i[ml])}const iF=function(i){return function(A,e){var a;let t="";typeof e=="string"?t=e:t=e.name;let g=null,I;typeof i=="string"?I=A[i]:typeof i=="function"&&(I=i);const o=A,s=o.__internalAwake;if(typeof s!="function"){(fB||Ge())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((a=A==null?void 0:A.constructor)==null?void 0:a.name)+'" is not supported',A);return}fB&&console.log(t);const n=Symbol(t);o.__internalAwake=function(){if(this[n]!==void 0)return;this[n]=this[t],g=tF.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,t);if((B==null?void 0:B.set)===void 0){let Q=!1;Object.defineProperty(this,t,{set:function(E){var h;const c=this[n];if(this[n]=E,Q){Ge()&&console.warn("Recursive call detected",t);return}Q=!0;try{const u=AoA(E,c);fB&&console.log("SyncField assignment",t,"changed?",u,E),u&&(I==null?void 0:I.call(this,E,c))!==!1&&((h=eoA(this))==null||h.notifyChanged(t,E))}finally{Q=!1}},get:function(){return this[n]},configurable:!0,enumerable:!0})}g==null||g.init(this),s.call(this)};const C=o.__internalDestroy;o.__internalDestroy=function(){toA(this),C.call(this)}}};var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,kS=(i,A,e,t)=>{for(var g=t>1?void 0:t?goA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ioA(A,e,g),g};const zo=oA("debugplayersync");class vc extends NA{constructor(){super(...arguments);r(this,"autoSync",!0);r(this,"asset");r(this,"onPlayerSpawned");r(this,"_localInstance");r(this,"onJoinedRoom",()=>{zo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new kg)}onEnable(){this.context.connection.beginListen(dt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(dt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom)}async getInstance(){var t,g,I,o,s,n;if(this._localInstance)return this._localInstance;if(zo&&console.log("PlayerSync.createInstance",(t=this.asset)==null?void 0:t.uri),!((g=this.asset)!=null&&g.asset)&&!((I=this.asset)!=null&&I.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const e=await this._localInstance;if(e){const C=BA.getComponent(e,gs);C?(C.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(e)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((n=this.asset)==null?void 0:n.uri)+"</strong>: please make sure the asset has a PlayerState component!"),BA.destroySynced(e))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(zo&&console.log("PlayerSync.destroyInstance",t),BA.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=gs.all.length-1;t>=0;t--){const g=gs.all[t];(!g.owner||!this.context.connection.userIsInRoom(g.owner))&&g.doDestroy()}})}}kS([D()],vc.prototype,"autoSync",2);kS([D(It)],vc.prototype,"asset",2);kS([D(kg)],vc.prototype,"onPlayerSpawned",2);var fP=(i=>(i.OwnerChanged="ownerChanged",i))(fP||{}),Th;const bg=(Th=class extends NA{constructor(){super(...arguments);r(this,"onOwnerChangeEvent",new kg);r(this,"onFirstOwnerChangeEvent",new kg);r(this,"hasOwner",!1);r(this,"owner");r(this,"dontDestroy",!1);r(this,"onUserLeftRoom",A=>{if(A.userId===this.owner){zo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return bg._all}static get local(){return bg._local}static getFor(A){if(A instanceof pA)return BA.getComponentInParent(A,bg);if(A instanceof NA)return BA.getComponentInParent(A.gameObject,bg)}static isLocalPlayer(A){const e=bg.getFor(A);return(e==null?void 0:e.isLocalPlayer)??!1}static addEventListener(A,e){return this._callbacks[A]||(this._callbacks[A]=[]),this._callbacks[A].push(e),e}static removeEventListener(A,e){if(!this._callbacks[A])return;const t=this._callbacks[A].indexOf(e);t>=0&&this._callbacks[A].splice(t,1)}static dispatchEvent(A,e){if(this._callbacks[A])for(const t of this._callbacks[A])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(A,e){var o,s;zo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",A,"oldOwner",e);const t=bg._local.indexOf(this);t>=0&&bg._local.splice(t,1);const g={playerState:this,oldValue:e,newValue:A};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(g)),(s=this.onOwnerChangeEvent)==null||s.invoke(g),this.owner===this.context.connection.connectionId){bg._local.push(this);const n=new CustomEvent("local-owner-changed",{detail:g});this.dispatchEvent(n)}const I=new CustomEvent("owner-changed",{detail:g});this.dispatchEvent(I),bg.dispatchEvent("ownerChanged",I)}awake(){bg.all.push(this),zo&&console.log("Registered new PlayerState",this.guid,bg.all.length-1,bg.all),this.context.connection.beginListen(dt.UserLeftRoom,this.onUserLeftRoom)}async start(){zo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await os(300),this.context.connection.userIsInRoom(this.owner)==!1&&(zo&&console.log(`PlayerSync.start โ doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(zo&&console.warn("PlayerState.start โ owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?zo&&console.warn("PlayerState.start โ owner is still undefined but dontDestroy is set to true",this.name):(zo&&console.warn(`PlayerState.start โ owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):console.log("PlayerState.start โ owner is assigned",this.owner)},2e3))}doDestroy(){zo&&console.log("PlayerSync.doDestroy โ syncDestroy",this.name),CS(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(dt.UserLeftRoom,this.onUserLeftRoom),bg.all.splice(bg.all.indexOf(this),1),this.isLocalPlayer){const A=bg._local.indexOf(this);A>=0&&bg._local.splice(A,1)}}},r(Th,"_all",[]),r(Th,"_local",[]),r(Th,"_callbacks",{}),Th);let gs=bg;kS([iF(gs.prototype.onOwnerChange)],gs.prototype,"owner",2);const IoA=oA("debugavatar"),Ms=class extends NA{constructor(){super(...arguments);r(this,"connectionId");r(this,"avatar")}static getAvatar(e){return e>=0&&e<Ms.instances.length?Ms.instances[e]:null}static onAvatarMarkerCreated(e){return Ms._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return Ms._onAvatarMarkerDestroyed.push(e),e}awake(){Ms.instances.push(this),IoA&&console.log(this);for(const e of Ms._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Ms.instances.splice(Ms.instances.indexOf(this),1);for(const e of Ms._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ag=Ms;r(ag,"instances",[]),r(ag,"_onNewAvatarMarkerAdded",[]),r(ag,"_onAvatarMarkerDestroyed",[]);var ooA=Object.defineProperty,soA=Object.getOwnPropertyDescriptor,noA=(i,A,e,t)=>{for(var g=t>1?void 0:t?soA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ooA(A,e,g),g};const rE=oA("debugxrflags"),DP=oA("disablexrflags");DP&&console.warn("XRFlags are disabled");var ln=(i=>(i[i.Never=0]="Never",i[i.Browser=1]="Browser",i[i.AR=2]="AR",i[i.VR=4]="VR",i[i.FirstPerson=8]="FirstPerson",i[i.ThirdPerson=16]="ThirdPerson",i[i.All=4294967295]="All",i))(ln||{});const YK=class{constructor(){r(this,"Mask",17)}Has(A){return(this.Mask&A)!==0}Set(A){rE&&console.warn("Set XR flag state to",A),this.Mask=A,po.Apply()}Enable(A){this.Mask|=A,po.Apply()}Disable(A){this.Mask&=~A,po.Apply()}Toggle(A){this.Mask^=A,po.Apply()}EnableAll(){this.Mask=-1,po.Apply()}DisableAll(){this.Mask=0,po.Apply()}};let Tg=YK;r(Tg,"Global",new YK);var _h;const rC=(_h=class extends NA{constructor(){super(...arguments);r(this,"visibleIn")}static Apply(){for(const A of this.registry)A.UpdateVisible(Tg.Global)}awake(){rC.registry.push(this)}onEnable(){rC.firstApply?this.UpdateVisible(Tg.Global):(rC.firstApply=!0,rC.Apply())}onDestroy(){const A=rC.registry.indexOf(this);A>=0&&rC.registry.splice(A,1)}get isOn(){return this.gameObject.visible}UpdateVisible(A=null){if(DP)return;let e;const t=A;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),rE&&console.log(t),rC.buffer.Mask=t,A=rC.buffer),A instanceof Tg?(rE&&console.warn(this.name,"use passed in mask",A.Mask,this.visibleIn),e=A.Has(this.visibleIn)):(rE&&console.log(this.name,"use global mask"),Tg.Global.Has(this.visibleIn)),e!==void 0)if(e)rE&&console.log(this.name,"is visible",this.gameObject.uuid),BA.setActive(this.gameObject,!0);else{if(rE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},r(_h,"registry",[]),r(_h,"firstApply"),r(_h,"buffer",new Tg),_h);let po=rC;noA([D()],po.prototype,"visibleIn",2);var CoA=Object.defineProperty,aoA=Object.getOwnPropertyDescriptor,gF=(i,A,e,t)=>{for(var g=t>1?void 0:t?aoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CoA(A,e,g),g};const Uh=oA("debugwebxr"),$q=new RA().setFromAxisAngle(new y(0,1,0),Math.PI);class AQ extends NA{constructor(){super(...arguments);r(this,"head");r(this,"leftHand");r(this,"rightHand");r(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Uh&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=gs.getFor(this);if(t!=null&&t.owner){const g=this.gameObject.addNewComponent(ag);g.avatar=this.gameObject,g.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(ag);t&&t.destroy()}onUpdateXR(e){var n,C;if(!this.activeAndEnabled)return;const t=gs.isLocalPlayer(this);if(!t)return;const g=e.xr;if(g.rig&&g.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),g.rig.gameObject.add(this.gameObject)),this._syncTransforms&&t)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const B=BA.getComponentsInChildren(this.head.asset,po);for(const Q of B)Q.enabled=!1,Q.gameObject.visible=!1}}const I=e.xr.leftController,o=(n=this.leftHand)==null?void 0:n.asset;I&&o&&(o.position.copy(I.gripPosition),o.quaternion.copy(I.gripQuaternion),o.quaternion.multiply($q),o.visible=I.isTracking);const s=e.xr.rightController;if(s&&((C=this.rightHand)!=null&&C.asset)){const a=this.rightHand.asset;a.position.copy(s.gripPosition),a.quaternion.copy(s.gripQuaternion),a.quaternion.multiply($q),a.visible=s.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,g;if(this.context.connection.isConnected){const I=gs.getFor(this);if(I&&I.isLocalPlayer==!1){const o=pe.getXRSync(this.context);if(o&&o.hasState(I.owner)){this.tryFindAvatarObjectsIfMissing();const s=(e=this.leftHand)==null?void 0:e.asset;s&&(s.visible=(o==null?void 0:o.isTracking(I.owner,"left"))??!1);const n=(t=this.rightHand)==null?void 0:t.asset;n&&(n.visible=(o==null?void 0:o.isTracking(I.owner,"right"))??!1)}if((g=this.head)!=null&&g.asset){const s=BA.getComponentsInChildren(this.head.asset,po);for(const n of s)n.enabled=!1,n.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};iO.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof pA&&(this.head=new It("",this.sourceId,this.head));else{const e=new pA;e.name="Head";const t=ec.createPrimitive(_B.Cube);e.add(t),this.gameObject.add(e),this.head=new It("",this.sourceId,e),Uh&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof pA&&(this.rightHand=new It("",this.sourceId,this.rightHand));else{const e=new pA;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new It("",this.sourceId,e),Uh&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof pA&&(this.leftHand=new It("",this.sourceId,this.leftHand));else{const e=new pA;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new It("",this.sourceId,e),Uh&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),gs.isLocalPlayer(this.gameObject)&&(this._syncTransforms=BA.getComponentsInChildren(this.gameObject,sr))}async loadAvatarObjects(e,t,g){const I=e.loadAssetAsync(),o=t.loadAssetAsync(),s=g.loadAssetAsync(),n=new Array;I&&n.push(I),o&&n.push(o),s&&n.push(s);const C=await zd(n);Uh&&console.log("Avatar loaded results:",C)}}gF([D(It)],AQ.prototype,"head",2);gF([D(It)],AQ.prototype,"leftHand",2);gF([D(It)],AQ.prototype,"rightHand",2);class Nn{static Add(A,e,t=null){if(e){for(const g of this.Pois)if(g.obj===e)return;this.Pois.push({obj:e,avatar:t}),this.LastChangeTime=A.time.time}}static Remove(A,e){var t;if(e){for(const g of this.Pois)if(g.obj===e){this.Pois.splice(this.Pois.indexOf(g),1),this.LastChangeTime=(A==null?void 0:A.time.time)??((t=ve.Current)==null?void 0:t.time.time);return}}}}r(Nn,"Pois",[]),r(Nn,"LastChangeTime",0);class roA{constructor(){r(this,"guid");r(this,"position",new y)}}class ud extends NA{constructor(){super(...arguments);r(this,"target",null);r(this,"avatar",null);r(this,"_model",null);r(this,"_targetModel",new roA);r(this,"_currentTargetObject",null);r(this,"_lastUpdateTime",0);r(this,"_lookDuration",0);r(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=AA.get("MoveRandom");if(t&&this.target){const g=BA.getComponent(this.target,t);g&&g.destroy()}}awake(){if(this.avatar=BA.getComponentInParent(this.gameObject,ag),this.avatar){const e=BA.getComponentInParent(this.gameObject,ag);this._model=new XU(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&QI(this.target,e.position)})}update(){var t;if((!this.context.connection.isConnected||(t=this._model)!=null&&t.hasOwnership)&&(Nn.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Nn.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const g=Je(this._currentTargetObject);QI(this.target,g),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(g))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const t=Nn.Pois;if(t.length>0){const g=t[Math.floor(Math.random()*t.length)];if(g&&g.obj){if(g.avatar&&g.avatar===this.avatar)return;this._currentTargetObject=g.obj}}}}}const wE=oA("debugnetworkingstreams");var mn=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(mn||{});class yP{constructor(A,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=A,this.direction=e}}class wP{constructor(A,e){r(this,"type","receive-stream");r(this,"stream");r(this,"target");this.stream=A,this.target=e}}class BoA{constructor(A,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var SP=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(SP||{});class QoA extends Rg{constructor(e,t,g){super();r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.userId=e,this.call=t,this.direction=g,this._stream=null,t.on("stream",I=>{if(wE&&console.log("Receive video",I.getAudioTracks(),I.getVideoTracks()),this._stream=I,g==="incoming"){const o=new wP(I,this);this.dispatchEvent(o)}}),t.on("close",()=>{this.dispatchEvent(new yP(e,g))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),GC(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const ME=class extends Rg{constructor(e,t){super();r(this,"id");r(this,"context");r(this,"_peer");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnectFn",this.onPeerConnect.bind(this));r(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if(ME.instances.has(t))return ME.instances.get(t);const g=new ME(e,t);return ME.instances.set(t,g),g}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var o;const g={metadata:{userId:this.context.connection.connectionId}},I=(o=this._peer)==null?void 0:o.call(e,t,g);if(I)return this.registerCall(I,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(dt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(dt.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const e=this.getMyPeerId();e?this._peer=mH(e):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(e){wE&&console.log("Peer connected as",e),this.context.connection.send("peer-user-connected",new BoA(this,e))}onPeerReceivingCall(e){e.answer(),this.registerCall(e,"incoming")}registerCall(e,t){const g=e.metadata;(!g||!g.userId)&&console.error("Missing call metadata",e);const I=g.userId;t==="incoming"&&wE?console.log("Receive call from",e.metadata):wE&&console.log("Make call to",e.metadata);const o=t==="incoming"?this._incomingCalls:this._outgoingCalls,s=new QoA(I,e,t);return o.push(s),e.on("error",n=>{console.error("Call error",n)}),e.on("close",()=>{wE&&console.log("Call ended",e.metadata),e.close();const n=o.indexOf(s);n!==-1&&o.splice(n,1)}),s.addEventListener("call-ended",n=>{this.dispatchEvent(n)}),t==="incoming"&&(s.addEventListener("receive-stream",n=>{this.dispatchEvent(n)}),e.on("stream",()=>{let n=0;const C=setInterval(()=>{const a=n===0;!s.isOpen&&a&&(n+=1,clearInterval(C),s.close())},2e3)})),s}};let xE=ME;r(xE,"instances",new Map);class ku extends Rg{constructor(e,t){super();r(this,"context");r(this,"peer");r(this,"_sendingStreams",new Map);r(this,"debug",!1);r(this,"onJoinedRoom",e=>{this.debug&&console.log(`${e.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});r(this,"onReceiveStream",e=>{this.debug&&console.log("RECEIVE STREAM",e),this.dispatchEvent({type:"receive-stream",target:this,stream:e.stream,userId:e.userId})});r(this,"onCallEnded",e=>{this.dispatchEvent(e)});r(this,"onUserConnected",e=>{if(this.peer.id===e.guid){this.debug&&console.log("USER CONNECTED",e.guid,e);const t=this._sendingStreams.keys().next().value;this.peer.makeCall(e.peerId,t)}});r(this,"onUserLeft",e=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=e,this.peer=t,wE&&(this.debug=!0)}static create(e){const t=xE.getOrCreate(e.context,e.context.connection.connectionId);return new ku(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const g of t)g.close()}this._sendingStreams.delete(e),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(dt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(dt.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(dt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(dt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var g;let e=!1;const t=this.context.connection.connectionId;for(const I of this._sendingStreams.keys()){const o=this._sendingStreams.get(I)||[];for(const s of this.context.connection.usersInRoom()){if(s===t)continue;const n=o.find(C=>C.userId===s);if(!n||((g=n.stream)==null?void 0:g.active)===!1){this.debug&&console.log("Starting call to",s,t);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(s),I);C&&(e=!0,o.push(C))}}this._sendingStreams.set(I,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let g=t.length-1;g>=0;g--){const I=t[g];this.context.connection.userIsInRoom(I.userId)||(I.close(),t.splice(g,1))}}}}function GC(i){if(i&&i instanceof MediaStream)for(const A of i.getTracks())A.stop()}var EoA=Object.defineProperty,coA=Object.getOwnPropertyDescriptor,mP=(i,A,e,t)=>{for(var g=t>1?void 0:t?coA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&EoA(A,e,g),g};const hoA="noVoip",loA=oA("debugvoip");class eQ extends NA{constructor(){super(...arguments);r(this,"autoConnect",!1);r(this,"runInBackground",!0);r(this,"debug",!1);r(this,"_net");r(this,"_outputStream",null);r(this,"onJoinedRoom",async()=>{await os(300),this.autoConnect&&!this.isSending&&this.connect()});r(this,"_incomingStreams",new Map);r(this,"onReceiveStream",e=>{const t=e.target.userId,g=e.stream,I=this._incomingStreams.get(t);if(I)I.srcObject=g,I.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(t,o),o.setAttribute("autoplay","true"),o.srcObject=g}});r(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);GC(t==null?void 0:t.srcObject),this._incomingStreams.delete(e.userId)});r(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}});r(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const t=!(document.visibilityState==="visible");this.setMuted(t);for(const g of this._incomingStreams){const I=g[1];I.muted=t}})}awake(){loA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=ku.create(this)),this._net.addEventListener(mn.StreamReceived,this.onReceiveStream),this._net.addEventListener(mn.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(dt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(mn.StreamReceived,this.onReceiveStream),this._net.removeEventListener(mn.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(dt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await WG())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),GC(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await WG()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):vT("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),GC(this._outputStream),this._outputStream=null}setMuted(e){var g;const t=(g=this._outputStream)==null?void 0:g.getAudioTracks();if(t)for(const I of t)I.enabled=!e}get isMuted(){var t;if(this._outputStream===null)return!1;const e=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(e){for(const g of e)if(!g.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,Ge()&&fi("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(g=>(console.warn("VOIP failed getting audio stream",g),null)):(console.error("No getDisplayMedia support"),null)}}mP([D()],eQ.prototype,"autoConnect",2);mP([D()],eQ.prototype,"runInBackground",2);var doA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,kP=(i,A,e,t)=>{for(var g=t>1?void 0:t?uoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&doA(A,e,g),g};const poA=oA("debugmouth");class Gu extends NA{constructor(){super(...arguments);r(this,"idle",[]);r(this,"talking",[]);r(this,"marker",null);r(this,"voip",null);r(this,"lastMouthChangeTime",0);r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=BA.findObjectOfType(eQ,this.context),this.marker||(this.marker=BA.getComponentInParent(this.gameObject,ag))},3e3)}update(){var g;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((g=this.marker)==null?void 0:g.connectionId)??null;if(!e){poA&&(e=null);return}const t=this.voip.getFrequency(e)??0;this.updateLips(t)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(g=>g.visible=!1):this.talking.map(g=>g.visible=!1);for(let g=0;g<e.length;g++){const I=e[g];I&&(I.visible=g===t)}}}}kP([D(pA)],Gu.prototype,"idle",2);kP([D(pA)],Gu.prototype,"talking",2);class IF extends NA{constructor(){super(...arguments);r(this,"voip",null);r(this,"marker",null);r(this,"_startPosition",null)}awake(){this.voip=BA.findObjectOfType(eQ,this.context),this.marker=BA.getComponentInParent(this.gameObject,ag)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const g=t/100;this.gameObject.position.y=this._startPosition.y+g*.07}}var foA=Object.defineProperty,DoA=Object.getOwnPropertyDescriptor,GS=(i,A,e,t)=>{for(var g=t>1?void 0:t?DoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&foA(A,e,g),g};class tQ extends NA{constructor(){super(...arguments);r(this,"eyes",[]);r(this,"lastBlinkTime",0);r(this,"blinkLength",0);r(this,"eyesOpen",!0);r(this,"state",null)}awake(){this.state=BA.getComponentInParent(this.gameObject,po)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const t of this.eyes)t&&(t.visible=this.eyesOpen)}}}GS([D(pA)],tQ.prototype,"eyes",2);GS([D()],tQ.prototype,"lastBlinkTime",2);GS([D()],tQ.prototype,"blinkLength",2);GS([D()],tQ.prototype,"eyesOpen",2);var yoA=Object.defineProperty,woA=Object.getOwnPropertyDescriptor,oF=(i,A,e,t)=>{for(var g=t>1?void 0:t?woA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&yoA(A,e,g),g},tG;const GP=(tG=class extends NA{constructor(){super(...arguments);r(this,"head",null);r(this,"eyes",null);r(this,"target",null);r(this,"brain",null);r(this,"vec",new y);r(this,"currentTargetPoint",new y)}awake(){this.brain||(this.brain=BA.getComponentInParent(this.gameObject,ud)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=BA.addNewComponent(this.gameObject,ud)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const A=this.target;if(A&&this.head){const e=this.eyes;if(e){const t=Je(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const g=Je(this.head),I=this.vec.copy(this.currentTargetPoint).sub(g).normalize();if(I.length()<.1)return;const o=GP.forward;if(o.set(0,0,1),o.applyQuaternion(qt(this.head)),o.dot(I)>.45)for(let n=0;n<e.length;n++)e[n].lookAt(this.currentTargetPoint)}}}},r(tG,"forward",new y(0,0,1)),tG);let bc=GP;oF([D(pA)],bc.prototype,"head",2);oF([D(pA)],bc.prototype,"eyes",2);oF([D(pA)],bc.prototype,"target",2);const Nh=oA("debugavatar");class MS{constructor(A,e,t,g){r(this,"root");r(this,"head");r(this,"leftHand");r(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=t,this.rigthHand=g,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class sF{constructor(){r(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let t=null;if(typeof e=="string"){if(t=await this.loadAvatar(A,e),!t){const I=new Vs;t=BA.instantiate(VE(e,A.scene),I)}}else t=e;if(!t)return null;const g=this.findAvatar(t);return g.isValid?(Nh&&console.log("[Custom Avatar] valid config",e,Nh?g:""),g):(console.warn("[Custom Avatar] config isn't valid",e,Nh?g:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(Nh&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const g=await fetch("./"+e);let I=null;if(g.ok){const s=await g.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await LU(e,e,0,"no url here go away",!0),!I))return null;const o=await Ys().parseSync(A,I,null,0);return(o==null?void 0:o.scene)??null}const t=new Rc;return cu(t,A),new Promise((g,I)=>{const o=this.avatarRegistryUrl+"/"+e;t.load(o,async s=>{await Ys().createBuiltinComponents(A,o,s,null,void 0),g(s.scene)},s=>{Nh&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),g(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let t=e;t.children.length==1&&(t=A.children[0]);let g=this.findAvatarPart(t,["head"]);const I=this.findAvatarPart(t,["left","hand"]),o=this.findAvatarPart(t,["right","hand"]);if(!g){g=e;const n=new y;new Lt().setFromObject(g).getSize(n);const C=Math.max(n.x,n.y,n.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&g.scale.multiplyScalar(1/C*.3)}return new MS(e,g,I,o)}findAvatarPart(A,e){const t=A.name.toLowerCase();let g=!0;for(const I of e){if(!g)break;t.indexOf(I)===-1&&(g=!1)}if(g)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var SoA=Object.defineProperty,moA=Object.getOwnPropertyDescriptor,nF=(i,A,e,t)=>{for(var g=t>1?void 0:t?moA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&SoA(A,e,g),g};class qc extends NA{constructor(){super(...arguments);r(this,"length",1);r(this,"depthTest",!0);r(this,"isGizmo",!0);r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!$d)return;this._axes||(this._axes=new Cs(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}nF([D()],qc.prototype,"length",2);nF([D()],qc.prototype,"depthTest",2);nF([D()],qc.prototype,"isGizmo",2);class CF extends NA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"hint");r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=Je(this.to).clone(),t=Je(this.from).clone(),g=e.distanceTo(t),I=e.clone();I.sub(t);const o=t.clone();o.add(e),o.multiplyScalar(.5);const s=Je(this.hint).clone();s.sub(o);const n=new y;n.crossVectors(s,I),n.crossVectors(I,n),n.normalize();const C=g*.5,a=Math.max(this.desiredDistance,C),B=Math.sqrt(a*a-C*C),Q=n.clone();Q.multiplyScalar(B),Q.add(o),QI(this.gameObject,Q);const E=o.clone();E.sub(n),this.gameObject.lookAt(E)}}const koA=oA("debugusdz");class RS{constructor(){r(this,"behaviours",[]);r(this,"behaviourComponents",[]);r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{BA.foreachComponent(t,g=>{var o;const I=g;if(typeof I.createBehaviours=="function"||typeof I.beforeCreateDocument=="function"||typeof I.afterCreateDocument=="function"||typeof I.afterSerialize=="function"){this.behaviourComponents.push(I);const s=(o=I.beforeCreateDocument)==null?void 0:o.call(I,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,t){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,t)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var t;if((t=this.behaviours)!=null&&t.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){koA&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var GoA=Object.defineProperty,MoA=Object.getOwnPropertyDescriptor,aF=(i,A,e,t)=>{for(var g=t>1?void 0:t?MoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&GoA(A,e,g),g};class iQ extends lI{constructor(){super(...arguments);r(this,"threshold");r(this,"intensity");r(this,"scatter");r(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new B_(this.context.scene,this.context.mainCamera,{blendFunction:je.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new vU;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}aF([D(be)],iQ.prototype,"threshold",2);aF([D(be)],iQ.prototype,"intensity",2);aF([D(be)],iQ.prototype,"scatter",2);ls("Bloom",iQ);var RoA=Object.defineProperty,UoA=Object.getOwnPropertyDescriptor,Io=(i,A,e,t)=>{for(var g=t>1?void 0:t?UoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RoA(A,e,g),g};class ds extends NA{constructor(){super(...arguments);r(this,"attachedRigidbody",null);r(this,"isTrigger",!1);r(this,"sharedMaterial");r(this,"membership",[0]);r(this,"filter");r(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ei))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Io([D(ei)],ds.prototype,"attachedRigidbody",2);Io([D()],ds.prototype,"isTrigger",2);Io([D()],ds.prototype,"sharedMaterial",2);Io([D()],ds.prototype,"membership",2);Io([D()],ds.prototype,"filter",2);class Mu extends ds{constructor(){super(...arguments);r(this,"radius",.5);r(this,"center",new y(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),Tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),wU(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([$g(),D()],Mu.prototype,"radius",2);Io([D(y)],Mu.prototype,"center",2);class Ru extends ds{constructor(){super(...arguments);r(this,"size",new y(1,1,1));r(this,"center",new y(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size),Tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),wU(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([$g(),D(y)],Ru.prototype,"size",2);Io([D(y)],Ru.prototype,"center",2);class Lc extends ds{constructor(){super(...arguments);r(this,"sharedMesh");r(this,"convex",!1)}onEnable(){var e,t,g,I,o;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof uA&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(g=this.context.physics.engine)==null||g.addMeshCollider(this,this.sharedMesh,this.convex,li(this.gameObject));else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${((I=this.sharedMesh)==null?void 0:I.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const n in s.children){const C=s.children[n];C.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,C,this.convex,li(this.gameObject)))}}}}}Io([D()],Lc.prototype,"sharedMesh",2);Io([D()],Lc.prototype,"convex",2);class nr extends ds{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Io([D(y)],nr.prototype,"center",2);Io([D()],nr.prototype,"radius",2);Io([D()],nr.prototype,"height",2);var NoA=Object.defineProperty,FoA=Object.getOwnPropertyDescriptor,rF=(i,A,e,t)=>{for(var g=t>1?void 0:t?FoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&NoA(A,e,g),g};class gQ extends NA{constructor(){super(...arguments);r(this,"objectBounds",!1);r(this,"color");r(this,"isGizmo",!0);r(this,"_gizmoObject",null);r(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!$d||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new fU(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=LN(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),eg.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var e;for(;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}rF([D()],gQ.prototype,"objectBounds",2);rF([D(yA)],gQ.prototype,"color",2);rF([D()],gQ.prototype,"isGizmo",2);class KoA extends Z2{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const t in e)for(const g in e[t])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(t);for(const t of A._components)A._simpleState__statesProperties[t.id]&&(A._simpleState__normalStyles[t.id]=t.inline?t.inline:t._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const t=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],t.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)t.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const t in A)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=A[t]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var JoA=Object.defineProperty,voA=Object.getOwnPropertyDescriptor,MP=(i,A,e,t)=>{for(var g=t>1?void 0:t?voA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JoA(A,e,g),g};class xc extends NA{constructor(){super(...arguments);r(this,"effectColor");r(this,"effectDistance")}}MP([D(Kt)],xc.prototype,"effectColor",2);MP([D(gA)],xc.prototype,"effectDistance",2);var boA=Object.defineProperty,qoA=Object.getOwnPropertyDescriptor,Uu=(i,A,e,t)=>{for(var g=t>1?void 0:t?qoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&boA(A,e,g),g};const fk=oA("debugui"),Dk=oA("debuguilayout");class BF{constructor(){r(this,"width");r(this,"height")}}class QF{constructor(){r(this,"x");r(this,"y");r(this,"width");r(this,"height")}}const Ss=new y,Fh=new GA,Sf=new RA,RP=class extends _s{constructor(){super(...arguments);r(this,"_anchoredPosition");r(this,"sizeDelta",new gA(100,100));r(this,"pivot",new gA(.5,.5));r(this,"anchorMin",new gA(0,0));r(this,"anchorMax",new gA(1,1));r(this,"minWidth");r(this,"minHeight");r(this,"lastMatrix");r(this,"rectBlock");r(this,"_transformNeedsUpdate",!1);r(this,"_initialPosition");r(this,"_parentRectTransform");r(this,"_lastUpdateFrame",-1);r(this,"_lastAnchoring");r(this,"_createdBlocks",[]);r(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new gA),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){let A=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;A=e*t,A+=this.sizeDelta.x}return this.minWidth!==void 0&&A<this.minWidth?this.minWidth:A}get height(){let A=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;A=e*t,A+=this.sizeDelta.y}return this.minHeight!==void 0&&A<this.minHeight?this.minHeight:A}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new gA),this.lastMatrix=new GA,this.rectBlock=new pA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,aE(this,"_anchoredPosition",()=>{this.markDirty()}),aE(this,"sizeDelta",()=>{this.markDirty()}),aE(this,"pivot",()=>{this.markDirty()}),aE(this,"anchorMin",()=>{this.markDirty()}),aE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var A;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(A=this.Canvas)==null||A.registerTransform(this)}onDisable(){var A;super.onDisable(),this.removeShadowComponent(),(A=this.Canvas)==null||A.unregisterTransform(this)}onParentRectTransformChanged(A){this._transformNeedsUpdate||this.onApplyTransform(Dk?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(Dk&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(A){var g;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=BA.getComponentInParent(this.gameObject.parent,RP):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,Dk&&console.warn("RectTransform โ ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Ss.set(0,0,0),this.applyPivot(Ss),e.matrix.setPosition(Ss.x,Ss.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Sf.copy(this.gameObject.quaternion),Sf.x*=-1,Sf.z*=-1,Fh.makeRotationFromQuaternion(Sf),e.matrix.premultiply(Fh)),Ss.set(0,0,0),this.applyAnchoring(Ss),(g=this.Canvas)!=null&&g.screenspace?Ss.z+=.1:Ss.z+=.01,Fh.identity(),Fh.setPosition(Ss.x,Ss.y,Ss.z),e.matrix.premultiply(Fh),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of YN(this.gameObject,_s,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new gA);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),A.x+=this._initialPosition.x-this.gameObject.position.x,A.y+=this._initialPosition.y-this.gameObject.position.y,A.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let g=0;const I=1-this.anchorMax.y-this.anchorMin.y;g-=t.height*.5*I,A.y+=g;let o=0;const s=1-this.anchorMax.x-this.anchorMin.x;o-=t.width*.5*s,A.x+=o}}applyPivot(A){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;A.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;A.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const A={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}createNewBlock(A){A={...this.getBasicOptions(),...A},fk&&console.log(this.name,A);const e=new MN(A);return this._createdBlocks.push(e),e}createNewText(A){fk&&console.log(A),A={...this.getBasicOptions(),...A},fk&&console.log(this.name,A);const e=new RN(A);return this._createdTextBlocks.push(e),e}};let qI=RP;Uu([D(gA)],qI.prototype,"anchoredPosition",1);Uu([D(gA)],qI.prototype,"sizeDelta",2);Uu([D(gA)],qI.prototype,"pivot",2);Uu([D(gA)],qI.prototype,"anchorMin",2);Uu([D(gA)],qI.prototype,"anchorMax",2);var LoA=Object.defineProperty,xoA=Object.getOwnPropertyDescriptor,UP=(i,A,e,t)=>{for(var g=t>1?void 0:t?xoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&LoA(A,e,g),g};const mf={backgroundColor:new yA(1,1,1),backgroundOpacity:1,borderColor:new yA(1,1,1),borderOpacity:1};var iG;const MD=(iG=class extends _s{constructor(){super(...arguments);r(this,"_alphaFactor",1);r(this,"sRGBColor",new yA(1,0,1));r(this,"raycastTarget",!0);r(this,"uiObject",null);r(this,"_color",null);r(this,"_rect",null);r(this,"_stateManager",null);r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Kt(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new Kt(1,1,1,1)),this._color.copy(A),this.onColorChanged())}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),mf.backgroundColor=this.sRGBColor,mf.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(mf,this._alphaFactor),this.uiObject.set(mf),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=BA.getComponent(this.gameObject,qI)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var A;(A=this.uiObject)==null||A.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new KoA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),aE(this,"_color",()=>hIA(this,this.onColorChanged))}onEnable(){var A;super.onEnable(),this.uiObject&&((A=this.rectTransform.shadowComponent)==null||A.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const A=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:A};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var g;const t=(g=this.gameObject)==null?void 0:g.getComponent(xc);t&&(t.effectDistance&&(A.borderWidth=Math.max(Math.abs(t.effectDistance.x),Math.abs(t.effectDistance.y))),t.effectColor&&(A.borderColor=t.effectColor,A.borderOpacity=t.effectColor.alpha*e))}async setTexture(A){if(this.setOptions({backgroundOpacity:0}),A){if(MD.textureCache.has(A))A=MD.textureCache.get(A);else if(!A.isRenderTargetTexture){const e=A.clone();e.colorSpace=xt,MD.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},r(iG,"textureCache",new Map),iG);let IQ=MD;UP([D(Kt)],IQ.prototype,"color",1);UP([D()],IQ.prototype,"raycastTarget",2);class Nu extends IQ{constructor(){super(...arguments);r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var YoA=Object.defineProperty,ToA=Object.getOwnPropertyDescriptor,US=(i,A,e,t)=>{for(var g=t>1?void 0:t?ToA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&YoA(A,e,g),g};let EF=class{constructor(){r(this,"texture",null);r(this,"rect")}};US([D(He)],EF.prototype,"texture",2);let Yc=class extends Nu{constructor(){super(...arguments);r(this,"_sprite");r(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new EF),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}isBuiltinSprite(){var e,t,g,I,o,s,n,C,a,B,Q;switch((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((o=(I=(g=this.sprite)==null?void 0:g.texture)==null?void 0:I.name)!=null&&o.length)&&((C=(n=(s=this.sprite)==null?void 0:s.texture)==null?void 0:n.image)==null?void 0:C.width)===32&&((Q=(B=(a=this.sprite)==null?void 0:a.texture)==null?void 0:B.image)==null?void 0:Q.height)===32}onBeforeCreate(e){var t,g;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((g=(t=this.sprite)==null?void 0:t.texture)==null?void 0:g.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};US([D(EF)],Yc.prototype,"sprite",1);US([D()],Yc.prototype,"pixelsPerUnitMultiplier",2);class NS extends Nu{constructor(){super(...arguments);r(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}US([D(He)],NS.prototype,"mainTexture",1);var _oA=Object.defineProperty,HoA=Object.getOwnPropertyDescriptor,Ko=(i,A,e,t)=>{for(var g=t>1?void 0:t?HoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&_oA(A,e,g),g};const Vr=oA("debugbutton");class oQ{constructor(){r(this,"colorMultiplier");r(this,"disabledColor");r(this,"fadeDuration");r(this,"highlightedColor");r(this,"normalColor");r(this,"pressedColor");r(this,"selectedColor")}}Ko([D()],oQ.prototype,"colorMultiplier",2);Ko([D(Kt)],oQ.prototype,"disabledColor",2);Ko([D()],oQ.prototype,"fadeDuration",2);Ko([D(Kt)],oQ.prototype,"highlightedColor",2);Ko([D(Kt)],oQ.prototype,"normalColor",2);Ko([D(Kt)],oQ.prototype,"pressedColor",2);Ko([D(Kt)],oQ.prototype,"selectedColor",2);class Aa extends NA{constructor(){super(...arguments);r(this,"onClick");r(this,"_isHovered",0);r(this,"colors");r(this,"transition");r(this,"animationTriggers");r(this,"animator");r(this,"_interactable",!0);r(this,"_requestedAnimatorTrigger");r(this,"_isInit",!1);r(this,"_image")}onPointerEnter(e){var t,g;this._isHovered+=1,Vr&&console.warn("Button Enter",this._isHovered,(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;this._isHovered-=1,Vr&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var t,g;Vr&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("pressed")))}onPointerUp(e){var t,g;Vr&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===xU.Mouse)&&(Vr&&(console.warn("Button Click",this.onClick),Ui("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Vr))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),Ue.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Vr&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(fu)||this.gameObject.addComponent(uS)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=BA.getComponent(this.gameObject,Yc),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,c,h,u,l;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),g={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(g);const I=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.pressedColor),n={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(n);const C=this.getFinalColor(e.color,(u=this.colors)==null?void 0:u.selectedColor),a={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};e.setupState(a);const B=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.disabledColor),Q={state:"disabled",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}Ko([D(kg)],Aa.prototype,"onClick",2);Ko([D()],Aa.prototype,"colors",2);Ko([D()],Aa.prototype,"transition",2);Ko([D()],Aa.prototype,"animationTriggers",2);Ko([D(jg)],Aa.prototype,"animator",2);Ko([D()],Aa.prototype,"interactable",1);var OoA=Object.defineProperty,PoA=Object.getOwnPropertyDescriptor,gg=(i,A,e,t)=>{for(var g=t>1?void 0:t?PoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OoA(A,e,g),g};const AL=oA("debuguilayout");class pr{constructor(){r(this,"left",0);r(this,"right",0);r(this,"top",0);r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}gg([D()],pr.prototype,"left",2);gg([D()],pr.prototype,"right",2);gg([D()],pr.prototype,"top",2);gg([D()],pr.prototype,"bottom",2);class Jo extends NA{constructor(){super(...arguments);r(this,"_rectTransform",null);r(this,"_needsUpdate",!1);r(this,"childAlignment",0);r(this,"reverseArrangement",!1);r(this,"spacing",0);r(this,"padding");r(this,"minWidth",0);r(this,"minHeight",0);r(this,"flexibleHeight",0);r(this,"flexibleWidth",0);r(this,"preferredHeight",0);r(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(AL&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){AL&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(qI);const e=this.gameObject.getComponentInParent(Vg);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(Vg);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}gg([D()],Jo.prototype,"childAlignment",2);gg([D()],Jo.prototype,"reverseArrangement",2);gg([D()],Jo.prototype,"spacing",2);gg([D(pr)],Jo.prototype,"padding",2);gg([D()],Jo.prototype,"minWidth",2);gg([D()],Jo.prototype,"minHeight",2);gg([D()],Jo.prototype,"flexibleHeight",2);gg([D()],Jo.prototype,"flexibleWidth",2);gg([D()],Jo.prototype,"preferredHeight",2);gg([D()],Jo.prototype,"preferredWidth",2);class fr extends Jo{constructor(){super(...arguments);r(this,"childControlHeight",!0);r(this,"childControlWidth",!0);r(this,"childForceExpandHeight",!1);r(this,"childForceExpandWidth",!1);r(this,"childScaleHeight",!1);r(this,"childScaleWidth",!1)}onCalculateLayout(e){var R;const t=this.primaryAxis,g=e.width;let I=g;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const n=t==="x",C=n?"y":"x",a=n?this.childControlWidth:this.childControlHeight,B=n?this.childControlHeight:this.childControlWidth,Q=n?this.childForceExpandWidth:this.childForceExpandHeight,E=n?this.childForceExpandHeight:this.childForceExpandWidth,c=n?s:I,h=n?g:o,u=.5*(n?this.childAlignment%3:Math.floor(this.childAlignment/3));let l=0;n?l+=this.padding.left:l+=this.padding.top;let d=0,p=0;for(let w=0;w<this.gameObject.children.length;w++){const k=this.gameObject.children[w],K=BA.getComponent(k,qI);K!=null&&K.activeAndEnabled&&(p+=1,n?d+=K.width:d+=K.height)}let f=0;const S=this.spacing*(p-1);if(Q||a){let w=0;n?w=I-=S:w=s-=S,p>0&&(f=w/p)}let m=0;m+=this.padding.left,m-=this.padding.right,u!==0&&(l=h-d,l*=u,l-=S*u,n?(l-=this.padding.right*u,l+=this.padding.left*(1-u),l<this.padding.left&&(l=this.padding.left)):(l-=this.padding.bottom*u,l+=this.padding.top*(1-u),l<this.padding.top&&(l=this.padding.top)));let G=1;for(let w=0;w<this.gameObject.children.length;w++){const k=this.gameObject.children[w],K=BA.getComponent(k,qI);if(K!=null&&K.activeAndEnabled){(R=K.pivot)==null||R.set(.5,.5),K.anchorMin.set(0,1),K.anchorMax.set(0,1);const T=g*.5+m*.5;K.anchoredPosition.x!==T&&(K.anchoredPosition.x=T);const O=o*-.5;K.anchoredPosition.y!==O&&(K.anchoredPosition.y=O),E&&B&&K.sizeDelta[C]!==c&&(K.sizeDelta[C]=c),Q&&a&&K.sizeDelta[t]!==f&&(K.sizeDelta[t]=f);const b=n?K.width:K.height,_=b*.5;if(l+=_,Q){const L=f*G-f*.5;L>l&&(l=L-f*.5+b+this.padding.left,l-=_)}let J=l;t==="y"&&(J=-J),K.anchoredPosition[t]!==J&&(K.anchoredPosition[t]=J),l+=_,l+=this.spacing,G+=1}}}}gg([D()],fr.prototype,"childControlHeight",2);gg([D()],fr.prototype,"childControlWidth",2);gg([D()],fr.prototype,"childForceExpandHeight",2);gg([D()],fr.prototype,"childForceExpandWidth",2);gg([D()],fr.prototype,"childScaleHeight",2);gg([D()],fr.prototype,"childScaleWidth",2);class cF extends fr{get primaryAxis(){return"y"}}class hF extends fr{get primaryAxis(){return"x"}}class lF extends Jo{onCalculateLayout(){}}var WoA=Object.defineProperty,joA=Object.getOwnPropertyDescriptor,Hn=(i,A,e,t)=>{for(var g=t>1?void 0:t?joA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WoA(A,e,g),g},NP=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(NP||{});const yk=oA("debuguilayout"),FP=class extends pu{constructor(){super(...arguments);r(this,"_renderOnTop");r(this,"_depthWrite",!1);r(this,"_doubleSided",!0);r(this,"_castShadows",!1);r(this,"_receiveShadows",!1);r(this,"_renderMode",-1);r(this,"_rootCanvas");r(this,"_scaleFactor",1);r(this,"worldCamera");r(this,"planeDistance",-1);r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));r(this,"previousParent",null);r(this,"_lastMatrixWorld",null);r(this,"_rectTransforms",[]);r(this,"_layoutGroups",new Map);r(this,"_receivers",[]);r(this,"onBeforeRenderRoutine",()=>{var A,e,t,g;if(this.previousParent=this.gameObject.parent,((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(g=this.shadowComponent)==null||g.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),eo.ensureUpdateMeshUI(jb,this.context))});r(this,"onAfterRenderRoutine",()=>{var A,e,t,g,I;if(((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(t=this.previousParent)==null||t.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const n=this.context.mainCamera;n==null||n.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(g=this.shadowComponent)==null||g.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),eo.ensureUpdateMeshUI(jb,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(I=this._lastMatrixWorld)==null||I.copy(this.gameObject.matrixWorld)});r(this,"_updateRenderSettingsRoutine");r(this,"_activeRenderMode",-1);r(this,"_lastWidth",-1);r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}set rootCanvas(A){this._rootCanvas instanceof FP||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){var A;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,yk&&console.log("Canvas.Awake()",((A=this.previousParent)==null?void 0:A.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new GA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const A=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);A!==-1&&this.context.pre_render_callbacks.splice(A,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(A){this._rectTransforms.push(A)}unregisterTransform(A){const e=this._rectTransforms.indexOf(A);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(A){const e=A.gameObject;this._layoutGroups.set(e,A)}unregisterLayoutGroup(A){const e=A.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(A){this._receivers.push(A)}unregisterEventReceiver(A){const e=this._receivers.indexOf(A);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(A){this.screenspace?(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await wT(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(A){this.screenspace&&(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var A;for(const e of this._receivers)(A=e.onBeforeCanvasRender)==null||A.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new GA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);yk&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let g=this._layoutGroups.get(t.gameObject);t.isDirty&&!g&&(g=t.gameObject.getComponentInParent(Jo)),(t.isDirty||g!=null&&g.isDirty)&&(yk&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),g==null||g.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),eg.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Ry(this.shadowComponent,this);for(const A of BA.getComponentsInChildren(this.gameObject,_s))Ry(A.shadowComponent,this)}}onUpdateRenderMode(A=!1){if(!A&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=se.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const g=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-g,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(qI);let o=!1;I.sizeDelta.x!==this.context.domWidth&&(o=!0),I.sizeDelta.y!==this.context.domHeight&&(o=!0);const s=e.fieldOfView*Math.PI/180,n=2*Math.tan(s/2)*Math.abs(g);this.gameObject.scale.x=n/this.context.domHeight,this.gameObject.scale.y=n/this.context.domHeight,this.gameObject.scale.z=.01,o&&(I.sizeDelta.x=this.context.domWidth,I.sizeDelta.y=this.context.domHeight,I==null||I.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Vg=FP;Hn([D()],Vg.prototype,"renderOnTop",1);Hn([D()],Vg.prototype,"depthWrite",1);Hn([D()],Vg.prototype,"doubleSided",1);Hn([D()],Vg.prototype,"castShadows",1);Hn([D()],Vg.prototype,"receiveShadows",1);Hn([D()],Vg.prototype,"renderMode",1);Hn([D(Vg)],Vg.prototype,"rootCanvas",1);Hn([D()],Vg.prototype,"scaleFactor",1);Hn([D(ti)],Vg.prototype,"worldCamera",2);Hn([D()],Vg.prototype,"planeDistance",2);var VoA=Object.defineProperty,zoA=Object.getOwnPropertyDescriptor,dF=(i,A,e,t)=>{for(var g=t>1?void 0:t?zoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VoA(A,e,g),g};class Cr extends NA{constructor(){super(...arguments);r(this,"_alpha",1);r(this,"interactable",!0);r(this,"blocksRaycasts",!0);r(this,"_isDirty",!1);r(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),eg.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of BA.getComponentsInChildren(this.gameObject,_s,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}dF([D()],Cr.prototype,"alpha",1);dF([D()],Cr.prototype,"interactable",2);dF([D()],Cr.prototype,"blocksRaycasts",2);var ZoA=Object.defineProperty,XoA=Object.getOwnPropertyDescriptor,Di=(i,A,e,t)=>{for(var g=t>1?void 0:t?XoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ZoA(A,e,g),g};function Fu(i){i&&(i.getComponentInParent(fu)||(Ge()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(Mo)))}class sQ extends NA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new y);r(this,"targetRot",new RA);r(this,"targetScale",new y)}start(){Fu(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Je(this.object).clone(),t=Je(this.target).clone(),g=qt(this.object).clone(),I=qt(this.target).clone(),o=li(this.object).clone(),s=li(this.target).clone(),n=e.distanceTo(t),C=g.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){QI(this.object,t),rs(this.object,I),Bd(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),QI(this.object,this.targetPos),rs(this.object,this.targetRot),Bd(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),g=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(g,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new rg("Move to "+((t=this.target)==null?void 0:t.name),Hg.tapTrigger(this.gameObject),ct.transformAction(this.object,this.target,this.duration,this.relativeMotion?jM.Relative:jM.Absolute));e.addBehavior(g)}}}Di([D(pA)],sQ.prototype,"object",2);Di([D(pA)],sQ.prototype,"target",2);Di([D()],sQ.prototype,"duration",2);Di([D()],sQ.prototype,"relativeMotion",2);var Vf;const BC=(Vf=class extends NA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",[]);r(this,"selfModel");r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=BA.findObjectsOfType(Fi);for(const e of A)for(let t=0;t<e.sharedMaterials.length;t++){const g=e.sharedMaterials[t];if(g===this.materialToSwitch){if(e.gameObject instanceof uA)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof NI)for(const I of e.gameObject.children)I instanceof uA&&I.material===g&&this._objectsWithThisMaterial.push(I);break}}}}start(){Fu(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(A,e){this.targetModels=[],BC._materialTriggersPerId={},BC.variantSwitchIndex=0,this.materialToSwitch&&await lo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await lo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(BC._materialTriggersPerId[this.materialToSwitch.uuid]||(BC._materialTriggersPerId[this.materialToSwitch.uuid]=[]),BC._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=BC._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(g[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in g)s!==I.selfModel.uuid&&o.push(...g[s]);I.createAndAttachBehaviors(A,g[I.selfModel.uuid],o)}}delete BC._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);I.push(ct.fadeAction([...this.targetModels,...t],o,!1)),g.push(ct.fadeAction(e,o,!1)),I.push(ct.fadeAction(e,o,!0)),A.addBehavior(new rg("Select_"+this.selfModel.name,Hg.tapTrigger(this.selfModel),ct.parallel(...I))),A.addBehavior(new rg("StartHidden_"+this.selfModel.name,Hg.sceneStartTrigger(),ct.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+BC.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&Ao.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(Vf,"_materialTriggersPerId",{}),r(Vf,"variantSwitchIndex",0),Vf);let Tc=BC;Di([D(_e)],Tc.prototype,"materialToSwitch",2);Di([D(_e)],Tc.prototype,"variantMaterial",2);Di([D()],Tc.prototype,"fadeDuration",2);var gE;const Qi=(gE=class extends NA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"selfModelClone");r(this,"targetModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1);r(this,"targetStateBeforeCreatingDocument",!1)}start(){Fu(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[Qi.wasVisible]===void 0&&(this.gameObject[Qi.wasVisible]=this.gameObject.activeSelf),this.target[Qi.wasVisible]===void 0&&(this.target[Qi.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[Qi.wasVisible],this.targetStateBeforeCreatingDocument=this.target[Qi.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(A,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let g=this.selfModel,I=this.targetState;if(this.toggleOnClick)if(I=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&nP.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[Qi.toggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggle"+Qi.clonedToggleIndex++,t.add(n),this.gameObject[Qi.toggleClone]=n,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const s=this.gameObject[Qi.toggleClone];if(!this.gameObject[Qi.reverseToggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggleReverse"+Qi.clonedToggleIndex++,t.add(n),this.gameObject[Qi.reverseToggleClone]=n}this.toggleModel=this.gameObject[Qi.reverseToggleClone],(!this.toggleModel.geometry||!s.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),g=s,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const s=[];s.push(ct.fadeAction(g,0,!1)),s.push(ct.fadeAction(this.toggleModel,0,!0)),s.push(ct.fadeAction(this.targetModel,0,I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Hg.tapTrigger(g),ct.parallel(...s)));const n=[];n.push(ct.fadeAction(this.toggleModel,0,!1)),n.push(ct.fadeAction(g,0,!0)),n.push(ct.fadeAction(this.targetModel,0,!I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"Off":"On"),Hg.tapTrigger(this.toggleModel),ct.parallel(...n)))}}else{const s=[];this.hideSelf&&s.push(ct.fadeAction(g,0,!1)),s.push(ct.fadeAction(this.targetModel,0,I)),A.addBehavior(new rg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Hg.tapTrigger(g),ct.parallel(...s)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(t),this.toggleModel&&o.push(this.toggleModel),A.addBehavior(new rg("HideOnStart_"+this.gameObject.name,Hg.sceneStartTrigger(),ct.fadeAction(o,0,!1)))}}afterSerialize(A,e){this.gameObject[Qi.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[Qi.wasVisible],delete this.gameObject[Qi.wasVisible]),this.target&&this.target[Qi.wasVisible]!==void 0&&(this.target.visible=this.target[Qi.wasVisible],delete this.target[Qi.wasVisible]),delete this.gameObject[Qi.toggleClone],delete this.gameObject[Qi.reverseToggleClone]}},r(gE,"clonedToggleIndex",0),r(gE,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),r(gE,"toggleClone",Symbol("clone for toggling")),r(gE,"reverseToggleClone",Symbol("clone for reverse toggling")),gE);let nQ=Qi;Di([D(pA)],nQ.prototype,"target",2);Di([D()],nQ.prototype,"toggleOnClick",2);Di([D()],nQ.prototype,"targetState",2);Di([D()],nQ.prototype,"hideSelf",2);class uF extends NA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new rg("HideOnStart_"+this.gameObject.name,Hg.sceneStartTrigger(),ct.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class _c extends NA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType",zN.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new rg("emphasize "+this.name,Hg.tapTrigger(this.gameObject),ct.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}Di([D()],_c.prototype,"target",2);Di([D()],_c.prototype,"duration",2);Di([D()],_c.prototype,"motionType",2);class Hc extends NA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){Fu(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(Ki);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,t,g){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=I.split("/").pop(),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?zM.NonSpatial:zM.Spatial;{let a=ct.playAudioAction(o,"audio/"+s,VM.Play,n,C);this.toggleOnClick&&(a.multiplePerformOperation=QP.Stop),this.target&&this.target.loop&&(a=ct.sequence(a).makeLooping());const B=new rg("playAudio "+this.name,Hg.tapTrigger(this.gameObject),a);e.addBehavior(B)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let a=ct.playAudioAction(o,"audio/"+s,VM.Play,n,C);this.target.loop&&(a=ct.sequence(a).makeLooping());const B=new rg("playAudioOnStart "+this.name,Hg.sceneStartTrigger(),a);e.addBehavior(B)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=g.split("/").pop(),n=await(await(await fetch(g)).blob()).arrayBuffer(),C=new Uint8Array(n);t.files["audio/"+I]=C}}Di([D(Ki)],Hc.prototype,"target",2);Di([D(URL)],Hc.prototype,"clip",2);Di([D()],Hc.prototype,"toggleOnClick",2);var zf;const Ga=(zf=class extends NA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A;return(A=this.animator)==null?void 0:A.gameObject}start(){Fu(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Ga.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';Ge()&&fi(A),console.warn(A,...Ga.rootsWithExclusivePlayback)}Ga.animationActions=[],Ga.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,g=e.extensions.find(s=>s instanceof wu);if(!g)return;const I=g.getClipCount(this.target)>1;I&&(Ge()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+g.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Ga.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=Ga.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=ct.startAnimationAction(s,n.start,n.duration),Ga.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=ct.sequence();if(this.animationSequence!==void 0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence!==void 0){const Q=a.actions.length==0?a:ct.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new rg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Hg.tapTrigger(this.selfModel):Hg.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var n,C,a,B;if(!this.target||!this.animator)return;const g=(n=this.animator)==null?void 0:n.runtimeAnimatorController;let I=g==null?void 0:g.findState(this.stateName),o=[],s=[];if(g&&I){const Q=new Array;Q.push(I);let E=!1;for(;Q.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(C=I.motion)!=null&&C.isLooping&&(E=!0);break}const c=I.transitions.find(u=>u.conditions.length===0),h=c?g.getState(c.destinationState,0):null;if(h&&Q.includes(h)){I=h,E=!0;break}else if(c){if(I=h,!I)break;Q.push(I)}else{E=((a=I.motion)==null?void 0:a.isLooping)??!1;break}}if(E&&I){const c=Q.indexOf(I);o=Q.slice(0,c),s=Q.slice(c),console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=Q,s=[],console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(Q=>{var E,c,h;return((E=Q.motion)==null?void 0:E.clip)&&((h=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)>0}),s=s.filter(Q=>{var E,c,h;return((E=Q.motion)==null?void 0:E.clip)&&((h=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((B=this.animator)==null?void 0:B.name)+", can't export animation data");return}if(this.stateAnimationModel=e,o.length>0){this.animationSequence=new Array;for(const Q of o)this.animationSequence.push(A.registerAnimation(this.target,Q.motion.clip))}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const Q of s)this.animationLoopAfterSequence.push(A.registerAnimation(this.target,Q.motion.clip))}}},r(zf,"animationActions",[]),r(zf,"rootsWithExclusivePlayback",new Set),zf);let Oc=Ga;Di([D(jg)],Oc.prototype,"animator",2);Di([D()],Oc.prototype,"stateName",2);class Pc extends NA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}Di([D(pA)],Pc.prototype,"target",2);class Ku extends NA{constructor(){super(...arguments);r(this,"target")}}Di([D(Pc)],Ku.prototype,"target",2);class Ju extends Pc{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Di([D()],Ju.prototype,"type",2);Di([D()],Ju.prototype,"duration",2);class pF extends Ku{}var $oA=Object.defineProperty,AsA=Object.getOwnPropertyDescriptor,ea=(i,A,e,t)=>{for(var g=t>1?void 0:t?AsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&$oA(A,e,g),g};const eL=oA("debugcharactercontroller");class CQ extends NA{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new y)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ei),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ei)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(nr);t||(t=this.gameObject.addNewComponent(nr)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const g=new y(0,0,1),I=new y(1,0,0),o=new y(0,1,0),s=this.gameObject.getWorldDirection(new y);s.y=0;const n=I.dot(s)<0?-1:1,C=g.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),eL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),eL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const g=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);g&&(this._contactVelocity.x+=g.x,this._contactVelocity.y+=g.y,this._contactVelocity.z+=g.z)}return this._contactVelocity}}ea([D(y)],CQ.prototype,"center",2);ea([D()],CQ.prototype,"radius",2);ea([D()],CQ.prototype,"height",2);class ta extends NA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new gA(0,0));r(this,"moveInput",new gA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new y(0,0,0));r(this,"_currentAngularSpeed",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new Bs)}awake(){this._currentRotation=new RA}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,g){var I,o,s,n,C,a,B,Q,E,c,h;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=se.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const u=this.context.mainCameraComponent.forward;u.y=0,u.normalize(),this._currentRotation.setFromUnitVectors(new y(0,0,1),u),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let u=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(u=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),u){this._jumpCount+=1;const l=this.controller.rigidbody,d=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new y(0,1,0).multiplyScalar(d))}}if(this.controller){const u=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(u<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Uo),this._raycastOptions.ray.origin.copy(Je(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const d=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(d.length&&d[0].distance>2||u<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}ea([D(CQ)],ta.prototype,"controller",2);ea([D()],ta.prototype,"movementSpeed",2);ea([D()],ta.prototype,"rotationSpeed",2);ea([D()],ta.prototype,"jumpForce",2);ea([D()],ta.prototype,"doubleJumpForce",2);ea([D(jg)],ta.prototype,"animator",2);var esA=Object.defineProperty,tsA=Object.getOwnPropertyDescriptor,isA=(i,A,e,t)=>{for(var g=t>1?void 0:t?tsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&esA(A,e,g),g};class vu extends lI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new n_;return e.offset=new gA(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}isA([D(be)],vu.prototype,"intensity",2);ls("ChromaticAberration",vu);var gsA=Object.defineProperty,IsA=Object.getOwnPropertyDescriptor,FS=(i,A,e,t)=>{for(var g=t>1?void 0:t?IsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&gsA(A,e,g),g};class Dr extends lI{constructor(){super(...arguments);r(this,"postExposure");r(this,"contrast");r(this,"hueShift");r(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===to&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=ql);const e=new s_;this.postExposure.onValueChanged=g=>{this.context.renderer.toneMapping===to&&(this.context.renderer.toneMapping=ql),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=g)},this.contrast.onValueChanged=g=>{e.contrast=g};const t=new a_;return this.hueShift.onValueChanged=g=>t.hue=g,this.saturation.onValueChanged=g=>t.saturation=g,[t,e]}}FS([D(be)],Dr.prototype,"postExposure",2);FS([D(be)],Dr.prototype,"contrast",2);FS([D(be)],Dr.prototype,"hueShift",2);FS([D(be)],Dr.prototype,"saturation",2);ls("ColorAdjustments",Dr);const osA=(Math.sqrt(5)-1)/4,Ng=(5-Math.sqrt(5))/20,kf=i=>Math.floor(i)|0,Gf=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ssA(i=Math.random){const A=nsA(i),e=new Float64Array(A).map(o=>Gf[o%32*4]),t=new Float64Array(A).map(o=>Gf[o%32*4+1]),g=new Float64Array(A).map(o=>Gf[o%32*4+2]),I=new Float64Array(A).map(o=>Gf[o%32*4+3]);return function(s,n,C,a){let B,Q,E,c,h;const u=(s+n+C+a)*osA,l=kf(s+u),d=kf(n+u),p=kf(C+u),f=kf(a+u),S=(l+d+p+f)*Ng,m=l-S,G=d-S,R=p-S,w=f-S,k=s-m,K=n-G,T=C-R,O=a-w;let b=0,_=0,J=0,L=0;k>K?b++:_++,k>T?b++:J++,k>O?b++:L++,K>T?_++:J++,K>O?_++:L++,T>O?J++:L++;const H=b>=3?1:0,Z=_>=3?1:0,X=J>=3?1:0,nA=L>=3?1:0,lA=b>=2?1:0,SA=_>=2?1:0,qA=J>=2?1:0,ZA=L>=2?1:0,CA=b>=1?1:0,DA=_>=1?1:0,TA=J>=1?1:0,OA=L>=1?1:0,XA=k-H+Ng,HA=K-Z+Ng,JA=T-X+Ng,V=O-nA+Ng,fA=k-lA+2*Ng,LA=K-SA+2*Ng,wA=T-qA+2*Ng,VA=O-ZA+2*Ng,re=k-CA+3*Ng,q=K-DA+3*Ng,F=T-TA+3*Ng,aA=O-OA+3*Ng,MA=k-1+4*Ng,mA=K-1+4*Ng,FA=T-1+4*Ng,Ie=O-1+4*Ng,YA=l&255,ee=d&255,Ce=p&255,De=f&255;let UA=.6-k*k-K*K-T*T-O*O;if(UA<0)B=0;else{const PA=YA+A[ee+A[Ce+A[De]]];UA*=UA,B=UA*UA*(e[PA]*k+t[PA]*K+g[PA]*T+I[PA]*O)}let Le=.6-XA*XA-HA*HA-JA*JA-V*V;if(Le<0)Q=0;else{const PA=YA+H+A[ee+Z+A[Ce+X+A[De+nA]]];Le*=Le,Q=Le*Le*(e[PA]*XA+t[PA]*HA+g[PA]*JA+I[PA]*V)}let he=.6-fA*fA-LA*LA-wA*wA-VA*VA;if(he<0)E=0;else{const PA=YA+lA+A[ee+SA+A[Ce+qA+A[De+ZA]]];he*=he,E=he*he*(e[PA]*fA+t[PA]*LA+g[PA]*wA+I[PA]*VA)}let le=.6-re*re-q*q-F*F-aA*aA;if(le<0)c=0;else{const PA=YA+CA+A[ee+DA+A[Ce+TA+A[De+OA]]];le*=le,c=le*le*(e[PA]*re+t[PA]*q+g[PA]*F+I[PA]*aA)}let te=.6-MA*MA-mA*mA-FA*FA-Ie*Ie;if(te<0)h=0;else{const PA=YA+1+A[ee+1+A[Ce+1+A[De+1]]];te*=te,h=te*te*(e[PA]*MA+t[PA]*mA+g[PA]*FA+I[PA]*Ie)}return 27*(B+Q+E+c+h)}}function nsA(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const g=t+~~(i()*(256-t)),I=e[t];e[t]=e[g],e[g]=I}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var CsA=Object.defineProperty,asA=Object.getOwnPropertyDescriptor,sA=(i,A,e,t)=>{for(var g=t>1?void 0:t?asA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CsA(A,e,g),g};const Mf=oA("debugparticles");var hC=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(hC||{});let yr=class{constructor(){r(this,"alphaKeys");r(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let t,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const n=this.alphaKeys[s];(n.time<A||!t)&&(t=n,g=s)}for(let s=0;s<this.colorKeys.length;s++){const n=this.colorKeys[s];(n.time<A||!I)&&(I=n,o=s)}if(I)if(o+1<this.colorKeys.length){const n=this.colorKeys[o+1],C=se.remap(A,I.time,n.time,0,1);e.r=se.lerp(I.color.r,n.color.r,C),e.g=se.lerp(I.color.g,n.color.g,C),e.b=se.lerp(I.color.b,n.color.b,C)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(t)if(g+1<this.alphaKeys.length){const n=this.alphaKeys[g+1],C=se.remap(A,t.time,n.time,0,1);e.alpha=se.lerp(t.alpha,n.alpha,C)}else e.alpha=t.alpha;return e}};sA([D()],yr.prototype,"alphaKeys",2);sA([D()],yr.prototype,"colorKeys",2);var pd=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(pd||{}),Uy=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(Uy||{});const KP=class{constructor(){r(this,"mode");r(this,"constant");r(this,"constantMin");r(this,"constantMax");r(this,"curve");r(this,"curveMin");r(this,"curveMax");r(this,"curveMultiplier")}clone(){var A,e,t;const i=new KP;return i.mode=this.mode,i.constant=this.constant,i.constantMin=this.constantMin,i.constantMax=this.constantMax,i.curve=(A=this.curve)==null?void 0:A.clone(),i.curveMin=(e=this.curveMin)==null?void 0:e.clone(),i.curveMax=(t=this.curveMax)==null?void 0:t.clone(),i.curveMultiplier=this.curveMultiplier,i}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.constant;case 1:return i=se.clamp01(i),this.curve.evaluate(i)*this.curveMultiplier;case 2:const t=i*this.curveMin.duration,g=i*this.curveMax.duration;return se.lerp(this.curveMin.evaluate(t),this.curveMax.evaluate(g),e%1)*this.curveMultiplier;case 3:return se.lerp(this.constantMin,this.constantMax,e%1);default:this.curveMax.evaluate(i)*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(i){if(!i)return 0;let A=Number.MIN_VALUE;for(let e=0;e<i.keys.length;e++){const t=i.keys[e];t.value>A&&(A=t.value)}return A}};let ce=KP;sA([D()],ce.prototype,"mode",2);sA([D()],ce.prototype,"constant",2);sA([D()],ce.prototype,"constantMin",2);sA([D()],ce.prototype,"constantMax",2);sA([D($B)],ce.prototype,"curve",2);sA([D($B)],ce.prototype,"curveMin",2);sA([D($B)],ce.prototype,"curveMax",2);sA([D()],ce.prototype,"curveMultiplier",2);var Zf;const ks=(Zf=class{constructor(){r(this,"mode");r(this,"color");r(this,"colorMin");r(this,"colorMax");r(this,"gradient");r(this,"gradientMin");r(this,"gradientMax")}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,ks._temp),ks._temp;case 2:return ks._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(i,ks._temp),this.gradientMax.evaluate(i,ks._temp2),ks._temp.lerp(ks._temp2,e)}return ks._temp.set(16711935),ks._temp.alpha=1,ks._temp}},r(Zf,"_temp",new Kt(0,0,0,1)),r(Zf,"_temp2",new Kt(0,0,0,1)),Zf);let oo=ks;sA([D(Kt)],oo.prototype,"color",2);sA([D(Kt)],oo.prototype,"colorMin",2);sA([D(Kt)],oo.prototype,"colorMax",2);sA([D(yr)],oo.prototype,"gradient",2);sA([D(yr)],oo.prototype,"gradientMin",2);sA([D(yr)],oo.prototype,"gradientMax",2);var gR=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(gR||{});class eI{constructor(){r(this,"cullingMode");r(this,"duration");r(this,"emitterVelocityMode");r(this,"flipRotation");r(this,"gravityModifier");r(this,"gravityModifierMultiplier");r(this,"loop");r(this,"maxParticles");r(this,"playOnAwake");r(this,"prewarm");r(this,"ringBufferLoopRange");r(this,"ringBufferMode");r(this,"scalingMode");r(this,"simulationSpace");r(this,"simulationSpeed");r(this,"startColor");r(this,"startDelay");r(this,"startDelayMultiplier");r(this,"startLifetime");r(this,"startLifetimeMultiplier");r(this,"startRotation");r(this,"startRotationMultiplier");r(this,"startRotation3D");r(this,"startRotationX");r(this,"startRotationXMultiplier");r(this,"startRotationY");r(this,"startRotationYMultiplier");r(this,"startRotationZ");r(this,"startRotationZMultiplier");r(this,"startSize");r(this,"startSize3D");r(this,"startSizeMultiplier");r(this,"startSizeX");r(this,"startSizeXMultiplier");r(this,"startSizeY");r(this,"startSizeYMultiplier");r(this,"startSizeZ");r(this,"startSizeZMultiplier");r(this,"startSpeed");r(this,"startSpeedMultiplier");r(this,"stopAction");r(this,"useUnscaledTime")}}sA([D(ce)],eI.prototype,"gravityModifier",2);sA([D(oo)],eI.prototype,"startColor",2);sA([D(ce)],eI.prototype,"startDelay",2);sA([D(ce)],eI.prototype,"startLifetime",2);sA([D(ce)],eI.prototype,"startRotation",2);sA([D(ce)],eI.prototype,"startRotationX",2);sA([D(ce)],eI.prototype,"startRotationY",2);sA([D(ce)],eI.prototype,"startRotationZ",2);sA([D(ce)],eI.prototype,"startSize",2);sA([D(ce)],eI.prototype,"startSizeX",2);sA([D(ce)],eI.prototype,"startSizeY",2);sA([D(ce)],eI.prototype,"startSizeZ",2);sA([D(ce)],eI.prototype,"startSpeed",2);class fd{constructor(){r(this,"cycleCount");r(this,"maxCount");r(this,"minCount");r(this,"probability");r(this,"repeatInterval");r(this,"time");r(this,"count");r(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 t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=se.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=se.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class On{constructor(){r(this,"enabled");r(this,"bursts");r(this,"rateOverTime");r(this,"rateOverTimeMultiplier");r(this,"rateOverDistance");r(this,"rateOverDistanceMultiplier");r(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 t=this.bursts[e];this.system.main.loop&&t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}}sA([D()],On.prototype,"enabled",2);sA([D()],On.prototype,"bursts",2);sA([D(ce)],On.prototype,"rateOverTime",2);sA([D()],On.prototype,"rateOverTimeMultiplier",2);sA([D(ce)],On.prototype,"rateOverDistance",2);sA([D()],On.prototype,"rateOverDistanceMultiplier",2);class bu{constructor(){r(this,"enabled");r(this,"color")}}sA([D(oo)],bu.prototype,"color",2);class wr{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_time",0);r(this,"_temp",new y)}evaluate(A,e,t){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,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{const g=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=g}return e}}sA([D(ce)],wr.prototype,"size",2);sA([D(ce)],wr.prototype,"x",2);sA([D(ce)],wr.prototype,"y",2);sA([D(ce)],wr.prototype,"z",2);var Xf;const il=(Xf=class{constructor(){r(this,"shapeType",5);r(this,"enabled",!0);r(this,"alignToDirection",!1);r(this,"angle",0);r(this,"arc",360);r(this,"arcSpread");r(this,"arcSpeedMultiplier");r(this,"arcMode");r(this,"boxThickness");r(this,"position");r(this,"rotation");r(this,"_rotation",new Og);r(this,"scale");r(this,"radius");r(this,"radiusThickness");r(this,"sphericalDirectionAmount");r(this,"randomDirectionAmount");r(this,"randomPositionAmount");r(this,"meshShapeType");r(this,"meshRenderer");r(this,"_meshObj");r(this,"_meshGeometry");r(this,"system");r(this,"_space");r(this,"_worldSpaceMatrix",new GA);r(this,"_worldSpaceMatrixInverse",new GA);r(this,"_vector",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_triangle",new UI);r(this,"_dir",new y);r(this,"_loopTime",0);r(this,"_loopDirection",1);Mf&&console.log(this)}get type(){return Uy[this.shapeType]}initialize(i){this.onInitialize(i),i.position.copy(this._vector)}toJSON(){return this}clone(){return new il}setMesh(i){this.meshRenderer=i,i?(this._meshObj=i.sharedMeshes[Math.floor(Math.random()*i.sharedMeshes.length)],this._meshGeometry=this._meshObj.geometry):(this._meshObj=void 0,this._meshGeometry=void 0)}update(i,A,e,t){this.system=i,this._space=e,e===1&&(this._worldSpaceMatrix.copy(t.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=se.toRadians(this.rotation.x),this._rotation.y=se.toRadians(this.rotation.y),this._rotation.z=se.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),A}onInitialize(i){this._vector.set(0,0,0),i.mesh=void 0,i.mesh_geometry=void 0;const A=this._temp.copy(this.position),e=this._space===1;e&&A.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Mf&&Ue.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,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 13:const g=this.meshRenderer;(g==null?void 0:g.destroyed)==!1&&this.setMesh(g);const I=i.mesh=this._meshObj,o=i.mesh_geometry=this._meshGeometry;if(I&&o)switch(this.meshShapeType){case 0:{const s=o.getAttribute("position"),n=Math.floor(Math.random()*s.count);this._vector.fromBufferAttribute(s,n),this._vector.applyMatrix4(I.matrixWorld),i.mesh_normal=n}break;case 1:break;case 2:{const s=o.index;if(s){let n=Math.random(),C=Math.random();n+C>1&&(n=1-n,C=1-C);const a=Math.floor(Math.random()*(s.count/3));let B=a*3,Q=a*3+1,E=a*3+2;B=s.getX(B),Q=s.getX(Q),E=s.getX(E);const c=o.getAttribute("position");this._triangle.a.fromBufferAttribute(c,B),this._triangle.b.fromBufferAttribute(c,Q),this._triangle.c.fromBufferAttribute(c,E),this._vector.set(0,0,0).addScaledVector(this._triangle.a,n).addScaledVector(this._triangle.b,C).addScaledVector(this._triangle.c,1-(n+C)),this._vector.applyMatrix4(I.matrixWorld),i.mesh_normal=a}}break}break;default:this._vector.set(0,0,0),Ge()&&!globalThis.__particlesystem_shapetype_unsupported&&(console.warn("ParticleSystem ShapeType is not supported:",Uy[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)),Mf&&Ue.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i,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 t=A.x,g=A.y,I=A.z;this._dir.set(t,g,I),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;case 13:const o=i.mesh,s=i.mesh_geometry;if(o&&s)switch(this.meshShapeType){case 0:{const n=s.getAttribute("normal"),C=i.mesh_normal;this._dir.fromBufferAttribute(n,C)}break;case 1:break;case 2:{const n=s.index;if(n){const C=i.mesh_normal,a=n.getX(C*3),B=n.getX(C*3+1),Q=n.getX(C*3+2),E=s.getAttribute("position"),c=Zi(),h=Zi(),u=Zi();c.fromBufferAttribute(E,a),h.fromBufferAttribute(E,B),u.fromBufferAttribute(E,Q),c.sub(h),u.sub(h),c.cross(u),this._dir.copy(c).multiplyScalar(-1);const l=qt(o);this._dir.applyQuaternion(l)}}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),Mf&&(Ue.DrawSphere(A,.01,8925952,.5,!0),Ue.DrawDirection(A,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,A){if(A<=0)return;const e=il._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,i.add(e)}randomizeDirection(i,A){if(A===0)return;const e=il._randomQuat,t=il._tempVec;t.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(t,A*Math.random()*Math.PI),i.applyQuaternion(e)}spherizeDirection(i,A){if(A===0)return;const e=Math.random()*Math.PI*2,t=Math.acos(1-Math.random()*2),g=Math.sin(t)*Math.cos(e),I=Math.sin(t)*Math.sin(e),o=Math.cos(t),s=new y(g,I,o);i.lerp(s,A)}randomSpherePoint(i,A,e,t,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(t/360),n=Math.acos(2*o-1),C=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,a=i.x+this.scale.x*(-C*Math.sin(n)*Math.cos(s)),B=i.y+this.scale.y*(C*Math.sin(n)*Math.sin(s)),Q=i.z+this.scale.z*(C*Math.cos(n));g.x=a,g.y=B,g.z=Q}randomCirclePoint(i,A,e,t,g){const I=Math.random(),o=2*Math.PI*I*(t/360),s=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,n=i.x+this.scale.x*s*Math.cos(o),C=i.y+this.scale.y*s*Math.sin(o),a=i.z;g.x=n,g.y=C,g.z=a}randomConePoint(i,A,e,t,g,I,o){let s=0,n=0;switch(I){case 0:s=Math.random(),n=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,n=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let C=2*Math.PI*s*(g/360);switch(I){case 2:case 1:C+=Math.PI+.5,C+=this._loopTime*Math.PI*2,C%=se.toRadians(g);break}const a=Math.acos(2*n-1),B=se.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,Q=i.x+-B*Math.sin(a)*Math.cos(C),E=i.y+B*Math.sin(a)*Math.sin(C),c=i.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=c*this.scale.z}},r(Xf,"_randomQuat",new RA),r(Xf,"_tempVec",new y),Xf);let yi=il;sA([D()],yi.prototype,"shapeType",2);sA([D()],yi.prototype,"enabled",2);sA([D()],yi.prototype,"alignToDirection",2);sA([D()],yi.prototype,"angle",2);sA([D()],yi.prototype,"arc",2);sA([D()],yi.prototype,"arcSpread",2);sA([D()],yi.prototype,"arcSpeedMultiplier",2);sA([D()],yi.prototype,"arcMode",2);sA([D(y)],yi.prototype,"boxThickness",2);sA([D(y)],yi.prototype,"position",2);sA([D(y)],yi.prototype,"rotation",2);sA([D(y)],yi.prototype,"scale",2);sA([D()],yi.prototype,"radius",2);sA([D()],yi.prototype,"radiusThickness",2);sA([D()],yi.prototype,"sphericalDirectionAmount",2);sA([D()],yi.prototype,"randomDirectionAmount",2);sA([D()],yi.prototype,"randomPositionAmount",2);sA([D()],yi.prototype,"meshShapeType",2);sA([D(hu)],yi.prototype,"meshRenderer",2);class vt{constructor(){r(this,"damping");r(this,"enabled");r(this,"frequency");r(this,"octaveCount");r(this,"octaveMultiplier");r(this,"octaveScale");r(this,"positionAmount");r(this,"quality");r(this,"remap");r(this,"remapEnabled");r(this,"remapMultiplier");r(this,"remapX");r(this,"remapXMultiplier");r(this,"remapY");r(this,"remapYMultiplier");r(this,"remapZ");r(this,"remapZMultiplier");r(this,"scrollSpeedMultiplier");r(this,"separateAxes");r(this,"strengthMultiplier");r(this,"strengthX");r(this,"strengthXMultiplier");r(this,"strengthY");r(this,"strengthYMultiplier");r(this,"strengthZ");r(this,"strengthZMultiplier");r(this,"_noise");r(this,"_time",0);r(this,"_temp",new y)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,t,g,I,o){if(!this.enabled)return;this._noise||(this._noise=ssA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),n=this._noise(s.x,s.y,s.z,this._time),C=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),a=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(n,C,a).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)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}}sA([D()],vt.prototype,"damping",2);sA([D()],vt.prototype,"enabled",2);sA([D()],vt.prototype,"frequency",2);sA([D()],vt.prototype,"octaveCount",2);sA([D()],vt.prototype,"octaveMultiplier",2);sA([D()],vt.prototype,"octaveScale",2);sA([D(ce)],vt.prototype,"positionAmount",2);sA([D()],vt.prototype,"quality",2);sA([D(ce)],vt.prototype,"remap",2);sA([D()],vt.prototype,"remapEnabled",2);sA([D()],vt.prototype,"remapMultiplier",2);sA([D(ce)],vt.prototype,"remapX",2);sA([D()],vt.prototype,"remapXMultiplier",2);sA([D(ce)],vt.prototype,"remapY",2);sA([D()],vt.prototype,"remapYMultiplier",2);sA([D(ce)],vt.prototype,"remapZ",2);sA([D()],vt.prototype,"remapZMultiplier",2);sA([D()],vt.prototype,"scrollSpeedMultiplier",2);sA([D()],vt.prototype,"separateAxes",2);sA([D()],vt.prototype,"strengthMultiplier",2);sA([D(ce)],vt.prototype,"strengthX",2);sA([D()],vt.prototype,"strengthXMultiplier",2);sA([D(ce)],vt.prototype,"strengthY",2);sA([D()],vt.prototype,"strengthYMultiplier",2);sA([D(ce)],vt.prototype,"strengthZ",2);sA([D()],vt.prototype,"strengthZMultiplier",2);class ri{constructor(){r(this,"enabled");r(this,"attachRibbonToTransform",!1);r(this,"colorOverLifetime");r(this,"colorOverTrail");r(this,"dieWithParticles",!0);r(this,"inheritParticleColor",!0);r(this,"lifetime");r(this,"lifetimeMultiplier");r(this,"minVertexDistance",.2);r(this,"mode",0);r(this,"ratio",1);r(this,"ribbonCount",1);r(this,"shadowBias",0);r(this,"sizeAffectsLifetime",!1);r(this,"sizeAffectsWidth",!1);r(this,"splitSubEmitterRibbons",!1);r(this,"textureMode",0);r(this,"widthOverTrail");r(this,"widthOverTrailMultiplier");r(this,"worldSpace",!1)}getWidth(A,e,t,g){const I=this.widthOverTrail.evaluate(t,g);return A*=I,A}getColor(A,e,t){const g=this.colorOverTrail.evaluate(t),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}}sA([D()],ri.prototype,"enabled",2);sA([D()],ri.prototype,"attachRibbonToTransform",2);sA([D(oo)],ri.prototype,"colorOverLifetime",2);sA([D(oo)],ri.prototype,"colorOverTrail",2);sA([D()],ri.prototype,"dieWithParticles",2);sA([D()],ri.prototype,"inheritParticleColor",2);sA([D(ce)],ri.prototype,"lifetime",2);sA([D()],ri.prototype,"lifetimeMultiplier",2);sA([D()],ri.prototype,"minVertexDistance",2);sA([D()],ri.prototype,"mode",2);sA([D()],ri.prototype,"ratio",2);sA([D()],ri.prototype,"ribbonCount",2);sA([D()],ri.prototype,"shadowBias",2);sA([D()],ri.prototype,"sizeAffectsLifetime",2);sA([D()],ri.prototype,"sizeAffectsWidth",2);sA([D()],ri.prototype,"splitSubEmitterRibbons",2);sA([D()],ri.prototype,"textureMode",2);sA([D(ce)],ri.prototype,"widthOverTrail",2);sA([D()],ri.prototype,"widthOverTrailMultiplier",2);sA([D()],ri.prototype,"worldSpace",2);class wi{constructor(){r(this,"enabled");r(this,"space",0);r(this,"orbitalX");r(this,"orbitalY");r(this,"orbitalZ");r(this,"orbitalXMultiplier");r(this,"orbitalYMultiplier");r(this,"orbitalZMultiplier");r(this,"orbitalOffsetX");r(this,"orbitalOffsetY");r(this,"orbitalOffsetZ");r(this,"speedModifier");r(this,"speedModifierMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_system");r(this,"_temp",new y);r(this,"_temp2",new y);r(this,"_temp3",new y);r(this,"_hasOrbital",!1);r(this,"_index",0);r(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,t,g,I,o,s){var E;if(!this.enabled)return;const n=o/s,C=this.speedModifier.evaluate(n)*this.speedModifierMultiplier,a=this.x.evaluate(n),B=this.y.evaluate(n),Q=this.z.evaluate(n);if(this._temp.set(-a,B,Q),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((E=this._system)==null?void 0:E.worldPos)){const h=this._temp2.set(t.x,t.y,t.z),u=this.orbitalXMultiplier,l=this.orbitalYMultiplier,d=this.orbitalZMultiplier,p=C*Math.PI*2*10,f=Math.cos(p*u),S=Math.sin(p*u),m=Math.cos(p*l),G=Math.sin(p*l),R=Math.cos(p*d),w=Math.sin(p*d),k=h.x*(m*R)+h.y*(m*w)+h.z*-G,K=h.x*(S*G*R-f*w)+h.y*(S*G*w+f*R)+h.z*(S*m),T=h.x*(f*G*R+S*w)+h.y*(f*G*w-S*R)+h.z*(f*m),O=this._temp3.set(h.x-k,h.y-K,h.z-T);O.normalize(),O.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=O.x,g.y+=O.y,g.z+=O.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=C,g.y*=C,g.z*=C}}sA([D()],wi.prototype,"enabled",2);sA([D()],wi.prototype,"space",2);sA([D(ce)],wi.prototype,"orbitalX",2);sA([D(ce)],wi.prototype,"orbitalY",2);sA([D(ce)],wi.prototype,"orbitalZ",2);sA([D()],wi.prototype,"orbitalXMultiplier",2);sA([D()],wi.prototype,"orbitalYMultiplier",2);sA([D()],wi.prototype,"orbitalZMultiplier",2);sA([D()],wi.prototype,"orbitalOffsetX",2);sA([D()],wi.prototype,"orbitalOffsetY",2);sA([D()],wi.prototype,"orbitalOffsetZ",2);sA([D(ce)],wi.prototype,"speedModifier",2);sA([D()],wi.prototype,"speedModifierMultiplier",2);sA([D(ce)],wi.prototype,"x",2);sA([D()],wi.prototype,"xMultiplier",2);sA([D(ce)],wi.prototype,"y",2);sA([D()],wi.prototype,"yMultiplier",2);sA([D(ce)],wi.prototype,"z",2);sA([D()],wi.prototype,"zMultiplier",2);class tI{constructor(){r(this,"animation");r(this,"enabled");r(this,"cycleCount");r(this,"frameOverTime");r(this,"frameOverTimeMultiplier");r(this,"numTilesX");r(this,"numTilesY");r(this,"startFrame");r(this,"startFrameMultiplier");r(this,"rowMode");r(this,"rowIndex");r(this,"spriteCount");r(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 t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}}sA([D()],tI.prototype,"animation",2);sA([D()],tI.prototype,"enabled",2);sA([D()],tI.prototype,"cycleCount",2);sA([D(ce)],tI.prototype,"frameOverTime",2);sA([D()],tI.prototype,"frameOverTimeMultiplier",2);sA([D()],tI.prototype,"numTilesX",2);sA([D()],tI.prototype,"numTilesY",2);sA([D(ce)],tI.prototype,"startFrame",2);sA([D()],tI.prototype,"startFrameMultiplier",2);sA([D()],tI.prototype,"rowMode",2);sA([D()],tI.prototype,"rowIndex",2);sA([D()],tI.prototype,"spriteCount",2);sA([D()],tI.prototype,"timeMode",2);class us{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}sA([D()],us.prototype,"enabled",2);sA([D()],us.prototype,"separateAxes",2);sA([D(ce)],us.prototype,"x",2);sA([D()],us.prototype,"xMultiplier",2);sA([D(ce)],us.prototype,"y",2);sA([D()],us.prototype,"yMultiplier",2);sA([D(ce)],us.prototype,"z",2);sA([D()],us.prototype,"zMultiplier",2);class vo{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const t=se.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}}sA([D()],vo.prototype,"enabled",2);sA([D()],vo.prototype,"range",2);sA([D()],vo.prototype,"separateAxes",2);sA([D(ce)],vo.prototype,"x",2);sA([D()],vo.prototype,"xMultiplier",2);sA([D(ce)],vo.prototype,"y",2);sA([D()],vo.prototype,"yMultiplier",2);sA([D(ce)],vo.prototype,"z",2);sA([D()],vo.prototype,"zMultiplier",2);class Ig{constructor(){r(this,"enabled");r(this,"dampen");r(this,"drag");r(this,"dragMultiplier");r(this,"limit");r(this,"limitMultiplier");r(this,"separateAxes");r(this,"limitX");r(this,"limitXMultiplier");r(this,"limitY");r(this,"limitYMultiplier");r(this,"limitZ");r(this,"limitZMultiplier");r(this,"multiplyDragByParticleSize",!1);r(this,"multiplyDragByParticleVelocity",!1);r(this,"space");r(this,"_temp",new y);r(this,"_temp2",new y)}apply(A,e,t,g,I,o,s){if(this.enabled){const n=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>n){this._temp.copy(e).normalize().multiplyScalar(n);const a=this.dampen*.5;e.x=se.lerp(e.x,this._temp.x,a),e.y=se.lerp(e.y,this._temp.y,a),e.z=se.lerp(e.z,this._temp.z,a),t.x=se.lerp(t.x,this._temp.x,a),t.y=se.lerp(t.y,this._temp.y,a),t.z=se.lerp(t.z,this._temp.z,a)}}}}sA([D()],Ig.prototype,"enabled",2);sA([D()],Ig.prototype,"dampen",2);sA([D(ce)],Ig.prototype,"drag",2);sA([D()],Ig.prototype,"dragMultiplier",2);sA([D(ce)],Ig.prototype,"limit",2);sA([D()],Ig.prototype,"limitMultiplier",2);sA([D()],Ig.prototype,"separateAxes",2);sA([D(ce)],Ig.prototype,"limitX",2);sA([D()],Ig.prototype,"limitXMultiplier",2);sA([D(ce)],Ig.prototype,"limitY",2);sA([D()],Ig.prototype,"limitYMultiplier",2);sA([D(ce)],Ig.prototype,"limitZ",2);sA([D()],Ig.prototype,"limitZMultiplier",2);sA([D()],Ig.prototype,"multiplyDragByParticleSize",2);sA([D()],Ig.prototype,"multiplyDragByParticleVelocity",2);sA([D()],Ig.prototype,"space",2);const JP=class{constructor(){r(this,"enabled");r(this,"curve");r(this,"curveMultiplier");r(this,"mode");r(this,"system");r(this,"_temp",new y);r(this,"_firstUpdate",!0);r(this,"_frames",0)}clone(){var A;const i=new JP;return i.enabled=this.enabled,i.curve=(A=this.curve)==null?void 0:A.clone(),i.curveMultiplier=this.curveMultiplier,i.mode=this.mode,i}get _lastWorldPosition(){return this.system._iv_lastWorldPosition||(this.system._iv_lastWorldPosition=new y),this.system._iv_lastWorldPosition}get _velocity(){return this.system._iv_velocity||(this.system._iv_velocity=new y),this.system._iv_velocity}awake(i){this.system=i,this.reset()}reset(){this._firstUpdate=!0}update(i){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(i){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),i.add(this._temp)}}applyCurrent(i,A,e){if(this.enabled&&this.system&&this.system.worldspace!==!1&&this.mode===1){const t=this.curve.evaluate(A,e);this._temp.copy(this._velocity).multiplyScalar(t),i.add(this._temp)}}};let Sr=JP;sA([D()],Sr.prototype,"enabled",2);sA([D(ce)],Sr.prototype,"curve",2);sA([D()],Sr.prototype,"curveMultiplier",2);sA([D()],Sr.prototype,"mode",2);class xI{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e,t,g){const I=A.length(),o=se.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,t);return g*s}}sA([D()],xI.prototype,"enabled",2);sA([D(gA)],xI.prototype,"range",2);sA([D()],xI.prototype,"separateAxes",2);sA([D(ce)],xI.prototype,"size",2);sA([D()],xI.prototype,"sizeMultiplier",2);sA([D(ce)],xI.prototype,"x",2);sA([D()],xI.prototype,"xMultiplier",2);sA([D(ce)],xI.prototype,"y",2);sA([D()],xI.prototype,"yMultiplier",2);sA([D(ce)],xI.prototype,"z",2);sA([D()],xI.prototype,"zMultiplier",2);class aQ{constructor(){r(this,"enabled");r(this,"range");r(this,"color")}evaluate(A,e,t){const g=A.length(),I=se.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}}sA([D()],aQ.prototype,"enabled",2);sA([D(gA)],aQ.prototype,"range",2);sA([D(oo)],aQ.prototype,"color",2);const rsA={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
5411
5413
|
|
|
5412
5414
|
varying vec2 vUv;
|
|
5413
5415
|
|