@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
|
`;s+=g(o);const n=Object.keys(I);let C="";for(let a=0;a<n.length;a++){const B=n[a],Q=I[B];if(Sh.has(Q)){C+="";continue}Sh.set(Q,!0),C+=B+":"+t(Q,o+1),a<n.length-1&&(C+=", "),C.length>=60&&(C+=`
|
|
4371
4371
|
`,C+=g(o),s+=C,C="")}return s+=C,s+=`
|
|
4372
4372
|
}`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const y7=IA("nodevlogs");function fi(i,A=Bs.Log){LC(A,i)}function yi(i){fi(i,Bs.Warn)}function G_(i){fi(i,Bs.Error)}let wG;function me(){return y7?!1:wG!==void 0?wG:HI()}function w7(i){wG=i}const eB=new Gc,QI=new y,wa=new y,si=new GA,cb={X:new y(1,0,0),Y:new y(0,1,0),Z:new y(0,0,1)},Zm={type:"change"},hb={type:"mouseDown"},lb={type:"mouseUp",mode:null},db={type:"objectChange"};class S7 extends pA{constructor(A,e){super(),e===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const t=new GN;this._gizmo=t,this.add(t);const g=new U7;this._plane=g,this.add(g);const I=this;function o(d,p){let f=p;Object.defineProperty(I,d,{get:function(){return f!==void 0?f:p},set:function(S){f!==S&&(f=S,g[d]=S,t[d]=S,I.dispatchEvent({type:d+"-changed",value:S}),I.dispatchEvent(Zm))}}),I[d]=p,g[d]=p,t[d]=p}o("camera",A),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const s=new y,n=new y,C=new GA,a=new GA,B=new y,Q=new GA,E=new y,c=new y,h=new y,u=0,l=new y;o("worldPosition",s),o("worldPositionStart",n),o("worldQuaternion",C),o("worldQuaternionStart",a),o("cameraPosition",B),o("cameraQuaternion",Q),o("pointStart",E),o("pointEnd",c),o("rotationAxis",h),o("rotationAngle",u),o("eye",l),this._offset=new y,this._startNorm=new y,this._endNorm=new y,this._cameraScale=new y,this._parentPosition=new y,this._parentQuaternion=new GA,this._parentQuaternionInv=new GA,this._parentScale=new y,this._worldScaleStart=new y,this._worldQuaternionInv=new GA,this._worldScale=new y,this._positionStart=new y,this._quaternionStart=new GA,this._scaleStart=new y,this._getPointer=m7.bind(this),this._onPointerDown=M7.bind(this),this._onPointerHover=k7.bind(this),this._onPointerMove=G7.bind(this),this._onPointerUp=R7.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(A){if(this.object===void 0||this.dragging===!0)return;eB.setFromCamera(A,this.camera);const e=Xm(this._gizmo.picker[this.mode],eB);e?this.axis=e.object.name:this.axis=null}pointerDown(A){if(!(this.object===void 0||this.dragging===!0||A.button!==0)&&this.axis!==null){eB.setFromCamera(A,this.camera);const e=Xm(this._plane,eB,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,hb.mode=this.mode,this.dispatchEvent(hb)}}pointerMove(A){const e=this.axis,t=this.mode,g=this.object;let I=this.space;if(t==="scale"?I="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(I="world"),g===void 0||e===null||this.dragging===!1||A.button!==-1)return;eB.setFromCamera(A,this.camera);const o=Xm(this._plane,eB,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),t==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),I==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),I==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),g.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(I==="local"&&(g.position.applyQuaternion(si.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(g.position.x=Math.round(g.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(g.position.y=Math.round(g.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(g.position.z=Math.round(g.position.z/this.translationSnap)*this.translationSnap),g.position.applyQuaternion(this._quaternionStart)),I==="world"&&(g.parent&&g.position.add(QI.setFromMatrixPosition(g.parent.matrixWorld)),e.search("X")!==-1&&(g.position.x=Math.round(g.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(g.position.y=Math.round(g.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(g.position.z=Math.round(g.position.z/this.translationSnap)*this.translationSnap),g.parent&&g.position.sub(QI.setFromMatrixPosition(g.parent.matrixWorld))));else if(t==="scale"){if(e.search("XYZ")!==-1){let s=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(s*=-1),wa.set(s,s,s)}else QI.copy(this.pointStart),wa.copy(this.pointEnd),QI.applyQuaternion(this._worldQuaternionInv),wa.applyQuaternion(this._worldQuaternionInv),wa.divide(QI),e.search("X")===-1&&(wa.x=1),e.search("Y")===-1&&(wa.y=1),e.search("Z")===-1&&(wa.z=1);g.scale.copy(this._scaleStart).multiply(wa),this.scaleSnap&&(e.search("X")!==-1&&(g.scale.x=Math.round(g.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(g.scale.y=Math.round(g.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(g.scale.z=Math.round(g.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(t==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const s=20/this.worldPosition.distanceTo(QI.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(QI.copy(this.rotationAxis).cross(this.eye))*s):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(cb[e]),QI.copy(cb[e]),I==="local"&&QI.applyQuaternion(this.worldQuaternion),QI.cross(this.eye),QI.length()===0?n=!0:this.rotationAngle=this._offset.dot(QI.normalize())*s),(e==="E"||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),I==="local"&&e!=="E"&&e!=="XYZE"?(g.quaternion.copy(this._quaternionStart),g.quaternion.multiply(si.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),g.quaternion.copy(si.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),g.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Zm),this.dispatchEvent(db)}}pointerUp(A){A.button===0&&(this.dragging&&this.axis!==null&&(lb.mode=this.mode,this.dispatchEvent(lb)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(A){A.geometry&&A.geometry.dispose(),A.material&&A.material.dispose()})}attach(A){return this.object=A,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Zm),this.dispatchEvent(db),this.pointStart.copy(this.pointEnd))}getRaycaster(){return eB}getMode(){return this.mode}setMode(A){this.mode=A}setTranslationSnap(A){this.translationSnap=A}setRotationSnap(A){this.rotationSnap=A}setScaleSnap(A){this.scaleSnap=A}setSize(A){this.size=A}setSpace(A){this.space=A}}function m7(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const A=this.domElement.getBoundingClientRect();return{x:(i.clientX-A.left)/A.width*2-1,y:-(i.clientY-A.top)/A.height*2+1,button:i.button}}}function k7(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function M7(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function G7(i){this.enabled&&this.pointerMove(this._getPointer(i))}function R7(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function Xm(i,A,e){const t=A.intersectObject(i,!0);for(let g=0;g<t.length;g++)if(t[g].object.visible||e)return t[g];return!1}const wf=new jg,Ot=new y(0,1,0),ub=new y(0,0,0),pb=new mA,Sf=new GA,SD=new GA,sn=new y,fb=new mA,el=new y(1,0,0),lB=new y(0,1,0),tl=new y(0,0,1),mf=new y,mh=new y,kh=new y;class GN extends pA{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const A=new Bt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Pi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=A.clone();t.opacity=.15;const g=e.clone();g.opacity=.5;const I=A.clone();I.color.setHex(16711680);const o=A.clone();o.color.setHex(65280);const s=A.clone();s.color.setHex(255);const n=A.clone();n.color.setHex(16711680),n.opacity=.5;const C=A.clone();C.color.setHex(65280),C.opacity=.5;const a=A.clone();a.color.setHex(255),a.opacity=.5;const B=A.clone();B.opacity=.25;const Q=A.clone();Q.color.setHex(16776960),Q.opacity=.25,A.clone().color.setHex(16776960);const c=A.clone();c.color.setHex(7895160);const h=new Ti(0,.04,.1,12);h.translate(0,.05,0);const u=new Zt(.08,.08,.08);u.translate(0,.04,0);const l=new fe;l.setAttribute("position",new Qe([0,0,0,1,0,0],3));const d=new Ti(.0075,.0075,.5,3);d.translate(0,.25,0);function p(_,v){const q=new mC(_,.0075,3,64,v*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function f(){const _=new fe;return _.setAttribute("position",new Qe([0,0,0,1,1,1],3)),_}const S={X:[[new uA(h,I),[.5,0,0],[0,0,-Math.PI/2]],[new uA(h,I),[-.5,0,0],[0,0,Math.PI/2]],[new uA(d,I),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new uA(h,o),[0,.5,0]],[new uA(h,o),[0,-.5,0],[Math.PI,0,0]],[new uA(d,o)]],Z:[[new uA(h,s),[0,0,.5],[Math.PI/2,0,0]],[new uA(h,s),[0,0,-.5],[-Math.PI/2,0,0]],[new uA(d,s),null,[Math.PI/2,0,0]]],XYZ:[[new uA(new NC(.1,0),B.clone()),[0,0,0]]],XY:[[new uA(new Zt(.15,.15,.01),a.clone()),[.15,.15,0]]],YZ:[[new uA(new Zt(.15,.15,.01),n.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new Zt(.15,.15,.01),C.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},k={X:[[new uA(new Ti(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new uA(new Ti(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new uA(new Ti(.2,0,.6,4),t),[0,.3,0]],[new uA(new Ti(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new uA(new Ti(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new uA(new Ti(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new uA(new NC(.2,0),t)]],XY:[[new uA(new Zt(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new uA(new Zt(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new Zt(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]]},R={START:[[new uA(new NC(.01,2),g),null,null,null,"helper"]],END:[[new uA(new NC(.01,2),g),null,null,null,"helper"]],DELTA:[[new _i(f(),g),null,null,null,"helper"]],X:[[new _i(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new _i(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new _i(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new uA(p(.5,1),c),null,[0,Math.PI/2,0]]],X:[[new uA(p(.5,.5),I)]],Y:[[new uA(p(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new uA(p(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new uA(p(.75,1),Q),null,[0,Math.PI/2,0]]]},w={AXIS:[[new _i(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},m={XYZE:[[new uA(new Xs(.25,10,8),t)]],X:[[new uA(new mC(.5,.1,4,24),t),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new uA(new mC(.5,.1,4,24),t),[0,0,0],[Math.PI/2,0,0]]],Z:[[new uA(new mC(.5,.1,4,24),t),[0,0,0],[0,0,-Math.PI/2]]],E:[[new uA(new mC(.75,.1,2,24),t)]]},J={X:[[new uA(u,I),[.5,0,0],[0,0,-Math.PI/2]],[new uA(d,I),[0,0,0],[0,0,-Math.PI/2]],[new uA(u,I),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new uA(u,o),[0,.5,0]],[new uA(d,o)],[new uA(u,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new uA(u,s),[0,0,.5],[Math.PI/2,0,0]],[new uA(d,s),[0,0,0],[Math.PI/2,0,0]],[new uA(u,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new uA(new Zt(.15,.15,.01),a),[.15,.15,0]]],YZ:[[new uA(new Zt(.15,.15,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new Zt(.15,.15,.01),C),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new uA(new Zt(.1,.1,.1),B.clone())]]},Y={X:[[new uA(new Ti(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new uA(new Ti(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new uA(new Ti(.2,0,.6,4),t),[0,.3,0]],[new uA(new Ti(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new uA(new Ti(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new uA(new Ti(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new uA(new Zt(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new uA(new Zt(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new uA(new Zt(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new uA(new Zt(.2,.2,.2),t),[0,0,0]]]},O={X:[[new _i(l,g.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new _i(l,g.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new _i(l,g.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function K(_){const v=new pA;for(const q in _)for(let H=_[q].length;H--;){const Z=_[q][H][0].clone(),z=_[q][H][1],sA=_[q][H][2],hA=_[q][H][3],FA=_[q][H][4];Z.name=q,Z.tag=FA,z&&Z.position.set(z[0],z[1],z[2]),sA&&Z.rotation.set(sA[0],sA[1],sA[2]),hA&&Z.scale.set(hA[0],hA[1],hA[2]),Z.updateMatrix();const RA=Z.geometry.clone();RA.applyMatrix4(Z.matrix),Z.geometry=RA,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),v.add(Z)}return v}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=K(S)),this.add(this.gizmo.rotate=K(M)),this.add(this.gizmo.scale=K(J)),this.add(this.picker.translate=K(k)),this.add(this.picker.rotate=K(m)),this.add(this.picker.scale=K(Y)),this.add(this.helper.translate=K(R)),this.add(this.helper.rotate=K(w)),this.add(this.helper.scale=K(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(A){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:SD;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let g=[];g=g.concat(this.picker[this.mode].children),g=g.concat(this.gizmo[this.mode].children),g=g.concat(this.helper[this.mode].children);for(let I=0;I<g.length;I++){const o=g[I];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let s;if(this.camera.isOrthographicCamera?s=(this.camera.top-this.camera.bottom)/this.camera.zoom:s=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(s*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(si.setFromEuler(wf.set(0,0,0)),o.quaternion.copy(t).multiply(si),Math.abs(Ot.copy(el).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(si.setFromEuler(wf.set(0,0,Math.PI/2)),o.quaternion.copy(t).multiply(si),Math.abs(Ot.copy(lB).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(si.setFromEuler(wf.set(0,Math.PI/2,0)),o.quaternion.copy(t).multiply(si),Math.abs(Ot.copy(tl).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(si.setFromEuler(wf.set(0,Math.PI/2,0)),Ot.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(pb.lookAt(ub,Ot,lB)),o.quaternion.multiply(si),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),QI.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),QI.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(QI),o.visible=this.dragging):(o.quaternion.copy(t),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Ot.copy(el).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Ot.copy(lB).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Ot.copy(tl).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Ot.copy(tl).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Ot.copy(el).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Ot.copy(lB).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Sf.copy(t),Ot.copy(this.eye).applyQuaternion(si.copy(t).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(pb.lookAt(this.eye,ub,lB)),o.name==="X"&&(si.setFromAxisAngle(el,Math.atan2(-Ot.y,Ot.z)),si.multiplyQuaternions(Sf,si),o.quaternion.copy(si)),o.name==="Y"&&(si.setFromAxisAngle(lB,Math.atan2(Ot.x,Ot.z)),si.multiplyQuaternions(Sf,si),o.quaternion.copy(si)),o.name==="Z"&&(si.setFromAxisAngle(tl,Math.atan2(Ot.y,Ot.x)),si.multiplyQuaternions(Sf,si),o.quaternion.copy(si))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(n){return o.name===n}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(A)}}class U7 extends uA{constructor(){super(new ug(1e5,1e5,2,2),new Bt({visible:!1,wireframe:!0,side:mt,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(A){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),mf.copy(el).applyQuaternion(e==="local"?this.worldQuaternion:SD),mh.copy(lB).applyQuaternion(e==="local"?this.worldQuaternion:SD),kh.copy(tl).applyQuaternion(e==="local"?this.worldQuaternion:SD),Ot.copy(mh),this.mode){case"translate":case"scale":switch(this.axis){case"X":Ot.copy(this.eye).cross(mf),sn.copy(mf).cross(Ot);break;case"Y":Ot.copy(this.eye).cross(mh),sn.copy(mh).cross(Ot);break;case"Z":Ot.copy(this.eye).cross(kh),sn.copy(kh).cross(Ot);break;case"XY":sn.copy(kh);break;case"YZ":sn.copy(mf);break;case"XZ":Ot.copy(kh),sn.copy(mh);break;case"XYZ":case"E":sn.set(0,0,0);break}break;case"rotate":default:sn.set(0,0,0)}sn.length()===0?this.quaternion.copy(this.cameraQuaternion):(fb.lookAt(QI.set(0,0,0),sn,Ot),this.quaternion.setFromRotationMatrix(fb)),super.updateMatrixWorld(A)}}const N7=IA("debugpatch");function pS(i,A,e,t){const g=N7===A;if(!e&&!t)return;const I=A+"___needle";K7(i,A,e,t);const o=Object.getOwnPropertyDescriptor(i,A),s=i[A];g&&console.log("Patch",i.constructor.name,A,o,s),o?(g&&console.log("Apply patch with existing descriptor",i.constructor.name,A,o),typeof o.value=="function"&&(i[A]=yb(o.value,i,A))):(g&&console.log("Create patch with new property",i.constructor.name,A,o),Object.defineProperty(i,A,{set:function(n){if(typeof n=="function")this[I]=yb(n,i,A);else{const C=this[I];R_(i,A,this,C,n),this[I]=n,U_(i,A,this,C,n)}},get:function(){const n=this[I];return typeof n=="function"&&n[I]?n[I]:n}}))}function F7(i,A,e){const t=RN(i,A);if(t)for(let g=t.length-1;g>=0;g--){const I=t[g];I.prefix===e&&(I.prefix=null),I.postfix===e&&(I.postfix=null),!I.prefix&&!I.postfix&&t.splice(g,1)}}const Db=Symbol("Needle:Patches:WrappedFunction");function yb(i,A,e){if(i[Db])return i;const t=function(...g){R_(A,e,this,...g);const I=i.apply(this,g);return U_(A,e,this,I,...g),I};return t[Db]=!0,t}const mD="Needle:Patches";function SG(){return globalThis[mD]||(globalThis[mD]=new WeakMap),globalThis[mD]}function RN(i,A){const e=SG().get(i);return e?e.get(A):null}function K7(i,A,e,t){let g=SG().get(i);g||(g=new Map,SG().set(i,g));let I=g.get(A);I||(I=[],g.set(A,I)),I.push({prefix:e,postfix:t})}function R_(i,A,e,...t){var I;if(!e)return;const g=RN(i,A);if(g)for(const o of g)(I=o.prefix)==null||I.call(e,...t)}function U_(i,A,e,t,...g){var o;if(!e)return;const I=RN(i,A);if(I)for(const s of I)(o=s.postfix)==null||o.call(e,t,...g)}const wb=Symbol("gltf-loader-internal-usage-tracker"),J7=IA("debugusers"),_l=class{constructor(A){r(this,"parser");r(this,"_getDependency");r(this,"_loadingId");r(this,"_loadedObjects",new Set);this.parser=A,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(A){return _l._loadingProcesses>0}beforeRoot(){_l._loadingProcesses++;const A=this,e=this._getDependency;return this.parser.getDependency=function(t,g){const I=e.call(this,t,g);return I.then(o=>(o&&(A._loadedObjects.add(o),o[wb]=A._loadingId),o)),I},null}afterRoot(A){_l._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[wb],e instanceof pA&&(e.parent||e instanceof uA&&(J7&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null));return null}};let Sl=_l;r(Sl,"_loadingProcesses",0);class N_{constructor(){window.addEventListener("unhandledrejection",A=>{var t;if(A.defaultPrevented)return;const e=(t=A==null?void 0:A.reason)==null?void 0:t.path;if(e){const g=e[0];g&&g.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4373
|
-
`+g.src),A.preventDefault())}})}}const fS=IA("trackresources");function F_(){return fS==="dispose"}let nQ=!0;fS===0&&(nQ=!1);function v7(i){nQ=i}function K_(){return nQ}const J_=Symbol("disposable");function UN(i,A){i&&(i[J_]=A,LB&&console.warn("Set disposable",A,i))}const v_=Symbol("disposed");function b7(i){return i[v_]===!0}function jt(i){var A;if(i){if(i[J_]===!1){LB&&console.warn("Object is marked as not disposable",i);return}if(i[v_]=!0,i instanceof pI)jt(i.environment),jt(i.background),jt(i.customDepthMaterial),jt(i.customDistanceMaterial);else if(i instanceof Os)jt(i.geometry),jt(i.material),jt(i.skeleton),jt(i.bindMatrix),jt(i.bindMatrixInverse),jt(i.customDepthMaterial),jt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof uA)jt(i.geometry),jt(i.material),jt(i.customDepthMaterial),jt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof fe){gE(i);for(const e of Object.keys(i.attributes)){const t=i.attributes[e];jt(t)}}else if(i instanceof ie||i instanceof TI)LB&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const e of i)e instanceof xe&&jt(e);else if(i instanceof xe){gE(i);for(const t of Object.keys(i)){const g=i[t];g instanceof qe&&(jt(g),i[t]=null)}const e=i.uniforms;if(e)for(const t of Object.keys(e)){const g=e[t];g instanceof qe?(jt(g),e[t]=null):g instanceof fA&&(jt(g.value),g.value=null)}}else i instanceof qe?(gE(i),gE(i.source),((A=i.source)==null?void 0:A.data)instanceof ImageBitmap&&gE(i.source.data)):i instanceof kc?(gE(i.boneTexture),i.boneTexture=null):i instanceof iu||!(i instanceof pA)&&LB&&console.warn("Unknown object type",i)}}function gE(i){i&&((LB||F_()||fS)&&console.warn("๐งจ FREE",i),i instanceof ImageBitmap?i.close():i instanceof UC?i.data=null:i.dispose())}function b_(i){(i instanceof uA||i instanceof Os)&&(i.material=null,i.geometry=null)}const q7=new Set;function NN(i,A,e=null,t){if(t||(t=q7,t.clear()),!i)return t;const g=i[ud];if(g)for(const I of g)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&NN(I,!0,e,t));return t}function L7(i){return i[il]}const LB=IA("debugresourceusers")||IA("debugmemory"),ud=Symbol("needle-resource-users"),il=Symbol("needle-resource-users-count");function mI(i,A){pS(i,A,function(e,t){nQ&&(Ny(ud,this,e,!1),Ny(ud,this,t,!0))})}nQ&&(mI(uA.prototype,"material"),mI(uA.prototype,"geometry"),mI(xe.prototype,"map"),mI(xe.prototype,"bumpMap"),mI(xe.prototype,"alphaMap"),mI(xe.prototype,"normalMap"),mI(xe.prototype,"displacementMap"),mI(xe.prototype,"roughnessMap"),mI(xe.prototype,"metalnessMap"),mI(xe.prototype,"emissiveMap"),mI(xe.prototype,"specularMap"),mI(xe.prototype,"envMap"),mI(xe.prototype,"lightMap"),mI(xe.prototype,"aoMap"),mI(xe.prototype,"gradientMap"));function x7(i){if(nQ===!1)return;const A=i[ud];if(A)for(const e of A)Ny(ud,e,i,!1)}nQ&&pS(xe.prototype,"dispose",function(){x7(this)});let mG=0;function Ny(i,A,e,t){if(mG>0)return;if(Array.isArray(e)){for(const I of e)Ny(i,A,I,t);return}if(!e)return;let g=e[i];if(g||(g=new Set),t){if(A&&!g.has(A)){g.add(A);let I=e[il]||0;I+=1,e[il]=I,LB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[il]||0;I>0&&(I-=1,e[il]=I),LB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(Sl.isLoading(e)||(fS&&console.warn(`๐ด Removed all user of "${e.type}"`,e),F_()&&jt(e)))}e[i]=g}try{pS(ga.prototype,"render",function(){mG++},function(){mG--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var hu=(i=>(i.Added="component-added",i.Removing="removing-component",i))(hu||{});const Sb=IA("debugcomponentevents");class lu{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let t=this.eventListeners.get(A);t||(t=[]),t.push(e),this.eventListeners.set(A,t),Sb&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const g=t.indexOf(e);g<0||t.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(Sb&&console.log("Dispatching event "+A,t),!!t)for(const g of t)g(e)}}r(lu,"eventListeners",new Map);const q_=IA("debugdefines");Kc('if(!globalThis[""3.32.
|
|
4373
|
+
`+g.src),A.preventDefault())}})}}const fS=IA("trackresources");function F_(){return fS==="dispose"}let nQ=!0;fS===0&&(nQ=!1);function v7(i){nQ=i}function K_(){return nQ}const J_=Symbol("disposable");function UN(i,A){i&&(i[J_]=A,LB&&console.warn("Set disposable",A,i))}const v_=Symbol("disposed");function b7(i){return i[v_]===!0}function jt(i){var A;if(i){if(i[J_]===!1){LB&&console.warn("Object is marked as not disposable",i);return}if(i[v_]=!0,i instanceof pI)jt(i.environment),jt(i.background),jt(i.customDepthMaterial),jt(i.customDistanceMaterial);else if(i instanceof Os)jt(i.geometry),jt(i.material),jt(i.skeleton),jt(i.bindMatrix),jt(i.bindMatrixInverse),jt(i.customDepthMaterial),jt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof uA)jt(i.geometry),jt(i.material),jt(i.customDepthMaterial),jt(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof fe){gE(i);for(const e of Object.keys(i.attributes)){const t=i.attributes[e];jt(t)}}else if(i instanceof ie||i instanceof TI)LB&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const e of i)e instanceof xe&&jt(e);else if(i instanceof xe){gE(i);for(const t of Object.keys(i)){const g=i[t];g instanceof qe&&(jt(g),i[t]=null)}const e=i.uniforms;if(e)for(const t of Object.keys(e)){const g=e[t];g instanceof qe?(jt(g),e[t]=null):g instanceof fA&&(jt(g.value),g.value=null)}}else i instanceof qe?(gE(i),gE(i.source),((A=i.source)==null?void 0:A.data)instanceof ImageBitmap&&gE(i.source.data)):i instanceof kc?(gE(i.boneTexture),i.boneTexture=null):i instanceof iu||!(i instanceof pA)&&LB&&console.warn("Unknown object type",i)}}function gE(i){i&&((LB||F_()||fS)&&console.warn("๐งจ FREE",i),i instanceof ImageBitmap?i.close():i instanceof UC?i.data=null:i.dispose())}function b_(i){(i instanceof uA||i instanceof Os)&&(i.material=null,i.geometry=null)}const q7=new Set;function NN(i,A,e=null,t){if(t||(t=q7,t.clear()),!i)return t;const g=i[ud];if(g)for(const I of g)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&NN(I,!0,e,t));return t}function L7(i){return i[il]}const LB=IA("debugresourceusers")||IA("debugmemory"),ud=Symbol("needle-resource-users"),il=Symbol("needle-resource-users-count");function mI(i,A){pS(i,A,function(e,t){nQ&&(Ny(ud,this,e,!1),Ny(ud,this,t,!0))})}nQ&&(mI(uA.prototype,"material"),mI(uA.prototype,"geometry"),mI(xe.prototype,"map"),mI(xe.prototype,"bumpMap"),mI(xe.prototype,"alphaMap"),mI(xe.prototype,"normalMap"),mI(xe.prototype,"displacementMap"),mI(xe.prototype,"roughnessMap"),mI(xe.prototype,"metalnessMap"),mI(xe.prototype,"emissiveMap"),mI(xe.prototype,"specularMap"),mI(xe.prototype,"envMap"),mI(xe.prototype,"lightMap"),mI(xe.prototype,"aoMap"),mI(xe.prototype,"gradientMap"));function x7(i){if(nQ===!1)return;const A=i[ud];if(A)for(const e of A)Ny(ud,e,i,!1)}nQ&&pS(xe.prototype,"dispose",function(){x7(this)});let mG=0;function Ny(i,A,e,t){if(mG>0)return;if(Array.isArray(e)){for(const I of e)Ny(i,A,I,t);return}if(!e)return;let g=e[i];if(g||(g=new Set),t){if(A&&!g.has(A)){g.add(A);let I=e[il]||0;I+=1,e[il]=I,LB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",g)}}else if(A&&g.has(A)){g.delete(A);let I=e[il]||0;I>0&&(I-=1,e[il]=I),LB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",g),I<=0&&(Sl.isLoading(e)||(fS&&console.warn(`๐ด Removed all user of "${e.type}"`,e),F_()&&jt(e)))}e[i]=g}try{pS(ga.prototype,"render",function(){mG++},function(){mG--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var hu=(i=>(i.Added="component-added",i.Removing="removing-component",i))(hu||{});const Sb=IA("debugcomponentevents");class lu{static addComponentLifecylceEventListener(A,e){this.eventListeners.has(A)&&this.eventListeners.set(A,[]);let t=this.eventListeners.get(A);t||(t=[]),t.push(e),this.eventListeners.set(A,t),Sb&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const g=t.indexOf(e);g<0||t.splice(g,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(Sb&&console.log("Dispatching event "+A,t),!!t)for(const g of t)g(e)}}r(lu,"eventListeners",new Map);const q_=IA("debugdefines");Kc('if(!globalThis[""3.32.27-alpha""]) globalThis[""3.32.27-alpha""] = "0.0.0";');Kc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Kc('if(!globalThis[""Mon Feb 26 2024 22:30:20 GMT+0800 (Pacific Standard Time)""]) globalThis[""Mon Feb 26 2024 22:30:20 GMT+0800 (Pacific Standard Time)""] = "unknown";');Kc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.32.27-alpha";');Kc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Kc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Feb 26 2024 22:30:20 GMT+0800 (Pacific Standard Time)";');const Rn="3.32.27-alpha",DS="undefined",T7="Mon Feb 26 2024 22:30:20 GMT+0800 (Pacific Standard Time)";q_&&console.log(`Engine version: ${Rn} (generator: ${DS})
|
|
4374
4374
|
Project built at ${T7}`);const YC="needle_isActiveInHierarchy",uB="builtin_components",ml="needle_editor_guid";function Kc(i){try{(0,eval)(i)}catch(A){q_&&console.error(A)}}const pd=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),L_=Symbol("isUsingInstancing"),x_=Symbol("instancingRenderer"),kG=Symbol("instancingAutoUpdateBounds");class Ws{static isUsingInstancing(A){return A[L_]===!0}static getRenderer(A){return A[x_]||null}setAutoUpdateBounds(A,e){const t=Ws.getRenderer(A);t&&(t[kG]=e)}static markDirty(A,e=!0){if(A&&(this.isUsingInstancing(A)&&(A[pd]=!0,A.matrixWorldNeedsUpdate=!0),e))for(const t of A.children)Ws.markDirty(t,!0)}}function xB(i,A){try{A?i(A):i()}catch(e){return console.error(e),!1}return!0}const MG=IA("debugnewscripts"),Y7=IA("debughierarchy"),Ii=[];function _7(){return Ii.length>0}function Fy(i){if(!(i.new_scripts.length<=0)){if(MG&&console.log("Register new components",i.new_scripts.length,[...i.new_scripts],i.alias?"element: "+i.alias:i.hash,i),i.new_scripts_pre_setup_callbacks.length>0){for(const A of i.new_scripts_pre_setup_callbacks)A&&A();i.new_scripts_pre_setup_callbacks.length=0}Ii.length=0,i.new_scripts.length>0&&Ii.push(...i.new_scripts),i.new_scripts.length=0;for(let A=0;A<Ii.length;A++)try{const e=Ii[A];if(e.isComponent!==!0){(me()||MG)&&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
|
`,e),Ii.splice(A,1),A--;continue}if(e.destroyed)continue;if(!e.gameObject){console.error("MISSING GAMEOBJECT - will ignore",e),Ii.splice(A,1),A--;continue}e.context=i,kl(e.gameObject),FN(e,i)}catch(e){console.error(e),kC(Ii[A],i),Ii.splice(A,1),A--}for(let A=0;A<Ii.length;A++)try{const e=Ii[A];if(e.destroyed){kC(Ii[A],i),Ii.splice(A,1),A--;continue}if(e.registering)try{e.registering()}catch(t){console.error(t)}e.__internalAwake!==void 0&&(e.gameObject||console.error("MISSING GAMEOBJECT",e,e.gameObject),kl(e.gameObject),e.activeAndEnabled&&xB(e.__internalAwake.bind(e)))}catch(e){console.error(e),kC(Ii[A],i),Ii.splice(A,1),A--}for(let A=0;A<Ii.length;A++)try{const e=Ii[A];if(e.destroyed||e.enabled===!1||(kl(e.gameObject),e.activeAndEnabled===!1))continue;e.__internalEnable!==void 0&&(e.enabled=!0,xB(e.__internalEnable.bind(e)))}catch(e){console.error(e),kC(Ii[A],i),Ii.splice(A,1),A--}for(let A=0;A<Ii.length;A++)try{const e=Ii[A];if(e.destroyed||!e.gameObject)continue;i.new_script_start.push(e)}catch(e){console.error(e),kC(Ii[A],i),Ii.splice(A,1),A--}Ii.length=0;for(const A of i.new_scripts_post_setup_callbacks)A&&A();i.new_scripts_post_setup_callbacks.length=0}}function H7(i){i&&(i.__internalDisable(!0),kC(i,i.context))}function T_(i,A){for(let e=0;e<i.new_script_start.length;e++)try{const t=i.new_script_start[e];if(A!==void 0&&t.gameObject!==A||t.destroyed||t.activeAndEnabled===!1)continue;xB(t.__internalAwake.bind(t)),t.enabled&&(xB(t.__internalEnable.bind(t)),xB(t.__internalStart.bind(t)),i.new_script_start.splice(e,1),e--)}catch(t){console.error(t),kC(i.new_script_start[e],i),i.new_script_start.splice(e,1),e--}}function FN(i,A){A.scripts.indexOf(i)===-1&&(A.scripts.push(i),i.earlyUpdate&&A.scripts_earlyUpdate.push(i),i.update&&A.scripts_update.push(i),i.lateUpdate&&A.scripts_lateUpdate.push(i),i.onBeforeRender&&A.scripts_onBeforeRender.push(i),i.onAfterRender&&A.scripts_onAfterRender.push(i),i.onPausedChanged&&A.scripts_pausedChanged.push(i),$m(i,null)&&A.new_scripts_xr.push(i),$m(i,"immersive-vr")&&A.scripts_immersive_vr.push(i),$m(i,"immersive-ar")&&A.scripts_immersive_ar.push(i))}function kC(i,A){zo(i,A.new_scripts),zo(i,A.new_script_start),zo(i,A.scripts),zo(i,A.scripts_earlyUpdate),zo(i,A.scripts_update),zo(i,A.scripts_lateUpdate),zo(i,A.scripts_onBeforeRender),zo(i,A.scripts_onAfterRender),zo(i,A.scripts_pausedChanged),zo(i,A.new_scripts_xr),zo(i,A.scripts_immersive_vr),zo(i,A.scripts_immersive_ar),A.stopAllCoroutinesFrom(i)}function zo(i,A){const e=A.indexOf(i);e>=0&&A.splice(e,1)}function $m(i,A){var e;if(i){const t=i;if(t.onBeforeXR||t.onEnterXR||t.onUpdateXR||t.onLeaveXR||t.onXRControllerAdded||t.onXRControllerRemoved)return!(A!=null&&((e=t.supportsXR)==null?void 0:e.call(t,A))===!1)}return!1}function kD(i){if(i||(i=wt.Current.scene),!i){console.trace("Invalid call - no current context.");return}const A=bc(i);Y_(i,A,!0)||(MG||me()?console.error(`Error updating hierarchy
|
|
@@ -4916,7 +4916,7 @@ in script ${t}.ts
|
|
|
4916
4916
|
*
|
|
4917
4917
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
4918
4918
|
* @license MIT
|
|
4919
|
-
*/var feA=function(i){return i!=null&&(cH(i)||DeA(i)||!!i._isBuffer)};function cH(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function DeA(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&cH(i.slice(0,0))}(function(){var i=peA,A=qb.utf8,e=feA,t=qb.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=t.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=i.bytesToWords(I),n=I.length*8,C=1732584193,a=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[n>>>5]|=128<<n%32,s[(n+64>>>9<<4)+14]=n;for(var c=g._ff,h=g._gg,u=g._hh,l=g._ii,E=0;E<s.length;E+=16){var d=C,p=a,f=B,S=Q;C=c(C,a,B,Q,s[E+0],7,-680876936),Q=c(Q,C,a,B,s[E+1],12,-389564586),B=c(B,Q,C,a,s[E+2],17,606105819),a=c(a,B,Q,C,s[E+3],22,-1044525330),C=c(C,a,B,Q,s[E+4],7,-176418897),Q=c(Q,C,a,B,s[E+5],12,1200080426),B=c(B,Q,C,a,s[E+6],17,-1473231341),a=c(a,B,Q,C,s[E+7],22,-45705983),C=c(C,a,B,Q,s[E+8],7,1770035416),Q=c(Q,C,a,B,s[E+9],12,-1958414417),B=c(B,Q,C,a,s[E+10],17,-42063),a=c(a,B,Q,C,s[E+11],22,-1990404162),C=c(C,a,B,Q,s[E+12],7,1804603682),Q=c(Q,C,a,B,s[E+13],12,-40341101),B=c(B,Q,C,a,s[E+14],17,-1502002290),a=c(a,B,Q,C,s[E+15],22,1236535329),C=h(C,a,B,Q,s[E+1],5,-165796510),Q=h(Q,C,a,B,s[E+6],9,-1069501632),B=h(B,Q,C,a,s[E+11],14,643717713),a=h(a,B,Q,C,s[E+0],20,-373897302),C=h(C,a,B,Q,s[E+5],5,-701558691),Q=h(Q,C,a,B,s[E+10],9,38016083),B=h(B,Q,C,a,s[E+15],14,-660478335),a=h(a,B,Q,C,s[E+4],20,-405537848),C=h(C,a,B,Q,s[E+9],5,568446438),Q=h(Q,C,a,B,s[E+14],9,-1019803690),B=h(B,Q,C,a,s[E+3],14,-187363961),a=h(a,B,Q,C,s[E+8],20,1163531501),C=h(C,a,B,Q,s[E+13],5,-1444681467),Q=h(Q,C,a,B,s[E+2],9,-51403784),B=h(B,Q,C,a,s[E+7],14,1735328473),a=h(a,B,Q,C,s[E+12],20,-1926607734),C=u(C,a,B,Q,s[E+5],4,-378558),Q=u(Q,C,a,B,s[E+8],11,-2022574463),B=u(B,Q,C,a,s[E+11],16,1839030562),a=u(a,B,Q,C,s[E+14],23,-35309556),C=u(C,a,B,Q,s[E+1],4,-1530992060),Q=u(Q,C,a,B,s[E+4],11,1272893353),B=u(B,Q,C,a,s[E+7],16,-155497632),a=u(a,B,Q,C,s[E+10],23,-1094730640),C=u(C,a,B,Q,s[E+13],4,681279174),Q=u(Q,C,a,B,s[E+0],11,-358537222),B=u(B,Q,C,a,s[E+3],16,-722521979),a=u(a,B,Q,C,s[E+6],23,76029189),C=u(C,a,B,Q,s[E+9],4,-640364487),Q=u(Q,C,a,B,s[E+12],11,-421815835),B=u(B,Q,C,a,s[E+15],16,530742520),a=u(a,B,Q,C,s[E+2],23,-995338651),C=l(C,a,B,Q,s[E+0],6,-198630844),Q=l(Q,C,a,B,s[E+7],10,1126891415),B=l(B,Q,C,a,s[E+14],15,-1416354905),a=l(a,B,Q,C,s[E+5],21,-57434055),C=l(C,a,B,Q,s[E+12],6,1700485571),Q=l(Q,C,a,B,s[E+3],10,-1894986606),B=l(B,Q,C,a,s[E+10],15,-1051523),a=l(a,B,Q,C,s[E+1],21,-2054922799),C=l(C,a,B,Q,s[E+8],6,1873313359),Q=l(Q,C,a,B,s[E+15],10,-30611744),B=l(B,Q,C,a,s[E+6],15,-1560198380),a=l(a,B,Q,C,s[E+13],21,1309151649),C=l(C,a,B,Q,s[E+4],6,-145523070),Q=l(Q,C,a,B,s[E+11],10,-1120210379),B=l(B,Q,C,a,s[E+2],15,718787259),a=l(a,B,Q,C,s[E+9],21,-343485551),C=C+d>>>0,a=a+p>>>0,B=B+f>>>0,Q=Q+S>>>0}return i.endian([C,a,B,Q])};g._ff=function(I,o,s,n,C,a,B){var Q=I+(o&s|~o&n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._gg=function(I,o,s,n,C,a,B){var Q=I+(o&n|s&~n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._hh=function(I,o,s,n,C,a,B){var Q=I+(o^s^n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._ii=function(I,o,s,n,C,a,B){var Q=I+(s^(o|~n))+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._blocksize=16,g._digestsize=16,QH.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=i.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?t.bytesToString(s):i.bytesToHex(s)}})();var yeA=QH.exports;const weA=mS(yeA);class vG{constructor(A,e,t,g){r(this,"success");r(this,"filename");r(this,"hash");r(this,"size");r(this,"url");this.success=A,this.filename=e,this.hash=t,this.size=g}}async function hH(i,A){const e=await i.arrayBuffer(),t=YN(e),g=i.name.split(".").pop(),I=t+"."+g,o=i.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",t),new vG(!0,I,t,i.size);console.log("begin uploading file",o,i.size);const a=new FormData;a.append("file",i);const B={};B.filesize=i.size,o&&(B.alias=o);const E=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:B})).json();if((E==null?void 0:E.success)===!1)return E.message!==void 0?console.error("Upload failed:",E.message):console.error("Upload failed"),null;console.assert(E.hash_sum===t,"hash sum did not match","received:",E.hash_sum,"expected:",t),E.success&&console.log("successfully uploaded",t,E.id);const c=new vG(E.success,I,t,i.size);return c.url=A,c}function YN(i){return weA(new Uint8Array(i))}async function _N(i,A,e,t,g=!1){try{const I=await fetch(t+"/download/file",{method:"POST",body:i});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const n=YN(s);return g||console.assert(n===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function lH(i,A){var a;const e=await fetch(i),t=(a=e.body)==null?void 0:a.getReader(),g=e.headers.get("Content-Length"),I=g?parseInt(g):0;if(!t)return null;let o=0;const s=[];for(;;){const{done:B,value:Q}=await t.read();if(Q&&(s.push(Q),o+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:o,total:I}))),B)break}const n=new Uint8Array(o);let C=0;for(const B of s)n.set(B,C),C+=B.length;return n}const ka=IA("debugaddressables");class dH{constructor(A){r(this,"_context");r(this,"_assetReferences",{});this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e==null||e.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const Ik=Symbol("assetReference"),bE=class{constructor(A,e,t=null){r(this,"_loading");r(this,"_asset");r(this,"_glbRoot");r(this,"_url");r(this,"_progressListeners",[]);r(this,"_hash");r(this,"_hashedUri");r(this,"_isLoadingRawBinary",!1);r(this,"_rawBinary");this._url=A,this._hash=e,A.includes("?v=")?this._hashedUri=A:this._hashedUri=e?A+"?v="+e:A,t!==null&&(this.asset=t),PO(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(A,e,t){if(typeof A=="string"){if(!t&&(t=ve.Current,!t))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 t=A.context,A=A.sourceId;const g=Ia(A,e);ka&&console.log("GetOrCreate Addressable from",A,e,"FinalPath=",g);const I=t.addressables,o=I.findAssetReference(g);if(o)return o;const s=new bE(g,t.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(A){this._asset=A}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(A){return A===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||AQ(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(ka&&console.log("Unload",this.asset),this.asset.scene&&Vs(this.asset.scene,!0,!0),Vs(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,ve.Current&&ve.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,ka&&console.log("Preload",this._hashedUri);const A=await lH(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=(A==null?void 0:A.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(A){if(ka&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(A&&this._progressListeners.push(A),this._loading!==void 0)return this._loading.then(g=>this.asset);const e=ve.Current;this._rawBinary?(this._loading=js().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(ka&&console.log("Load async",this.uri),this._loading=js().loadSync(e,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[Ik]=this,this._glbRoot&&(this._glbRoot[Ik]=this),this.asset&&(this.asset[Ik]=this),Fy(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(A){return this.onInstantiate(A,!1)}async instantiateSynced(A,e=!0){return this.onInstantiate(A,!0,e)}beginListenDownload(A){this._progressListeners.indexOf(A)<0&&this._progressListeners.push(A)}endListenDownload(A){const e=this._progressListeners.indexOf(A);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(A){for(const e of this._progressListeners)e(this,A)}async onInstantiate(A,e=!1,t){const g=ve.Current,I=new en;if(A instanceof pA?I.parent=A:A&&I.cloneAssign(A),I.parent||(I.parent=g.scene),this.mustLoad&&await this.loadAssetAsync(),ka&&console.log("Instantiate",this.uri,"parent:",A),this.asset){ka&&console.log("Add to scene",this.asset);let o=bE.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,bE.currentlyInstantiating.set(this.uri,o),e){I.context=g;const s=this.asset;s.guid=this.uri;const n=IF(s,I,void 0,t);if(n)return n}else{const s=qc(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,bE.currentlyInstantiating.set(this.uri,o)})}}else ka&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(A){if(A&&A.scene){const e=A.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let It=bE;r(It,"currentlyInstantiating",new Map);class SeA extends jn{constructor(){super([It],"AssetReferenceSerializer")}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?It.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof pA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const t=A,g=e.context,I=t.guid??t.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new It(I,void 0,t);return g.addressables.registerAssetReference(s),s}return null}}new SeA;const meA=Promise.resolve(null),Hl=class{constructor(A){r(this,"url");r(this,"_bitmap");r(this,"_bitmapObject");r(this,"loader",null);this.url=A}static getOrCreate(A){let e=Hl.imageReferences.get(A);return e||(e=new Hl(A),Hl.imageReferences.set(A,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const A=new Image;return A.src=this.url,A}createTexture(){return this.url?(this.loader||(this.loader=new bC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):meA}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((A,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(g=>(this._bitmapObject=g,A(g),g))}),t.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),A(null)}),t.src=this.url}),this._bitmap)}};let HE=Hl;r(HE,"imageReferences",new Map);class uH extends jn{constructor(){super([HE],"ImageReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=Ia(e.gltfId,A);return HE.getOrCreate(t)}}}new uH;const Ol=class{constructor(A){r(this,"url");r(this,"res");this.url=A}static getOrCreate(A){let e=Ol.cache.get(A);return e||(e=new Ol(A),Ol.cache.set(A,e)),e}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(A=>A.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(A=>A.text())}};let OE=Ol;r(OE,"cache",new Map);class pH extends jn{constructor(){super([OE],"FileReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=Ia(e.gltfId,A);return OE.getOrCreate(t)}}}new pH;const Sg={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 fH(i){const A=await fetch(i);if(A.ok)return A.json();throw new Error(A.statusText)}async function keA(i){if(!i)throw new Error("No basePath supplied");return await fH(`${i}/profilesList.json`)}async function MeA(i,A,e=null,t=!0){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No basePath supplied");const g=await keA(A);let I;if(i.profiles.some(n=>{const C=g[n];return C&&(I={profileId:n,profilePath:`${A}/${C.path}`,deprecated:!!C.deprecated}),!!I}),!I){if(!e)throw new Error("No matching profile name found");const n=g[e];if(!n)throw new Error(`No matching profile name found and default profile "${e}" missing.`);I={profileId:e,profilePath:`${A}/${n.path}`,deprecated:!!n.deprecated}}const o=await fH(I.profilePath);let s;if(t){let n;if(i.handedness==="any"?n=o.layouts[Object.keys(o.layouts)[0]]:n=o.layouts[i.handedness],!n)throw new Error(`No matching handedness, ${i.handedness}, in profile ${I.profileId}`);n.assetPath&&(s=I.profilePath.replace("profile.json",n.assetPath))}return{profile:o,assetPath:s}}const GeA={xAxis:0,yAxis:0,button:0,state:Sg.ComponentState.DEFAULT};function ReA(i=0,A=0){let e=i,t=A;if(Math.sqrt(i*i+A*A)>1){const o=Math.atan2(A,i);e=Math.cos(o),t=Math.sin(o)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:t*.5+.5}}let UeA=class{constructor(A){this.componentProperty=A.componentProperty,this.states=A.states,this.valueNodeName=A.valueNodeName,this.valueNodeProperty=A.valueNodeProperty,this.valueNodeProperty===Sg.VisualResponseProperty.TRANSFORM&&(this.minNodeName=A.minNodeName,this.maxNodeName=A.maxNodeName),this.value=0,this.updateFromComponent(GeA)}updateFromComponent({xAxis:A,yAxis:e,button:t,state:g}){const{normalizedXAxis:I,normalizedYAxis:o}=ReA(A,e);switch(this.componentProperty){case Sg.ComponentProperty.X_AXIS:this.value=this.states.includes(g)?I:.5;break;case Sg.ComponentProperty.Y_AXIS:this.value=this.states.includes(g)?o:.5;break;case Sg.ComponentProperty.BUTTON:this.value=this.states.includes(g)?t:0;break;case Sg.ComponentProperty.STATE:this.valueNodeProperty===Sg.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(g):this.value=this.states.includes(g)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},NeA=class{constructor(A,e){if(!A||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=A,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(t=>{const g=new UeA(e.visualResponses[t]);this.visualResponses[t]=g}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:Sg.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(A){if(this.values.state=Sg.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&A.buttons.length>this.gamepadIndices.button){const e=A.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=Sg.ComponentState.PRESSED:(e.touched||this.values.button>Sg.ButtonTouchThreshold)&&(this.values.state=Sg.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&A.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=A.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===Sg.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Sg.AxisTouchThreshold&&(this.values.state=Sg.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&A.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=A.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===Sg.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Sg.AxisTouchThreshold&&(this.values.state=Sg.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},FeA=class{constructor(A,e,t){if(!A)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=A,this.assetUrl=t,this.id=e.profileId,this.layoutDescription=e.layouts[A.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(g=>{const I=this.layoutDescription.components[g];this.components[g]=new NeA(g,I)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const A=[];return Object.values(this.components).forEach(e=>{A.push(e.data)}),A}updateFromGamepad(){Object.values(this.components).forEach(A=>{A.updateFromGamepad(this.xrInputSource.gamepad)})}};class Jt extends wA{constructor(e,t,g,I){super(e,t,g);r(this,"alpha",1);this.alpha=I}get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return super.copy(e),"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const g=e;return g.alpha&&(this.alpha=se.lerp(this.alpha,g.alpha,t)),super.lerp(e,t)}lerpColors(e,t,g){const I=e,o=t;return I.alpha&&o.alpha&&(this.alpha=se.lerp(I.alpha,o.alpha,g)),super.lerpColors(e,t,g)}multiply(e){const t=e;return t.alpha&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}}const kI=new y,Lb=new y,xb=new GA,KeA=IA("debuggizmos"),CC=8947848,Js=class{static isGizmo(A){return A[bG]!==void 0}static DrawLabel(A,e,t=.05,g=0,I,o,s){var a;if(!Js.enabled)return null;I||(I=CC);const n=((a=ue.active)==null?void 0:a.rigScale)??1,C=Zi.getTextLabel(g,e,t*n,I,o);return s instanceof pA&&s.add(C),C.position.x=A.x,C.position.y=A.y,C.position.z=A.z,C}static DrawRay(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),kI.set(e.x,e.y,e.z).multiplyScalar(999999999),s.setXYZ(1,A.x+kI.x,A.y+kI.y,A.z+kI.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawDirection(A,e,t=CC,g=0,I=!0,o=1){if(!Js.enabled)return;const s=Zi.getLine(g),n=s.geometry.getAttribute("position");n.setXYZ(0,A.x,A.y,A.z),e.w!==void 0?(kI.set(0,0,-o),xb.set(e.x,e.y,e.z,e.w),kI.applyQuaternion(xb)):(kI.set(e.x,e.y,e.z),kI.multiplyScalar(o)),n.setXYZ(1,A.x+kI.x,A.y+kI.y,A.z+kI.z),n.needsUpdate=!0,s.material.color.set(t),s.material.depthTest=I,s.material.depthWrite=!1}static DrawLine(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),s.setXYZ(1,e.x,e.y,e.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireSphere(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getSphere(e,g,!0);XB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawSphere(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getSphere(e,g,!1);XB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireBox(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getBox(g);o.position.set(A.x,A.y,A.z),o.scale.set(e.x,e.y,e.z),o.material.color.set(t),o.material.depthTest=I,o.material.wireframe=!0,o.material.depthWrite=!1}static DrawWireBox3(A,e=CC,t=0,g=!0){if(!Js.enabled)return;const I=Zi.getBox(t);I.position.copy(A.getCenter(kI)),I.scale.copy(A.getSize(kI)),I.material.color.set(e),I.material.depthTest=g,I.material.wireframe=!0,I.material.depthWrite=!1}static DrawArrow(A,e,t=CC,g=0,I=!0,o=!1){if(!Js.enabled)return;const s=Zi.getArrowHead(g);s.position.set(e.x,e.y,e.z),s.quaternion.setFromUnitVectors(this._up.set(0,1,0),kI.set(e.x,e.y,e.z).sub(Lb.set(A.x,A.y,A.z)).normalize());const C=kI.set(e.x,e.y,e.z).sub(Lb.set(A.x,A.y,A.z)).length()*.1;s.scale.set(C,C,C),s.material.color.set(t),s.material.depthTest=I,s.material.wireframe=o,this.DrawLine(A,e,t,g,I)}};let Re=Js;r(Re,"enabled",!0),r(Re,"_up",new y(0,1,0));const JeA=new Zt(1,1,1);function HN(i=null){const A=new wA(i??14540253),e=new SU(JeA);return new Lo(e,new Pi({color:A}))}const bG=Symbol("GizmoCache");class Zi{static ensureFont(){let A=Io.FontLibrary.getFontFamily(this.familyName);if(!A){A=Io.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{Io.update()})}}static getTextLabel(A,e,t,g,I){this.ensureFont();let o=this.textLabelCache.pop(),s=1;I&&typeof I=="string"&&(I==null?void 0:I.length)>=8&&I.startsWith("#")?(s=parseInt(I.substring(7),16)/255,I=I.substring(0,7),KeA&&console.log(I,s)):typeof I=="object"&&I.a!==void 0&&(s=I.a);const n={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:t,color:g,lineHeight:1,backgroundColor:I??void 0,backgroundOpacity:s,textContent:e,borderRadius:.5*t,padding:.8*t,whiteSpace:"pre"};if(o)o.set(n);else{o=new DN(n);const C=this,a=o;a.setText=function(B){this.set({textContent:B}),C.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(ve.Current,o,A,this.textLabelCache),o}static getBox(A){let e=this.boxesCache.pop();if(!e){const t=new Zt(1,1,1);e=new uA(t)}return this.registerTimedObject(ve.Current,e,A,this.boxesCache),e}static getLine(A){let e=this.linesCache.pop();if(!e){e=new _i;let t=e.geometry.getAttribute("position");t||(t=new ie(new Float32Array(2*3),3),e.geometry.setAttribute("position",t))}return e.frustumCulled=!1,this.registerTimedObject(ve.Current,e,A,this.linesCache),e}static getSphere(A,e,t){let g=this.spheresCache.pop();return g||(g=new uA(new Xs(1,8,8))),g.scale.set(A,A,A),g.material.wireframe=t,this.registerTimedObject(ve.Current,g,e,this.spheresCache),g}static getArrowHead(A){let e=this.arrowHeadsCache.pop();return e||(e=new uA(new Ti(0,.5,1,8))),this.registerTimedObject(ve.Current,e,A,this.arrowHeadsCache),e}static registerTimedObject(A,e,t,g){const I=this.contextBeforeRenderCallbacks.get(A),o=this.contextPostRenderCallbacks.get(A);if(I){if(A.pre_render_callbacks[A.pre_render_callbacks.length-1]!==I){const s=A.pre_render_callbacks.indexOf(I);s>=0&&A.pre_render_callbacks.splice(s,1),A.pre_render_callbacks.push(I)}}else{const s=()=>{this.onBeforeRender(A,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(A,s),A.pre_render_callbacks.push(s)}if(o){if(A.post_render_callbacks[A.post_render_callbacks.length-1]!==o){const s=A.post_render_callbacks.indexOf(o);s>=0&&A.post_render_callbacks.splice(s,1),A.post_render_callbacks.push(o)}}else{const s=()=>{this.onPostRender(A,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(A,s),A.post_render_callbacks.push(s)}e.traverse(s=>{s.layers.disableAll(),s.layers.enable(2)}),e.renderOrder=999999,e[bG]=g,this.timedObjectsBuffer.push(e),this.timesBuffer.push(ve.Current.time.realtimeSinceStartup+t),A.scene.add(e)}static onBeforeRender(A,e){this.tmuiNeedsUpdate&&Io.update();for(let t=0;t<e.length;t++){const g=e[t];if(A.mainCamera&&g instanceof Io.MeshUIBaseElement){if(AQ(g))continue;const I=A.isInVR,o=!1,s=!I;uS(g,A.mainCamera,o,s)}}}static onPostRender(A,e,t){const g=A.time.realtimeSinceStartup;for(let I=e.length-1;I>=0;I--){const o=e[I];g>t[I]&&(e.splice(I,1),t.splice(I,1),o.removeFromParent(),AQ(o)!=!0&&o[bG].push(o))}}}r(Zi,"familyName","needle-gizmos"),r(Zi,"linesCache",[]),r(Zi,"spheresCache",[]),r(Zi,"boxesCache",[]),r(Zi,"arrowHeadsCache",[]),r(Zi,"textLabelCache",[]),r(Zi,"timedObjectsBuffer",new Array),r(Zi,"timesBuffer",new Array),r(Zi,"contextPostRenderCallbacks",new Map),r(Zi,"contextBeforeRenderCallbacks",new Map),r(Zi,"tmuiNeedsUpdate",!1);const Kg=IA("debuginput");var kS=(i=>(i.Mouse="mouse",i.Touch="touch",i.Controller="controller",i.Hand="hand",i))(kS||{}),ni=(i=>(i.PointerDown="pointerdown",i.PointerUp="pointerup",i.PointerMove="pointermove",i.KeyDown="keydown",i.KeyUp="keyup",i.KeyPressed="keypress",i))(ni||{});class pC extends PointerEvent{constructor(e,t,g){super(e,g);r(this,"deviceIndex");r(this,"origin");r(this,"source");r(this,"mode");r(this,"ray");r(this,"space");r(this,"isClick",!1);r(this,"isDoubleClick",!1);r(this,"_used",!1);r(this,"_pointerid");r(this,"_pointerType");r(this,"_type");r(this,"_immediatePropagationStopped",!1);r(this,"_propagationStopped",!1);this._pointerid=g.pointerId,this._pointerType=g.pointerType,this._type=e,this.deviceIndex=g.deviceIndex,this.origin=g.origin,this.source=t,this.mode=g.mode,this.ray=g.ray,this.space=g.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 e;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}stopPropagation(){var e;this._propagationStopped=!0,super.stopPropagation(),(e=this.source)==null||e.stopPropagation()}}class gl extends KeyboardEvent{constructor(e,t,g){super(e,g);r(this,"source");this.source=t}stopImmediatePropagation(){var e;super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}}class veA{constructor(A){r(this,"key");r(this,"keyType");r(this,"source");this.key=A.key,this.keyType=A.type,this.source=A}}var un=(i=>(i[i.Early=-100]="Early",i[i.Default=0]="Default",i[i.Late=100]="Late",i))(un||{});class DH{constructor(A){r(this,"_eventListeners",{});r(this,"_doubleClickTimeThreshold",.2);r(this,"_longPressTimeThreshold",1);r(this,"_specialCursorTrigger",0);r(this,"context");r(this,"_pointerDown",[!1]);r(this,"_pointerUp",[!1]);r(this,"_pointerClick",[!1]);r(this,"_pointerDoubleClick",[!1]);r(this,"_pointerPressed",[!1]);r(this,"_pointerPositions",[new gA]);r(this,"_pointerPositionsLastFrame",[new gA]);r(this,"_pointerPositionsDelta",[new gA]);r(this,"_pointerPositionsRC",[new gA]);r(this,"_pointerPositionDown",[new gA]);r(this,"_pointerDownTime",[]);r(this,"_pointerUpTime",[]);r(this,"_pointerUpTimestamp",[]);r(this,"_pointerIds",[]);r(this,"_pointerTypes",[""]);r(this,"_mouseWheelChanged",[!1]);r(this,"_mouseWheelDeltaY",[0]);r(this,"_pointerEvent",[]);r(this,"_pointerUsed",[]);r(this,"_pointerSpace",[]);r(this,"_pressedStack",new Map);r(this,"_htmlEventSource");r(this,"onLostFocus",()=>{for(const A in this.keysPressed)this.keysPressed[A].pressed=!1});r(this,"onEndOfFrame",()=>{for(let A=0;A<this._pointerUp.length;A++)this._pointerUp[A]=!1;for(let A=0;A<this._pointerDown.length;A++)this._pointerDown[A]=!1;for(let A=0;A<this._pointerClick.length;A++)this._pointerClick[A]=!1;for(let A=0;A<this._pointerDoubleClick.length;A++)this._pointerDoubleClick[A]=!1;for(const A of this._pointerPositionsDelta)A.set(0,0);for(let A=0;A<this._mouseWheelChanged.length;A++)this._mouseWheelChanged[A]=!1;for(let A=0;A<this._mouseWheelDeltaY.length;A++)this._mouseWheelDeltaY[A]=0});r(this,"onContextMenu",A=>{this.canReceiveInput(A)!==!1&&A instanceof PointerEvent&&A.pointerType});r(this,"keysPressed",{});r(this,"onKeyDown",A=>{if(Kg&&console.log(`key down ${A.code}, ${this.context.application.hasFocus}`,A),!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(e&&e.pressed)return;this.keysPressed[A.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:A.key,code:A.code};const t=new gl("keydown",A,A);this.onDispatchEvent(t)});r(this,"onKeyPressed",A=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(!e)return;e.pressed=!0,e.frame=this.context.time.frameCount+1;const t=new gl("keypress",A,A);this.onDispatchEvent(t)});r(this,"onKeyUp",A=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(!e)return;e.pressed=!1,e.frame=this.context.time.frameCount+1;const t=new gl("keyup",A,A);this.onDispatchEvent(t)});r(this,"onMouseWheel",A=>{if(this.canReceiveInput(A)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const e=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=e+A.deltaY});r(this,"onTouchStartWindow",A=>{this.context.isInAR&&this.onTouchStart(A)});r(this,"onTouchStart",A=>{if(!(A.changedTouches.length<=0)&&this.canReceiveInput(A)!==!1)for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier);Kg&&fi(`touch start #${g}, identifier:${t.identifier}`);const I=this.getAndUpdateSpatialObjectForScreenPosition(g,t.clientX,t.clientY),o=new pC("pointerdown",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:0,clientX:t.clientX,clientY:t.clientY,pointerType:"touch",buttonName:"unknown",device:I,pressure:t.force});this.onDown(o)}});r(this,"onTouchMove",A=>{if(!(A.changedTouches.length<=0))for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier),I=this.getAndUpdateSpatialObjectForScreenPosition(g,t.clientX,t.clientY),o=new pC("pointermove",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:0,clientX:t.clientX,clientY:t.clientY,pointerType:"touch",buttonName:"unknown",device:I,pressure:t.force});this.onMove(o)}});r(this,"onTouchUp",A=>{if(!(A.changedTouches.length<=0))for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier);if(!this.isNewEvent(A.timeStamp,g,this._pointerUpTimestamp))continue;const I=this.createPointerEventFromTouch("pointerup",t.identifier,t.clientX,t.clientY,t.force,A);this.onUp(I),this._pointerIds.splice(this._pointerIds.indexOf(g),1)}});r(this,"onTouchCancel",A=>{});r(this,"onMouseDown",A=>{if(this.onDownButton(0,A.button),this.context.isInVR||A.defaultPrevented||this.canReceiveInput(A)===!1)return;const e=A.button;let t="none";switch(e){case 0:t="left";break;case 1:t="middle";break;case 2:t="right";break}const g=0+e,I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=new pC("pointerdown",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:t,device:I,pressure:1});this.onDown(o)});r(this,"onMouseMove",A=>{if(this.context.isInVR||A.defaultPrevented)return;const e=this.getFirstPressedButtonForPointer(0),t=e??0,g=0+t,I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=e!==void 0?1:0,s=new pC("pointermove",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:t,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:"none",device:I,pressure:o});this.onMove(s)});r(this,"onMouseUp",A=>{if(this.onReleaseButton(0,A.button),this.context.isInVR)return;const e=A.button;if(!this.isNewEvent(A.timeStamp,e,this._pointerUpTimestamp))return;let t="none";switch(e){case 0:t="left";break;case 1:t="middle";break;case 2:t="right";break}const g=0+e;if(A.defaultPrevented)return;const I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=new pC("pointerup",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:t,device:I,pressure:0});this.onUp(o)});r(this,"tempNearPlaneVector",new y);r(this,"tempFarPlaneVector",new y);r(this,"tempLookMatrix",new mA);this.context=A,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(A,e,t=0){this._eventListeners[A]||(this._eventListeners[A]=[]);const g=this._eventListeners[A],I=g.find(o=>o.priority===t);I?I.listeners.push(e):(g.push({priority:t,listeners:[e]}),g.sort((o,s)=>o.priority-s.priority))}removeEventListener(A,e,t){if(!this._eventListeners[A])return;const g=this._eventListeners[A];if(t!==void 0){const I=g.find(s=>s.priority===t);if(!I)return;const o=I.listeners.indexOf(e);o>=0&&I.listeners.splice(o,1)}else for(const I of g){const o=I.listeners.indexOf(e);o>=0&&I.listeners.splice(o,1)}}dispatchEvent(A){let e=!1;if(A instanceof gl){const t=this._eventListeners[A.type];if(t)for(const g of t)for(const I of g.listeners)I(A)}if(A instanceof pC){const t=this._eventListeners[A.type];if(t)for(const g of t){if(e)break;for(const I of g.listeners){if(A.immediatePropagationStopped){e=!0,Kg&&console.log("immediatePropagationStopped",A.type);break}else A.propagationStopped&&(e=!0,Kg&&console.log("propagationStopped",A.type));I(A)}}}}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(A,e=!0){if(A>=this._pointerUsed.length){if(A>=this._pointerIds.length)return;for(;this._pointerUsed.length<=A;)this._pointerUsed.push(!1)}this._pointerUsed[A]=e}getPointerUsed(A){return A>=this._pointerUsed.length?!1:this._pointerUsed[A]}getPointerPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&A++;return A}getPointerPosition(A){return A>=this._pointerPositions.length?null:this._pointerPositions[A]}getPointerPositionLastFrame(A){return A>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[A]}getPointerPositionDelta(A){return A>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[A]}getPointerPositionRC(A){return A>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[A]}getPointerDown(A){return A>=this._pointerDown.length?!1:this._pointerDown[A]}getPointerUp(A){return A>=this._pointerUp.length?!1:this._pointerUp[A]}getPointerPressed(A){return A>=this._pointerPressed.length?!1:this._pointerPressed[A]}getPointerClicked(A){return A>=this._pointerClick.length?!1:this._pointerClick[A]}getPointerDoubleClicked(A){return A>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[A]}getPointerDownTime(A){return A>=this._pointerDownTime.length?-1:this._pointerDownTime[A]}getPointerUpTime(A){return A>=this._pointerUpTime.length?-1:this._pointerUpTime[A]}getPointerLongPress(A){return A>=this._pointerDownTime.length?!1:this.getPointerPressed(A)&&this.context.time.time-this._pointerDownTime[A]>this._longPressTimeThreshold}getIsMouse(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="mouse"}getIsTouch(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="touch"}getTouchesPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&this.getIsTouch(e)&&A++;return A}getMouseWheelChanged(A=0){return A>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[A]}getMouseWheelDeltaY(A=0){return A>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[A]}getPointerEvent(A){if(!(A>=this._pointerEvent.length))return this._pointerEvent[A]??void 0}*foreachPointerId(A){for(let e=0;e<this._pointerTypes.length;e++)if(this._pointerIsActive(e)){if(A!==void 0){const t=this._pointerTypes[e];if(Array.isArray(A)){let g=!1;for(const I of A)if(t===I){g=!0;break}if(!g)continue}else if(A!==t)continue}yield e}}*foreachTouchId(){for(let A=0;A<this._pointerTypes.length;A++)this._pointerTypes[A]==="touch"&&this._pointerIsActive[A]&&(yield A)}_pointerIsActive(A){return A<0?!1:this._pointerPressed[A]||this._pointerDown[A]||this._pointerUp[A]}onDownButton(A,e){let t=this._pressedStack.get(A);t||(t=[],this._pressedStack.set(A,t)),t.push(e)}onReleaseButton(A,e){const t=this._pressedStack.get(A);if(!t)return;const g=t.indexOf(e);g>=0&&t.splice(g,1)}getFirstPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[0]}getLatestPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[e.length-1]}getKeyDown(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.startFrame===this.context.time.frameCount)return e.key}return null}getKeyPressed(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.pressed)return e.key}return null}isKeyDown(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyDown(g))return!0;return!1}return((t=this.keysPressed[A])==null?void 0:t.startFrame)===this.context.time.frameCount&&this.keysPressed[A].pressed}isKeyUp(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyUp(g))return!0;return!1}return((t=this.keysPressed[A])==null?void 0:t.frame)===this.context.time.frameCount&&!this.keysPressed[A].pressed}isKeyPressed(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyPressed(g))return!0;return!1}return(t=this.keysPressed[A])==null?void 0:t.pressed}getCodeForCommonKeyName(A){if(A.length===1){if(A>="0"&&A<="9")return["Digit"+A];if(A>="a"&&A<="z")return["Key"+A.toUpperCase()];if(A==" ")return["Space"]}switch(A){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(A){switch(A.type){case"pointerdown":Kg&&fi("Create Pointer down"),this.onDownButton(A.deviceIndex,A.button),this.onDown(A);break;case"pointermove":Kg&&fi("Create Pointer move"),this.onMove(A);break;case"pointerup":Kg&&fi("Create Pointer up"),this.onUp(A),this.onReleaseButton(A.deviceIndex,A.button);break}}convertScreenspaceToRaycastSpace(A){A.x=(A.x-this.context.domX)/this.context.domWidth*2-1,A.y=-((A.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 A,e,t;window.removeEventListener("contextmenu",this.onContextMenu),(A=this._htmlEventSource)==null||A.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),(e=this._htmlEventSource)==null||e.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),(t=this._htmlEventSource)==null||t.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 A=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);A>=0&&this.context.post_render_callbacks.splice(A,1),this.unbindEvents()}canReceiveInput(A){var e;return!!(A.target===((e=this.context.renderer)==null?void 0:e.domElement)||A.target===this.context.domElement||this.context.isInAR&&A.target===document.body&&bB())}createPointerEventFromTouch(A,e,t,g,I,o){const s=this.getPointerIndex(e);Kg&&fi(`touch up #${s}, identifier:${e}`);const n=this.getAndUpdateSpatialObjectForScreenPosition(s,t,g);return new pC(A,o,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:t,clientY:g,pointerType:"touch",buttonName:"unknown",device:n,pressure:I})}getAndUpdateSpatialObjectForScreenPosition(A,e,t){let g=this._pointerSpace[A];g||(g=new pA,this._pointerSpace[A]=g),this._pointerSpace[A]=g;const I=this.context.mainCamera;if(I){const o=this.tempNearPlaneVector.set(e,t,-1);this.convertScreenspaceToRaycastSpace(o);const s=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(I),s.unproject(I),this.tempLookMatrix.lookAt(s,o,I.worldUp),g.position.set(o.x,o.y,o.z),g.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return g}isNewEvent(A,e,t){for(;t.length<=e;)t.push(-1);return A===t[e]?!1:(t[e]=A,!0)}isInRect(A){if(this.context.isInXR)return!0;const e=this.context.domElement.getBoundingClientRect(),t=A.clientX,g=A.clientY,I=t>=e.x&&t<=e.right&&g>=e.y&&g<=e.bottom;return Kg&&!I&&console.log("Not in rect",e,t,g),I}onDown(A){const e=A.pointerId;if(this.getPointerPressed(e)&&console.warn(`pointerId is already pressed: ${e}`,Kg?A:""),Kg&&console.log(A.pointerType,"DOWN",e),!!this.isInRect(A)&&!this.isMouseEventFromTouch(A)){for(this.setPointerState(e,this._pointerPressed,!0),this.setPointerState(e,this._pointerDown,!0),this.setPointerStateT(e,this._pointerEvent,A.source);e>=this._pointerTypes.length;)this._pointerTypes.push(A.pointerType);for(this._pointerTypes[e]=A.pointerType;e>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new gA);for(this._pointerPositionDown[e].set(A.clientX,A.clientY);e>=this._pointerPositions.length;)this._pointerPositions.push(new gA);this._pointerPositions[e].set(A.clientX,A.clientY),e>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[e]=this.context.time.time,this.updatePointerPosition(A),this.onDispatchEvent(A)}}onMove(A){const e=A.pointerId,t=this.getPointerPressed(e);t===!1&&!this.isInRect(A)||A.pointerType==="touch"&&!t||this.isMouseEventFromTouch(A)||(Kg&&console.log(A.pointerType,"MOVE",e,"hasSpace="+A.space!=null),this.updatePointerPosition(A),this.setPointerStateT(e,this._pointerEvent,A.source),this.onDispatchEvent(A))}onUp(A){const e=A.pointerId;if(!this.getPointerPressed(e)){Kg&&console.log(A.pointerType,"UP",e,"was not down");return}if(this.isMouseEventFromTouch(A))return;for(Kg&&console.log(A.pointerType,"UP",e),this.setPointerState(e,this._pointerPressed,!1),this.setPointerStateT(e,this._pointerEvent,A.source),this.setPointerState(e,this._pointerUp,!0);e>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(e,this._pointerUsed,!1),this.updatePointerPosition(A),!this._pointerPositionDown[e]){Kg&&yi("Received pointer up event without matching down event for button: "+e),console.warn("Received pointer up event without matching down event for button: "+e);return}const g=A.clientX-this._pointerPositionDown[e].x,I=A.clientY-this._pointerPositionDown[e].y;if(e>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(g)<5&&Math.abs(I)<5){Kg&&console.log("CLICK",e),this.setPointerState(e,this._pointerClick,!0),A.isClick=!0;const o=this._pointerUpTime[e],s=this.context.time.time-o;s<this._doubleClickTimeThreshold&&s>0&&(this.setPointerState(e,this._pointerDoubleClick,!0),A.isDoubleClick=!0)}this._pointerUpTime[e]=this.context.time.time,this.onDispatchEvent(A)}isMouseEventFromTouch(A){var e;if(A.pointerType==="mouse"){const t=this._pointerUpTimestamp.map((g,I)=>({timestamp:g,index:I})).sort((g,I)=>g.timestamp-I.timestamp).at(-1);if(t&&this._pointerTypes[t.index]==="touch"&&t.timestamp>0&&((e=A.source)==null?void 0:e.timeStamp)!==void 0){const g=A.source.timeStamp-t.timestamp;if(g<320&&g>=0)return Kg&&console.log("Ignoring mouse.down for touch.up"),!0}}return!1}updatePointerPosition(A){const e=A.pointerId;for(;e>=this._pointerPositions.length;)this._pointerPositions.push(new gA);for(;e>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new gA);for(;e>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new gA);const t=this._pointerPositionsLastFrame[e];t.copy(this._pointerPositions[e]);const g=this._pointerPositionsDelta[e];let I=A.clientX-t.x,o=A.clientY-t.y;if(A.source instanceof MouseEvent||A.source instanceof TouchEvent){const a=A.source;I===0&&a.movementX!==0&&(I=a.movementX||0),o===0&&a.movementY!==0&&(o=a.movementY||0)}g.x+=I,g.y+=o,this._pointerPositions[e].x=A.clientX,this._pointerPositions[e].y=A.clientY;const s=A.clientX,n=A.clientY;for(;e>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new gA);const C=this._pointerPositionsRC[e];C.set(s,n),this.convertScreenspaceToRaycastSpace(C)}getPointerIndex(A){const e=this._pointerIds;let t=-1;for(let g=0;g<e.length;g++){if(e[g]===A)return g;t===-1&&e[g]===-1&&(t=g)}return t!==-1?(e[t]=A,t):(e.push(A),e.length-1)}setPointerState(A,e,t){e[A]=t}setPointerStateT(A,e,t){return e[A]=t,t}onDispatchEvent(A){const e=ve.Current;try{ve.Current=this.context,this.dispatchEvent(A)}finally{ve.Current=e}}}const by=new mA().makeRotationY(Math.PI),qs=new GA().setFromAxisAngle(new y(0,1,0),Math.PI),beA=IA("debugwebxr");class qeA{constructor(){r(this,"priority",-1e5);r(this,"gameObject");if(this.gameObject=new pA,this.gameObject.name="Implicit XR Rig",beA){const A=HN(16733661);A.position.y+=.5,this.gameObject.add(A)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const Ma=IA("debugwebxr"),Mh=IA("debugcustomgesture");let ok=!1;const LeA="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",xeA="generic-trigger";class ON{constructor(A,e,t){r(this,"xr");r(this,"inputSource");r(this,"index",0);r(this,"emitEvents",!0);r(this,"_connected",!0);r(this,"_isTracking",!1);r(this,"_hitTestSource");r(this,"_handJointPoses",new Map);r(this,"_gripPosition",new y);r(this,"_gripQuaternion",new GA);r(this,"_linearVelocity",new y);r(this,"_rayPosition",new y);r(this,"_rayQuaternion",new GA);r(this,"_gripWorldPosition",new y);r(this,"_gripWorldQuaternion",new GA);r(this,"_rayWorldPosition",new y);r(this,"_rayWorldQuaternion",new GA);r(this,"_ray");r(this,"_object");r(this,"_debugAxesHelper",new Es(.2));r(this,"_needleGamepadButtons",{});r(this,"_buttonMap",new Map);r(this,"_motioncontroller");r(this,"_layout");r(this,"getMotionController");r(this,"_selectButtonIndex");r(this,"_squeezeButtonIndex");r(this,"onSelectStart",A=>{var g,I,o,s;if(this.inputSource!==A.inputSource)return;const e=(g=this._layout)==null?void 0:g.selectComponentId,t=(s=(o=(I=this._layout)==null?void 0:I.components[e])==null?void 0:o.gamepadIndices)==null?void 0:s.button;if(t!==void 0&&(this._selectButtonIndex=t),!Mh){if(!ok){ok=!0;const n=this.getGesture("pinch");if(n!=null&&n.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}}Ma&&Re.DrawDirection(this.rayWorldPosition,Xi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(ni.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,A)}});r(this,"onSelectEnd",A=>{Mh||this.inputSource===A.inputSource&&this.emitPointerEvent(ni.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,A)});r(this,"onSequeezeStart",A=>{var e,t,g;this.inputSource===A.inputSource&&(this._squeezeButtonIndex=(g=(t=(e=this._layout)==null?void 0:e.components["xr-standard-squeeze"])==null?void 0:t.gamepadIndices)==null?void 0:g.button,this._squeezeButtonIndex!==void 0&&(Ma&&Re.DrawDirection(this.rayWorldPosition,Xi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(ni.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,A)))});r(this,"onSequeezeEnd",A=>{this.inputSource===A.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(ni.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,A)});r(this,"states",{});r(this,"_didMoveLastFrame",!1);r(this,"_lastPointerMovePosition",new y);r(this,"_lastPointerMoveQuaternion",new GA);r(this,"pointerInit");var g,I,o;this.xr=A,this.inputSource=e,this.index=t,this._object=new pA,Ma&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new qo,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=(I=(g=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:I.call(g,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(s=>this._hitTestSource=s))}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(A){var t,g;if(!this.hand||!((t=this.xr.frame)!=null&&t.getJointPose)||!this.xr.referenceSpace)return null;let e=(g=this._handJointPoses)==null?void 0:g.get(A);return e||(e=this.xr.frame.getJointPose(A,this.xr.referenceSpace),e&&this._handJointPoses.set(A,e),e)}get gripPosition(){return Xi(this._gripPosition).applyMatrix4(by)}get gripQuaternion(){return MB(this._gripQuaternion).premultiply(qs)}get gripLinearVelocity(){return Xi(this._linearVelocity).applyQuaternion(qs)}get rayPosition(){return Xi(this._rayPosition).applyMatrix4(by)}get rayQuaternion(){return MB(this._rayQuaternion).premultiply(qs)}get gripWorldPosition(){return Xi(this._gripWorldPosition)}get gripWorldQuaternion(){return MB(this._gripWorldQuaternion)}get rayWorldPosition(){return Xi(this._rayWorldPosition)}updateRayWorldPosition(){var e;const A=(e=this.xr.context.mainCamera)==null?void 0:e.parent;this._rayWorldPosition.copy(this._rayPosition),A&&this._rayWorldPosition.applyMatrix4(A.matrixWorld)}get rayWorldQuaternion(){return MB(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var t;const A=(t=this.xr.context.mainCamera)==null?void 0:t.parent,e=A?Lt(A):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(qs),e&&this._rayWorldQuaternion.premultiply(e)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(Xi(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var A;return(A=this.getMotionController)==null?void 0:A.then(e=>(e==null?void 0:e.assetUrl)||null)}onUpdate(A){this.onUpdateFrame(A),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var g;Re.DrawWireSphere(this.rayWorldPosition,.02),Re.DrawDirection(this.rayWorldPosition,Xi(0,0,10).applyQuaternion(this.rayWorldQuaternion));const A=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),e=this.inputSource.profiles.join(`
|
|
4919
|
+
*/var feA=function(i){return i!=null&&(cH(i)||DeA(i)||!!i._isBuffer)};function cH(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function DeA(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&cH(i.slice(0,0))}(function(){var i=peA,A=qb.utf8,e=feA,t=qb.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=t.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=i.bytesToWords(I),n=I.length*8,C=1732584193,a=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[n>>>5]|=128<<n%32,s[(n+64>>>9<<4)+14]=n;for(var c=g._ff,h=g._gg,u=g._hh,l=g._ii,E=0;E<s.length;E+=16){var d=C,p=a,f=B,S=Q;C=c(C,a,B,Q,s[E+0],7,-680876936),Q=c(Q,C,a,B,s[E+1],12,-389564586),B=c(B,Q,C,a,s[E+2],17,606105819),a=c(a,B,Q,C,s[E+3],22,-1044525330),C=c(C,a,B,Q,s[E+4],7,-176418897),Q=c(Q,C,a,B,s[E+5],12,1200080426),B=c(B,Q,C,a,s[E+6],17,-1473231341),a=c(a,B,Q,C,s[E+7],22,-45705983),C=c(C,a,B,Q,s[E+8],7,1770035416),Q=c(Q,C,a,B,s[E+9],12,-1958414417),B=c(B,Q,C,a,s[E+10],17,-42063),a=c(a,B,Q,C,s[E+11],22,-1990404162),C=c(C,a,B,Q,s[E+12],7,1804603682),Q=c(Q,C,a,B,s[E+13],12,-40341101),B=c(B,Q,C,a,s[E+14],17,-1502002290),a=c(a,B,Q,C,s[E+15],22,1236535329),C=h(C,a,B,Q,s[E+1],5,-165796510),Q=h(Q,C,a,B,s[E+6],9,-1069501632),B=h(B,Q,C,a,s[E+11],14,643717713),a=h(a,B,Q,C,s[E+0],20,-373897302),C=h(C,a,B,Q,s[E+5],5,-701558691),Q=h(Q,C,a,B,s[E+10],9,38016083),B=h(B,Q,C,a,s[E+15],14,-660478335),a=h(a,B,Q,C,s[E+4],20,-405537848),C=h(C,a,B,Q,s[E+9],5,568446438),Q=h(Q,C,a,B,s[E+14],9,-1019803690),B=h(B,Q,C,a,s[E+3],14,-187363961),a=h(a,B,Q,C,s[E+8],20,1163531501),C=h(C,a,B,Q,s[E+13],5,-1444681467),Q=h(Q,C,a,B,s[E+2],9,-51403784),B=h(B,Q,C,a,s[E+7],14,1735328473),a=h(a,B,Q,C,s[E+12],20,-1926607734),C=u(C,a,B,Q,s[E+5],4,-378558),Q=u(Q,C,a,B,s[E+8],11,-2022574463),B=u(B,Q,C,a,s[E+11],16,1839030562),a=u(a,B,Q,C,s[E+14],23,-35309556),C=u(C,a,B,Q,s[E+1],4,-1530992060),Q=u(Q,C,a,B,s[E+4],11,1272893353),B=u(B,Q,C,a,s[E+7],16,-155497632),a=u(a,B,Q,C,s[E+10],23,-1094730640),C=u(C,a,B,Q,s[E+13],4,681279174),Q=u(Q,C,a,B,s[E+0],11,-358537222),B=u(B,Q,C,a,s[E+3],16,-722521979),a=u(a,B,Q,C,s[E+6],23,76029189),C=u(C,a,B,Q,s[E+9],4,-640364487),Q=u(Q,C,a,B,s[E+12],11,-421815835),B=u(B,Q,C,a,s[E+15],16,530742520),a=u(a,B,Q,C,s[E+2],23,-995338651),C=l(C,a,B,Q,s[E+0],6,-198630844),Q=l(Q,C,a,B,s[E+7],10,1126891415),B=l(B,Q,C,a,s[E+14],15,-1416354905),a=l(a,B,Q,C,s[E+5],21,-57434055),C=l(C,a,B,Q,s[E+12],6,1700485571),Q=l(Q,C,a,B,s[E+3],10,-1894986606),B=l(B,Q,C,a,s[E+10],15,-1051523),a=l(a,B,Q,C,s[E+1],21,-2054922799),C=l(C,a,B,Q,s[E+8],6,1873313359),Q=l(Q,C,a,B,s[E+15],10,-30611744),B=l(B,Q,C,a,s[E+6],15,-1560198380),a=l(a,B,Q,C,s[E+13],21,1309151649),C=l(C,a,B,Q,s[E+4],6,-145523070),Q=l(Q,C,a,B,s[E+11],10,-1120210379),B=l(B,Q,C,a,s[E+2],15,718787259),a=l(a,B,Q,C,s[E+9],21,-343485551),C=C+d>>>0,a=a+p>>>0,B=B+f>>>0,Q=Q+S>>>0}return i.endian([C,a,B,Q])};g._ff=function(I,o,s,n,C,a,B){var Q=I+(o&s|~o&n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._gg=function(I,o,s,n,C,a,B){var Q=I+(o&n|s&~n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._hh=function(I,o,s,n,C,a,B){var Q=I+(o^s^n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._ii=function(I,o,s,n,C,a,B){var Q=I+(s^(o|~n))+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._blocksize=16,g._digestsize=16,QH.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=i.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?t.bytesToString(s):i.bytesToHex(s)}})();var yeA=QH.exports;const weA=mS(yeA);class vG{constructor(A,e,t,g){r(this,"success");r(this,"filename");r(this,"hash");r(this,"size");r(this,"url");this.success=A,this.filename=e,this.hash=t,this.size=g}}async function hH(i,A){const e=await i.arrayBuffer(),t=YN(e),g=i.name.split(".").pop(),I=t+"."+g,o=i.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",t),new vG(!0,I,t,i.size);console.log("begin uploading file",o,i.size);const a=new FormData;a.append("file",i);const B={};B.filesize=i.size,o&&(B.alias=o);const E=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:B})).json();if((E==null?void 0:E.success)===!1)return E.message!==void 0?console.error("Upload failed:",E.message):console.error("Upload failed"),null;console.assert(E.hash_sum===t,"hash sum did not match","received:",E.hash_sum,"expected:",t),E.success&&console.log("successfully uploaded",t,E.id);const c=new vG(E.success,I,t,i.size);return c.url=A,c}function YN(i){return weA(new Uint8Array(i))}async function _N(i,A,e,t,g=!1){try{const I=await fetch(t+"/download/file",{method:"POST",body:i});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const n=YN(s);return g||console.assert(n===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function lH(i,A){var a;const e=await fetch(i),t=(a=e.body)==null?void 0:a.getReader(),g=e.headers.get("Content-Length"),I=g?parseInt(g):0;if(!t)return null;let o=0;const s=[];for(;;){const{done:B,value:Q}=await t.read();if(Q&&(s.push(Q),o+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:o,total:I}))),B)break}const n=new Uint8Array(o);let C=0;for(const B of s)n.set(B,C),C+=B.length;return n}const ka=IA("debugaddressables");class dH{constructor(A){r(this,"_context");r(this,"_assetReferences",{});this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e==null||e.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const Ik=Symbol("assetReference"),bE=class{constructor(A,e,t=null){r(this,"_loading");r(this,"_asset");r(this,"_glbRoot");r(this,"_url");r(this,"_progressListeners",[]);r(this,"_hash");r(this,"_hashedUri");r(this,"_isLoadingRawBinary",!1);r(this,"_rawBinary");this._url=A,this._hash=e,A.includes("?v=")?this._hashedUri=A:this._hashedUri=e?A+"?v="+e:A,t!==null&&(this.asset=t),PO(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(A,e,t){if(typeof A=="string"){if(!t&&(t=ve.Current,!t))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 t=A.context,A=A.sourceId;const g=Ia(A,e);ka&&console.log("GetOrCreate Addressable from",A,e,"FinalPath=",g);const I=t.addressables,o=I.findAssetReference(g);if(o)return o;const s=new bE(g,t.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(A){this._asset=A}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(A){return A===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||AQ(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(ka&&console.log("Unload",this.asset),this.asset.scene&&Vs(this.asset.scene,!0,!0),Vs(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,ve.Current&&ve.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,ka&&console.log("Preload",this._hashedUri);const A=await lH(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=(A==null?void 0:A.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(A){if(ka&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(A&&this._progressListeners.push(A),this._loading!==void 0)return this._loading.then(g=>this.asset);const e=ve.Current;this._rawBinary?(this._loading=js().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(ka&&console.log("Load async",this.uri),this._loading=js().loadSync(e,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[Ik]=this,this._glbRoot&&(this._glbRoot[Ik]=this),this.asset&&(this.asset[Ik]=this),Fy(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(A){return this.onInstantiate(A,!1)}async instantiateSynced(A,e=!0){return this.onInstantiate(A,!0,e)}beginListenDownload(A){this._progressListeners.indexOf(A)<0&&this._progressListeners.push(A)}endListenDownload(A){const e=this._progressListeners.indexOf(A);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(A){for(const e of this._progressListeners)e(this,A)}async onInstantiate(A,e=!1,t){const g=ve.Current,I=new en;if(A instanceof pA?I.parent=A:A&&I.cloneAssign(A),I.parent||(I.parent=g.scene),this.mustLoad&&await this.loadAssetAsync(),ka&&console.log("Instantiate",this.uri,"parent:",A),this.asset){ka&&console.log("Add to scene",this.asset);let o=bE.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,bE.currentlyInstantiating.set(this.uri,o),e){I.context=g;const s=this.asset;s.guid=this.uri;const n=IF(s,I,void 0,t);if(n)return n}else{const s=qc(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,bE.currentlyInstantiating.set(this.uri,o)})}}else ka&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(A){if(A&&A.scene){const e=A.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let It=bE;r(It,"currentlyInstantiating",new Map);class SeA extends jn{constructor(){super([It],"AssetReferenceSerializer")}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?It.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof pA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const t=A,g=e.context,I=t.guid??t.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new It(I,void 0,t);return g.addressables.registerAssetReference(s),s}return null}}new SeA;const meA=Promise.resolve(null),Hl=class{constructor(A){r(this,"url");r(this,"_bitmap");r(this,"_bitmapObject");r(this,"loader",null);this.url=A}static getOrCreate(A){let e=Hl.imageReferences.get(A);return e||(e=new Hl(A),Hl.imageReferences.set(A,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const A=new Image;return A.src=this.url,A}createTexture(){return this.url?(this.loader||(this.loader=new bC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):meA}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((A,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(g=>(this._bitmapObject=g,A(g),g))}),t.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),A(null)}),t.src=this.url}),this._bitmap)}};let HE=Hl;r(HE,"imageReferences",new Map);class uH extends jn{constructor(){super([HE],"ImageReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=Ia(e.gltfId,A);return HE.getOrCreate(t)}}}new uH;const Ol=class{constructor(A){r(this,"url");r(this,"res");this.url=A}static getOrCreate(A){let e=Ol.cache.get(A);return e||(e=new Ol(A),Ol.cache.set(A,e)),e}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(A=>A.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(A=>A.text())}};let OE=Ol;r(OE,"cache",new Map);class pH extends jn{constructor(){super([OE],"FileReferenceSerializer")}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=Ia(e.gltfId,A);return OE.getOrCreate(t)}}}new pH;const Sg={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 fH(i){const A=await fetch(i);if(A.ok)return A.json();throw new Error(A.statusText)}async function keA(i){if(!i)throw new Error("No basePath supplied");return await fH(`${i}/profilesList.json`)}async function MeA(i,A,e=null,t=!0){if(!i)throw new Error("No xrInputSource supplied");if(!A)throw new Error("No basePath supplied");const g=await keA(A);let I;if(i.profiles.some(n=>{const C=g[n];return C&&(I={profileId:n,profilePath:`${A}/${C.path}`,deprecated:!!C.deprecated}),!!I}),!I){if(!e)throw new Error("No matching profile name found");const n=g[e];if(!n)throw new Error(`No matching profile name found and default profile "${e}" missing.`);I={profileId:e,profilePath:`${A}/${n.path}`,deprecated:!!n.deprecated}}const o=await fH(I.profilePath);let s;if(t){let n;if(i.handedness==="any"?n=o.layouts[Object.keys(o.layouts)[0]]:n=o.layouts[i.handedness],!n)throw new Error(`No matching handedness, ${i.handedness}, in profile ${I.profileId}`);n.assetPath&&(s=I.profilePath.replace("profile.json",n.assetPath))}return{profile:o,assetPath:s}}const GeA={xAxis:0,yAxis:0,button:0,state:Sg.ComponentState.DEFAULT};function ReA(i=0,A=0){let e=i,t=A;if(Math.sqrt(i*i+A*A)>1){const o=Math.atan2(A,i);e=Math.cos(o),t=Math.sin(o)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:t*.5+.5}}let UeA=class{constructor(A){this.componentProperty=A.componentProperty,this.states=A.states,this.valueNodeName=A.valueNodeName,this.valueNodeProperty=A.valueNodeProperty,this.valueNodeProperty===Sg.VisualResponseProperty.TRANSFORM&&(this.minNodeName=A.minNodeName,this.maxNodeName=A.maxNodeName),this.value=0,this.updateFromComponent(GeA)}updateFromComponent({xAxis:A,yAxis:e,button:t,state:g}){const{normalizedXAxis:I,normalizedYAxis:o}=ReA(A,e);switch(this.componentProperty){case Sg.ComponentProperty.X_AXIS:this.value=this.states.includes(g)?I:.5;break;case Sg.ComponentProperty.Y_AXIS:this.value=this.states.includes(g)?o:.5;break;case Sg.ComponentProperty.BUTTON:this.value=this.states.includes(g)?t:0;break;case Sg.ComponentProperty.STATE:this.valueNodeProperty===Sg.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(g):this.value=this.states.includes(g)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},NeA=class{constructor(A,e){if(!A||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=A,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(t=>{const g=new UeA(e.visualResponses[t]);this.visualResponses[t]=g}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:Sg.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(A){if(this.values.state=Sg.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&A.buttons.length>this.gamepadIndices.button){const e=A.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=Sg.ComponentState.PRESSED:(e.touched||this.values.button>Sg.ButtonTouchThreshold)&&(this.values.state=Sg.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&A.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=A.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===Sg.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Sg.AxisTouchThreshold&&(this.values.state=Sg.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&A.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=A.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===Sg.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Sg.AxisTouchThreshold&&(this.values.state=Sg.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},FeA=class{constructor(A,e,t){if(!A)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=A,this.assetUrl=t,this.id=e.profileId,this.layoutDescription=e.layouts[A.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(g=>{const I=this.layoutDescription.components[g];this.components[g]=new NeA(g,I)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const A=[];return Object.values(this.components).forEach(e=>{A.push(e.data)}),A}updateFromGamepad(){Object.values(this.components).forEach(A=>{A.updateFromGamepad(this.xrInputSource.gamepad)})}};class Jt extends wA{constructor(e,t,g,I){super(e,t,g);r(this,"alpha",1);this.alpha=I}get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return super.copy(e),"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const g=e;return g.alpha&&(this.alpha=se.lerp(this.alpha,g.alpha,t)),super.lerp(e,t)}lerpColors(e,t,g){const I=e,o=t;return I.alpha&&o.alpha&&(this.alpha=se.lerp(I.alpha,o.alpha,g)),super.lerpColors(e,t,g)}multiply(e){const t=e;return t.alpha&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}}const kI=new y,Lb=new y,xb=new GA,KeA=IA("debuggizmos"),CC=8947848,Js=class{static isGizmo(A){return A[bG]!==void 0}static DrawLabel(A,e,t=.05,g=0,I,o,s){var a;if(!Js.enabled)return null;I||(I=CC);const n=((a=ue.active)==null?void 0:a.rigScale)??1,C=Zi.getTextLabel(g,e,t*n,I,o);return s instanceof pA&&s.add(C),C.position.x=A.x,C.position.y=A.y,C.position.z=A.z,C}static DrawRay(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),kI.set(e.x,e.y,e.z).multiplyScalar(999999999),s.setXYZ(1,A.x+kI.x,A.y+kI.y,A.z+kI.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawDirection(A,e,t=CC,g=0,I=!0,o=1){if(!Js.enabled)return;const s=Zi.getLine(g),n=s.geometry.getAttribute("position");n.setXYZ(0,A.x,A.y,A.z),e.w!==void 0?(kI.set(0,0,-o),xb.set(e.x,e.y,e.z,e.w),kI.applyQuaternion(xb)):(kI.set(e.x,e.y,e.z),kI.multiplyScalar(o)),n.setXYZ(1,A.x+kI.x,A.y+kI.y,A.z+kI.z),n.needsUpdate=!0,s.material.color.set(t),s.material.depthTest=I,s.material.depthWrite=!1}static DrawLine(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getLine(g),s=o.geometry.getAttribute("position");s.setXYZ(0,A.x,A.y,A.z),s.setXYZ(1,e.x,e.y,e.z),s.needsUpdate=!0,o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireSphere(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getSphere(e,g,!0);XB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawSphere(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getSphere(e,g,!1);XB(o,A.x,A.y,A.z),o.material.color.set(t),o.material.depthTest=I,o.material.depthWrite=!1}static DrawWireBox(A,e,t=CC,g=0,I=!0){if(!Js.enabled)return;const o=Zi.getBox(g);o.position.set(A.x,A.y,A.z),o.scale.set(e.x,e.y,e.z),o.material.color.set(t),o.material.depthTest=I,o.material.wireframe=!0,o.material.depthWrite=!1}static DrawWireBox3(A,e=CC,t=0,g=!0){if(!Js.enabled)return;const I=Zi.getBox(t);I.position.copy(A.getCenter(kI)),I.scale.copy(A.getSize(kI)),I.material.color.set(e),I.material.depthTest=g,I.material.wireframe=!0,I.material.depthWrite=!1}static DrawArrow(A,e,t=CC,g=0,I=!0,o=!1){if(!Js.enabled)return;const s=Zi.getArrowHead(g);s.position.set(e.x,e.y,e.z),s.quaternion.setFromUnitVectors(this._up.set(0,1,0),kI.set(e.x,e.y,e.z).sub(Lb.set(A.x,A.y,A.z)).normalize());const C=kI.set(e.x,e.y,e.z).sub(Lb.set(A.x,A.y,A.z)).length()*.1;s.scale.set(C,C,C),s.material.color.set(t),s.material.depthTest=I,s.material.wireframe=o,this.DrawLine(A,e,t,g,I)}};let Re=Js;r(Re,"enabled",!0),r(Re,"_up",new y(0,1,0));const JeA=new Zt(1,1,1);function HN(i=null){const A=new wA(i??14540253),e=new SU(JeA);return new Lo(e,new Pi({color:A}))}const bG=Symbol("GizmoCache");class Zi{static ensureFont(){let A=Io.FontLibrary.getFontFamily(this.familyName);if(!A){A=Io.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{Io.update()})}}static getTextLabel(A,e,t,g,I){this.ensureFont();let o=this.textLabelCache.pop(),s=1;I&&typeof I=="string"&&(I==null?void 0:I.length)>=8&&I.startsWith("#")?(s=parseInt(I.substring(7),16)/255,I=I.substring(0,7),KeA&&console.log(I,s)):typeof I=="object"&&I.a!==void 0&&(s=I.a);const n={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:t,color:g,lineHeight:1,backgroundColor:I??void 0,backgroundOpacity:s,textContent:e,borderRadius:.5*t,padding:.8*t,whiteSpace:"pre"};if(o)o.set(n);else{o=new DN(n);const C=this,a=o;a.setText=function(B){this.set({textContent:B}),C.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(ve.Current,o,A,this.textLabelCache),o}static getBox(A){let e=this.boxesCache.pop();if(!e){const t=new Zt(1,1,1);e=new uA(t)}return this.registerTimedObject(ve.Current,e,A,this.boxesCache),e}static getLine(A){let e=this.linesCache.pop();if(!e){e=new _i;let t=e.geometry.getAttribute("position");t||(t=new ie(new Float32Array(2*3),3),e.geometry.setAttribute("position",t))}return e.frustumCulled=!1,this.registerTimedObject(ve.Current,e,A,this.linesCache),e}static getSphere(A,e,t){let g=this.spheresCache.pop();return g||(g=new uA(new Xs(1,8,8))),g.scale.set(A,A,A),g.material.wireframe=t,this.registerTimedObject(ve.Current,g,e,this.spheresCache),g}static getArrowHead(A){let e=this.arrowHeadsCache.pop();return e||(e=new uA(new Ti(0,.5,1,8))),this.registerTimedObject(ve.Current,e,A,this.arrowHeadsCache),e}static registerTimedObject(A,e,t,g){const I=this.contextBeforeRenderCallbacks.get(A),o=this.contextPostRenderCallbacks.get(A);if(I){if(A.pre_render_callbacks[A.pre_render_callbacks.length-1]!==I){const s=A.pre_render_callbacks.indexOf(I);s>=0&&A.pre_render_callbacks.splice(s,1),A.pre_render_callbacks.push(I)}}else{const s=()=>{this.onBeforeRender(A,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(A,s),A.pre_render_callbacks.push(s)}if(o){if(A.post_render_callbacks[A.post_render_callbacks.length-1]!==o){const s=A.post_render_callbacks.indexOf(o);s>=0&&A.post_render_callbacks.splice(s,1),A.post_render_callbacks.push(o)}}else{const s=()=>{this.onPostRender(A,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(A,s),A.post_render_callbacks.push(s)}e.traverse(s=>{s.layers.disableAll(),s.layers.enable(2)}),e.renderOrder=999999,e[bG]=g,this.timedObjectsBuffer.push(e),this.timesBuffer.push(ve.Current.time.realtimeSinceStartup+t),A.scene.add(e)}static onBeforeRender(A,e){this.tmuiNeedsUpdate&&Io.update();for(let t=0;t<e.length;t++){const g=e[t];if(A.mainCamera&&g instanceof Io.MeshUIBaseElement){if(AQ(g))continue;const I=A.isInVR,o=!1,s=!I;uS(g,A.mainCamera,o,s)}}}static onPostRender(A,e,t){const g=A.time.realtimeSinceStartup;for(let I=e.length-1;I>=0;I--){const o=e[I];g>t[I]&&(e.splice(I,1),t.splice(I,1),o.removeFromParent(),AQ(o)!=!0&&o[bG].push(o))}}}r(Zi,"familyName","needle-gizmos"),r(Zi,"linesCache",[]),r(Zi,"spheresCache",[]),r(Zi,"boxesCache",[]),r(Zi,"arrowHeadsCache",[]),r(Zi,"textLabelCache",[]),r(Zi,"timedObjectsBuffer",new Array),r(Zi,"timesBuffer",new Array),r(Zi,"contextPostRenderCallbacks",new Map),r(Zi,"contextBeforeRenderCallbacks",new Map),r(Zi,"tmuiNeedsUpdate",!1);const Kg=IA("debuginput");var kS=(i=>(i.Mouse="mouse",i.Touch="touch",i.Controller="controller",i.Hand="hand",i))(kS||{}),ni=(i=>(i.PointerDown="pointerdown",i.PointerUp="pointerup",i.PointerMove="pointermove",i.KeyDown="keydown",i.KeyUp="keyup",i.KeyPressed="keypress",i))(ni||{});class pC extends PointerEvent{constructor(e,t,g){super(e,g);r(this,"deviceIndex");r(this,"origin");r(this,"source");r(this,"mode");r(this,"ray");r(this,"space");r(this,"isClick",!1);r(this,"isDoubleClick",!1);r(this,"_used",!1);r(this,"_pointerid");r(this,"_pointerType");r(this,"_type");r(this,"_immediatePropagationStopped",!1);r(this,"_propagationStopped",!1);this._pointerid=g.pointerId,this._pointerType=g.pointerType,this._type=e,this.deviceIndex=g.deviceIndex,this.origin=g.origin,this.source=t,this.mode=g.mode,this.ray=g.ray,this.space=g.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 e;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}stopPropagation(){var e;this._propagationStopped=!0,super.stopPropagation(),(e=this.source)==null||e.stopPropagation()}}class gl extends KeyboardEvent{constructor(e,t,g){super(e,g);r(this,"source");this.source=t}stopImmediatePropagation(){var e;super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}}class veA{constructor(A){r(this,"key");r(this,"keyType");r(this,"source");this.key=A.key,this.keyType=A.type,this.source=A}}var un=(i=>(i[i.Early=-100]="Early",i[i.Default=0]="Default",i[i.Late=100]="Late",i))(un||{});class DH{constructor(A){r(this,"_eventListeners",{});r(this,"_doubleClickTimeThreshold",.2);r(this,"_longPressTimeThreshold",1);r(this,"_specialCursorTrigger",0);r(this,"context");r(this,"_pointerDown",[!1]);r(this,"_pointerUp",[!1]);r(this,"_pointerClick",[!1]);r(this,"_pointerDoubleClick",[!1]);r(this,"_pointerPressed",[!1]);r(this,"_pointerPositions",[new gA]);r(this,"_pointerPositionsLastFrame",[new gA]);r(this,"_pointerPositionsDelta",[new gA]);r(this,"_pointerPositionsRC",[new gA]);r(this,"_pointerPositionDown",[new gA]);r(this,"_pointerDownTime",[]);r(this,"_pointerUpTime",[]);r(this,"_pointerUpTimestamp",[]);r(this,"_pointerIds",[]);r(this,"_pointerTypes",[""]);r(this,"_mouseWheelChanged",[!1]);r(this,"_mouseWheelDeltaY",[0]);r(this,"_pointerEvent",[]);r(this,"_pointerUsed",[]);r(this,"_pointerSpace",[]);r(this,"_pressedStack",new Map);r(this,"_htmlEventSource");r(this,"onLostFocus",()=>{for(const A in this.keysPressed)this.keysPressed[A].pressed=!1});r(this,"onEndOfFrame",()=>{for(let A=0;A<this._pointerUp.length;A++)this._pointerUp[A]=!1;for(let A=0;A<this._pointerDown.length;A++)this._pointerDown[A]=!1;for(let A=0;A<this._pointerClick.length;A++)this._pointerClick[A]=!1;for(let A=0;A<this._pointerDoubleClick.length;A++)this._pointerDoubleClick[A]=!1;for(const A of this._pointerPositionsDelta)A.set(0,0);for(let A=0;A<this._mouseWheelChanged.length;A++)this._mouseWheelChanged[A]=!1;for(let A=0;A<this._mouseWheelDeltaY.length;A++)this._mouseWheelDeltaY[A]=0});r(this,"onContextMenu",A=>{this.canReceiveInput(A)!==!1&&A instanceof PointerEvent&&A.pointerType});r(this,"keysPressed",{});r(this,"onKeyDown",A=>{if(Kg&&console.log(`key down ${A.code}, ${this.context.application.hasFocus}`,A),!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(e&&e.pressed)return;this.keysPressed[A.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:A.key,code:A.code};const t=new gl("keydown",A,A);this.onDispatchEvent(t)});r(this,"onKeyPressed",A=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(!e)return;e.pressed=!0,e.frame=this.context.time.frameCount+1;const t=new gl("keypress",A,A);this.onDispatchEvent(t)});r(this,"onKeyUp",A=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[A.code];if(!e)return;e.pressed=!1,e.frame=this.context.time.frameCount+1;const t=new gl("keyup",A,A);this.onDispatchEvent(t)});r(this,"onMouseWheel",A=>{if(this.canReceiveInput(A)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const e=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=e+A.deltaY});r(this,"onTouchStartWindow",A=>{this.context.isInAR&&this.onTouchStart(A)});r(this,"onTouchStart",A=>{if(!(A.changedTouches.length<=0)&&this.canReceiveInput(A)!==!1)for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier);Kg&&fi(`touch start #${g}, identifier:${t.identifier}`);const I=this.getAndUpdateSpatialObjectForScreenPosition(g,t.clientX,t.clientY),o=new pC("pointerdown",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:0,clientX:t.clientX,clientY:t.clientY,pointerType:"touch",buttonName:"unknown",device:I,pressure:t.force});this.onDown(o)}});r(this,"onTouchMove",A=>{if(!(A.changedTouches.length<=0))for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier),I=this.getAndUpdateSpatialObjectForScreenPosition(g,t.clientX,t.clientY),o=new pC("pointermove",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:0,clientX:t.clientX,clientY:t.clientY,pointerType:"touch",buttonName:"unknown",device:I,pressure:t.force});this.onMove(o)}});r(this,"onTouchUp",A=>{if(!(A.changedTouches.length<=0))for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e],g=this.getPointerIndex(t.identifier);if(!this.isNewEvent(A.timeStamp,g,this._pointerUpTimestamp))continue;const I=this.createPointerEventFromTouch("pointerup",t.identifier,t.clientX,t.clientY,t.force,A);this.onUp(I),this._pointerIds.splice(this._pointerIds.indexOf(g),1)}});r(this,"onTouchCancel",A=>{});r(this,"onMouseDown",A=>{if(this.onDownButton(0,A.button),this.context.isInVR||A.defaultPrevented||this.canReceiveInput(A)===!1)return;const e=A.button;let t="none";switch(e){case 0:t="left";break;case 1:t="middle";break;case 2:t="right";break}const g=0+e,I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=new pC("pointerdown",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:t,device:I,pressure:1});this.onDown(o)});r(this,"onMouseMove",A=>{if(this.context.isInVR||A.defaultPrevented)return;const e=this.getFirstPressedButtonForPointer(0),t=e??0,g=0+t,I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=e!==void 0?1:0,s=new pC("pointermove",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:t,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:"none",device:I,pressure:o});this.onMove(s)});r(this,"onMouseUp",A=>{if(this.onReleaseButton(0,A.button),this.context.isInVR)return;const e=A.button;if(!this.isNewEvent(A.timeStamp,e,this._pointerUpTimestamp))return;let t="none";switch(e){case 0:t="left";break;case 1:t="middle";break;case 2:t="right";break}const g=0+e;if(A.defaultPrevented)return;const I=this.getAndUpdateSpatialObjectForScreenPosition(g,A.clientX,A.clientY),o=new pC("pointerup",A,{origin:this,mode:"screen",deviceIndex:0,pointerId:g,button:e,clientX:A.clientX,clientY:A.clientY,pointerType:"mouse",buttonName:t,device:I,pressure:0});this.onUp(o)});r(this,"tempNearPlaneVector",new y);r(this,"tempFarPlaneVector",new y);r(this,"tempLookMatrix",new mA);this.context=A,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(A,e,t){this._eventListeners[A]||(this._eventListeners[A]=[]);let g=0;(t==null?void 0:t.queue)!=null&&(g=t.queue);const I=this._eventListeners[A],o=I.find(s=>s.priority===g);o?o.listeners.push(e):(I.push({priority:g,listeners:[e]}),I.sort((s,n)=>s.priority-n.priority))}removeEventListener(A,e,t){if(!this._eventListeners[A])return;const g=this._eventListeners[A];if((t==null?void 0:t.queue)!=null){const I=g.find(s=>s.priority===t.queue);if(!I)return;const o=I.listeners.indexOf(e);o>=0&&I.listeners.splice(o,1)}else for(const I of g){const o=I.listeners.indexOf(e);o>=0&&I.listeners.splice(o,1)}}dispatchEvent(A){let e=!1;if(A instanceof gl){const t=this._eventListeners[A.type];if(t)for(const g of t)for(const I of g.listeners)I(A)}if(A instanceof pC){const t=this._eventListeners[A.type];if(t)for(const g of t){if(e)break;for(const I of g.listeners){if(A.immediatePropagationStopped){e=!0,Kg&&console.log("immediatePropagationStopped",A.type);break}else A.propagationStopped&&(e=!0,Kg&&console.log("propagationStopped",A.type));I(A)}}}}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(A,e=!0){if(A>=this._pointerUsed.length){if(A>=this._pointerIds.length)return;for(;this._pointerUsed.length<=A;)this._pointerUsed.push(!1)}this._pointerUsed[A]=e}getPointerUsed(A){return A>=this._pointerUsed.length?!1:this._pointerUsed[A]}getPointerPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&A++;return A}getPointerPosition(A){return A>=this._pointerPositions.length?null:this._pointerPositions[A]}getPointerPositionLastFrame(A){return A>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[A]}getPointerPositionDelta(A){return A>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[A]}getPointerPositionRC(A){return A>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[A]}getPointerDown(A){return A>=this._pointerDown.length?!1:this._pointerDown[A]}getPointerUp(A){return A>=this._pointerUp.length?!1:this._pointerUp[A]}getPointerPressed(A){return A>=this._pointerPressed.length?!1:this._pointerPressed[A]}getPointerClicked(A){return A>=this._pointerClick.length?!1:this._pointerClick[A]}getPointerDoubleClicked(A){return A>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[A]}getPointerDownTime(A){return A>=this._pointerDownTime.length?-1:this._pointerDownTime[A]}getPointerUpTime(A){return A>=this._pointerUpTime.length?-1:this._pointerUpTime[A]}getPointerLongPress(A){return A>=this._pointerDownTime.length?!1:this.getPointerPressed(A)&&this.context.time.time-this._pointerDownTime[A]>this._longPressTimeThreshold}getIsMouse(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="mouse"}getIsTouch(A){return A<0||A>=this._pointerTypes.length?!1:this._pointerTypes[A]==="touch"}getTouchesPressedCount(){let A=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&this.getIsTouch(e)&&A++;return A}getMouseWheelChanged(A=0){return A>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[A]}getMouseWheelDeltaY(A=0){return A>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[A]}getPointerEvent(A){if(!(A>=this._pointerEvent.length))return this._pointerEvent[A]??void 0}*foreachPointerId(A){for(let e=0;e<this._pointerTypes.length;e++)if(this._pointerIsActive(e)){if(A!==void 0){const t=this._pointerTypes[e];if(Array.isArray(A)){let g=!1;for(const I of A)if(t===I){g=!0;break}if(!g)continue}else if(A!==t)continue}yield e}}*foreachTouchId(){for(let A=0;A<this._pointerTypes.length;A++)this._pointerTypes[A]==="touch"&&this._pointerIsActive[A]&&(yield A)}_pointerIsActive(A){return A<0?!1:this._pointerPressed[A]||this._pointerDown[A]||this._pointerUp[A]}onDownButton(A,e){let t=this._pressedStack.get(A);t||(t=[],this._pressedStack.set(A,t)),t.push(e)}onReleaseButton(A,e){const t=this._pressedStack.get(A);if(!t)return;const g=t.indexOf(e);g>=0&&t.splice(g,1)}getFirstPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[0]}getLatestPressedButtonForPointer(A){const e=this._pressedStack.get(A);if(e)return e[e.length-1]}getKeyDown(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.startFrame===this.context.time.frameCount)return e.key}return null}getKeyPressed(){for(const A in this.keysPressed){const e=this.keysPressed[A];if(e.pressed)return e.key}return null}isKeyDown(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyDown(g))return!0;return!1}return((t=this.keysPressed[A])==null?void 0:t.startFrame)===this.context.time.frameCount&&this.keysPressed[A].pressed}isKeyUp(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyUp(g))return!0;return!1}return((t=this.keysPressed[A])==null?void 0:t.frame)===this.context.time.frameCount&&!this.keysPressed[A].pressed}isKeyPressed(A){var t;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(A);if(e!==null){for(const g of e)if(this.isKeyPressed(g))return!0;return!1}return(t=this.keysPressed[A])==null?void 0:t.pressed}getCodeForCommonKeyName(A){if(A.length===1){if(A>="0"&&A<="9")return["Digit"+A];if(A>="a"&&A<="z")return["Key"+A.toUpperCase()];if(A==" ")return["Space"]}switch(A){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(A){switch(A.type){case"pointerdown":Kg&&fi("Create Pointer down"),this.onDownButton(A.deviceIndex,A.button),this.onDown(A);break;case"pointermove":Kg&&fi("Create Pointer move"),this.onMove(A);break;case"pointerup":Kg&&fi("Create Pointer up"),this.onUp(A),this.onReleaseButton(A.deviceIndex,A.button);break}}convertScreenspaceToRaycastSpace(A){A.x=(A.x-this.context.domX)/this.context.domWidth*2-1,A.y=-((A.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 A,e,t;window.removeEventListener("contextmenu",this.onContextMenu),(A=this._htmlEventSource)==null||A.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),(e=this._htmlEventSource)==null||e.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),(t=this._htmlEventSource)==null||t.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 A=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);A>=0&&this.context.post_render_callbacks.splice(A,1),this.unbindEvents()}canReceiveInput(A){var e;return!!(A.target===((e=this.context.renderer)==null?void 0:e.domElement)||A.target===this.context.domElement||this.context.isInAR&&A.target===document.body&&bB())}createPointerEventFromTouch(A,e,t,g,I,o){const s=this.getPointerIndex(e);Kg&&fi(`touch up #${s}, identifier:${e}`);const n=this.getAndUpdateSpatialObjectForScreenPosition(s,t,g);return new pC(A,o,{origin:this,mode:"screen",deviceIndex:0,pointerId:s,button:0,clientX:t,clientY:g,pointerType:"touch",buttonName:"unknown",device:n,pressure:I})}getAndUpdateSpatialObjectForScreenPosition(A,e,t){let g=this._pointerSpace[A];g||(g=new pA,this._pointerSpace[A]=g),this._pointerSpace[A]=g;const I=this.context.mainCamera;if(I){const o=this.tempNearPlaneVector.set(e,t,-1);this.convertScreenspaceToRaycastSpace(o);const s=this.tempFarPlaneVector.set(o.x,o.y,1);o.unproject(I),s.unproject(I),this.tempLookMatrix.lookAt(s,o,I.worldUp),g.position.set(o.x,o.y,o.z),g.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return g}isNewEvent(A,e,t){for(;t.length<=e;)t.push(-1);return A===t[e]?!1:(t[e]=A,!0)}isInRect(A){if(this.context.isInXR)return!0;const e=this.context.domElement.getBoundingClientRect(),t=A.clientX,g=A.clientY,I=t>=e.x&&t<=e.right&&g>=e.y&&g<=e.bottom;return Kg&&!I&&console.log("Not in rect",e,t,g),I}onDown(A){const e=A.pointerId;if(this.getPointerPressed(e)&&console.warn(`pointerId is already pressed: ${e}`,Kg?A:""),Kg&&console.log(A.pointerType,"DOWN",e),!!this.isInRect(A)&&!this.isMouseEventFromTouch(A)){for(this.setPointerState(e,this._pointerPressed,!0),this.setPointerState(e,this._pointerDown,!0),this.setPointerStateT(e,this._pointerEvent,A.source);e>=this._pointerTypes.length;)this._pointerTypes.push(A.pointerType);for(this._pointerTypes[e]=A.pointerType;e>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new gA);for(this._pointerPositionDown[e].set(A.clientX,A.clientY);e>=this._pointerPositions.length;)this._pointerPositions.push(new gA);this._pointerPositions[e].set(A.clientX,A.clientY),e>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[e]=this.context.time.time,this.updatePointerPosition(A),this.onDispatchEvent(A)}}onMove(A){const e=A.pointerId,t=this.getPointerPressed(e);t===!1&&!this.isInRect(A)||A.pointerType==="touch"&&!t||this.isMouseEventFromTouch(A)||(Kg&&console.log(A.pointerType,"MOVE",e,"hasSpace="+A.space!=null),this.updatePointerPosition(A),this.setPointerStateT(e,this._pointerEvent,A.source),this.onDispatchEvent(A))}onUp(A){const e=A.pointerId;if(!this.getPointerPressed(e)){Kg&&console.log(A.pointerType,"UP",e,"was not down");return}if(this.isMouseEventFromTouch(A))return;for(Kg&&console.log(A.pointerType,"UP",e),this.setPointerState(e,this._pointerPressed,!1),this.setPointerStateT(e,this._pointerEvent,A.source),this.setPointerState(e,this._pointerUp,!0);e>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(e,this._pointerUsed,!1),this.updatePointerPosition(A),!this._pointerPositionDown[e]){Kg&&yi("Received pointer up event without matching down event for button: "+e),console.warn("Received pointer up event without matching down event for button: "+e);return}const g=A.clientX-this._pointerPositionDown[e].x,I=A.clientY-this._pointerPositionDown[e].y;if(e>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(g)<5&&Math.abs(I)<5){Kg&&console.log("CLICK",e),this.setPointerState(e,this._pointerClick,!0),A.isClick=!0;const o=this._pointerUpTime[e],s=this.context.time.time-o;s<this._doubleClickTimeThreshold&&s>0&&(this.setPointerState(e,this._pointerDoubleClick,!0),A.isDoubleClick=!0)}this._pointerUpTime[e]=this.context.time.time,this.onDispatchEvent(A)}isMouseEventFromTouch(A){var e;if(A.pointerType==="mouse"){const t=this._pointerUpTimestamp.map((g,I)=>({timestamp:g,index:I})).sort((g,I)=>g.timestamp-I.timestamp).at(-1);if(t&&this._pointerTypes[t.index]==="touch"&&t.timestamp>0&&((e=A.source)==null?void 0:e.timeStamp)!==void 0){const g=A.source.timeStamp-t.timestamp;if(g<320&&g>=0)return Kg&&console.log("Ignoring mouse.down for touch.up"),!0}}return!1}updatePointerPosition(A){const e=A.pointerId;for(;e>=this._pointerPositions.length;)this._pointerPositions.push(new gA);for(;e>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new gA);for(;e>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new gA);const t=this._pointerPositionsLastFrame[e];t.copy(this._pointerPositions[e]);const g=this._pointerPositionsDelta[e];let I=A.clientX-t.x,o=A.clientY-t.y;if(A.source instanceof MouseEvent||A.source instanceof TouchEvent){const a=A.source;I===0&&a.movementX!==0&&(I=a.movementX||0),o===0&&a.movementY!==0&&(o=a.movementY||0)}g.x+=I,g.y+=o,this._pointerPositions[e].x=A.clientX,this._pointerPositions[e].y=A.clientY;const s=A.clientX,n=A.clientY;for(;e>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new gA);const C=this._pointerPositionsRC[e];C.set(s,n),this.convertScreenspaceToRaycastSpace(C)}getPointerIndex(A){const e=this._pointerIds;let t=-1;for(let g=0;g<e.length;g++){if(e[g]===A)return g;t===-1&&e[g]===-1&&(t=g)}return t!==-1?(e[t]=A,t):(e.push(A),e.length-1)}setPointerState(A,e,t){e[A]=t}setPointerStateT(A,e,t){return e[A]=t,t}onDispatchEvent(A){const e=ve.Current;try{ve.Current=this.context,this.dispatchEvent(A)}finally{ve.Current=e}}}const by=new mA().makeRotationY(Math.PI),qs=new GA().setFromAxisAngle(new y(0,1,0),Math.PI),beA=IA("debugwebxr");class qeA{constructor(){r(this,"priority",-1e5);r(this,"gameObject");if(this.gameObject=new pA,this.gameObject.name="Implicit XR Rig",beA){const A=HN(16733661);A.position.y+=.5,this.gameObject.add(A)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const Ma=IA("debugwebxr"),Mh=IA("debugcustomgesture");let ok=!1;const LeA="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",xeA="generic-trigger";class ON{constructor(A,e,t){r(this,"xr");r(this,"inputSource");r(this,"index",0);r(this,"emitEvents",!0);r(this,"_connected",!0);r(this,"_isTracking",!1);r(this,"_hitTestSource");r(this,"_handJointPoses",new Map);r(this,"_gripPosition",new y);r(this,"_gripQuaternion",new GA);r(this,"_linearVelocity",new y);r(this,"_rayPosition",new y);r(this,"_rayQuaternion",new GA);r(this,"_gripWorldPosition",new y);r(this,"_gripWorldQuaternion",new GA);r(this,"_rayWorldPosition",new y);r(this,"_rayWorldQuaternion",new GA);r(this,"_ray");r(this,"_object");r(this,"_debugAxesHelper",new Es(.2));r(this,"_needleGamepadButtons",{});r(this,"_buttonMap",new Map);r(this,"_motioncontroller");r(this,"_layout");r(this,"getMotionController");r(this,"_selectButtonIndex");r(this,"_squeezeButtonIndex");r(this,"onSelectStart",A=>{var g,I,o,s;if(this.inputSource!==A.inputSource)return;const e=(g=this._layout)==null?void 0:g.selectComponentId,t=(s=(o=(I=this._layout)==null?void 0:I.components[e])==null?void 0:o.gamepadIndices)==null?void 0:s.button;if(t!==void 0&&(this._selectButtonIndex=t),!Mh){if(!ok){ok=!0;const n=this.getGesture("pinch");if(n!=null&&n.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}}Ma&&Re.DrawDirection(this.rayWorldPosition,Xi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(ni.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,A)}});r(this,"onSelectEnd",A=>{Mh||this.inputSource===A.inputSource&&this.emitPointerEvent(ni.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,A)});r(this,"onSequeezeStart",A=>{var e,t,g;this.inputSource===A.inputSource&&(this._squeezeButtonIndex=(g=(t=(e=this._layout)==null?void 0:e.components["xr-standard-squeeze"])==null?void 0:t.gamepadIndices)==null?void 0:g.button,this._squeezeButtonIndex!==void 0&&(Ma&&Re.DrawDirection(this.rayWorldPosition,Xi(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(ni.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,A)))});r(this,"onSequeezeEnd",A=>{this.inputSource===A.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(ni.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,A)});r(this,"states",{});r(this,"_didMoveLastFrame",!1);r(this,"_lastPointerMovePosition",new y);r(this,"_lastPointerMoveQuaternion",new GA);r(this,"pointerInit");var g,I,o;this.xr=A,this.inputSource=e,this.index=t,this._object=new pA,Ma&&this._object.add(this._debugAxesHelper),this.xr.context.scene.add(this._object),this._ray=new qo,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=(I=(g=this.xr.session).requestHitTestSourceForTransientInput)==null?void 0:I.call(g,{profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null||o.then(s=>this._hitTestSource=s))}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(A){var t,g;if(!this.hand||!((t=this.xr.frame)!=null&&t.getJointPose)||!this.xr.referenceSpace)return null;let e=(g=this._handJointPoses)==null?void 0:g.get(A);return e||(e=this.xr.frame.getJointPose(A,this.xr.referenceSpace),e&&this._handJointPoses.set(A,e),e)}get gripPosition(){return Xi(this._gripPosition).applyMatrix4(by)}get gripQuaternion(){return MB(this._gripQuaternion).premultiply(qs)}get gripLinearVelocity(){return Xi(this._linearVelocity).applyQuaternion(qs)}get rayPosition(){return Xi(this._rayPosition).applyMatrix4(by)}get rayQuaternion(){return MB(this._rayQuaternion).premultiply(qs)}get gripWorldPosition(){return Xi(this._gripWorldPosition)}get gripWorldQuaternion(){return MB(this._gripWorldQuaternion)}get rayWorldPosition(){return Xi(this._rayWorldPosition)}updateRayWorldPosition(){var e;const A=(e=this.xr.context.mainCamera)==null?void 0:e.parent;this._rayWorldPosition.copy(this._rayPosition),A&&this._rayWorldPosition.applyMatrix4(A.matrixWorld)}get rayWorldQuaternion(){return MB(this._rayWorldQuaternion)}updateRayWorldQuaternion(){var t;const A=(t=this.xr.context.mainCamera)==null?void 0:t.parent,e=A?Lt(A):void 0;this._rayWorldQuaternion.copy(this._rayQuaternion).multiply(qs),e&&this._rayWorldQuaternion.premultiply(e)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(Xi(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get object(){return this._object}async getModelUrl(){var A;return(A=this.getMotionController)==null?void 0:A.then(e=>(e==null?void 0:e.assetUrl)||null)}onUpdate(A){this.onUpdateFrame(A),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){var g;Re.DrawWireSphere(this.rayWorldPosition,.02),Re.DrawDirection(this.rayWorldPosition,Xi(0,0,10).applyQuaternion(this.rayWorldQuaternion));const A=this.gripWorldPosition.sub(this.object.worldForward.multiplyScalar(.1)),e=this.inputSource.profiles.join(`
|
|
4920
4920
|
`);let t=`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&&(t+=`
|
|
4922
4922
|
Pinch: ${(g=this.getGesture("pinch"))==null?void 0:g.value.toFixed(3)}`),t+=`
|
|
@@ -5540,7 +5540,7 @@ Texture:`,t),this.setLightmapDebugMaterial()),this.applyLightmap())}updateLightm
|
|
|
5540
5540
|
gl_FragColor = lightMapTexel;
|
|
5541
5541
|
gl_FragColor.a = 1.;
|
|
5542
5542
|
}
|
|
5543
|
-
`,defines:{USE_LIGHTMAP:""}})}}var JsA=Object.defineProperty,vsA=Object.getOwnPropertyDescriptor,Ca=(i,A,e,t)=>{for(var g=t>1?void 0:t?vsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JsA(A,e,g),g};const PD=IA("debugrenderer"),bsA=IA("debugskinnedmesh"),yL=IA("noInstancing"),Bl=IA("debuginstancing"),qsA=IA("debugprogressive"),LsA=IA("noprogressive"),xsA=IA("wireframe");class JF{constructor(){r(this,"path",null);r(this,"asset",null);r(this,"default")}}class TsA{constructor(A,e){r(this,"_renderer");r(this,"_targets",[]);r(this,"_indexMapMaxIndex");r(this,"_indexMap");r(this,"_changed",!1);this._renderer=A;const t=this.setMaterial.bind(this),g=this.getMaterial.bind(this),I=A.gameObject;if(this._targets=[],I)switch(I.type){case"Group":this._targets=[...I.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(I);break}let o=!1,s,n=0;for(let C=0;C<this._targets.length;C++){const a=this._targets[C];if(!a)continue;const B=a.material;if(B){B.shadowSide=B.side;for(let Q=0;Q<e.length;Q++){const E=e[Q];if(!E){o=!0;continue}if(B.name===E.name){s===void 0&&(s=new Map),s.set(Q,C),n=Math.max(n,Q);break}}}}if(o){this._indexMapMaxIndex=n,this._indexMap=s;const C=`Renderer ${A.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(C),HI()&&yi("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(C,a){if(typeof a=="string"){const B=parseInt(a);if(!isNaN(B))return g(B)}return C[a]},set(C,a,B){return typeof a=="string"&&t(B,Number.parseInt(a)),Reflect.set(C,a,B)?(B instanceof xe&&(C.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(A){A===!0&&PD&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=A}is(A){return this._renderer===A}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let A=0;A<this.length;A++)yield this.getMaterial(A)}resolveIndex(A){const e=this._indexMap;return e&&e.has(A)?e.get(A):A}setMaterial(A,e){if(e=this.resolveIndex(e),e<0||e>=this._targets.length)return;const t=this._targets[e];!t||t.material===void 0||(t.material=A,this.changed=!0)}getMaterial(A){if(A=this.resolveIndex(A),A<0)return null;const e=this._targets;if(A>=e.length)return null;const t=e[A];return t?t.material:null}}const sP=class extends UA{constructor(){super(...arguments);r(this,"receiveShadows",!1);r(this,"shadowCastingMode",0);r(this,"lightmapIndex",-1);r(this,"lightmapScaleOffset",new ge(1,1,0,0));r(this,"enableInstancing");r(this,"renderOrder");r(this,"allowOcclusionWhenDynamic",!0);r(this,"probeAnchor");r(this,"reflectionProbeUsage",0);r(this,"_lightmaps");r(this,"_sharedMeshes",[]);r(this,"_sharedMaterials");r(this,"_originalMaterials");r(this,"_lightmapTextureOverride");r(this,"allowProgressiveLoading",!0);r(this,"_isInstancingEnabled",!1);r(this,"handles");r(this,"onBeforeRenderThree",(A,e,t,g,I,o)=>{var s;if(I.envMapIntensity!==void 0){const n=this.hasLightmap?Math.PI:1,C=((s=this.context.mainCameraComponent)==null?void 0:s.environmentIntensity)??1;I.envMapIntensity=Math.max(0,C*this.context.sceneLighting.environmentIntensity/n)}if(this._lightmaps)for(const n of this._lightmaps)n.updateLightmapUniforms(I)});r(this,"_reflectionProbe",null)}static setVisible(A,e){fE(A,e)}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 A of this.gameObject.children)(A.type==="Mesh"||A.type==="SkinnedMesh")&&this._sharedMeshes.push(A);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(A){this.sharedMaterials[0]!==A&&(this.sharedMaterials[0]=A,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(A){this.sharedMaterial=A}set sharedMaterials(A){if(!this._originalMaterials)this._originalMaterials=A;else if(A){let e=!1;for(let t=0;t<this._sharedMaterials.length;t++){const g=t<A.length?A[t]:null;g&&g instanceof xe?this.sharedMaterials[t]=g:e||(e=!0,console.warn("Can not assign null as material: "+this.name,g))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new TsA(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return yL}get lightmap(){var A;return(A=this._lightmaps)!=null&&A.length?this._lightmaps[0].lightmap:null}set lightmap(A){var e;if(this._lightmapTextureOverride=A,A===void 0&&(A=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(e=this._lightmaps)!=null&&e.length)for(const t of this._lightmaps)t.lightmap=A}get hasLightmap(){const A=this.lightmap;return A!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(PD&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&PD&&this.probeAnchor.add(new Es(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const A of this.gameObject.children)this.context.addBeforeRenderListener(A,this.onBeforeRenderThree),A.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let A=0;for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];if(!(!this.isMeshOrSkinnedMesh(t)||rA.getComponent(t,sP))){if(this.renderOrder.length<=A){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+A,"ChildElement:",t);continue}t.renderOrder=this.renderOrder[A],A+=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(),xsA)for(let A=0;A<this.sharedMaterials.length;A++){const e=this.sharedMaterials[A];e&&(e.wireframe=!0)}}applyLightmapping(){var A;if(this.lightmapIndex>=0){const e=this.gameObject.type,t=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(t){if(this._lightmaps||(this._lightmaps=[]),e==="Mesh"){const g=this.gameObject.material;if(g!=null&&g.isMeshBasicMaterial)g&&console.warn("Lightmapping is not supported on MeshBasicMaterial",g.name);else{if(this._lightmaps.length<=0){const o=new Ud(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,t)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let g=0;g<this.gameObject.children.length;g++){const I=this.gameObject.children[g];if(!((A=I.material)!=null&&A.isMeshBasicMaterial)){let o;g>=this._lightmaps.length?(o=new Ud(I,this.context),this._lightmaps.push(o)):o=this._lightmaps[g],o.init(this.lightmapIndex,this.lightmapScaleOffset,t)}}}else PD&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}setInstancingEnabled(A){if(this._isInstancingEnabled===A)return A&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=A,A){if(this.handles===void 0){if(this.handles=_sA.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return rA.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const e of this.handles)e.updateInstanceMatrix(!0),e.add();return rA.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const e of this.handles)e.remove();return!0}return!1}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!yL&&(this.setInstancingEnabled(!0),Ws.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let A=0;A<this.gameObject.children.length;A++){const e=this.gameObject.children[A];e.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 A of this.gameObject.children)this.context.removeBeforeRenderListener(A,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}applyStencil(){bl.applyStencil(this)}onBeforeRender(){var A,e;if(this.gameObject){if(this.isMultiMaterialObject(this.gameObject)&&((A=this.gameObject.children)==null?void 0:A.length)>0)for(const t of this.gameObject.children)this.applySettings(t);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(e=this.handles)!=null&&e.length&&this.gameObject[pd]===!0){Bl&&console.log("UPDATE INSTANCED MATRICES",this.context.time.frame),this.gameObject[pd]=!1;for(let g=this.handles.length-1;g>=0;g--)this.handles[g].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&rA.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let t=0;t<this.handles.length;t++){const g=this.handles[t];fE(g.object,!1)}for(const t of this.sharedMaterials)t&&this.loadProgressiveTextures(t);this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let A=0;A<this.handles.length;A++){const e=this.handles[A];fE(e.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this)}loadProgressiveTextures(A){return!LsA&&A&&A._didRequestTextureLOD===void 0&&this.allowProgressiveLoading?(A._didRequestTextureLOD=0,qsA&&console.log("Load material LOD",A.name),lI.assignTextureLOD(this.context,this.sourceId,A)):Promise.resolve(!0)}applySettings(A){A.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?A.castShadow=!0:A.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),tg.LateUpdate)}}*_updateReflectionProbe(){const A=this.probeAnchor||this.gameObject,e=!!this.probeAnchor;this._reflectionProbe=Zc.get(A,this.context,e,this.probeAnchor)}setVisibility(A){if(!this.isMultiMaterialObject(this.gameObject))fE(this.gameObject,A);else for(const e of this.gameObject.children)this.isMeshOrSkinnedMesh(e)&&fE(e,A)}isMultiMaterialObject(A){return A.type==="Group"}isMeshOrSkinnedMesh(A){return A.type==="Mesh"||A.type==="SkinnedMesh"}};let Ji=sP;Ca([D()],Ji.prototype,"receiveShadows",2);Ca([D()],Ji.prototype,"shadowCastingMode",2);Ca([D()],Ji.prototype,"lightmapIndex",2);Ca([D(ge)],Ji.prototype,"lightmapScaleOffset",2);Ca([D()],Ji.prototype,"enableInstancing",2);Ca([D()],Ji.prototype,"renderOrder",2);Ca([D()],Ji.prototype,"allowOcclusionWhenDynamic",2);Ca([D(pA)],Ji.prototype,"probeAnchor",2);Ca([D()],Ji.prototype,"reflectionProbeUsage",2);class Ou extends Ji{}class vF extends Ou{awake(){var A;super.awake(),this.allowOcclusionWhenDynamic=!1,(A=this.gameObject.parent)==null||A.updateWorldMatrix(!1,!0)}onBeforeRender(){if(super.onBeforeRender(),bsA&&this.gameObject instanceof Os&&this.gameObject.boundingSphere){const A=Xi(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);Re.DrawWireSphere(A,this.gameObject.boundingSphere.radius,"red")}}}class YsA{constructor(){r(this,"objs",[])}setup(A,e,t,g,I,o=0){A.applySettings(e);const s=this.tryCreateOrAddInstance(e,t,I);if(s)A.loadProgressiveTextures(s.instancer.material),g===null&&(g=[]),g.push(s);else if(o<=0&&e.type!=="Mesh"){const n=o+1;for(const C of e.children)g=this.setup(A,C,t,g,I,n)}return o===0&&I.useMatrixWorldAutoUpdate&&g&&g.length>=0&&this.autoUpdateInstanceMatrix(e),g}tryCreateOrAddInstance(A,e,t){if(A.type==="Mesh"){const g=t.foundMeshes;if(t.foundMeshes+=1,!t.rend.enableInstancing||g>=t.rend.enableInstancing.length||!t.rend.enableInstancing[g])return null;const I=A,o=I.geometry,s=I.material;for(const a of this.objs)if(!a.isFull()&&a.geo===o&&a.material===s)return a.addInstance(I);const n=new WD(A.name,o,s,200,e);return this.objs.push(n),n.addInstance(I)}return null}autoUpdateInstanceMatrix(A){const e=A.matrixWorld.multiplyMatrices.bind(A.matrixWorld),t=A.matrixWorld.clone(),g=(I,o)=>{const s=e(I,o);return(A[pd]||t.equals(s)===!1)&&(t.copy(s),A[pd]=!0),s};A.matrixWorld.multiplyMatrices=g}}const _sA=new YsA;class HsA{constructor(A,e,t){r(this,"instanceIndex",-1);r(this,"object");r(this,"instancer");this.instanceIndex=A,this.object=e,this.instancer=t,e[x_]=t,rA.markAsInstancedRendered(e,!0)}get name(){return this.object.name}updateInstanceMatrix(A=!1){this.instanceIndex<0||(this.object.updateWorldMatrix(!0,A),this.instancer.updateInstance(this.object.matrixWorld,this.instanceIndex))}setMatrix(A){this.instanceIndex<0||this.instancer.updateInstance(A,this.instanceIndex)}add(){this.instanceIndex>=0||this.instancer.add(this)}remove(){this.instanceIndex<0||this.instancer.remove(this)}}const oJ=class{constructor(A,e,t,g,I){r(this,"name","");r(this,"geo");r(this,"material");r(this,"context");r(this,"inst");r(this,"handles",[]);r(this,"maxCount");r(this,"_needUpdateBounds",!1);r(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[kG]===!0&&(Bl&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});r(this,"onAfterRender",()=>{this.inst.layers.disableAll()});this.name=A,this.geo=e,this.material=t,this.context=I,this.maxCount=g,Bl&&(t=new Bt({color:this.randomColor()})),this.inst=new Lw(e,t,g),this.inst[kG]=!0,this.inst.count=0,this.inst.visible=!0,this.context.scene.add(this.inst),t instanceof Iu&&(t.defines.USE_INSTANCING=!0,t.needsUpdate=!0),I.pre_render_callbacks.push(this.onBeforeRender),I.post_render_callbacks.push(this.onAfterRender)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(A){this.inst.visible=A}get castShadow(){return this.inst.castShadow}set castShadow(A){this.inst.castShadow=A}set receiveShadow(A){this.inst.receiveShadow=A}updateBounds(A=!0,e=!0){this._needUpdateBounds=!1,A&&this.inst.computeBoundingBox(),e&&this.inst.computeBoundingSphere()}get currentCount(){return this.inst.count}isFull(){return this.currentCount>=this.maxCount}randomColor(){return new wA(Math.random(),Math.random(),Math.random())}addInstance(A){if(this.currentCount>=this.maxCount)return console.error("TOO MANY INSTANCES - resize is not yet implemented!",this.inst.count),null;const e=new HsA(-1,A,this);return A.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),A.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0),this.add(e),e}add(A){A.instanceIndex<0&&(A.instanceIndex=this.currentCount,A.instanceIndex>=this.handles.length?this.handles.push(A):this.handles[A.instanceIndex]=A),A.object.updateWorldMatrix(!0,!0),this.inst.setMatrixAt(A.instanceIndex,A.object.matrixWorld),this.inst.instanceMatrix.needsUpdate=!0,this.inst.count+=1,this._needUpdateBounds=!0,this.inst.count>0&&(this.inst.visible=!0),Bl&&console.log("Added",this.name,this.inst.count)}remove(A){if(!A||A.instanceIndex<0||A.instanceIndex>=this.handles.length||this.inst.count<=0)return;if(this.handles[A.instanceIndex]!==A){console.error("instance handle is not part of renderer, was it removed before?",A.instanceIndex,this.name);const t=this.handles.indexOf(A);if(t<0)return;A.instanceIndex=t}if(this.handles[A.instanceIndex]=null,this.inst.setMatrixAt(A.instanceIndex,oJ.nullMatrix),!(A.instanceIndex>=this.currentCount-1)&&this.currentCount>0){const t=this.handles[this.currentCount-1];t&&(t.instanceIndex=A.instanceIndex,t.updateInstanceMatrix(),this.handles[A.instanceIndex]=t,this.handles[this.currentCount-1]=null)}this.inst.count>0&&(this.inst.count-=1),A.instanceIndex=-1,this._needUpdateBounds=!0,this.inst.count<=0&&(this.inst.visible=!1),this.inst.instanceMatrix.needsUpdate=!0,Bl&&console.log("Removed",this.name,this.inst.count)}updateInstance(A,e){this.inst.setMatrixAt(e,A),this.inst.instanceMatrix.needsUpdate=!0,this._needUpdateBounds=!0}};let WD=oJ;r(WD,"nullMatrix",new mA);var OsA=Object.defineProperty,PsA=Object.getOwnPropertyDescriptor,Si=(i,A,e,t)=>{for(var g=t>1?void 0:t?PsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OsA(A,e,g),g};const wL=IA("debugusdzbehaviours");function Pu(i){i&&(i.getComponentInParent(Fu)||(me()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(vo)))}class dQ extends UA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new y);r(this,"targetRot",new GA);r(this,"targetScale",new y)}start(){Pu(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Je(this.object).clone(),t=Je(this.target).clone(),g=Lt(this.object).clone(),I=Lt(this.target).clone(),o=ui(this.object).clone(),s=ui(this.target).clone(),n=e.distanceTo(t),C=g.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){uI(this.object,t),hs(this.object,I),dd(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),uI(this.object,this.targetPos),hs(this.object,this.targetRot),dd(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),g=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(g,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new Bg("Move to "+((t=this.target)==null?void 0:t.name),Wg.tapTrigger(this.gameObject),ht.transformAction(this.object,this.target,this.duration,this.relativeMotion?rR.Relative:rR.Absolute));e.addBehavior(g)}}}Si([D(pA)],dQ.prototype,"object",2);Si([D(pA)],dQ.prototype,"target",2);Si([D()],dQ.prototype,"duration",2);Si([D()],dQ.prototype,"relativeMotion",2);var QD;const uC=(QD=class extends UA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",[]);r(this,"selfModel");r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=rA.findObjectsOfType(Ji);for(const e of A)for(let t=0;t<e.sharedMaterials.length;t++){const g=e.sharedMaterials[t];if(g===this.materialToSwitch){if(e.gameObject instanceof uA)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof xI)for(const I of e.gameObject.children)I instanceof uA&&I.material===g&&this._objectsWithThisMaterial.push(I);break}}}}start(){Pu(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(A,e){this.targetModels=[],uC._materialTriggersPerId={},uC.variantSwitchIndex=0,this.materialToSwitch&&await lI.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await lI.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(uC._materialTriggersPerId[this.materialToSwitch.uuid]||(uC._materialTriggersPerId[this.materialToSwitch.uuid]=[]),uC._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=uC._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(g[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in g)s!==I.selfModel.uuid&&o.push(...g[s]);I.createAndAttachBehaviors(A,g[I.selfModel.uuid],o)}}delete uC._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);I.push(ht.fadeAction([...this.targetModels,...t],o,!1)),g.push(ht.fadeAction(e,o,!1)),I.push(ht.fadeAction(e,o,!0)),A.addBehavior(new Bg("Select_"+this.selfModel.name,Wg.tapTrigger(this.selfModel),ht.parallel(...I))),A.addBehavior(new Bg("StartHidden_"+this.selfModel.name,Wg.sceneStartTrigger(),ht.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+uC.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&no.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(QD,"_materialTriggersPerId",{}),r(QD,"variantSwitchIndex",0),QD);let Xc=uC;Si([D(xe)],Xc.prototype,"materialToSwitch",2);Si([D(xe)],Xc.prototype,"variantMaterial",2);Si([D()],Xc.prototype,"fadeDuration",2);var cE;const ci=(cE=class extends UA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"selfModelClone");r(this,"targetModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1);r(this,"targetStateBeforeCreatingDocument",!1)}start(){Pu(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ci.wasVisible]===void 0&&(this.gameObject[ci.wasVisible]=this.gameObject.activeSelf),this.target[ci.wasVisible]===void 0&&(this.target[ci.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ci.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ci.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(A,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let g=this.selfModel,I=this.targetState;if(this.toggleOnClick)if(I=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&M1.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ci.toggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggle"+ci.clonedToggleIndex++,t.add(n),this.gameObject[ci.toggleClone]=n,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const s=this.gameObject[ci.toggleClone];if(!this.gameObject[ci.reverseToggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggleReverse"+ci.clonedToggleIndex++,t.add(n),this.gameObject[ci.reverseToggleClone]=n}this.toggleModel=this.gameObject[ci.reverseToggleClone],(!this.toggleModel.geometry||!s.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),g=s,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const s=[];s.push(ht.fadeAction(g,0,!1)),s.push(ht.fadeAction(this.toggleModel,0,!0)),s.push(ht.fadeAction(this.targetModel,0,I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Wg.tapTrigger(g),ht.parallel(...s)));const n=[];n.push(ht.fadeAction(this.toggleModel,0,!1)),n.push(ht.fadeAction(g,0,!0)),n.push(ht.fadeAction(this.targetModel,0,!I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"Off":"On"),Wg.tapTrigger(this.toggleModel),ht.parallel(...n)))}}else{const s=[];this.hideSelf&&s.push(ht.fadeAction(g,0,!1)),s.push(ht.fadeAction(this.targetModel,0,I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Wg.tapTrigger(g),ht.parallel(...s)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(t),this.toggleModel&&o.push(this.toggleModel),A.addBehavior(new Bg("HideOnStart_"+this.gameObject.name,Wg.sceneStartTrigger(),ht.fadeAction(o,0,!1)))}}afterSerialize(A,e){this.gameObject[ci.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ci.wasVisible],delete this.gameObject[ci.wasVisible]),this.target&&this.target[ci.wasVisible]!==void 0&&(this.target.visible=this.target[ci.wasVisible],delete this.target[ci.wasVisible]),delete this.gameObject[ci.toggleClone],delete this.gameObject[ci.reverseToggleClone]}},r(cE,"clonedToggleIndex",0),r(cE,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),r(cE,"toggleClone",Symbol("clone for toggling")),r(cE,"reverseToggleClone",Symbol("clone for reverse toggling")),cE);let uQ=ci;Si([D(pA)],uQ.prototype,"target",2);Si([D()],uQ.prototype,"toggleOnClick",2);Si([D()],uQ.prototype,"targetState",2);Si([D()],uQ.prototype,"hideSelf",2);class bF extends UA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new Bg("HideOnStart_"+this.gameObject.name,Wg.sceneStartTrigger(),ht.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class $c extends UA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType",BF.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new Bg("emphasize "+this.name,Wg.tapTrigger(this.gameObject),ht.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}Si([D()],$c.prototype,"target",2);Si([D()],$c.prototype,"duration",2);Si([D()],$c.prototype,"motionType",2);class Dr extends UA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){Pu(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(wi);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,t,g){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=ur.getName(I),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?QR.NonSpatial:QR.Spatial;let a=!1;if(this.gameObject.traverse(B=>{B instanceof uA&&B.visible&&(a=!0)}),a){let B=ht.playAudioAction(o,"audio/"+s,BR.Play,n,C);this.toggleOnClick&&(B.multiplePerformOperation=K1.Stop),this.target&&this.target.loop&&(B=ht.sequence(B).makeLooping());const Q=new Bg("playAudio "+this.name,Wg.tapTrigger(this.gameObject),B);e.addBehavior(Q)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let B=ht.playAudioAction(o,"audio/"+s,BR.Play,n,C);this.target.loop&&(B=ht.sequence(B).makeLooping());const Q=new Bg("playAudioOnStart"+(this.name?"_"+this.name:""),Wg.sceneStartTrigger(),B);e.addBehavior(Q)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const o="audio/"+ur.getName(g);if(t.files[o])return;const C=await(await(await fetch(g)).blob()).arrayBuffer(),a=new Uint8Array(C);t.files[o]=a}}Si([D(wi)],Dr.prototype,"target",2);Si([D(URL)],Dr.prototype,"clip",2);Si([D()],Dr.prototype,"toggleOnClick",2);var ED;const ba=(ED=class extends UA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A;return(A=this.animator)==null?void 0:A.gameObject}start(){Pu(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(ba.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';me()&&yi(A),console.warn(A,...ba.rootsWithExclusivePlayback)}ba.animationActions=[],ba.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,g=e.extensions.find(s=>s instanceof vu);if(!g)return;const I=g.getClipCount(this.target)>1;I&&(me()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+g.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),ba.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=ba.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=ht.startAnimationAction(s,n.start,n.duration),ba.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=ht.sequence();if(this.animationSequence!==void 0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence!==void 0){const Q=a.actions.length==0?a:ht.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new Bg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Wg.tapTrigger(this.selfModel):Wg.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var C,a,B,Q;if(!this.target||!this.animator)return;const g=(C=this.animator)==null?void 0:C.runtimeAnimatorController;let I=g==null?void 0:g.findState(this.stateName),o=[],s=[];if(g&&I){const E=new Array;E.push(I);let c=!1;for(;E.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(a=I.motion)!=null&&a.isLooping&&(c=!0);break}const h=I.transitions.find(l=>l.conditions.length===0),u=h?g.getState(h.destinationState,0):null;if(u&&E.includes(u)){I=u,c=!0;break}else if(h){if(I=u,!I)break;E.push(I)}else{c=((B=I.motion)==null?void 0:B.isLooping)??!1;break}}if(c&&I){const h=E.indexOf(I);o=E.slice(0,h),s=E.slice(h),wL&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=E,s=[],wL&&console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(E=>{var c,h,u;return((c=E.motion)==null?void 0:c.clip)&&((u=(h=E.motion)==null?void 0:h.clip.tracks)==null?void 0:u.length)>0}),s=s.filter(E=>{var c,h,u;return((c=E.motion)==null?void 0:c.clip)&&((u=(h=E.motion)==null?void 0:h.clip.tracks)==null?void 0:u.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((Q=this.animator)==null?void 0:Q.name)+", can't export animation data");return}this.stateAnimationModel=e;const n=(E,c)=>{var u,l,d;if(!this.target)return;if(!((u=E.motion)!=null&&u.clip)){console.warn("No clip found for state "+E.name+" on "+((l=this.animator)==null?void 0:l.name)+", can't export animation data");return}const h=A.registerAnimation(this.target,E.motion.clip);h?c.push(h):console.warn("Couldn't register animation for state "+E.name+" on "+((d=this.animator)==null?void 0:d.name))};if(o.length>0){this.animationSequence=new Array;for(const E of o)n(E,this.animationSequence)}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const E of s)n(E,this.animationLoopAfterSequence)}}},r(ED,"animationActions",[]),r(ED,"rootsWithExclusivePlayback",new Set),ED);let Ah=ba;Si([D(Zg)],Ah.prototype,"animator",2);Si([D()],Ah.prototype,"stateName",2);class eh extends UA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}Si([D(pA)],eh.prototype,"target",2);class Wu extends UA{constructor(){super(...arguments);r(this,"target")}}Si([D(eh)],Wu.prototype,"target",2);class ju extends eh{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Si([D()],ju.prototype,"type",2);Si([D()],ju.prototype,"duration",2);class qF extends Wu{}var WsA=Object.defineProperty,jsA=Object.getOwnPropertyDescriptor,aa=(i,A,e,t)=>{for(var g=t>1?void 0:t?jsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WsA(A,e,g),g};const SL=IA("debugcharactercontroller");class pQ extends UA{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new y)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ti),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ti)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(pr);t||(t=this.gameObject.addNewComponent(pr)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const g=new y(0,0,1),I=new y(1,0,0),o=new y(0,1,0),s=this.gameObject.getWorldDirection(new y);s.y=0;const n=I.dot(s)<0?-1:1,C=g.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),SL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),SL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const g=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);g&&(this._contactVelocity.x+=g.x,this._contactVelocity.y+=g.y,this._contactVelocity.z+=g.z)}return this._contactVelocity}}aa([D(y)],pQ.prototype,"center",2);aa([D()],pQ.prototype,"radius",2);aa([D()],pQ.prototype,"height",2);class ra extends UA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new gA(0,0));r(this,"moveInput",new gA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new y(0,0,0));r(this,"_currentAngularSpeed",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new ls)}awake(){this._currentRotation=new GA}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,g){var I,o,s,n,C,a,B,Q,E,c,h;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=se.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const u=this.context.mainCameraComponent.forward;u.y=0,u.normalize(),this._currentRotation.setFromUnitVectors(new y(0,0,1),u),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let u=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(u=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),u){this._jumpCount+=1;const l=this.controller.rigidbody,d=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new y(0,1,0).multiplyScalar(d))}}if(this.controller){const u=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(u<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qo),this._raycastOptions.ray.origin.copy(Je(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const d=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(d.length&&d[0].distance>2||u<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}aa([D(pQ)],ra.prototype,"controller",2);aa([D()],ra.prototype,"movementSpeed",2);aa([D()],ra.prototype,"rotationSpeed",2);aa([D()],ra.prototype,"jumpForce",2);aa([D()],ra.prototype,"doubleJumpForce",2);aa([D(Zg)],ra.prototype,"animator",2);var VsA=Object.defineProperty,zsA=Object.getOwnPropertyDescriptor,ZsA=(i,A,e,t)=>{for(var g=t>1?void 0:t?zsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VsA(A,e,g),g};class Vu extends DI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new tH;return e.offset=new gA(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}ZsA([D(be)],Vu.prototype,"intensity",2);ys("ChromaticAberration",Vu);const zu=new fe;zu.setAttribute("position",new ie(new Float32Array([-1,-1,3,-1,-1,3]),2));zu.setAttribute("uv",new ie(new Float32Array([0,0,2,0,0,2]),2));zu.boundingSphere=new Oi;zu.computeBoundingSphere=function(){};const XsA=new ia;class sB{constructor(A){this._mesh=new uA(zu,A),this._mesh.frustumCulled=!1}render(A){A.render(this._mesh,XsA)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const $sA={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new mA},viewMat:{value:new mA},projViewMat:{value:new mA},projectionMatrixInv:{value:new mA},viewMatrixInv:{value:new mA},cameraPos:{value:new y},resolution:{value:new gA},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 JsA=Object.defineProperty,vsA=Object.getOwnPropertyDescriptor,Ca=(i,A,e,t)=>{for(var g=t>1?void 0:t?vsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JsA(A,e,g),g};const PD=IA("debugrenderer"),bsA=IA("debugskinnedmesh"),yL=IA("noInstancing"),Bl=IA("debuginstancing"),qsA=IA("debugprogressive"),LsA=IA("noprogressive"),xsA=IA("wireframe");class JF{constructor(){r(this,"path",null);r(this,"asset",null);r(this,"default")}}class TsA{constructor(A,e){r(this,"_renderer");r(this,"_targets",[]);r(this,"_indexMapMaxIndex");r(this,"_indexMap");r(this,"_changed",!1);this._renderer=A;const t=this.setMaterial.bind(this),g=this.getMaterial.bind(this),I=A.gameObject;if(this._targets=[],I)switch(I.type){case"Group":this._targets=[...I.children];break;case"SkinnedMesh":case"Mesh":this._targets.push(I);break}let o=!1,s,n=0;for(let C=0;C<this._targets.length;C++){const a=this._targets[C];if(!a)continue;const B=a.material;if(B){B.shadowSide=B.side;for(let Q=0;Q<e.length;Q++){const E=e[Q];if(!E){o=!0;continue}if(B.name===E.name){s===void 0&&(s=new Map),s.set(Q,C),n=Math.max(n,Q);break}}}}if(o){this._indexMapMaxIndex=n,this._indexMap=s;const C=`Renderer ${A.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;console.warn(C),HI()&&yi("Found renderer with missing materials: please check the console for details.")}return new Proxy(this,{get(C,a){if(typeof a=="string"){const B=parseInt(a);if(!isNaN(B))return g(B)}return C[a]},set(C,a,B){return typeof a=="string"&&t(B,Number.parseInt(a)),Reflect.set(C,a,B)?(B instanceof xe&&(C.changed=!0),!0):!1}})}get changed(){return this._changed}set changed(A){A===!0&&PD&&console.warn("SharedMaterials have changed: "+this._renderer.name,this),this._changed=A}is(A){return this._renderer===A}get length(){return this._indexMapMaxIndex!==void 0?this._indexMapMaxIndex+1:this._targets.length}*[Symbol.iterator](){for(let A=0;A<this.length;A++)yield this.getMaterial(A)}resolveIndex(A){const e=this._indexMap;return e&&e.has(A)?e.get(A):A}setMaterial(A,e){if(e=this.resolveIndex(e),e<0||e>=this._targets.length)return;const t=this._targets[e];!t||t.material===void 0||(t.material=A,this.changed=!0)}getMaterial(A){if(A=this.resolveIndex(A),A<0)return null;const e=this._targets;if(A>=e.length)return null;const t=e[A];return t?t.material:null}}const sP=class extends UA{constructor(){super(...arguments);r(this,"receiveShadows",!1);r(this,"shadowCastingMode",0);r(this,"lightmapIndex",-1);r(this,"lightmapScaleOffset",new ge(1,1,0,0));r(this,"enableInstancing");r(this,"renderOrder");r(this,"allowOcclusionWhenDynamic",!0);r(this,"probeAnchor");r(this,"reflectionProbeUsage",0);r(this,"_lightmaps");r(this,"_sharedMeshes",[]);r(this,"_sharedMaterials");r(this,"_originalMaterials");r(this,"_lightmapTextureOverride");r(this,"allowProgressiveLoading",!0);r(this,"_isInstancingEnabled",!1);r(this,"handles");r(this,"onBeforeRenderThree",(A,e,t,g,I,o)=>{var s;if(I.envMapIntensity!==void 0){const n=this.hasLightmap?Math.PI:1,C=((s=this.context.mainCameraComponent)==null?void 0:s.environmentIntensity)??1;I.envMapIntensity=Math.max(0,C*this.context.sceneLighting.environmentIntensity/n)}if(this._lightmaps)for(const n of this._lightmaps)n.updateLightmapUniforms(I)});r(this,"_reflectionProbe",null)}static setVisible(A,e){fE(A,e)}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 A of this.gameObject.children)(A.type==="Mesh"||A.type==="SkinnedMesh")&&this._sharedMeshes.push(A);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(A){this.sharedMaterials[0]!==A&&(this.sharedMaterials[0]=A,this.applyLightmapping())}get material(){return this.sharedMaterials[0]}set material(A){this.sharedMaterial=A}set sharedMaterials(A){if(!this._originalMaterials)this._originalMaterials=A;else if(A){let e=!1;for(let t=0;t<this._sharedMaterials.length;t++){const g=t<A.length?A[t]:null;g&&g instanceof xe?this.sharedMaterials[t]=g:e||(e=!0,console.warn("Can not assign null as material: "+this.name,g))}}}get sharedMaterials(){return(!this._sharedMaterials||!this._sharedMaterials.is(this))&&(this._originalMaterials||(this._originalMaterials=[]),this._sharedMaterials=new TsA(this,this._originalMaterials)),this._sharedMaterials}static get shouldSuppressInstancing(){return yL}get lightmap(){var A;return(A=this._lightmaps)!=null&&A.length?this._lightmaps[0].lightmap:null}set lightmap(A){var e;if(this._lightmapTextureOverride=A,A===void 0&&(A=this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex)),(e=this._lightmaps)!=null&&e.length)for(const t of this._lightmaps)t.lightmap=A}get hasLightmap(){const A=this.lightmap;return A!=null}registering(){this.enabled||this.setVisibility(!1)}awake(){if(PD&&console.log("Renderer ",this.name,this),this.clearInstancingState(),this.probeAnchor&&PD&&this.probeAnchor.add(new Es(.2)),this._reflectionProbe=null,this.isMultiMaterialObject(this.gameObject)){for(const A of this.gameObject.children)this.context.addBeforeRenderListener(A,this.onBeforeRenderThree),A.layers.mask=this.gameObject.layers.mask;if(this.renderOrder!==void 0){let A=0;for(let e=0;e<this.gameObject.children.length;e++){const t=this.gameObject.children[e];if(!(!this.isMeshOrSkinnedMesh(t)||rA.getComponent(t,sP))){if(this.renderOrder.length<=A){console.warn("Incorrect renderOrder element count",this,this.renderOrder.length+" but expected "+this.gameObject.children.length,"Index: "+A,"ChildElement:",t);continue}t.renderOrder=this.renderOrder[A],A+=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(),xsA)for(let A=0;A<this.sharedMaterials.length;A++){const e=this.sharedMaterials[A];e&&(e.wireframe=!0)}}applyLightmapping(){var A;if(this.lightmapIndex>=0){const e=this.gameObject.type,t=this._lightmapTextureOverride!==void 0?this._lightmapTextureOverride:this.context.lightmaps.tryGetLightmap(this.sourceId,this.lightmapIndex);if(t){if(this._lightmaps||(this._lightmaps=[]),e==="Mesh"){const g=this.gameObject.material;if(g!=null&&g.isMeshBasicMaterial)g&&console.warn("Lightmapping is not supported on MeshBasicMaterial",g.name);else{if(this._lightmaps.length<=0){const o=new Ud(this.gameObject,this.context);this._lightmaps.push(o)}this._lightmaps[0].init(this.lightmapIndex,this.lightmapScaleOffset,t)}}else if(this.isMultiMaterialObject(this.gameObject)&&this.sharedMaterials.length>0)for(let g=0;g<this.gameObject.children.length;g++){const I=this.gameObject.children[g];if(!((A=I.material)!=null&&A.isMeshBasicMaterial)){let o;g>=this._lightmaps.length?(o=new Ud(I,this.context),this._lightmaps.push(o)):o=this._lightmaps[g],o.init(this.lightmapIndex,this.lightmapScaleOffset,t)}}}else PD&&console.warn("Lightmap not found",this.sourceId,this.lightmapIndex)}}clearInstancingState(){this._isInstancingEnabled=!1,this.handles=void 0}setInstancingEnabled(A){if(this._isInstancingEnabled===A)return A&&(this.handles===void 0||this.handles!=null&&this.handles.length>0);if(this._isInstancingEnabled=A,A){if(this.handles===void 0){if(this.handles=_sA.setup(this,this.gameObject,this.context,null,{rend:this,foundMeshes:0,useMatrixWorldAutoUpdate:this.useInstanceMatrixWorldAutoUpdate()}),this.handles)return rA.markAsInstancedRendered(this.gameObject,!0),!0}else if(this.handles!==null){for(const e of this.handles)e.updateInstanceMatrix(!0),e.add();return rA.markAsInstancedRendered(this.gameObject,!0),!0}}else{if(this.handles)for(const e of this.handles)e.remove();return!0}return!1}useInstanceMatrixWorldAutoUpdate(){return!0}start(){if(this.enableInstancing&&!yL&&(this.setInstancingEnabled(!0),Ws.markDirty(this.gameObject)),this.gameObject.frustumCulled=this.allowOcclusionWhenDynamic,this.isMultiMaterialObject(this.gameObject))for(let A=0;A<this.gameObject.children.length;A++){const e=this.gameObject.children[A];e.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 A of this.gameObject.children)this.context.removeBeforeRenderListener(A,this.onBeforeRenderThree);else this.context.removeBeforeRenderListener(this.gameObject,this.onBeforeRenderThree)}applyStencil(){bl.applyStencil(this)}onBeforeRender(){var A,e;if(this.gameObject){if(this.isMultiMaterialObject(this.gameObject)&&((A=this.gameObject.children)==null?void 0:A.length)>0)for(const t of this.gameObject.children)this.applySettings(t);else this.applySettings(this.gameObject);if(this.sharedMaterials.changed&&(this.sharedMaterials.changed=!1,this.applyLightmapping()),(e=this.handles)!=null&&e.length&&this.gameObject[pd]===!0){Bl&&console.log("UPDATE INSTANCED MATRICES",this.context.time.frame),this.gameObject[pd]=!1;for(let g=this.handles.length-1;g>=0;g--)this.handles[g].updateInstanceMatrix();this.gameObject.matrixWorldNeedsUpdate=!1}if(this.handles&&this.handles.length<=0&&rA.markAsInstancedRendered(this.gameObject,!1),this._isInstancingEnabled&&this.handles)for(let t=0;t<this.handles.length;t++){const g=this.handles[t];fE(g.object,!1)}for(const t of this.sharedMaterials)t&&this.loadProgressiveTextures(t);this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onSet(this)}}onAfterRender(){if(this._isInstancingEnabled&&this.handles)for(let A=0;A<this.handles.length;A++){const e=this.handles[A];fE(e.object,!0)}this.reflectionProbeUsage!==0&&this._reflectionProbe&&this._reflectionProbe.onUnset(this)}loadProgressiveTextures(A){return!LsA&&A&&A._didRequestTextureLOD===void 0&&this.allowProgressiveLoading?(A._didRequestTextureLOD=0,qsA&&console.log("Load material LOD",A.name),lI.assignTextureLOD(this.context,this.sourceId,A)):Promise.resolve(!0)}applySettings(A){A.receiveShadow=this.receiveShadows,this.shadowCastingMode==1?A.castShadow=!0:A.castShadow=!1}updateReflectionProbe(){if(this._reflectionProbe=null,this.reflectionProbeUsage!==0){if(!this.probeAnchor)return;this.startCoroutine(this._updateReflectionProbe(),tg.LateUpdate)}}*_updateReflectionProbe(){const A=this.probeAnchor||this.gameObject,e=!!this.probeAnchor;this._reflectionProbe=Zc.get(A,this.context,e,this.probeAnchor)}setVisibility(A){if(!this.isMultiMaterialObject(this.gameObject))fE(this.gameObject,A);else for(const e of this.gameObject.children)this.isMeshOrSkinnedMesh(e)&&fE(e,A)}isMultiMaterialObject(A){return A.type==="Group"}isMeshOrSkinnedMesh(A){return A.type==="Mesh"||A.type==="SkinnedMesh"}};let Ji=sP;Ca([D()],Ji.prototype,"receiveShadows",2);Ca([D()],Ji.prototype,"shadowCastingMode",2);Ca([D()],Ji.prototype,"lightmapIndex",2);Ca([D(ge)],Ji.prototype,"lightmapScaleOffset",2);Ca([D()],Ji.prototype,"enableInstancing",2);Ca([D()],Ji.prototype,"renderOrder",2);Ca([D()],Ji.prototype,"allowOcclusionWhenDynamic",2);Ca([D(pA)],Ji.prototype,"probeAnchor",2);Ca([D()],Ji.prototype,"reflectionProbeUsage",2);class Ou extends Ji{}class vF extends Ou{awake(){var A;super.awake(),this.allowOcclusionWhenDynamic=!1,(A=this.gameObject.parent)==null||A.updateWorldMatrix(!1,!0)}onBeforeRender(){if(super.onBeforeRender(),bsA&&this.gameObject instanceof Os&&this.gameObject.boundingSphere){const A=Xi(this.gameObject.boundingSphere.center).applyMatrix4(this.gameObject.matrixWorld);Re.DrawWireSphere(A,this.gameObject.boundingSphere.radius,"red")}}}class YsA{constructor(){r(this,"objs",[])}setup(A,e,t,g,I,o=0){A.applySettings(e);const s=this.tryCreateOrAddInstance(e,t,I);if(s)A.loadProgressiveTextures(s.instancer.material),g===null&&(g=[]),g.push(s);else if(o<=0&&e.type!=="Mesh"){const n=o+1;for(const C of e.children)g=this.setup(A,C,t,g,I,n)}return o===0&&I.useMatrixWorldAutoUpdate&&g&&g.length>=0&&this.autoUpdateInstanceMatrix(e),g}tryCreateOrAddInstance(A,e,t){if(A.type==="Mesh"){const g=t.foundMeshes;if(t.foundMeshes+=1,!t.rend.enableInstancing||g>=t.rend.enableInstancing.length||!t.rend.enableInstancing[g])return null;const I=A,o=I.geometry,s=I.material;for(const a of this.objs)if(!a.isFull()&&a.geo===o&&a.material===s)return a.addInstance(I);const n=new WD(A.name,o,s,200,e);return this.objs.push(n),n.addInstance(I)}return null}autoUpdateInstanceMatrix(A){const e=A.matrixWorld.multiplyMatrices.bind(A.matrixWorld),t=A.matrixWorld.clone(),g=(I,o)=>{const s=e(I,o);return(A[pd]||t.equals(s)===!1)&&(t.copy(s),A[pd]=!0),s};A.matrixWorld.multiplyMatrices=g}}const _sA=new YsA;class HsA{constructor(A,e,t){r(this,"instanceIndex",-1);r(this,"object");r(this,"instancer");this.instanceIndex=A,this.object=e,this.instancer=t,e[x_]=t,rA.markAsInstancedRendered(e,!0)}get name(){return this.object.name}updateInstanceMatrix(A=!1){this.instanceIndex<0||(this.object.updateWorldMatrix(!0,A),this.instancer.updateInstance(this.object.matrixWorld,this.instanceIndex))}setMatrix(A){this.instanceIndex<0||this.instancer.updateInstance(A,this.instanceIndex)}add(){this.instanceIndex>=0||this.instancer.add(this)}remove(){this.instanceIndex<0||this.instancer.remove(this)}}const oJ=class{constructor(A,e,t,g,I){r(this,"name","");r(this,"geo");r(this,"material");r(this,"context");r(this,"inst");r(this,"handles",[]);r(this,"maxCount");r(this,"_needUpdateBounds",!1);r(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[kG]===!0&&(Bl&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});r(this,"onAfterRender",()=>{this.inst.layers.disableAll()});this.name=A,this.geo=e,this.material=t,this.context=I,this.maxCount=g,Bl&&(t=new Bt({color:this.randomColor()})),this.inst=new Lw(e,t,g),this.inst[kG]=!0,this.inst.count=0,this.inst.visible=!0,this.context.scene.add(this.inst),t instanceof Iu&&(t.defines.USE_INSTANCING=!0,t.needsUpdate=!0),I.pre_render_callbacks.push(this.onBeforeRender),I.post_render_callbacks.push(this.onAfterRender)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(A){this.inst.visible=A}get castShadow(){return this.inst.castShadow}set castShadow(A){this.inst.castShadow=A}set receiveShadow(A){this.inst.receiveShadow=A}updateBounds(A=!0,e=!0){this._needUpdateBounds=!1,A&&this.inst.computeBoundingBox(),e&&this.inst.computeBoundingSphere()}get currentCount(){return this.inst.count}isFull(){return this.currentCount>=this.maxCount}randomColor(){return new wA(Math.random(),Math.random(),Math.random())}addInstance(A){if(this.currentCount>=this.maxCount)return console.error("TOO MANY INSTANCES - resize is not yet implemented!",this.inst.count),null;const e=new HsA(-1,A,this);return A.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),A.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0),this.add(e),e}add(A){A.instanceIndex<0&&(A.instanceIndex=this.currentCount,A.instanceIndex>=this.handles.length?this.handles.push(A):this.handles[A.instanceIndex]=A),A.object.updateWorldMatrix(!0,!0),this.inst.setMatrixAt(A.instanceIndex,A.object.matrixWorld),this.inst.instanceMatrix.needsUpdate=!0,this.inst.count+=1,this._needUpdateBounds=!0,this.inst.count>0&&(this.inst.visible=!0),Bl&&console.log("Added",this.name,this.inst.count)}remove(A){if(!A||A.instanceIndex<0||A.instanceIndex>=this.handles.length||this.inst.count<=0)return;if(this.handles[A.instanceIndex]!==A){console.error("instance handle is not part of renderer, was it removed before?",A.instanceIndex,this.name);const t=this.handles.indexOf(A);if(t<0)return;A.instanceIndex=t}if(this.handles[A.instanceIndex]=null,this.inst.setMatrixAt(A.instanceIndex,oJ.nullMatrix),!(A.instanceIndex>=this.currentCount-1)&&this.currentCount>0){const t=this.handles[this.currentCount-1];t&&(t.instanceIndex=A.instanceIndex,t.updateInstanceMatrix(),this.handles[A.instanceIndex]=t,this.handles[this.currentCount-1]=null)}this.inst.count>0&&(this.inst.count-=1),A.instanceIndex=-1,this._needUpdateBounds=!0,this.inst.count<=0&&(this.inst.visible=!1),this.inst.instanceMatrix.needsUpdate=!0,Bl&&console.log("Removed",this.name,this.inst.count)}updateInstance(A,e){this.inst.setMatrixAt(e,A),this.inst.instanceMatrix.needsUpdate=!0,this._needUpdateBounds=!0}};let WD=oJ;r(WD,"nullMatrix",new mA);var OsA=Object.defineProperty,PsA=Object.getOwnPropertyDescriptor,Si=(i,A,e,t)=>{for(var g=t>1?void 0:t?PsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OsA(A,e,g),g};const wL=IA("debugusdzbehaviours");function Pu(i){i&&(i.getComponentInParent(Fu)||(me()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(vo)))}class dQ extends UA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new y);r(this,"targetRot",new GA);r(this,"targetScale",new y)}start(){Pu(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Je(this.object).clone(),t=Je(this.target).clone(),g=Lt(this.object).clone(),I=Lt(this.target).clone(),o=ui(this.object).clone(),s=ui(this.target).clone(),n=e.distanceTo(t),C=g.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){uI(this.object,t),hs(this.object,I),dd(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),uI(this.object,this.targetPos),hs(this.object,this.targetRot),dd(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),g=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(g,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new Bg("Move to "+((t=this.target)==null?void 0:t.name),Wg.tapTrigger(this.gameObject),ht.transformAction(this.object,this.target,this.duration,this.relativeMotion?rR.Relative:rR.Absolute));e.addBehavior(g)}}}Si([D(pA)],dQ.prototype,"object",2);Si([D(pA)],dQ.prototype,"target",2);Si([D()],dQ.prototype,"duration",2);Si([D()],dQ.prototype,"relativeMotion",2);var QD;const uC=(QD=class extends UA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",[]);r(this,"selfModel");r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=rA.findObjectsOfType(Ji);for(const e of A)for(let t=0;t<e.sharedMaterials.length;t++){const g=e.sharedMaterials[t];if(g===this.materialToSwitch){if(e.gameObject instanceof uA)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof xI)for(const I of e.gameObject.children)I instanceof uA&&I.material===g&&this._objectsWithThisMaterial.push(I);break}}}}start(){Pu(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(A,e){this.targetModels=[],uC._materialTriggersPerId={},uC.variantSwitchIndex=0,this.materialToSwitch&&await lI.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await lI.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(uC._materialTriggersPerId[this.materialToSwitch.uuid]||(uC._materialTriggersPerId[this.materialToSwitch.uuid]=[]),uC._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=uC._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(g[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in g)s!==I.selfModel.uuid&&o.push(...g[s]);I.createAndAttachBehaviors(A,g[I.selfModel.uuid],o)}}delete uC._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);I.push(ht.fadeAction([...this.targetModels,...t],o,!1)),g.push(ht.fadeAction(e,o,!1)),I.push(ht.fadeAction(e,o,!0)),A.addBehavior(new Bg("Select_"+this.selfModel.name,Wg.tapTrigger(this.selfModel),ht.parallel(...I))),A.addBehavior(new Bg("StartHidden_"+this.selfModel.name,Wg.sceneStartTrigger(),ht.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+uC.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&no.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(QD,"_materialTriggersPerId",{}),r(QD,"variantSwitchIndex",0),QD);let Xc=uC;Si([D(xe)],Xc.prototype,"materialToSwitch",2);Si([D(xe)],Xc.prototype,"variantMaterial",2);Si([D()],Xc.prototype,"fadeDuration",2);var cE;const ci=(cE=class extends UA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"selfModelClone");r(this,"targetModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1);r(this,"targetStateBeforeCreatingDocument",!1)}start(){Pu(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ci.wasVisible]===void 0&&(this.gameObject[ci.wasVisible]=this.gameObject.activeSelf),this.target[ci.wasVisible]===void 0&&(this.target[ci.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ci.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ci.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(A,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let g=this.selfModel,I=this.targetState;if(this.toggleOnClick)if(I=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&M1.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ci.toggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggle"+ci.clonedToggleIndex++,t.add(n),this.gameObject[ci.toggleClone]=n,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const s=this.gameObject[ci.toggleClone];if(!this.gameObject[ci.reverseToggleClone]){const n=this.selfModelClone.clone();n.matrix.identity(),n.name+="_toggleReverse"+ci.clonedToggleIndex++,t.add(n),this.gameObject[ci.reverseToggleClone]=n}this.toggleModel=this.gameObject[ci.reverseToggleClone],(!this.toggleModel.geometry||!s.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),g=s,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const s=[];s.push(ht.fadeAction(g,0,!1)),s.push(ht.fadeAction(this.toggleModel,0,!0)),s.push(ht.fadeAction(this.targetModel,0,I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Wg.tapTrigger(g),ht.parallel(...s)));const n=[];n.push(ht.fadeAction(this.toggleModel,0,!1)),n.push(ht.fadeAction(g,0,!0)),n.push(ht.fadeAction(this.targetModel,0,!I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"Off":"On"),Wg.tapTrigger(this.toggleModel),ht.parallel(...n)))}}else{const s=[];this.hideSelf&&s.push(ht.fadeAction(g,0,!1)),s.push(ht.fadeAction(this.targetModel,0,I)),A.addBehavior(new Bg("Toggle_"+g.name+"_toggleTo"+(I?"On":"Off"),Wg.tapTrigger(g),ht.parallel(...s)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(t),this.toggleModel&&o.push(this.toggleModel),A.addBehavior(new Bg("HideOnStart_"+this.gameObject.name,Wg.sceneStartTrigger(),ht.fadeAction(o,0,!1)))}}afterSerialize(A,e){this.gameObject[ci.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ci.wasVisible],delete this.gameObject[ci.wasVisible]),this.target&&this.target[ci.wasVisible]!==void 0&&(this.target.visible=this.target[ci.wasVisible],delete this.target[ci.wasVisible]),delete this.gameObject[ci.toggleClone],delete this.gameObject[ci.reverseToggleClone]}},r(cE,"clonedToggleIndex",0),r(cE,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),r(cE,"toggleClone",Symbol("clone for toggling")),r(cE,"reverseToggleClone",Symbol("clone for reverse toggling")),cE);let uQ=ci;Si([D(pA)],uQ.prototype,"target",2);Si([D()],uQ.prototype,"toggleOnClick",2);Si([D()],uQ.prototype,"targetState",2);Si([D()],uQ.prototype,"hideSelf",2);class bF extends UA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new Bg("HideOnStart_"+this.gameObject.name,Wg.sceneStartTrigger(),ht.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class $c extends UA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType",BF.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new Bg("emphasize "+this.name,Wg.tapTrigger(this.gameObject),ht.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}Si([D()],$c.prototype,"target",2);Si([D()],$c.prototype,"duration",2);Si([D()],$c.prototype,"motionType",2);class Dr extends UA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){Pu(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(wi);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,t,g){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=ur.getName(I),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?QR.NonSpatial:QR.Spatial;let a=!1;if(this.gameObject.traverse(B=>{B instanceof uA&&B.visible&&(a=!0)}),a=!0,a){let B=ht.playAudioAction(o,"audio/"+s,BR.Play,n,C);this.toggleOnClick&&(B.multiplePerformOperation=K1.Stop),this.target&&this.target.loop&&(B=ht.sequence(B).makeLooping());const Q=new Bg("playAudio "+this.name,Wg.tapTrigger(this.gameObject),B);e.addBehavior(Q)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let B=ht.playAudioAction(o,"audio/"+s,BR.Play,n,C);this.target.loop&&(B=ht.sequence(B).makeLooping());const Q=new Bg("playAudioOnStart"+(this.name?"_"+this.name:""),Wg.sceneStartTrigger(),B);e.addBehavior(Q)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const o="audio/"+ur.getName(g);if(t.files[o])return;const C=await(await(await fetch(g)).blob()).arrayBuffer(),a=new Uint8Array(C);t.files[o]=a}}Si([D(wi)],Dr.prototype,"target",2);Si([D(URL)],Dr.prototype,"clip",2);Si([D()],Dr.prototype,"toggleOnClick",2);var ED;const ba=(ED=class extends UA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A;return(A=this.animator)==null?void 0:A.gameObject}start(){Pu(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(ba.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';me()&&yi(A),console.warn(A,...ba.rootsWithExclusivePlayback)}ba.animationActions=[],ba.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,g=e.extensions.find(s=>s instanceof vu);if(!g)return;const I=g.getClipCount(this.target)>1;I&&(me()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+g.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),ba.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=ba.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=ht.startAnimationAction(s,n.start,n.duration),ba.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=ht.sequence();if(this.animationSequence!==void 0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence!==void 0){const Q=a.actions.length==0?a:ht.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new Bg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Wg.tapTrigger(this.selfModel):Wg.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var C,a,B,Q;if(!this.target||!this.animator)return;const g=(C=this.animator)==null?void 0:C.runtimeAnimatorController;let I=g==null?void 0:g.findState(this.stateName),o=[],s=[];if(g&&I){const E=new Array;E.push(I);let c=!1;for(;E.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(a=I.motion)!=null&&a.isLooping&&(c=!0);break}const h=I.transitions.find(l=>l.conditions.length===0),u=h?g.getState(h.destinationState,0):null;if(u&&E.includes(u)){I=u,c=!0;break}else if(h){if(I=u,!I)break;E.push(I)}else{c=((B=I.motion)==null?void 0:B.isLooping)??!1;break}}if(c&&I){const h=E.indexOf(I);o=E.slice(0,h),s=E.slice(h),wL&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=E,s=[],wL&&console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(E=>{var c,h,u;return((c=E.motion)==null?void 0:c.clip)&&((u=(h=E.motion)==null?void 0:h.clip.tracks)==null?void 0:u.length)>0}),s=s.filter(E=>{var c,h,u;return((c=E.motion)==null?void 0:c.clip)&&((u=(h=E.motion)==null?void 0:h.clip.tracks)==null?void 0:u.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((Q=this.animator)==null?void 0:Q.name)+", can't export animation data");return}this.stateAnimationModel=e;const n=(E,c)=>{var u,l,d;if(!this.target)return;if(!((u=E.motion)!=null&&u.clip)){console.warn("No clip found for state "+E.name+" on "+((l=this.animator)==null?void 0:l.name)+", can't export animation data");return}const h=A.registerAnimation(this.target,E.motion.clip);h?c.push(h):console.warn("Couldn't register animation for state "+E.name+" on "+((d=this.animator)==null?void 0:d.name))};if(o.length>0){this.animationSequence=new Array;for(const E of o)n(E,this.animationSequence)}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const E of s)n(E,this.animationLoopAfterSequence)}}},r(ED,"animationActions",[]),r(ED,"rootsWithExclusivePlayback",new Set),ED);let Ah=ba;Si([D(Zg)],Ah.prototype,"animator",2);Si([D()],Ah.prototype,"stateName",2);class eh extends UA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}Si([D(pA)],eh.prototype,"target",2);class Wu extends UA{constructor(){super(...arguments);r(this,"target")}}Si([D(eh)],Wu.prototype,"target",2);class ju extends eh{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Si([D()],ju.prototype,"type",2);Si([D()],ju.prototype,"duration",2);class qF extends Wu{}var WsA=Object.defineProperty,jsA=Object.getOwnPropertyDescriptor,aa=(i,A,e,t)=>{for(var g=t>1?void 0:t?jsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WsA(A,e,g),g};const SL=IA("debugcharactercontroller");class pQ extends UA{constructor(){super(...arguments);r(this,"center",new y(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new y)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ti),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ti)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(pr);t||(t=this.gameObject.addNewComponent(pr)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const g=new y(0,0,1),I=new y(1,0,0),o=new y(0,1,0),s=this.gameObject.getWorldDirection(new y);s.y=0;const n=I.dot(s)<0?-1:1,C=g.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),SL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),SL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const g=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);g&&(this._contactVelocity.x+=g.x,this._contactVelocity.y+=g.y,this._contactVelocity.z+=g.z)}return this._contactVelocity}}aa([D(y)],pQ.prototype,"center",2);aa([D()],pQ.prototype,"radius",2);aa([D()],pQ.prototype,"height",2);class ra extends UA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new gA(0,0));r(this,"moveInput",new gA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new y(0,0,0));r(this,"_currentAngularSpeed",new y(0,0,0));r(this,"_temp",new y(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new ls)}awake(){this._currentRotation=new GA}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,g){var I,o,s,n,C,a,B,Q,E,c,h;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&g),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=se.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const u=this.context.mainCameraComponent.forward;u.y=0,u.normalize(),this._currentRotation.setFromUnitVectors(new y(0,0,1),u),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&g&&this.jumpForce>0){let u=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(u=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),u){this._jumpCount+=1;const l=this.controller.rigidbody,d=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new y(0,1,0).multiplyScalar(d))}}if(this.controller){const u=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(u<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qo),this._raycastOptions.ray.origin.copy(Je(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const d=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(d.length&&d[0].distance>2||u<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}aa([D(pQ)],ra.prototype,"controller",2);aa([D()],ra.prototype,"movementSpeed",2);aa([D()],ra.prototype,"rotationSpeed",2);aa([D()],ra.prototype,"jumpForce",2);aa([D()],ra.prototype,"doubleJumpForce",2);aa([D(Zg)],ra.prototype,"animator",2);var VsA=Object.defineProperty,zsA=Object.getOwnPropertyDescriptor,ZsA=(i,A,e,t)=>{for(var g=t>1?void 0:t?zsA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&VsA(A,e,g),g};class Vu extends DI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new tH;return e.offset=new gA(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}ZsA([D(be)],Vu.prototype,"intensity",2);ys("ChromaticAberration",Vu);const zu=new fe;zu.setAttribute("position",new ie(new Float32Array([-1,-1,3,-1,-1,3]),2));zu.setAttribute("uv",new ie(new Float32Array([0,0,2,0,0,2]),2));zu.boundingSphere=new Oi;zu.computeBoundingSphere=function(){};const XsA=new ia;class sB{constructor(A){this._mesh=new uA(zu,A),this._mesh.frustumCulled=!1}render(A){A.render(this._mesh,XsA)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const $sA={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new mA},viewMat:{value:new mA},projViewMat:{value:new mA},projectionMatrixInv:{value:new mA},viewMatrixInv:{value:new mA},cameraPos:{value:new y},resolution:{value:new gA},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 hnA=Object.defineProperty,lnA=Object.getOwnPropertyDescriptor,$u=(i,A,e,t)=>{for(var g=t>1?void 0:t?lnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&hnA(A,e,g),g};const Ok=IA("debugcontactshadows");class qr extends UA{constructor(){super(...arguments);r(this,"darkness",.5);r(this,"opacity",.5);r(this,"blur",4);r(this,"occludeBelowGround",!0);r(this,"backfaceShadows",!0);r(this,"shadowCamera");r(this,"shadowGroup");r(this,"renderTarget");r(this,"renderTargetBlur");r(this,"plane");r(this,"occluderMesh");r(this,"blurPlane");r(this,"depthMaterial");r(this,"horizontalBlurMaterial");r(this,"verticalBlurMaterial")}awake(){Ok&&console.log("Create ContactShadows on "+this.gameObject.name,this);const e=512;this.shadowGroup=new xI,this.gameObject.add(this.shadowGroup),this.renderTarget=new At(e,e),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new At(e,e),this.renderTargetBlur.texture.generateMipmaps=!1;const t=new ug(1,1).rotateX(Math.PI/2);if(this.gameObject instanceof uA){Ok&&console.log("ContactShadows: use existing mesh",this.gameObject),this.plane=this.gameObject;const g=this.plane.material=this.plane.material.clone();g.map=this.renderTarget.texture,g.opacity=this.opacity}else{const g=new Bt({map:this.renderTarget.texture,opacity:this.opacity,color:0,transparent:!0,depthWrite:!1});this.plane=new uA(t,g),this.plane.scale.y=-1,this.gameObject.add(this.plane)}this.plane&&(this.plane.renderOrder=1),this.occludeBelowGround&&(this.occluderMesh=new uA(this.plane.geometry,new Bt({depthWrite:!0,stencilWrite:!0,colorWrite:!1})).translateY(-1e-4),this.occluderMesh.renderOrder=-100,this.gameObject.add(this.occluderMesh)),this.blurPlane=new uA(t),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane),this.shadowCamera=new ia(-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 eu,this.depthMaterial.userData.darkness={value:this.darkness},this.depthMaterial.blending=HR,this.depthMaterial.blendEquation=oy,this.backfaceShadows&&(this.depthMaterial.side=mt),this.depthMaterial.onBeforeCompile=g=>{this.depthMaterial&&(g.uniforms.darkness=this.depthMaterial.userData.darkness,g.fragmentShader=`
|
|
6301
6301
|
uniform float darkness;
|
|
6302
6302
|
${g.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 Fe(EnA),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Fe(cnA),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,g,I,o,s,n,C;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(g=this.depthMaterial)==null||g.dispose(),(I=this.horizontalBlurMaterial)==null||I.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(s=this.blurPlane)==null||s.geometry.dispose(),(n=this.plane)==null||n.geometry.dispose(),(C=this.occluderMesh)==null||C.geometry.dispose()}onBeforeRender(e){const t=this.context.scene,g=this.context.renderer,I=g.getRenderTarget();if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){Ok&&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 uA&&(this.gameObject.visible=!1,fE(this.gameObject,!1));const s=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const n=g.getClearAlpha();g.setClearAlpha(0),g.setRenderTarget(this.renderTarget),g.render(t,this.shadowCamera),t.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,g.setRenderTarget(I),g.setClearAlpha(n),t.background=s}blurShadow(e){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=e*1/256;const t=this.context.renderer,g=t.getRenderTarget();t.setRenderTarget(this.renderTargetBlur),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=e*1/256,t.setRenderTarget(this.renderTarget),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,t.setRenderTarget(g)}}$u([D()],qr.prototype,"darkness",2);$u([D()],qr.prototype,"opacity",2);$u([D()],qr.prototype,"blur",2);$u([D()],qr.prototype,"occludeBelowGround",2);$u([D()],qr.prototype,"backfaceShadows",2);var dnA=Object.defineProperty,unA=Object.getOwnPropertyDescriptor,Ap=(i,A,e,t)=>{for(var g=t>1?void 0:t?unA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&dnA(A,e,g),g};const mL=IA("debugwebxr"),pnA=new mA().makeRotationY(Math.PI);class bo extends UA{constructor(){super(...arguments);r(this,"_arScale",1);r(this,"invertForward",!1);r(this,"customReticle");r(this,"useXRAnchor",!1);r(this,"arTouchTransform",!1);r(this,"_isPlacing",!0);r(this,"_startOffset",new mA);r(this,"_createdPlacementObject",null);r(this,"_reparentedComponents",[]);r(this,"_placementScene",new pI);r(this,"_reticle",[]);r(this,"_hits",[]);r(this,"_placementStartTime",-1);r(this,"_rigPlacementMatrix");r(this,"_anchor",null);r(this,"userInput");r(this,"onPlaceScene",e=>{var I;if(this._isPlacing==!1)return;let t=this._reticle[0],g=this._hits[0];if(e.origin instanceof ON){const o=this._reticle[e.origin.index];o&&(t=o,g=this._hits[e.origin.index])}if(!t){console.warn("No reticle to place...");return}if(!t.visible){console.warn("Reticle is not visible (can not place)");return}if((I=ue.active)!=null&&I.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}e.stopImmediatePropagation(),e.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(t),this.useXRAnchor&&this.onCreateAnchor(ue.active,g)})}get arScale(){return this._arScale}set arScale(e){e!==this._arScale&&(this._arScale=e,this.onScaleChanged())}onEnable(){var e;(e=this.customReticle)==null||e.preload()}supportsXR(e){return e==="immersive-ar"}onEnterXR(e){mL&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const t=new pA;this._createdPlacementObject=t,t.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let g=this.context.scene.children.length-1;g>=0;g--){const I=this.context.scene.children[g];this._placementScene.add(I)}this.context.scene.add(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),rA.addComponent(t,this);for(const g of this._reticle)Vs(g);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,un.Early)}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,un.Early),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,g,I,o;if(e.xr.isTrackingImages){for(const s of this._reticle)s.visible=!1;return}if(this._isPlacing){const s=(t=e.xr.rig)==null?void 0:t.gameObject;s&&s.parent!==this.context.scene&&this.context.scene.add(s);let n=!1;if(e.xr.isPassThrough&&e.xr.controllers.length>0)for(const C of e.xr.controllers){const a=C.getHitTest();a&&(n=!0,this.updateReticleAndHits(e.xr,C.index,a,e.xr.rigScale))}if(!n){const C=e.xr.getHitTest();C&&this.updateReticleAndHits(e.xr,0,C,e.xr.rigScale)}}else{if(this._anchor&&e.xr.referenceSpace){const s=e.xr.frame.getPose(this._anchor.anchorSpace,e.xr.referenceSpace);if(s&&this.context.time.frame%20===0){const n=e.xr.convertSpace(s.transform),C=this._reticle[0];C&&(C.position.copy(n.position),C.quaternion.copy(n.quaternion),this.onApplyPose(C))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new DE(this.context)),(g=this.userInput)==null||g.enable()):(I=this.userInput)==null||I.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(e.xr.rig){const s=e.xr.rig.gameObject;this.userInput.applyMatrixTo(s.matrix,!0),s.matrix.decompose(s.position,s.quaternion,s.scale),this.userInput.factor=s.scale.x}this.userInput.reset()}}}updateReticleAndHits(e,t,g,I){this._hits[t]=g.hit;let o=this._reticle[t];if(!o){if(this.customReticle)if(this.customReticle.asset)o=qc(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new uA(new zB(.07,.09,32).rotateX(-Math.PI/2),new Bt({side:mt})),o.name="AR Placement Reticle";if(mL){const s=new Es(1);s.position.y+=.01,o.add(s)}this._reticle[t]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(g.position,this.context.time.deltaTime/.1),o.quaternion.slerp(g.quaternion,this.context.time.deltaTime/.05),o.scale.set(I,I,I),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 e;for(const t of this._reticle)t&&(t.visible=!1,t==null||t.removeFromParent());this._reticle.length=0;for(let t=this._placementScene.children.length-1;t>=0;t--){const g=this._placementScene.children[t];this.context.scene.add(g)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)rA.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),me()&&yi("Hit does not support creating an anchor");return}else{const g=await t.createAnchor(e.viewerPose.transform);e.running&&g&&(this._anchor=g)}}applyViewBasedTransform(e){const t=this.context.mainCamera,g=e,I=t.worldPosition,o=g.worldPosition;I.y=o.y,e.lookAt(I)}onApplyPose(e){var g,I,o,s;const t=(I=(g=ue.active)==null?void 0:g.rig)==null?void 0:I.gameObject;if((o=ue.active)!=null&&o.rigScale,t){const n=t.parent||this.context.scene;this._rigPlacementMatrix?(s=this._rigPlacementMatrix)==null||s.decompose(t.position,t.quaternion,t.scale):this._rigPlacementMatrix=t.matrix.clone(),this.applyViewBasedTransform(e),e.updateMatrix(),this.context.scene.add(e),e.attach(t),e.removeFromParent(),t.scale.set(this.arScale,this.arScale,this.arScale),t.position.multiplyScalar(this.arScale),t.updateMatrix(),this.invertForward&&t.matrix.premultiply(pnA),t.matrix.premultiply(this._startOffset),t.matrix.decompose(t.position,t.quaternion,t.scale),n.add(t)}}}Ap([D()],bo.prototype,"arScale",1);Ap([D()],bo.prototype,"invertForward",2);Ap([D(It)],bo.prototype,"customReticle",2);Ap([D()],bo.prototype,"useXRAnchor",2);Ap([D()],bo.prototype,"arTouchTransform",2);const yw=class{constructor(A){r(this,"oneFingerDrag",!0);r(this,"twoFingerRotate",!0);r(this,"twoFingerScale",!0);r(this,"factor",1);r(this,"context");r(this,"offset");r(this,"plane");r(this,"_scale",1);r(this,"_hasChanged",!1);r(this,"_enabled",!1);r(this,"currentlyUsedPointerIds",new Set);r(this,"currentlyUnusedPointerIds",new Set);r(this,"onPointerDownEarly",A=>{this.isActive&&A.stopPropagation()});r(this,"onPointerDownLate",A=>{A.used?this.currentlyUsedPointerIds.add(A.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(A.pointerId)});r(this,"onPointerUpEarly",A=>{this.currentlyUsedPointerIds.delete(A.pointerId),this.currentlyUnusedPointerIds.delete(A.pointerId)});r(this,"prev",new Map);r(this,"_didMultitouch",!1);r(this,"touchStart",A=>{for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e];this.prev.has(t.identifier)||this.prev.set(t.identifier,{x:0,z:0,screenx:0,screeny:0});const g=this.prev.get(t.identifier);if(g){const I=this.getPositionOnPlane(t.clientX,t.clientY);g.x=I.x,g.z=I.z,g.screenx=t.clientX,g.screeny=t.clientY}}});r(this,"touchEnd",A=>{A.touches.length<=0&&(this._didMultitouch=!1)});r(this,"touchMove",A=>{if(!A.defaultPrevented&&this.isActive){if(A.touches.length===1){if(this._didMultitouch)return;const e=A.touches[0],t=this.prev.get(e.identifier);if(!t)return;const g=this.getPositionOnPlane(e.clientX,e.clientY),I=g.x-t.x,o=g.z-t.z;if(I===0&&o===0)return;this.oneFingerDrag&&this.addMovement(I,o),t.x=g.x,t.z=g.z,t.screenx=e.clientX,t.screeny=e.clientY;return}else if(A.touches.length===2){this._didMultitouch=!0;const e=A.touches[0],t=A.touches[1],g=this.prev.get(e.identifier),I=this.prev.get(t.identifier);if(!g||!I)return;if(this.twoFingerRotate){const o=Math.atan2(e.clientY-t.clientY,e.clientX-t.clientX),s=Math.atan2(g.screeny-I.screeny,g.screenx-I.screenx),n=o-s;Math.abs(n)>.001&&this.addRotation(n)}if(this.twoFingerScale){const o=e.clientX-t.clientX,s=e.clientY-t.clientY,n=Math.sqrt(o*o+s*s),C=g.screenx-I.screenx,a=g.screeny-I.screeny,B=Math.sqrt(C*C+a*a),Q=n-B;Math.abs(Q)>2&&this.addScale(Q)}g.screenx=e.clientX,g.screeny=e.clientY,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"_raycaster",new Gc);r(this,"_intersection",new y);r(this,"_screenPos",new y);r(this,"_tempMatrix",new mA);this.context=A,this.offset=new mA,this.plane=new vI,this.plane.setFromNormalAndCoplanarPoint(yw.up,yw.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(A,e){this._hasChanged=!1,e?(this.offset.invert(),A.premultiply(this.offset)):A.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,un.Early),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,un.Late),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,un.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,un.Early),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,un.Late),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,un.Early),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(A,e){const t=this.context.mainCamera;return this._screenPos.x=A/window.innerWidth*2-1,this._screenPos.y=-(e/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(t),this._raycaster.set(t.position,this._screenPos.sub(t.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(A,e){A/=this._scale,e/=this._scale,A*=this.factor,e*=this.factor,this.offset.elements[12]+=A,this.offset.elements[14]+=e,(A!==0||e!==0)&&(this._hasChanged=!0)}addScale(A){A/=window.innerWidth,A*=-1,this._scale*=1+A,this._tempMatrix.makeScale(1-A,1-A,1-A),this.offset.premultiply(this._tempMatrix),A!==0&&(this._hasChanged=!0)}addRotation(A){A*=-1,this._tempMatrix.makeRotationY(A),this.offset.premultiply(this._tempMatrix),A!==0&&(this._hasChanged=!0)}};let DE=yw;r(DE,"up",new y(0,1,0)),r(DE,"zero",new y(0,0,0)),r(DE,"one",new y(1,1,1));const sJ=class{constructor(){r(this,"_quicklookButton");r(this,"_arButton");r(this,"_vrButton");r(this,"_sendToQuestButton");r(this,"_qrButton")}static create(){return new sJ}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 A=document.createElement("button");return this._quicklookButton=A,A.dataset.needle="quicklook-button",A.innerText="Open in Quicklook",A.addEventListener("click",()=>{const e=rA.findObjectOfType(lg);e?(A.classList.add("this-mode-is-requested"),e.exportAsync().then(()=>{A.classList.remove("this-mode-is-requested")}).catch(t=>{A.classList.remove("this-mode-is-requested"),console.error(t)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(A),A}createARButton(A){var g;if(this._arButton)return this._arButton;const e="immersive-ar",t=document.createElement("button");return this._arButton=t,t.classList.add("webxr-button"),t.dataset.needle="webxr-ar-button",t.innerText="Enter AR",t.title="Click to start a WebXR session in AR",t.addEventListener("click",()=>ue.start(e,A)),this.updateSessionSupported(t,e),this.listenToXRSessionState(t,e),this.hideElementDuringXRSession(t),this.isSecureConnection||(t.disabled=!0,t.title="WebXR requires a secure connection (HTTPS)"),bB()||(g=navigator.xr)==null||g.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createVRButton(A){var g;if(this._vrButton)return this._vrButton;const e="immersive-vr",t=document.createElement("button");return this._vrButton=t,t.classList.add("webxr-button"),t.dataset.needle="webxr-vr-button",t.innerText="Enter VR",t.title="Click to start a WebXR session in VR",t.addEventListener("click",()=>ue.start(e,A)),this.updateSessionSupported(t,e),this.listenToXRSessionState(t,e),this.hideElementDuringXRSession(t),this.isSecureConnection||(t.disabled=!0,t.title="WebXR requires a secure connection (HTTPS)"),bB()||(g=navigator.xr)==null||g.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createSendToQuestButton(){var t;if(this._sendToQuestButton)return this._sendToQuestButton;const A="https://oculus.com/open_url/?url=",e=document.createElement("button");return this._sendToQuestButton=e,e.dataset.needle="webxr-sendtoquest-button",e.innerText="Open on Quest",e.title="Click to send this page to the Oculus Browser on your Quest",e.addEventListener("click",()=>{const g=encodeURIComponent(window.location.href);window.open(A+g)}),this.listenToXRSessionState(e),this.hideElementDuringXRSession(e),bB()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>{var g;(g=navigator.xr)!=null&&g.isSessionSupported("immersive-vr")?e.style.display="none":e.style.display=""}),e}createQRCode(){if(this._qrButton)return this._qrButton;const A=document.createElement("button");this._qrButton=A,A.innerText="QR Code",A.title="Scan this QR code with your phone to open this page",this.hideElementDuringXRSession(A);const e=document.createElement("div");e.style.position="fixed",e.style.display="inline-block",e.style.padding="1rem",e.style.backgroundColor="white",e.style.borderRadius="0.4rem",e.style.cursor="pointer",e.style.zIndex="1000",e.style.boxShadow="0 0 12px rgba(0, 0, 0, 0.2)";const t=document.createElement("div");t.classList.add("qr-code-container"),e.appendChild(t),A.addEventListener("click",()=>{if(e.parentNode)return I();g()});async function g(){await o(),document.body.appendChild(e);const s=t.getBoundingClientRect(),n=A.getBoundingClientRect();e.style.left=n.left+n.width*.5-s.width*.5+"px",n.top<s.height?e.style.top=`calc(${n.bottom}px + ${e.style.padding} * .6)`:e.style.top=`calc(${n.top-s.height}px - ${e.style.padding} * 2.5)`,setTimeout(()=>window.addEventListener("click",I,{once:!0})),window.addEventListener("resize",I),window.addEventListener("scroll",I),document.body.appendChild(e)}function I(){var s;(s=e.parentNode)==null||s.removeChild(e),window.removeEventListener("click",I),window.removeEventListener("resize",I),window.removeEventListener("scroll",I)}async function o(){const n=await zY({text:window.location.href,width:200,height:200});t.innerHTML="",t.appendChild(n)}return A.addEventListener("pointerenter",()=>{o()},{once:!0}),A}updateSessionSupported(A,e){if(!("xr"in navigator)){A.style.display="none";return}ue.isSessionSupported(e).then(t=>{A.style.display=t?"":"none",me()&&!t&&console.warn(e+" is not supported on this device - make sure your server runs using HTTPS and you have a device connected that supports "+e)})}hideElementDuringXRSession(A){ue.onXRSessionStart(e=>{A["previous-display"]=A.style.display,A.style.display="none"}),ue.onXRSessionEnd(e=>{A["previous-display"]!=null&&(A.style.display=A["previous-display"])})}listenToXRSessionState(A,e){e&&(ue.onSessionRequestStart(t=>{t.mode===e?A.classList.add("this-mode-is-requested"):(A["was-disabled"]=A.disabled,A.disabled=!0,A.classList.add("other-mode-is-requested"))}),ue.onSessionRequestEnd(t=>{A.classList.remove("this-mode-is-requested"),A.classList.remove("other-mode-is-requested"),A.disabled=A["was-disabled"]}))}};let Cr=sJ;r(Cr,"_instance");var fnA=Object.defineProperty,DnA=Object.getOwnPropertyDescriptor,Ba=(i,A,e,t)=>{for(var g=t>1?void 0:t?DnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&fnA(A,e,g),g};const nB=IA("debugtext");var Cg=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Cg||{}),QP=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(QP||{});class VI extends hQ{constructor(){super(...arguments);r(this,"alignment",0);r(this,"verticalOverflow",0);r(this,"horizontalOverflow",0);r(this,"lineSpacing",1);r(this,"supportRichText",!1);r(this,"font");r(this,"fontStyle",0);r(this,"sRGBTextColor",new wA(1,0,1));r(this,"_text","");r(this,"_fontSize",12);r(this,"_textMeshUi",null);r(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(e=this.uiObject)==null||e.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(e){this.updateOverflow()}updateOverflow(){var t;const e=(t=this.uiObject)==null?void 0:t._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(e){nB&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,nB&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),nB&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){var e;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(e=this.canvas)==null||e.registerEventReceiver(this)}onDisable(){var e;super.onDisable(),(e=this.canvas)==null||e.unregisterEventReceiver(this)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var g,I,o;if(nB&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let s=this.getNextTag(e);if(s){if(s.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const B=this.uiObject.children[a];B.isUI&&(this.uiObject.remove(B),B.clear())}const C=new yD({textContent:e.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(C)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const n=[];for(;s;){const C=this.getNextTag(e,s.endIndex),a={fontFamily:(g=this.uiObject)==null?void 0:g.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(e,s,C),this.handleTag(s,a,n);const B=new yD(a);(I=this.uiObject)==null||I.add(B)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,n);const B=new yD(a);(o=this.uiObject)==null||o.add(B)}s=C}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,g={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(zy(s,g),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,g){if(!e.isEndTag){if(e.type.includes("color")){const I=new Pk(e,{color:t.color});if(g.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new wA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new Pk(e,{fontWeight:700});g.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new Pk(e,{fontStyle:"italic"});g.push(I)}}}getText(e,t,g){return e.substring(t.endIndex,g.startIndex)}getNextTag(e,t=0){const g=e.indexOf("<",t),I=e.indexOf(">",g);if(g>=0&&I>=0){const o=e.substring(g+1,I);return{type:o,startIndex:g,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const g=this.font,I=this.getFamilyNameWithCorrectSuffix(g,t);nB&&console.log("Selected font family:"+I);let o=DG.getFontFamily(I);switch(o||(o=DG.addFontFamily(I)),e.fontFamily=o,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let s=o.getVariant(e.fontWeight,e.fontStyle);if(!s){let n=I;n!=null&&n.endsWith("-msdf.json")||(n+="-msdf.json");let C=I;C!=null&&C.endsWith(".png")||(C+=".png"),s=o.addVariant(e.fontWeight,e.fontStyle,n,C),s==null||s.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var a;const g=e.lastIndexOf("-");if(g<0)return e;const I=(a=e.substring(g+1))==null?void 0:a.toLowerCase();if(ynA.includes(I))return nB&&console.warn("Unsupported font style: "+I),e;const o=e.lastIndexOf("/");let s=e;o>=0&&(s=s.substring(o+1));const n=s[0]===s[0].toUpperCase(),C=e.substring(0,g);switch(nB&&console.log("Select font: ",e,QP[t],s,n,C),t){case 0:return n?C+"-Regular":C+"-regular";case 1:return n?C+"-Bold":C+"-bold";case 2:return n?C+"-Italic":C+"-italic";case 3:return n?C+"-BoldItalic":C+"-bolditalic";default:return e}}}Ba([D()],VI.prototype,"alignment",2);Ba([D()],VI.prototype,"verticalOverflow",2);Ba([D()],VI.prototype,"horizontalOverflow",2);Ba([D()],VI.prototype,"lineSpacing",2);Ba([D()],VI.prototype,"supportRichText",2);Ba([D(URL)],VI.prototype,"font",2);Ba([D()],VI.prototype,"fontStyle",2);Ba([D()],VI.prototype,"text",1);Ba([D()],VI.prototype,"fontSize",1);class Pk{constructor(A,e){r(this,"tag");r(this,"previousValues");this.tag=A,this.previousValues=e}}const ynA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class $a{constructor(A){r(this,"id");r(this,"content","");r(this,"font",[]);r(this,"pointSize",144);r(this,"width");r(this,"height");r(this,"depth");r(this,"wrapMode");r(this,"horizontalAlignment");r(this,"verticalAlignment");r(this,"material");this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var g;e.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),e.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),e.closeBlock(")"),e.beginBlock(),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(g=this.font)==null||g.push("sans-serif"));const t=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${t} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </StageRoot/Materials/${rF(this.material)}>`),e.closeBlock()}}r($a,"global_id",0);class t0{static singleLine(A,e,t){const g=new $a("text_"+$a.getId());return g.content=A,e&&(g.pointSize=e),t&&(g.depth=t),g}static multiLine(A,e,t,g,I,o){const s=new $a("text_"+$a.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const wnA=new mA().makeRotationY(Math.PI),SnA=new mA().makeScale(-1,1,-1);class ep{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const g=rA.getComponent(A,VI);if(!g)return;const I=rA.getComponent(A,PI);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=wnA.clone(),I&&e.matrix.premultiply(SnA);const n=g.color.clone();e.material=new ao({color:n,emissive:n}),e.addEventListener("serialize",(C,a)=>{let B=g.text;B=B.replace(/\r/g,""),B=B.replace(/\n/g,"\\n");const Q=t0.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,C)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case Cg.LowerLeft:case Cg.MiddleLeft:case Cg.UpperLeft:A.horizontalAlignment="left";break;case Cg.LowerCenter:case Cg.MiddleCenter:case Cg.UpperCenter:A.horizontalAlignment="center";break;case Cg.LowerRight:case Cg.MiddleRight:case Cg.UpperRight:A.horizontalAlignment="right";break}switch(e){case Cg.LowerLeft:case Cg.LowerCenter:case Cg.LowerRight:A.verticalAlignment="bottom";break;case Cg.MiddleLeft:case Cg.MiddleCenter:case Cg.MiddleRight:A.verticalAlignment="middle";break;case Cg.UpperLeft:case Cg.UpperCenter:case Cg.UpperRight:A.verticalAlignment="top";break}}}class i0{get extensionName(){return"tmui"}onExportObject(A,e,t){const g=rA.getComponent(A,Xg);if(g&&g.activeAndEnabled&&g.renderMode===iP.WorldSpace){const I=new ep,o=rA.getComponent(A,PI),s=rA.getComponent(A,fr);if(o){o.width,o.height;const n=no.createEmpty(),C=o.shadowComponent;if(e.add(n),C){const a=C.matrix;n.matrix.copy(a);const B=new Map,Q=new Map;B.set(C,n),Q.set(C,s?s.alpha:1),C.traverse(E=>{if(E===C)return;const c=no.createEmpty();c.matrix.copy(E.matrix);const h=E.parent,u=!!h&&typeof h.textContent=="string"&&h.textContent.length>0;let l=Q.get(h)||1;const d=rA.getComponent(E,fr);if(d&&(l*=d.alpha),E instanceof uA&&u){const f=E[os];f?I.exportText(f.gameObject,c,t):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",E)}if(E instanceof uA&&!u){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),c.geometry=f;const S=new wA,k=E.material.opacity;S.copy(E.material.color),c.material=new Bt({color:S,opacity:k*l,map:E.material.map,transparent:!0})}B.set(E,c),Q.set(E,l);const p=B.get(h);if(!p){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}p.add(c)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,g=e.length/3;t<g;t++){const I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}const Vf=IA("debugusdz");function mnA(i,A){var o;const e=[],t=rA.getComponentsInChildren(i,Zg),g=rA.getComponentsInChildren(i,Jo),I=new Array;if(A.injectImplicitBehaviours)for(const s of t){if(!s||!s.runtimeAnimatorController)continue;const n=s.runtimeAnimatorController.activeState;if(!n||!n.motion||!n.motion.clip||((o=n.motion.clip.tracks)==null?void 0:o.length)<1)continue;const C=new Ah;C.animator=s,C.stateName=n.name,C.trigger="start",C.name="PlayAnimationOnClick_implicitAtStart_"+C.stateName;const a=new pA;rA.addComponent(a,C),I.push(a),i.add(a)}else for(const s of t){if(!s||!s.runtimeAnimatorController)continue;Vf&&console.log(s);const n=[];for(const C of s.runtimeAnimatorController.enumerateActions()){Vf&&console.log(C);const a=C.getClip();n.includes(a)||n.push(a)}e.push({root:s.gameObject,clips:n})}for(const s of g){Vf&&console.log(s);const n=[];for(const C of s.animations)n.includes(C)||n.push(C);e.push({root:s.gameObject,clips:n})}Vf&&console.log("USDZ Animation Clips",e);for(const s of e)for(const n of s.clips)A.registerAnimation(s.root,n);return I}function knA(i,A){const e=rA.getComponentsInChildren(i,wi),t=rA.getComponentsInChildren(i,Dr),g=new Array;for(const I of t){if(!I.target)continue;const o=e.indexOf(I.target);o>-1&&e.splice(o,1)}for(const I of e){if(!I||!I.clip||I.volume<=0)continue;const o=new Dr;o.target=I,o.name="PlayAudioOnClick_implicitAtStart_";const s=new pA;rA.addComponent(s,o),console.log("implicit PlayAudioOnStart",s,o),g.push(s),i.add(s)}return g}function kL(i){const A=i.domElement.shadowRoot.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const t=document.createElement("button");t.id="open-in-ar",t.innerText="Open in QuickLook",e.appendChild(t);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),i.domElement.shadowRoot.appendChild(e),g}var MnA=Object.defineProperty,GnA=Object.getOwnPropertyDescriptor,yI=(i,A,e,t)=>{for(var g=t>1?void 0:t?GnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&MnA(A,e,g),g};const Ao=IA("debugusdz");class Lr{constructor(){r(this,"callToAction");r(this,"checkoutTitle");r(this,"checkoutSubtitle");r(this,"callToActionURL")}}yI([D()],Lr.prototype,"callToAction",2);yI([D()],Lr.prototype,"checkoutTitle",2);yI([D()],Lr.prototype,"checkoutSubtitle",2);yI([D()],Lr.prototype,"callToActionURL",2);var yM;const yR=(yM=class extends UA{constructor(){super(...arguments);r(this,"objectToExport");r(this,"autoExportAnimations",!1);r(this,"autoExportAudioSources",!0);r(this,"exportFileName");r(this,"customUsdzFile");r(this,"customBranding");r(this,"anchoringType","plane");r(this,"maxTextureSize",2048);r(this,"planeAnchoringAlignment","horizontal");r(this,"interactive",!0);r(this,"allowCreateQuicklookButton",!0);r(this,"quickLookCompatible",!0);r(this,"extensions",[]);r(this,"link");r(this,"button");r(this,"onClickedOpenInARElement",A=>{A.preventDefault(),this.exportAsync()});r(this,"lastCallback")}start(){var A,e,t;Ao&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",g=>{switch(g.key){case"t":this.exportAsync();break}}),Pn()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(A=this.objectToExport)==null?void 0:A.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new ZS),this.extensions.push(new ur),this.extensions.push(new ep),this.extensions.push(new i0))}onEnable(){var t;const A=Rc(),e=YE();(Ao||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=kL(this.context),this.link.addEventListener("message",this.lastCallback)),Ao&&fi("USDZ Exporter enabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var A,e,t;(A=this.button)==null||A.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),Ao&&fi("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var t;let A=this.exportFileName??((t=this.objectToExport)==null?void 0:t.name)??this.name;if(A+="-"+S1(),HC()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=kL(this.context)),this.customUsdzFile){Ao&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,A);return}const e=await this.export(this.objectToExport);if(!e){console.warn("No object to export",this);return}Ao&&console.log("USDZ generation done. Downloading as "+this.link.download),this.openInQuickLook(e,A)}async export(A){if(!A)return null;nt.start("export-usdz",{onProgress:c=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:c}}))}}),nt.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),nt.report("export-usdz",{message:"Load progressive textures",autoStep:5}),nt.start("export-usdz-textures","export-usdz");const e=rA.getComponentsInChildren(A,Ji),t=new Array;let g=0;for(const c of e)for(const h of c.sharedMaterials)if(h){const u=c.loadProgressiveTextures(h);u instanceof Promise&&t.push(new Promise((l,d)=>{u.then(()=>{g++,nt.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:g,totalSteps:t.length}),l()}).catch(p=>d(p))}))}Ao&&fi("Load textures: "+t.length),await Promise.all(t),Ao&&fi("Load textures: done"),nt.end("export-usdz-textures");const I=Og.Global.Mask;Og.Global.Set(yn.AR),this.applyWebARSessionRoot();const o=new PgA,s=[...this.extensions],n=new vu(this.quickLookCompatible);s.push(n);const C={self:this,exporter:o,extensions:s,object:A};nt.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:C})),nt.report("export-usdz","auto export animations and audio sources");const a=new Array;this.autoExportAnimations&&a.push(...mnA(A,n)),this.extensions.find(c=>c.extensionName==="Audio")&&this.autoExportAudioSources&&a.push(...knA(A)),o.debug=Ao,o.keepObject=c=>{const h=rA.getComponent(c,Ji);return!(h&&!h.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"),nt.report("export-usdz","Invoking exporter.parse");const Q=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:s,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),E=new Blob([Q],{type:"vnd.usdz+zip"});for(const c of a)rA.destroy(c);return nt.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:C})),Og.Global.Set(I),nt.end("export-usdz"),E}openInQuickLook(A,e){const t=A instanceof Blob?URL.createObjectURL(A):A,g=this.buildQuicklookOverlay();Ao&&console.log("QuickLook Overlay",g);const I=g.callToAction?encodeURIComponent(g.callToAction):"",o=g.checkoutTitle?encodeURIComponent(g.checkoutTitle):"",s=g.checkoutSubtitle?encodeURIComponent(g.checkoutSubtitle):"";this.link.href=t+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${g.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(A,e){yR.save(A,e)}static save(A,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof A=="string"?t.href=A:t.href=URL.createObjectURL(A),t.download=e,t.click(),t.remove()}quicklookCallback(A){if((A==null?void 0:A.data)=="_apple_ar_quicklook_button_tapped"){Ao&&yi("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const t=new URLSearchParams(this.link.href);if(t){const g=t.get("callToActionURL");Ao&&fi("Quicklook url: "+g),g&&(HC()?globalThis.open(g,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",g))}}}}buildQuicklookOverlay(){var t,g,I,o,s,n;const A={};return this.customBranding&&Object.assign(A,this.customBranding),HC()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),A.callToAction="Close",A.checkoutTitle="๐ต Made with Needle",A.checkoutSubtitle="_"),(((t=A.callToAction)==null?void 0:t.length)||((g=A.checkoutTitle)==null?void 0:g.length)||((I=A.checkoutSubtitle)==null?void 0:I.length))&&((o=A.callToAction)!=null&&o.length||(A.callToAction="\0"),(s=A.checkoutTitle)!=null&&s.length||(A.checkoutTitle="\0"),(n=A.checkoutSubtitle)!=null&&n.length||(A.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:A})),A}applyWebARSessionRoot(){if(!this.objectToExport)return;let A=rA.getComponentInParent(this.objectToExport,bo);const e=A!=null;if(A||(A=rA.getComponentInChildren(this.objectToExport,bo)),Ao&&console.log("applyWebARSessionRoot",A),!A){Ao&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:A.gameObject,g=1/A.arScale;t.matrix.makeScale(g,g,g),A.invertForward&&t.matrix.multiply(yR.invertForwardMatrix)}createQuicklookButton(){const e=Cr.getOrCreate().createQuicklookButton();return e.parentNode||this.context.menu.appendChild(e),e}},r(yM,"invertForwardMatrix",new mA().makeRotationY(Math.PI)),yM);let lg=yR;yI([D(pA)],lg.prototype,"objectToExport",2);yI([D()],lg.prototype,"autoExportAnimations",2);yI([D()],lg.prototype,"autoExportAudioSources",2);yI([D()],lg.prototype,"exportFileName",2);yI([D(URL)],lg.prototype,"customUsdzFile",2);yI([D(Lr)],lg.prototype,"customBranding",2);yI([D()],lg.prototype,"anchoringType",2);yI([D()],lg.prototype,"maxTextureSize",2);yI([D()],lg.prototype,"planeAnchoringAlignment",2);yI([D()],lg.prototype,"interactive",2);yI([D()],lg.prototype,"allowCreateQuicklookButton",2);yI([D()],lg.prototype,"quickLookCompatible",2);class tp extends UA{constructor(){super(...arguments);r(this,"isUsed",!0);r(this,"usedBy",null)}}class LF extends UA{}const ML=IA("debugdeletable");class g0 extends ss{}class xF extends UA{constructor(){super(...arguments);r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=rA.findObjectsOfType(g0,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=rA.getComponentInParent(this.gameObject,tp);I?ML&&console.warn("Can not delete object with usage marker",this.guid,I):(ML&&console.log("DESTROY",this.gameObject),FS(this.gameObject,this.context.connection))}}}}var RnA=Object.defineProperty,UnA=Object.getOwnPropertyDescriptor,DQ=(i,A,e,t)=>{for(var g=t>1?void 0:t?UnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RnA(A,e,g),g};const GL=IA("debugpost");class tn extends DI{constructor(){super(...arguments);r(this,"mode");r(this,"focusDistance");r(this,"focalLength");r(this,"aperture");r(this,"gaussianMaxRadius");r(this,"resolutionScale");r(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){GL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const g=t/300,I=2;return se.lerp(I,.01,g)};const e=20;this.aperture.valueProcessor=t=>{const g=1-t/32;return se.lerp(1,e,g)}}onCreateEffect(){if(this.mode===0){GL&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let g=1;Pn()&&(g=.6),this.resolutionScale=new be(g*e)}const t=new iH(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=g=>{t.cocMaterial.worldFocusDistance=g},this.focalLength.onValueChanged=g=>t.cocMaterial.worldFocusRange=g,this.aperture.onValueChanged=g=>t.bokehScale=g,this.resolutionScale&&(this.resolutionScale.onValueChanged=g=>t.resolution.scale=g),[t]}unapply(){}}DQ([D()],tn.prototype,"mode",2);DQ([D(be)],tn.prototype,"focusDistance",2);DQ([D(be)],tn.prototype,"focalLength",2);DQ([D(be)],tn.prototype,"aperture",2);DQ([D(be)],tn.prototype,"gaussianMaxRadius",2);DQ([D(be)],tn.prototype,"resolutionScale",2);DQ([D(be)],tn.prototype,"bokehScale",2);ys("DepthOfField",tn);var NnA=Object.defineProperty,FnA=Object.getOwnPropertyDescriptor,KnA=(i,A,e,t)=>{for(var g=t>1?void 0:t?FnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&NnA(A,e,g),g};class I0 extends UA{constructor(){super(...arguments);r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||rA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Pn()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}KnA([D()],I0.prototype,"visibleOn",2);class TF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var JnA=Object.defineProperty,vnA=Object.getOwnPropertyDescriptor,yQ=(i,A,e,t)=>{for(var g=t>1?void 0:t?vnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JnA(A,e,g),g};const Fn=IA("debugdrag");var EP=(i=>(i[i.XZPlane=0]="XZPlane",i[i.Attached=1]="Attached",i[i.HitNormal=2]="HitNormal",i[i.DynamicViewAngle=3]="DynamicViewAngle",i[i.SnapToSurfaces=4]="SnapToSurfaces",i[i.None=5]="None",i))(EP||{}),lD;const En=(lD=class extends UA{constructor(){super(...arguments);r(this,"dragMode",3);r(this,"snapGridResolution",0);r(this,"keepRotation",!0);r(this,"xrDragMode",1);r(this,"xrKeepRotation",!1);r(this,"xrDistanceDragFactor",1);r(this,"showGizmo",!1);r(this,"targetObject",null);r(this,"orbit",null);r(this,"_dragHelper",null);r(this,"_draggingRigidbodies",[]);r(this,"_potentialDragStartEvt",null);r(this,"_dragHandlers",new Map);r(this,"_totalMovement",new y);r(this,"_marker",null);r(this,"_isDragging",!1);r(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(A){this.targetObject=A;for(const e of this._dragHandlers.values())e.setTargetObject(A)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new y,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=rA.findObjectOfType(gi,this.context),this.gameObject.getComponentInParent(vo)||this.gameObject.addNewComponent(vo)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||A.mode!=="screen"||(A.event.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)return;const g=rA.getComponentInParent(A.object,En);!g||g!==this||(En.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&A.mode==="screen"&&En.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(A){if(!(!this.allowEdit(this.gameObject)||A.used||(A.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)&&(En.lastHovered=A.object,A.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=A),En._active+=1;const g=new qnA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(A.event.space,g),this.orbit&&(this.orbit.enabled=!1),g.onDragStart(A),this._dragHandlers.size===2){const I=this._dragHandlers.values(),o=I.next().value,s=I.next().value,n=new bnA(this,this.targetObject||this.gameObject,o,s);this._dragHandlers.set(this.gameObject,n),n.onDragStart(A)}A.use()}}onPointerMove(A){(this._isDragging||this._potentialDragStartEvt!==null)&&A.use()}onPointerUp(A){if(Fn&&Re.DrawLabel(A.point??this.gameObject.worldPosition,"POINTERUP:"+A.pointerId+", "+A.button,.03,3),!this.allowEdit(this.gameObject)||A.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(A.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(A)),e&&(En._active>0&&(En._active-=1),e.onDragEnd&&e.onDragEnd(A),this._dragHandlers.delete(A.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(A),A.use()),En._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const A of this._dragHandlers.values())A.collectMovementInfo&&A.collectMovementInfo(),A.getTotalMovement&&this._totalMovement.add(A.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const A=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(A)}for(const A of this._dragHandlers.values())A.onDragUpdate&&A.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new jD(this.context.mainCamera);else return;if(!A||!A.object)return;const e=rA.getComponentInParent(A.object,En);if(!e||e!==this)return;const t=this.targetObject||this.gameObject;if(!t)return;this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const g=rA.getComponentInChildren(t,dr);Fn&&console.log("DRAG START",g,t),g&&(g.fastMode=!0,g==null||g.requestOwnership()),this._marker=rA.addNewComponent(t,tp),this._draggingRigidbodies.length=0;const I=rA.getComponentsInChildren(t,ti);I&&this._draggingRigidbodies.push(...I)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities(),e.resetForcesAndTorques();const A=this.targetObject||this.gameObject;Ws.markDirty(A)}onLastDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const t of this._draggingRigidbodies)t.setVelocity(t.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(Fn&&console.log("DRAG END",e,e==null?void 0:e.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A!=null&&A.object){const t=rA.getComponentInChildren(A.object,dr);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},r(lD,"_active",0),r(lD,"lastHovered"),lD);let ds=En;yQ([D()],ds.prototype,"dragMode",2);yQ([D()],ds.prototype,"snapGridResolution",2);yQ([D()],ds.prototype,"keepRotation",2);yQ([D()],ds.prototype,"xrDragMode",2);yQ([D()],ds.prototype,"xrKeepRotation",2);yQ([D()],ds.prototype,"xrDistanceDragFactor",2);yQ([D()],ds.prototype,"showGizmo",2);class bnA{constructor(A,e,t,g){r(this,"handlerA");r(this,"handlerB");r(this,"context");r(this,"settings");r(this,"gameObject");r(this,"_handlerAAttachmentPoint",new y);r(this,"_handlerBAttachmentPoint",new y);r(this,"_followObject");r(this,"_manipulatorObject");r(this,"_deviceMode");r(this,"_followObjectStartWorldQuaternion",new GA);r(this,"_manipulatorPosOffset",new y);r(this,"_manipulatorRotOffset",new GA);r(this,"_manipulatorScaleOffset",new y);r(this,"_tempVec1",new y);r(this,"_tempVec2",new y);r(this,"_tempVec3",new y);r(this,"tempLookMatrix",new mA);r(this,"_initialScale",new y);r(this,"_initialDistance",0);var o,s;this.context=A.context,this.settings=A,this.gameObject=e,this.handlerA=t,this.handlerB=g,this._followObject=new pA,this._manipulatorObject=new pA,this.context.scene.add(this._manipulatorObject);const I=(s=(o=ue.active)==null?void 0:o.rig)==null?void 0:s.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),I&&(I.worldToLocal(this._tempVec1),I.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(Fn&&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(e.scale),Fn){this._followObject.add(new Es(2)),this._manipulatorObject.add(new Es(5));const n=C=>`${C.x.toFixed(2)}, ${C.y.toFixed(2)}, ${C.z.toFixed(2)}`;Re.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),Re.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6303
|
+
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Fe(EnA),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Fe(cnA),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,g,I,o,s,n,C;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(g=this.depthMaterial)==null||g.dispose(),(I=this.horizontalBlurMaterial)==null||I.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(s=this.blurPlane)==null||s.geometry.dispose(),(n=this.plane)==null||n.geometry.dispose(),(C=this.occluderMesh)==null||C.geometry.dispose()}onBeforeRender(e){const t=this.context.scene,g=this.context.renderer,I=g.getRenderTarget();if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){Ok&&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 uA&&(this.gameObject.visible=!1,fE(this.gameObject,!1));const s=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const n=g.getClearAlpha();g.setClearAlpha(0),g.setRenderTarget(this.renderTarget),g.render(t,this.shadowCamera),t.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,g.setRenderTarget(I),g.setClearAlpha(n),t.background=s}blurShadow(e){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=e*1/256;const t=this.context.renderer,g=t.getRenderTarget();t.setRenderTarget(this.renderTargetBlur),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=e*1/256,t.setRenderTarget(this.renderTarget),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,t.setRenderTarget(g)}}$u([D()],qr.prototype,"darkness",2);$u([D()],qr.prototype,"opacity",2);$u([D()],qr.prototype,"blur",2);$u([D()],qr.prototype,"occludeBelowGround",2);$u([D()],qr.prototype,"backfaceShadows",2);var dnA=Object.defineProperty,unA=Object.getOwnPropertyDescriptor,Ap=(i,A,e,t)=>{for(var g=t>1?void 0:t?unA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&dnA(A,e,g),g};const mL=IA("debugwebxr"),pnA=new mA().makeRotationY(Math.PI);class bo extends UA{constructor(){super(...arguments);r(this,"_arScale",1);r(this,"invertForward",!1);r(this,"customReticle");r(this,"useXRAnchor",!1);r(this,"arTouchTransform",!1);r(this,"_isPlacing",!0);r(this,"_startOffset",new mA);r(this,"_createdPlacementObject",null);r(this,"_reparentedComponents",[]);r(this,"_placementScene",new pI);r(this,"_reticle",[]);r(this,"_hits",[]);r(this,"_placementStartTime",-1);r(this,"_rigPlacementMatrix");r(this,"_anchor",null);r(this,"userInput");r(this,"onPlaceScene",e=>{var I;if(this._isPlacing==!1)return;let t=this._reticle[0],g=this._hits[0];if(e.origin instanceof ON){const o=this._reticle[e.origin.index];o&&(t=o,g=this._hits[e.origin.index])}if(!t){console.warn("No reticle to place...");return}if(!t.visible){console.warn("Reticle is not visible (can not place)");return}if((I=ue.active)!=null&&I.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}e.stopImmediatePropagation(),e.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(t),this.useXRAnchor&&this.onCreateAnchor(ue.active,g)})}get arScale(){return this._arScale}set arScale(e){e!==this._arScale&&(this._arScale=e,this.onScaleChanged())}onEnable(){var e;(e=this.customReticle)==null||e.preload()}supportsXR(e){return e==="immersive-ar"}onEnterXR(e){mL&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const t=new pA;this._createdPlacementObject=t,t.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let g=this.context.scene.children.length-1;g>=0;g--){const I=this.context.scene.children[g];this._placementScene.add(I)}this.context.scene.add(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),rA.addComponent(t,this);for(const g of this._reticle)Vs(g);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:un.Early})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:un.Early}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,g,I,o;if(e.xr.isTrackingImages){for(const s of this._reticle)s.visible=!1;return}if(this._isPlacing){const s=(t=e.xr.rig)==null?void 0:t.gameObject;s&&s.parent!==this.context.scene&&this.context.scene.add(s);let n=!1;if(e.xr.isPassThrough&&e.xr.controllers.length>0)for(const C of e.xr.controllers){const a=C.getHitTest();a&&(n=!0,this.updateReticleAndHits(e.xr,C.index,a,e.xr.rigScale))}if(!n){const C=e.xr.getHitTest();C&&this.updateReticleAndHits(e.xr,0,C,e.xr.rigScale)}}else{if(this._anchor&&e.xr.referenceSpace){const s=e.xr.frame.getPose(this._anchor.anchorSpace,e.xr.referenceSpace);if(s&&this.context.time.frame%20===0){const n=e.xr.convertSpace(s.transform),C=this._reticle[0];C&&(C.position.copy(n.position),C.quaternion.copy(n.quaternion),this.onApplyPose(C))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new DE(this.context)),(g=this.userInput)==null||g.enable()):(I=this.userInput)==null||I.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(e.xr.rig){const s=e.xr.rig.gameObject;this.userInput.applyMatrixTo(s.matrix,!0),s.matrix.decompose(s.position,s.quaternion,s.scale),this.userInput.factor=s.scale.x}this.userInput.reset()}}}updateReticleAndHits(e,t,g,I){this._hits[t]=g.hit;let o=this._reticle[t];if(!o){if(this.customReticle)if(this.customReticle.asset)o=qc(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new uA(new zB(.07,.09,32).rotateX(-Math.PI/2),new Bt({side:mt})),o.name="AR Placement Reticle";if(mL){const s=new Es(1);s.position.y+=.01,o.add(s)}this._reticle[t]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(g.position,this.context.time.deltaTime/.1),o.quaternion.slerp(g.quaternion,this.context.time.deltaTime/.05),o.scale.set(I,I,I),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 e;for(const t of this._reticle)t&&(t.visible=!1,t==null||t.removeFromParent());this._reticle.length=0;for(let t=this._placementScene.children.length-1;t>=0;t--){const g=this._placementScene.children[t];this.context.scene.add(g)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)rA.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),me()&&yi("Hit does not support creating an anchor");return}else{const g=await t.createAnchor(e.viewerPose.transform);e.running&&g&&(this._anchor=g)}}applyViewBasedTransform(e){const t=this.context.mainCamera,g=e,I=t.worldPosition,o=g.worldPosition;I.y=o.y,e.lookAt(I)}onApplyPose(e){var g,I,o,s;const t=(I=(g=ue.active)==null?void 0:g.rig)==null?void 0:I.gameObject;if((o=ue.active)!=null&&o.rigScale,t){const n=t.parent||this.context.scene;this._rigPlacementMatrix?(s=this._rigPlacementMatrix)==null||s.decompose(t.position,t.quaternion,t.scale):this._rigPlacementMatrix=t.matrix.clone(),this.applyViewBasedTransform(e),e.updateMatrix(),this.context.scene.add(e),e.attach(t),e.removeFromParent(),t.scale.set(this.arScale,this.arScale,this.arScale),t.position.multiplyScalar(this.arScale),t.updateMatrix(),this.invertForward&&t.matrix.premultiply(pnA),t.matrix.premultiply(this._startOffset),t.matrix.decompose(t.position,t.quaternion,t.scale),n.add(t)}}}Ap([D()],bo.prototype,"arScale",1);Ap([D()],bo.prototype,"invertForward",2);Ap([D(It)],bo.prototype,"customReticle",2);Ap([D()],bo.prototype,"useXRAnchor",2);Ap([D()],bo.prototype,"arTouchTransform",2);const yw=class{constructor(A){r(this,"oneFingerDrag",!0);r(this,"twoFingerRotate",!0);r(this,"twoFingerScale",!0);r(this,"factor",1);r(this,"context");r(this,"offset");r(this,"plane");r(this,"_scale",1);r(this,"_hasChanged",!1);r(this,"_enabled",!1);r(this,"currentlyUsedPointerIds",new Set);r(this,"currentlyUnusedPointerIds",new Set);r(this,"onPointerDownEarly",A=>{this.isActive&&A.stopPropagation()});r(this,"onPointerDownLate",A=>{A.used?this.currentlyUsedPointerIds.add(A.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(A.pointerId)});r(this,"onPointerUpEarly",A=>{this.currentlyUsedPointerIds.delete(A.pointerId),this.currentlyUnusedPointerIds.delete(A.pointerId)});r(this,"prev",new Map);r(this,"_didMultitouch",!1);r(this,"touchStart",A=>{for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e];this.prev.has(t.identifier)||this.prev.set(t.identifier,{x:0,z:0,screenx:0,screeny:0});const g=this.prev.get(t.identifier);if(g){const I=this.getPositionOnPlane(t.clientX,t.clientY);g.x=I.x,g.z=I.z,g.screenx=t.clientX,g.screeny=t.clientY}}});r(this,"touchEnd",A=>{A.touches.length<=0&&(this._didMultitouch=!1)});r(this,"touchMove",A=>{if(!A.defaultPrevented&&this.isActive){if(A.touches.length===1){if(this._didMultitouch)return;const e=A.touches[0],t=this.prev.get(e.identifier);if(!t)return;const g=this.getPositionOnPlane(e.clientX,e.clientY),I=g.x-t.x,o=g.z-t.z;if(I===0&&o===0)return;this.oneFingerDrag&&this.addMovement(I,o),t.x=g.x,t.z=g.z,t.screenx=e.clientX,t.screeny=e.clientY;return}else if(A.touches.length===2){this._didMultitouch=!0;const e=A.touches[0],t=A.touches[1],g=this.prev.get(e.identifier),I=this.prev.get(t.identifier);if(!g||!I)return;if(this.twoFingerRotate){const o=Math.atan2(e.clientY-t.clientY,e.clientX-t.clientX),s=Math.atan2(g.screeny-I.screeny,g.screenx-I.screenx),n=o-s;Math.abs(n)>.001&&this.addRotation(n)}if(this.twoFingerScale){const o=e.clientX-t.clientX,s=e.clientY-t.clientY,n=Math.sqrt(o*o+s*s),C=g.screenx-I.screenx,a=g.screeny-I.screeny,B=Math.sqrt(C*C+a*a),Q=n-B;Math.abs(Q)>2&&this.addScale(Q)}g.screenx=e.clientX,g.screeny=e.clientY,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"_raycaster",new Gc);r(this,"_intersection",new y);r(this,"_screenPos",new y);r(this,"_tempMatrix",new mA);this.context=A,this.offset=new mA,this.plane=new vI,this.plane.setFromNormalAndCoplanarPoint(yw.up,yw.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(A,e){this._hasChanged=!1,e?(this.offset.invert(),A.premultiply(this.offset)):A.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:un.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:un.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:un.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:un.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:un.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:un.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(A,e){const t=this.context.mainCamera;return this._screenPos.x=A/window.innerWidth*2-1,this._screenPos.y=-(e/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(t),this._raycaster.set(t.position,this._screenPos.sub(t.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(A,e){A/=this._scale,e/=this._scale,A*=this.factor,e*=this.factor,this.offset.elements[12]+=A,this.offset.elements[14]+=e,(A!==0||e!==0)&&(this._hasChanged=!0)}addScale(A){A/=window.innerWidth,A*=-1,this._scale*=1+A,this._tempMatrix.makeScale(1-A,1-A,1-A),this.offset.premultiply(this._tempMatrix),A!==0&&(this._hasChanged=!0)}addRotation(A){A*=-1,this._tempMatrix.makeRotationY(A),this.offset.premultiply(this._tempMatrix),A!==0&&(this._hasChanged=!0)}};let DE=yw;r(DE,"up",new y(0,1,0)),r(DE,"zero",new y(0,0,0)),r(DE,"one",new y(1,1,1));const sJ=class{constructor(){r(this,"_quicklookButton");r(this,"_arButton");r(this,"_vrButton");r(this,"_sendToQuestButton");r(this,"_qrButton")}static create(){return new sJ}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 A=document.createElement("button");return this._quicklookButton=A,A.dataset.needle="quicklook-button",A.innerText="Open in Quicklook",A.addEventListener("click",()=>{const e=rA.findObjectOfType(lg);e?(A.classList.add("this-mode-is-requested"),e.exportAsync().then(()=>{A.classList.remove("this-mode-is-requested")}).catch(t=>{A.classList.remove("this-mode-is-requested"),console.error(t)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(A),A}createARButton(A){var g;if(this._arButton)return this._arButton;const e="immersive-ar",t=document.createElement("button");return this._arButton=t,t.classList.add("webxr-button"),t.dataset.needle="webxr-ar-button",t.innerText="Enter AR",t.title="Click to start a WebXR session in AR",t.addEventListener("click",()=>ue.start(e,A)),this.updateSessionSupported(t,e),this.listenToXRSessionState(t,e),this.hideElementDuringXRSession(t),this.isSecureConnection||(t.disabled=!0,t.title="WebXR requires a secure connection (HTTPS)"),bB()||(g=navigator.xr)==null||g.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createVRButton(A){var g;if(this._vrButton)return this._vrButton;const e="immersive-vr",t=document.createElement("button");return this._vrButton=t,t.classList.add("webxr-button"),t.dataset.needle="webxr-vr-button",t.innerText="Enter VR",t.title="Click to start a WebXR session in VR",t.addEventListener("click",()=>ue.start(e,A)),this.updateSessionSupported(t,e),this.listenToXRSessionState(t,e),this.hideElementDuringXRSession(t),this.isSecureConnection||(t.disabled=!0,t.title="WebXR requires a secure connection (HTTPS)"),bB()||(g=navigator.xr)==null||g.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createSendToQuestButton(){var t;if(this._sendToQuestButton)return this._sendToQuestButton;const A="https://oculus.com/open_url/?url=",e=document.createElement("button");return this._sendToQuestButton=e,e.dataset.needle="webxr-sendtoquest-button",e.innerText="Open on Quest",e.title="Click to send this page to the Oculus Browser on your Quest",e.addEventListener("click",()=>{const g=encodeURIComponent(window.location.href);window.open(A+g)}),this.listenToXRSessionState(e),this.hideElementDuringXRSession(e),bB()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>{var g;(g=navigator.xr)!=null&&g.isSessionSupported("immersive-vr")?e.style.display="none":e.style.display=""}),e}createQRCode(){if(this._qrButton)return this._qrButton;const A=document.createElement("button");this._qrButton=A,A.innerText="QR Code",A.title="Scan this QR code with your phone to open this page",this.hideElementDuringXRSession(A);const e=document.createElement("div");e.style.position="fixed",e.style.display="inline-block",e.style.padding="1rem",e.style.backgroundColor="white",e.style.borderRadius="0.4rem",e.style.cursor="pointer",e.style.zIndex="1000",e.style.boxShadow="0 0 12px rgba(0, 0, 0, 0.2)";const t=document.createElement("div");t.classList.add("qr-code-container"),e.appendChild(t),A.addEventListener("click",()=>{if(e.parentNode)return I();g()});async function g(){await o(),document.body.appendChild(e);const s=t.getBoundingClientRect(),n=A.getBoundingClientRect();e.style.left=n.left+n.width*.5-s.width*.5+"px",n.top<s.height?e.style.top=`calc(${n.bottom}px + ${e.style.padding} * .6)`:e.style.top=`calc(${n.top-s.height}px - ${e.style.padding} * 2.5)`,setTimeout(()=>window.addEventListener("click",I,{once:!0})),window.addEventListener("resize",I),window.addEventListener("scroll",I),document.body.appendChild(e)}function I(){var s;(s=e.parentNode)==null||s.removeChild(e),window.removeEventListener("click",I),window.removeEventListener("resize",I),window.removeEventListener("scroll",I)}async function o(){const n=await zY({text:window.location.href,width:200,height:200});t.innerHTML="",t.appendChild(n)}return A.addEventListener("pointerenter",()=>{o()},{once:!0}),A}updateSessionSupported(A,e){if(!("xr"in navigator)){A.style.display="none";return}ue.isSessionSupported(e).then(t=>{A.style.display=t?"":"none",me()&&!t&&console.warn(e+" is not supported on this device - make sure your server runs using HTTPS and you have a device connected that supports "+e)})}hideElementDuringXRSession(A){ue.onXRSessionStart(e=>{A["previous-display"]=A.style.display,A.style.display="none"}),ue.onXRSessionEnd(e=>{A["previous-display"]!=null&&(A.style.display=A["previous-display"])})}listenToXRSessionState(A,e){e&&(ue.onSessionRequestStart(t=>{t.mode===e?A.classList.add("this-mode-is-requested"):(A["was-disabled"]=A.disabled,A.disabled=!0,A.classList.add("other-mode-is-requested"))}),ue.onSessionRequestEnd(t=>{A.classList.remove("this-mode-is-requested"),A.classList.remove("other-mode-is-requested"),A.disabled=A["was-disabled"]}))}};let Cr=sJ;r(Cr,"_instance");var fnA=Object.defineProperty,DnA=Object.getOwnPropertyDescriptor,Ba=(i,A,e,t)=>{for(var g=t>1?void 0:t?DnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&fnA(A,e,g),g};const nB=IA("debugtext");var Cg=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Cg||{}),QP=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(QP||{});class VI extends hQ{constructor(){super(...arguments);r(this,"alignment",0);r(this,"verticalOverflow",0);r(this,"horizontalOverflow",0);r(this,"lineSpacing",1);r(this,"supportRichText",!1);r(this,"font");r(this,"fontStyle",0);r(this,"sRGBTextColor",new wA(1,0,1));r(this,"_text","");r(this,"_fontSize",12);r(this,"_textMeshUi",null);r(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(e=this.uiObject)==null||e.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(e){this.updateOverflow()}updateOverflow(){var t;const e=(t=this.uiObject)==null?void 0:t._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(e){nB&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,nB&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),nB&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){var e;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(e=this.canvas)==null||e.registerEventReceiver(this)}onDisable(){var e;super.onDisable(),(e=this.canvas)==null||e.unregisterEventReceiver(this)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var g,I,o;if(nB&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let s=this.getNextTag(e);if(s){if(s.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const B=this.uiObject.children[a];B.isUI&&(this.uiObject.remove(B),B.clear())}const C=new yD({textContent:e.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(C)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const n=[];for(;s;){const C=this.getNextTag(e,s.endIndex),a={fontFamily:(g=this.uiObject)==null?void 0:g.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(e,s,C),this.handleTag(s,a,n);const B=new yD(a);(I=this.uiObject)==null||I.add(B)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,n);const B=new yD(a);(o=this.uiObject)==null||o.add(B)}s=C}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,g={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(zy(s,g),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,g){if(!e.isEndTag){if(e.type.includes("color")){const I=new Pk(e,{color:t.color});if(g.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new wA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new Pk(e,{fontWeight:700});g.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new Pk(e,{fontStyle:"italic"});g.push(I)}}}getText(e,t,g){return e.substring(t.endIndex,g.startIndex)}getNextTag(e,t=0){const g=e.indexOf("<",t),I=e.indexOf(">",g);if(g>=0&&I>=0){const o=e.substring(g+1,I);return{type:o,startIndex:g,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const g=this.font,I=this.getFamilyNameWithCorrectSuffix(g,t);nB&&console.log("Selected font family:"+I);let o=DG.getFontFamily(I);switch(o||(o=DG.addFontFamily(I)),e.fontFamily=o,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let s=o.getVariant(e.fontWeight,e.fontStyle);if(!s){let n=I;n!=null&&n.endsWith("-msdf.json")||(n+="-msdf.json");let C=I;C!=null&&C.endsWith(".png")||(C+=".png"),s=o.addVariant(e.fontWeight,e.fontStyle,n,C),s==null||s.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var a;const g=e.lastIndexOf("-");if(g<0)return e;const I=(a=e.substring(g+1))==null?void 0:a.toLowerCase();if(ynA.includes(I))return nB&&console.warn("Unsupported font style: "+I),e;const o=e.lastIndexOf("/");let s=e;o>=0&&(s=s.substring(o+1));const n=s[0]===s[0].toUpperCase(),C=e.substring(0,g);switch(nB&&console.log("Select font: ",e,QP[t],s,n,C),t){case 0:return n?C+"-Regular":C+"-regular";case 1:return n?C+"-Bold":C+"-bold";case 2:return n?C+"-Italic":C+"-italic";case 3:return n?C+"-BoldItalic":C+"-bolditalic";default:return e}}}Ba([D()],VI.prototype,"alignment",2);Ba([D()],VI.prototype,"verticalOverflow",2);Ba([D()],VI.prototype,"horizontalOverflow",2);Ba([D()],VI.prototype,"lineSpacing",2);Ba([D()],VI.prototype,"supportRichText",2);Ba([D(URL)],VI.prototype,"font",2);Ba([D()],VI.prototype,"fontStyle",2);Ba([D()],VI.prototype,"text",1);Ba([D()],VI.prototype,"fontSize",1);class Pk{constructor(A,e){r(this,"tag");r(this,"previousValues");this.tag=A,this.previousValues=e}}const ynA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class $a{constructor(A){r(this,"id");r(this,"content","");r(this,"font",[]);r(this,"pointSize",144);r(this,"width");r(this,"height");r(this,"depth");r(this,"wrapMode");r(this,"horizontalAlignment");r(this,"verticalAlignment");r(this,"material");this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var g;e.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),e.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),e.closeBlock(")"),e.beginBlock(),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(g=this.font)==null||g.push("sans-serif"));const t=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${t} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </StageRoot/Materials/${rF(this.material)}>`),e.closeBlock()}}r($a,"global_id",0);class t0{static singleLine(A,e,t){const g=new $a("text_"+$a.getId());return g.content=A,e&&(g.pointSize=e),t&&(g.depth=t),g}static multiLine(A,e,t,g,I,o){const s=new $a("text_"+$a.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const wnA=new mA().makeRotationY(Math.PI),SnA=new mA().makeScale(-1,1,-1);class ep{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const g=rA.getComponent(A,VI);if(!g)return;const I=rA.getComponent(A,PI);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=wnA.clone(),I&&e.matrix.premultiply(SnA);const n=g.color.clone();e.material=new ao({color:n,emissive:n}),e.addEventListener("serialize",(C,a)=>{let B=g.text;B=B.replace(/\r/g,""),B=B.replace(/\n/g,"\\n");const Q=t0.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,C)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case Cg.LowerLeft:case Cg.MiddleLeft:case Cg.UpperLeft:A.horizontalAlignment="left";break;case Cg.LowerCenter:case Cg.MiddleCenter:case Cg.UpperCenter:A.horizontalAlignment="center";break;case Cg.LowerRight:case Cg.MiddleRight:case Cg.UpperRight:A.horizontalAlignment="right";break}switch(e){case Cg.LowerLeft:case Cg.LowerCenter:case Cg.LowerRight:A.verticalAlignment="bottom";break;case Cg.MiddleLeft:case Cg.MiddleCenter:case Cg.MiddleRight:A.verticalAlignment="middle";break;case Cg.UpperLeft:case Cg.UpperCenter:case Cg.UpperRight:A.verticalAlignment="top";break}}}class i0{get extensionName(){return"tmui"}onExportObject(A,e,t){const g=rA.getComponent(A,Xg);if(g&&g.activeAndEnabled&&g.renderMode===iP.WorldSpace){const I=new ep,o=rA.getComponent(A,PI),s=rA.getComponent(A,fr);if(o){o.width,o.height;const n=no.createEmpty(),C=o.shadowComponent;if(e.add(n),C){const a=C.matrix;n.matrix.copy(a);const B=new Map,Q=new Map;B.set(C,n),Q.set(C,s?s.alpha:1),C.traverse(E=>{if(E===C)return;const c=no.createEmpty();c.matrix.copy(E.matrix);const h=E.parent,u=!!h&&typeof h.textContent=="string"&&h.textContent.length>0;let l=Q.get(h)||1;const d=rA.getComponent(E,fr);if(d&&(l*=d.alpha),E instanceof uA&&u){const f=E[os];f?I.exportText(f.gameObject,c,t):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",E)}if(E instanceof uA&&!u){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),c.geometry=f;const S=new wA,k=E.material.opacity;S.copy(E.material.color),c.material=new Bt({color:S,opacity:k*l,map:E.material.map,transparent:!0})}B.set(E,c),Q.set(E,l);const p=B.get(h);if(!p){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}p.add(c)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,g=e.length/3;t<g;t++){const I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}const Vf=IA("debugusdz");function mnA(i,A){var o;const e=[],t=rA.getComponentsInChildren(i,Zg),g=rA.getComponentsInChildren(i,Jo),I=new Array;if(A.injectImplicitBehaviours)for(const s of t){if(!s||!s.runtimeAnimatorController)continue;const n=s.runtimeAnimatorController.activeState;if(!n||!n.motion||!n.motion.clip||((o=n.motion.clip.tracks)==null?void 0:o.length)<1)continue;const C=new Ah;C.animator=s,C.stateName=n.name,C.trigger="start",C.name="PlayAnimationOnClick_implicitAtStart_"+C.stateName;const a=new pA;rA.addComponent(a,C),I.push(a),i.add(a)}else for(const s of t){if(!s||!s.runtimeAnimatorController)continue;Vf&&console.log(s);const n=[];for(const C of s.runtimeAnimatorController.enumerateActions()){Vf&&console.log(C);const a=C.getClip();n.includes(a)||n.push(a)}e.push({root:s.gameObject,clips:n})}for(const s of g){Vf&&console.log(s);const n=[];for(const C of s.animations)n.includes(C)||n.push(C);e.push({root:s.gameObject,clips:n})}Vf&&console.log("USDZ Animation Clips",e);for(const s of e)for(const n of s.clips)A.registerAnimation(s.root,n);return I}function knA(i,A){const e=rA.getComponentsInChildren(i,wi),t=rA.getComponentsInChildren(i,Dr),g=new Array;for(const I of t){if(!I.target)continue;const o=e.indexOf(I.target);o>-1&&e.splice(o,1)}for(const I of e){if(!I||!I.clip||I.volume<=0)continue;const o=new Dr;o.target=I,o.name="PlayAudioOnClick_implicitAtStart_";const s=new pA;rA.addComponent(s,o),console.log("implicit PlayAudioOnStart",s,o),g.push(s),i.add(s)}return g}function kL(i){const A=i.domElement.shadowRoot.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const t=document.createElement("button");t.id="open-in-ar",t.innerText="Open in QuickLook",e.appendChild(t);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),i.domElement.shadowRoot.appendChild(e),g}var MnA=Object.defineProperty,GnA=Object.getOwnPropertyDescriptor,yI=(i,A,e,t)=>{for(var g=t>1?void 0:t?GnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&MnA(A,e,g),g};const Ao=IA("debugusdz");class Lr{constructor(){r(this,"callToAction");r(this,"checkoutTitle");r(this,"checkoutSubtitle");r(this,"callToActionURL")}}yI([D()],Lr.prototype,"callToAction",2);yI([D()],Lr.prototype,"checkoutTitle",2);yI([D()],Lr.prototype,"checkoutSubtitle",2);yI([D()],Lr.prototype,"callToActionURL",2);var yM;const yR=(yM=class extends UA{constructor(){super(...arguments);r(this,"objectToExport");r(this,"autoExportAnimations",!1);r(this,"autoExportAudioSources",!0);r(this,"exportFileName");r(this,"customUsdzFile");r(this,"customBranding");r(this,"anchoringType","plane");r(this,"maxTextureSize",2048);r(this,"planeAnchoringAlignment","horizontal");r(this,"interactive",!0);r(this,"allowCreateQuicklookButton",!0);r(this,"quickLookCompatible",!0);r(this,"extensions",[]);r(this,"link");r(this,"button");r(this,"onClickedOpenInARElement",A=>{A.preventDefault(),this.exportAsync()});r(this,"lastCallback")}start(){var A,e,t;Ao&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",g=>{switch(g.key){case"t":this.exportAsync();break}}),Pn()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(A=this.objectToExport)==null?void 0:A.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new ZS),this.extensions.push(new ur),this.extensions.push(new ep),this.extensions.push(new i0))}onEnable(){var t;const A=Rc(),e=YE();(Ao||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=kL(this.context),this.link.addEventListener("message",this.lastCallback)),Ao&&fi("USDZ Exporter enabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var A,e,t;(A=this.button)==null||A.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),Ao&&fi("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var t;let A=this.exportFileName??((t=this.objectToExport)==null?void 0:t.name)??this.name;if(A+="-"+S1(),HC()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=kL(this.context)),this.customUsdzFile){Ao&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,A);return}const e=await this.export(this.objectToExport);if(!e){console.warn("No object to export",this);return}Ao&&console.log("USDZ generation done. Downloading as "+this.link.download),this.openInQuickLook(e,A)}async export(A){if(!A)return null;nt.start("export-usdz",{onProgress:c=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:c}}))}}),nt.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),nt.report("export-usdz",{message:"Load progressive textures",autoStep:5}),nt.start("export-usdz-textures","export-usdz");const e=rA.getComponentsInChildren(A,Ji),t=new Array;let g=0;for(const c of e)for(const h of c.sharedMaterials)if(h){const u=c.loadProgressiveTextures(h);u instanceof Promise&&t.push(new Promise((l,d)=>{u.then(()=>{g++,nt.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:g,totalSteps:t.length}),l()}).catch(p=>d(p))}))}Ao&&fi("Load textures: "+t.length),await Promise.all(t),Ao&&fi("Load textures: done"),nt.end("export-usdz-textures");const I=Og.Global.Mask;Og.Global.Set(yn.AR),this.applyWebARSessionRoot();const o=new PgA,s=[...this.extensions],n=new vu(this.quickLookCompatible);s.push(n);const C={self:this,exporter:o,extensions:s,object:A};nt.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:C})),nt.report("export-usdz","auto export animations and audio sources");const a=new Array;this.autoExportAnimations&&a.push(...mnA(A,n)),this.extensions.find(c=>c.extensionName==="Audio")&&this.autoExportAudioSources&&a.push(...knA(A)),o.debug=Ao,o.keepObject=c=>{const h=rA.getComponent(c,Ji);return!(h&&!h.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"),nt.report("export-usdz","Invoking exporter.parse");const Q=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:s,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),E=new Blob([Q],{type:"model/vnd.usdz+zip"});for(const c of a)rA.destroy(c);return nt.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:C})),Og.Global.Set(I),nt.end("export-usdz"),E}openInQuickLook(A,e){const t=A instanceof Blob?URL.createObjectURL(A):A,g=this.buildQuicklookOverlay();Ao&&console.log("QuickLook Overlay",g);const I=g.callToAction?encodeURIComponent(g.callToAction):"",o=g.checkoutTitle?encodeURIComponent(g.checkoutTitle):"",s=g.checkoutSubtitle?encodeURIComponent(g.checkoutSubtitle):"";this.link.href=t+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${g.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(A,e){yR.save(A,e)}static save(A,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof A=="string"?t.href=A:t.href=URL.createObjectURL(A),t.download=e,t.click(),t.remove()}quicklookCallback(A){if((A==null?void 0:A.data)=="_apple_ar_quicklook_button_tapped"){Ao&&yi("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const t=new URLSearchParams(this.link.href);if(t){const g=t.get("callToActionURL");Ao&&fi("Quicklook url: "+g),g&&(HC()?globalThis.open(g,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",g))}}}}buildQuicklookOverlay(){var t,g,I,o,s,n;const A={};return this.customBranding&&Object.assign(A,this.customBranding),HC()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),A.callToAction="Close",A.checkoutTitle="๐ต Made with Needle",A.checkoutSubtitle="_"),(((t=A.callToAction)==null?void 0:t.length)||((g=A.checkoutTitle)==null?void 0:g.length)||((I=A.checkoutSubtitle)==null?void 0:I.length))&&((o=A.callToAction)!=null&&o.length||(A.callToAction="\0"),(s=A.checkoutTitle)!=null&&s.length||(A.checkoutTitle="\0"),(n=A.checkoutSubtitle)!=null&&n.length||(A.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:A})),A}applyWebARSessionRoot(){if(!this.objectToExport)return;let A=rA.getComponentInParent(this.objectToExport,bo);const e=A!=null;if(A||(A=rA.getComponentInChildren(this.objectToExport,bo)),Ao&&console.log("applyWebARSessionRoot",A),!A){Ao&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:A.gameObject,g=1/A.arScale;t.matrix.makeScale(g,g,g),A.invertForward&&t.matrix.multiply(yR.invertForwardMatrix)}createQuicklookButton(){const e=Cr.getOrCreate().createQuicklookButton();return e.parentNode||this.context.menu.appendChild(e),e}},r(yM,"invertForwardMatrix",new mA().makeRotationY(Math.PI)),yM);let lg=yR;yI([D(pA)],lg.prototype,"objectToExport",2);yI([D()],lg.prototype,"autoExportAnimations",2);yI([D()],lg.prototype,"autoExportAudioSources",2);yI([D()],lg.prototype,"exportFileName",2);yI([D(URL)],lg.prototype,"customUsdzFile",2);yI([D(Lr)],lg.prototype,"customBranding",2);yI([D()],lg.prototype,"anchoringType",2);yI([D()],lg.prototype,"maxTextureSize",2);yI([D()],lg.prototype,"planeAnchoringAlignment",2);yI([D()],lg.prototype,"interactive",2);yI([D()],lg.prototype,"allowCreateQuicklookButton",2);yI([D()],lg.prototype,"quickLookCompatible",2);class tp extends UA{constructor(){super(...arguments);r(this,"isUsed",!0);r(this,"usedBy",null)}}class LF extends UA{}const ML=IA("debugdeletable");class g0 extends ss{}class xF extends UA{constructor(){super(...arguments);r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=rA.findObjectsOfType(g0,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=rA.getComponentInParent(this.gameObject,tp);I?ML&&console.warn("Can not delete object with usage marker",this.guid,I):(ML&&console.log("DESTROY",this.gameObject),FS(this.gameObject,this.context.connection))}}}}var RnA=Object.defineProperty,UnA=Object.getOwnPropertyDescriptor,DQ=(i,A,e,t)=>{for(var g=t>1?void 0:t?UnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RnA(A,e,g),g};const GL=IA("debugpost");class tn extends DI{constructor(){super(...arguments);r(this,"mode");r(this,"focusDistance");r(this,"focalLength");r(this,"aperture");r(this,"gaussianMaxRadius");r(this,"resolutionScale");r(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){GL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const g=t/300,I=2;return se.lerp(I,.01,g)};const e=20;this.aperture.valueProcessor=t=>{const g=1-t/32;return se.lerp(1,e,g)}}onCreateEffect(){if(this.mode===0){GL&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let g=1;Pn()&&(g=.6),this.resolutionScale=new be(g*e)}const t=new iH(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=g=>{t.cocMaterial.worldFocusDistance=g},this.focalLength.onValueChanged=g=>t.cocMaterial.worldFocusRange=g,this.aperture.onValueChanged=g=>t.bokehScale=g,this.resolutionScale&&(this.resolutionScale.onValueChanged=g=>t.resolution.scale=g),[t]}unapply(){}}DQ([D()],tn.prototype,"mode",2);DQ([D(be)],tn.prototype,"focusDistance",2);DQ([D(be)],tn.prototype,"focalLength",2);DQ([D(be)],tn.prototype,"aperture",2);DQ([D(be)],tn.prototype,"gaussianMaxRadius",2);DQ([D(be)],tn.prototype,"resolutionScale",2);DQ([D(be)],tn.prototype,"bokehScale",2);ys("DepthOfField",tn);var NnA=Object.defineProperty,FnA=Object.getOwnPropertyDescriptor,KnA=(i,A,e,t)=>{for(var g=t>1?void 0:t?FnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&NnA(A,e,g),g};class I0 extends UA{constructor(){super(...arguments);r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||rA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Pn()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}KnA([D()],I0.prototype,"visibleOn",2);class TF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var JnA=Object.defineProperty,vnA=Object.getOwnPropertyDescriptor,yQ=(i,A,e,t)=>{for(var g=t>1?void 0:t?vnA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&JnA(A,e,g),g};const Fn=IA("debugdrag");var EP=(i=>(i[i.XZPlane=0]="XZPlane",i[i.Attached=1]="Attached",i[i.HitNormal=2]="HitNormal",i[i.DynamicViewAngle=3]="DynamicViewAngle",i[i.SnapToSurfaces=4]="SnapToSurfaces",i[i.None=5]="None",i))(EP||{}),lD;const En=(lD=class extends UA{constructor(){super(...arguments);r(this,"dragMode",3);r(this,"snapGridResolution",0);r(this,"keepRotation",!0);r(this,"xrDragMode",1);r(this,"xrKeepRotation",!1);r(this,"xrDistanceDragFactor",1);r(this,"showGizmo",!1);r(this,"targetObject",null);r(this,"orbit",null);r(this,"_dragHelper",null);r(this,"_draggingRigidbodies",[]);r(this,"_potentialDragStartEvt",null);r(this,"_dragHandlers",new Map);r(this,"_totalMovement",new y);r(this,"_marker",null);r(this,"_isDragging",!1);r(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(A){this.targetObject=A;for(const e of this._dragHandlers.values())e.setTargetObject(A)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new y,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=rA.findObjectOfType(gi,this.context),this.gameObject.getComponentInParent(vo)||this.gameObject.addNewComponent(vo)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||A.mode!=="screen"||(A.event.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)return;const g=rA.getComponentInParent(A.object,En);!g||g!==this||(En.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&A.mode==="screen"&&En.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(A){if(!(!this.allowEdit(this.gameObject)||A.used||(A.mode==="tracked-pointer"?this.xrDragMode:this.dragMode)===5)&&(En.lastHovered=A.object,A.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=A),En._active+=1;const g=new qnA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(A.event.space,g),this.orbit&&(this.orbit.enabled=!1),g.onDragStart(A),this._dragHandlers.size===2){const I=this._dragHandlers.values(),o=I.next().value,s=I.next().value,n=new bnA(this,this.targetObject||this.gameObject,o,s);this._dragHandlers.set(this.gameObject,n),n.onDragStart(A)}A.use()}}onPointerMove(A){(this._isDragging||this._potentialDragStartEvt!==null)&&A.use()}onPointerUp(A){if(Fn&&Re.DrawLabel(A.point??this.gameObject.worldPosition,"POINTERUP:"+A.pointerId+", "+A.button,.03,3),!this.allowEdit(this.gameObject)||A.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(A.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(A)),e&&(En._active>0&&(En._active-=1),e.onDragEnd&&e.onDragEnd(A),this._dragHandlers.delete(A.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(A),A.use()),En._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const A of this._dragHandlers.values())A.collectMovementInfo&&A.collectMovementInfo(),A.getTotalMovement&&this._totalMovement.add(A.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const A=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(A)}for(const A of this._dragHandlers.values())A.onDragUpdate&&A.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new jD(this.context.mainCamera);else return;if(!A||!A.object)return;const e=rA.getComponentInParent(A.object,En);if(!e||e!==this)return;const t=this.targetObject||this.gameObject;if(!t)return;this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const g=rA.getComponentInChildren(t,dr);Fn&&console.log("DRAG START",g,t),g&&(g.fastMode=!0,g==null||g.requestOwnership()),this._marker=rA.addNewComponent(t,tp),this._draggingRigidbodies.length=0;const I=rA.getComponentsInChildren(t,ti);I&&this._draggingRigidbodies.push(...I)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities(),e.resetForcesAndTorques();const A=this.targetObject||this.gameObject;Ws.markDirty(A)}onLastDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const t of this._draggingRigidbodies)t.setVelocity(t.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(Fn&&console.log("DRAG END",e,e==null?void 0:e.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A!=null&&A.object){const t=rA.getComponentInChildren(A.object,dr);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},r(lD,"_active",0),r(lD,"lastHovered"),lD);let ds=En;yQ([D()],ds.prototype,"dragMode",2);yQ([D()],ds.prototype,"snapGridResolution",2);yQ([D()],ds.prototype,"keepRotation",2);yQ([D()],ds.prototype,"xrDragMode",2);yQ([D()],ds.prototype,"xrKeepRotation",2);yQ([D()],ds.prototype,"xrDistanceDragFactor",2);yQ([D()],ds.prototype,"showGizmo",2);class bnA{constructor(A,e,t,g){r(this,"handlerA");r(this,"handlerB");r(this,"context");r(this,"settings");r(this,"gameObject");r(this,"_handlerAAttachmentPoint",new y);r(this,"_handlerBAttachmentPoint",new y);r(this,"_followObject");r(this,"_manipulatorObject");r(this,"_deviceMode");r(this,"_followObjectStartWorldQuaternion",new GA);r(this,"_manipulatorPosOffset",new y);r(this,"_manipulatorRotOffset",new GA);r(this,"_manipulatorScaleOffset",new y);r(this,"_tempVec1",new y);r(this,"_tempVec2",new y);r(this,"_tempVec3",new y);r(this,"tempLookMatrix",new mA);r(this,"_initialScale",new y);r(this,"_initialDistance",0);var o,s;this.context=A.context,this.settings=A,this.gameObject=e,this.handlerA=t,this.handlerB=g,this._followObject=new pA,this._manipulatorObject=new pA,this.context.scene.add(this._manipulatorObject);const I=(s=(o=ue.active)==null?void 0:o.rig)==null?void 0:s.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),I&&(I.worldToLocal(this._tempVec1),I.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(Fn&&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(e.scale),Fn){this._followObject.add(new Es(2)),this._manipulatorObject.add(new Es(5));const n=C=>`${C.x.toFixed(2)}, ${C.y.toFixed(2)}, ${C.z.toFixed(2)}`;Re.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),Re.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6304
6304
|
`+n(this._tempVec1)+`
|
|
6305
6305
|
`+n(this._tempVec2),.03,5)}}onDragStart(A){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=A.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(A){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 A=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,A.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const e=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(e/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),Fn&&(Re.DrawLabel(this._tempVec3.clone().add(new y(0,.2,0)),"A:B "+e.toFixed(2),.03),Re.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const A=30,e=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const t=this.gameObject,g=this._followObject;g.updateMatrix(),g.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const B=this._followObject.worldPosition,Q=this.settings.snapGridResolution;B.x=Math.round(B.x/Q)*Q,B.y=Math.round(B.y/Q)*Q,B.z=Math.round(B.z/Q)*Q,this._followObject.worldPosition=B,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const s=se.clamp01(this.context.time.deltaTime*A*e),n=t.worldPosition;n.lerp(g.worldPosition,s),t.worldPosition=n;const C=t.worldQuaternion;C.slerp(g.worldQuaternion,s),t.worldQuaternion=C;const a=t.worldScale;a.lerp(g.worldScale,s),t.worldScale=a}setTargetObject(A){this.gameObject=A}}class qnA{constructor(A,e){r(this,"context");r(this,"gameObject");r(this,"settings");r(this,"_lastRig");r(this,"_followObject");r(this,"_totalMovement",new y);r(this,"_totalMovementAlongRayDirection",0);r(this,"_grabStartDistance",0);r(this,"_deviceMode");r(this,"_followObjectStartPosition",new y);r(this,"_followObjectStartQuaternion",new GA);r(this,"_followObjectStartWorldQuaternion",new GA);r(this,"_lastDragPosRigSpace");r(this,"_tempVec",new y);r(this,"_tempMat",new mA);r(this,"_hitPointInLocalSpace",new y);r(this,"_hitNormalInLocalSpace",new y);r(this,"_bottomCenter",new y);r(this,"_backCenter",new y);r(this,"_backBottomCenter",new y);r(this,"_bounds",new xt);r(this,"_dragPlane",new vI(new y(0,1,0)));r(this,"_draggedOverObject",null);r(this,"_draggedOverObjectLastSetUp",null);r(this,"_draggedOverObjectLastNormal",new y);r(this,"_draggedOverObjectDuration",0);this.settings=A,this.context=A.context,this.gameObject=e,this._followObject=new pA}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(A){this.gameObject=A}recenter(){var I,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 A=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),A.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 e=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(e),this._grabStartDistance=e.distanceTo(A.worldPosition);const t=(o=(I=ue.active)==null?void 0:I.rig)==null?void 0:o.gameObject,g=(t==null?void 0:t.worldScale.x)||1;this._grabStartDistance/=g,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,Fn&&(Re.DrawLine(e,A.worldPosition,65280,.5,!1),Re.DrawLabel(A.worldPosition.add(new y(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(A){if(A.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,A.point&&A.normal)this._hitPointInLocalSpace.copy(A.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(A.normal);else if(A){const c=A.event.space,h=c.worldPosition;this.gameObject.worldToLocal(h),this._hitPointInLocalSpace.copy(h);const u=c.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),u.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(u)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const t=this._followObject.parent.worldForward,I=this._deviceMode==="tracked-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),I){case 0:const c=new y(0,1,0);this.gameObject.parent&&c.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(c,o);break;case 2:const h=this._hitNormalInLocalSpace.clone();h.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(h,o);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break;case 3:const u=new y(0,1,0),l=t,d=u.angleTo(l),p=.5;d>Math.PI/2+p||d<Math.PI/2-p?this._dragPlane.setFromNormalAndCoplanarPoint(new y(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break}const s=new xt,n=this.gameObject.parent,C=this.gameObject.position.clone(),a=this.gameObject.quaternion.clone(),B=this.gameObject.scale.clone();n&&n.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),s.setFromObject(this.gameObject);const Q=new y;s.getCenter(Q);const E=new y;s.getSize(E),this._bottomCenter.copy(Q.clone().add(new y(0,-E.y/2,0))),this._backCenter.copy(Q.clone().add(new y(0,0,E.z/2))),this._backBottomCenter.copy(Q.clone().add(new y(0,-E.y/2,E.z/2))),this._bounds.copy(s),n&&n.add(this.gameObject),this.gameObject.position.copy(C),this.gameObject.quaternion.copy(a),this.gameObject.scale.copy(B),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var I,o;if(!this._followObject.parent)return;const A=this._followObject.parent;this._followObject.updateMatrix();const e=A.worldPosition,t=(o=(I=ue.active)==null?void 0:I.rig)==null?void 0:o.gameObject;t&&t.worldToLocal(e),(this._lastDragPosRigSpace===void 0||t!=this._lastRig)&&(this._lastDragPosRigSpace=e.clone(),this._lastRig=t),this._tempVec.copy(e).sub(this._lastDragPosRigSpace);const g=A.worldForward;if(t&&(this._tempMat.copy(t.matrixWorld).invert(),g.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=g.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(e),Fn){let s=e;t&&(s=s.clone(),s.transformDirection(t.matrixWorld)),Re.DrawRay(s,g,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,t=this._followObject.parent;this._followObject.updateMatrix();const g=t.worldPosition,I=t.worldForward,o=this._deviceMode==="tracked-pointer",s=o?this.settings.xrKeepRotation:this.settings.keepRotation,n=o?this.settings.xrDragMode:this.settings.dragMode;if(n===5)return;const C=10;s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let a=1,B=1;if(this._deviceMode==="tracked-pointer"&&this._grabStartDistance>.5){const u=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);a=Math.max(0,u),a=a*a*a}else this._grabStartDistance<=.5&&(B=3);this._followObject.position.copy(this._followObjectStartPosition),s||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(a),this._followObject.updateMatrix();const Q=new qo(g,I);if(n==4){const u=new ls;u.ignore=[e];const l=this.context.physics.raycastFromRay(Q,u);if(l.length>0){const d=l[0];if(this._draggedOverObject===d.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=d.object,this._draggedOverObjectDuration=0),d.face&&this._draggedOverObjectDuration>.15&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(d.face.normal)<.999999)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(d.face.normal);const p=new y,f=new y;this._bounds.getCenter(p),this._bounds.getSize(f),p.sub(f.multiplyScalar(.5).multiply(d.face.normal)),this._hitPointInLocalSpace.copy(p),this._hitNormalInLocalSpace.copy(d.face.normal),this._bounds.getCenter(p),this._bounds.getSize(f),p.add(f.multiplyScalar(.5).multiply(d.face.normal));const S=this._hitPointInLocalSpace.clone().add(p);this._followObject.localToWorld(S);const k=this._followObject.worldPosition.sub(S);this._dragPlane.setFromNormalAndCoplanarPoint(d.face.normal,d.point.sub(k))}}}if(n!==1&&Q.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const u=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(u),Fn&&Re.DrawLine(u,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(u),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const u=this._followObject.worldPosition,l=this.settings.snapGridResolution;u.x=Math.round(u.x/l)*l,u.y=Math.round(u.y/l)*l,u.z=Math.round(u.z/l)*l,this._followObject.worldPosition=u,this._followObject.updateMatrix()}s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const E=se.clamp01(this.context.time.deltaTime*C*B),c=e.worldPosition;c.lerp(this._followObject.worldPosition,E),e.worldPosition=c;const h=e.worldQuaternion;if(h.slerp(this._followObject.worldQuaternion,E),e.worldQuaternion=h,Fn){const u=this._hitPointInLocalSpace.clone();e.localToWorld(u),Re.DrawSphere(u,.02,16711680);const l=this._hitNormalInLocalSpace.clone();l.applyQuaternion(h),Re.DrawRay(u,l,16711680),Re.DrawLabel(c.add(new y(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6306
6306
|
|