@needle-tools/engine 3.32.26-alpha โ 3.32.27-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 +5 -0
- package/dist/needle-engine.js +2031 -2029
- package/dist/needle-engine.light.js +21 -19
- package/dist/needle-engine.light.min.js +5 -5
- package/dist/needle-engine.light.umd.cjs +5 -5
- package/dist/needle-engine.min.js +157 -157
- package/dist/needle-engine.umd.cjs +5 -5
- package/lib/engine/engine_input.d.ts +10 -4
- package/lib/engine/engine_input.js +9 -6
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +3 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/webxr/WebARSessionRoot.js +8 -8
- package/lib/engine-components/webxr/WebARSessionRoot.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_input.ts +17 -6
- package/src/engine-components/export/usdz/USDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +3 -0
- package/src/engine-components/webxr/WebARSessionRoot.ts +10 -10
|
@@ -4370,7 +4370,7 @@ void main() {
|
|
|
4370
4370
|
`;a+=s(o);const c=Object.keys(r);let l="";for(let u=0;u<c.length;u++){const d=c[u],f=r[d];if(qm.has(f)){l+="";continue}qm.set(f,!0),l+=d+":"+i(f,o+1),u<c.length-1&&(l+=", "),l.length>=60&&(l+=`
|
|
4371
4371
|
`,l+=s(o),a+=l,l="")}return a+=l,a+=`
|
|
4372
4372
|
}`,a}return r}function s(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const XJ=ne("nodevlogs");function pn(n,e=ta.Log){Cl(e,n)}function gn(n){pn(n,ta.Warn)}function qN(n){pn(n,ta.Error)}let sM;function Ct(){return XJ?!1:sM!==void 0?sM:Or()}function YJ(n){sM=n}const Pu=new tm,sr=new w,ah=new w,en=new Ce,SD={X:new w(1,0,0),Y:new w(0,1,0),Z:new w(0,0,1)},IC={type:"change"},CD={type:"mouseDown"},ED={type:"mouseUp",mode:null},MD={type:"objectChange"};class JJ extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const i=new fR;this._gizmo=i,this.add(i);const s=new iK;this._plane=s,this.add(s);const r=this;function o(A,_){let b=_;Object.defineProperty(r,A,{get:function(){return b!==void 0?b:_},set:function(C){b!==C&&(b=C,s[A]=C,i[A]=C,r.dispatchEvent({type:A+"-changed",value:C}),r.dispatchEvent(IC))}}),r[A]=_,s[A]=_,i[A]=_}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new w,c=new w,l=new Ce,u=new Ce,d=new w,f=new Ce,p=new w,m=new w,g=new w,y=0,v=new w;o("worldPosition",a),o("worldPositionStart",c),o("worldQuaternion",l),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",p),o("pointEnd",m),o("rotationAxis",g),o("rotationAngle",y),o("eye",v),this._offset=new w,this._startNorm=new w,this._endNorm=new w,this._cameraScale=new w,this._parentPosition=new w,this._parentQuaternion=new Ce,this._parentQuaternionInv=new Ce,this._parentScale=new w,this._worldScaleStart=new w,this._worldQuaternionInv=new Ce,this._worldScale=new w,this._positionStart=new w,this._quaternionStart=new Ce,this._scaleStart=new w,this._getPointer=KJ.bind(this),this._onPointerDown=$J.bind(this),this._onPointerHover=ZJ.bind(this),this._onPointerMove=eK.bind(this),this._onPointerUp=tK.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;Pu.setFromCamera(e,this.camera);const t=RC(this._gizmo.picker[this.mode],Pu);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e.button!==0)&&this.axis!==null){Pu.setFromCamera(e,this.camera);const t=RC(this._plane,Pu,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,CD.mode=this.mode,this.dispatchEvent(CD)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),s===void 0||t===null||this.dragging===!1||e.button!==-1)return;Pu.setFromCamera(e,this.camera);const o=RC(this._plane,Pu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(s.position.applyQuaternion(en.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),r==="world"&&(s.parent&&s.position.add(sr.setFromMatrixPosition(s.parent.matrixWorld)),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(sr.setFromMatrixPosition(s.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),ah.set(a,a,a)}else sr.copy(this.pointStart),ah.copy(this.pointEnd),sr.applyQuaternion(this._worldQuaternionInv),ah.applyQuaternion(this._worldQuaternionInv),ah.divide(sr),t.search("X")===-1&&(ah.x=1),t.search("Y")===-1&&(ah.y=1),t.search("Z")===-1&&(ah.z=1);s.scale.copy(this._scaleStart).multiply(ah),this.scaleSnap&&(t.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(sr.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(sr.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(SD[t]),sr.copy(SD[t]),r==="local"&&sr.applyQuaternion(this.worldQuaternion),sr.cross(this.eye),sr.length()===0?c=!0:this.rotationAngle=this._offset.dot(sr.normalize())*a),(t==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(en.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(en.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(IC),this.dispatchEvent(MD)}}pointerUp(e){e.button===0&&(this.dragging&&this.axis!==null&&(ED.mode=this.mode,this.dispatchEvent(ED)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(IC),this.dispatchEvent(MD),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Pu}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function KJ(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function ZJ(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function $J(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function eK(n){this.enabled&&this.pointerMove(this._getPointer(n))}function tK(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function RC(n,e,t){const i=e.intersectObject(n,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const Ny=new Us,Ni=new w(0,1,0),TD=new w(0,0,0),ID=new xe,zy=new Ce,z_=new Ce,Xa=new w,RD=new xe,wg=new w(1,0,0),qu=new w(0,1,0),Sg=new w(0,0,1),Gy=new w,Xm=new w,Ym=new w;class fR extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new li({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Ln({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const l=e.clone();l.color.setHex(65280),l.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const g=new Pn(0,.04,.1,12);g.translate(0,.05,0);const y=new Qi(.08,.08,.08);y.translate(0,.04,0);const v=new _t;v.setAttribute("position",new ut([0,0,0,1,0,0],3));const A=new Pn(.0075,.0075,.5,3);A.translate(0,.25,0);function _(V,k){const F=new dl(V,.0075,3,64,k*Math.PI*2);return F.rotateY(Math.PI/2),F.rotateX(Math.PI/2),F}function b(){const V=new _t;return V.setAttribute("position",new ut([0,0,0,1,1,1],3)),V}const C={X:[[new me(g,r),[.5,0,0],[0,0,-Math.PI/2]],[new me(g,r),[-.5,0,0],[0,0,Math.PI/2]],[new me(A,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new me(g,o),[0,.5,0]],[new me(g,o),[0,-.5,0],[Math.PI,0,0]],[new me(A,o)]],Z:[[new me(g,a),[0,0,.5],[Math.PI/2,0,0]],[new me(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new me(A,a),null,[Math.PI/2,0,0]]],XYZ:[[new me(new Al(.1,0),d.clone()),[0,0,0]]],XY:[[new me(new Qi(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new me(new Qi(.15,.15,.01),c.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Qi(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new me(new Pn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new me(new Pn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new me(new Pn(.2,0,.6,4),i),[0,.3,0]],[new me(new Pn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new me(new Pn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new me(new Pn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new me(new Al(.2,0),i)]],XY:[[new me(new Qi(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new me(new Qi(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Qi(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new me(new Al(.01,2),s),null,null,null,"helper"]],END:[[new me(new Al(.01,2),s),null,null,null,"helper"]],DELTA:[[new Dn(b(),s),null,null,null,"helper"]],X:[[new Dn(v,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Dn(v,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Dn(v,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},T={XYZE:[[new me(_(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new me(_(.5,.5),r)]],Y:[[new me(_(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new me(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new me(_(.75,1),f),null,[0,Math.PI/2,0]]]},S={AXIS:[[new Dn(v,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},E={XYZE:[[new me(new za(.25,10,8),i)]],X:[[new me(new dl(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new me(new dl(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new me(new dl(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new me(new dl(.75,.1,2,24),i)]]},O={X:[[new me(y,r),[.5,0,0],[0,0,-Math.PI/2]],[new me(A,r),[0,0,0],[0,0,-Math.PI/2]],[new me(y,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new me(y,o),[0,.5,0]],[new me(A,o)],[new me(y,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new me(y,a),[0,0,.5],[Math.PI/2,0,0]],[new me(A,a),[0,0,0],[Math.PI/2,0,0]],[new me(y,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new me(new Qi(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new me(new Qi(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Qi(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new me(new Qi(.1,.1,.1),d.clone())]]},G={X:[[new me(new Pn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new me(new Pn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new me(new Pn(.2,0,.6,4),i),[0,.3,0]],[new me(new Pn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new me(new Pn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new me(new Pn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new me(new Qi(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new me(new Qi(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Qi(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new me(new Qi(.2,.2,.2),i),[0,0,0]]]},Q={X:[[new Dn(v,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Dn(v,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Dn(v,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function D(V){const k=new ge;for(const F in V)for(let H=V[F].length;H--;){const J=V[F][H][0].clone(),Y=V[F][H][1],re=V[F][H][2],de=V[F][H][3],Re=V[F][H][4];J.name=F,J.tag=Re,Y&&J.position.set(Y[0],Y[1],Y[2]),re&&J.rotation.set(re[0],re[1],re[2]),de&&J.scale.set(de[0],de[1],de[2]),J.updateMatrix();const Ee=J.geometry.clone();Ee.applyMatrix4(J.matrix),J.geometry=Ee,J.renderOrder=1/0,J.position.set(0,0,0),J.rotation.set(0,0,0),J.scale.set(1,1,1),k.add(J)}return k}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=D(C)),this.add(this.gizmo.rotate=D(T)),this.add(this.gizmo.scale=D(O)),this.add(this.picker.translate=D(M)),this.add(this.picker.rotate=D(E)),this.add(this.picker.scale=D(G)),this.add(this.helper.translate=D(I)),this.add(this.helper.rotate=D(S)),this.add(this.helper.scale=D(Q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:z_;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 s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const o=s[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(en.setFromEuler(Ny.set(0,0,0)),o.quaternion.copy(i).multiply(en),Math.abs(Ni.copy(wg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(en.setFromEuler(Ny.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(en),Math.abs(Ni.copy(qu).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(en.setFromEuler(Ny.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(en),Math.abs(Ni.copy(Sg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(en.setFromEuler(Ny.set(0,Math.PI/2,0)),Ni.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(ID.lookAt(TD,Ni,qu)),o.quaternion.multiply(en),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),sr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),sr.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(sr),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Ni.copy(wg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Ni.copy(qu).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Ni.copy(Sg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Ni.copy(Sg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Ni.copy(wg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Ni.copy(qu).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(zy.copy(i),Ni.copy(this.eye).applyQuaternion(en.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(ID.lookAt(this.eye,TD,qu)),o.name==="X"&&(en.setFromAxisAngle(wg,Math.atan2(-Ni.y,Ni.z)),en.multiplyQuaternions(zy,en),o.quaternion.copy(en)),o.name==="Y"&&(en.setFromAxisAngle(qu,Math.atan2(Ni.x,Ni.z)),en.multiplyQuaternions(zy,en),o.quaternion.copy(en)),o.name==="Z"&&(en.setFromAxisAngle(Sg,Math.atan2(Ni.y,Ni.x)),en.multiplyQuaternions(zy,en),o.quaternion.copy(en))),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(c){return o.name===c}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class iK extends me{constructor(){super(new as(1e5,1e5,2,2),new li({visible:!1,wireframe:!0,side:bi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Gy.copy(wg).applyQuaternion(t==="local"?this.worldQuaternion:z_),Xm.copy(qu).applyQuaternion(t==="local"?this.worldQuaternion:z_),Ym.copy(Sg).applyQuaternion(t==="local"?this.worldQuaternion:z_),Ni.copy(Xm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ni.copy(this.eye).cross(Gy),Xa.copy(Gy).cross(Ni);break;case"Y":Ni.copy(this.eye).cross(Xm),Xa.copy(Xm).cross(Ni);break;case"Z":Ni.copy(this.eye).cross(Ym),Xa.copy(Ym).cross(Ni);break;case"XY":Xa.copy(Ym);break;case"YZ":Xa.copy(Gy);break;case"XZ":Ni.copy(Ym),Xa.copy(Xm);break;case"XYZ":case"E":Xa.set(0,0,0);break}break;case"rotate":default:Xa.set(0,0,0)}Xa.length()===0?this.quaternion.copy(this.cameraQuaternion):(RD.lookAt(sr.set(0,0,0),Xa,Ni),this.quaternion.setFromRotationMatrix(RD)),super.updateMatrixWorld(e)}}const nK=ne("debugpatch");function Aw(n,e,t,i){const s=nK===e;if(!t&&!i)return;const r=e+"___needle";rK(n,e,t,i);const o=Object.getOwnPropertyDescriptor(n,e),a=n[e];s&&console.log("Patch",n.constructor.name,e,o,a),o?(s&&console.log("Apply patch with existing descriptor",n.constructor.name,e,o),typeof o.value=="function"&&(n[e]=BD(o.value,n,e))):(s&&console.log("Create patch with new property",n.constructor.name,e,o),Object.defineProperty(n,e,{set:function(c){if(typeof c=="function")this[r]=BD(c,n,e);else{const l=this[r];XN(n,e,this,l,c),this[r]=c,YN(n,e,this,l,c)}},get:function(){const c=this[r];return typeof c=="function"&&c[r]?c[r]:c}}))}function sK(n,e,t){const i=pR(n,e);if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(s,1)}}const PD=Symbol("Needle:Patches:WrappedFunction");function BD(n,e,t){if(n[PD])return n;const i=function(...s){XN(e,t,this,...s);const r=n.apply(this,s);return YN(e,t,this,r,...s),r};return i[PD]=!0,i}const G_="Needle:Patches";function rM(){return globalThis[G_]||(globalThis[G_]=new WeakMap),globalThis[G_]}function pR(n,e){const t=rM().get(n);return t?t.get(e):null}function rK(n,e,t,i){let s=rM().get(n);s||(s=new Map,rM().set(n,s));let r=s.get(e);r||(r=[],s.set(e,r)),r.push({prefix:t,postfix:i})}function XN(n,e,t,...i){var r;if(!t)return;const s=pR(n,e);if(s)for(const o of s)(r=o.prefix)==null||r.call(t,...i)}function YN(n,e,t,i,...s){var o;if(!t)return;const r=pR(n,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...s)}const DD=Symbol("gltf-loader-internal-usage-tracker"),oK=ne("debugusers"),dv=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return dv._loadingProcesses>0}beforeRoot(){dv._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,s){const r=t.call(this,i,s);return r.then(o=>(o&&(e._loadedObjects.add(o),o[DD]=e._loadingId),o)),r},null}afterRoot(e){dv._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[DD],t instanceof ge&&(t.parent||t instanceof me&&(oK&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null));return null}};let qg=dv;h(qg,"_loadingProcesses",0);class JN{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const s=t[0];s&&s.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4373
|
-
`+s.src),e.preventDefault())}})}}const yw=ne("trackresources");function KN(){return yw==="dispose"}let Fd=!0;yw===0&&(Fd=!1);function aK(n){Fd=n}function ZN(){return Fd}const $N=Symbol("disposable");function mR(n,e){n&&(n[$N]=e,gd&&console.warn("Set disposable",e,n))}const e4=Symbol("disposed");function cK(n){return n[e4]===!0}function Vi(n){var e;if(n){if(n[$N]===!1){gd&&console.warn("Object is marked as not disposable",n);return}if(n[e4]=!0,n instanceof ur)Vi(n.environment),Vi(n.background),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial);else if(n instanceof Da)Vi(n.geometry),Vi(n.material),Vi(n.skeleton),Vi(n.bindMatrix),Vi(n.bindMatrixInverse),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof me)Vi(n.geometry),Vi(n.material),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof _t){Df(n);for(const t of Object.keys(n.attributes)){const i=n.attributes[t];Vi(i)}}else if(n instanceof tt||n instanceof Pr)gd&&console.warn("BufferAttribute dispose not supported",n.count);else if(n instanceof Array)for(const t of n)t instanceof Ut&&Vi(t);else if(n instanceof Ut){Df(n);for(const i of Object.keys(n)){const s=n[i];s instanceof Lt&&(Vi(s),n[i]=null)}const t=n.uniforms;if(t)for(const i of Object.keys(t)){const s=t[i];s instanceof Lt?(Vi(s),t[i]=null):s instanceof ve&&(Vi(s.value),s.value=null)}}else n instanceof Lt?(Df(n),Df(n.source),((e=n.source)==null?void 0:e.data)instanceof ImageBitmap&&Df(n.source.data)):n instanceof $p?(Df(n.boneTexture),n.boneTexture=null):n instanceof _A||!(n instanceof ge)&&gd&&console.warn("Unknown object type",n)}}function Df(n){n&&((gd||KN()||yw)&&console.warn("๐งจ FREE",n),n instanceof ImageBitmap?n.close():n instanceof vl?n.data=null:n.dispose())}function t4(n){(n instanceof me||n instanceof Da)&&(n.material=null,n.geometry=null)}const lK=new Set;function gR(n,e,t=null,i){if(i||(i=lK,i.clear()),!n)return i;const s=n[Vv];if(s)for(const r of s)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&gR(r,!0,t,i));return i}function hK(n){return n[Cg]}const gd=ne("debugresourceusers")||ne("debugmemory"),Vv=Symbol("needle-resource-users"),Cg=Symbol("needle-resource-users-count");function vr(n,e){Aw(n,e,function(t,i){Fd&&(Vb(Vv,this,t,!1),Vb(Vv,this,i,!0))})}Fd&&(vr(me.prototype,"material"),vr(me.prototype,"geometry"),vr(Ut.prototype,"map"),vr(Ut.prototype,"bumpMap"),vr(Ut.prototype,"alphaMap"),vr(Ut.prototype,"normalMap"),vr(Ut.prototype,"displacementMap"),vr(Ut.prototype,"roughnessMap"),vr(Ut.prototype,"metalnessMap"),vr(Ut.prototype,"emissiveMap"),vr(Ut.prototype,"specularMap"),vr(Ut.prototype,"envMap"),vr(Ut.prototype,"lightMap"),vr(Ut.prototype,"aoMap"),vr(Ut.prototype,"gradientMap"));function uK(n){if(Fd===!1)return;const e=n[Vv];if(e)for(const t of e)Vb(Vv,t,n,!1)}Fd&&Aw(Ut.prototype,"dispose",function(){uK(this)});let oM=0;function Vb(n,e,t,i){if(oM>0)return;if(Array.isArray(t)){for(const r of t)Vb(n,e,r,i);return}if(!t)return;let s=t[n];if(s||(s=new Set),i){if(e&&!s.has(e)){s.add(e);let r=t[Cg]||0;r+=1,t[Cg]=r,gd&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",s)}}else if(e&&s.has(e)){s.delete(e);let r=t[Cg]||0;r>0&&(r-=1,t[Cg]=r),gd&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",s),r<=0&&(qg.isLoading(t)||(yw&&console.warn(`๐ด Removed all user of "${t.type}"`,t),KN()&&Vi(t)))}t[n]=s}try{Aw(Gl.prototype,"render",function(){oM++},function(){oM--})}catch(n){console.warn("Could not wrap WebGLRenderer.render",n)}var DA=(n=>(n.Added="component-added",n.Removing="removing-component",n))(DA||{});const OD=ne("debugcomponentevents");class OA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),OD&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const s=i.indexOf(t);s<0||i.splice(s,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(OD&&console.log("Dispatching event "+e,i),!!i)for(const s of i)s(t)}}h(OA,"eventListeners",new Map);const i4=ne("debugdefines");om('if(!globalThis[""3.32.
|
|
4373
|
+
`+s.src),e.preventDefault())}})}}const yw=ne("trackresources");function KN(){return yw==="dispose"}let Fd=!0;yw===0&&(Fd=!1);function aK(n){Fd=n}function ZN(){return Fd}const $N=Symbol("disposable");function mR(n,e){n&&(n[$N]=e,gd&&console.warn("Set disposable",e,n))}const e4=Symbol("disposed");function cK(n){return n[e4]===!0}function Vi(n){var e;if(n){if(n[$N]===!1){gd&&console.warn("Object is marked as not disposable",n);return}if(n[e4]=!0,n instanceof ur)Vi(n.environment),Vi(n.background),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial);else if(n instanceof Da)Vi(n.geometry),Vi(n.material),Vi(n.skeleton),Vi(n.bindMatrix),Vi(n.bindMatrixInverse),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof me)Vi(n.geometry),Vi(n.material),Vi(n.customDepthMaterial),Vi(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof _t){Df(n);for(const t of Object.keys(n.attributes)){const i=n.attributes[t];Vi(i)}}else if(n instanceof tt||n instanceof Pr)gd&&console.warn("BufferAttribute dispose not supported",n.count);else if(n instanceof Array)for(const t of n)t instanceof Ut&&Vi(t);else if(n instanceof Ut){Df(n);for(const i of Object.keys(n)){const s=n[i];s instanceof Lt&&(Vi(s),n[i]=null)}const t=n.uniforms;if(t)for(const i of Object.keys(t)){const s=t[i];s instanceof Lt?(Vi(s),t[i]=null):s instanceof ve&&(Vi(s.value),s.value=null)}}else n instanceof Lt?(Df(n),Df(n.source),((e=n.source)==null?void 0:e.data)instanceof ImageBitmap&&Df(n.source.data)):n instanceof $p?(Df(n.boneTexture),n.boneTexture=null):n instanceof _A||!(n instanceof ge)&&gd&&console.warn("Unknown object type",n)}}function Df(n){n&&((gd||KN()||yw)&&console.warn("๐งจ FREE",n),n instanceof ImageBitmap?n.close():n instanceof vl?n.data=null:n.dispose())}function t4(n){(n instanceof me||n instanceof Da)&&(n.material=null,n.geometry=null)}const lK=new Set;function gR(n,e,t=null,i){if(i||(i=lK,i.clear()),!n)return i;const s=n[Vv];if(s)for(const r of s)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&gR(r,!0,t,i));return i}function hK(n){return n[Cg]}const gd=ne("debugresourceusers")||ne("debugmemory"),Vv=Symbol("needle-resource-users"),Cg=Symbol("needle-resource-users-count");function vr(n,e){Aw(n,e,function(t,i){Fd&&(Vb(Vv,this,t,!1),Vb(Vv,this,i,!0))})}Fd&&(vr(me.prototype,"material"),vr(me.prototype,"geometry"),vr(Ut.prototype,"map"),vr(Ut.prototype,"bumpMap"),vr(Ut.prototype,"alphaMap"),vr(Ut.prototype,"normalMap"),vr(Ut.prototype,"displacementMap"),vr(Ut.prototype,"roughnessMap"),vr(Ut.prototype,"metalnessMap"),vr(Ut.prototype,"emissiveMap"),vr(Ut.prototype,"specularMap"),vr(Ut.prototype,"envMap"),vr(Ut.prototype,"lightMap"),vr(Ut.prototype,"aoMap"),vr(Ut.prototype,"gradientMap"));function uK(n){if(Fd===!1)return;const e=n[Vv];if(e)for(const t of e)Vb(Vv,t,n,!1)}Fd&&Aw(Ut.prototype,"dispose",function(){uK(this)});let oM=0;function Vb(n,e,t,i){if(oM>0)return;if(Array.isArray(t)){for(const r of t)Vb(n,e,r,i);return}if(!t)return;let s=t[n];if(s||(s=new Set),i){if(e&&!s.has(e)){s.add(e);let r=t[Cg]||0;r+=1,t[Cg]=r,gd&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",s)}}else if(e&&s.has(e)){s.delete(e);let r=t[Cg]||0;r>0&&(r-=1,t[Cg]=r),gd&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",s),r<=0&&(qg.isLoading(t)||(yw&&console.warn(`๐ด Removed all user of "${t.type}"`,t),KN()&&Vi(t)))}t[n]=s}try{Aw(Gl.prototype,"render",function(){oM++},function(){oM--})}catch(n){console.warn("Could not wrap WebGLRenderer.render",n)}var DA=(n=>(n.Added="component-added",n.Removing="removing-component",n))(DA||{});const OD=ne("debugcomponentevents");class OA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),OD&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const s=i.indexOf(t);s<0||i.splice(s,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(OD&&console.log("Dispatching event "+e,i),!!i)for(const s of i)s(t)}}h(OA,"eventListeners",new Map);const i4=ne("debugdefines");om('if(!globalThis[""3.32.27-alpha""]) globalThis[""3.32.27-alpha""] = "0.0.0";');om('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');om('if(!globalThis[""Mon Feb 26 2024 22:30:25 GMT+0800 (Pacific Standard Time)""]) globalThis[""Mon Feb 26 2024 22:30:25 GMT+0800 (Pacific Standard Time)""] = "unknown";');om('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.32.27-alpha";');om('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');om('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Feb 26 2024 22:30:25 GMT+0800 (Pacific Standard Time)";');const yc="3.32.27-alpha",_w="undefined",dK="Mon Feb 26 2024 22:30:25 GMT+0800 (Pacific Standard Time)";i4&&console.log(`Engine version: ${yc} (generator: ${_w})
|
|
4374
4374
|
Project built at ${dK}`);const Tl="needle_isActiveInHierarchy",Ju="builtin_components",Xg="needle_editor_guid";function om(n){try{(0,eval)(n)}catch(e){i4&&console.error(e)}}const Hv=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),n4=Symbol("isUsingInstancing"),s4=Symbol("instancingRenderer"),aM=Symbol("instancingAutoUpdateBounds");class ka{static isUsingInstancing(e){return e[n4]===!0}static getRenderer(e){return e[s4]||null}setAutoUpdateBounds(e,t){const i=ka.getRenderer(e);i&&(i[aM]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[Hv]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)ka.markDirty(i,!0)}}function vd(n,e){try{e?n(e):n()}catch(t){return console.error(t),!1}return!0}const cM=ne("debugnewscripts"),fK=ne("debughierarchy"),Zi=[];function pK(){return Zi.length>0}function Hb(n){if(!(n.new_scripts.length<=0)){if(cM&&console.log("Register new components",n.new_scripts.length,[...n.new_scripts],n.alias?"element: "+n.alias:n.hash,n),n.new_scripts_pre_setup_callbacks.length>0){for(const e of n.new_scripts_pre_setup_callbacks)e&&e();n.new_scripts_pre_setup_callbacks.length=0}Zi.length=0,n.new_scripts.length>0&&Zi.push(...n.new_scripts),n.new_scripts.length=0;for(let e=0;e<Zi.length;e++)try{const t=Zi[e];if(t.isComponent!==!0){(Ct()||cM)&&console.error(`Registered script is not a Needle Engine component.
|
|
4375
4375
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
4376
4376
|
`,t),Zi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Zi.splice(e,1),e--;continue}t.context=n,Yg(t.gameObject),vR(t,n)}catch(t){console.error(t),fl(Zi[e],n),Zi.splice(e,1),e--}for(let e=0;e<Zi.length;e++)try{const t=Zi[e];if(t.destroyed){fl(Zi[e],n),Zi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),Yg(t.gameObject),t.activeAndEnabled&&vd(t.__internalAwake.bind(t)))}catch(t){console.error(t),fl(Zi[e],n),Zi.splice(e,1),e--}for(let e=0;e<Zi.length;e++)try{const t=Zi[e];if(t.destroyed||t.enabled===!1||(Yg(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,vd(t.__internalEnable.bind(t)))}catch(t){console.error(t),fl(Zi[e],n),Zi.splice(e,1),e--}for(let e=0;e<Zi.length;e++)try{const t=Zi[e];if(t.destroyed||!t.gameObject)continue;n.new_script_start.push(t)}catch(t){console.error(t),fl(Zi[e],n),Zi.splice(e,1),e--}Zi.length=0;for(const e of n.new_scripts_post_setup_callbacks)e&&e();n.new_scripts_post_setup_callbacks.length=0}}function mK(n){n&&(n.__internalDisable(!0),fl(n,n.context))}function r4(n,e){for(let t=0;t<n.new_script_start.length;t++)try{const i=n.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;vd(i.__internalAwake.bind(i)),i.enabled&&(vd(i.__internalEnable.bind(i)),vd(i.__internalStart.bind(i)),n.new_script_start.splice(t,1),t--)}catch(i){console.error(i),fl(n.new_script_start[t],n),n.new_script_start.splice(t,1),t--}}function vR(n,e){e.scripts.indexOf(n)===-1&&(e.scripts.push(n),n.earlyUpdate&&e.scripts_earlyUpdate.push(n),n.update&&e.scripts_update.push(n),n.lateUpdate&&e.scripts_lateUpdate.push(n),n.onBeforeRender&&e.scripts_onBeforeRender.push(n),n.onAfterRender&&e.scripts_onAfterRender.push(n),n.onPausedChanged&&e.scripts_pausedChanged.push(n),PC(n,null)&&e.new_scripts_xr.push(n),PC(n,"immersive-vr")&&e.scripts_immersive_vr.push(n),PC(n,"immersive-ar")&&e.scripts_immersive_ar.push(n))}function fl(n,e){zo(n,e.new_scripts),zo(n,e.new_script_start),zo(n,e.scripts),zo(n,e.scripts_earlyUpdate),zo(n,e.scripts_update),zo(n,e.scripts_lateUpdate),zo(n,e.scripts_onBeforeRender),zo(n,e.scripts_onAfterRender),zo(n,e.scripts_pausedChanged),zo(n,e.new_scripts_xr),zo(n,e.scripts_immersive_vr),zo(n,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(n)}function zo(n,e){const t=e.indexOf(n);t>=0&&e.splice(t,1)}function PC(n,e){var t;if(n){const i=n;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(e!=null&&((t=i.supportsXR)==null?void 0:t.call(i,e))===!1)}return!1}function V_(n){if(n||(n=Mi.Current.scene),!n){console.trace("Invalid call - no current context.");return}const e=lm(n);o4(n,e,!0)||(cM||Ct()?console.error(`Error updating hierarchy
|
|
@@ -4916,7 +4916,7 @@ in script ${i}.ts
|
|
|
4916
4916
|
*
|
|
4917
4917
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
4918
4918
|
* @license MIT
|
|
4919
|
-
*/var W$=function(n){return n!=null&&(D4(n)||q$(n)||!!n._isBuffer)};function D4(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function q$(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&D4(n.slice(0,0))}(function(){var n=j$,e=qD.utf8,t=W$,i=qD.bin,s=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=n.bytesToWords(r),c=r.length*8,l=1732584193,u=-271733879,d=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var m=s._ff,g=s._gg,y=s._hh,v=s._ii,p=0;p<a.length;p+=16){var A=l,_=u,b=d,C=f;l=m(l,u,d,f,a[p+0],7,-680876936),f=m(f,l,u,d,a[p+1],12,-389564586),d=m(d,f,l,u,a[p+2],17,606105819),u=m(u,d,f,l,a[p+3],22,-1044525330),l=m(l,u,d,f,a[p+4],7,-176418897),f=m(f,l,u,d,a[p+5],12,1200080426),d=m(d,f,l,u,a[p+6],17,-1473231341),u=m(u,d,f,l,a[p+7],22,-45705983),l=m(l,u,d,f,a[p+8],7,1770035416),f=m(f,l,u,d,a[p+9],12,-1958414417),d=m(d,f,l,u,a[p+10],17,-42063),u=m(u,d,f,l,a[p+11],22,-1990404162),l=m(l,u,d,f,a[p+12],7,1804603682),f=m(f,l,u,d,a[p+13],12,-40341101),d=m(d,f,l,u,a[p+14],17,-1502002290),u=m(u,d,f,l,a[p+15],22,1236535329),l=g(l,u,d,f,a[p+1],5,-165796510),f=g(f,l,u,d,a[p+6],9,-1069501632),d=g(d,f,l,u,a[p+11],14,643717713),u=g(u,d,f,l,a[p+0],20,-373897302),l=g(l,u,d,f,a[p+5],5,-701558691),f=g(f,l,u,d,a[p+10],9,38016083),d=g(d,f,l,u,a[p+15],14,-660478335),u=g(u,d,f,l,a[p+4],20,-405537848),l=g(l,u,d,f,a[p+9],5,568446438),f=g(f,l,u,d,a[p+14],9,-1019803690),d=g(d,f,l,u,a[p+3],14,-187363961),u=g(u,d,f,l,a[p+8],20,1163531501),l=g(l,u,d,f,a[p+13],5,-1444681467),f=g(f,l,u,d,a[p+2],9,-51403784),d=g(d,f,l,u,a[p+7],14,1735328473),u=g(u,d,f,l,a[p+12],20,-1926607734),l=y(l,u,d,f,a[p+5],4,-378558),f=y(f,l,u,d,a[p+8],11,-2022574463),d=y(d,f,l,u,a[p+11],16,1839030562),u=y(u,d,f,l,a[p+14],23,-35309556),l=y(l,u,d,f,a[p+1],4,-1530992060),f=y(f,l,u,d,a[p+4],11,1272893353),d=y(d,f,l,u,a[p+7],16,-155497632),u=y(u,d,f,l,a[p+10],23,-1094730640),l=y(l,u,d,f,a[p+13],4,681279174),f=y(f,l,u,d,a[p+0],11,-358537222),d=y(d,f,l,u,a[p+3],16,-722521979),u=y(u,d,f,l,a[p+6],23,76029189),l=y(l,u,d,f,a[p+9],4,-640364487),f=y(f,l,u,d,a[p+12],11,-421815835),d=y(d,f,l,u,a[p+15],16,530742520),u=y(u,d,f,l,a[p+2],23,-995338651),l=v(l,u,d,f,a[p+0],6,-198630844),f=v(f,l,u,d,a[p+7],10,1126891415),d=v(d,f,l,u,a[p+14],15,-1416354905),u=v(u,d,f,l,a[p+5],21,-57434055),l=v(l,u,d,f,a[p+12],6,1700485571),f=v(f,l,u,d,a[p+3],10,-1894986606),d=v(d,f,l,u,a[p+10],15,-1051523),u=v(u,d,f,l,a[p+1],21,-2054922799),l=v(l,u,d,f,a[p+8],6,1873313359),f=v(f,l,u,d,a[p+15],10,-30611744),d=v(d,f,l,u,a[p+6],15,-1560198380),u=v(u,d,f,l,a[p+13],21,1309151649),l=v(l,u,d,f,a[p+4],6,-145523070),f=v(f,l,u,d,a[p+11],10,-1120210379),d=v(d,f,l,u,a[p+2],15,718787259),u=v(u,d,f,l,a[p+9],21,-343485551),l=l+A>>>0,u=u+_>>>0,d=d+b>>>0,f=f+C>>>0}return n.endian([l,u,d,f])};s._ff=function(r,o,a,c,l,u,d){var f=r+(o&a|~o&c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._gg=function(r,o,a,c,l,u,d){var f=r+(o&c|a&~c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._hh=function(r,o,a,c,l,u,d){var f=r+(o^a^c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._ii=function(r,o,a,c,l,u,d){var f=r+(a^(o|~c))+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._blocksize=16,s._digestsize=16,P4.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=n.wordsToBytes(s(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):n.bytesToHex(a)}})();var X$=P4.exports;const Y$=Sw(X$);class gM{constructor(e,t,i,s){h(this,"success");h(this,"filename");h(this,"hash");h(this,"size");h(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=s}}async function O4(n,e){const t=await n.arrayBuffer(),i=ER(t),s=n.name.split(".").pop(),r=i+"."+s,o=n.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",i),new gM(!0,r,i,n.size);console.log("begin uploading file",o,n.size);const u=new FormData;u.append("file",n);const d={};d.filesize=n.size,o&&(d.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:u,headers:d})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new gM(p.success,r,i,n.size);return m.url=e,m}function ER(n){return Y$(new Uint8Array(n))}async function MR(n,e,t,i,s=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:n});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();s||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const c=ER(a);return s||console.assert(c===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function k4(n,e){var u;const t=await fetch(n),i=(u=t.body)==null?void 0:u.getReader(),s=t.headers.get("Content-Length"),r=s?parseInt(s):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:d,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),d)break}const c=new Uint8Array(o);let l=0;for(const d of a)c.set(d,l),l+=d.length;return c}const hh=ne("debugaddressables");class L4{constructor(e){h(this,"_context");h(this,"_assetReferences",{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t==null||t.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const FC=Symbol("assetReference"),mp=class{constructor(e,t,i=null){h(this,"_loading");h(this,"_asset");h(this,"_glbRoot");h(this,"_url");h(this,"_progressListeners",[]);h(this,"_hash");h(this,"_hashedUri");h(this,"_isLoadingRawBinary",!1);h(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),hG(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Ot.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const s=Vl(e,t);hh&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new mp(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Pd(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(hh&&console.log("Unload",this.asset),this.asset.scene&&Fa(this.asset.scene,!0,!0),Fa(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,hh&&console.log("Preload",this._hashedUri);const e=await k4(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(hh&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading.then(s=>this.asset);const t=Ot.Current;this._rawBinary?(this._loading=La().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(hh&&console.log("Load async",this.uri),this._loading=La().loadSync(t,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[FC]=this,this._glbRoot&&(this._glbRoot[FC]=this),this.asset&&(this.asset[FC]=this),Hb(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const s=Ot.Current,r=new Ha;if(e instanceof ge?r.parent=e:e&&r.cloneAssign(e),r.parent||(r.parent=s.scene),this.mustLoad&&await this.loadAssetAsync(),hh&&console.log("Instantiate",this.uri,"parent:",e),this.asset){hh&&console.log("Add to scene",this.asset);let o=mp.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,mp.currentlyInstantiating.set(this.uri,o),t){r.context=s;const a=this.asset;a.guid=this.uri;const c=HR(a,r,void 0,i);if(c)return c}else{const a=hm(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,mp.currentlyInstantiating.set(this.uri,o)})}}else hh&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let ii=mp;h(ii,"currentlyInstantiating",new Map);class J$ extends Oc{constructor(){super([ii],"AssetReferenceSerializer")}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?ii.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ge){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,s=t.context,r=i.guid??i.uuid,o=s.addressables.findAssetReference(r);if(o)return o;const a=new ii(r,void 0,i);return s.addressables.registerAssetReference(a),a}return null}}new J$;const K$=Promise.resolve(null),fv=class{constructor(e){h(this,"url");h(this,"_bitmap");h(this,"_bitmapObject");h(this,"loader",null);this.url=e}static getOrCreate(e){let t=fv.imageReferences.get(e);return t||(t=new fv(e),fv.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new wl),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):K$}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,e(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),e(null)}),i.src=this.url}),this._bitmap)}};let xp=fv;h(xp,"imageReferences",new Map);class F4 extends Oc{constructor(){super([xp],"ImageReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=Vl(t.gltfId,e);return xp.getOrCreate(i)}}}new F4;const pv=class{constructor(e){h(this,"url");h(this,"res");this.url=e}static getOrCreate(e){let t=pv.cache.get(e);return t||(t=new pv(e),pv.cache.set(e,t)),t}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.text())}};let wp=pv;h(wp,"cache",new Map);class U4 extends Oc{constructor(){super([wp],"FileReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=Vl(t.gltfId,e);return wp.getOrCreate(i)}}}new U4;const fs={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function N4(n){const e=await fetch(n);if(e.ok)return e.json();throw new Error(e.statusText)}async function Z$(n){if(!n)throw new Error("No basePath supplied");return await N4(`${n}/profilesList.json`)}async function $$(n,e,t=null,i=!0){if(!n)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const s=await Z$(e);let r;if(n.profiles.some(c=>{const l=s[c];return l&&(r={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!r}),!r){if(!t)throw new Error("No matching profile name found");const c=s[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);r={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const o=await N4(r.profilePath);let a;if(i){let c;if(n.handedness==="any"?c=o.layouts[Object.keys(o.layouts)[0]]:c=o.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${r.profileId}`);c.assetPath&&(a=r.profilePath.replace("profile.json",c.assetPath))}return{profile:o,assetPath:a}}const eee={xAxis:0,yAxis:0,button:0,state:fs.ComponentState.DEFAULT};function tee(n=0,e=0){let t=n,i=e;if(Math.sqrt(n*n+e*e)>1){const o=Math.atan2(e,n);t=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:i*.5+.5}}let iee=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fs.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(eee)}updateFromComponent({xAxis:e,yAxis:t,button:i,state:s}){const{normalizedXAxis:r,normalizedYAxis:o}=tee(e,t);switch(this.componentProperty){case fs.ComponentProperty.X_AXIS:this.value=this.states.includes(s)?r:.5;break;case fs.ComponentProperty.Y_AXIS:this.value=this.states.includes(s)?o:.5;break;case fs.ComponentProperty.BUTTON:this.value=this.states.includes(s)?i:0;break;case fs.ComponentProperty.STATE:this.valueNodeProperty===fs.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(s):this.value=this.states.includes(s)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},nee=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(i=>{const s=new iee(t.visualResponses[i]);this.visualResponses[i]=s}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fs.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fs.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=fs.ComponentState.PRESSED:(t.touched||this.values.button>fs.ButtonTouchThreshold)&&(this.values.state=fs.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fs.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fs.AxisTouchThreshold&&(this.values.state=fs.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fs.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fs.AxisTouchThreshold&&(this.values.state=fs.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}},see=class{constructor(e,t,i){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=i,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(s=>{const r=this.layoutDescription.components[s];this.components[s]=new nee(s,r)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}};class Ri extends _e{constructor(t,i,s,r){super(t,i,s);h(this,"alpha",1);this.alpha=r}get isRGBAColor(){return!0}set a(t){this.alpha=t}get a(){return this.alpha}clone(){const t=super.clone();return t.alpha=this.alpha,t}copy(t){return super.copy(t),"alpha"in t&&typeof t.alpha=="number"?this.alpha=t.alpha:typeof t.a=="number"&&(this.alpha=t.a),this}lerp(t,i){const s=t;return s.alpha&&(this.alpha=rt.lerp(this.alpha,s.alpha,i)),super.lerp(t,i)}lerpColors(t,i,s){const r=t,o=i;return r.alpha&&o.alpha&&(this.alpha=rt.lerp(r.alpha,o.alpha,s)),super.lerpColors(t,i,s)}multiply(t){const i=t;return i.alpha&&(this.alpha=this.alpha*i.alpha),super.multiply(t)}fromArray(t,i=0){return this.alpha=t[i+3],super.fromArray(t,i)}}const Ar=new w,XD=new w,YD=new Ce,ree=ne("debuggizmos"),Yc=8947848,Sa=class{static isGizmo(e){return e[vM]!==void 0}static DrawLabel(e,t,i=.05,s=0,r,o,a){var u;if(!Sa.enabled)return null;r||(r=Yc);const c=((u=vt.active)==null?void 0:u.rigScale)??1,l=Gn.getTextLabel(s,t,i*c,r,o);return a instanceof ge&&a.add(l),l.position.x=e.x,l.position.y=e.y,l.position.z=e.z,l}static DrawRay(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),Ar.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+Ar.x,e.y+Ar.y,e.z+Ar.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(e,t,i=Yc,s=0,r=!0,o=1){if(!Sa.enabled)return;const a=Gn.getLine(s),c=a.geometry.getAttribute("position");c.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(Ar.set(0,0,-o),YD.set(t.x,t.y,t.z,t.w),Ar.applyQuaternion(YD)):(Ar.set(t.x,t.y,t.z),Ar.multiplyScalar(o)),c.setXYZ(1,e.x+Ar.x,e.y+Ar.y,e.z+Ar.z),c.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireSphere(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getSphere(t,s,!0);Id(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawSphere(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getSphere(t,s,!1);Id(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getBox(s);o.position.set(e.x,e.y,e.z),o.scale.set(t.x,t.y,t.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1}static DrawWireBox3(e,t=Yc,i=0,s=!0){if(!Sa.enabled)return;const r=Gn.getBox(i);r.position.copy(e.getCenter(Ar)),r.scale.copy(e.getSize(Ar)),r.material.color.set(t),r.material.depthTest=s,r.material.wireframe=!0,r.material.depthWrite=!1}static DrawArrow(e,t,i=Yc,s=0,r=!0,o=!1){if(!Sa.enabled)return;const a=Gn.getArrowHead(s);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Ar.set(t.x,t.y,t.z).sub(XD.set(e.x,e.y,e.z)).normalize());const l=Ar.set(t.x,t.y,t.z).sub(XD.set(e.x,e.y,e.z)).length()*.1;a.scale.set(l,l,l),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(e,t,i,s,r)}};let It=Sa;h(It,"enabled",!0),h(It,"_up",new w(0,1,0));const oee=new Qi(1,1,1);function TR(n=null){const e=new _e(n??14540253),t=new lI(oee);return new Io(t,new Ln({color:e}))}const vM=Symbol("GizmoCache");class Gn{static ensureFont(){let e=Yr.FontLibrary.getFontFamily(this.familyName);if(!e){e=Yr.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{Yr.update()})}}static getTextLabel(e,t,i,s,r){this.ensureFont();let o=this.textLabelCache.pop(),a=1;r&&typeof r=="string"&&(r==null?void 0:r.length)>=8&&r.startsWith("#")?(a=parseInt(r.substring(7),16)/255,r=r.substring(0,7),ree&&console.log(r,a)):typeof r=="object"&&r.a!==void 0&&(a=r.a);const c={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:s,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre"};if(o)o.set(c);else{o=new oR(c);const l=this,u=o;u.setText=function(d){this.set({textContent:d}),l.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ot.Current,o,e,this.textLabelCache),o}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new Qi(1,1,1);t=new me(i)}return this.registerTimedObject(Ot.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new Dn;let i=t.geometry.getAttribute("position");i||(i=new tt(new Float32Array(2*3),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(Ot.Current,t,e,this.linesCache),t}static getSphere(e,t,i){let s=this.spheresCache.pop();return s||(s=new me(new za(1,8,8))),s.scale.set(e,e,e),s.material.wireframe=i,this.registerTimedObject(Ot.Current,s,t,this.spheresCache),s}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new me(new Pn(0,.5,1,8))),this.registerTimedObject(Ot.Current,t,e,this.arrowHeadsCache),t}static registerTimedObject(e,t,i,s){const r=this.contextBeforeRenderCallbacks.get(e),o=this.contextPostRenderCallbacks.get(e);if(r){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==r){const a=e.pre_render_callbacks.indexOf(r);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(r)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(o){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==o){const a=e.post_render_callbacks.indexOf(o);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(o)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[vM]=s,this.timedObjectsBuffer.push(t),this.timesBuffer.push(Ot.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static onBeforeRender(e,t){this.tmuiNeedsUpdate&&Yr.update();for(let i=0;i<t.length;i++){const s=t[i];if(e.mainCamera&&s instanceof Yr.MeshUIBaseElement){if(Pd(s))continue;const r=e.isInVR,o=!1,a=!r;vw(s,e.mainCamera,o,a)}}}static onPostRender(e,t,i){const s=e.time.realtimeSinceStartup;for(let r=t.length-1;r>=0;r--){const o=t[r];s>i[r]&&(t.splice(r,1),i.splice(r,1),o.removeFromParent(),Pd(o)!=!0&&o[vM].push(o))}}}h(Gn,"familyName","needle-gizmos"),h(Gn,"linesCache",[]),h(Gn,"spheresCache",[]),h(Gn,"boxesCache",[]),h(Gn,"arrowHeadsCache",[]),h(Gn,"textLabelCache",[]),h(Gn,"timedObjectsBuffer",new Array),h(Gn,"timesBuffer",new Array),h(Gn,"contextPostRenderCallbacks",new Map),h(Gn,"contextBeforeRenderCallbacks",new Map),h(Gn,"tmuiNeedsUpdate",!1);const Ss=ne("debuginput");var Cw=(n=>(n.Mouse="mouse",n.Touch="touch",n.Controller="controller",n.Hand="hand",n))(Cw||{}),nn=(n=>(n.PointerDown="pointerdown",n.PointerUp="pointerup",n.PointerMove="pointermove",n.KeyDown="keydown",n.KeyUp="keyup",n.KeyPressed="keypress",n))(nn||{});class ol extends PointerEvent{constructor(t,i,s){super(t,s);h(this,"deviceIndex");h(this,"origin");h(this,"source");h(this,"mode");h(this,"ray");h(this,"space");h(this,"isClick",!1);h(this,"isDoubleClick",!1);h(this,"_used",!1);h(this,"_pointerid");h(this,"_pointerType");h(this,"_type");h(this,"_immediatePropagationStopped",!1);h(this,"_propagationStopped",!1);this._pointerid=s.pointerId,this._pointerType=s.pointerType,this._type=t,this.deviceIndex=s.deviceIndex,this.origin=s.origin,this.source=i,this.mode=s.mode,this.ray=s.ray,this.space=s.device}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation()}}class Eg extends KeyboardEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class aee{constructor(e){h(this,"key");h(this,"keyType");h(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var ac=(n=>(n[n.Early=-100]="Early",n[n.Default=0]="Default",n[n.Late=100]="Late",n))(ac||{});class z4{constructor(e){h(this,"_eventListeners",{});h(this,"_doubleClickTimeThreshold",.2);h(this,"_longPressTimeThreshold",1);h(this,"_specialCursorTrigger",0);h(this,"context");h(this,"_pointerDown",[!1]);h(this,"_pointerUp",[!1]);h(this,"_pointerClick",[!1]);h(this,"_pointerDoubleClick",[!1]);h(this,"_pointerPressed",[!1]);h(this,"_pointerPositions",[new ie]);h(this,"_pointerPositionsLastFrame",[new ie]);h(this,"_pointerPositionsDelta",[new ie]);h(this,"_pointerPositionsRC",[new ie]);h(this,"_pointerPositionDown",[new ie]);h(this,"_pointerDownTime",[]);h(this,"_pointerUpTime",[]);h(this,"_pointerUpTimestamp",[]);h(this,"_pointerIds",[]);h(this,"_pointerTypes",[""]);h(this,"_mouseWheelChanged",[!1]);h(this,"_mouseWheelDeltaY",[0]);h(this,"_pointerEvent",[]);h(this,"_pointerUsed",[]);h(this,"_pointerSpace",[]);h(this,"_pressedStack",new Map);h(this,"_htmlEventSource");h(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1});h(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0});h(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType});h(this,"keysPressed",{});h(this,"onKeyDown",e=>{if(Ss&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new Eg("keydown",e,e);this.onDispatchEvent(i)});h(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new Eg("keypress",e,e);this.onDispatchEvent(i)});h(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new Eg("keyup",e,e);this.onDispatchEvent(i)});h(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY});h(this,"onTouchStartWindow",e=>{this.context.isInAR&&this.onTouchStart(e)});h(this,"onTouchStart",e=>{if(!(e.changedTouches.length<=0)&&this.canReceiveInput(e)!==!1)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier);Ss&&pn(`touch start #${s}, identifier:${i.identifier}`);const r=this.getAndUpdateSpatialObjectForScreenPosition(s,i.clientX,i.clientY),o=new ol("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onDown(o)}});h(this,"onTouchMove",e=>{if(!(e.changedTouches.length<=0))for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(s,i.clientX,i.clientY),o=new ol("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onMove(o)}});h(this,"onTouchUp",e=>{if(!(e.changedTouches.length<=0))for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier);if(!this.isNewEvent(e.timeStamp,s,this._pointerUpTimestamp))continue;const r=this.createPointerEventFromTouch("pointerup",i.identifier,i.clientX,i.clientY,i.force,e);this.onUp(r),this._pointerIds.splice(this._pointerIds.indexOf(s),1)}});h(this,"onTouchCancel",e=>{});h(this,"onMouseDown",e=>{if(this.onDownButton(0,e.button),this.context.isInVR||e.defaultPrevented||this.canReceiveInput(e)===!1)return;const t=e.button;let i="none";switch(t){case 0:i="left";break;case 1:i="middle";break;case 2:i="right";break}const s=0+t,r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=new ol("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:i,device:r,pressure:1});this.onDown(o)});h(this,"onMouseMove",e=>{if(this.context.isInVR||e.defaultPrevented)return;const t=this.getFirstPressedButtonForPointer(0),i=t??0,s=0+i,r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=t!==void 0?1:0,a=new ol("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:i,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:"none",device:r,pressure:o});this.onMove(a)});h(this,"onMouseUp",e=>{if(this.onReleaseButton(0,e.button),this.context.isInVR)return;const t=e.button;if(!this.isNewEvent(e.timeStamp,t,this._pointerUpTimestamp))return;let i="none";switch(t){case 0:i="left";break;case 1:i="middle";break;case 2:i="right";break}const s=0+t;if(e.defaultPrevented)return;const r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=new ol("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:i,device:r,pressure:0});this.onUp(o)});h(this,"tempNearPlaneVector",new w);h(this,"tempFarPlaneVector",new w);h(this,"tempLookMatrix",new xe);this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(e,t,i=0){this._eventListeners[e]||(this._eventListeners[e]=[]);const s=this._eventListeners[e],r=s.find(o=>o.priority===i);r?r.listeners.push(t):(s.push({priority:i,listeners:[t]}),s.sort((o,a)=>o.priority-a.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e])return;const s=this._eventListeners[e];if(i!==void 0){const r=s.find(a=>a.priority===i);if(!r)return;const o=r.listeners.indexOf(t);o>=0&&r.listeners.splice(o,1)}else for(const r of s){const o=r.listeners.indexOf(t);o>=0&&r.listeners.splice(o,1)}}dispatchEvent(e){let t=!1;if(e instanceof Eg){const i=this._eventListeners[e.type];if(i)for(const s of i)for(const r of s.listeners)r(e)}if(e instanceof ol){const i=this._eventListeners[e.type];if(i)for(const s of i){if(t)break;for(const r of s.listeners){if(e.immediatePropagationStopped){t=!0,Ss&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,Ss&&console.log("propagationStopped",e.type));r(e)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(e,t=!0){if(e>=this._pointerUsed.length){if(e>=this._pointerIds.length)return;for(;this._pointerUsed.length<=e;)this._pointerUsed.push(!1)}this._pointerUsed[e]=t}getPointerUsed(e){return e>=this._pointerUsed.length?!1:this._pointerUsed[e]}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let s=!1;for(const r of e)if(i===r){s=!0;break}if(!s)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const s=i.indexOf(t);s>=0&&i.splice(s,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.startFrame===this.context.time.frameCount)return t.key}return null}getKeyPressed(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.pressed)return t.key}return null}isKeyDown(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyDown(s))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[e].pressed}isKeyUp(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyUp(s))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[e].pressed}isKeyPressed(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyPressed(s))return!0;return!1}return(i=this.keysPressed[e])==null?void 0:i.pressed}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":Ss&&pn("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":Ss&&pn("Create Pointer move"),this.onMove(e);break;case"pointerup":Ss&&pn("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("touchstart",this.onTouchStart,!1),window.addEventListener("touchstart",this.onTouchStartWindow),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchUp,!1),window.addEventListener("touchcancel",this.onTouchCancel,!1),this._htmlEventSource.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var e,t,i;window.removeEventListener("contextmenu",this.onContextMenu),(e=this._htmlEventSource)==null||e.removeEventListener("touchstart",this.onTouchStart,!1),window.removeEventListener("touchstart",this.onTouchStartWindow),window.removeEventListener("touchmove",this.onTouchMove,!1),window.removeEventListener("touchend",this.onTouchUp,!1),window.removeEventListener("touchcancel",this.onTouchCancel,!1),(t=this._htmlEventSource)==null||t.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),(i=this._htmlEventSource)==null||i.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}canReceiveInput(e){var t;return!!(e.target===((t=this.context.renderer)==null?void 0:t.domElement)||e.target===this.context.domElement||this.context.isInAR&&e.target===document.body&&pd())}createPointerEventFromTouch(e,t,i,s,r,o){const a=this.getPointerIndex(t);Ss&&pn(`touch up #${a}, identifier:${t}`);const c=this.getAndUpdateSpatialObjectForScreenPosition(a,i,s);return new ol(e,o,{origin:this,mode:"screen",deviceIndex:0,pointerId:a,button:0,clientX:i,clientY:s,pointerType:"touch",buttonName:"unknown",device:c,pressure:r})}getAndUpdateSpatialObjectForScreenPosition(e,t,i){let s=this._pointerSpace[e];s||(s=new ge,this._pointerSpace[e]=s),this._pointerSpace[e]=s;const r=this.context.mainCamera;if(r){const o=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(o);const a=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(r),a.unproject(r),this.tempLookMatrix.lookAt(a,o,r.worldUp),s.position.set(o.x,o.y,o.z),s.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return s}isNewEvent(e,t,i){for(;i.length<=t;)i.push(-1);return e===i[t]?!1:(i[t]=e,!0)}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,s=e.clientY,r=i>=t.x&&i<=t.right&&s>=t.y&&s<=t.bottom;return Ss&&!r&&console.log("Not in rect",t,i,s),r}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)&&console.warn(`pointerId is already pressed: ${t}`,Ss?e:""),Ss&&console.log(e.pointerType,"DOWN",t),!!this.isInRect(e)&&!this.isMouseEventFromTouch(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new ie);for(this._pointerPositionDown[t].set(e.clientX,e.clientY);t>=this._pointerPositions.length;)this._pointerPositions.push(new ie);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.time,this.updatePointerPosition(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||this.isMouseEventFromTouch(e)||(Ss&&console.log(e.pointerType,"MOVE",t,"hasSpace="+e.space!=null),this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){Ss&&console.log(e.pointerType,"UP",t,"was not down");return}if(this.isMouseEventFromTouch(e))return;for(Ss&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0);t>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t,this._pointerUsed,!1),this.updatePointerPosition(e),!this._pointerPositionDown[t]){Ss&&gn("Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const s=e.clientX-this._pointerPositionDown[t].x,r=e.clientY-this._pointerPositionDown[t].y;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(s)<5&&Math.abs(r)<5){Ss&&console.log("CLICK",t),this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const o=this._pointerUpTime[t],a=this.context.time.time-o;a<this._doubleClickTimeThreshold&&a>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}this._pointerUpTime[t]=this.context.time.time,this.onDispatchEvent(e)}isMouseEventFromTouch(e){var t;if(e.pointerType==="mouse"){const i=this._pointerUpTimestamp.map((s,r)=>({timestamp:s,index:r})).sort((s,r)=>s.timestamp-r.timestamp).at(-1);if(i&&this._pointerTypes[i.index]==="touch"&&i.timestamp>0&&((t=e.source)==null?void 0:t.timeStamp)!==void 0){const s=e.source.timeStamp-i.timestamp;if(s<320&&s>=0)return Ss&&console.log("Ignoring mouse.down for touch.up"),!0}}return!1}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new ie);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new ie);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new ie);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const s=this._pointerPositionsDelta[t];let r=e.clientX-i.x,o=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const u=e.source;r===0&&u.movementX!==0&&(r=u.movementX||0),o===0&&u.movementY!==0&&(o=u.movementY||0)}s.x+=r,s.y+=o,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,c=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new ie);const l=this._pointerPositionsRC[t];l.set(a,c),this.convertScreenspaceToRaycastSpace(l)}getPointerIndex(e){const t=this._pointerIds;let i=-1;for(let s=0;s<t.length;s++){if(t[s]===e)return s;i===-1&&t[s]===-1&&(i=s)}return i!==-1?(t[i]=e,i):(t.push(e),t.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=Ot.Current;try{Ot.Current=this.context,this.dispatchEvent(e)}finally{Ot.Current=t}}}const qb=new xe().makeRotationY(Math.PI),Ma=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI),cee=ne("debugwebxr");class lee{constructor(){h(this,"priority",-1e5);h(this,"gameObject");if(this.gameObject=new ge,this.gameObject.name="Implicit XR Rig",cee){const e=TR(16733661);e.position.y+=.5,this.gameObject.add(e)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const uh=ne("debugwebxr"),Jm=ne("debugcustomgesture");let UC=!1;const hee="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",uee="generic-trigger";class IR{constructor(e,t,i){h(this,"xr");h(this,"inputSource");h(this,"index",0);h(this,"emitEvents",!0);h(this,"_connected",!0);h(this,"_isTracking",!1);h(this,"_hitTestSource");h(this,"_handJointPoses",new Map);h(this,"_gripPosition",new w);h(this,"_gripQuaternion",new Ce);h(this,"_linearVelocity",new w);h(this,"_rayPosition",new w);h(this,"_rayQuaternion",new Ce);h(this,"_gripWorldPosition",new w);h(this,"_gripWorldQuaternion",new Ce);h(this,"_rayWorldPosition",new w);h(this,"_rayWorldQuaternion",new Ce);h(this,"_ray");h(this,"_object");h(this,"_debugAxesHelper",new na(.2));h(this,"_needleGamepadButtons",{});h(this,"_buttonMap",new Map);h(this,"_motioncontroller");h(this,"_layout");h(this,"getMotionController");h(this,"_selectButtonIndex");h(this,"_squeezeButtonIndex");h(this,"onSelectStart",e=>{var s,r,o,a;if(this.inputSource!==e.inputSource)return;const t=(s=this._layout)==null?void 0:s.selectComponentId,i=(a=(o=(r=this._layout)==null?void 0:r.components[t])==null?void 0:o.gamepadIndices)==null?void 0:a.button;if(i!==void 0&&(this._selectButtonIndex=i),!Jm){if(!UC){UC=!0;const c=this.getGesture("pinch");if(c!=null&&c.pressed){console.warn("Select start event was received but the pinch gesture is already down. This might happen the first time you start pinching",this.index,this.side);return}}uh&&It.DrawDirection(this.rayWorldPosition,Vn(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(nn.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)}});h(this,"onSelectEnd",e=>{Jm||this.inputSource===e.inputSource&&this.emitPointerEvent(nn.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)});h(this,"onSequeezeStart",e=>{var t,i,s;this.inputSource===e.inputSource&&(this._squeezeButtonIndex=(s=(i=(t=this._layout)==null?void 0:t.components["xr-standard-squeeze"])==null?void 0:i.gamepadIndices)==null?void 0:s.button,this._squeezeButtonIndex!==void 0&&(uh&&It.DrawDirection(this.rayWorldPosition,Vn(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(nn.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)))});h(this,"onSequeezeEnd",e=>{this.inputSource===e.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(nn.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)});h(this,"states",{});h(this,"_didMoveLastFrame",!1);h(this,"_lastPointerMovePosition",new w);h(this,"_lastPointerMoveQuaternion",new Ce);h(this,"pointerInit");var s,r,o;this.xr=e,this.inputSource=t,this.index=i,this._object=new ge,uh&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new To,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((o=(r=(s=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:r.call(s,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(a=>this._hitTestSource=a))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(e){var i,s;if(!this.hand||!((i=this.xr.frame)!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let t=(s=this._handJointPoses)==null?void 0:s.get(e);return t||(t=this.xr.frame.getJointPose(e,this.xr.referenceSpace),t&&this._handJointPoses.set(e,t),t)}get gripPosition(){return Vn(this._gripPosition).applyMatrix4(qb)}get gripQuaternion(){return rd(this._gripQuaternion).premultiply(Ma)}get gripLinearVelocity(){return Vn(this._linearVelocity).applyQuaternion(Ma)}get rayPosition(){return Vn(this._rayPosition).applyMatrix4(qb)}get rayQuaternion(){return rd(this._rayQuaternion).premultiply(Ma)}get gripWorldPosition(){return Vn(this._gripWorldPosition)}get gripWorldQuaternion(){return rd(this._gripWorldQuaternion)}get rayWorldPosition(){return Vn(this._rayWorldPosition)}updateRayWorldPosition(){var t;const e=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return rd(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var i;const e=(i=this.xr.context.mainCamera)==null?void 0:i.parent,t=e?Oi(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(Ma),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(Vn(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var e;return(e=this.getMotionController)==null?void 0:e.then(t=>(t==null?void 0:t.assetUrl)||null)}onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var s;It.DrawWireSphere(this.rayWorldPosition,.02),It.DrawDirection(this.rayWorldPosition,Vn(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),t=this.inputSource.profiles.join(`
|
|
4919
|
+
*/var W$=function(n){return n!=null&&(D4(n)||q$(n)||!!n._isBuffer)};function D4(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function q$(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&D4(n.slice(0,0))}(function(){var n=j$,e=qD.utf8,t=W$,i=qD.bin,s=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=n.bytesToWords(r),c=r.length*8,l=1732584193,u=-271733879,d=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var m=s._ff,g=s._gg,y=s._hh,v=s._ii,p=0;p<a.length;p+=16){var A=l,_=u,b=d,C=f;l=m(l,u,d,f,a[p+0],7,-680876936),f=m(f,l,u,d,a[p+1],12,-389564586),d=m(d,f,l,u,a[p+2],17,606105819),u=m(u,d,f,l,a[p+3],22,-1044525330),l=m(l,u,d,f,a[p+4],7,-176418897),f=m(f,l,u,d,a[p+5],12,1200080426),d=m(d,f,l,u,a[p+6],17,-1473231341),u=m(u,d,f,l,a[p+7],22,-45705983),l=m(l,u,d,f,a[p+8],7,1770035416),f=m(f,l,u,d,a[p+9],12,-1958414417),d=m(d,f,l,u,a[p+10],17,-42063),u=m(u,d,f,l,a[p+11],22,-1990404162),l=m(l,u,d,f,a[p+12],7,1804603682),f=m(f,l,u,d,a[p+13],12,-40341101),d=m(d,f,l,u,a[p+14],17,-1502002290),u=m(u,d,f,l,a[p+15],22,1236535329),l=g(l,u,d,f,a[p+1],5,-165796510),f=g(f,l,u,d,a[p+6],9,-1069501632),d=g(d,f,l,u,a[p+11],14,643717713),u=g(u,d,f,l,a[p+0],20,-373897302),l=g(l,u,d,f,a[p+5],5,-701558691),f=g(f,l,u,d,a[p+10],9,38016083),d=g(d,f,l,u,a[p+15],14,-660478335),u=g(u,d,f,l,a[p+4],20,-405537848),l=g(l,u,d,f,a[p+9],5,568446438),f=g(f,l,u,d,a[p+14],9,-1019803690),d=g(d,f,l,u,a[p+3],14,-187363961),u=g(u,d,f,l,a[p+8],20,1163531501),l=g(l,u,d,f,a[p+13],5,-1444681467),f=g(f,l,u,d,a[p+2],9,-51403784),d=g(d,f,l,u,a[p+7],14,1735328473),u=g(u,d,f,l,a[p+12],20,-1926607734),l=y(l,u,d,f,a[p+5],4,-378558),f=y(f,l,u,d,a[p+8],11,-2022574463),d=y(d,f,l,u,a[p+11],16,1839030562),u=y(u,d,f,l,a[p+14],23,-35309556),l=y(l,u,d,f,a[p+1],4,-1530992060),f=y(f,l,u,d,a[p+4],11,1272893353),d=y(d,f,l,u,a[p+7],16,-155497632),u=y(u,d,f,l,a[p+10],23,-1094730640),l=y(l,u,d,f,a[p+13],4,681279174),f=y(f,l,u,d,a[p+0],11,-358537222),d=y(d,f,l,u,a[p+3],16,-722521979),u=y(u,d,f,l,a[p+6],23,76029189),l=y(l,u,d,f,a[p+9],4,-640364487),f=y(f,l,u,d,a[p+12],11,-421815835),d=y(d,f,l,u,a[p+15],16,530742520),u=y(u,d,f,l,a[p+2],23,-995338651),l=v(l,u,d,f,a[p+0],6,-198630844),f=v(f,l,u,d,a[p+7],10,1126891415),d=v(d,f,l,u,a[p+14],15,-1416354905),u=v(u,d,f,l,a[p+5],21,-57434055),l=v(l,u,d,f,a[p+12],6,1700485571),f=v(f,l,u,d,a[p+3],10,-1894986606),d=v(d,f,l,u,a[p+10],15,-1051523),u=v(u,d,f,l,a[p+1],21,-2054922799),l=v(l,u,d,f,a[p+8],6,1873313359),f=v(f,l,u,d,a[p+15],10,-30611744),d=v(d,f,l,u,a[p+6],15,-1560198380),u=v(u,d,f,l,a[p+13],21,1309151649),l=v(l,u,d,f,a[p+4],6,-145523070),f=v(f,l,u,d,a[p+11],10,-1120210379),d=v(d,f,l,u,a[p+2],15,718787259),u=v(u,d,f,l,a[p+9],21,-343485551),l=l+A>>>0,u=u+_>>>0,d=d+b>>>0,f=f+C>>>0}return n.endian([l,u,d,f])};s._ff=function(r,o,a,c,l,u,d){var f=r+(o&a|~o&c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._gg=function(r,o,a,c,l,u,d){var f=r+(o&c|a&~c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._hh=function(r,o,a,c,l,u,d){var f=r+(o^a^c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._ii=function(r,o,a,c,l,u,d){var f=r+(a^(o|~c))+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._blocksize=16,s._digestsize=16,P4.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=n.wordsToBytes(s(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):n.bytesToHex(a)}})();var X$=P4.exports;const Y$=Sw(X$);class gM{constructor(e,t,i,s){h(this,"success");h(this,"filename");h(this,"hash");h(this,"size");h(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=s}}async function O4(n,e){const t=await n.arrayBuffer(),i=ER(t),s=n.name.split(".").pop(),r=i+"."+s,o=n.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",i),new gM(!0,r,i,n.size);console.log("begin uploading file",o,n.size);const u=new FormData;u.append("file",n);const d={};d.filesize=n.size,o&&(d.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:u,headers:d})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new gM(p.success,r,i,n.size);return m.url=e,m}function ER(n){return Y$(new Uint8Array(n))}async function MR(n,e,t,i,s=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:n});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();s||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const c=ER(a);return s||console.assert(c===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function k4(n,e){var u;const t=await fetch(n),i=(u=t.body)==null?void 0:u.getReader(),s=t.headers.get("Content-Length"),r=s?parseInt(s):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:d,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),d)break}const c=new Uint8Array(o);let l=0;for(const d of a)c.set(d,l),l+=d.length;return c}const hh=ne("debugaddressables");class L4{constructor(e){h(this,"_context");h(this,"_assetReferences",{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t==null||t.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const FC=Symbol("assetReference"),mp=class{constructor(e,t,i=null){h(this,"_loading");h(this,"_asset");h(this,"_glbRoot");h(this,"_url");h(this,"_progressListeners",[]);h(this,"_hash");h(this,"_hashedUri");h(this,"_isLoadingRawBinary",!1);h(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),hG(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Ot.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const s=Vl(e,t);hh&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new mp(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Pd(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(hh&&console.log("Unload",this.asset),this.asset.scene&&Fa(this.asset.scene,!0,!0),Fa(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,hh&&console.log("Preload",this._hashedUri);const e=await k4(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(hh&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading.then(s=>this.asset);const t=Ot.Current;this._rawBinary?(this._loading=La().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(hh&&console.log("Load async",this.uri),this._loading=La().loadSync(t,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[FC]=this,this._glbRoot&&(this._glbRoot[FC]=this),this.asset&&(this.asset[FC]=this),Hb(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const s=Ot.Current,r=new Ha;if(e instanceof ge?r.parent=e:e&&r.cloneAssign(e),r.parent||(r.parent=s.scene),this.mustLoad&&await this.loadAssetAsync(),hh&&console.log("Instantiate",this.uri,"parent:",e),this.asset){hh&&console.log("Add to scene",this.asset);let o=mp.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,mp.currentlyInstantiating.set(this.uri,o),t){r.context=s;const a=this.asset;a.guid=this.uri;const c=HR(a,r,void 0,i);if(c)return c}else{const a=hm(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,mp.currentlyInstantiating.set(this.uri,o)})}}else hh&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let ii=mp;h(ii,"currentlyInstantiating",new Map);class J$ extends Oc{constructor(){super([ii],"AssetReferenceSerializer")}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?ii.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ge){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,s=t.context,r=i.guid??i.uuid,o=s.addressables.findAssetReference(r);if(o)return o;const a=new ii(r,void 0,i);return s.addressables.registerAssetReference(a),a}return null}}new J$;const K$=Promise.resolve(null),fv=class{constructor(e){h(this,"url");h(this,"_bitmap");h(this,"_bitmapObject");h(this,"loader",null);this.url=e}static getOrCreate(e){let t=fv.imageReferences.get(e);return t||(t=new fv(e),fv.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new wl),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):K$}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,e(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),e(null)}),i.src=this.url}),this._bitmap)}};let xp=fv;h(xp,"imageReferences",new Map);class F4 extends Oc{constructor(){super([xp],"ImageReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=Vl(t.gltfId,e);return xp.getOrCreate(i)}}}new F4;const pv=class{constructor(e){h(this,"url");h(this,"res");this.url=e}static getOrCreate(e){let t=pv.cache.get(e);return t||(t=new pv(e),pv.cache.set(e,t)),t}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(e=>e.text())}};let wp=pv;h(wp,"cache",new Map);class U4 extends Oc{constructor(){super([wp],"FileReferenceSerializer")}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=Vl(t.gltfId,e);return wp.getOrCreate(i)}}}new U4;const fs={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function N4(n){const e=await fetch(n);if(e.ok)return e.json();throw new Error(e.statusText)}async function Z$(n){if(!n)throw new Error("No basePath supplied");return await N4(`${n}/profilesList.json`)}async function $$(n,e,t=null,i=!0){if(!n)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const s=await Z$(e);let r;if(n.profiles.some(c=>{const l=s[c];return l&&(r={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!r}),!r){if(!t)throw new Error("No matching profile name found");const c=s[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);r={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const o=await N4(r.profilePath);let a;if(i){let c;if(n.handedness==="any"?c=o.layouts[Object.keys(o.layouts)[0]]:c=o.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${r.profileId}`);c.assetPath&&(a=r.profilePath.replace("profile.json",c.assetPath))}return{profile:o,assetPath:a}}const eee={xAxis:0,yAxis:0,button:0,state:fs.ComponentState.DEFAULT};function tee(n=0,e=0){let t=n,i=e;if(Math.sqrt(n*n+e*e)>1){const o=Math.atan2(e,n);t=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:i*.5+.5}}let iee=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fs.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(eee)}updateFromComponent({xAxis:e,yAxis:t,button:i,state:s}){const{normalizedXAxis:r,normalizedYAxis:o}=tee(e,t);switch(this.componentProperty){case fs.ComponentProperty.X_AXIS:this.value=this.states.includes(s)?r:.5;break;case fs.ComponentProperty.Y_AXIS:this.value=this.states.includes(s)?o:.5;break;case fs.ComponentProperty.BUTTON:this.value=this.states.includes(s)?i:0;break;case fs.ComponentProperty.STATE:this.valueNodeProperty===fs.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(s):this.value=this.states.includes(s)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},nee=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(i=>{const s=new iee(t.visualResponses[i]);this.visualResponses[i]=s}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fs.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fs.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=fs.ComponentState.PRESSED:(t.touched||this.values.button>fs.ButtonTouchThreshold)&&(this.values.state=fs.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fs.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fs.AxisTouchThreshold&&(this.values.state=fs.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fs.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fs.AxisTouchThreshold&&(this.values.state=fs.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}},see=class{constructor(e,t,i){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=i,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(s=>{const r=this.layoutDescription.components[s];this.components[s]=new nee(s,r)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}};class Ri extends _e{constructor(t,i,s,r){super(t,i,s);h(this,"alpha",1);this.alpha=r}get isRGBAColor(){return!0}set a(t){this.alpha=t}get a(){return this.alpha}clone(){const t=super.clone();return t.alpha=this.alpha,t}copy(t){return super.copy(t),"alpha"in t&&typeof t.alpha=="number"?this.alpha=t.alpha:typeof t.a=="number"&&(this.alpha=t.a),this}lerp(t,i){const s=t;return s.alpha&&(this.alpha=rt.lerp(this.alpha,s.alpha,i)),super.lerp(t,i)}lerpColors(t,i,s){const r=t,o=i;return r.alpha&&o.alpha&&(this.alpha=rt.lerp(r.alpha,o.alpha,s)),super.lerpColors(t,i,s)}multiply(t){const i=t;return i.alpha&&(this.alpha=this.alpha*i.alpha),super.multiply(t)}fromArray(t,i=0){return this.alpha=t[i+3],super.fromArray(t,i)}}const Ar=new w,XD=new w,YD=new Ce,ree=ne("debuggizmos"),Yc=8947848,Sa=class{static isGizmo(e){return e[vM]!==void 0}static DrawLabel(e,t,i=.05,s=0,r,o,a){var u;if(!Sa.enabled)return null;r||(r=Yc);const c=((u=vt.active)==null?void 0:u.rigScale)??1,l=Gn.getTextLabel(s,t,i*c,r,o);return a instanceof ge&&a.add(l),l.position.x=e.x,l.position.y=e.y,l.position.z=e.z,l}static DrawRay(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),Ar.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+Ar.x,e.y+Ar.y,e.z+Ar.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(e,t,i=Yc,s=0,r=!0,o=1){if(!Sa.enabled)return;const a=Gn.getLine(s),c=a.geometry.getAttribute("position");c.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(Ar.set(0,0,-o),YD.set(t.x,t.y,t.z,t.w),Ar.applyQuaternion(YD)):(Ar.set(t.x,t.y,t.z),Ar.multiplyScalar(o)),c.setXYZ(1,e.x+Ar.x,e.y+Ar.y,e.z+Ar.z),c.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireSphere(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getSphere(t,s,!0);Id(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawSphere(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getSphere(t,s,!1);Id(o,e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(e,t,i=Yc,s=0,r=!0){if(!Sa.enabled)return;const o=Gn.getBox(s);o.position.set(e.x,e.y,e.z),o.scale.set(t.x,t.y,t.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1}static DrawWireBox3(e,t=Yc,i=0,s=!0){if(!Sa.enabled)return;const r=Gn.getBox(i);r.position.copy(e.getCenter(Ar)),r.scale.copy(e.getSize(Ar)),r.material.color.set(t),r.material.depthTest=s,r.material.wireframe=!0,r.material.depthWrite=!1}static DrawArrow(e,t,i=Yc,s=0,r=!0,o=!1){if(!Sa.enabled)return;const a=Gn.getArrowHead(s);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Ar.set(t.x,t.y,t.z).sub(XD.set(e.x,e.y,e.z)).normalize());const l=Ar.set(t.x,t.y,t.z).sub(XD.set(e.x,e.y,e.z)).length()*.1;a.scale.set(l,l,l),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(e,t,i,s,r)}};let It=Sa;h(It,"enabled",!0),h(It,"_up",new w(0,1,0));const oee=new Qi(1,1,1);function TR(n=null){const e=new _e(n??14540253),t=new lI(oee);return new Io(t,new Ln({color:e}))}const vM=Symbol("GizmoCache");class Gn{static ensureFont(){let e=Yr.FontLibrary.getFontFamily(this.familyName);if(!e){e=Yr.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{Yr.update()})}}static getTextLabel(e,t,i,s,r){this.ensureFont();let o=this.textLabelCache.pop(),a=1;r&&typeof r=="string"&&(r==null?void 0:r.length)>=8&&r.startsWith("#")?(a=parseInt(r.substring(7),16)/255,r=r.substring(0,7),ree&&console.log(r,a)):typeof r=="object"&&r.a!==void 0&&(a=r.a);const c={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:s,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre"};if(o)o.set(c);else{o=new oR(c);const l=this,u=o;u.setText=function(d){this.set({textContent:d}),l.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Ot.Current,o,e,this.textLabelCache),o}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new Qi(1,1,1);t=new me(i)}return this.registerTimedObject(Ot.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new Dn;let i=t.geometry.getAttribute("position");i||(i=new tt(new Float32Array(2*3),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(Ot.Current,t,e,this.linesCache),t}static getSphere(e,t,i){let s=this.spheresCache.pop();return s||(s=new me(new za(1,8,8))),s.scale.set(e,e,e),s.material.wireframe=i,this.registerTimedObject(Ot.Current,s,t,this.spheresCache),s}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new me(new Pn(0,.5,1,8))),this.registerTimedObject(Ot.Current,t,e,this.arrowHeadsCache),t}static registerTimedObject(e,t,i,s){const r=this.contextBeforeRenderCallbacks.get(e),o=this.contextPostRenderCallbacks.get(e);if(r){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==r){const a=e.pre_render_callbacks.indexOf(r);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(r)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(o){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==o){const a=e.post_render_callbacks.indexOf(o);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(o)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[vM]=s,this.timedObjectsBuffer.push(t),this.timesBuffer.push(Ot.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static onBeforeRender(e,t){this.tmuiNeedsUpdate&&Yr.update();for(let i=0;i<t.length;i++){const s=t[i];if(e.mainCamera&&s instanceof Yr.MeshUIBaseElement){if(Pd(s))continue;const r=e.isInVR,o=!1,a=!r;vw(s,e.mainCamera,o,a)}}}static onPostRender(e,t,i){const s=e.time.realtimeSinceStartup;for(let r=t.length-1;r>=0;r--){const o=t[r];s>i[r]&&(t.splice(r,1),i.splice(r,1),o.removeFromParent(),Pd(o)!=!0&&o[vM].push(o))}}}h(Gn,"familyName","needle-gizmos"),h(Gn,"linesCache",[]),h(Gn,"spheresCache",[]),h(Gn,"boxesCache",[]),h(Gn,"arrowHeadsCache",[]),h(Gn,"textLabelCache",[]),h(Gn,"timedObjectsBuffer",new Array),h(Gn,"timesBuffer",new Array),h(Gn,"contextPostRenderCallbacks",new Map),h(Gn,"contextBeforeRenderCallbacks",new Map),h(Gn,"tmuiNeedsUpdate",!1);const Ss=ne("debuginput");var Cw=(n=>(n.Mouse="mouse",n.Touch="touch",n.Controller="controller",n.Hand="hand",n))(Cw||{}),nn=(n=>(n.PointerDown="pointerdown",n.PointerUp="pointerup",n.PointerMove="pointermove",n.KeyDown="keydown",n.KeyUp="keyup",n.KeyPressed="keypress",n))(nn||{});class ol extends PointerEvent{constructor(t,i,s){super(t,s);h(this,"deviceIndex");h(this,"origin");h(this,"source");h(this,"mode");h(this,"ray");h(this,"space");h(this,"isClick",!1);h(this,"isDoubleClick",!1);h(this,"_used",!1);h(this,"_pointerid");h(this,"_pointerType");h(this,"_type");h(this,"_immediatePropagationStopped",!1);h(this,"_propagationStopped",!1);this._pointerid=s.pointerId,this._pointerType=s.pointerType,this._type=t,this.deviceIndex=s.deviceIndex,this.origin=s.origin,this.source=i,this.mode=s.mode,this.ray=s.ray,this.space=s.device}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation()}}class Eg extends KeyboardEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class aee{constructor(e){h(this,"key");h(this,"keyType");h(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var ac=(n=>(n[n.Early=-100]="Early",n[n.Default=0]="Default",n[n.Late=100]="Late",n))(ac||{});class z4{constructor(e){h(this,"_eventListeners",{});h(this,"_doubleClickTimeThreshold",.2);h(this,"_longPressTimeThreshold",1);h(this,"_specialCursorTrigger",0);h(this,"context");h(this,"_pointerDown",[!1]);h(this,"_pointerUp",[!1]);h(this,"_pointerClick",[!1]);h(this,"_pointerDoubleClick",[!1]);h(this,"_pointerPressed",[!1]);h(this,"_pointerPositions",[new ie]);h(this,"_pointerPositionsLastFrame",[new ie]);h(this,"_pointerPositionsDelta",[new ie]);h(this,"_pointerPositionsRC",[new ie]);h(this,"_pointerPositionDown",[new ie]);h(this,"_pointerDownTime",[]);h(this,"_pointerUpTime",[]);h(this,"_pointerUpTimestamp",[]);h(this,"_pointerIds",[]);h(this,"_pointerTypes",[""]);h(this,"_mouseWheelChanged",[!1]);h(this,"_mouseWheelDeltaY",[0]);h(this,"_pointerEvent",[]);h(this,"_pointerUsed",[]);h(this,"_pointerSpace",[]);h(this,"_pressedStack",new Map);h(this,"_htmlEventSource");h(this,"onLostFocus",()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1});h(this,"onEndOfFrame",()=>{for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0});h(this,"onContextMenu",e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType});h(this,"keysPressed",{});h(this,"onKeyDown",e=>{if(Ss&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new Eg("keydown",e,e);this.onDispatchEvent(i)});h(this,"onKeyPressed",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new Eg("keypress",e,e);this.onDispatchEvent(i)});h(this,"onKeyUp",e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new Eg("keyup",e,e);this.onDispatchEvent(i)});h(this,"onMouseWheel",e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY});h(this,"onTouchStartWindow",e=>{this.context.isInAR&&this.onTouchStart(e)});h(this,"onTouchStart",e=>{if(!(e.changedTouches.length<=0)&&this.canReceiveInput(e)!==!1)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier);Ss&&pn(`touch start #${s}, identifier:${i.identifier}`);const r=this.getAndUpdateSpatialObjectForScreenPosition(s,i.clientX,i.clientY),o=new ol("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onDown(o)}});h(this,"onTouchMove",e=>{if(!(e.changedTouches.length<=0))for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier),r=this.getAndUpdateSpatialObjectForScreenPosition(s,i.clientX,i.clientY),o=new ol("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:r,pressure:i.force});this.onMove(o)}});h(this,"onTouchUp",e=>{if(!(e.changedTouches.length<=0))for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],s=this.getPointerIndex(i.identifier);if(!this.isNewEvent(e.timeStamp,s,this._pointerUpTimestamp))continue;const r=this.createPointerEventFromTouch("pointerup",i.identifier,i.clientX,i.clientY,i.force,e);this.onUp(r),this._pointerIds.splice(this._pointerIds.indexOf(s),1)}});h(this,"onTouchCancel",e=>{});h(this,"onMouseDown",e=>{if(this.onDownButton(0,e.button),this.context.isInVR||e.defaultPrevented||this.canReceiveInput(e)===!1)return;const t=e.button;let i="none";switch(t){case 0:i="left";break;case 1:i="middle";break;case 2:i="right";break}const s=0+t,r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=new ol("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:i,device:r,pressure:1});this.onDown(o)});h(this,"onMouseMove",e=>{if(this.context.isInVR||e.defaultPrevented)return;const t=this.getFirstPressedButtonForPointer(0),i=t??0,s=0+i,r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=t!==void 0?1:0,a=new ol("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:i,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:"none",device:r,pressure:o});this.onMove(a)});h(this,"onMouseUp",e=>{if(this.onReleaseButton(0,e.button),this.context.isInVR)return;const t=e.button;if(!this.isNewEvent(e.timeStamp,t,this._pointerUpTimestamp))return;let i="none";switch(t){case 0:i="left";break;case 1:i="middle";break;case 2:i="right";break}const s=0+t;if(e.defaultPrevented)return;const r=this.getAndUpdateSpatialObjectForScreenPosition(s,e.clientX,e.clientY),o=new ol("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:"mouse",buttonName:i,device:r,pressure:0});this.onUp(o)});h(this,"tempNearPlaneVector",new w);h(this,"tempFarPlaneVector",new w);h(this,"tempLookMatrix",new xe);this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(e,t,i){this._eventListeners[e]||(this._eventListeners[e]=[]);let s=0;(i==null?void 0:i.queue)!=null&&(s=i.queue);const r=this._eventListeners[e],o=r.find(a=>a.priority===s);o?o.listeners.push(t):(r.push({priority:s,listeners:[t]}),r.sort((a,c)=>a.priority-c.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e])return;const s=this._eventListeners[e];if((i==null?void 0:i.queue)!=null){const r=s.find(a=>a.priority===i.queue);if(!r)return;const o=r.listeners.indexOf(t);o>=0&&r.listeners.splice(o,1)}else for(const r of s){const o=r.listeners.indexOf(t);o>=0&&r.listeners.splice(o,1)}}dispatchEvent(e){let t=!1;if(e instanceof Eg){const i=this._eventListeners[e.type];if(i)for(const s of i)for(const r of s.listeners)r(e)}if(e instanceof ol){const i=this._eventListeners[e.type];if(i)for(const s of i){if(t)break;for(const r of s.listeners){if(e.immediatePropagationStopped){t=!0,Ss&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,Ss&&console.log("propagationStopped",e.type));r(e)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(e,t=!0){if(e>=this._pointerUsed.length){if(e>=this._pointerIds.length)return;for(;this._pointerUsed.length<=e;)this._pointerUsed.push(!1)}this._pointerUsed[e]=t}getPointerUsed(e){return e>=this._pointerUsed.length?!1:this._pointerUsed[e]}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let s=!1;for(const r of e)if(i===r){s=!0;break}if(!s)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const s=i.indexOf(t);s>=0&&i.splice(s,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.startFrame===this.context.time.frameCount)return t.key}return null}getKeyPressed(){for(const e in this.keysPressed){const t=this.keysPressed[e];if(t.pressed)return t.key}return null}isKeyDown(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyDown(s))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[e].pressed}isKeyUp(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyUp(s))return!0;return!1}return((i=this.keysPressed[e])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[e].pressed}isKeyPressed(e){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const s of t)if(this.isKeyPressed(s))return!0;return!1}return(i=this.keysPressed[e])==null?void 0:i.pressed}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":Ss&&pn("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":Ss&&pn("Create Pointer move"),this.onMove(e);break;case"pointerup":Ss&&pn("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("touchstart",this.onTouchStart,!1),window.addEventListener("touchstart",this.onTouchStartWindow),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchUp,!1),window.addEventListener("touchcancel",this.onTouchCancel,!1),this._htmlEventSource.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var e,t,i;window.removeEventListener("contextmenu",this.onContextMenu),(e=this._htmlEventSource)==null||e.removeEventListener("touchstart",this.onTouchStart,!1),window.removeEventListener("touchstart",this.onTouchStartWindow),window.removeEventListener("touchmove",this.onTouchMove,!1),window.removeEventListener("touchend",this.onTouchUp,!1),window.removeEventListener("touchcancel",this.onTouchCancel,!1),(t=this._htmlEventSource)==null||t.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),(i=this._htmlEventSource)==null||i.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}canReceiveInput(e){var t;return!!(e.target===((t=this.context.renderer)==null?void 0:t.domElement)||e.target===this.context.domElement||this.context.isInAR&&e.target===document.body&&pd())}createPointerEventFromTouch(e,t,i,s,r,o){const a=this.getPointerIndex(t);Ss&&pn(`touch up #${a}, identifier:${t}`);const c=this.getAndUpdateSpatialObjectForScreenPosition(a,i,s);return new ol(e,o,{origin:this,mode:"screen",deviceIndex:0,pointerId:a,button:0,clientX:i,clientY:s,pointerType:"touch",buttonName:"unknown",device:c,pressure:r})}getAndUpdateSpatialObjectForScreenPosition(e,t,i){let s=this._pointerSpace[e];s||(s=new ge,this._pointerSpace[e]=s),this._pointerSpace[e]=s;const r=this.context.mainCamera;if(r){const o=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(o);const a=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(r),a.unproject(r),this.tempLookMatrix.lookAt(a,o,r.worldUp),s.position.set(o.x,o.y,o.z),s.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return s}isNewEvent(e,t,i){for(;i.length<=t;)i.push(-1);return e===i[t]?!1:(i[t]=e,!0)}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,s=e.clientY,r=i>=t.x&&i<=t.right&&s>=t.y&&s<=t.bottom;return Ss&&!r&&console.log("Not in rect",t,i,s),r}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)&&console.warn(`pointerId is already pressed: ${t}`,Ss?e:""),Ss&&console.log(e.pointerType,"DOWN",t),!!this.isInRect(e)&&!this.isMouseEventFromTouch(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new ie);for(this._pointerPositionDown[t].set(e.clientX,e.clientY);t>=this._pointerPositions.length;)this._pointerPositions.push(new ie);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.time,this.updatePointerPosition(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||this.isMouseEventFromTouch(e)||(Ss&&console.log(e.pointerType,"MOVE",t,"hasSpace="+e.space!=null),this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){Ss&&console.log(e.pointerType,"UP",t,"was not down");return}if(this.isMouseEventFromTouch(e))return;for(Ss&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0);t>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t,this._pointerUsed,!1),this.updatePointerPosition(e),!this._pointerPositionDown[t]){Ss&&gn("Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const s=e.clientX-this._pointerPositionDown[t].x,r=e.clientY-this._pointerPositionDown[t].y;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(s)<5&&Math.abs(r)<5){Ss&&console.log("CLICK",t),this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const o=this._pointerUpTime[t],a=this.context.time.time-o;a<this._doubleClickTimeThreshold&&a>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}this._pointerUpTime[t]=this.context.time.time,this.onDispatchEvent(e)}isMouseEventFromTouch(e){var t;if(e.pointerType==="mouse"){const i=this._pointerUpTimestamp.map((s,r)=>({timestamp:s,index:r})).sort((s,r)=>s.timestamp-r.timestamp).at(-1);if(i&&this._pointerTypes[i.index]==="touch"&&i.timestamp>0&&((t=e.source)==null?void 0:t.timeStamp)!==void 0){const s=e.source.timeStamp-i.timestamp;if(s<320&&s>=0)return Ss&&console.log("Ignoring mouse.down for touch.up"),!0}}return!1}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new ie);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new ie);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new ie);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const s=this._pointerPositionsDelta[t];let r=e.clientX-i.x,o=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const u=e.source;r===0&&u.movementX!==0&&(r=u.movementX||0),o===0&&u.movementY!==0&&(o=u.movementY||0)}s.x+=r,s.y+=o,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,c=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new ie);const l=this._pointerPositionsRC[t];l.set(a,c),this.convertScreenspaceToRaycastSpace(l)}getPointerIndex(e){const t=this._pointerIds;let i=-1;for(let s=0;s<t.length;s++){if(t[s]===e)return s;i===-1&&t[s]===-1&&(i=s)}return i!==-1?(t[i]=e,i):(t.push(e),t.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=Ot.Current;try{Ot.Current=this.context,this.dispatchEvent(e)}finally{Ot.Current=t}}}const qb=new xe().makeRotationY(Math.PI),Ma=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI),cee=ne("debugwebxr");class lee{constructor(){h(this,"priority",-1e5);h(this,"gameObject");if(this.gameObject=new ge,this.gameObject.name="Implicit XR Rig",cee){const e=TR(16733661);e.position.y+=.5,this.gameObject.add(e)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const uh=ne("debugwebxr"),Jm=ne("debugcustomgesture");let UC=!1;const hee="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",uee="generic-trigger";class IR{constructor(e,t,i){h(this,"xr");h(this,"inputSource");h(this,"index",0);h(this,"emitEvents",!0);h(this,"_connected",!0);h(this,"_isTracking",!1);h(this,"_hitTestSource");h(this,"_handJointPoses",new Map);h(this,"_gripPosition",new w);h(this,"_gripQuaternion",new Ce);h(this,"_linearVelocity",new w);h(this,"_rayPosition",new w);h(this,"_rayQuaternion",new Ce);h(this,"_gripWorldPosition",new w);h(this,"_gripWorldQuaternion",new Ce);h(this,"_rayWorldPosition",new w);h(this,"_rayWorldQuaternion",new Ce);h(this,"_ray");h(this,"_object");h(this,"_debugAxesHelper",new na(.2));h(this,"_needleGamepadButtons",{});h(this,"_buttonMap",new Map);h(this,"_motioncontroller");h(this,"_layout");h(this,"getMotionController");h(this,"_selectButtonIndex");h(this,"_squeezeButtonIndex");h(this,"onSelectStart",e=>{var s,r,o,a;if(this.inputSource!==e.inputSource)return;const t=(s=this._layout)==null?void 0:s.selectComponentId,i=(a=(o=(r=this._layout)==null?void 0:r.components[t])==null?void 0:o.gamepadIndices)==null?void 0:a.button;if(i!==void 0&&(this._selectButtonIndex=i),!Jm){if(!UC){UC=!0;const c=this.getGesture("pinch");if(c!=null&&c.pressed){console.warn("Select start event was received but the pinch gesture is already down. This might happen the first time you start pinching",this.index,this.side);return}}uh&&It.DrawDirection(this.rayWorldPosition,Vn(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(nn.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)}});h(this,"onSelectEnd",e=>{Jm||this.inputSource===e.inputSource&&this.emitPointerEvent(nn.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,e)});h(this,"onSequeezeStart",e=>{var t,i,s;this.inputSource===e.inputSource&&(this._squeezeButtonIndex=(s=(i=(t=this._layout)==null?void 0:t.components["xr-standard-squeeze"])==null?void 0:i.gamepadIndices)==null?void 0:s.button,this._squeezeButtonIndex!==void 0&&(uh&&It.DrawDirection(this.rayWorldPosition,Vn(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(nn.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)))});h(this,"onSequeezeEnd",e=>{this.inputSource===e.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(nn.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,e)});h(this,"states",{});h(this,"_didMoveLastFrame",!1);h(this,"_lastPointerMovePosition",new w);h(this,"_lastPointerMoveQuaternion",new Ce);h(this,"pointerInit");var s,r,o;this.xr=e,this.inputSource=t,this.index=i,this._object=new ge,uh&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new To,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents(),this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&((o=(r=(s=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:r.call(s,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(a=>this._hitTestSource=a))}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.inputSource.gamepad}get isHand(){return this.inputSource.hand!=null}get hand(){return this.inputSource.hand}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.inputSource.handedness}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get hitTestSource(){return this._hitTestSource}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(e){var i,s;if(!this.hand||!((i=this.xr.frame)!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let t=(s=this._handJointPoses)==null?void 0:s.get(e);return t||(t=this.xr.frame.getJointPose(e,this.xr.referenceSpace),t&&this._handJointPoses.set(e,t),t)}get gripPosition(){return Vn(this._gripPosition).applyMatrix4(qb)}get gripQuaternion(){return rd(this._gripQuaternion).premultiply(Ma)}get gripLinearVelocity(){return Vn(this._linearVelocity).applyQuaternion(Ma)}get rayPosition(){return Vn(this._rayPosition).applyMatrix4(qb)}get rayQuaternion(){return rd(this._rayQuaternion).premultiply(Ma)}get gripWorldPosition(){return Vn(this._gripWorldPosition)}get gripWorldQuaternion(){return rd(this._gripWorldQuaternion)}get rayWorldPosition(){return Vn(this._rayWorldPosition)}updateRayWorldPosition(){var t;const e=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPosition),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return rd(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var i;const e=(i=this.xr.context.mainCamera)==null?void 0:i.parent,t=e?Oi(e):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(Ma),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(Vn(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var e;return(e=this.getMotionController)==null?void 0:e.then(t=>(t==null?void 0:t.assetUrl)||null)}onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var s;It.DrawWireSphere(this.rayWorldPosition,.02),It.DrawDirection(this.rayWorldPosition,Vn(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),t=this.inputSource.profiles.join(`
|
|
4920
4920
|
`);let i=`Controller[${this.index}] ${this.side}
|
|
4921
4921
|
C:${this.connected?"yes":"no"} T:${this.isTracking?"yes":"no"} Hand:${this.inputSource.hand?"yes":"no"}`;this.inputSource.hand&&(i+=`
|
|
4922
4922
|
Pinch: ${(s=this.getGesture("pinch"))==null?void 0:s.value.toFixed(3)}`),i+=`
|
|
@@ -5540,7 +5540,7 @@ Texture:`,i),this.setLightmapDebugMaterial()),this.applyLightmap())}updateLightm
|
|
|
5540
5540
|
gl_FragColor = lightMapTexel;
|
|
5541
5541
|
gl_FragColor.a = 1.;
|
|
5542
5542
|
}
|
|
5543
|
-
`,defines:{USE_LIGHTMAP:""}})}}var ooe=Object.defineProperty,aoe=Object.getOwnPropertyDescriptor,Wl=(n,e,t,i)=>{for(var s=i>1?void 0:i?aoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ooe(e,t,s),s};const ab=ne("debugrenderer"),coe=ne("debugskinnedmesh"),Bk=ne("noInstancing"),Og=ne("debuginstancing"),loe=ne("debugprogressive"),hoe=ne("noprogressive"),uoe=ne("wireframe");class yP{constructor(){h(this,"path",null);h(this,"asset",null);h(this,"default")}}class doe{constructor(e,t){h(this,"_renderer");h(this,"_targets",[]);h(this,"_indexMapMaxIndex");h(this,"_indexMap");h(this,"_changed",!1);this._renderer=e;const i=this.setMaterial.bind(this),s=this.getMaterial.bind(this),r=e.gameObject;if(this._targets=[],r)switch(r.type){case"Group":this._targets=[...r.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(r);break}let o=!1,a,c=0;for(let l=0;l<this._targets.length;l++){const u=this._targets[l];if(!u)continue;const d=u.material;if(d){d.shadowSide=d.side;for(let f=0;f<t.length;f++){const p=t[f];if(!p){o=!0;continue}if(d.name===p.name){a===void 0&&(a=new Map),a.set(f,l),c=Math.max(c,f);break}}}}if(o){this._indexMapMaxIndex=c,this._indexMap=a;const l=`Renderer ${e.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(l),Or()&&gn("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(l,u){if(typeof u=="string"){const d=parseInt(u);if(!isNaN(d))return s(d)}return l[u]},set(l,u,d){return typeof u=="string"&&i(d,Number.parseInt(u)),Reflect.set(l,u,d)?(d instanceof Ut&&(l.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(e){e===!0&&ab&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=e}is(e){return this._renderer===e}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.getMaterial(e)}resolveIndex(e){const t=this._indexMap;return t&&t.has(e)?t.get(e):e}setMaterial(e,t){if(t=this.resolveIndex(t),t<0||t>=this._targets.length)return;const i=this._targets[t];!i||i.material===void 0||(i.material=e,this.changed=!0)}getMaterial(e){if(e=this.resolveIndex(e),e<0)return null;const t=this._targets;if(e>=t.length)return null;const i=t[e];return i?i.material:null}}const C8=class extends Me{constructor(){super(...arguments);h(this,"receiveShadows",!1);h(this,"shadowCastingMode",0);h(this,"lightmapIndex",-1);h(this,"lightmapScaleOffset",new it(1,1,0,0));h(this,"enableInstancing");h(this,"renderOrder");h(this,"allowOcclusionWhenDynamic",!0);h(this,"probeAnchor");h(this,"reflectionProbeUsage",0);h(this,"_lightmaps");h(this,"_sharedMeshes",[]);h(this,"_sharedMaterials");h(this,"_originalMaterials");h(this,"_lightmapTextureOverride");h(this,"allowProgressiveLoading",!0);h(this,"_isInstancingEnabled",!1);h(this,"handles");h(this,"onBeforeRenderThree",(e,t,i,s,r,o)=>{var a;if(r.envMapIntensity!==void 0){const c=this.hasLightmap?Math.PI:1,l=((a=this.context.mainCameraComponent)==null?void 0:a.environmentIntensity)??1;r.envMapIntensity=Math.max(0,l*this.context.sceneLighting.environmentIntensity/c)}if(this._lightmaps)for(const c of this._lightmaps)c.updateLightmapUniforms(r)});h(this,"_reflectionProbe",null)}static setVisible(e,t){Kf(e,t)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const e of this.gameObject.children)(e.type==="Mesh"||e.type==="SkinnedMesh")&&this._sharedMeshes.push(e);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(e){this.sharedMaterials[0]!==e&&(this.sharedMaterials[0]=e,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(e){this.sharedMaterial=e}set sharedMaterials(e){if(!this._originalMaterials)this._originalMaterials=e;else if(e){let t=!1;for(let i=0;i<this._sharedMaterials.length;i++){const s=i<e.length?e[i]:null;s&&s instanceof Ut?this.sharedMaterials[i]=s:t||(t=!0,console.warn("Can not assign null as material: "+this.name,s))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new doe(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return Bk}get lightmap(){var e;return(e=this._lightmaps)!=null&&e.length?this._lightmaps[0].lightmap:null}set lightmap(e){var t;if(this._lightmapTextureOverride=e,e===void 0&&(e=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(t=this._lightmaps)!=null&&t.length)for(const i of this._lightmaps)i.lightmap=e}get hasLightmap(){const e=this.lightmap;return e!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(ab&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&ab&&this.probeAnchor.add(new na(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const e of this.gameObject.children)this.context.addBeforeRenderListener(e,this.onBeforeRenderThree),e.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let e=0;for(let t=0;t<this.gameObject.children.length;t++){const i=this.gameObject.children[t];if(!(!this.isMeshOrSkinnedMesh(i)||le.getComponent(i,C8))){if(this.renderOrder.length<=e){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+e,"ChildElement:",i);continue}i.renderOrder=this.renderOrder[e],e+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),uoe)for(let e=0;e<this.sharedMaterials.length;e++){const t=this.sharedMaterials[e];t&&(t.wireframe=!0)}}applyLightmapping(){var e;if(this.lightmapIndex>=0){const t=this.gameObject.type,i=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(i){if(this._lightmaps||(this._lightmaps=[]),t==="Mesh"){const s=this.gameObject.material;if(s!=null&&s.isMeshBasicMaterial)s&&console.warn("Lightmapping is not supported on MeshBasicMaterial",s.name);else{if(this._lightmaps.length<=0){const o=new eA(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,i)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let s=0;s<this.gameObject.children.length;s++){const r=this.gameObject.children[s];if(!((e=r.material)!=null&&e.isMeshBasicMaterial)){let o;s>=this._lightmaps.length?(o=new eA(r,this.context),this._lightmaps.push(o)):o=this._lightmaps[s],o.init(this.lightmapIndex,this.lightmapScaleOffset,i)}}}else ab&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}setInstancingEnabled(e){if(this._isInstancingEnabled===e)return e&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=e,e){if(this.handles===void 0){if(this.handles=poe.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return le.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const t of this.handles)t.updateInstanceMatrix(!0),t.add();return le.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const t of this.handles)t.remove();return!0}return!1}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!Bk&&(this.setInstancingEnabled(!0),ka.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];t.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled?this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const e of this.gameObject.children)this.context.removeBeforeRenderListener(e,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}applyStencil(){rv.applyStencil(this)}onBeforeRender(){var e,t;if(this.gameObject){if(this.isMultiMaterialObject(this.gameObject)&&((e=this.gameObject.children)==null?void 0:e.length)>0)for(const i of this.gameObject.children)this.applySettings(i);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(t=this.handles)!=null&&t.length&&this.gameObject[Hv]===!0){Og&&console.log("UPDATE INSTANCED MATRICES",this.context.time.frame),this.gameObject[Hv]=!1;for(let s=this.handles.length-1;s>=0;s--)this.handles[s].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&le.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let i=0;i<this.handles.length;i++){const s=this.handles[i];Kf(s.object,!1)}for(const i of this.sharedMaterials)i&&this.loadProgressiveTextures(i);this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const t=this.handles[e];Kf(t.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this)}loadProgressiveTextures(e){return!hoe&&e&&e._didRequestTextureLOD===void 0&&this.allowProgressiveLoading?(e._didRequestTextureLOD=0,loe&&console.log("Load material LOD",e.name),cr.assignTextureLOD(this.context,this.sourceId,e)):Promise.resolve(!0)}applySettings(e){e.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?e.castShadow=!0:e.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),Qn.LateUpdate)}}*_updateReflectionProbe(){const e=this.probeAnchor||this.gameObject,t=!!this.probeAnchor;this._reflectionProbe=wm.get(e,this.context,t,this.probeAnchor)}setVisibility(e){if(!this.isMultiMaterialObject(this.gameObject))Kf(this.gameObject,e);else for(const t of this.gameObject.children)this.isMeshOrSkinnedMesh(t)&&Kf(t,e)}isMultiMaterialObject(e){return e.type==="Group"}isMeshOrSkinnedMesh(e){return e.type==="Mesh"||e.type==="SkinnedMesh"}};let En=C8;Wl([x()],En.prototype,"receiveShadows",2);Wl([x()],En.prototype,"shadowCastingMode",2);Wl([x()],En.prototype,"lightmapIndex",2);Wl([x(it)],En.prototype,"lightmapScaleOffset",2);Wl([x()],En.prototype,"enableInstancing",2);Wl([x()],En.prototype,"renderOrder",2);Wl([x()],En.prototype,"allowOcclusionWhenDynamic",2);Wl([x(ge)],En.prototype,"probeAnchor",2);Wl([x()],En.prototype,"reflectionProbeUsage",2);class c0 extends En{}class _P extends c0{awake(){var e;super.awake(),this.allowOcclusionWhenDynamic=!1,(e=this.gameObject.parent)==null||e.updateWorldMatrix(!1,!0)}onBeforeRender(){if(super.onBeforeRender(),coe&&this.gameObject instanceof Da&&this.gameObject.boundingSphere){const e=Vn(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);It.DrawWireSphere(e,this.gameObject.boundingSphere.radius,"red")}}}class foe{constructor(){h(this,"objs",[])}setup(e,t,i,s,r,o=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,r);if(a)e.loadProgressiveTextures(a.instancer.material),s===null&&(s=[]),s.push(a);else if(o<=0&&t.type!=="Mesh"){const c=o+1;for(const l of t.children)s=this.setup(e,l,i,s,r,c)}return o===0&&r.useMatrixWorldAutoUpdate&&s&&s.length>=0&&this.autoUpdateInstanceMatrix(t),s}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const s=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing||s>=i.rend.enableInstancing.length||!i.rend.enableInstancing[s])return null;const r=e,o=r.geometry,a=r.material;for(const u of this.objs)if(!u.isFull()&&u.geo===o&&u.material===a)return u.addInstance(r);const c=new cb(e.name,o,a,200,t);return this.objs.push(c),c.addInstance(r)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),s=(r,o)=>{const a=t(r,o);return(e[Hv]||i.equals(a)===!1)&&(i.copy(a),e[Hv]=!0),a};e.matrixWorld.multiplyMatrices=s}}const poe=new foe;class moe{constructor(e,t,i){h(this,"instanceIndex",-1);h(this,"object");h(this,"instancer");this.instanceIndex=e,this.object=t,this.instancer=i,t[s4]=i,le.markAsInstancedRendered(t,!0)}get name(){return this.object.name}updateInstanceMatrix(e=!1){this.instanceIndex<0||(this.object.updateWorldMatrix(!0,e),this.instancer.updateInstance(this.object.matrixWorld,this.instanceIndex))}setMatrix(e){this.instanceIndex<0||this.instancer.updateInstance(e,this.instanceIndex)}add(){this.instanceIndex>=0||this.instancer.add(this)}remove(){this.instanceIndex<0||this.instancer.remove(this)}}const m2=class{constructor(e,t,i,s,r){h(this,"name","");h(this,"geo");h(this,"material");h(this,"context");h(this,"inst");h(this,"handles",[]);h(this,"maxCount");h(this,"_needUpdateBounds",!1);h(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[aM]===!0&&(Og&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});h(this,"onAfterRender",()=>{this.inst.layers.disableAll()});this.name=e,this.geo=t,this.material=i,this.context=r,this.maxCount=s,Og&&(i=new li({color:this.randomColor()})),this.inst=new Fx(t,i,s),this.inst[aM]=!0,this.inst.count=0,this.inst.visible=!0,this.context.scene.add(this.inst),i instanceof xA&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),r.pre_render_callbacks.push(this.onBeforeRender),r.post_render_callbacks.push(this.onAfterRender)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get currentCount(){return this.inst.count}isFull(){return this.currentCount>=this.maxCount}randomColor(){return new _e(Math.random(),Math.random(),Math.random())}addInstance(e){if(this.currentCount>=this.maxCount)return console.error("TOO MANY INSTANCES - resize is not yet implemented!",this.inst.count),null;const t=new moe(-1,e,this);return e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0),this.add(t),t}add(e){e.instanceIndex<0&&(e.instanceIndex=this.currentCount,e.instanceIndex>=this.handles.length?this.handles.push(e):this.handles[e.instanceIndex]=e),e.object.updateWorldMatrix(!0,!0),this.inst.setMatrixAt(e.instanceIndex,e.object.matrixWorld),this.inst.instanceMatrix.needsUpdate=!0,this.inst.count+=1,this._needUpdateBounds=!0,this.inst.count>0&&(this.inst.visible=!0),Og&&console.log("Added",this.name,this.inst.count)}remove(e){if(!e||e.instanceIndex<0||e.instanceIndex>=this.handles.length||this.inst.count<=0)return;if(this.handles[e.instanceIndex]!==e){console.error("instance handle is not part of renderer, was it removed before?",e.instanceIndex,this.name);const i=this.handles.indexOf(e);if(i<0)return;e.instanceIndex=i}if(this.handles[e.instanceIndex]=null,this.inst.setMatrixAt(e.instanceIndex,m2.nullMatrix),!(e.instanceIndex>=this.currentCount-1)&&this.currentCount>0){const i=this.handles[this.currentCount-1];i&&(i.instanceIndex=e.instanceIndex,i.updateInstanceMatrix(),this.handles[e.instanceIndex]=i,this.handles[this.currentCount-1]=null)}this.inst.count>0&&(this.inst.count-=1),e.instanceIndex=-1,this._needUpdateBounds=!0,this.inst.count<=0&&(this.inst.visible=!1),this.inst.instanceMatrix.needsUpdate=!0,Og&&console.log("Removed",this.name,this.inst.count)}updateInstance(e,t){this.inst.setMatrixAt(t,e),this.inst.instanceMatrix.needsUpdate=!0,this._needUpdateBounds=!0}};let cb=m2;h(cb,"nullMatrix",new xe);var goe=Object.defineProperty,voe=Object.getOwnPropertyDescriptor,An=(n,e,t,i)=>{for(var s=i>1?void 0:i?voe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&goe(e,t,s),s};const Dk=ne("debugusdzbehaviours");function l0(n){n&&(n.getComponentInParent(JA)||(Ct()&&console.warn("Create Raycaster on "+n.name+" because no raycaster was found in the hierarchy"),n.addNewComponent(Eo)))}class qd extends Me{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new Ce);h(this,"targetScale",new w)}start(){l0(this.gameObject)}onPointerClick(t){t.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 t=Dt(this.object).clone(),i=Dt(this.target).clone(),s=Oi(this.object).clone(),r=Oi(this.target).clone(),o=dn(this.object).clone(),a=dn(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),u=o.distanceTo(a);if(c<.01&&l<.01&&u<.01){hr(this.object,i),ra(this.object,r),Gv(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),hr(this.object,this.targetPos),ra(this.object,this.targetRot),Gv(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new es("Move to "+((i=this.target)==null?void 0:i.name),Fs.tapTrigger(this.gameObject),fi.transformAction(this.object,this.target,this.duration,this.relativeMotion?jM.Relative:jM.Absolute));t.addBehavior(s)}}}An([x(ge)],qd.prototype,"object",2);An([x(ge)],qd.prototype,"target",2);An([x()],qd.prototype,"duration",2);An([x()],qd.prototype,"relativeMotion",2);var T_;const rl=(T_=class extends Me{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",[]);h(this,"selfModel");h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=le.findObjectsOfType(En);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof me)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof Rr)for(const r of t.gameObject.children)r instanceof me&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}start(){l0(this.gameObject)}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this._objectsWithThisMaterial.length;t++){const i=this._objectsWithThisMaterial[t];i.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],rl._materialTriggersPerId={},rl.variantSwitchIndex=0,this.materialToSwitch&&await cr.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await cr.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(rl._materialTriggersPerId[this.materialToSwitch.uuid]||(rl._materialTriggersPerId[this.materialToSwitch.uuid]=[]),rl._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=rl._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(s[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in s)a!==r.selfModel.uuid&&o.push(...s[a]);r.createAndAttachBehaviors(e,s[r.selfModel.uuid],o)}}delete rl._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);r.push(fi.fadeAction([...this.targetModels,...i],o,!1)),s.push(fi.fadeAction(t,o,!1)),r.push(fi.fadeAction(t,o,!0)),e.addBehavior(new es("Select_"+this.selfModel.name,Fs.tapTrigger(this.selfModel),fi.parallel(...r))),e.addBehavior(new es("StartHidden_"+this.selfModel.name,Fs.sceneStartTrigger(),fi.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+rl.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&Zr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(T_,"_materialTriggersPerId",{}),h(T_,"variantSwitchIndex",0),T_);let Sm=rl;An([x(Ut)],Sm.prototype,"materialToSwitch",2);An([x(Ut)],Sm.prototype,"variantMaterial",2);An([x()],Sm.prototype,"fadeDuration",2);var jf;const hn=(jf=class extends Me{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"selfModelClone");h(this,"targetModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1);h(this,"targetStateBeforeCreatingDocument",!1)}start(){l0(this.gameObject)}onPointerClick(e){e.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[hn.wasVisible]===void 0&&(this.gameObject[hn.wasVisible]=this.gameObject.activeSelf),this.target[hn.wasVisible]===void 0&&(this.target[hn.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[hn.wasVisible],this.targetStateBeforeCreatingDocument=this.target[hn.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(e,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let s=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&WG.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[hn.toggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggle"+hn.clonedToggleIndex++,i.add(c),this.gameObject[hn.toggleClone]=c,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[hn.toggleClone];if(!this.gameObject[hn.reverseToggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggleReverse"+hn.clonedToggleIndex++,i.add(c),this.gameObject[hn.reverseToggleClone]=c}this.toggleModel=this.gameObject[hn.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),s=a,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(fi.fadeAction(s,0,!1)),a.push(fi.fadeAction(this.toggleModel,0,!0)),a.push(fi.fadeAction(this.targetModel,0,r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Fs.tapTrigger(s),fi.parallel(...a)));const c=[];c.push(fi.fadeAction(this.toggleModel,0,!1)),c.push(fi.fadeAction(s,0,!0)),c.push(fi.fadeAction(this.targetModel,0,!r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"Off":"On"),Fs.tapTrigger(this.toggleModel),fi.parallel(...c)))}}else{const a=[];this.hideSelf&&a.push(fi.fadeAction(s,0,!1)),a.push(fi.fadeAction(this.targetModel,0,r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Fs.tapTrigger(s),fi.parallel(...a)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(i),this.toggleModel&&o.push(this.toggleModel),e.addBehavior(new es("HideOnStart_"+this.gameObject.name,Fs.sceneStartTrigger(),fi.fadeAction(o,0,!1)))}}afterSerialize(e,t){this.gameObject[hn.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[hn.wasVisible],delete this.gameObject[hn.wasVisible]),this.target&&this.target[hn.wasVisible]!==void 0&&(this.target.visible=this.target[hn.wasVisible],delete this.target[hn.wasVisible]),delete this.gameObject[hn.toggleClone],delete this.gameObject[hn.reverseToggleClone]}},h(jf,"clonedToggleIndex",0),h(jf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(jf,"toggleClone",Symbol("clone for toggling")),h(jf,"reverseToggleClone",Symbol("clone for reverse toggling")),jf);let Xd=hn;An([x(ge)],Xd.prototype,"target",2);An([x()],Xd.prototype,"toggleOnClick",2);An([x()],Xd.prototype,"targetState",2);An([x()],Xd.prototype,"hideSelf",2);class bP extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new es("HideOnStart_"+this.gameObject.name,Fs.sceneStartTrigger(),fi.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Cm extends Me{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType",JR.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new es("emphasize "+this.name,Fs.tapTrigger(this.gameObject),fi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}An([x()],Cm.prototype,"target",2);An([x()],Cm.prototype,"duration",2);An([x()],Cm.prototype,"motionType",2);class eu extends Me{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}start(){l0(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addNewComponent(vn);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.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(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject,a=Kh.getName(r),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?qM.NonSpatial:qM.Spatial;let u=!1;if(this.gameObject.traverse(d=>{d instanceof me&&d.visible&&(u=!0)}),u){let d=fi.playAudioAction(o,"audio/"+a,WM.Play,c,l);this.toggleOnClick&&(d.multiplePerformOperation=ZG.Stop),this.target&&this.target.loop&&(d=fi.sequence(d).makeLooping());const f=new es("playAudio "+this.name,Fs.tapTrigger(this.gameObject),d);t.addBehavior(f)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let d=fi.playAudioAction(o,"audio/"+a,WM.Play,c,l);this.target.loop&&(d=fi.sequence(d).makeLooping());const f=new es("playAudioOnStart"+(this.name?"_"+this.name:""),Fs.sceneStartTrigger(),d);t.addBehavior(f)}}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s||typeof s!="string")return;const o="audio/"+Kh.getName(s);if(i.files[o])return;const l=await(await(await fetch(s)).blob()).arrayBuffer(),u=new Uint8Array(l);i.files[o]=u}}An([x(vn)],eu.prototype,"target",2);An([x(URL)],eu.prototype,"clip",2);An([x()],eu.prototype,"toggleOnClick",2);var I_;const yh=(I_=class extends Me{constructor(){super(...arguments);h(this,"animator");h(this,"stateName");h(this,"trigger","tap");h(this,"selfModel");h(this,"stateAnimationModel");h(this,"animationSequence",new Array);h(this,"animationLoopAfterSequence",new Array)}get target(){var e;return(e=this.animator)==null?void 0:e.gameObject}start(){l0(this.gameObject)}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(yh.rootsWithExclusivePlayback.size>1){const e='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.';Ct()&&gn(e),console.warn(e,...yh.rootsWithExclusivePlayback)}yh.animationActions=[],yh.rootsWithExclusivePlayback=new Set}afterCreateDocument(e,t){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const i=t.document,s=t.extensions.find(a=>a instanceof $A);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(Ct()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),yh.rootsWithExclusivePlayback.add(this.target));const o=(a,c)=>{let l=yh.animationActions.find(u=>u.affectedObjects==a&&u.start==c.start&&u.duration==c.duration);return l||(l=fi.startAnimationAction(a,c.start,c.duration),yh.animationActions.push(l)),l};i.traverse(a=>{var c,l;if(a.uuid===((c=this.target)==null?void 0:c.uuid)){const u=fi.sequence();if(this.animationSequence!==void 0)for(const f of this.animationSequence)u.addAction(o(a,f));if(this.animationLoopAfterSequence!==void 0){const f=u.actions.length==0?u:fi.sequence();for(const p of this.animationLoopAfterSequence)f.addAction(o(a,p));f.makeLooping(),u!==f&&u.addAction(f)}const d=new es("tap "+this.name+" for "+this.stateName+" on "+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?Fs.tapTrigger(this.selfModel):Fs.sceneStartTrigger(),u);r&&d.makeExclusive(!0),e.addBehavior(d)}})}createAnimation(e,t,i){var l,u,d,f;if(!this.target||!this.animator)return;const s=(l=this.animator)==null?void 0:l.runtimeAnimatorController;let r=s==null?void 0:s.findState(this.stateName),o=[],a=[];if(s&&r){const p=new Array;p.push(r);let m=!1;for(;p.length<100;){if(!r||r===null||!r.transitions||r.transitions.length===0){(u=r.motion)!=null&&u.isLooping&&(m=!0);break}const g=r.transitions.find(v=>v.conditions.length===0),y=g?s.getState(g.destinationState,0):null;if(y&&p.includes(y)){r=y,m=!0;break}else if(g){if(r=y,!r)break;p.push(r)}else{m=((d=r.motion)==null?void 0:d.isLooping)??!1;break}}if(m&&r){const g=p.indexOf(r);o=p.slice(0,g),a=p.slice(g),Dk&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",a)}else o=p,a=[],Dk&&console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(p=>{var m,g,y;return((m=p.motion)==null?void 0:m.clip)&&((y=(g=p.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),a=a.filter(p=>{var m,g,y;return((m=p.motion)==null?void 0:m.clip)&&((y=(g=p.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),o.length===0&&a.length===0){console.warn("No clips found for state "+this.stateName+" on "+((f=this.animator)==null?void 0:f.name)+", can't export animation data");return}this.stateAnimationModel=t;const c=(p,m)=>{var y,v,A;if(!this.target)return;if(!((y=p.motion)!=null&&y.clip)){console.warn("No clip found for state "+p.name+" on "+((v=this.animator)==null?void 0:v.name)+", can't export animation data");return}const g=e.registerAnimation(this.target,p.motion.clip);g?m.push(g):console.warn("Couldn't register animation for state "+p.name+" on "+((A=this.animator)==null?void 0:A.name))};if(o.length>0){this.animationSequence=new Array;for(const p of o)c(p,this.animationSequence)}if(a.length>0){this.animationLoopAfterSequence=new Array;for(const p of a)c(p,this.animationLoopAfterSequence)}}},h(I_,"animationActions",[]),h(I_,"rootsWithExclusivePlayback",new Set),I_);let Em=yh;An([x(Gs)],Em.prototype,"animator",2);An([x()],Em.prototype,"stateName",2);class Mm extends Me{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}An([x(ge)],Mm.prototype,"target",2);class h0 extends Me{constructor(){super(...arguments);h(this,"target")}}An([x(Mm)],h0.prototype,"target",2);class u0 extends Mm{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}An([x()],u0.prototype,"type",2);An([x()],u0.prototype,"duration",2);class xP extends h0{}var Aoe=Object.defineProperty,yoe=Object.getOwnPropertyDescriptor,ql=(n,e,t,i)=>{for(var s=i>1?void 0:i?yoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Aoe(e,t,s),s};const Ok=ne("debugcharactercontroller");class Yd extends Me{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions");h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Yi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Yi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(Zh);i||(i=this.gameObject.addNewComponent(Zh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const c=r.dot(a)<0?-1:1,l=s.angleTo(a)*c;this.gameObject.setRotationFromAxisAngle(o,l),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){(t.contacts.length==0||t.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(t),Ok&&console.log(`Collision(${this._activeGroundCollisions.size}): ${t.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(t){this._activeGroundCollisions.delete(t),Ok&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var t;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const s=(t=this.context.physics.engine)==null?void 0:t.getLinearVelocity(i.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}ql([x(w)],Yd.prototype,"center",2);ql([x()],Yd.prototype,"radius",2);ql([x()],Yd.prototype,"height",2);class Xl extends Me{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new ie(0,0));h(this,"moveInput",new ie(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new oa)}awake(){this._currentRotation=new Ce}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}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(t,i,s){var r,o,a,c,l,u,d,f,p,m,g;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),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+=rt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const y=this.context.mainCameraComponent.forward;y.y=0,y.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),y),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&&s&&this.jumpForce>0){let y=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(y=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),y){this._jumpCount+=1;const v=this.controller.rigidbody,A=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(A))}}if(this.controller){const y=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(y<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new To),this._raycastOptions.ray.origin.copy(Dt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const A=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(A.length&&A[0].distance>2||y<-10)&&((m=this.animator)==null||m.setBool("falling",!0))}else(g=this.animator)==null||g.setBool("falling",!1)}}}ql([x(Yd)],Xl.prototype,"controller",2);ql([x()],Xl.prototype,"movementSpeed",2);ql([x()],Xl.prototype,"rotationSpeed",2);ql([x()],Xl.prototype,"jumpForce",2);ql([x()],Xl.prototype,"doubleJumpForce",2);ql([x(Gs)],Xl.prototype,"animator",2);var _oe=Object.defineProperty,boe=Object.getOwnPropertyDescriptor,xoe=(n,e,t,i)=>{for(var s=i>1?void 0:i?boe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&_oe(e,t,s),s};class d0 extends fr{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new _4;return t.offset=new ie(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}xoe([x(kt)],d0.prototype,"intensity",2);da("ChromaticAberration",d0);const f0=new _t;f0.setAttribute("position",new tt(new Float32Array([-1,-1,3,-1,-1,3]),2));f0.setAttribute("uv",new tt(new Float32Array([0,0,2,0,0,2]),2));f0.boundingSphere=new kn;f0.computeBoundingSphere=function(){};const woe=new zl;class Fu{constructor(e){this._mesh=new me(f0,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,woe)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const Soe={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new xe},viewMat:{value:new xe},projViewMat:{value:new xe},projectionMatrixInv:{value:new xe},viewMatrixInv:{value:new xe},cameraPos:{value:new w},resolution:{value:new ie},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|
|
5543
|
+
`,defines:{USE_LIGHTMAP:""}})}}var ooe=Object.defineProperty,aoe=Object.getOwnPropertyDescriptor,Wl=(n,e,t,i)=>{for(var s=i>1?void 0:i?aoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ooe(e,t,s),s};const ab=ne("debugrenderer"),coe=ne("debugskinnedmesh"),Bk=ne("noInstancing"),Og=ne("debuginstancing"),loe=ne("debugprogressive"),hoe=ne("noprogressive"),uoe=ne("wireframe");class yP{constructor(){h(this,"path",null);h(this,"asset",null);h(this,"default")}}class doe{constructor(e,t){h(this,"_renderer");h(this,"_targets",[]);h(this,"_indexMapMaxIndex");h(this,"_indexMap");h(this,"_changed",!1);this._renderer=e;const i=this.setMaterial.bind(this),s=this.getMaterial.bind(this),r=e.gameObject;if(this._targets=[],r)switch(r.type){case"Group":this._targets=[...r.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(r);break}let o=!1,a,c=0;for(let l=0;l<this._targets.length;l++){const u=this._targets[l];if(!u)continue;const d=u.material;if(d){d.shadowSide=d.side;for(let f=0;f<t.length;f++){const p=t[f];if(!p){o=!0;continue}if(d.name===p.name){a===void 0&&(a=new Map),a.set(f,l),c=Math.max(c,f);break}}}}if(o){this._indexMapMaxIndex=c,this._indexMap=a;const l=`Renderer ${e.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(l),Or()&&gn("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(l,u){if(typeof u=="string"){const d=parseInt(u);if(!isNaN(d))return s(d)}return l[u]},set(l,u,d){return typeof u=="string"&&i(d,Number.parseInt(u)),Reflect.set(l,u,d)?(d instanceof Ut&&(l.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(e){e===!0&&ab&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=e}is(e){return this._renderer===e}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this.getMaterial(e)}resolveIndex(e){const t=this._indexMap;return t&&t.has(e)?t.get(e):e}setMaterial(e,t){if(t=this.resolveIndex(t),t<0||t>=this._targets.length)return;const i=this._targets[t];!i||i.material===void 0||(i.material=e,this.changed=!0)}getMaterial(e){if(e=this.resolveIndex(e),e<0)return null;const t=this._targets;if(e>=t.length)return null;const i=t[e];return i?i.material:null}}const C8=class extends Me{constructor(){super(...arguments);h(this,"receiveShadows",!1);h(this,"shadowCastingMode",0);h(this,"lightmapIndex",-1);h(this,"lightmapScaleOffset",new it(1,1,0,0));h(this,"enableInstancing");h(this,"renderOrder");h(this,"allowOcclusionWhenDynamic",!0);h(this,"probeAnchor");h(this,"reflectionProbeUsage",0);h(this,"_lightmaps");h(this,"_sharedMeshes",[]);h(this,"_sharedMaterials");h(this,"_originalMaterials");h(this,"_lightmapTextureOverride");h(this,"allowProgressiveLoading",!0);h(this,"_isInstancingEnabled",!1);h(this,"handles");h(this,"onBeforeRenderThree",(e,t,i,s,r,o)=>{var a;if(r.envMapIntensity!==void 0){const c=this.hasLightmap?Math.PI:1,l=((a=this.context.mainCameraComponent)==null?void 0:a.environmentIntensity)??1;r.envMapIntensity=Math.max(0,l*this.context.sceneLighting.environmentIntensity/c)}if(this._lightmaps)for(const c of this._lightmaps)c.updateLightmapUniforms(r)});h(this,"_reflectionProbe",null)}static setVisible(e,t){Kf(e,t)}get sharedMesh(){if(this.gameObject.type==="Mesh")return this.gameObject;if(this.gameObject.type==="SkinnesMesh")return this.gameObject;if(this.gameObject.type==="Group")return this.gameObject.children[0]}get sharedMeshes(){if(this.destroyed||!this.gameObject)return this._sharedMeshes;if(this._sharedMeshes.length=0,this.gameObject.type==="Group")for(const e of this.gameObject.children)(e.type==="Mesh"||e.type==="SkinnedMesh")&&this._sharedMeshes.push(e);else(this.gameObject.type==="Mesh"||this.gameObject.type==="SkinnedMesh")&&this._sharedMeshes.push(this.gameObject);return this._sharedMeshes}get sharedMaterial(){return this.sharedMaterials[0]}set sharedMaterial(e){this.sharedMaterials[0]!==e&&(this.sharedMaterials[0]=e,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(e){this.sharedMaterial=e}set sharedMaterials(e){if(!this._originalMaterials)this._originalMaterials=e;else if(e){let t=!1;for(let i=0;i<this._sharedMaterials.length;i++){const s=i<e.length?e[i]:null;s&&s instanceof Ut?this.sharedMaterials[i]=s:t||(t=!0,console.warn("Can not assign null as material: "+this.name,s))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new doe(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return Bk}get lightmap(){var e;return(e=this._lightmaps)!=null&&e.length?this._lightmaps[0].lightmap:null}set lightmap(e){var t;if(this._lightmapTextureOverride=e,e===void 0&&(e=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(t=this._lightmaps)!=null&&t.length)for(const i of this._lightmaps)i.lightmap=e}get hasLightmap(){const e=this.lightmap;return e!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(ab&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&ab&&this.probeAnchor.add(new na(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const e of this.gameObject.children)this.context.addBeforeRenderListener(e,this.onBeforeRenderThree),e.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let e=0;for(let t=0;t<this.gameObject.children.length;t++){const i=this.gameObject.children[t];if(!(!this.isMeshOrSkinnedMesh(i)||le.getComponent(i,C8))){if(this.renderOrder.length<=e){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+e,"ChildElement:",i);continue}i.renderOrder=this.renderOrder[e],e+=1}}}}else this.isMeshOrSkinnedMesh(this.gameObject)?(this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree),this.renderOrder!==void 0&&this.renderOrder.length>0&&(this.gameObject.renderOrder=this.renderOrder[0])):this.context.addBeforeRenderListener(this.gameObject,this.onBeforeRenderThree);if(this.applyLightmapping(),uoe)for(let e=0;e<this.sharedMaterials.length;e++){const t=this.sharedMaterials[e];t&&(t.wireframe=!0)}}applyLightmapping(){var e;if(this.lightmapIndex>=0){const t=this.gameObject.type,i=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(i){if(this._lightmaps||(this._lightmaps=[]),t==="Mesh"){const s=this.gameObject.material;if(s!=null&&s.isMeshBasicMaterial)s&&console.warn("Lightmapping is not supported on MeshBasicMaterial",s.name);else{if(this._lightmaps.length<=0){const o=new eA(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,i)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let s=0;s<this.gameObject.children.length;s++){const r=this.gameObject.children[s];if(!((e=r.material)!=null&&e.isMeshBasicMaterial)){let o;s>=this._lightmaps.length?(o=new eA(r,this.context),this._lightmaps.push(o)):o=this._lightmaps[s],o.init(this.lightmapIndex,this.lightmapScaleOffset,i)}}}else ab&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}setInstancingEnabled(e){if(this._isInstancingEnabled===e)return e&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=e,e){if(this.handles===void 0){if(this.handles=poe.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return le.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const t of this.handles)t.updateInstanceMatrix(!0),t.add();return le.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const t of this.handles)t.remove();return!0}return!1}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!Bk&&(this.setInstancingEnabled(!0),ka.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];t.frustumCulled=this.allowOcclusionWhenDynamic}}onEnable(){this.sharedMeshes,this.setVisibility(!0),this._isInstancingEnabled?this.setInstancingEnabled(!0):this.enabled&&this.applyStencil(),this.updateReflectionProbe()}onDisable(){this.setVisibility(!1),this.handles&&this.handles.length>0&&this.setInstancingEnabled(!1)}onDestroy(){if(this.handles=null,this.isMultiMaterialObject(this.gameObject))for(const e of this.gameObject.children)this.context.removeBeforeRenderListener(e,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}applyStencil(){rv.applyStencil(this)}onBeforeRender(){var e,t;if(this.gameObject){if(this.isMultiMaterialObject(this.gameObject)&&((e=this.gameObject.children)==null?void 0:e.length)>0)for(const i of this.gameObject.children)this.applySettings(i);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(t=this.handles)!=null&&t.length&&this.gameObject[Hv]===!0){Og&&console.log("UPDATE INSTANCED MATRICES",this.context.time.frame),this.gameObject[Hv]=!1;for(let s=this.handles.length-1;s>=0;s--)this.handles[s].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&le.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let i=0;i<this.handles.length;i++){const s=this.handles[i];Kf(s.object,!1)}for(const i of this.sharedMaterials)i&&this.loadProgressiveTextures(i);this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let e=0;e<this.handles.length;e++){const t=this.handles[e];Kf(t.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this)}loadProgressiveTextures(e){return!hoe&&e&&e._didRequestTextureLOD===void 0&&this.allowProgressiveLoading?(e._didRequestTextureLOD=0,loe&&console.log("Load material LOD",e.name),cr.assignTextureLOD(this.context,this.sourceId,e)):Promise.resolve(!0)}applySettings(e){e.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?e.castShadow=!0:e.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),Qn.LateUpdate)}}*_updateReflectionProbe(){const e=this.probeAnchor||this.gameObject,t=!!this.probeAnchor;this._reflectionProbe=wm.get(e,this.context,t,this.probeAnchor)}setVisibility(e){if(!this.isMultiMaterialObject(this.gameObject))Kf(this.gameObject,e);else for(const t of this.gameObject.children)this.isMeshOrSkinnedMesh(t)&&Kf(t,e)}isMultiMaterialObject(e){return e.type==="Group"}isMeshOrSkinnedMesh(e){return e.type==="Mesh"||e.type==="SkinnedMesh"}};let En=C8;Wl([x()],En.prototype,"receiveShadows",2);Wl([x()],En.prototype,"shadowCastingMode",2);Wl([x()],En.prototype,"lightmapIndex",2);Wl([x(it)],En.prototype,"lightmapScaleOffset",2);Wl([x()],En.prototype,"enableInstancing",2);Wl([x()],En.prototype,"renderOrder",2);Wl([x()],En.prototype,"allowOcclusionWhenDynamic",2);Wl([x(ge)],En.prototype,"probeAnchor",2);Wl([x()],En.prototype,"reflectionProbeUsage",2);class c0 extends En{}class _P extends c0{awake(){var e;super.awake(),this.allowOcclusionWhenDynamic=!1,(e=this.gameObject.parent)==null||e.updateWorldMatrix(!1,!0)}onBeforeRender(){if(super.onBeforeRender(),coe&&this.gameObject instanceof Da&&this.gameObject.boundingSphere){const e=Vn(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);It.DrawWireSphere(e,this.gameObject.boundingSphere.radius,"red")}}}class foe{constructor(){h(this,"objs",[])}setup(e,t,i,s,r,o=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,r);if(a)e.loadProgressiveTextures(a.instancer.material),s===null&&(s=[]),s.push(a);else if(o<=0&&t.type!=="Mesh"){const c=o+1;for(const l of t.children)s=this.setup(e,l,i,s,r,c)}return o===0&&r.useMatrixWorldAutoUpdate&&s&&s.length>=0&&this.autoUpdateInstanceMatrix(t),s}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const s=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing||s>=i.rend.enableInstancing.length||!i.rend.enableInstancing[s])return null;const r=e,o=r.geometry,a=r.material;for(const u of this.objs)if(!u.isFull()&&u.geo===o&&u.material===a)return u.addInstance(r);const c=new cb(e.name,o,a,200,t);return this.objs.push(c),c.addInstance(r)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),s=(r,o)=>{const a=t(r,o);return(e[Hv]||i.equals(a)===!1)&&(i.copy(a),e[Hv]=!0),a};e.matrixWorld.multiplyMatrices=s}}const poe=new foe;class moe{constructor(e,t,i){h(this,"instanceIndex",-1);h(this,"object");h(this,"instancer");this.instanceIndex=e,this.object=t,this.instancer=i,t[s4]=i,le.markAsInstancedRendered(t,!0)}get name(){return this.object.name}updateInstanceMatrix(e=!1){this.instanceIndex<0||(this.object.updateWorldMatrix(!0,e),this.instancer.updateInstance(this.object.matrixWorld,this.instanceIndex))}setMatrix(e){this.instanceIndex<0||this.instancer.updateInstance(e,this.instanceIndex)}add(){this.instanceIndex>=0||this.instancer.add(this)}remove(){this.instanceIndex<0||this.instancer.remove(this)}}const m2=class{constructor(e,t,i,s,r){h(this,"name","");h(this,"geo");h(this,"material");h(this,"context");h(this,"inst");h(this,"handles",[]);h(this,"maxCount");h(this,"_needUpdateBounds",!1);h(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[aM]===!0&&(Og&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});h(this,"onAfterRender",()=>{this.inst.layers.disableAll()});this.name=e,this.geo=t,this.material=i,this.context=r,this.maxCount=s,Og&&(i=new li({color:this.randomColor()})),this.inst=new Fx(t,i,s),this.inst[aM]=!0,this.inst.count=0,this.inst.visible=!0,this.context.scene.add(this.inst),i instanceof xA&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),r.pre_render_callbacks.push(this.onBeforeRender),r.post_render_callbacks.push(this.onAfterRender)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get currentCount(){return this.inst.count}isFull(){return this.currentCount>=this.maxCount}randomColor(){return new _e(Math.random(),Math.random(),Math.random())}addInstance(e){if(this.currentCount>=this.maxCount)return console.error("TOO MANY INSTANCES - resize is not yet implemented!",this.inst.count),null;const t=new moe(-1,e,this);return e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0),this.add(t),t}add(e){e.instanceIndex<0&&(e.instanceIndex=this.currentCount,e.instanceIndex>=this.handles.length?this.handles.push(e):this.handles[e.instanceIndex]=e),e.object.updateWorldMatrix(!0,!0),this.inst.setMatrixAt(e.instanceIndex,e.object.matrixWorld),this.inst.instanceMatrix.needsUpdate=!0,this.inst.count+=1,this._needUpdateBounds=!0,this.inst.count>0&&(this.inst.visible=!0),Og&&console.log("Added",this.name,this.inst.count)}remove(e){if(!e||e.instanceIndex<0||e.instanceIndex>=this.handles.length||this.inst.count<=0)return;if(this.handles[e.instanceIndex]!==e){console.error("instance handle is not part of renderer, was it removed before?",e.instanceIndex,this.name);const i=this.handles.indexOf(e);if(i<0)return;e.instanceIndex=i}if(this.handles[e.instanceIndex]=null,this.inst.setMatrixAt(e.instanceIndex,m2.nullMatrix),!(e.instanceIndex>=this.currentCount-1)&&this.currentCount>0){const i=this.handles[this.currentCount-1];i&&(i.instanceIndex=e.instanceIndex,i.updateInstanceMatrix(),this.handles[e.instanceIndex]=i,this.handles[this.currentCount-1]=null)}this.inst.count>0&&(this.inst.count-=1),e.instanceIndex=-1,this._needUpdateBounds=!0,this.inst.count<=0&&(this.inst.visible=!1),this.inst.instanceMatrix.needsUpdate=!0,Og&&console.log("Removed",this.name,this.inst.count)}updateInstance(e,t){this.inst.setMatrixAt(t,e),this.inst.instanceMatrix.needsUpdate=!0,this._needUpdateBounds=!0}};let cb=m2;h(cb,"nullMatrix",new xe);var goe=Object.defineProperty,voe=Object.getOwnPropertyDescriptor,An=(n,e,t,i)=>{for(var s=i>1?void 0:i?voe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&goe(e,t,s),s};const Dk=ne("debugusdzbehaviours");function l0(n){n&&(n.getComponentInParent(JA)||(Ct()&&console.warn("Create Raycaster on "+n.name+" because no raycaster was found in the hierarchy"),n.addNewComponent(Eo)))}class qd extends Me{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new Ce);h(this,"targetScale",new w)}start(){l0(this.gameObject)}onPointerClick(t){t.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 t=Dt(this.object).clone(),i=Dt(this.target).clone(),s=Oi(this.object).clone(),r=Oi(this.target).clone(),o=dn(this.object).clone(),a=dn(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),u=o.distanceTo(a);if(c<.01&&l<.01&&u<.01){hr(this.object,i),ra(this.object,r),Gv(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),hr(this.object,this.targetPos),ra(this.object,this.targetRot),Gv(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new es("Move to "+((i=this.target)==null?void 0:i.name),Fs.tapTrigger(this.gameObject),fi.transformAction(this.object,this.target,this.duration,this.relativeMotion?jM.Relative:jM.Absolute));t.addBehavior(s)}}}An([x(ge)],qd.prototype,"object",2);An([x(ge)],qd.prototype,"target",2);An([x()],qd.prototype,"duration",2);An([x()],qd.prototype,"relativeMotion",2);var T_;const rl=(T_=class extends Me{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",[]);h(this,"selfModel");h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=le.findObjectsOfType(En);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof me)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof Rr)for(const r of t.gameObject.children)r instanceof me&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}start(){l0(this.gameObject)}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this._objectsWithThisMaterial.length;t++){const i=this._objectsWithThisMaterial[t];i.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],rl._materialTriggersPerId={},rl.variantSwitchIndex=0,this.materialToSwitch&&await cr.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await cr.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(rl._materialTriggersPerId[this.materialToSwitch.uuid]||(rl._materialTriggersPerId[this.materialToSwitch.uuid]=[]),rl._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=rl._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(s[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in s)a!==r.selfModel.uuid&&o.push(...s[a]);r.createAndAttachBehaviors(e,s[r.selfModel.uuid],o)}}delete rl._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);r.push(fi.fadeAction([...this.targetModels,...i],o,!1)),s.push(fi.fadeAction(t,o,!1)),r.push(fi.fadeAction(t,o,!0)),e.addBehavior(new es("Select_"+this.selfModel.name,Fs.tapTrigger(this.selfModel),fi.parallel(...r))),e.addBehavior(new es("StartHidden_"+this.selfModel.name,Fs.sceneStartTrigger(),fi.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+rl.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&Zr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(T_,"_materialTriggersPerId",{}),h(T_,"variantSwitchIndex",0),T_);let Sm=rl;An([x(Ut)],Sm.prototype,"materialToSwitch",2);An([x(Ut)],Sm.prototype,"variantMaterial",2);An([x()],Sm.prototype,"fadeDuration",2);var jf;const hn=(jf=class extends Me{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"selfModelClone");h(this,"targetModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1);h(this,"targetStateBeforeCreatingDocument",!1)}start(){l0(this.gameObject)}onPointerClick(e){e.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[hn.wasVisible]===void 0&&(this.gameObject[hn.wasVisible]=this.gameObject.activeSelf),this.target[hn.wasVisible]===void 0&&(this.target[hn.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[hn.wasVisible],this.targetStateBeforeCreatingDocument=this.target[hn.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(e,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let s=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&WG.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[hn.toggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggle"+hn.clonedToggleIndex++,i.add(c),this.gameObject[hn.toggleClone]=c,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[hn.toggleClone];if(!this.gameObject[hn.reverseToggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggleReverse"+hn.clonedToggleIndex++,i.add(c),this.gameObject[hn.reverseToggleClone]=c}this.toggleModel=this.gameObject[hn.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),s=a,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(fi.fadeAction(s,0,!1)),a.push(fi.fadeAction(this.toggleModel,0,!0)),a.push(fi.fadeAction(this.targetModel,0,r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Fs.tapTrigger(s),fi.parallel(...a)));const c=[];c.push(fi.fadeAction(this.toggleModel,0,!1)),c.push(fi.fadeAction(s,0,!0)),c.push(fi.fadeAction(this.targetModel,0,!r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"Off":"On"),Fs.tapTrigger(this.toggleModel),fi.parallel(...c)))}}else{const a=[];this.hideSelf&&a.push(fi.fadeAction(s,0,!1)),a.push(fi.fadeAction(this.targetModel,0,r)),e.addBehavior(new es("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Fs.tapTrigger(s),fi.parallel(...a)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(i),this.toggleModel&&o.push(this.toggleModel),e.addBehavior(new es("HideOnStart_"+this.gameObject.name,Fs.sceneStartTrigger(),fi.fadeAction(o,0,!1)))}}afterSerialize(e,t){this.gameObject[hn.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[hn.wasVisible],delete this.gameObject[hn.wasVisible]),this.target&&this.target[hn.wasVisible]!==void 0&&(this.target.visible=this.target[hn.wasVisible],delete this.target[hn.wasVisible]),delete this.gameObject[hn.toggleClone],delete this.gameObject[hn.reverseToggleClone]}},h(jf,"clonedToggleIndex",0),h(jf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(jf,"toggleClone",Symbol("clone for toggling")),h(jf,"reverseToggleClone",Symbol("clone for reverse toggling")),jf);let Xd=hn;An([x(ge)],Xd.prototype,"target",2);An([x()],Xd.prototype,"toggleOnClick",2);An([x()],Xd.prototype,"targetState",2);An([x()],Xd.prototype,"hideSelf",2);class bP extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new es("HideOnStart_"+this.gameObject.name,Fs.sceneStartTrigger(),fi.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Cm extends Me{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType",JR.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new es("emphasize "+this.name,Fs.tapTrigger(this.gameObject),fi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}An([x()],Cm.prototype,"target",2);An([x()],Cm.prototype,"duration",2);An([x()],Cm.prototype,"motionType",2);class eu extends Me{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}start(){l0(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addNewComponent(vn);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.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(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject,a=Kh.getName(r),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?qM.NonSpatial:qM.Spatial;let u=!1;if(this.gameObject.traverse(d=>{d instanceof me&&d.visible&&(u=!0)}),u=!0,u){let d=fi.playAudioAction(o,"audio/"+a,WM.Play,c,l);this.toggleOnClick&&(d.multiplePerformOperation=ZG.Stop),this.target&&this.target.loop&&(d=fi.sequence(d).makeLooping());const f=new es("playAudio "+this.name,Fs.tapTrigger(this.gameObject),d);t.addBehavior(f)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let d=fi.playAudioAction(o,"audio/"+a,WM.Play,c,l);this.target.loop&&(d=fi.sequence(d).makeLooping());const f=new es("playAudioOnStart"+(this.name?"_"+this.name:""),Fs.sceneStartTrigger(),d);t.addBehavior(f)}}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s||typeof s!="string")return;const o="audio/"+Kh.getName(s);if(i.files[o])return;const l=await(await(await fetch(s)).blob()).arrayBuffer(),u=new Uint8Array(l);i.files[o]=u}}An([x(vn)],eu.prototype,"target",2);An([x(URL)],eu.prototype,"clip",2);An([x()],eu.prototype,"toggleOnClick",2);var I_;const yh=(I_=class extends Me{constructor(){super(...arguments);h(this,"animator");h(this,"stateName");h(this,"trigger","tap");h(this,"selfModel");h(this,"stateAnimationModel");h(this,"animationSequence",new Array);h(this,"animationLoopAfterSequence",new Array)}get target(){var e;return(e=this.animator)==null?void 0:e.gameObject}start(){l0(this.gameObject)}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(yh.rootsWithExclusivePlayback.size>1){const e='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.';Ct()&&gn(e),console.warn(e,...yh.rootsWithExclusivePlayback)}yh.animationActions=[],yh.rootsWithExclusivePlayback=new Set}afterCreateDocument(e,t){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const i=t.document,s=t.extensions.find(a=>a instanceof $A);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(Ct()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),yh.rootsWithExclusivePlayback.add(this.target));const o=(a,c)=>{let l=yh.animationActions.find(u=>u.affectedObjects==a&&u.start==c.start&&u.duration==c.duration);return l||(l=fi.startAnimationAction(a,c.start,c.duration),yh.animationActions.push(l)),l};i.traverse(a=>{var c,l;if(a.uuid===((c=this.target)==null?void 0:c.uuid)){const u=fi.sequence();if(this.animationSequence!==void 0)for(const f of this.animationSequence)u.addAction(o(a,f));if(this.animationLoopAfterSequence!==void 0){const f=u.actions.length==0?u:fi.sequence();for(const p of this.animationLoopAfterSequence)f.addAction(o(a,p));f.makeLooping(),u!==f&&u.addAction(f)}const d=new es("tap "+this.name+" for "+this.stateName+" on "+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?Fs.tapTrigger(this.selfModel):Fs.sceneStartTrigger(),u);r&&d.makeExclusive(!0),e.addBehavior(d)}})}createAnimation(e,t,i){var l,u,d,f;if(!this.target||!this.animator)return;const s=(l=this.animator)==null?void 0:l.runtimeAnimatorController;let r=s==null?void 0:s.findState(this.stateName),o=[],a=[];if(s&&r){const p=new Array;p.push(r);let m=!1;for(;p.length<100;){if(!r||r===null||!r.transitions||r.transitions.length===0){(u=r.motion)!=null&&u.isLooping&&(m=!0);break}const g=r.transitions.find(v=>v.conditions.length===0),y=g?s.getState(g.destinationState,0):null;if(y&&p.includes(y)){r=y,m=!0;break}else if(g){if(r=y,!r)break;p.push(r)}else{m=((d=r.motion)==null?void 0:d.isLooping)??!1;break}}if(m&&r){const g=p.indexOf(r);o=p.slice(0,g),a=p.slice(g),Dk&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",a)}else o=p,a=[],Dk&&console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(p=>{var m,g,y;return((m=p.motion)==null?void 0:m.clip)&&((y=(g=p.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),a=a.filter(p=>{var m,g,y;return((m=p.motion)==null?void 0:m.clip)&&((y=(g=p.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),o.length===0&&a.length===0){console.warn("No clips found for state "+this.stateName+" on "+((f=this.animator)==null?void 0:f.name)+", can't export animation data");return}this.stateAnimationModel=t;const c=(p,m)=>{var y,v,A;if(!this.target)return;if(!((y=p.motion)!=null&&y.clip)){console.warn("No clip found for state "+p.name+" on "+((v=this.animator)==null?void 0:v.name)+", can't export animation data");return}const g=e.registerAnimation(this.target,p.motion.clip);g?m.push(g):console.warn("Couldn't register animation for state "+p.name+" on "+((A=this.animator)==null?void 0:A.name))};if(o.length>0){this.animationSequence=new Array;for(const p of o)c(p,this.animationSequence)}if(a.length>0){this.animationLoopAfterSequence=new Array;for(const p of a)c(p,this.animationLoopAfterSequence)}}},h(I_,"animationActions",[]),h(I_,"rootsWithExclusivePlayback",new Set),I_);let Em=yh;An([x(Gs)],Em.prototype,"animator",2);An([x()],Em.prototype,"stateName",2);class Mm extends Me{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}An([x(ge)],Mm.prototype,"target",2);class h0 extends Me{constructor(){super(...arguments);h(this,"target")}}An([x(Mm)],h0.prototype,"target",2);class u0 extends Mm{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}An([x()],u0.prototype,"type",2);An([x()],u0.prototype,"duration",2);class xP extends h0{}var Aoe=Object.defineProperty,yoe=Object.getOwnPropertyDescriptor,ql=(n,e,t,i)=>{for(var s=i>1?void 0:i?yoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Aoe(e,t,s),s};const Ok=ne("debugcharactercontroller");class Yd extends Me{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions");h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Yi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Yi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(Zh);i||(i=this.gameObject.addNewComponent(Zh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const c=r.dot(a)<0?-1:1,l=s.angleTo(a)*c;this.gameObject.setRotationFromAxisAngle(o,l),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){(t.contacts.length==0||t.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(t),Ok&&console.log(`Collision(${this._activeGroundCollisions.size}): ${t.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(t){this._activeGroundCollisions.delete(t),Ok&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var t;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const s=(t=this.context.physics.engine)==null?void 0:t.getLinearVelocity(i.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}ql([x(w)],Yd.prototype,"center",2);ql([x()],Yd.prototype,"radius",2);ql([x()],Yd.prototype,"height",2);class Xl extends Me{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new ie(0,0));h(this,"moveInput",new ie(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new oa)}awake(){this._currentRotation=new Ce}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}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(t,i,s){var r,o,a,c,l,u,d,f,p,m,g;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),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+=rt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const y=this.context.mainCameraComponent.forward;y.y=0,y.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),y),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&&s&&this.jumpForce>0){let y=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(y=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),y){this._jumpCount+=1;const v=this.controller.rigidbody,A=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(A))}}if(this.controller){const y=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(y<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new To),this._raycastOptions.ray.origin.copy(Dt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const A=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(A.length&&A[0].distance>2||y<-10)&&((m=this.animator)==null||m.setBool("falling",!0))}else(g=this.animator)==null||g.setBool("falling",!1)}}}ql([x(Yd)],Xl.prototype,"controller",2);ql([x()],Xl.prototype,"movementSpeed",2);ql([x()],Xl.prototype,"rotationSpeed",2);ql([x()],Xl.prototype,"jumpForce",2);ql([x()],Xl.prototype,"doubleJumpForce",2);ql([x(Gs)],Xl.prototype,"animator",2);var _oe=Object.defineProperty,boe=Object.getOwnPropertyDescriptor,xoe=(n,e,t,i)=>{for(var s=i>1?void 0:i?boe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&_oe(e,t,s),s};class d0 extends fr{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new _4;return t.offset=new ie(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}xoe([x(kt)],d0.prototype,"intensity",2);da("ChromaticAberration",d0);const f0=new _t;f0.setAttribute("position",new tt(new Float32Array([-1,-1,3,-1,-1,3]),2));f0.setAttribute("uv",new tt(new Float32Array([0,0,2,0,0,2]),2));f0.boundingSphere=new kn;f0.computeBoundingSphere=function(){};const woe=new zl;class Fu{constructor(e){this._mesh=new me(f0,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,woe)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const Soe={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new xe},viewMat:{value:new xe},projViewMat:{value:new xe},projectionMatrixInv:{value:new xe},viewMatrixInv:{value:new xe},cameraPos:{value:new w},resolution:{value:new ie},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|
|
5544
5544
|
varying vec2 vUv;
|
|
5545
5545
|
void main() {
|
|
5546
5546
|
vUv = uv;
|
|
@@ -6159,7 +6159,7 @@ void main() {
|
|
|
6159
6159
|
void main() {
|
|
6160
6160
|
vec2 uv = vUv - vec2(0.5) / resolution;
|
|
6161
6161
|
vec2 pixelSize = vec2(1.0) / resolution;
|
|
6162
|
-
vec2[4] uvSamples;
|
|
6162
|
+
highp vec2[4] uvSamples;
|
|
6163
6163
|
uvSamples[0] = uv;
|
|
6164
6164
|
uvSamples[1] = uv + vec2(pixelSize.x, 0.0);
|
|
6165
6165
|
uvSamples[2] = uv + vec2(0.0, pixelSize.y);
|
|
@@ -6300,7 +6300,7 @@ void main() {
|
|
|
6300
6300
|
}`};var Goe=Object.defineProperty,Voe=Object.getOwnPropertyDescriptor,g0=(n,e,t,i)=>{for(var s=i>1?void 0:i?Voe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Goe(e,t,s),s};const w1=ne("debugcontactshadows");class pu extends Me{constructor(){super(...arguments);h(this,"darkness",.5);h(this,"opacity",.5);h(this,"blur",4);h(this,"occludeBelowGround",!0);h(this,"backfaceShadows",!0);h(this,"shadowCamera");h(this,"shadowGroup");h(this,"renderTarget");h(this,"renderTargetBlur");h(this,"plane");h(this,"occluderMesh");h(this,"blurPlane");h(this,"depthMaterial");h(this,"horizontalBlurMaterial");h(this,"verticalBlurMaterial")}awake(){w1&&console.log("Create ContactShadows on "+this.gameObject.name,this);const t=512;this.shadowGroup=new Rr,this.gameObject.add(this.shadowGroup),this.renderTarget=new Zt(t,t),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Zt(t,t),this.renderTargetBlur.texture.generateMipmaps=!1;const i=new as(1,1).rotateX(Math.PI/2);if(this.gameObject instanceof me){w1&&console.log("ContactShadows: use existing mesh",this.gameObject),this.plane=this.gameObject;const s=this.plane.material=this.plane.material.clone();s.map=this.renderTarget.texture,s.opacity=this.opacity}else{const s=new li({map:this.renderTarget.texture,opacity:this.opacity,color:0,transparent:!0,depthWrite:!1});this.plane=new me(i,s),this.plane.scale.y=-1,this.gameObject.add(this.plane)}this.plane&&(this.plane.renderOrder=1),this.occludeBelowGround&&(this.occluderMesh=new me(this.plane.geometry,new li({depthWrite:!0,stencilWrite:!0,colorWrite:!1})).translateY(-1e-4),this.occluderMesh.renderOrder=-100,this.gameObject.add(this.occluderMesh)),this.blurPlane=new me(i),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane),this.shadowCamera=new zl(-1/2,1/2,1/2,-1/2,0,1),this.shadowCamera.rotation.x=Math.PI/2,this.shadowGroup.add(this.shadowCamera),this.depthMaterial=new AA,this.depthMaterial.userData.darkness={value:this.darkness},this.depthMaterial.blending=TT,this.depthMaterial.blendEquation=gb,this.backfaceShadows&&(this.depthMaterial.side=bi),this.depthMaterial.onBeforeCompile=s=>{this.depthMaterial&&(s.uniforms.darkness=this.depthMaterial.userData.darkness,s.fragmentShader=`
|
|
6301
6301
|
uniform float darkness;
|
|
6302
6302
|
${s.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 1.0 ), ( 1.0 - fragCoordZ ) * darkness * opacity * (gl_FrontFacing ? 1.0 : 0.66) );")}
|
|
6303
|
-
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Pt(Noe),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Pt(zoe),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var t,i,s,r,o,a,c,l;(t=this.renderTarget)==null||t.dispose(),(i=this.renderTargetBlur)==null||i.dispose(),(s=this.depthMaterial)==null||s.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(a=this.blurPlane)==null||a.geometry.dispose(),(c=this.plane)==null||c.geometry.dispose(),(l=this.occluderMesh)==null||l.geometry.dispose()}onBeforeRender(t){const i=this.context.scene,s=this.context.renderer,r=s.getRenderTarget();if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){w1&&console.error("ContactShadows: not initialized yet");return}this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof me&&(this.gameObject.visible=!1,Kf(this.gameObject,!1));const a=i.background;i.background=null,i.overrideMaterial=this.depthMaterial;const c=s.getClearAlpha();s.setClearAlpha(0),s.setRenderTarget(this.renderTarget),s.render(i,this.shadowCamera),i.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=o,s.setRenderTarget(r),s.setClearAlpha(c),i.background=a}blurShadow(t){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=t*1/256;const i=this.context.renderer,s=i.getRenderTarget();i.setRenderTarget(this.renderTargetBlur),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=t*1/256,i.setRenderTarget(this.renderTarget),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,i.setRenderTarget(s)}}g0([x()],pu.prototype,"darkness",2);g0([x()],pu.prototype,"opacity",2);g0([x()],pu.prototype,"blur",2);g0([x()],pu.prototype,"occludeBelowGround",2);g0([x()],pu.prototype,"backfaceShadows",2);var Hoe=Object.defineProperty,Qoe=Object.getOwnPropertyDescriptor,v0=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hoe(e,t,s),s};const kk=ne("debugwebxr"),joe=new xe().makeRotationY(Math.PI);class Mo extends Me{constructor(){super(...arguments);h(this,"_arScale",1);h(this,"invertForward",!1);h(this,"customReticle");h(this,"useXRAnchor",!1);h(this,"arTouchTransform",!1);h(this,"_isPlacing",!0);h(this,"_startOffset",new xe);h(this,"_createdPlacementObject",null);h(this,"_reparentedComponents",[]);h(this,"_placementScene",new ur);h(this,"_reticle",[]);h(this,"_hits",[]);h(this,"_placementStartTime",-1);h(this,"_rigPlacementMatrix");h(this,"_anchor",null);h(this,"userInput");h(this,"onPlaceScene",t=>{var r;if(this._isPlacing==!1)return;let i=this._reticle[0],s=this._hits[0];if(t.origin instanceof IR){const o=this._reticle[t.origin.index];o&&(i=o,s=this._hits[t.origin.index])}if(!i){console.warn("No reticle to place...");return}if(!i.visible){console.warn("Reticle is not visible (can not place)");return}if((r=vt.active)!=null&&r.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}t.stopImmediatePropagation(),t.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(i),this.useXRAnchor&&this.onCreateAnchor(vt.active,s)})}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){kk&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new ge;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let s=this.context.scene.children.length-1;s>=0;s--){const r=this.context.scene.children[s];this._placementScene.add(r)}this.context.scene.add(i),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),le.addComponent(i,this);for(const s of this._reticle)Fa(s);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,ac.Early)}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,ac.Early),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,s,r,o;if(t.xr.isTrackingImages){for(const a of this._reticle)a.visible=!1;return}if(this._isPlacing){const a=(i=t.xr.rig)==null?void 0:i.gameObject;a&&a.parent!==this.context.scene&&this.context.scene.add(a);let c=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0)for(const l of t.xr.controllers){const u=l.getHitTest();u&&(c=!0,this.updateReticleAndHits(t.xr,l.index,u,t.xr.rigScale))}if(!c){const l=t.xr.getHitTest();l&&this.updateReticleAndHits(t.xr,0,l,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const a=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(a&&this.context.time.frame%20===0){const c=t.xr.convertSpace(a.transform),l=this._reticle[0];l&&(l.position.copy(c.position),l.quaternion.copy(c.quaternion),this.onApplyPose(l))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new Zf(this.context)),(s=this.userInput)==null||s.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(t.xr.rig){const a=t.xr.rig.gameObject;this.userInput.applyMatrixTo(a.matrix,!0),a.matrix.decompose(a.position,a.quaternion,a.scale),this.userInput.factor=a.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,s,r){this._hits[i]=s.hit;let o=this._reticle[i];if(!o){if(this.customReticle)if(this.customReticle.asset)o=hm(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new me(new Md(.07,.09,32).rotateX(-Math.PI/2),new li({side:bi})),o.name="AR Placement Reticle";if(kk){const a=new na(1);a.position.y+=.01,o.add(a)}this._reticle[i]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(s.position,this.context.time.deltaTime/.1),o.quaternion.slerp(s.quaternion,this.context.time.deltaTime/.05),o.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(o),o.updateMatrix(),o.visible=!0,o.parent!==this.context.scene&&this.context.scene.add(o),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i==null||i.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const s=this._placementScene.children[i];this.context.scene.add(s)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)le.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),Ct()&&gn("Hit does not support creating an anchor");return}else{const s=await i.createAnchor(t.viewerPose.transform);t.running&&s&&(this._anchor=s)}}applyViewBasedTransform(t){const i=this.context.mainCamera,s=t,r=i.worldPosition,o=s.worldPosition;r.y=o.y,t.lookAt(r)}onApplyPose(t){var s,r,o,a;const i=(r=(s=vt.active)==null?void 0:s.rig)==null?void 0:r.gameObject;if((o=vt.active)!=null&&o.rigScale,i){const c=i.parent||this.context.scene;this._rigPlacementMatrix?(a=this._rigPlacementMatrix)==null||a.decompose(i.position,i.quaternion,i.scale):this._rigPlacementMatrix=i.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(i),t.removeFromParent(),i.scale.set(this.arScale,this.arScale,this.arScale),i.position.multiplyScalar(this.arScale),i.updateMatrix(),this.invertForward&&i.matrix.premultiply(joe),i.matrix.premultiply(this._startOffset),i.matrix.decompose(i.position,i.quaternion,i.scale),c.add(i)}}}v0([x()],Mo.prototype,"arScale",1);v0([x()],Mo.prototype,"invertForward",2);v0([x(ii)],Mo.prototype,"customReticle",2);v0([x()],Mo.prototype,"useXRAnchor",2);v0([x()],Mo.prototype,"arTouchTransform",2);const bx=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"factor",1);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_hasChanged",!1);h(this,"_enabled",!1);h(this,"currentlyUsedPointerIds",new Set);h(this,"currentlyUnusedPointerIds",new Set);h(this,"onPointerDownEarly",e=>{this.isActive&&e.stopPropagation()});h(this,"onPointerDownLate",e=>{e.used?this.currentlyUsedPointerIds.add(e.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(e.pointerId)});h(this,"onPointerUpEarly",e=>{this.currentlyUsedPointerIds.delete(e.pointerId),this.currentlyUnusedPointerIds.delete(e.pointerId)});h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.has(i.identifier)||this.prev.set(i.identifier,{x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(i.identifier);if(s){const r=this.getPositionOnPlane(i.clientX,i.clientY);s.x=r.x,s.z=r.z,s.screenx=i.clientX,s.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1)});h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i)return;const s=this.getPositionOnPlane(t.clientX,t.clientY),r=s.x-i.x,o=s.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=s.x,i.z=s.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],s=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!s||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(s.screeny-r.screeny,s.screenx-r.screenx),c=o-a;Math.abs(c)>.001&&this.addRotation(c)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,c=Math.sqrt(o*o+a*a),l=s.screenx-r.screenx,u=s.screeny-r.screeny,d=Math.sqrt(l*l+u*u),f=c-d;Math.abs(f)>2&&this.addScale(f)}s.screenx=t.clientX,s.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new tm);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new xe);this.context=e,this.offset=new xe,this.plane=new Er,this.plane.setFromNormalAndCoplanarPoint(bx.up,bx.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(e,t){this._hasChanged=!1,t?(this.offset.invert(),e.premultiply(this.offset)):e.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,ac.Early),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,ac.Late),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,ac.Early),window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,this.context.input.removeEventListener("pointerdown",this.onPointerDownEarly,ac.Early),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,ac.Late),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,ac.Early),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e/=this._scale,t/=this._scale,e*=this.factor,t*=this.factor,this.offset.elements[12]+=e,this.offset.elements[14]+=t,(e!==0||t!==0)&&(this._hasChanged=!0)}addScale(e){e/=window.innerWidth,e*=-1,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}addRotation(e){e*=-1,this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}};let Zf=bx;h(Zf,"up",new w(0,1,0)),h(Zf,"zero",new w(0,0,0)),h(Zf,"one",new w(1,1,1));const g2=class{constructor(){h(this,"_quicklookButton");h(this,"_arButton");h(this,"_vrButton");h(this,"_sendToQuestButton");h(this,"_qrButton")}static create(){return new g2}static getOrCreate(){return this._instance||(this._instance=this.create()),this._instance}get isSecureConnection(){return window.location.protocol==="https:"}get quicklookButton(){return this._quicklookButton}get arButton(){return this._arButton}get vrButton(){return this._vrButton}get sendToQuestButton(){return this._sendToQuestButton}get qrButton(){return this._qrButton}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const e=document.createElement("button");return this._quicklookButton=e,e.dataset.needle="quicklook-button",e.innerText="Open in Quicklook",e.addEventListener("click",()=>{const t=le.findObjectOfType(rs);t?(e.classList.add("this-mode-is-requested"),t.exportAsync().then(()=>{e.classList.remove("this-mode-is-requested")}).catch(i=>{e.classList.remove("this-mode-is-requested"),console.error(i)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(e),e}createARButton(e){var s;if(this._arButton)return this._arButton;const t="immersive-ar",i=document.createElement("button");return this._arButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-ar-button",i.innerText="Enter AR",i.title="Click to start a WebXR session in AR",i.addEventListener("click",()=>vt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),pd()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createVRButton(e){var s;if(this._vrButton)return this._vrButton;const t="immersive-vr",i=document.createElement("button");return this._vrButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-vr-button",i.innerText="Enter VR",i.title="Click to start a WebXR session in VR",i.addEventListener("click",()=>vt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),pd()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createSendToQuestButton(){var i;if(this._sendToQuestButton)return this._sendToQuestButton;const e="https://oculus.com/open_url/?url=",t=document.createElement("button");return this._sendToQuestButton=t,t.dataset.needle="webxr-sendtoquest-button",t.innerText="Open on Quest",t.title="Click to send this page to the Oculus Browser on your Quest",t.addEventListener("click",()=>{const s=encodeURIComponent(window.location.href);window.open(e+s)}),this.listenToXRSessionState(t),this.hideElementDuringXRSession(t),pd()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>{var s;(s=navigator.xr)!=null&&s.isSessionSupported("immersive-vr")?t.style.display="none":t.style.display=""}),t}createQRCode(){if(this._qrButton)return this._qrButton;const e=document.createElement("button");this._qrButton=e,e.innerText="QR Code",e.title="Scan this QR code with your phone to open this page",this.hideElementDuringXRSession(e);const t=document.createElement("div");t.style.position="fixed",t.style.display="inline-block",t.style.padding="1rem",t.style.backgroundColor="white",t.style.borderRadius="0.4rem",t.style.cursor="pointer",t.style.zIndex="1000",t.style.boxShadow="0 0 12px rgba(0, 0, 0, 0.2)";const i=document.createElement("div");i.classList.add("qr-code-container"),t.appendChild(i),e.addEventListener("click",()=>{if(t.parentNode)return r();s()});async function s(){await o(),document.body.appendChild(t);const a=i.getBoundingClientRect(),c=e.getBoundingClientRect();t.style.left=c.left+c.width*.5-a.width*.5+"px",c.top<a.height?t.style.top=`calc(${c.bottom}px + ${t.style.padding} * .6)`:t.style.top=`calc(${c.top-a.height}px - ${t.style.padding} * 2.5)`,setTimeout(()=>window.addEventListener("click",r,{once:!0})),window.addEventListener("resize",r),window.addEventListener("scroll",r),document.body.appendChild(t)}function r(){var a;(a=t.parentNode)==null||a.removeChild(t),window.removeEventListener("click",r),window.removeEventListener("resize",r),window.removeEventListener("scroll",r)}async function o(){const c=await p3({text:window.location.href,width:200,height:200});i.innerHTML="",i.appendChild(c)}return e.addEventListener("pointerenter",()=>{o()},{once:!0}),e}updateSessionSupported(e,t){if(!("xr"in navigator)){e.style.display="none";return}vt.isSessionSupported(t).then(i=>{e.style.display=i?"":"none",Ct()&&!i&&console.warn(t+" is not supported on this device - make sure your server runs using HTTPS and you have a device connected that supports "+t)})}hideElementDuringXRSession(e){vt.onXRSessionStart(t=>{e["previous-display"]=e.style.display,e.style.display="none"}),vt.onXRSessionEnd(t=>{e["previous-display"]!=null&&(e.style.display=e["previous-display"])})}listenToXRSessionState(e,t){t&&(vt.onSessionRequestStart(i=>{i.mode===t?e.classList.add("this-mode-is-requested"):(e["was-disabled"]=e.disabled,e.disabled=!0,e.classList.add("other-mode-is-requested"))}),vt.onSessionRequestEnd(i=>{e.classList.remove("this-mode-is-requested"),e.classList.remove("other-mode-is-requested"),e.disabled=e["was-disabled"]}))}};let Vh=g2;h(Vh,"_instance");var Woe=Object.defineProperty,qoe=Object.getOwnPropertyDescriptor,Yl=(n,e,t,i)=>{for(var s=i>1?void 0:i?qoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Woe(e,t,s),s};const Uu=ne("debugtext");var Jn=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(Jn||{}),P8=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(P8||{});class Nr extends jd{constructor(){super(...arguments);h(this,"alignment",0);h(this,"verticalOverflow",0);h(this,"horizontalOverflow",0);h(this,"lineSpacing",1);h(this,"supportRichText",!1);h(this,"font");h(this,"fontStyle",0);h(this,"sRGBTextColor",new _e(1,0,1));h(this,"_text","");h(this,"_fontSize",12);h(this,"_textMeshUi",null);h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){Uu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Uu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Uu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(Uu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let u=this.uiObject.children.length-1;u>=0;u--){const d=this.uiObject.children[u];d.isUI&&(this.uiObject.remove(d),d.clear())}const l=new U_({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;a;){const l=this.getNextTag(t,a.endIndex),u={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){u.textContent=this.getText(t,a,l),this.handleTag(a,u,c);const d=new U_(u);(r=this.uiObject)==null||r.add(d)}else{u.textContent=t.substring(a.endIndex),this.handleTag(a,u,c);const d=new U_(u);(o=this.uiObject)==null||o.add(d)}a=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(ox(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new S1(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new _e(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new S1(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new S1(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);Uu&&console.log("Selected font family:"+r);let o=iM.getFontFamily(r);switch(o||(o=iM.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let c=r;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,c,l),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var u;const s=t.lastIndexOf("-");if(s<0)return t;const r=(u=t.substring(s+1))==null?void 0:u.toLowerCase();if(Xoe.includes(r))return Uu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const c=a[0]===a[0].toUpperCase(),l=t.substring(0,s);switch(Uu&&console.log("Select font: ",t,P8[i],a,c,l),i){case 0:return c?l+"-Regular":l+"-regular";case 1:return c?l+"-Bold":l+"-bold";case 2:return c?l+"-Italic":l+"-italic";case 3:return c?l+"-BoldItalic":l+"-bolditalic";default:return t}}}Yl([x()],Nr.prototype,"alignment",2);Yl([x()],Nr.prototype,"verticalOverflow",2);Yl([x()],Nr.prototype,"horizontalOverflow",2);Yl([x()],Nr.prototype,"lineSpacing",2);Yl([x()],Nr.prototype,"supportRichText",2);Yl([x(URL)],Nr.prototype,"font",2);Yl([x()],Nr.prototype,"fontStyle",2);Yl([x()],Nr.prototype,"text",1);Yl([x()],Nr.prototype,"fontSize",1);class S1{constructor(e,t){h(this,"tag");h(this,"previousValues");this.tag=e,this.previousValues=t}}const Xoe=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Oh{constructor(e){h(this,"id");h(this,"content","");h(this,"font",[]);h(this,"pointSize",144);h(this,"width");h(this,"height");h(this,"depth");h(this,"wrapMode");h(this,"horizontalAlignment");h(this,"verticalAlignment");h(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),t.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),t.closeBlock(")"),t.beginBlock(),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </StageRoot/Materials/${YR(this.material)}>`),t.closeBlock()}}h(Oh,"global_id",0);class eS{static singleLine(e,t,i){const s=new Oh("text_"+Oh.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new Oh("text_"+Oh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Yoe=new xe().makeRotationY(Math.PI),Joe=new xe().makeScale(-1,1,-1);class A0{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=le.getComponent(e,Nr);if(!s)return;const r=le.getComponent(e,Lr);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Yoe.clone(),r&&t.matrix.premultiply(Joe);const c=s.color.clone();t.material=new eo({color:c,emissive:c}),t.addEventListener("serialize",(l,u)=>{let d=s.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const f=eS.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.writeTo(void 0,l)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Jn.LowerLeft:case Jn.MiddleLeft:case Jn.UpperLeft:e.horizontalAlignment="left";break;case Jn.LowerCenter:case Jn.MiddleCenter:case Jn.UpperCenter:e.horizontalAlignment="center";break;case Jn.LowerRight:case Jn.MiddleRight:case Jn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Jn.LowerLeft:case Jn.LowerCenter:case Jn.LowerRight:e.verticalAlignment="bottom";break;case Jn.MiddleLeft:case Jn.MiddleCenter:case Jn.MiddleRight:e.verticalAlignment="middle";break;case Jn.UpperLeft:case Jn.UpperCenter:case Jn.UpperRight:e.verticalAlignment="top";break}}}class tS{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=le.getComponent(e,Vs);if(s&&s.activeAndEnabled&&s.renderMode===b8.WorldSpace){const r=new A0,o=le.getComponent(e,Lr),a=le.getComponent(e,$h);if(o){o.width,o.height;const c=Zr.createEmpty(),l=o.shadowComponent;if(t.add(c),l){const u=l.matrix;c.matrix.copy(u);const d=new Map,f=new Map;d.set(l,c),f.set(l,a?a.alpha:1),l.traverse(p=>{if(p===l)return;const m=Zr.createEmpty();m.matrix.copy(p.matrix);const g=p.parent,y=!!g&&typeof g.textContent=="string"&&g.textContent.length>0;let v=f.get(g)||1;const A=le.getComponent(p,$h);if(A&&(v*=A.alpha),p instanceof me&&y){const b=p[Jo];b?r.exportText(b.gameObject,m,i):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",p)}if(p instanceof me&&!y){const b=p.geometry.clone();b.scale(1,1,-1),this.flipWindingOrder(b),m.geometry=b;const C=new _e,M=p.material.opacity;C.copy(p.material.color),m.material=new li({color:C,opacity:M*v,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,v);const _=d.get(g);if(!_){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}_.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}const h_=ne("debugusdz");function Koe(n,e){var o;const t=[],i=le.getComponentsInChildren(n,Gs),s=le.getComponentsInChildren(n,Co),r=new Array;if(e.injectImplicitBehaviours)for(const a of i){if(!a||!a.runtimeAnimatorController)continue;const c=a.runtimeAnimatorController.activeState;if(!c||!c.motion||!c.motion.clip||((o=c.motion.clip.tracks)==null?void 0:o.length)<1)continue;const l=new Em;l.animator=a,l.stateName=c.name,l.trigger="start",l.name="PlayAnimationOnClick_implicitAtStart_"+l.stateName;const u=new ge;le.addComponent(u,l),r.push(u),n.add(u)}else for(const a of i){if(!a||!a.runtimeAnimatorController)continue;h_&&console.log(a);const c=[];for(const l of a.runtimeAnimatorController.enumerateActions()){h_&&console.log(l);const u=l.getClip();c.includes(u)||c.push(u)}t.push({root:a.gameObject,clips:c})}for(const a of s){h_&&console.log(a);const c=[];for(const l of a.animations)c.includes(l)||c.push(l);t.push({root:a.gameObject,clips:c})}h_&&console.log("USDZ Animation Clips",t);for(const a of t)for(const c of a.clips)e.registerAnimation(a.root,c);return r}function Zoe(n,e){const t=le.getComponentsInChildren(n,vn),i=le.getComponentsInChildren(n,eu),s=new Array;for(const r of i){if(!r.target)continue;const o=t.indexOf(r.target);o>-1&&t.splice(o,1)}for(const r of t){if(!r||!r.clip||r.volume<=0)continue;const o=new eu;o.target=r,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;le.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),s.push(a),n.add(a)}return s}function Lk(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}var $oe=Object.defineProperty,eae=Object.getOwnPropertyDescriptor,pr=(n,e,t,i)=>{for(var s=i>1?void 0:i?eae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$oe(e,t,s),s};const Qr=ne("debugusdz");class mu{constructor(){h(this,"callToAction");h(this,"checkoutTitle");h(this,"checkoutSubtitle");h(this,"callToActionURL")}}pr([x()],mu.prototype,"callToAction",2);pr([x()],mu.prototype,"checkoutTitle",2);pr([x()],mu.prototype,"checkoutSubtitle",2);pr([x()],mu.prototype,"callToActionURL",2);var nE;const nT=(nE=class extends Me{constructor(){super(...arguments);h(this,"objectToExport");h(this,"autoExportAnimations",!1);h(this,"autoExportAudioSources",!0);h(this,"exportFileName");h(this,"customUsdzFile");h(this,"customBranding");h(this,"anchoringType","plane");h(this,"maxTextureSize",2048);h(this,"planeAnchoringAlignment","horizontal");h(this,"interactive",!0);h(this,"allowCreateQuicklookButton",!0);h(this,"quickLookCompatible",!0);h(this,"extensions",[]);h(this,"link");h(this,"button");h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()});h(this,"lastCallback")}start(){var e,t,i;Qr&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",s=>{switch(s.key){case"t":this.exportAsync();break}}),Bc()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Yw),this.extensions.push(new Kh),this.extensions.push(new A0),this.extensions.push(new tS))}onEnable(){var i;const e=im(),t=_p();(Qr||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=Lk(this.context),this.link.addEventListener("message",this.lastCallback)),Qr&&pn("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t,i;(e=this.button)==null||e.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Qr&&pn("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+HG(),Rl()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=Lk(this.context)),this.customUsdzFile){Qr&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e);return}const t=await this.export(this.objectToExport);if(!t){console.warn("No object to export",this);return}Qr&&console.log("USDZ generation done. Downloading as "+this.link.download),this.openInQuickLook(t,e)}async export(e){if(!e)return null;ri.start("export-usdz",{onProgress:m=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:m}}))}}),ri.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ri.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ri.start("export-usdz-textures","export-usdz");const t=le.getComponentsInChildren(e,En),i=new Array;let s=0;for(const m of t)for(const g of m.sharedMaterials)if(g){const y=m.loadProgressiveTextures(g);y instanceof Promise&&i.push(new Promise((v,A)=>{y.then(()=>{s++,ri.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:s,totalSteps:i.length}),v()}).catch(_=>A(_))}))}Qr&&pn("Load textures: "+i.length),await Promise.all(i),Qr&&pn("Load textures: done"),ri.end("export-usdz-textures");const r=ks.Global.Mask;ks.Global.Set(uc.AR),this.applyWebARSessionRoot();const o=new vne,a=[...this.extensions],c=new $A(this.quickLookCompatible);a.push(c);const l={self:this,exporter:o,extensions:a,object:e};ri.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:l})),ri.report("export-usdz","auto export animations and audio sources");const u=new Array;this.autoExportAnimations&&u.push(...Koe(e,c)),this.extensions.find(m=>m.extensionName==="Audio")&&this.autoExportAudioSources&&u.push(...Zoe(e)),o.debug=Qr,o.keepObject=m=>{const g=le.getComponent(m,En);return!(g&&!g.enabled)},this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal"),ri.report("export-usdz","Invoking exporter.parse");const f=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),p=new Blob([f],{type:"vnd.usdz+zip"});for(const m of u)le.destroy(m);return ri.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:l})),ks.Global.Set(r),ri.end("export-usdz"),p}openInQuickLook(e,t){const i=e instanceof Blob?URL.createObjectURL(e):e,s=this.buildQuicklookOverlay();Qr&&console.log("QuickLook Overlay",s);const r=s.callToAction?encodeURIComponent(s.callToAction):"",o=s.checkoutTitle?encodeURIComponent(s.checkoutTitle):"",a=s.checkoutSubtitle?encodeURIComponent(s.checkoutSubtitle):"";this.link.href=i+`#callToAction=${r}&checkoutTitle=${o}&checkoutSubtitle=${a}&callToActionURL=${s.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(e,t){nT.save(e,t)}static save(e,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof e=="string"?i.href=e:i.href=URL.createObjectURL(e),i.download=t,i.click(),i.remove()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Qr&&gn("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const s=i.get("callToActionURL");Qr&&pn("Quicklook url: "+s),s&&(Rl()?globalThis.open(s,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",s))}}}}buildQuicklookOverlay(){var i,s,r,o,a,c;const e={};return this.customBranding&&Object.assign(e,this.customBranding),Rl()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="๐ต Made with Needle",e.checkoutSubtitle="_"),(((i=e.callToAction)==null?void 0:i.length)||((s=e.checkoutTitle)==null?void 0:s.length)||((r=e.checkoutSubtitle)==null?void 0:r.length))&&((o=e.callToAction)!=null&&o.length||(e.callToAction="\0"),(a=e.checkoutTitle)!=null&&a.length||(e.checkoutTitle="\0"),(c=e.checkoutSubtitle)!=null&&c.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=le.getComponentInParent(this.objectToExport,Mo);const t=e!=null;if(e||(e=le.getComponentInChildren(this.objectToExport,Mo)),Qr&&console.log("applyWebARSessionRoot",e),!e){Qr&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=t?this.objectToExport:e.gameObject,s=1/e.arScale;i.matrix.makeScale(s,s,s),e.invertForward&&i.matrix.multiply(nT.invertForwardMatrix)}createQuicklookButton(){const t=Vh.getOrCreate().createQuicklookButton();return t.parentNode||this.context.menu.appendChild(t),t}},h(nE,"invertForwardMatrix",new xe().makeRotationY(Math.PI)),nE);let rs=nT;pr([x(ge)],rs.prototype,"objectToExport",2);pr([x()],rs.prototype,"autoExportAnimations",2);pr([x()],rs.prototype,"autoExportAudioSources",2);pr([x()],rs.prototype,"exportFileName",2);pr([x(URL)],rs.prototype,"customUsdzFile",2);pr([x(mu)],rs.prototype,"customBranding",2);pr([x()],rs.prototype,"anchoringType",2);pr([x()],rs.prototype,"maxTextureSize",2);pr([x()],rs.prototype,"planeAnchoringAlignment",2);pr([x()],rs.prototype,"interactive",2);pr([x()],rs.prototype,"allowCreateQuicklookButton",2);pr([x()],rs.prototype,"quickLookCompatible",2);class y0 extends Me{constructor(){super(...arguments);h(this,"isUsed",!0);h(this,"usedBy",null)}}class wP extends Me{}const Fk=ne("debugdeletable");class iS extends Ko{}class SP extends Me{constructor(){super(...arguments);h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=le.findObjectsOfType(iS,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=le.getComponentInParent(this.gameObject,y0);r?Fk&&console.warn("Can not delete object with usage marker",this.guid,r):(Fk&&console.log("DESTROY",this.gameObject),Pw(this.gameObject,this.context.connection))}}}}var tae=Object.defineProperty,iae=Object.getOwnPropertyDescriptor,Kd=(n,e,t,i)=>{for(var s=i>1?void 0:i?iae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tae(e,t,s),s};const Uk=ne("debugpost");class Qa extends fr{constructor(){super(...arguments);h(this,"mode");h(this,"focusDistance");h(this,"focalLength");h(this,"aperture");h(this,"gaussianMaxRadius");h(this,"resolutionScale");h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){Uk&&console.log("DOF: INIT"),this.focalLength.valueProcessor=i=>{const s=i/300,r=2;return rt.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return rt.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0){Uk&&console.warn("DepthOfField: Mode is set to Off");return}const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Bc()&&(s=.6),this.resolutionScale=new kt(s*t)}const i=new b4(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.cocMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.cocMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Kd([x()],Qa.prototype,"mode",2);Kd([x(kt)],Qa.prototype,"focusDistance",2);Kd([x(kt)],Qa.prototype,"focalLength",2);Kd([x(kt)],Qa.prototype,"aperture",2);Kd([x(kt)],Qa.prototype,"gaussianMaxRadius",2);Kd([x(kt)],Qa.prototype,"resolutionScale",2);Kd([x(kt)],Qa.prototype,"bokehScale",2);da("DepthOfField",Qa);var nae=Object.defineProperty,sae=Object.getOwnPropertyDescriptor,rae=(n,e,t,i)=>{for(var s=i>1?void 0:i?sae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nae(e,t,s),s};class nS extends Me{constructor(){super(...arguments);h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||le.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Bc()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}rae([x()],nS.prototype,"visibleOn",2);class CP{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var oae=Object.defineProperty,aae=Object.getOwnPropertyDescriptor,Zd=(n,e,t,i)=>{for(var s=i>1?void 0:i?aae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&oae(e,t,s),s};const xc=ne("debugdrag");var B8=(n=>(n[n.XZPlane=0]="XZPlane",n[n.Attached=1]="Attached",n[n.HitNormal=2]="HitNormal",n[n.DynamicViewAngle=3]="DynamicViewAngle",n[n.SnapToSurfaces=4]="SnapToSurfaces",n[n.None=5]="None",n))(B8||{}),B_;const tc=(B_=class extends Me{constructor(){super(...arguments);h(this,"dragMode",3);h(this,"snapGridResolution",0);h(this,"keepRotation",!0);h(this,"xrDragMode",1);h(this,"xrKeepRotation",!1);h(this,"xrDistanceDragFactor",1);h(this,"showGizmo",!1);h(this,"targetObject",null);h(this,"orbit",null);h(this,"_dragHelper",null);h(this,"_draggingRigidbodies",[]);h(this,"_potentialDragStartEvt",null);h(this,"_dragHandlers",new Map);h(this,"_totalMovement",new w);h(this,"_marker",null);h(this,"_isDragging",!1);h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(e){this.targetObject=e;for(const t of this._dragHandlers.values())t.setTargetObject(e)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new w,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=le.findObjectOfType(Ki,this.context),this.gameObject.getComponentInParent(Eo)||this.gameObject.addNewComponent(Eo)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||e.mode!=="screen"||(e.event.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)return;const s=le.getComponentInParent(e.object,tc);!s||s!==this||(tc.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&e.mode==="screen"&&tc.lastHovered===e.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(e){if(!(!this.allowEdit(this.gameObject)||e.used||(e.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)&&(tc.lastHovered=e.object,e.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=e),tc._active+=1;const s=new lae(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(e.event.space,s),this.orbit&&(this.orbit.enabled=!1),s.onDragStart(e),this._dragHandlers.size===2){const r=this._dragHandlers.values(),o=r.next().value,a=r.next().value,c=new cae(this,this.targetObject||this.gameObject,o,a);this._dragHandlers.set(this.gameObject,c),c.onDragStart(e)}e.use()}}onPointerMove(e){(this._isDragging||this._potentialDragStartEvt!==null)&&e.use()}onPointerUp(e){if(xc&&It.DrawLabel(e.point??this.gameObject.worldPosition,"POINTERUP:"+e.pointerId+", "+e.button,.03,3),!this.allowEdit(this.gameObject)||e.button!==0)return;this._potentialDragStartEvt=null;const t=this._dragHandlers.get(e.event.space),i=this._dragHandlers.get(this.gameObject);i&&(i.handlerA===t||i.handlerB===t)&&(this._dragHandlers.delete(this.gameObject),i.onDragEnd(e)),t&&(tc._active>0&&(tc._active-=1),t.onDragEnd&&t.onDragEnd(e),this._dragHandlers.delete(e.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(e),e.use()),tc._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const e of this._dragHandlers.values())e.collectMovementInfo&&e.collectMovementInfo(),e.getTotalMovement&&this._totalMovement.add(e.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const e=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(e)}for(const e of this._dragHandlers.values())e.onDragUpdate&&e.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new lb(this.context.mainCamera);else return;if(!e||!e.object)return;const t=le.getComponentInParent(e.object,tc);if(!t||t!==this)return;const i=this.targetObject||this.gameObject;if(!i)return;this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const s=le.getComponentInChildren(i,Jh);xc&&console.log("DRAG START",s,i),s&&(s.fastMode=!0,s==null||s.requestOwnership()),this._marker=le.addNewComponent(i,y0),this._draggingRigidbodies.length=0;const r=le.getComponentsInChildren(i,Yi);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities(),t.resetForcesAndTorques();const e=this.targetObject||this.gameObject;ka.markDirty(e)}onLastDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(xc&&console.log("DRAG END",t,t==null?void 0:t.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const i=le.getComponentInChildren(e.object,Jh);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy()}},h(B_,"_active",0),h(B_,"lastHovered"),B_);let aa=tc;Zd([x()],aa.prototype,"dragMode",2);Zd([x()],aa.prototype,"snapGridResolution",2);Zd([x()],aa.prototype,"keepRotation",2);Zd([x()],aa.prototype,"xrDragMode",2);Zd([x()],aa.prototype,"xrKeepRotation",2);Zd([x()],aa.prototype,"xrDistanceDragFactor",2);Zd([x()],aa.prototype,"showGizmo",2);class cae{constructor(e,t,i,s){h(this,"handlerA");h(this,"handlerB");h(this,"context");h(this,"settings");h(this,"gameObject");h(this,"_handlerAAttachmentPoint",new w);h(this,"_handlerBAttachmentPoint",new w);h(this,"_followObject");h(this,"_manipulatorObject");h(this,"_deviceMode");h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_manipulatorPosOffset",new w);h(this,"_manipulatorRotOffset",new Ce);h(this,"_manipulatorScaleOffset",new w);h(this,"_tempVec1",new w);h(this,"_tempVec2",new w);h(this,"_tempVec3",new w);h(this,"tempLookMatrix",new xe);h(this,"_initialScale",new w);h(this,"_initialDistance",0);var o,a;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=i,this.handlerB=s,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const r=(a=(o=vt.active)==null?void 0:o.rig)==null?void 0:a.gameObject;if(!this.handlerA||!this.handlerB||!this.handlerA.hitPointInLocalSpace||!this.handlerB.hitPointInLocalSpace){console.error("Invalid: MultiTouchDragHandler needs two valid DragPointerHandlers with hitPointInLocalSpace set.");return}if(this._tempVec1.copy(this.handlerA.hitPointInLocalSpace),this._tempVec2.copy(this.handlerB.hitPointInLocalSpace),this.gameObject.localToWorld(this._tempVec1),this.gameObject.localToWorld(this._tempVec2),r&&(r.worldToLocal(this._tempVec1),r.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(xc&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now โ controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(t.scale),xc){this._followObject.add(new na(2)),this._manipulatorObject.add(new na(5));const c=l=>`${l.x.toFixed(2)}, ${l.y.toFixed(2)}, ${l.z.toFixed(2)}`;It.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),It.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6303
|
+
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Pt(Noe),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Pt(zoe),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var t,i,s,r,o,a,c,l;(t=this.renderTarget)==null||t.dispose(),(i=this.renderTargetBlur)==null||i.dispose(),(s=this.depthMaterial)==null||s.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(a=this.blurPlane)==null||a.geometry.dispose(),(c=this.plane)==null||c.geometry.dispose(),(l=this.occluderMesh)==null||l.geometry.dispose()}onBeforeRender(t){const i=this.context.scene,s=this.context.renderer,r=s.getRenderTarget();if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){w1&&console.error("ContactShadows: not initialized yet");return}this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof me&&(this.gameObject.visible=!1,Kf(this.gameObject,!1));const a=i.background;i.background=null,i.overrideMaterial=this.depthMaterial;const c=s.getClearAlpha();s.setClearAlpha(0),s.setRenderTarget(this.renderTarget),s.render(i,this.shadowCamera),i.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=o,s.setRenderTarget(r),s.setClearAlpha(c),i.background=a}blurShadow(t){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=t*1/256;const i=this.context.renderer,s=i.getRenderTarget();i.setRenderTarget(this.renderTargetBlur),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=t*1/256,i.setRenderTarget(this.renderTarget),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,i.setRenderTarget(s)}}g0([x()],pu.prototype,"darkness",2);g0([x()],pu.prototype,"opacity",2);g0([x()],pu.prototype,"blur",2);g0([x()],pu.prototype,"occludeBelowGround",2);g0([x()],pu.prototype,"backfaceShadows",2);var Hoe=Object.defineProperty,Qoe=Object.getOwnPropertyDescriptor,v0=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hoe(e,t,s),s};const kk=ne("debugwebxr"),joe=new xe().makeRotationY(Math.PI);class Mo extends Me{constructor(){super(...arguments);h(this,"_arScale",1);h(this,"invertForward",!1);h(this,"customReticle");h(this,"useXRAnchor",!1);h(this,"arTouchTransform",!1);h(this,"_isPlacing",!0);h(this,"_startOffset",new xe);h(this,"_createdPlacementObject",null);h(this,"_reparentedComponents",[]);h(this,"_placementScene",new ur);h(this,"_reticle",[]);h(this,"_hits",[]);h(this,"_placementStartTime",-1);h(this,"_rigPlacementMatrix");h(this,"_anchor",null);h(this,"userInput");h(this,"onPlaceScene",t=>{var r;if(this._isPlacing==!1)return;let i=this._reticle[0],s=this._hits[0];if(t.origin instanceof IR){const o=this._reticle[t.origin.index];o&&(i=o,s=this._hits[t.origin.index])}if(!i){console.warn("No reticle to place...");return}if(!i.visible){console.warn("Reticle is not visible (can not place)");return}if((r=vt.active)!=null&&r.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}t.stopImmediatePropagation(),t.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(i),this.useXRAnchor&&this.onCreateAnchor(vt.active,s)})}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){kk&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new ge;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let s=this.context.scene.children.length-1;s>=0;s--){const r=this.context.scene.children[s];this._placementScene.add(r)}this.context.scene.add(i),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),le.addComponent(i,this);for(const s of this._reticle)Fa(s);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:ac.Early})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:ac.Early}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,s,r,o;if(t.xr.isTrackingImages){for(const a of this._reticle)a.visible=!1;return}if(this._isPlacing){const a=(i=t.xr.rig)==null?void 0:i.gameObject;a&&a.parent!==this.context.scene&&this.context.scene.add(a);let c=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0)for(const l of t.xr.controllers){const u=l.getHitTest();u&&(c=!0,this.updateReticleAndHits(t.xr,l.index,u,t.xr.rigScale))}if(!c){const l=t.xr.getHitTest();l&&this.updateReticleAndHits(t.xr,0,l,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const a=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(a&&this.context.time.frame%20===0){const c=t.xr.convertSpace(a.transform),l=this._reticle[0];l&&(l.position.copy(c.position),l.quaternion.copy(c.quaternion),this.onApplyPose(l))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new Zf(this.context)),(s=this.userInput)==null||s.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(t.xr.rig){const a=t.xr.rig.gameObject;this.userInput.applyMatrixTo(a.matrix,!0),a.matrix.decompose(a.position,a.quaternion,a.scale),this.userInput.factor=a.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,s,r){this._hits[i]=s.hit;let o=this._reticle[i];if(!o){if(this.customReticle)if(this.customReticle.asset)o=hm(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new me(new Md(.07,.09,32).rotateX(-Math.PI/2),new li({side:bi})),o.name="AR Placement Reticle";if(kk){const a=new na(1);a.position.y+=.01,o.add(a)}this._reticle[i]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(s.position,this.context.time.deltaTime/.1),o.quaternion.slerp(s.quaternion,this.context.time.deltaTime/.05),o.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(o),o.updateMatrix(),o.visible=!0,o.parent!==this.context.scene&&this.context.scene.add(o),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i==null||i.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const s=this._placementScene.children[i];this.context.scene.add(s)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)le.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),Ct()&&gn("Hit does not support creating an anchor");return}else{const s=await i.createAnchor(t.viewerPose.transform);t.running&&s&&(this._anchor=s)}}applyViewBasedTransform(t){const i=this.context.mainCamera,s=t,r=i.worldPosition,o=s.worldPosition;r.y=o.y,t.lookAt(r)}onApplyPose(t){var s,r,o,a;const i=(r=(s=vt.active)==null?void 0:s.rig)==null?void 0:r.gameObject;if((o=vt.active)!=null&&o.rigScale,i){const c=i.parent||this.context.scene;this._rigPlacementMatrix?(a=this._rigPlacementMatrix)==null||a.decompose(i.position,i.quaternion,i.scale):this._rigPlacementMatrix=i.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(i),t.removeFromParent(),i.scale.set(this.arScale,this.arScale,this.arScale),i.position.multiplyScalar(this.arScale),i.updateMatrix(),this.invertForward&&i.matrix.premultiply(joe),i.matrix.premultiply(this._startOffset),i.matrix.decompose(i.position,i.quaternion,i.scale),c.add(i)}}}v0([x()],Mo.prototype,"arScale",1);v0([x()],Mo.prototype,"invertForward",2);v0([x(ii)],Mo.prototype,"customReticle",2);v0([x()],Mo.prototype,"useXRAnchor",2);v0([x()],Mo.prototype,"arTouchTransform",2);const bx=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"factor",1);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_hasChanged",!1);h(this,"_enabled",!1);h(this,"currentlyUsedPointerIds",new Set);h(this,"currentlyUnusedPointerIds",new Set);h(this,"onPointerDownEarly",e=>{this.isActive&&e.stopPropagation()});h(this,"onPointerDownLate",e=>{e.used?this.currentlyUsedPointerIds.add(e.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(e.pointerId)});h(this,"onPointerUpEarly",e=>{this.currentlyUsedPointerIds.delete(e.pointerId),this.currentlyUnusedPointerIds.delete(e.pointerId)});h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.has(i.identifier)||this.prev.set(i.identifier,{x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(i.identifier);if(s){const r=this.getPositionOnPlane(i.clientX,i.clientY);s.x=r.x,s.z=r.z,s.screenx=i.clientX,s.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1)});h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i)return;const s=this.getPositionOnPlane(t.clientX,t.clientY),r=s.x-i.x,o=s.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=s.x,i.z=s.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],s=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!s||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(s.screeny-r.screeny,s.screenx-r.screenx),c=o-a;Math.abs(c)>.001&&this.addRotation(c)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,c=Math.sqrt(o*o+a*a),l=s.screenx-r.screenx,u=s.screeny-r.screeny,d=Math.sqrt(l*l+u*u),f=c-d;Math.abs(f)>2&&this.addScale(f)}s.screenx=t.clientX,s.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new tm);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new xe);this.context=e,this.offset=new xe,this.plane=new Er,this.plane.setFromNormalAndCoplanarPoint(bx.up,bx.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(e,t){this._hasChanged=!1,t?(this.offset.invert(),e.premultiply(this.offset)):e.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,{queue:ac.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:ac.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:ac.Early}),window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,this.context.input.removeEventListener("pointerdown",this.onPointerDownEarly,{queue:ac.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:ac.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:ac.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e/=this._scale,t/=this._scale,e*=this.factor,t*=this.factor,this.offset.elements[12]+=e,this.offset.elements[14]+=t,(e!==0||t!==0)&&(this._hasChanged=!0)}addScale(e){e/=window.innerWidth,e*=-1,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}addRotation(e){e*=-1,this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}};let Zf=bx;h(Zf,"up",new w(0,1,0)),h(Zf,"zero",new w(0,0,0)),h(Zf,"one",new w(1,1,1));const g2=class{constructor(){h(this,"_quicklookButton");h(this,"_arButton");h(this,"_vrButton");h(this,"_sendToQuestButton");h(this,"_qrButton")}static create(){return new g2}static getOrCreate(){return this._instance||(this._instance=this.create()),this._instance}get isSecureConnection(){return window.location.protocol==="https:"}get quicklookButton(){return this._quicklookButton}get arButton(){return this._arButton}get vrButton(){return this._vrButton}get sendToQuestButton(){return this._sendToQuestButton}get qrButton(){return this._qrButton}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const e=document.createElement("button");return this._quicklookButton=e,e.dataset.needle="quicklook-button",e.innerText="Open in Quicklook",e.addEventListener("click",()=>{const t=le.findObjectOfType(rs);t?(e.classList.add("this-mode-is-requested"),t.exportAsync().then(()=>{e.classList.remove("this-mode-is-requested")}).catch(i=>{e.classList.remove("this-mode-is-requested"),console.error(i)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(e),e}createARButton(e){var s;if(this._arButton)return this._arButton;const t="immersive-ar",i=document.createElement("button");return this._arButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-ar-button",i.innerText="Enter AR",i.title="Click to start a WebXR session in AR",i.addEventListener("click",()=>vt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),pd()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createVRButton(e){var s;if(this._vrButton)return this._vrButton;const t="immersive-vr",i=document.createElement("button");return this._vrButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-vr-button",i.innerText="Enter VR",i.title="Click to start a WebXR session in VR",i.addEventListener("click",()=>vt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),pd()||(s=navigator.xr)==null||s.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createSendToQuestButton(){var i;if(this._sendToQuestButton)return this._sendToQuestButton;const e="https://oculus.com/open_url/?url=",t=document.createElement("button");return this._sendToQuestButton=t,t.dataset.needle="webxr-sendtoquest-button",t.innerText="Open on Quest",t.title="Click to send this page to the Oculus Browser on your Quest",t.addEventListener("click",()=>{const s=encodeURIComponent(window.location.href);window.open(e+s)}),this.listenToXRSessionState(t),this.hideElementDuringXRSession(t),pd()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>{var s;(s=navigator.xr)!=null&&s.isSessionSupported("immersive-vr")?t.style.display="none":t.style.display=""}),t}createQRCode(){if(this._qrButton)return this._qrButton;const e=document.createElement("button");this._qrButton=e,e.innerText="QR Code",e.title="Scan this QR code with your phone to open this page",this.hideElementDuringXRSession(e);const t=document.createElement("div");t.style.position="fixed",t.style.display="inline-block",t.style.padding="1rem",t.style.backgroundColor="white",t.style.borderRadius="0.4rem",t.style.cursor="pointer",t.style.zIndex="1000",t.style.boxShadow="0 0 12px rgba(0, 0, 0, 0.2)";const i=document.createElement("div");i.classList.add("qr-code-container"),t.appendChild(i),e.addEventListener("click",()=>{if(t.parentNode)return r();s()});async function s(){await o(),document.body.appendChild(t);const a=i.getBoundingClientRect(),c=e.getBoundingClientRect();t.style.left=c.left+c.width*.5-a.width*.5+"px",c.top<a.height?t.style.top=`calc(${c.bottom}px + ${t.style.padding} * .6)`:t.style.top=`calc(${c.top-a.height}px - ${t.style.padding} * 2.5)`,setTimeout(()=>window.addEventListener("click",r,{once:!0})),window.addEventListener("resize",r),window.addEventListener("scroll",r),document.body.appendChild(t)}function r(){var a;(a=t.parentNode)==null||a.removeChild(t),window.removeEventListener("click",r),window.removeEventListener("resize",r),window.removeEventListener("scroll",r)}async function o(){const c=await p3({text:window.location.href,width:200,height:200});i.innerHTML="",i.appendChild(c)}return e.addEventListener("pointerenter",()=>{o()},{once:!0}),e}updateSessionSupported(e,t){if(!("xr"in navigator)){e.style.display="none";return}vt.isSessionSupported(t).then(i=>{e.style.display=i?"":"none",Ct()&&!i&&console.warn(t+" is not supported on this device - make sure your server runs using HTTPS and you have a device connected that supports "+t)})}hideElementDuringXRSession(e){vt.onXRSessionStart(t=>{e["previous-display"]=e.style.display,e.style.display="none"}),vt.onXRSessionEnd(t=>{e["previous-display"]!=null&&(e.style.display=e["previous-display"])})}listenToXRSessionState(e,t){t&&(vt.onSessionRequestStart(i=>{i.mode===t?e.classList.add("this-mode-is-requested"):(e["was-disabled"]=e.disabled,e.disabled=!0,e.classList.add("other-mode-is-requested"))}),vt.onSessionRequestEnd(i=>{e.classList.remove("this-mode-is-requested"),e.classList.remove("other-mode-is-requested"),e.disabled=e["was-disabled"]}))}};let Vh=g2;h(Vh,"_instance");var Woe=Object.defineProperty,qoe=Object.getOwnPropertyDescriptor,Yl=(n,e,t,i)=>{for(var s=i>1?void 0:i?qoe(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Woe(e,t,s),s};const Uu=ne("debugtext");var Jn=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(Jn||{}),P8=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(P8||{});class Nr extends jd{constructor(){super(...arguments);h(this,"alignment",0);h(this,"verticalOverflow",0);h(this,"horizontalOverflow",0);h(this,"lineSpacing",1);h(this,"supportRichText",!1);h(this,"font");h(this,"fontStyle",0);h(this,"sRGBTextColor",new _e(1,0,1));h(this,"_text","");h(this,"_fontSize",12);h(this,"_textMeshUi",null);h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){Uu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Uu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Uu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(Uu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let u=this.uiObject.children.length-1;u>=0;u--){const d=this.uiObject.children[u];d.isUI&&(this.uiObject.remove(d),d.clear())}const l=new U_({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;a;){const l=this.getNextTag(t,a.endIndex),u={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){u.textContent=this.getText(t,a,l),this.handleTag(a,u,c);const d=new U_(u);(r=this.uiObject)==null||r.add(d)}else{u.textContent=t.substring(a.endIndex),this.handleTag(a,u,c);const d=new U_(u);(o=this.uiObject)==null||o.add(d)}a=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(ox(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new S1(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new _e(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new S1(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new S1(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);Uu&&console.log("Selected font family:"+r);let o=iM.getFontFamily(r);switch(o||(o=iM.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let c=r;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,c,l),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var u;const s=t.lastIndexOf("-");if(s<0)return t;const r=(u=t.substring(s+1))==null?void 0:u.toLowerCase();if(Xoe.includes(r))return Uu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const c=a[0]===a[0].toUpperCase(),l=t.substring(0,s);switch(Uu&&console.log("Select font: ",t,P8[i],a,c,l),i){case 0:return c?l+"-Regular":l+"-regular";case 1:return c?l+"-Bold":l+"-bold";case 2:return c?l+"-Italic":l+"-italic";case 3:return c?l+"-BoldItalic":l+"-bolditalic";default:return t}}}Yl([x()],Nr.prototype,"alignment",2);Yl([x()],Nr.prototype,"verticalOverflow",2);Yl([x()],Nr.prototype,"horizontalOverflow",2);Yl([x()],Nr.prototype,"lineSpacing",2);Yl([x()],Nr.prototype,"supportRichText",2);Yl([x(URL)],Nr.prototype,"font",2);Yl([x()],Nr.prototype,"fontStyle",2);Yl([x()],Nr.prototype,"text",1);Yl([x()],Nr.prototype,"fontSize",1);class S1{constructor(e,t){h(this,"tag");h(this,"previousValues");this.tag=e,this.previousValues=t}}const Xoe=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Oh{constructor(e){h(this,"id");h(this,"content","");h(this,"font",[]);h(this,"pointSize",144);h(this,"width");h(this,"height");h(this,"depth");h(this,"wrapMode");h(this,"horizontalAlignment");h(this,"verticalAlignment");h(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),t.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),t.closeBlock(")"),t.beginBlock(),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </StageRoot/Materials/${YR(this.material)}>`),t.closeBlock()}}h(Oh,"global_id",0);class eS{static singleLine(e,t,i){const s=new Oh("text_"+Oh.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new Oh("text_"+Oh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Yoe=new xe().makeRotationY(Math.PI),Joe=new xe().makeScale(-1,1,-1);class A0{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=le.getComponent(e,Nr);if(!s)return;const r=le.getComponent(e,Lr);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Yoe.clone(),r&&t.matrix.premultiply(Joe);const c=s.color.clone();t.material=new eo({color:c,emissive:c}),t.addEventListener("serialize",(l,u)=>{let d=s.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const f=eS.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.writeTo(void 0,l)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Jn.LowerLeft:case Jn.MiddleLeft:case Jn.UpperLeft:e.horizontalAlignment="left";break;case Jn.LowerCenter:case Jn.MiddleCenter:case Jn.UpperCenter:e.horizontalAlignment="center";break;case Jn.LowerRight:case Jn.MiddleRight:case Jn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Jn.LowerLeft:case Jn.LowerCenter:case Jn.LowerRight:e.verticalAlignment="bottom";break;case Jn.MiddleLeft:case Jn.MiddleCenter:case Jn.MiddleRight:e.verticalAlignment="middle";break;case Jn.UpperLeft:case Jn.UpperCenter:case Jn.UpperRight:e.verticalAlignment="top";break}}}class tS{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=le.getComponent(e,Vs);if(s&&s.activeAndEnabled&&s.renderMode===b8.WorldSpace){const r=new A0,o=le.getComponent(e,Lr),a=le.getComponent(e,$h);if(o){o.width,o.height;const c=Zr.createEmpty(),l=o.shadowComponent;if(t.add(c),l){const u=l.matrix;c.matrix.copy(u);const d=new Map,f=new Map;d.set(l,c),f.set(l,a?a.alpha:1),l.traverse(p=>{if(p===l)return;const m=Zr.createEmpty();m.matrix.copy(p.matrix);const g=p.parent,y=!!g&&typeof g.textContent=="string"&&g.textContent.length>0;let v=f.get(g)||1;const A=le.getComponent(p,$h);if(A&&(v*=A.alpha),p instanceof me&&y){const b=p[Jo];b?r.exportText(b.gameObject,m,i):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",p)}if(p instanceof me&&!y){const b=p.geometry.clone();b.scale(1,1,-1),this.flipWindingOrder(b),m.geometry=b;const C=new _e,M=p.material.opacity;C.copy(p.material.color),m.material=new li({color:C,opacity:M*v,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,v);const _=d.get(g);if(!_){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}_.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}const h_=ne("debugusdz");function Koe(n,e){var o;const t=[],i=le.getComponentsInChildren(n,Gs),s=le.getComponentsInChildren(n,Co),r=new Array;if(e.injectImplicitBehaviours)for(const a of i){if(!a||!a.runtimeAnimatorController)continue;const c=a.runtimeAnimatorController.activeState;if(!c||!c.motion||!c.motion.clip||((o=c.motion.clip.tracks)==null?void 0:o.length)<1)continue;const l=new Em;l.animator=a,l.stateName=c.name,l.trigger="start",l.name="PlayAnimationOnClick_implicitAtStart_"+l.stateName;const u=new ge;le.addComponent(u,l),r.push(u),n.add(u)}else for(const a of i){if(!a||!a.runtimeAnimatorController)continue;h_&&console.log(a);const c=[];for(const l of a.runtimeAnimatorController.enumerateActions()){h_&&console.log(l);const u=l.getClip();c.includes(u)||c.push(u)}t.push({root:a.gameObject,clips:c})}for(const a of s){h_&&console.log(a);const c=[];for(const l of a.animations)c.includes(l)||c.push(l);t.push({root:a.gameObject,clips:c})}h_&&console.log("USDZ Animation Clips",t);for(const a of t)for(const c of a.clips)e.registerAnimation(a.root,c);return r}function Zoe(n,e){const t=le.getComponentsInChildren(n,vn),i=le.getComponentsInChildren(n,eu),s=new Array;for(const r of i){if(!r.target)continue;const o=t.indexOf(r.target);o>-1&&t.splice(o,1)}for(const r of t){if(!r||!r.clip||r.volume<=0)continue;const o=new eu;o.target=r,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;le.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),s.push(a),n.add(a)}return s}function Lk(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}var $oe=Object.defineProperty,eae=Object.getOwnPropertyDescriptor,pr=(n,e,t,i)=>{for(var s=i>1?void 0:i?eae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$oe(e,t,s),s};const Qr=ne("debugusdz");class mu{constructor(){h(this,"callToAction");h(this,"checkoutTitle");h(this,"checkoutSubtitle");h(this,"callToActionURL")}}pr([x()],mu.prototype,"callToAction",2);pr([x()],mu.prototype,"checkoutTitle",2);pr([x()],mu.prototype,"checkoutSubtitle",2);pr([x()],mu.prototype,"callToActionURL",2);var nE;const nT=(nE=class extends Me{constructor(){super(...arguments);h(this,"objectToExport");h(this,"autoExportAnimations",!1);h(this,"autoExportAudioSources",!0);h(this,"exportFileName");h(this,"customUsdzFile");h(this,"customBranding");h(this,"anchoringType","plane");h(this,"maxTextureSize",2048);h(this,"planeAnchoringAlignment","horizontal");h(this,"interactive",!0);h(this,"allowCreateQuicklookButton",!0);h(this,"quickLookCompatible",!0);h(this,"extensions",[]);h(this,"link");h(this,"button");h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()});h(this,"lastCallback")}start(){var e,t,i;Qr&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",s=>{switch(s.key){case"t":this.exportAsync();break}}),Bc()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Yw),this.extensions.push(new Kh),this.extensions.push(new A0),this.extensions.push(new tS))}onEnable(){var i;const e=im(),t=_p();(Qr||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=Lk(this.context),this.link.addEventListener("message",this.lastCallback)),Qr&&pn("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t,i;(e=this.button)==null||e.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Qr&&pn("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+HG(),Rl()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=Lk(this.context)),this.customUsdzFile){Qr&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e);return}const t=await this.export(this.objectToExport);if(!t){console.warn("No object to export",this);return}Qr&&console.log("USDZ generation done. Downloading as "+this.link.download),this.openInQuickLook(t,e)}async export(e){if(!e)return null;ri.start("export-usdz",{onProgress:m=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:m}}))}}),ri.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ri.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ri.start("export-usdz-textures","export-usdz");const t=le.getComponentsInChildren(e,En),i=new Array;let s=0;for(const m of t)for(const g of m.sharedMaterials)if(g){const y=m.loadProgressiveTextures(g);y instanceof Promise&&i.push(new Promise((v,A)=>{y.then(()=>{s++,ri.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:s,totalSteps:i.length}),v()}).catch(_=>A(_))}))}Qr&&pn("Load textures: "+i.length),await Promise.all(i),Qr&&pn("Load textures: done"),ri.end("export-usdz-textures");const r=ks.Global.Mask;ks.Global.Set(uc.AR),this.applyWebARSessionRoot();const o=new vne,a=[...this.extensions],c=new $A(this.quickLookCompatible);a.push(c);const l={self:this,exporter:o,extensions:a,object:e};ri.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:l})),ri.report("export-usdz","auto export animations and audio sources");const u=new Array;this.autoExportAnimations&&u.push(...Koe(e,c)),this.extensions.find(m=>m.extensionName==="Audio")&&this.autoExportAudioSources&&u.push(...Zoe(e)),o.debug=Qr,o.keepObject=m=>{const g=le.getComponent(m,En);return!(g&&!g.enabled)},this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal"),ri.report("export-usdz","Invoking exporter.parse");const f=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),p=new Blob([f],{type:"model/vnd.usdz+zip"});for(const m of u)le.destroy(m);return ri.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:l})),ks.Global.Set(r),ri.end("export-usdz"),p}openInQuickLook(e,t){const i=e instanceof Blob?URL.createObjectURL(e):e,s=this.buildQuicklookOverlay();Qr&&console.log("QuickLook Overlay",s);const r=s.callToAction?encodeURIComponent(s.callToAction):"",o=s.checkoutTitle?encodeURIComponent(s.checkoutTitle):"",a=s.checkoutSubtitle?encodeURIComponent(s.checkoutSubtitle):"";this.link.href=i+`#callToAction=${r}&checkoutTitle=${o}&checkoutSubtitle=${a}&callToActionURL=${s.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(e,t){nT.save(e,t)}static save(e,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof e=="string"?i.href=e:i.href=URL.createObjectURL(e),i.download=t,i.click(),i.remove()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Qr&&gn("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const s=i.get("callToActionURL");Qr&&pn("Quicklook url: "+s),s&&(Rl()?globalThis.open(s,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",s))}}}}buildQuicklookOverlay(){var i,s,r,o,a,c;const e={};return this.customBranding&&Object.assign(e,this.customBranding),Rl()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="๐ต Made with Needle",e.checkoutSubtitle="_"),(((i=e.callToAction)==null?void 0:i.length)||((s=e.checkoutTitle)==null?void 0:s.length)||((r=e.checkoutSubtitle)==null?void 0:r.length))&&((o=e.callToAction)!=null&&o.length||(e.callToAction="\0"),(a=e.checkoutTitle)!=null&&a.length||(e.checkoutTitle="\0"),(c=e.checkoutSubtitle)!=null&&c.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=le.getComponentInParent(this.objectToExport,Mo);const t=e!=null;if(e||(e=le.getComponentInChildren(this.objectToExport,Mo)),Qr&&console.log("applyWebARSessionRoot",e),!e){Qr&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=t?this.objectToExport:e.gameObject,s=1/e.arScale;i.matrix.makeScale(s,s,s),e.invertForward&&i.matrix.multiply(nT.invertForwardMatrix)}createQuicklookButton(){const t=Vh.getOrCreate().createQuicklookButton();return t.parentNode||this.context.menu.appendChild(t),t}},h(nE,"invertForwardMatrix",new xe().makeRotationY(Math.PI)),nE);let rs=nT;pr([x(ge)],rs.prototype,"objectToExport",2);pr([x()],rs.prototype,"autoExportAnimations",2);pr([x()],rs.prototype,"autoExportAudioSources",2);pr([x()],rs.prototype,"exportFileName",2);pr([x(URL)],rs.prototype,"customUsdzFile",2);pr([x(mu)],rs.prototype,"customBranding",2);pr([x()],rs.prototype,"anchoringType",2);pr([x()],rs.prototype,"maxTextureSize",2);pr([x()],rs.prototype,"planeAnchoringAlignment",2);pr([x()],rs.prototype,"interactive",2);pr([x()],rs.prototype,"allowCreateQuicklookButton",2);pr([x()],rs.prototype,"quickLookCompatible",2);class y0 extends Me{constructor(){super(...arguments);h(this,"isUsed",!0);h(this,"usedBy",null)}}class wP extends Me{}const Fk=ne("debugdeletable");class iS extends Ko{}class SP extends Me{constructor(){super(...arguments);h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=le.findObjectsOfType(iS,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=le.getComponentInParent(this.gameObject,y0);r?Fk&&console.warn("Can not delete object with usage marker",this.guid,r):(Fk&&console.log("DESTROY",this.gameObject),Pw(this.gameObject,this.context.connection))}}}}var tae=Object.defineProperty,iae=Object.getOwnPropertyDescriptor,Kd=(n,e,t,i)=>{for(var s=i>1?void 0:i?iae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tae(e,t,s),s};const Uk=ne("debugpost");class Qa extends fr{constructor(){super(...arguments);h(this,"mode");h(this,"focusDistance");h(this,"focalLength");h(this,"aperture");h(this,"gaussianMaxRadius");h(this,"resolutionScale");h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){Uk&&console.log("DOF: INIT"),this.focalLength.valueProcessor=i=>{const s=i/300,r=2;return rt.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return rt.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0){Uk&&console.warn("DepthOfField: Mode is set to Off");return}const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Bc()&&(s=.6),this.resolutionScale=new kt(s*t)}const i=new b4(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.cocMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.cocMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Kd([x()],Qa.prototype,"mode",2);Kd([x(kt)],Qa.prototype,"focusDistance",2);Kd([x(kt)],Qa.prototype,"focalLength",2);Kd([x(kt)],Qa.prototype,"aperture",2);Kd([x(kt)],Qa.prototype,"gaussianMaxRadius",2);Kd([x(kt)],Qa.prototype,"resolutionScale",2);Kd([x(kt)],Qa.prototype,"bokehScale",2);da("DepthOfField",Qa);var nae=Object.defineProperty,sae=Object.getOwnPropertyDescriptor,rae=(n,e,t,i)=>{for(var s=i>1?void 0:i?sae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nae(e,t,s),s};class nS extends Me{constructor(){super(...arguments);h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||le.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Bc()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}rae([x()],nS.prototype,"visibleOn",2);class CP{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var oae=Object.defineProperty,aae=Object.getOwnPropertyDescriptor,Zd=(n,e,t,i)=>{for(var s=i>1?void 0:i?aae(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&oae(e,t,s),s};const xc=ne("debugdrag");var B8=(n=>(n[n.XZPlane=0]="XZPlane",n[n.Attached=1]="Attached",n[n.HitNormal=2]="HitNormal",n[n.DynamicViewAngle=3]="DynamicViewAngle",n[n.SnapToSurfaces=4]="SnapToSurfaces",n[n.None=5]="None",n))(B8||{}),B_;const tc=(B_=class extends Me{constructor(){super(...arguments);h(this,"dragMode",3);h(this,"snapGridResolution",0);h(this,"keepRotation",!0);h(this,"xrDragMode",1);h(this,"xrKeepRotation",!1);h(this,"xrDistanceDragFactor",1);h(this,"showGizmo",!1);h(this,"targetObject",null);h(this,"orbit",null);h(this,"_dragHelper",null);h(this,"_draggingRigidbodies",[]);h(this,"_potentialDragStartEvt",null);h(this,"_dragHandlers",new Map);h(this,"_totalMovement",new w);h(this,"_marker",null);h(this,"_isDragging",!1);h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(e){this.targetObject=e;for(const t of this._dragHandlers.values())t.setTargetObject(e)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new w,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=le.findObjectOfType(Ki,this.context),this.gameObject.getComponentInParent(Eo)||this.gameObject.addNewComponent(Eo)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||e.mode!=="screen"||(e.event.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)return;const s=le.getComponentInParent(e.object,tc);!s||s!==this||(tc.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&e.mode==="screen"&&tc.lastHovered===e.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(e){if(!(!this.allowEdit(this.gameObject)||e.used||(e.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)&&(tc.lastHovered=e.object,e.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=e),tc._active+=1;const s=new lae(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(e.event.space,s),this.orbit&&(this.orbit.enabled=!1),s.onDragStart(e),this._dragHandlers.size===2){const r=this._dragHandlers.values(),o=r.next().value,a=r.next().value,c=new cae(this,this.targetObject||this.gameObject,o,a);this._dragHandlers.set(this.gameObject,c),c.onDragStart(e)}e.use()}}onPointerMove(e){(this._isDragging||this._potentialDragStartEvt!==null)&&e.use()}onPointerUp(e){if(xc&&It.DrawLabel(e.point??this.gameObject.worldPosition,"POINTERUP:"+e.pointerId+", "+e.button,.03,3),!this.allowEdit(this.gameObject)||e.button!==0)return;this._potentialDragStartEvt=null;const t=this._dragHandlers.get(e.event.space),i=this._dragHandlers.get(this.gameObject);i&&(i.handlerA===t||i.handlerB===t)&&(this._dragHandlers.delete(this.gameObject),i.onDragEnd(e)),t&&(tc._active>0&&(tc._active-=1),t.onDragEnd&&t.onDragEnd(e),this._dragHandlers.delete(e.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(e),e.use()),tc._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const e of this._dragHandlers.values())e.collectMovementInfo&&e.collectMovementInfo(),e.getTotalMovement&&this._totalMovement.add(e.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const e=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(e)}for(const e of this._dragHandlers.values())e.onDragUpdate&&e.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new lb(this.context.mainCamera);else return;if(!e||!e.object)return;const t=le.getComponentInParent(e.object,tc);if(!t||t!==this)return;const i=this.targetObject||this.gameObject;if(!i)return;this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const s=le.getComponentInChildren(i,Jh);xc&&console.log("DRAG START",s,i),s&&(s.fastMode=!0,s==null||s.requestOwnership()),this._marker=le.addNewComponent(i,y0),this._draggingRigidbodies.length=0;const r=le.getComponentsInChildren(i,Yi);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities(),t.resetForcesAndTorques();const e=this.targetObject||this.gameObject;ka.markDirty(e)}onLastDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(xc&&console.log("DRAG END",t,t==null?void 0:t.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const i=le.getComponentInChildren(e.object,Jh);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy()}},h(B_,"_active",0),h(B_,"lastHovered"),B_);let aa=tc;Zd([x()],aa.prototype,"dragMode",2);Zd([x()],aa.prototype,"snapGridResolution",2);Zd([x()],aa.prototype,"keepRotation",2);Zd([x()],aa.prototype,"xrDragMode",2);Zd([x()],aa.prototype,"xrKeepRotation",2);Zd([x()],aa.prototype,"xrDistanceDragFactor",2);Zd([x()],aa.prototype,"showGizmo",2);class cae{constructor(e,t,i,s){h(this,"handlerA");h(this,"handlerB");h(this,"context");h(this,"settings");h(this,"gameObject");h(this,"_handlerAAttachmentPoint",new w);h(this,"_handlerBAttachmentPoint",new w);h(this,"_followObject");h(this,"_manipulatorObject");h(this,"_deviceMode");h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_manipulatorPosOffset",new w);h(this,"_manipulatorRotOffset",new Ce);h(this,"_manipulatorScaleOffset",new w);h(this,"_tempVec1",new w);h(this,"_tempVec2",new w);h(this,"_tempVec3",new w);h(this,"tempLookMatrix",new xe);h(this,"_initialScale",new w);h(this,"_initialDistance",0);var o,a;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=i,this.handlerB=s,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const r=(a=(o=vt.active)==null?void 0:o.rig)==null?void 0:a.gameObject;if(!this.handlerA||!this.handlerB||!this.handlerA.hitPointInLocalSpace||!this.handlerB.hitPointInLocalSpace){console.error("Invalid: MultiTouchDragHandler needs two valid DragPointerHandlers with hitPointInLocalSpace set.");return}if(this._tempVec1.copy(this.handlerA.hitPointInLocalSpace),this._tempVec2.copy(this.handlerB.hitPointInLocalSpace),this.gameObject.localToWorld(this._tempVec1),this.gameObject.localToWorld(this._tempVec2),r&&(r.worldToLocal(this._tempVec1),r.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(xc&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now โ controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(t.scale),xc){this._followObject.add(new na(2)),this._manipulatorObject.add(new na(5));const c=l=>`${l.x.toFixed(2)}, ${l.y.toFixed(2)}, ${l.z.toFixed(2)}`;It.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),It.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6304
6304
|
`+c(this._tempVec1)+`
|
|
6305
6305
|
`+c(this._tempVec2),.03,5)}}onDragStart(e){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=e.mode,this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this.alignManipulator(),this._manipulatorObject.attach(this._followObject),this._manipulatorPosOffset.copy(this._followObject.position),this._manipulatorRotOffset.copy(this._followObject.quaternion),this._manipulatorScaleOffset.copy(this._followObject.scale)}onDragEnd(e){if(!this.handlerA||!this.handlerB){console.error("onDragEnd called on MultiTouchDragHandler without valid handlers. This is likely a bug.");return}this.handlerA.recenter(),this.handlerB.recenter(),this._manipulatorObject.removeFromParent(),this._followObject.removeFromParent(),this._manipulatorObject.destroy(),this._followObject.destroy()}alignManipulator(){if(!this.handlerA||!this.handlerB){console.error("alignManipulator called on MultiTouchDragHandler without valid handlers. This is likely a bug.",this);return}if(!this.handlerA.followObject||!this.handlerB.followObject){console.error("alignManipulator called on MultiTouchDragHandler without valid follow objects. This is likely a bug.",this.handlerA,this.handlerB);return}this._tempVec1.copy(this._handlerAAttachmentPoint),this._tempVec2.copy(this._handlerBAttachmentPoint),this.handlerA.followObject.localToWorld(this._tempVec1),this.handlerB.followObject.localToWorld(this._tempVec2),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._manipulatorObject.position.copy(this._tempVec3);const e=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,e.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const t=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(t/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),xc&&(It.DrawLabel(this._tempVec3.clone().add(new w(0,.2,0)),"A:B "+t.toFixed(2),.03),It.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const e=30,t=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const i=this.gameObject,s=this._followObject;s.updateMatrix(),s.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const d=this._followObject.worldPosition,f=this.settings.snapGridResolution;d.x=Math.round(d.x/f)*f,d.y=Math.round(d.y/f)*f,d.z=Math.round(d.z/f)*f,this._followObject.worldPosition=d,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const a=rt.clamp01(this.context.time.deltaTime*e*t),c=i.worldPosition;c.lerp(s.worldPosition,a),i.worldPosition=c;const l=i.worldQuaternion;l.slerp(s.worldQuaternion,a),i.worldQuaternion=l;const u=i.worldScale;u.lerp(s.worldScale,a),i.worldScale=u}setTargetObject(e){this.gameObject=e}}class lae{constructor(e,t){h(this,"context");h(this,"gameObject");h(this,"settings");h(this,"_lastRig");h(this,"_followObject");h(this,"_totalMovement",new w);h(this,"_totalMovementAlongRayDirection",0);h(this,"_grabStartDistance",0);h(this,"_deviceMode");h(this,"_followObjectStartPosition",new w);h(this,"_followObjectStartQuaternion",new Ce);h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_lastDragPosRigSpace");h(this,"_tempVec",new w);h(this,"_tempMat",new xe);h(this,"_hitPointInLocalSpace",new w);h(this,"_hitNormalInLocalSpace",new w);h(this,"_bottomCenter",new w);h(this,"_backCenter",new w);h(this,"_backBottomCenter",new w);h(this,"_bounds",new ki);h(this,"_dragPlane",new Er(new w(0,1,0)));h(this,"_draggedOverObject",null);h(this,"_draggedOverObjectLastSetUp",null);h(this,"_draggedOverObjectLastNormal",new w);h(this,"_draggedOverObjectDuration",0);this.settings=e,this.context=e.context,this.gameObject=t,this._followObject=new ge}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(e){this.gameObject=e}recenter(){var r,o;if(!this._followObject.parent){console.warn("Error: space follow object doesn't have parent but recenter() is called. This is likely a bug");return}const e=this._followObject.parent;this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.position.set(0,0,0),this._followObject.quaternion.set(0,0,0,1),this._followObject.scale.set(1,1,1),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0),e.attach(this._followObject),this._followObjectStartPosition.copy(this._followObject.position),this._followObjectStartQuaternion.copy(this._followObject.quaternion),this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const t=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(t),this._grabStartDistance=t.distanceTo(e.worldPosition);const i=(o=(r=vt.active)==null?void 0:r.rig)==null?void 0:o.gameObject,s=(i==null?void 0:i.worldScale.x)||1;this._grabStartDistance/=s,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,xc&&(It.DrawLine(t,e.worldPosition,65280,.5,!1),It.DrawLabel(e.worldPosition.add(new w(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(e){if(e.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,e.point&&e.normal)this._hitPointInLocalSpace.copy(e.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(e.normal);else if(e){const m=e.event.space,g=m.worldPosition;this.gameObject.worldToLocal(g),this._hitPointInLocalSpace.copy(g);const y=m.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),y.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(y)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=e.mode;const i=this._followObject.parent.worldForward,r=this._deviceMode==="tracked-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),r){case 0:const m=new w(0,1,0);this.gameObject.parent&&m.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(m,o);break;case 2:const g=this._hitNormalInLocalSpace.clone();g.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(g,o);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(i,o);break;case 3:const y=new w(0,1,0),v=i,A=y.angleTo(v),_=.5;A>Math.PI/2+_||A<Math.PI/2-_?this._dragPlane.setFromNormalAndCoplanarPoint(new w(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(i,o);break}const a=new ki,c=this.gameObject.parent,l=this.gameObject.position.clone(),u=this.gameObject.quaternion.clone(),d=this.gameObject.scale.clone();c&&c.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1),a.setFromObject(this.gameObject);const f=new w;a.getCenter(f);const p=new w;a.getSize(p),this._bottomCenter.copy(f.clone().add(new w(0,-p.y/2,0))),this._backCenter.copy(f.clone().add(new w(0,0,p.z/2))),this._backBottomCenter.copy(f.clone().add(new w(0,-p.y/2,p.z/2))),this._bounds.copy(a),c&&c.add(this.gameObject),this.gameObject.position.copy(l),this.gameObject.quaternion.copy(u),this.gameObject.scale.copy(d),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var r,o;if(!this._followObject.parent)return;const e=this._followObject.parent;this._followObject.updateMatrix();const t=e.worldPosition,i=(o=(r=vt.active)==null?void 0:r.rig)==null?void 0:o.gameObject;i&&i.worldToLocal(t),(this._lastDragPosRigSpace===void 0||i!=this._lastRig)&&(this._lastDragPosRigSpace=t.clone(),this._lastRig=i),this._tempVec.copy(t).sub(this._lastDragPosRigSpace);const s=e.worldForward;if(i&&(this._tempMat.copy(i.matrixWorld).invert(),s.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=s.dot(this._tempVec),this._tempVec.x=Math.abs(this._tempVec.x),this._tempVec.y=Math.abs(this._tempVec.y),this._tempVec.z=Math.abs(this._tempVec.z),this._totalMovement.add(this._tempVec),this._lastDragPosRigSpace.copy(t),xc){let a=t;i&&(a=a.clone(),a.transformDirection(i.matrixWorld)),It.DrawRay(a,s,255)}}onDragUpdate(e){if(e>1)return;const t=this.gameObject,i=this._followObject.parent;this._followObject.updateMatrix();const s=i.worldPosition,r=i.worldForward,o=this._deviceMode==="tracked-pointer",a=o?this.settings.xrKeepRotation:this.settings.keepRotation,c=o?this.settings.xrDragMode:this.settings.dragMode;if(c===5)return;const l=10;a&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let u=1,d=1;if(this._deviceMode==="tracked-pointer"&&this._grabStartDistance>.5){const y=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);u=Math.max(0,y),u=u*u*u}else this._grabStartDistance<=.5&&(d=3);this._followObject.position.copy(this._followObjectStartPosition),a||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(u),this._followObject.updateMatrix();const f=new To(s,r);if(c==4){const y=new oa;y.ignore=[t];const v=this.context.physics.raycastFromRay(f,y);if(v.length>0){const A=v[0];if(this._draggedOverObject===A.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=A.object,this._draggedOverObjectDuration=0),A.face&&this._draggedOverObjectDuration>.15&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(A.face.normal)<.999999)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(A.face.normal);const _=new w,b=new w;this._bounds.getCenter(_),this._bounds.getSize(b),_.sub(b.multiplyScalar(.5).multiply(A.face.normal)),this._hitPointInLocalSpace.copy(_),this._hitNormalInLocalSpace.copy(A.face.normal),this._bounds.getCenter(_),this._bounds.getSize(b),_.add(b.multiplyScalar(.5).multiply(A.face.normal));const C=this._hitPointInLocalSpace.clone().add(_);this._followObject.localToWorld(C);const M=this._followObject.worldPosition.sub(C);this._dragPlane.setFromNormalAndCoplanarPoint(A.face.normal,A.point.sub(M))}}}if(c!==1&&f.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const y=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(y),xc&&It.DrawLine(y,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(y),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const y=this._followObject.worldPosition,v=this.settings.snapGridResolution;y.x=Math.round(y.x/v)*v,y.y=Math.round(y.y/v)*v,y.z=Math.round(y.z/v)*v,this._followObject.worldPosition=y,this._followObject.updateMatrix()}a&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const p=rt.clamp01(this.context.time.deltaTime*l*d),m=t.worldPosition;m.lerp(this._followObject.worldPosition,p),t.worldPosition=m;const g=t.worldQuaternion;if(g.slerp(this._followObject.worldQuaternion,p),t.worldQuaternion=g,xc){const y=this._hitPointInLocalSpace.clone();t.localToWorld(y),It.DrawSphere(y,.02,16711680);const v=this._hitNormalInLocalSpace.clone();v.applyQuaternion(g),It.DrawRay(y,v,16711680),It.DrawLabel(m.add(new w(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6306
6306
|
|