@needle-tools/engine 3.36.3-beta โ 3.36.3-beta.1
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 +47 -35
- package/dist/needle-engine.light.js +1194 -1182
- package/dist/needle-engine.light.min.js +19 -14
- package/dist/needle-engine.light.umd.cjs +19 -14
- package/dist/needle-engine.min.js +19 -14
- package/dist/needle-engine.umd.cjs +19 -14
- package/lib/engine/engine_license.js +33 -13
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +2 -1
- package/lib/engine/engine_texture.js +2 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -3
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -1
- package/lib/engine-components/ContactShadows.js +5 -0
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_license.ts +29 -12
- package/src/engine/engine_texture.ts +2 -1
- package/src/engine/webcomponents/needle menu/needle-menu.ts +15 -3
- package/src/engine-components/Component.ts +1 -1
- package/src/engine-components/ContactShadows.ts +9 -1
|
@@ -4341,7 +4341,7 @@ void main() {
|
|
|
4341
4341
|
`;s+=i(o);const n=Object.keys(I);let C="";for(let a=0;a<n.length;a++){const B=n[a],Q=I[B];if(Ql.has(Q)){C+="";continue}Ql.set(Q,!0),C+=B+":"+t(Q,o+1),a<n.length-1&&(C+=", "),C.length>=60&&(C+=`
|
|
4342
4342
|
`,C+=i(o),s+=C,C="")}return s+=C,s+=`
|
|
4343
4343
|
}`,s}return I}function i(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const W9=IA("nodevlogs");function di(g,A=fo.Log){cn(A,g)}function si(g){di(g,fo.Warn)}function XU(g){di(g,fo.Error)}let Ak;function ue(){return W9?!1:Ak!==void 0?Ak:XI()}function j9(g){Ak=g}const qr=new PB,II=new y,sa=new y,gi=new kA,vv={X:new y(1,0,0),Y:new y(0,1,0),Z:new y(0,0,1)},km={type:"change"},qv={type:"mouseDown"},bv={type:"mouseUp",mode:null},Lv={type:"objectChange"};class z9 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 $U;this._gizmo=t,this.add(t);const i=new e6;this._plane=i,this.add(i);const I=this;function o(p,u){let f=u;Object.defineProperty(I,p,{get:function(){return f!==void 0?f:u},set:function(S){f!==S&&(f=S,i[p]=S,t[p]=S,I.dispatchEvent({type:p+"-changed",value:S}),I.dispatchEvent(km))}}),I[p]=u,i[p]=u,t[p]=u}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 kA,a=new kA,B=new y,Q=new kA,E=new y,c=new y,d=new y,h=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",d),o("rotationAngle",h),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 kA,this._parentQuaternionInv=new kA,this._parentScale=new y,this._worldScaleStart=new y,this._worldQuaternionInv=new kA,this._worldScale=new y,this._positionStart=new y,this._quaternionStart=new kA,this._scaleStart=new y,this._getPointer=V9.bind(this),this._onPointerDown=X9.bind(this),this._onPointerHover=Z9.bind(this),this._onPointerMove=$9.bind(this),this._onPointerUp=A6.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(A){if(this.object===void 0||this.dragging===!0)return;A!==null&&qr.setFromCamera(A,this.camera);const e=Rm(this._gizmo.picker[this.mode],qr);e?this.axis=e.object.name:this.axis=null}pointerDown(A){if(!(this.object===void 0||this.dragging===!0||A!=null&&A.button!==0)&&this.axis!==null){A!==null&&qr.setFromCamera(A,this.camera);const e=Rm(this._plane,qr,!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,qv.mode=this.mode,this.dispatchEvent(qv)}}pointerMove(A){const e=this.axis,t=this.mode,i=this.object;let I=this.space;if(t==="scale"?I="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(I="world"),i===void 0||e===null||this.dragging===!1||A!==null&&A.button!==-1)return;A!==null&&qr.setFromCamera(A,this.camera);const o=Rm(this._plane,qr,!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),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(I==="local"&&(i.position.applyQuaternion(gi.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),I==="world"&&(i.parent&&i.position.add(II.setFromMatrixPosition(i.parent.matrixWorld)),e.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(II.setFromMatrixPosition(i.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),sa.set(s,s,s)}else II.copy(this.pointStart),sa.copy(this.pointEnd),II.applyQuaternion(this._worldQuaternionInv),sa.applyQuaternion(this._worldQuaternionInv),sa.divide(II),e.search("X")===-1&&(sa.x=1),e.search("Y")===-1&&(sa.y=1),e.search("Z")===-1&&(sa.z=1);i.scale.copy(this._scaleStart).multiply(sa),this.scaleSnap&&(e.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(i.scale.z=Math.round(i.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(II.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(II.copy(this.rotationAxis).cross(this.eye))*s):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(vv[e]),II.copy(vv[e]),I==="local"&&II.applyQuaternion(this.worldQuaternion),II.cross(this.eye),II.length()===0?n=!0:this.rotationAngle=this._offset.dot(II.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"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(gi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(gi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(km),this.dispatchEvent(Lv)}}pointerUp(A){A!==null&&A.button!==0||(this.dragging&&this.axis!==null&&(bv.mode=this.mode,this.dispatchEvent(bv)),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(km),this.dispatchEvent(Lv),this.pointStart.copy(this.pointEnd))}getRaycaster(){return qr}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 V9(g){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:g.button};{const A=this.domElement.getBoundingClientRect();return{x:(g.clientX-A.left)/A.width*2-1,y:-(g.clientY-A.top)/A.height*2+1,button:g.button}}}function Z9(g){if(this.enabled)switch(g.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(g));break}}function X9(g){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(g.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(g)),this.pointerDown(this._getPointer(g)))}function $9(g){this.enabled&&this.pointerMove(this._getPointer(g))}function A6(g){this.enabled&&(this.domElement.releasePointerCapture(g.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(g)))}function Rm(g,A,e){const t=A.intersectObject(g,!0);for(let i=0;i<t.length;i++)if(t[i].object.visible||e)return t[i];return!1}const af=new Zt,qt=new y(0,1,0),xv=new y(0,0,0),Yv=new MA,rf=new kA,BD=new kA,Ws=new y,Tv=new MA,Hl=new y(1,0,0),AB=new y(0,1,0),Ol=new y(0,0,1),Bf=new y,El=new y,cl=new y;class $U 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 Ti({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=A.clone();t.opacity=.15;const i=e.clone();i.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 d=new bi(0,.04,.1,12);d.translate(0,.05,0);const h=new _t(.08,.08,.08);h.translate(0,.04,0);const l=new le;l.setAttribute("position",new Qe([0,0,0,1,0,0],3));const p=new bi(.0075,.0075,.5,3);p.translate(0,.25,0);function u(O,v){const q=new QC(O,.0075,3,64,v*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function f(){const O=new le;return O.setAttribute("position",new Qe([0,0,0,1,1,1],3)),O}const S={X:[[new lA(d,I),[.5,0,0],[0,0,-Math.PI/2]],[new lA(d,I),[-.5,0,0],[0,0,Math.PI/2]],[new lA(p,I),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new lA(d,o),[0,.5,0]],[new lA(d,o),[0,-.5,0],[Math.PI,0,0]],[new lA(p,o)]],Z:[[new lA(d,s),[0,0,.5],[Math.PI/2,0,0]],[new lA(d,s),[0,0,-.5],[-Math.PI/2,0,0]],[new lA(p,s),null,[Math.PI/2,0,0]]],XYZ:[[new lA(new pC(.1,0),B.clone()),[0,0,0]]],XY:[[new lA(new _t(.15,.15,.01),a.clone()),[.15,.15,0]]],YZ:[[new lA(new _t(.15,.15,.01),n.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new lA(new _t(.15,.15,.01),C.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new lA(new bi(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new lA(new bi(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new lA(new bi(.2,0,.6,4),t),[0,.3,0]],[new lA(new bi(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new lA(new bi(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new lA(new bi(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new lA(new pC(.2,0),t)]],XY:[[new lA(new _t(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new lA(new _t(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new lA(new _t(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]]},k={START:[[new lA(new pC(.01,2),i),null,null,null,"helper"]],END:[[new lA(new pC(.01,2),i),null,null,null,"helper"]],DELTA:[[new xi(f(),i),null,null,null,"helper"]],X:[[new xi(l,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new xi(l,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new xi(l,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},m={XYZE:[[new lA(u(.5,1),c),null,[0,Math.PI/2,0]]],X:[[new lA(u(.5,.5),I)]],Y:[[new lA(u(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new lA(u(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new lA(u(.75,1),Q),null,[0,Math.PI/2,0]]]},F={AXIS:[[new xi(l,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},w={XYZE:[[new lA(new xs(.25,10,8),t)]],X:[[new lA(new QC(.5,.1,4,24),t),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new lA(new QC(.5,.1,4,24),t),[0,0,0],[Math.PI/2,0,0]]],Z:[[new lA(new QC(.5,.1,4,24),t),[0,0,0],[0,0,-Math.PI/2]]],E:[[new lA(new QC(.75,.1,2,24),t)]]},R={X:[[new lA(h,I),[.5,0,0],[0,0,-Math.PI/2]],[new lA(p,I),[0,0,0],[0,0,-Math.PI/2]],[new lA(h,I),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new lA(h,o),[0,.5,0]],[new lA(p,o)],[new lA(h,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new lA(h,s),[0,0,.5],[Math.PI/2,0,0]],[new lA(p,s),[0,0,0],[Math.PI/2,0,0]],[new lA(h,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new lA(new _t(.15,.15,.01),a),[.15,.15,0]]],YZ:[[new lA(new _t(.15,.15,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new lA(new _t(.15,.15,.01),C),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new lA(new _t(.1,.1,.1),B.clone())]]},H={X:[[new lA(new bi(.2,0,.6,4),t),[.3,0,0],[0,0,-Math.PI/2]],[new lA(new bi(.2,0,.6,4),t),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new lA(new bi(.2,0,.6,4),t),[0,.3,0]],[new lA(new bi(.2,0,.6,4),t),[0,-.3,0],[0,0,Math.PI]]],Z:[[new lA(new bi(.2,0,.6,4),t),[0,0,.3],[Math.PI/2,0,0]],[new lA(new bi(.2,0,.6,4),t),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new lA(new _t(.2,.2,.01),t),[.15,.15,0]]],YZ:[[new lA(new _t(.2,.2,.01),t),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new lA(new _t(.2,.2,.01),t),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new lA(new _t(.2,.2,.2),t),[0,0,0]]]},x={X:[[new xi(l,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new xi(l,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new xi(l,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(O){const v=new pA;for(const q in O)for(let T=O[q].length;T--;){const Z=O[q][T][0].clone(),AA=O[q][T][1],sA=O[q][T][2],QA=O[q][T][3],FA=O[q][T][4];Z.name=q,Z.tag=FA,AA&&Z.position.set(AA[0],AA[1],AA[2]),sA&&Z.rotation.set(sA[0],sA[1],sA[2]),QA&&Z.scale.set(QA[0],QA[1],QA[2]),Z.updateMatrix();const iA=Z.geometry.clone();iA.applyMatrix4(Z.matrix),Z.geometry=iA,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=J(S)),this.add(this.gizmo.rotate=J(m)),this.add(this.gizmo.scale=J(R)),this.add(this.picker.translate=J(M)),this.add(this.picker.rotate=J(w)),this.add(this.picker.scale=J(H)),this.add(this.helper.translate=J(k)),this.add(this.helper.rotate=J(F)),this.add(this.helper.scale=J(x)),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:BD;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let I=0;I<i.length;I++){const o=i[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"&&(gi.setFromEuler(af.set(0,0,0)),o.quaternion.copy(t).multiply(gi),Math.abs(qt.copy(Hl).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(gi.setFromEuler(af.set(0,0,Math.PI/2)),o.quaternion.copy(t).multiply(gi),Math.abs(qt.copy(AB).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(gi.setFromEuler(af.set(0,Math.PI/2,0)),o.quaternion.copy(t).multiply(gi),Math.abs(qt.copy(Ol).applyQuaternion(t).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(gi.setFromEuler(af.set(0,Math.PI/2,0)),qt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Yv.lookAt(xv,qt,AB)),o.quaternion.multiply(gi),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),II.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),II.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(II),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(qt.copy(Hl).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(qt.copy(AB).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(qt.copy(Ol).applyQuaternion(t).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(qt.copy(Ol).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(qt.copy(Hl).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(qt.copy(AB).applyQuaternion(t).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(rf.copy(t),qt.copy(this.eye).applyQuaternion(gi.copy(t).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Yv.lookAt(this.eye,xv,AB)),o.name==="X"&&(gi.setFromAxisAngle(Hl,Math.atan2(-qt.y,qt.z)),gi.multiplyQuaternions(rf,gi),o.quaternion.copy(gi)),o.name==="Y"&&(gi.setFromAxisAngle(AB,Math.atan2(qt.x,qt.z)),gi.multiplyQuaternions(rf,gi),o.quaternion.copy(gi)),o.name==="Z"&&(gi.setFromAxisAngle(Ol,Math.atan2(qt.y,qt.x)),gi.multiplyQuaternions(rf,gi),o.quaternion.copy(gi))),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 e6 extends lA{constructor(){super(new Xi(1e5,1e5,2,2),new Bt({visible:!1,wireframe:!0,side:ut,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"),Bf.copy(Hl).applyQuaternion(e==="local"?this.worldQuaternion:BD),El.copy(AB).applyQuaternion(e==="local"?this.worldQuaternion:BD),cl.copy(Ol).applyQuaternion(e==="local"?this.worldQuaternion:BD),qt.copy(El),this.mode){case"translate":case"scale":switch(this.axis){case"X":qt.copy(this.eye).cross(Bf),Ws.copy(Bf).cross(qt);break;case"Y":qt.copy(this.eye).cross(El),Ws.copy(El).cross(qt);break;case"Z":qt.copy(this.eye).cross(cl),Ws.copy(cl).cross(qt);break;case"XY":Ws.copy(cl);break;case"YZ":Ws.copy(Bf);break;case"XZ":qt.copy(cl),Ws.copy(El);break;case"XYZ":case"E":Ws.set(0,0,0);break}break;case"rotate":default:Ws.set(0,0,0)}Ws.length()===0?this.quaternion.copy(this.cameraQuaternion):(Tv.lookAt(II.set(0,0,0),Ws,qt),this.quaternion.setFromRotationMatrix(Tv)),super.updateMatrixWorld(A)}}const t6=IA("debugpatch");function $w(g,A,e,t){const i=t6===A;if(!e&&!t)return;const I=A+"___needle";g6(g,A,e,t);const o=Object.getOwnPropertyDescriptor(g,A),s=g[A];i&&console.log("Patch",g.constructor.name,A,o,s),o?(i&&console.log("Apply patch with existing descriptor",g.constructor.name,A,o),typeof o.value=="function"&&(g[A]=Hv(o.value,g,A))):(i&&console.log("Create patch with new property",g.constructor.name,A,o),Object.defineProperty(g,A,{set:function(n){if(typeof n=="function")this[I]=Hv(n,g,A);else{const C=this[I];f_(g,A,this,C,n),this[I]=n,D_(g,A,this,C,n)}},get:function(){const n=this[I];return typeof n=="function"&&n[I]?n[I]:n}}))}function i6(g,A,e){const t=AN(g,A);if(t)for(let i=t.length-1;i>=0;i--){const I=t[i];I.prefix===e&&(I.prefix=null),I.postfix===e&&(I.postfix=null),!I.prefix&&!I.postfix&&t.splice(i,1)}}const _v=Symbol("Needle:Patches:WrappedFunction");function Hv(g,A,e){if(g[_v])return g;const t=function(...i){f_(A,e,this,...i);const I=g.apply(this,i);return D_(A,e,this,I,...i),I};return t[_v]=!0,t}const QD="Needle:Patches";function ek(){return globalThis[QD]||(globalThis[QD]=new WeakMap),globalThis[QD]}function AN(g,A){const e=ek().get(g);return e?e.get(A):null}function g6(g,A,e,t){let i=ek().get(g);i||(i=new Map,ek().set(g,i));let I=i.get(A);I||(I=[],i.set(A,I)),I.push({prefix:e,postfix:t})}function f_(g,A,e,...t){var I;if(!e)return;const i=AN(g,A);if(i)for(const o of i)(I=o.prefix)==null||I.call(e,...t)}function D_(g,A,e,t,...i){var o;if(!e)return;const I=AN(g,A);if(I)for(const s of I)(o=s.postfix)==null||o.call(e,t,...i)}const Ov=Symbol("gltf-loader-internal-usage-tracker"),I6=IA("debugusers"),Jh=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 Jh._loadingProcesses>0}beforeRoot(){Jh._loadingProcesses++;const A=this,e=this._getDependency;return this.parser.getDependency=function(t,i){const I=e.call(this,t,i);return I.then(o=>(o&&(A._loadedObjects.add(o),o[Ov]=A._loadingId),o)),I},null}afterRoot(A){Jh._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[Ov],e instanceof pA&&(e.parent||e instanceof lA&&setTimeout(()=>{I6&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null},1e3));return null}};let lh=Jh;r(lh,"_loadingProcesses",0);class y_{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 i=e[0];i&&i.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4344
|
-
`+i.src),A.preventDefault())}})}}const AS=IA("trackresources");function w_(){return AS==="dispose"}let jB=!0;AS===0&&(jB=!1);function o6(g){jB=g}function S_(){return jB}const m_=Symbol("disposable");function eN(g,A){g&&(g[m_]=A,uB&&console.warn("Set disposable",A,g))}const M_=Symbol("disposed");function s6(g){return g[M_]===!0}function xt(g){var A;if(g){if(g[m_]===!1){uB&&console.warn("Object is marked as not disposable",g);return}if(g[M_]=!0,g instanceof rI)xt(g.environment),xt(g.background),xt(g.customDepthMaterial),xt(g.customDistanceMaterial);else if(g instanceof mo)xt(g.geometry),xt(g.material),xt(g.skeleton),xt(g.bindMatrix),xt(g.bindMatrixInverse),xt(g.customDepthMaterial),xt(g.customDistanceMaterial),g.geometry=null,g.material=null;else if(g instanceof lA)xt(g.geometry),xt(g.material),xt(g.customDepthMaterial),xt(g.customDistanceMaterial),g.geometry=null,g.material=null;else if(g instanceof le){OQ(g);for(const e of Object.keys(g.attributes)){const t=g.attributes[e];xt(t)}}else if(g instanceof ie||g instanceof FI)uB&&console.warn("BufferAttribute dispose not supported",g.count);else if(g instanceof Array)for(const e of g)e instanceof ve&&xt(e);else if(g instanceof ve){OQ(g);for(const t of Object.keys(g)){const i=g[t];i instanceof we&&(xt(i),g[t]=null)}const e=g.uniforms;if(e)for(const t of Object.keys(e)){const i=e[t];i instanceof we?(xt(i),e[t]=null):i instanceof wA&&(xt(i.value),i.value=null)}}else g instanceof we?(OQ(g),OQ(g.source),((A=g.source)==null?void 0:A.data)instanceof ImageBitmap&&OQ(g.source.data)):g instanceof dc?(OQ(g.boneTexture),g.boneTexture=null):g instanceof Pd||!(g instanceof pA)&&uB&&console.warn("Unknown object type",g)}}function OQ(g){g&&((uB||w_()||AS)&&console.warn("๐งจ FREE",g),g instanceof ImageBitmap?g.close():g instanceof uC?g.data=null:g.dispose())}function G_(g){(g instanceof lA||g instanceof mo)&&(g.material=null,g.geometry=null)}const n6=new Set;function eS(g,A,e=null,t){if(t||(t=n6,t.clear()),!g)return t;const i=g[Cd];if(i)for(const I of i)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&eS(I,!0,e,t));return t}function C6(g){return g[Pl]}const uB=IA("debugresourceusers")||IA("debugmemory"),Cd=Symbol("needle-resource-users"),Pl=Symbol("needle-resource-users-count");function dI(g,A){$w(g,A,function(e,t){jB&&(cy(Cd,this,e,!1),cy(Cd,this,t,!0))})}jB&&(dI(lA.prototype,"material"),dI(lA.prototype,"geometry"),dI(ve.prototype,"map"),dI(ve.prototype,"bumpMap"),dI(ve.prototype,"alphaMap"),dI(ve.prototype,"normalMap"),dI(ve.prototype,"displacementMap"),dI(ve.prototype,"roughnessMap"),dI(ve.prototype,"metalnessMap"),dI(ve.prototype,"emissiveMap"),dI(ve.prototype,"specularMap"),dI(ve.prototype,"envMap"),dI(ve.prototype,"lightMap"),dI(ve.prototype,"aoMap"),dI(ve.prototype,"gradientMap"));function a6(g){if(jB===!1)return;const A=g[Cd];if(A)for(const e of A)cy(Cd,e,g,!1)}jB&&$w(ve.prototype,"dispose",function(){a6(this)});let tk=0;function cy(g,A,e,t){if(tk>0)return;if(Array.isArray(e)){for(const I of e)cy(g,A,I,t);return}if(!e)return;let i=e[g];if(i||(i=new Set),t){if(A&&!i.has(A)){i.add(A);let I=e[Pl]||0;I+=1,e[Pl]=I,uB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",i)}}else if(A&&i.has(A)){i.delete(A);let I=e[Pl]||0;I>0&&(I-=1,e[Pl]=I),uB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",i),I<=0&&(lh.isLoading(e)||(AS&&console.warn(`๐ด Removed all user of "${e.type}"`,e),w_()&&xt(e)))}e[g]=i}try{$w(LC.prototype,"render",function(){tk++},function(){tk--})}catch(g){console.warn("Could not wrap WebGLRenderer.render",g)}var gu=(g=>(g.Added="component-added",g.Removing="removing-component",g))(gu||{});const Pv=IA("debugcomponentevents");class Iu{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),Pv&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const i=t.indexOf(e);i<0||t.splice(i,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(Pv&&console.log("Dispatching event "+A,t),!!t)for(const i of t)i(e)}}r(Iu,"eventListeners",new Map);const k_=IA("debugdefines");fc('if(!globalThis[""3.36.3-beta""]) globalThis[""3.36.3-beta""] = "0.0.0";');fc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');fc('if(!globalThis[""Thu Apr 04 2024
|
|
4344
|
+
`+i.src),A.preventDefault())}})}}const AS=IA("trackresources");function w_(){return AS==="dispose"}let jB=!0;AS===0&&(jB=!1);function o6(g){jB=g}function S_(){return jB}const m_=Symbol("disposable");function eN(g,A){g&&(g[m_]=A,uB&&console.warn("Set disposable",A,g))}const M_=Symbol("disposed");function s6(g){return g[M_]===!0}function xt(g){var A;if(g){if(g[m_]===!1){uB&&console.warn("Object is marked as not disposable",g);return}if(g[M_]=!0,g instanceof rI)xt(g.environment),xt(g.background),xt(g.customDepthMaterial),xt(g.customDistanceMaterial);else if(g instanceof mo)xt(g.geometry),xt(g.material),xt(g.skeleton),xt(g.bindMatrix),xt(g.bindMatrixInverse),xt(g.customDepthMaterial),xt(g.customDistanceMaterial),g.geometry=null,g.material=null;else if(g instanceof lA)xt(g.geometry),xt(g.material),xt(g.customDepthMaterial),xt(g.customDistanceMaterial),g.geometry=null,g.material=null;else if(g instanceof le){OQ(g);for(const e of Object.keys(g.attributes)){const t=g.attributes[e];xt(t)}}else if(g instanceof ie||g instanceof FI)uB&&console.warn("BufferAttribute dispose not supported",g.count);else if(g instanceof Array)for(const e of g)e instanceof ve&&xt(e);else if(g instanceof ve){OQ(g);for(const t of Object.keys(g)){const i=g[t];i instanceof we&&(xt(i),g[t]=null)}const e=g.uniforms;if(e)for(const t of Object.keys(e)){const i=e[t];i instanceof we?(xt(i),e[t]=null):i instanceof wA&&(xt(i.value),i.value=null)}}else g instanceof we?(OQ(g),OQ(g.source),((A=g.source)==null?void 0:A.data)instanceof ImageBitmap&&OQ(g.source.data)):g instanceof dc?(OQ(g.boneTexture),g.boneTexture=null):g instanceof Pd||!(g instanceof pA)&&uB&&console.warn("Unknown object type",g)}}function OQ(g){g&&((uB||w_()||AS)&&console.warn("๐งจ FREE",g),g instanceof ImageBitmap?g.close():g instanceof uC?g.data=null:g.dispose())}function G_(g){(g instanceof lA||g instanceof mo)&&(g.material=null,g.geometry=null)}const n6=new Set;function eS(g,A,e=null,t){if(t||(t=n6,t.clear()),!g)return t;const i=g[Cd];if(i)for(const I of i)t.has(I)||(e==null?void 0:e.call(null,I))!==!1&&(t.add(I),A&&eS(I,!0,e,t));return t}function C6(g){return g[Pl]}const uB=IA("debugresourceusers")||IA("debugmemory"),Cd=Symbol("needle-resource-users"),Pl=Symbol("needle-resource-users-count");function dI(g,A){$w(g,A,function(e,t){jB&&(cy(Cd,this,e,!1),cy(Cd,this,t,!0))})}jB&&(dI(lA.prototype,"material"),dI(lA.prototype,"geometry"),dI(ve.prototype,"map"),dI(ve.prototype,"bumpMap"),dI(ve.prototype,"alphaMap"),dI(ve.prototype,"normalMap"),dI(ve.prototype,"displacementMap"),dI(ve.prototype,"roughnessMap"),dI(ve.prototype,"metalnessMap"),dI(ve.prototype,"emissiveMap"),dI(ve.prototype,"specularMap"),dI(ve.prototype,"envMap"),dI(ve.prototype,"lightMap"),dI(ve.prototype,"aoMap"),dI(ve.prototype,"gradientMap"));function a6(g){if(jB===!1)return;const A=g[Cd];if(A)for(const e of A)cy(Cd,e,g,!1)}jB&&$w(ve.prototype,"dispose",function(){a6(this)});let tk=0;function cy(g,A,e,t){if(tk>0)return;if(Array.isArray(e)){for(const I of e)cy(g,A,I,t);return}if(!e)return;let i=e[g];if(i||(i=new Set),t){if(A&&!i.has(A)){i.add(A);let I=e[Pl]||0;I+=1,e[Pl]=I,uB&&console.warn(`๐ข Added user of "${e.type}"`,A,e,I,"users:",i)}}else if(A&&i.has(A)){i.delete(A);let I=e[Pl]||0;I>0&&(I-=1,e[Pl]=I),uB&&console.warn(`๐ด Removed user of "${e.type}"`,A,e,I,"users:",i),I<=0&&(lh.isLoading(e)||(AS&&console.warn(`๐ด Removed all user of "${e.type}"`,e),w_()&&xt(e)))}e[g]=i}try{$w(LC.prototype,"render",function(){tk++},function(){tk--})}catch(g){console.warn("Could not wrap WebGLRenderer.render",g)}var gu=(g=>(g.Added="component-added",g.Removing="removing-component",g))(gu||{});const Pv=IA("debugcomponentevents");class Iu{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),Pv&&console.log("Added event listener for "+A,this.eventListeners)}static removeComponentLifecylceEventListener(A,e){const t=this.eventListeners.get(A);if(!t)return;const i=t.indexOf(e);i<0||t.splice(i,1)}static dispatchComponentLifecycleEvent(A,e){const t=this.eventListeners.get(A);if(Pv&&console.log("Dispatching event "+A,t),!!t)for(const i of t)i(e)}}r(Iu,"eventListeners",new Map);const k_=IA("debugdefines");fc('if(!globalThis[""3.36.3-beta.1""]) globalThis[""3.36.3-beta.1""] = "0.0.0";');fc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');fc('if(!globalThis[""Thu Apr 04 2024 21:19:21 GMT+0200 (Central European Summer Time)""]) globalThis[""Thu Apr 04 2024 21:19:21 GMT+0200 (Central European Summer Time)""] = "unknown";');fc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.3-beta.1";');fc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');fc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Apr 04 2024 21:19:21 GMT+0200 (Central European Summer Time)";');const hn="3.36.3-beta.1",tS="undefined",tN="Thu Apr 04 2024 21:19:21 GMT+0200 (Central European Summer Time)";k_&&console.log(`Engine version: ${hn} (generator: ${tS})
|
|
4345
4345
|
Project built at ${tN}`);const mC="needle_isActiveInHierarchy",tB="builtin_components",hh="needle_editor_guid";function fc(g){try{(0,eval)(g)}catch(A){k_&&console.error(A)}}const ad=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),R_=Symbol("isUsingInstancing"),U_=Symbol("instancingRenderer"),Wl=Symbol("instancingAutoUpdateBounds");class As{static isUsingInstancing(A){return A[R_]===!0}static getRenderer(A){return A[U_]||null}setAutoUpdateBounds(A,e){const t=As.getRenderer(A);t&&(t[Wl]=e)}static markDirty(A,e=!0){if(A&&(this.isUsingInstancing(A)&&(A[ad]=!0,A.matrixWorldNeedsUpdate=!0),e))for(const t of A.children)As.markDirty(t,!0)}}function pB(g,A){try{A?g(A):g()}catch(e){return console.error(e),!1}return!0}const ik=IA("debugnewscripts"),r6=IA("debughierarchy"),ti=[];function B6(){return ti.length>0}function ly(g){if(!(g.new_scripts.length<=0)){if(ik&&console.log("Register new components",g.new_scripts.length,[...g.new_scripts],g.alias?"element: "+g.alias:g.hash,g),g.new_scripts_pre_setup_callbacks.length>0){for(const A of g.new_scripts_pre_setup_callbacks)A&&A();g.new_scripts_pre_setup_callbacks.length=0}ti.length=0,g.new_scripts.length>0&&ti.push(...g.new_scripts),g.new_scripts.length=0;for(let A=0;A<ti.length;A++)try{const e=ti[A];if(e.isComponent!==!0){(ue()||ik)&&console.error(`Registered script is not a Needle Engine component.
|
|
4346
4346
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
4347
4347
|
`,e),ti.splice(A,1),A--;continue}if(e.destroyed)continue;if(!e.gameObject){console.error("MISSING GAMEOBJECT - will ignore",e),ti.splice(A,1),A--;continue}e.context=g,dh(e.gameObject),iN(e,g)}catch(e){console.error(e),EC(ti[A],g),ti.splice(A,1),A--}for(let A=0;A<ti.length;A++)try{const e=ti[A];if(e.destroyed){EC(ti[A],g),ti.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),dh(e.gameObject),e.activeAndEnabled&&pB(e.__internalAwake.bind(e)))}catch(e){console.error(e),EC(ti[A],g),ti.splice(A,1),A--}for(let A=0;A<ti.length;A++)try{const e=ti[A];if(e.destroyed||e.enabled===!1||(dh(e.gameObject),e.activeAndEnabled===!1))continue;e.__internalEnable!==void 0&&(e.enabled=!0,pB(e.__internalEnable.bind(e)))}catch(e){console.error(e),EC(ti[A],g),ti.splice(A,1),A--}for(let A=0;A<ti.length;A++)try{const e=ti[A];if(e.destroyed||!e.gameObject)continue;g.new_script_start.push(e)}catch(e){console.error(e),EC(ti[A],g),ti.splice(A,1),A--}ti.length=0;for(const A of g.new_scripts_post_setup_callbacks)A&&A();g.new_scripts_post_setup_callbacks.length=0}}function Q6(g){g&&(g.__internalDisable(!0),EC(g,g.context))}function N_(g,A){for(let e=0;e<g.new_script_start.length;e++)try{const t=g.new_script_start[e];if(A!==void 0&&t.gameObject!==A||t.destroyed||t.activeAndEnabled===!1)continue;pB(t.__internalAwake.bind(t)),t.enabled&&(pB(t.__internalEnable.bind(t)),pB(t.__internalStart.bind(t)),g.new_script_start.splice(e,1),e--)}catch(t){console.error(t),EC(g.new_script_start[e],g),g.new_script_start.splice(e,1),e--}}function iN(g,A){A.scripts.indexOf(g)===-1&&(A.scripts.push(g),g.earlyUpdate&&A.scripts_earlyUpdate.push(g),g.update&&A.scripts_update.push(g),g.lateUpdate&&A.scripts_lateUpdate.push(g),g.onBeforeRender&&A.scripts_onBeforeRender.push(g),g.onAfterRender&&A.scripts_onAfterRender.push(g),g.onPausedChanged&&A.scripts_pausedChanged.push(g),Um(g,null)&&A.new_scripts_xr.push(g),Um(g,"immersive-vr")&&A.scripts_immersive_vr.push(g),Um(g,"immersive-ar")&&A.scripts_immersive_ar.push(g))}function EC(g,A){Lo(g,A.new_scripts),Lo(g,A.new_script_start),Lo(g,A.scripts),Lo(g,A.scripts_earlyUpdate),Lo(g,A.scripts_update),Lo(g,A.scripts_lateUpdate),Lo(g,A.scripts_onBeforeRender),Lo(g,A.scripts_onAfterRender),Lo(g,A.scripts_pausedChanged),Lo(g,A.new_scripts_xr),Lo(g,A.scripts_immersive_vr),Lo(g,A.scripts_immersive_ar),A.stopAllCoroutinesFrom(g)}function Lo(g,A){const e=A.indexOf(g);e>=0&&A.splice(e,1)}function Um(g,A){var e;if(g){const t=g;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 ED(g){if(g||(g=nt.Current.scene),!g){console.trace("Invalid call - no current context.");return}const A=wc(g);F_(g,A,!0)||(ik||ue()?console.error(`Error updating hierarchy
|
|
@@ -5001,21 +5001,26 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
5001
5001
|
height: 100%;
|
|
5002
5002
|
pointer-events: all;
|
|
5003
5003
|
zIndex: 2147483647;
|
|
5004
|
-
background-color: rgba(0,0,0,0.3);
|
|
5005
|
-
backdrop-filter: blur(10px);
|
|
5006
|
-
webkitBackdropFilter: blur(10px);
|
|
5007
5004
|
line-height: 1.5;
|
|
5008
|
-
|
|
5005
|
+
backdrop-filter: blur(15px);
|
|
5006
|
+
`;const I=i.style.cssText,o=document.createElement("div");i.appendChild(o),o.style.cssText=`
|
|
5009
5007
|
position: absolute;
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5008
|
+
left: 0;
|
|
5009
|
+
right: 0;
|
|
5010
|
+
top:0;
|
|
5011
|
+
bottom: 0;
|
|
5012
|
+
padding: 10%;
|
|
5013
5013
|
color: white;
|
|
5014
|
-
font-size:
|
|
5014
|
+
font-size: 20px;
|
|
5015
5015
|
font-family: sans-serif;
|
|
5016
5016
|
text-align: center;
|
|
5017
|
-
|
|
5018
|
-
|
|
5017
|
+
pointer-events: all;
|
|
5018
|
+
display: flex;
|
|
5019
|
+
justify-content: center;
|
|
5020
|
+
align-items: center;
|
|
5021
|
+
background-color: rgba(0,0,0,.3);
|
|
5022
|
+
text-shadow: 0 0 2px black;
|
|
5023
|
+
`;const s=o.style.cssText,n=($l==null?void 0:$l.length)>1?$l:"This web application has been blacklisted. You might be in violation of the Needle Engine terms of use.<br/>Please contact the Needle support if you think this is a mistake.";return o.innerHTML=n,setInterval(()=>{o.innerHTML!==n&&(o.innerHTML=n),o.parentNode!==i&&i.appendChild(o),i.style.cssText!==I&&(i.style.cssText=I),o.style.cssText!==s&&(o.style.cssText=s)},500),i}let e=A();const t=e.style.cssText;setInterval(()=>{var i;Uk===!0&&(e.style.cssText!==t&&(e=A()),g.domElement.shadowRoot?e.parentNode!==g.domElement.shadowRoot&&((i=g.domElement.shadowRoot)==null||i.appendChild(e)):e.parentNode!=document.body&&document.body.appendChild(e))},500)}async function qeA(g){try{if(ic()!==!0)return Wm(g)}catch(A){return jo&&console.log("License check failed",A),Wm(g)}jo&&Wm(g)}async function Wm(g){g.domElement.addEventListener("ready",()=>!0),await(Ta==null?void 0:Ta.catch(()=>{})),!ic()&&beA()}let Zq=0;async function beA(g){const A=Date.now();if(A-Zq<2e3)return;Zq=A;const t=`
|
|
5019
5024
|
position: relative;
|
|
5020
5025
|
display: block;
|
|
5021
5026
|
font-size: 18px;
|
|
@@ -5062,7 +5067,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
5062
5067
|
<div class="wrapper">
|
|
5063
5068
|
<img class="logo" src=${zeA} />
|
|
5064
5069
|
</div>
|
|
5065
|
-
`,this._root.appendChild(e.content.cloneNode(!0)),this.wrapper=this._root.querySelector(".wrapper"),this._root.appendChild(this.wrapper),this.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),this.wrapper.setAttribute("title","Made with Needle Engine")}static get elementName(){return Ry}static create(){return document.createElement(Ry)}setLogoVisible(e){this.logoElement.style.display=e?"block":"none"}}customElements.get(Ry)||customElements.define(Ry,UH);const jm=IA("debugspatialmenu");class VeA{constructor(A,e){r(this,"_context");r(this,"needleMenu");r(this,"htmlButtonsMap",new Map);r(this,"enabled",!0);r(this,"uiisDirty",!1);r(this,"_showNeedleLogo");r(this,"_wasInXR",!1);r(this,"preRender",()=>{var e;if(!this.enabled){(e=this.menu)==null||e.removeFromParent();return}jm&&JB()&&this.updateMenu();const A=this._context.xr;if(!(A!=null&&A.running)){this._wasInXR&&(this._wasInXR=!1,this.onExitXR());return}this._wasInXR||(this._wasInXR=!0,this.onEnterXR()),this.updateMenu()});r(this,"_menuTarget",new pA);r(this,"positionFilter",new OU(90,.5));r(this,"familyName","Needle Spatial Menu");r(this,"menu");r(this,"_poweredByNeedleElement");var i;this._context=A,this._context.pre_render_callbacks.push(this.preRender),this.needleMenu=e;const t=(i=this.needleMenu.shadowRoot)==null?void 0:i.querySelector(".options");t?new MutationObserver(o=>{if(this.enabled&&!(this._context.isInXR==!1&&!jm))for(const s of o)s.type==="childList"&&(s.addedNodes.forEach(n=>{this.createButtonFromHTMLNode(n)}),s.removedNodes.forEach(n=>{const C=n,a=this.htmlButtonsMap.get(C);a&&(this.htmlButtonsMap.delete(C),a.remove(),bt.update())}))}).observe(t,{childList:!0}):console.error("Could not find options container in needle menu")}setEnabled(A){var e;this.enabled=A,A||(e=this.menu)==null||e.removeFromParent()}onDestroy(){const A=this._context.pre_render_callbacks.indexOf(this.preRender);A>-1&&this._context.pre_render_callbacks.splice(A,1)}markDirty(){this.uiisDirty=!0}showNeedleLogo(A){this._showNeedleLogo=A}onEnterXR(){var e;const A=(e=this.needleMenu.shadowRoot)==null?void 0:e.querySelector(".options");A&&A.childNodes.forEach(t=>{this.createButtonFromHTMLNode(t)})}onExitXR(){var A;(A=this.menu)==null||A.removeFromParent()}createButtonFromHTMLNode(A){const e=this.getMenu(),t=this.htmlButtonsMap.get(A);if(t){t.add();return}const i=A,I=this.createButton(e,i);this.htmlButtonsMap.set(i,I),I.add()}updateMenu(){var I,o;const A=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(A);const e=this._context.mainCamera,t=this._context.xr,i=(t==null?void 0:t.rigScale)||1;if(e){const s=e.worldPosition,n=e.worldForward.multiplyScalar(-1),C=n.y>.6,a=n.y>.4,B=A.visible?a:C,Q=!A.visible&&B;A.visible=B||JB()&&jm,n.multiplyScalar(3*i),s.add(n),(Q||!1)&&(A.position.copy(this._menuTarget.position),A.position.y+=1,this._menuTarget.position.copy(A.position),this.positionFilter.reset(A.position),A.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const c=this._menuTarget.position.distanceTo(s);(Q||c>1.5*i)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(s),this._context.scene.add(this._menuTarget),eu(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,A.position,this._context.time.time);const d=5;(I=this.menu)==null||I.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*d),(o=this.menu)==null||o.scale.setScalar(i)}this.uiisDirty&&(this.uiisDirty=!1,bt.update())}ensureRenderOnTop(A,e=0){A instanceof lA&&(A.material.depthTest=!1,A.material.depthWrite=!1),A.renderOrder=1e3+e*2;for(const t of A.children)this.ensureRenderOnTop(t,e+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new bt.Block({boxSizing:"border-box",fontFamily:this.familyName,height:"auto",fontSize:.1,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:.55,borderRadius:.04,whiteSpace:"pre-wrap",flexDirection:"row",alignItems:"center",padding:new Ae(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const A=V.get("ObjectRaycaster");return A&&Ha(this.menu,new A),this.menu}handleNeedleWatermark(){var A;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new bt.Block({width:"auto",height:"auto",fontSize:.05,whiteSpace:"pre-wrap",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",margin:.02,borderRadius:.02,padding:.02,backgroundColor:16777215,backgroundOpacity:1}),this._poweredByNeedleElement["needle:use_eventsystem"]=!0;const e=new Xq(this._context,()=>globalThis.open("https://needle.tools","_self"));Ha(this._poweredByNeedleElement,e);const t=new bt.Text({textContent:"Powered by",width:"auto",height:"auto"}),i=new bt.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ae(0,0,0,.02)});this._poweredByNeedleElement.add(t),this._poweredByNeedleElement.add(i),(A=this.menu)==null||A.add(this._poweredByNeedleElement),this.markDirty(),new yn().load("./include/needle/poweredbyneedle.webp",o=>{var n;e.allowModifyUI=!1,t.removeFromParent(),i.removeFromParent();const s=o.image.width/o.image.height;(n=this._poweredByNeedleElement)==null||n.set({backgroundImage:o,backgroundOpacity:1,width:.1*s,height:.1}),this.markDirty()})}if(this.menu){const e=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&Ks())e>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const t=this.menu.children.indexOf(this._poweredByNeedleElement);e!==t&&this.markDirty()}}}ensureFont(){let A=bt.FontLibrary.getFontFamily(this.familyName);if(!A){A=bt.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{this.markDirty()})}}createButton(A,e){const t=new bt.Block({width:"auto",height:"auto",whiteSpace:"pre-wrap",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",backgroundColor:16777215,backgroundOpacity:0,padding:.02,margin:.01,borderRadius:.02,cursor:"pointer",fontSize:.05}),i=new bt.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});t.add(i),t["needle:use_eventsystem"]=!0;const I=new Xq(this._context,()=>e.click());return Ha(t,I),new ZeA(this,A,e,t,i)}}class ZeA{constructor(A,e,t,i,I){r(this,"menu");r(this,"root");r(this,"htmlbutton");r(this,"spatialContainer");r(this,"spatialText");r(this,"spatialIcon");r(this,"_lastText","");r(this,"_lastTexture");this.menu=A,this.root=e,this.htmlbutton=t,this.spatialContainer=i,this.spatialText=I,new MutationObserver(s=>{for(const n of s)n.type==="attributes"?n.attributeName==="style"&&this.updateVisible():n.type==="childList"&&this.updateText()}).observe(t,{attributes:!0,childList:!0}),this.updateText()}add(){this.spatialContainer.parent!=this.root&&(this.root.add(this.spatialContainer),this.menu.markDirty(),this.updateVisible(),this.updateText())}remove(){this.spatialContainer.parent&&(this.spatialContainer.removeFromParent(),this.menu.markDirty())}updateVisible(){const A=this.spatialContainer.visible;this.spatialContainer.visible=this.htmlbutton.style.display!=="none",A!==this.spatialContainer.visible&&this.menu.markDirty()}updateText(){let A="",e="";this.htmlbutton.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE?A+=t.textContent:t instanceof HTMLElement&&kH(t)&&t.textContent&&(e=t.textContent)}),this._lastText!==A&&(this._lastText=A,this.spatialText.name=A,this.spatialText.set({textContent:A}),this.menu.markDirty()),A.length<=0?this.spatialText.parent&&(this.spatialText.removeFromParent(),this.menu.markDirty()):this.spatialText.parent||(this.spatialContainer.add(this.spatialText),this.menu.markDirty()),e&&this.createIcon(e)}async createIcon(A){var t;if(!this.spatialIcon){const i=await Nk(A);if(i&&!this.spatialIcon){const o=new bt.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:i,backgroundOpacity:1,margin:new Ae(0,.005,0,0)});this.spatialIcon=o,this.spatialContainer.add(o),this.menu.markDirty()}}if(A!=this._lastTexture){this._lastTexture=A;const i=await Nk(A);i&&((t=this.spatialIcon)==null||t.set({backgroundImage:i}),this.menu.markDirty())}const e=this.spatialContainer.children.indexOf(this.spatialIcon);e>0&&(this.spatialContainer.children.splice(e,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class Xq{constructor(A,e){r(this,"isComponent",!0);r(this,"enabled",!0);r(this,"gameObject");r(this,"allowModifyUI",!0);r(this,"context");r(this,"onclick");this.context=A,this.onclick=e}get activeAndEnabled(){return!0}__internalAwake(){}__internalEnable(){}__internalDisable(){}__internalStart(){}onEnable(){}onDisable(){}get element(){return this.gameObject}onPointerEnter(){this.context.input.setCursorPointer(),this.allowModifyUI&&(this.element.set({backgroundOpacity:1}),bt.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),bt.update())}onPointerDown(A){A.use()}onPointerUp(A){A.use()}onPointerClick(A){A.use(),this.onclick()}}const pE="needle-menu",Uy=IA("debugmenu"),$q=IA("debugnoncommercial");let XeA=class{constructor(A){r(this,"_context");r(this,"_menu");r(this,"_spatialMenu");r(this,"onPostMessage",A=>{if(A.origin===globalThis.location.origin&&typeof A.data=="object"){const e=A.data,t=e.type;if(t==="needle:menu"){const i=e.button;if(i){if(!i.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!i.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const I=document.createElement("button");if(I.textContent=i.label,i.icon){const o=uo(i.icon);I.prepend(o)}i.priority&&I.setAttribute("priority",i.priority.toString()),I.onclick=()=>{if(i.onclick){const o=i.onclick.startsWith("http")||i.onclick.startsWith("www."),s=i.target||"_blank";o?globalThis.open(i.onclick,s):console.error("NeedleMenu: onclick is not a valid link",i.onclick)}},this._menu.appendChild(I)}else Uy&&console.error("NeedleMenu: unknown postMessage event",e)}else Uy&&console.warn("NeedleMenu: unknown postMessage type",t,e)}});r(this,"onStartXR",A=>{A.session.isScreenBasedAR&&(this._menu.previousParent=this._menu.parentNode,this._context.arOverlayElement.appendChild(this._menu),A.session.session.addEventListener("end",this.onExitXR))});r(this,"onExitXR",()=>{this._menu.previousParent&&(this._menu.previousParent.appendChild(this._menu),delete this._menu.previousParent)});r(this,"_muteButton");r(this,"_fullscreenButton");this._menu=rS.getOrCreate(A.domElement),this._context=A,this._spatialMenu=new VeA(A,this._menu),window.addEventListener("message",this.onPostMessage),oS(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(A){this._menu.setPosition(A)}showNeedleLogo(A){var e;this._menu.showNeedleLogo(A),(e=this._spatialMenu)==null||e.showNeedleLogo(A)}showSpatialMenu(A){this._spatialMenu.setEnabled(A)}showAudioPlaybackOption(A){var e;if(!A){(e=this._muteButton)==null||e.remove();return}this._muteButton=_a.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(A){var e;if(!A){(e=this._fullscreenButton)==null||e.remove();return}this._fullscreenButton=_a.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(A){this._menu.appendChild(A)}};class rS extends HTMLElement{constructor(){var n,C,a,B;super();r(this,"_domElement",null);r(this,"_sizeChangeInterval");r(this,"_userRequestedLogoVisible");r(this,"root");r(this,"wrapper");r(this,"options");r(this,"logoContainer");r(this,"_isHandlingChange",!1);r(this,"_didSort",new Map);r(this,"_lastAvailableWidthChange",0);r(this,"_timeoutHandle",0);r(this,"handleSizeChange",(e,t)=>{if(!this._domElement)return;const i=this._domElement.clientWidth;if(i<500){this.root.classList.add("compact");return}const I=20*2,o=i-I;if(!t&&Math.abs(o-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=o,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const C=n();C<0?this.root.classList.add("compact"):C>0&&(this.root.classList.remove("compact"),n()<0&&this.root.classList.add("compact"))},200);const s=()=>this.options.clientWidth+this.logoContainer.clientWidth,n=()=>o-s()});const e=document.createElement("template");e.innerHTML=`<style>
|
|
5070
|
+
`,this._root.appendChild(e.content.cloneNode(!0)),this.wrapper=this._root.querySelector(".wrapper"),this._root.appendChild(this.wrapper),this.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),this.wrapper.setAttribute("title","Made with Needle Engine")}static get elementName(){return Ry}static create(){return document.createElement(Ry)}setLogoVisible(e){this.logoElement.style.display=e?"block":"none"}}customElements.get(Ry)||customElements.define(Ry,UH);const jm=IA("debugspatialmenu");class VeA{constructor(A,e){r(this,"_context");r(this,"needleMenu");r(this,"htmlButtonsMap",new Map);r(this,"enabled",!0);r(this,"uiisDirty",!1);r(this,"_showNeedleLogo");r(this,"_wasInXR",!1);r(this,"preRender",()=>{var e;if(!this.enabled){(e=this.menu)==null||e.removeFromParent();return}jm&&JB()&&this.updateMenu();const A=this._context.xr;if(!(A!=null&&A.running)){this._wasInXR&&(this._wasInXR=!1,this.onExitXR());return}this._wasInXR||(this._wasInXR=!0,this.onEnterXR()),this.updateMenu()});r(this,"_menuTarget",new pA);r(this,"positionFilter",new OU(90,.5));r(this,"familyName","Needle Spatial Menu");r(this,"menu");r(this,"_poweredByNeedleElement");var i;this._context=A,this._context.pre_render_callbacks.push(this.preRender),this.needleMenu=e;const t=(i=this.needleMenu.shadowRoot)==null?void 0:i.querySelector(".options");t?new MutationObserver(o=>{if(this.enabled&&!(this._context.isInXR==!1&&!jm))for(const s of o)s.type==="childList"&&(s.addedNodes.forEach(n=>{this.createButtonFromHTMLNode(n)}),s.removedNodes.forEach(n=>{const C=n,a=this.htmlButtonsMap.get(C);a&&(this.htmlButtonsMap.delete(C),a.remove(),bt.update())}))}).observe(t,{childList:!0}):console.error("Could not find options container in needle menu")}setEnabled(A){var e;this.enabled=A,A||(e=this.menu)==null||e.removeFromParent()}onDestroy(){const A=this._context.pre_render_callbacks.indexOf(this.preRender);A>-1&&this._context.pre_render_callbacks.splice(A,1)}markDirty(){this.uiisDirty=!0}showNeedleLogo(A){this._showNeedleLogo=A}onEnterXR(){var e;const A=(e=this.needleMenu.shadowRoot)==null?void 0:e.querySelector(".options");A&&A.childNodes.forEach(t=>{this.createButtonFromHTMLNode(t)})}onExitXR(){var A;(A=this.menu)==null||A.removeFromParent()}createButtonFromHTMLNode(A){const e=this.getMenu(),t=this.htmlButtonsMap.get(A);if(t){t.add();return}const i=A,I=this.createButton(e,i);this.htmlButtonsMap.set(i,I),I.add()}updateMenu(){var I,o;const A=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(A);const e=this._context.mainCamera,t=this._context.xr,i=(t==null?void 0:t.rigScale)||1;if(e){const s=e.worldPosition,n=e.worldForward.multiplyScalar(-1),C=n.y>.6,a=n.y>.4,B=A.visible?a:C,Q=!A.visible&&B;A.visible=B||JB()&&jm,n.multiplyScalar(3*i),s.add(n),(Q||!1)&&(A.position.copy(this._menuTarget.position),A.position.y+=1,this._menuTarget.position.copy(A.position),this.positionFilter.reset(A.position),A.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const c=this._menuTarget.position.distanceTo(s);(Q||c>1.5*i)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(s),this._context.scene.add(this._menuTarget),eu(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,A.position,this._context.time.time);const d=5;(I=this.menu)==null||I.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*d),(o=this.menu)==null||o.scale.setScalar(i)}this.uiisDirty&&(this.uiisDirty=!1,bt.update())}ensureRenderOnTop(A,e=0){A instanceof lA&&(A.material.depthTest=!1,A.material.depthWrite=!1),A.renderOrder=1e3+e*2;for(const t of A.children)this.ensureRenderOnTop(t,e+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new bt.Block({boxSizing:"border-box",fontFamily:this.familyName,height:"auto",fontSize:.1,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:.55,borderRadius:.04,whiteSpace:"pre-wrap",flexDirection:"row",alignItems:"center",padding:new Ae(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const A=V.get("ObjectRaycaster");return A&&Ha(this.menu,new A),this.menu}handleNeedleWatermark(){var A;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new bt.Block({width:"auto",height:"auto",fontSize:.05,whiteSpace:"pre-wrap",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",margin:.02,borderRadius:.02,padding:.02,backgroundColor:16777215,backgroundOpacity:1}),this._poweredByNeedleElement["needle:use_eventsystem"]=!0;const e=new Xq(this._context,()=>globalThis.open("https://needle.tools","_self"));Ha(this._poweredByNeedleElement,e);const t=new bt.Text({textContent:"Powered by",width:"auto",height:"auto"}),i=new bt.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ae(0,0,0,.02)});this._poweredByNeedleElement.add(t),this._poweredByNeedleElement.add(i),(A=this.menu)==null||A.add(this._poweredByNeedleElement),this.markDirty(),new yn().load("./include/needle/poweredbyneedle.webp",o=>{var n;e.allowModifyUI=!1,t.removeFromParent(),i.removeFromParent();const s=o.image.width/o.image.height;(n=this._poweredByNeedleElement)==null||n.set({backgroundImage:o,backgroundOpacity:1,width:.1*s,height:.1}),this.markDirty()})}if(this.menu){const e=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&Ks())e>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const t=this.menu.children.indexOf(this._poweredByNeedleElement);e!==t&&this.markDirty()}}}ensureFont(){let A=bt.FontLibrary.getFontFamily(this.familyName);if(!A){A=bt.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{this.markDirty()})}}createButton(A,e){const t=new bt.Block({width:"auto",height:"auto",whiteSpace:"pre-wrap",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",backgroundColor:16777215,backgroundOpacity:0,padding:.02,margin:.01,borderRadius:.02,cursor:"pointer",fontSize:.05}),i=new bt.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});t.add(i),t["needle:use_eventsystem"]=!0;const I=new Xq(this._context,()=>e.click());return Ha(t,I),new ZeA(this,A,e,t,i)}}class ZeA{constructor(A,e,t,i,I){r(this,"menu");r(this,"root");r(this,"htmlbutton");r(this,"spatialContainer");r(this,"spatialText");r(this,"spatialIcon");r(this,"_lastText","");r(this,"_lastTexture");this.menu=A,this.root=e,this.htmlbutton=t,this.spatialContainer=i,this.spatialText=I,new MutationObserver(s=>{for(const n of s)n.type==="attributes"?n.attributeName==="style"&&this.updateVisible():n.type==="childList"&&this.updateText()}).observe(t,{attributes:!0,childList:!0}),this.updateText()}add(){this.spatialContainer.parent!=this.root&&(this.root.add(this.spatialContainer),this.menu.markDirty(),this.updateVisible(),this.updateText())}remove(){this.spatialContainer.parent&&(this.spatialContainer.removeFromParent(),this.menu.markDirty())}updateVisible(){const A=this.spatialContainer.visible;this.spatialContainer.visible=this.htmlbutton.style.display!=="none",A!==this.spatialContainer.visible&&this.menu.markDirty()}updateText(){let A="",e="";this.htmlbutton.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE?A+=t.textContent:t instanceof HTMLElement&&kH(t)&&t.textContent&&(e=t.textContent)}),this._lastText!==A&&(this._lastText=A,this.spatialText.name=A,this.spatialText.set({textContent:A}),this.menu.markDirty()),A.length<=0?this.spatialText.parent&&(this.spatialText.removeFromParent(),this.menu.markDirty()):this.spatialText.parent||(this.spatialContainer.add(this.spatialText),this.menu.markDirty()),e&&this.createIcon(e)}async createIcon(A){var t;if(!this.spatialIcon){const i=await Nk(A);if(i&&!this.spatialIcon){const o=new bt.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:i,backgroundOpacity:1,margin:new Ae(0,.005,0,0)});this.spatialIcon=o,this.spatialContainer.add(o),this.menu.markDirty()}}if(A!=this._lastTexture){this._lastTexture=A;const i=await Nk(A);i&&((t=this.spatialIcon)==null||t.set({backgroundImage:i}),this.menu.markDirty())}const e=this.spatialContainer.children.indexOf(this.spatialIcon);e>0&&(this.spatialContainer.children.splice(e,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class Xq{constructor(A,e){r(this,"isComponent",!0);r(this,"enabled",!0);r(this,"gameObject");r(this,"allowModifyUI",!0);r(this,"context");r(this,"onclick");this.context=A,this.onclick=e}get activeAndEnabled(){return!0}__internalAwake(){}__internalEnable(){}__internalDisable(){}__internalStart(){}onEnable(){}onDisable(){}get element(){return this.gameObject}onPointerEnter(){this.context.input.setCursorPointer(),this.allowModifyUI&&(this.element.set({backgroundOpacity:1}),bt.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),bt.update())}onPointerDown(A){A.use()}onPointerUp(A){A.use()}onPointerClick(A){A.use(),this.onclick()}}const pE="needle-menu",Uy=IA("debugmenu"),$q=IA("debugnoncommercial");let XeA=class{constructor(A){r(this,"_context");r(this,"_menu");r(this,"_spatialMenu");r(this,"onPostMessage",A=>{if(A.origin===globalThis.location.origin&&typeof A.data=="object"){const e=A.data,t=e.type;if(t==="needle:menu"){const i=e.button;if(i){if(!i.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!i.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const I=document.createElement("button");if(I.textContent=i.label,i.icon){const o=uo(i.icon);I.prepend(o)}i.priority&&I.setAttribute("priority",i.priority.toString()),I.onclick=()=>{if(i.onclick){const o=i.onclick.startsWith("http")||i.onclick.startsWith("www."),s=i.target||"_blank";o?globalThis.open(i.onclick,s):console.error("NeedleMenu: onclick is not a valid link",i.onclick)}},this._menu.appendChild(I)}else Uy&&console.error("NeedleMenu: unknown postMessage event",e)}else Uy&&console.warn("NeedleMenu: unknown postMessage type",t,e)}});r(this,"onStartXR",A=>{A.session.isScreenBasedAR&&(this._menu.previousParent=this._menu.parentNode,this._context.arOverlayElement.appendChild(this._menu),A.session.session.addEventListener("end",this.onExitXR))});r(this,"onExitXR",()=>{this._menu.previousParent&&(this._menu.previousParent.appendChild(this._menu),delete this._menu.previousParent)});r(this,"_muteButton");r(this,"_fullscreenButton");this._menu=rS.getOrCreate(A.domElement,A),this._context=A,this._spatialMenu=new VeA(A,this._menu),window.addEventListener("message",this.onPostMessage),oS(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(A){this._menu.setPosition(A)}showNeedleLogo(A){var e;this._menu.showNeedleLogo(A),(e=this._spatialMenu)==null||e.showNeedleLogo(A)}showSpatialMenu(A){this._spatialMenu.setEnabled(A)}showAudioPlaybackOption(A){var e;if(!A){(e=this._muteButton)==null||e.remove();return}this._muteButton=_a.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(A){var e;if(!A){(e=this._fullscreenButton)==null||e.remove();return}this._fullscreenButton=_a.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(A){this._menu.appendChild(A)}};class rS extends HTMLElement{constructor(){var C,a,B,Q;super();r(this,"_domElement",null);r(this,"_context",null);r(this,"_sizeChangeInterval");r(this,"_userRequestedLogoVisible");r(this,"root");r(this,"wrapper");r(this,"options");r(this,"logoContainer");r(this,"_isHandlingChange",!1);r(this,"_didSort",new Map);r(this,"_lastAvailableWidthChange",0);r(this,"_timeoutHandle",0);r(this,"handleSizeChange",(e,t)=>{if(!this._domElement)return;const i=this._domElement.clientWidth;if(i<500){this.root.classList.add("compact");return}const I=20*2,o=i-I;if(!t&&Math.abs(o-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=o,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const C=n();C<0?this.root.classList.add("compact"):C>0&&(this.root.classList.remove("compact"),n()<0&&this.root.classList.add("compact"))},200);const s=()=>this.options.clientWidth+this.logoContainer.clientWidth,n=()=>o-s()});const e=document.createElement("template");e.innerHTML=`<style>
|
|
5066
5071
|
|
|
5067
5072
|
#root {
|
|
5068
5073
|
position: absolute;
|
|
@@ -5255,7 +5260,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
5255
5260
|
</div>
|
|
5256
5261
|
</div>
|
|
5257
5262
|
</div>
|
|
5258
|
-
`;const t=this.attachShadow({mode:"open"});RH(),Fk("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{loadedCallback:()=>{this.handleSizeChange()}}),Fk("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:t});const i=e.content.cloneNode(!0);t==null||t.appendChild(i),this.root=t.querySelector("#root"),this.wrapper=(
|
|
5263
|
+
`;const t=this.attachShadow({mode:"open"});RH(),Fk("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{loadedCallback:()=>{this.handleSizeChange()}}),Fk("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:t});const i=e.content.cloneNode(!0);t==null||t.appendChild(i),this.root=t.querySelector("#root"),this.wrapper=(C=this.root)==null?void 0:C.querySelector(".wrapper"),this.options=(a=this.root)==null?void 0:a.querySelector(".options"),this.logoContainer=(B=this.root)==null?void 0:B.querySelector(".logo"),(Q=this.root)==null||Q.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const I=UH.create();I.style.minHeight="1rem",this.logoContainer.append(I),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),FeA(E=>{E==!0&&Ks()&&!$q&&(this.logoContainer.style.display=this._userRequestedLogoVisible?"":"none")});let o=this._context;setTimeout(()=>o=this._context);let s=-1;new MutationObserver(E=>{var d;this.onChangeDetected(E);const c=this==null?void 0:this.parentNode;(this.style.display!="flex"||this.style.visibility!="visible"||this.style.opacity!="1"||c!=((d=this._domElement)==null?void 0:d.shadowRoot))&&(Ks()||(clearInterval(s),s=setInterval(()=>{var h,l,p;o!=null&&o.isInAR&&o.arOverlayElement?c!=o.arOverlayElement&&o.arOverlayElement.appendChild(this):c!=((h=this._domElement)==null?void 0:h.shadowRoot)&&((p=(l=this._domElement)==null?void 0:l.shadowRoot)==null||p.appendChild(this)),this.style.display="flex",this.style.visibility="visible",this.style.opacity="1"},5)))}).observe(this.root,{childList:!0,subtree:!0,attributes:!0}),Uy&&this.___insertDebugOptions()}static create(){return document.createElement(pE,{is:pE})}static getOrCreate(e,t){let i=e.querySelector(pE);return!i&&e.shadowRoot&&(i=e.shadowRoot.querySelector(pE)),i||(i=rS.create(),i._domElement=e,i._context=t,e.shadowRoot?e.shadowRoot.appendChild(i):e.appendChild(i)),i}connectedCallback(){var e;window.addEventListener("resize",this.handleSizeChange),(e=this._domElement)==null||e.addEventListener("resize",this.handleSizeChange),this.handleMenuVisible(),this._sizeChangeInterval=setInterval(()=>this.handleSizeChange(void 0,!0),5e3)}disconnectedCallback(){var e;window.removeEventListener("resize",this.handleSizeChange),(e=this._domElement)==null||e.removeEventListener("resize",this.handleSizeChange),clearInterval(this._sizeChangeInterval)}showNeedleLogo(e){if(this._userRequestedLogoVisible=e,!Ks()||$q){ue()&&console.warn("Needle Menu: You need a PRO license to hide the Needle Engine logo.");return}this.logoContainer.style.display=e?"":"none"}setPosition(e){if(e!=="top"&&e!=="bottom")return console.error("NeedleMenu.setPosition: invalid position",e);this.root.classList.remove("top","bottom"),this.root.classList.add(e)}append(...e){for(const t of e)if(typeof t=="string"){const i=document.createTextNode(t);this.options.appendChild(i)}else this.options.appendChild(t)}appendChild(e){return this.options.appendChild(e)}prepend(...e){for(const t of e)if(typeof t=="string"){const i=document.createTextNode(t);this.options.prepend(i)}else this.options.prepend(t)}onChangeDetected(e){if(!this._isHandlingChange){this._isHandlingChange=!0;try{this.handleMenuVisible();for(const t of e)t.target==this.options&&this.onOptionsChildrenChanged(t)}finally{this._isHandlingChange=!1}}}onOptionsChildrenChanged(e){let t=!1;for(let i=0;i<this.options.children.length;i++)if(this.options.children[i].style.display!="none"){t=!0;break}if(this.logoContainer.classList.toggle("any-options",t),this.handleSizeChange(),e.type==="childList"){let i=!1;const I=Date.now();for(let o=0;o<e.addedNodes.length;o++){const s=e.addedNodes[o],n=this._didSort.get(s);typeof n=="number"&&I-n<100||(this._didSort.set(s,I),i=!0)}if(i){const o=Array.from(this.options.children);o.sort((s,n)=>{const C=parseInt(s.getAttribute("priority")||"0"),a=parseInt(n.getAttribute("priority")||"0");return C-a});for(const s of o)this.options.appendChild(s)}}}handleMenuVisible(){Uy&&console.log("Update VisibleState: Any Content?",this.hasAnyContent),this.hasAnyContent?this.root.style.display="":this.root.style.display="none"}get hasAnyContent(){if(this.logoContainer.style.display!="none")return!0;for(let e=0;e<this.options.children.length;e++)if(this.options.children[e].style.display!="none")return!0;return!1}___insertDebugOptions(){window.addEventListener("keydown",i=>{i.key==="p"&&this.setPosition(this.root.classList.contains("top")?"bottom":"top")});const e=document.createElement("button");e.textContent="Hide Buttons",e.onclick=()=>{const i=new Array(this.options.children.length);for(let I=0;I<this.options.children.length;I++)i[I]=this.options.children[I];for(const I of i)this.options.removeChild(I);setTimeout(()=>{for(const I of i)this.options.appendChild(I)},1e3)},this.appendChild(e);const t=document.createElement("button");t.textContent="Toggle Logo",t.addEventListener("click",()=>{this.logoContainer.style.display=this.logoContainer.style.display==="none"?"":"none"}),this.appendChild(t)}}customElements.get(pE)||customElements.define(pE,rS);const Ng=IA("debugcontext"),$eA=IA("stats"),AtA=IA("debugactive"),etA=IA("debugframerate"),ttA=IA("debugcoroutine"),itA={};class gtA{constructor(){r(this,"name");r(this,"alias");r(this,"hash");r(this,"runInBackground");r(this,"domElement");r(this,"renderer");r(this,"camera");r(this,"scene")}}var Vi=(g=>(g[g.Start=-1]="Start",g[g.EarlyUpdate=0]="EarlyUpdate",g[g.Update=1]="Update",g[g.LateUpdate=2]="LateUpdate",g[g.OnBeforeRender=3]="OnBeforeRender",g[g.OnAfterRender=4]="OnAfterRender",g[g.PrePhysicsStep=9]="PrePhysicsStep",g[g.PostPhysicsStep=10]="PostPhysicsStep",g[g.Undefined=-1]="Undefined",g))(Vi||{});function BS(g,A){if(!g)return;if(!g.isComponent){(ue()||Ng)&&console.error(`Registered script is not a Needle Engine component.
|
|
5259
5264
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
5260
5265
|
`,g);return}const e=(A==null?void 0:A.new_scripts)??xe.Current.new_scripts;e.includes(g)||e.push(g)}const Wt=class{constructor(A){r(this,"name");r(this,"alias");r(this,"isManagedExternally",!1);r(this,"isPaused",!1);r(this,"runInBackground",!1);r(this,"targetFrameRate");r(this,"physicsSteps",1);r(this,"hash");r(this,"domElement");r(this,"_resolutionScaleFactor",1);r(this,"_boundingClientRectFrame",-1);r(this,"_boundingClientRect",null);r(this,"_domX");r(this,"_domY");r(this,"xr",null);r(this,"_xrFrame",null);r(this,"_currentFrameEvent",-1);r(this,"scene");r(this,"renderer");r(this,"composer",null);r(this,"scripts",[]);r(this,"scripts_pausedChanged",[]);r(this,"scripts_earlyUpdate",[]);r(this,"scripts_update",[]);r(this,"scripts_lateUpdate",[]);r(this,"scripts_onBeforeRender",[]);r(this,"scripts_onAfterRender",[]);r(this,"scripts_WithCorroutines",[]);r(this,"scripts_immersive_vr",[]);r(this,"scripts_immersive_ar",[]);r(this,"coroutines",{});r(this,"post_setup_callbacks",[]);r(this,"pre_update_callbacks",[]);r(this,"pre_render_callbacks",[]);r(this,"post_render_callbacks",[]);r(this,"pre_update_oneshot_callbacks",[]);r(this,"new_scripts",[]);r(this,"new_script_start",[]);r(this,"new_scripts_pre_setup_callbacks",[]);r(this,"new_scripts_post_setup_callbacks",[]);r(this,"new_scripts_xr",[]);r(this,"mainCameraComponent");r(this,"_camera",null);r(this,"application");r(this,"time");r(this,"input");r(this,"physics");r(this,"connection");r(this,"assets");r(this,"mainLight",null);r(this,"sceneLighting");r(this,"addressables");r(this,"lightmaps");r(this,"players");r(this,"menu");r(this,"_sizeChanged",!1);r(this,"_isCreated",!1);r(this,"_isCreating",!1);r(this,"_isVisible",!1);r(this,"_stats",$eA?new w$:null);r(this,"_intersectionObserver",null);r(this,"_disposeCallbacks",[]);r(this,"maxRenderResolution");r(this,"_originalCreationArgs");r(this,"onUnhandledRejection",A=>{this.domElement.dispatchEvent(new CustomEvent("error",{detail:A.reason}))});r(this,"_cameraStack",[]);r(this,"_onBeforeRenderListeners",new Map);r(this,"_onAfterRenderListeners",new Map);r(this,"_requireDepthTexture",!1);r(this,"_requireColorTexture",!1);r(this,"_renderTarget");r(this,"_isRendering",!1);r(this,"_createId",0);r(this,"_renderlooperrors",0);r(this,"_lastTimestamp",0);r(this,"_accumulatedTime",0);r(this,"_dispatchReadyAfterFrame",!1);r(this,"_wasPaused",!1);this.name=(A==null?void 0:A.name)||"",this.alias=A==null?void 0:A.alias,this.domElement=(A==null?void 0:A.domElement)||document.body,this.hash=A==null?void 0:A.hash,A!=null&&A.renderer&&(this.renderer=A.renderer,this.isManagedExternally=!0),(A==null?void 0:A.runInBackground)!==void 0&&(this.runInBackground=A.runInBackground),A!=null&&A.scene?this.scene=A.scene:this.scene=new rI,A!=null&&A.camera&&(this._camera=A.camera),this.application=new Qd(this),this.time=new MH,this.input=new B2(this),this.physics=new fH(this),this.connection=new nH(this),this.assets=new y_,this.sceneLighting=new SH(this),this.addressables=new o2(this),this.lightmaps=new SeA(this),this.players=new yH(this),this.menu=new XeA(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(i=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.disconnect()),this._intersectionObserver=new IntersectionObserver(i=>{this._isVisible=i[0].isIntersecting}),this._disposeCallbacks.push(()=>{var i;return(i=this._intersectionObserver)==null?void 0:i.disconnect()}),nt.register(this)}static get DefaultTargetFrameRate(){return Wt._defaultTargetFramerate.value}static set DefaultTargetFrameRate(A){Wt._defaultTargetFramerate.value=A}static get DefaultWebGLRendererParameters(){return Wt._defaultWebglRendererParameters}get version(){return hn}static get Current(){return nt.Current}static set Current(A){nt.Current=A}appendHTMLElement(A){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(A):this.domElement.appendChild(A)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(A){if(A!==this._resolutionScaleFactor&&typeof A=="number"){if(A<=0){console.error("Invalid resolution scale factor",A);return}this._resolutionScaleFactor=A,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var A,e;return((e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var A;return(A=this.xr)==null?void 0:A.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var A,e;return(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var A,e;return this.renderer.xr.isPresenting?(e=(A=this.renderer)==null?void 0:A.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const A=this.domElement;return typeof A.getAROverlayContainer=="function"?A.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._camera)return this._camera;if(this.mainCameraComponent){const A=this.mainCameraComponent;return A.cam||A.buildCamera(),A.cam}return null}set mainCamera(A){this._camera=A}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(A){var e,t,i;if((e=this.renderer)==null||e.dispose(),A={...Wt.DefaultWebGLRendererParameters,...A},!A.canvas){const I=(i=(t=this.domElement)==null?void 0:t.shadowRoot)==null?void 0:i.querySelector("canvas");I&&(A.canvas=I,Ng&&console.log("Using canvas from shadow root",I))}Ng&&console.log("Using Renderer Parameters:",A,this.domElement),this.renderer=new LC(A),this.renderer.debug.checkShaderErrors=ue()||IA("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=wo,this.renderer.setClearColor(new mA("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=pR,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=de,this.input.bindEvents()}internalOnUpdateVisible(){var A,e;(A=this._intersectionObserver)==null||A.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(A=!1){var e,t,i;if(A||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const I=this.resolutionScaleFactor;let o=this.domWidth*I,s=this.domHeight*I;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),o=Math.min(this.maxRenderResolution.x,o),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),s=Math.min(this.maxRenderResolution.y,s));const n=this.mainCamera;this.updateAspect(n),this.renderer.setSize(o,s,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((t=this.composer.setSize)==null||t.call(this.composer,o,s),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((i=this.composer.setPixelRatio)==null||i.call(this.composer,window.devicePixelRatio)))}}updateAspect(A,e,t){if(!A)return;e===void 0&&(e=this.domWidth),t===void 0&&(t=this.domHeight);const i=A.aspect;A.aspect=e/t,i!==A.aspect&&A.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(A){return this.create(A)}async create(A){try{this._isCreating=!0,A!==this._originalCreationArgs&&(this._originalCreationArgs=Zd(A)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(A);return this._isCreated=!0,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}clear(){var A,e,t,i;nt.dispatchCallback(Ri.ContextClearing,this),qs(this.scene,!0,!0),this.scene=new rI,(A=this.addressables)==null||A.dispose(),(e=this.lightmaps)==null||e.clear(),(i=(t=this.physics)==null?void 0:t.engine)==null||i.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),nt.dispatchCallback(Ri.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var A,e;this.clear(),(A=this.renderer)==null||A.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(Ng&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy();for(const t of this._disposeCallbacks)try{t()}catch(i){console.error("Error in on dispose callback:",i,t)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,nt.dispatchCallback(Ri.ContextDestroyed,this),nt.unregister(this),Wt.Current===this&&(Wt.Current=null)}registerCoroutineUpdate(A,e,t){return typeof(e==null?void 0:e.next)!="function"?(console.error("Registered invalid coroutine function from "+A.name+`
|
|
5261
5266
|
Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
@@ -6290,7 +6295,7 @@ Texture LODs available? ${this.hasTextureLODs?"YES":"NO"}`)}updateLODs(){let A=0
|
|
|
6290
6295
|
}`};var $oA=Object.defineProperty,AsA=Object.getOwnPropertyDescriptor,Yu=(g,A,e,t)=>{for(var i=t>1?void 0:t?AsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&$oA(A,e,i),i};const yM=IA("debugcontactshadows");class pr 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")}start(){yM&&console.log("Create ContactShadows on "+this.gameObject.name,this);const e=512;this.shadowGroup=new NI,this.gameObject.add(this.shadowGroup),this.renderTarget=new Ze(e,e),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Ze(e,e),this.renderTargetBlur.texture.generateMipmaps=!1;const t=new Xi(1,1).rotateX(Math.PI/2);if(this.gameObject instanceof lA){yM&&console.log("ContactShadows: use existing mesh",this.gameObject),this.plane=this.gameObject;const i=this.plane.material=this.plane.material.clone();i.map=this.renderTarget.texture,i.opacity=this.opacity}else{const i=new Bt({map:this.renderTarget.texture,opacity:this.opacity,color:0,transparent:!0,depthWrite:!1});this.plane=new lA(t,i),this.plane.scale.y=-1,this.gameObject.add(this.plane)}this.plane&&(this.plane.renderOrder=1),this.occludeBelowGround&&(this.occluderMesh=new lA(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 lA(t),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane),this.shadowCamera=new bC(-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 Hd,this.depthMaterial.userData.darkness={value:this.darkness},this.depthMaterial.blending=fR,this.depthMaterial.blendEquation=HD,this.backfaceShadows&&(this.depthMaterial.side=ut),this.depthMaterial.onBeforeCompile=i=>{this.depthMaterial&&(i.uniforms.darkness=this.depthMaterial.userData.darkness,i.fragmentShader=`
|
|
6291
6296
|
uniform float darkness;
|
|
6292
6297
|
${i.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) );")}
|
|
6293
|
-
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Ke(ZoA),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Ke(XoA),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,i,I,o,s,n,C;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(i=this.depthMaterial)==null||i.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){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){yM&&console.error("ContactShadows: not initialized yet");return}const t=this.context.scene,i=this.context.renderer,I=i.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof lA&&(this.gameObject.visible=!1,CE(this.gameObject,!1));const s=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const n=i.getClearAlpha();i.setClearAlpha(0);const C=i.xr.enabled;i.xr.enabled=!1,i.setRenderTarget(this.renderTarget),i.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,i.setRenderTarget(I),i.setClearAlpha(n),t.background=s,i.xr.enabled=C}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,i=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(i)}}Yu([D()],pr.prototype,"darkness",2);Yu([D()],pr.prototype,"opacity",2);Yu([D()],pr.prototype,"blur",2);Yu([D()],pr.prototype,"occludeBelowGround",2);Yu([D()],pr.prototype,"backfaceShadows",2);var esA=Object.defineProperty,tsA=Object.getOwnPropertyDescriptor,Tu=(g,A,e,t)=>{for(var i=t>1?void 0:t?tsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&esA(A,e,i),i};const Xb=IA("debugwebxr"),isA=new MA().makeRotationY(Math.PI);class Uo 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 rI);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||e.used)return;let t=this._reticle[0],i=this._hits[0];if(e.origin instanceof cN){const o=this._reticle[e.origin.index];o&&(t=o,i=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=ye.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(ye.active,i)})}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){Xb&&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 i=this.context.scene.children.length-1;i>=0;i--){const I=this.context.scene.children[i];this._placementScene.add(I)}this.context.scene.add(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),nA.addComponent(t,this);for(const i of this._reticle)qs(i);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:on.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:on.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,i,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 BE(this.context)),(i=this.userInput)==null||i.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,i,I){this._hits[t]=i.hit;let o=this._reticle[t];if(!o){if(this.customReticle)if(this.customReticle.asset)o=Sc(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new lA(new KB(.07,.09,32).rotateX(-Math.PI/2),new Bt({side:ut})),o.name="AR Placement Reticle";if(Xb){const s=new ts(1);s.position.y+=.01,o.add(s)}this._reticle[t]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(i.position,this.context.time.deltaTime/.1),o.quaternion.slerp(i.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 i=this._placementScene.children[t];this.context.scene.add(i)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)nA.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),ue()&&si("Hit does not support creating an anchor");return}else{const i=await t.createAnchor(e.viewerPose.transform);e.running&&i&&(this._anchor=i)}}applyViewBasedTransform(e){const t=this.context.mainCamera,i=e,I=t.worldPosition,o=i.worldPosition;I.y=o.y,e.lookAt(I)}onApplyPose(e){var I,o,s,n;const t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject;if(!t){console.warn("No rig object to place");return}(s=ye.active)!=null&&s.rigScale;const i=t.parent||this.context.scene;this._rigPlacementMatrix?(n=this._rigPlacementMatrix)==null||n.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(isA),t.matrix.premultiply(this._startOffset),t.matrix.decompose(t.position,t.quaternion,t.scale),i.add(t)}}Tu([D()],Uo.prototype,"arScale",1);Tu([D()],Uo.prototype,"invertForward",2);Tu([D(ot)],Uo.prototype,"customReticle",2);Tu([D()],Uo.prototype,"useXRAnchor",2);Tu([D()],Uo.prototype,"arTouchTransform",2);const ow=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],i=dT()&&t.clientY<window.innerHeight*.1;this.prev.has(t.identifier)||this.prev.set(t.identifier,{ignore:i,x:0,z:0,screenx:0,screeny:0});const I=this.prev.get(t.identifier);if(I){const o=this.getPositionOnPlane(t.clientX,t.clientY);I.x=o.x,I.z=o.z,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"touchEnd",A=>{A.touches.length<=0&&(this._didMultitouch=!1);for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e];this.prev.delete(t.identifier)}});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||t.ignore)return;const i=this.getPositionOnPlane(e.clientX,e.clientY),I=i.x-t.x,o=i.z-t.z;if(I===0&&o===0)return;this.oneFingerDrag&&this.addMovement(I,o),t.x=i.x,t.z=i.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],i=this.prev.get(e.identifier),I=this.prev.get(t.identifier);if(!i||!I)return;if(this.twoFingerRotate){const o=Math.atan2(e.clientY-t.clientY,e.clientX-t.clientX),s=Math.atan2(i.screeny-I.screeny,i.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=i.screenx-I.screenx,a=i.screeny-I.screeny,B=Math.sqrt(C*C+a*a),Q=n-B;Math.abs(Q)>2&&this.addScale(Q)}i.screenx=e.clientX,i.screeny=e.clientY,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"_raycaster",new PB);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 GI,this.plane.setFromNormalAndCoplanarPoint(ow.up,ow.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:on.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:on.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:on.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:on.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:on.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:on.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 BE=ow;r(BE,"up",new y(0,1,0)),r(BE,"zero",new y(0,0,0)),r(BE,"one",new y(1,1,1));const NK=class{constructor(){r(this,"_quicklookButton");r(this,"_arButton");r(this,"_vrButton");r(this,"_sendToQuestButton")}static create(){return new NK}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 _a.getOrCreate().createQRCode()}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.prepend(uo("view_in_ar")),A.addEventListener("click",()=>{const e=nA.findObjectOfType(Qg);e?(A.classList.add("this-mode-is-requested"),e.exportAndOpen().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 i;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.prepend(uo("view_in_ar")),t.title="Click to start an AR session",t.addEventListener("click",()=>ye.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)"),hB()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createVRButton(A){var i;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.prepend(uo("panorama_photosphere")),t.title="Click to start a VR session",t.addEventListener("click",()=>ye.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)"),hB()||(i=navigator.xr)==null||i.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.prepend(uo("share_windows")),e.title="Click to send this page to the Oculus Browser on your Quest",e.addEventListener("click",()=>{const i=encodeURIComponent(window.location.href);window.open(A+i)}),this.listenToXRSessionState(e),this.hideElementDuringXRSession(e),hB()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>{var i;(i=navigator.xr)!=null&&i.isSessionSupported("immersive-vr")?e.style.display="none":e.style.display=""}),e}createQRCode(){return _a.getOrCreate().createQRCode()}updateSessionSupported(A,e){if(!("xr"in navigator)){A.style.display="none";return}ye.isSessionSupported(e).then(t=>{A.style.display=t?"":"none",ue()&&!t&&console.log('[WebXR] "'+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){oS(e=>{A["previous-display"]=A.style.display,A.style.display="none"}),QN(e=>{A["previous-display"]!=null&&(A.style.display=A["previous-display"])})}listenToXRSessionState(A,e){e&&(ye.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"))}),ye.onSessionRequestEnd(t=>{A.classList.remove("this-mode-is-requested"),A.classList.remove("other-mode-is-requested"),A.disabled=A["was-disabled"]}))}};let Wa=NK;r(Wa,"_instance");var gsA=Object.defineProperty,IsA=Object.getOwnPropertyDescriptor,OC=(g,A,e,t)=>{for(var i=t>1?void 0:t?IsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&gsA(A,e,i),i};const Or=IA("debugtext");var gg=(g=>(g[g.UpperLeft=0]="UpperLeft",g[g.UpperCenter=1]="UpperCenter",g[g.UpperRight=2]="UpperRight",g[g.MiddleLeft=3]="MiddleLeft",g[g.MiddleCenter=4]="MiddleCenter",g[g.MiddleRight=5]="MiddleRight",g[g.LowerLeft=6]="LowerLeft",g[g.LowerCenter=7]="LowerCenter",g[g.LowerRight=8]="LowerRight",g))(gg||{}),rP=(g=>(g[g.Normal=0]="Normal",g[g.Bold=1]="Bold",g[g.Italic=2]="Italic",g[g.BoldAndItalic=3]="BoldAndItalic",g))(rP||{});class YI extends gQ{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 mA(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){Or&&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,Or&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Or&&(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 i,I,o;if(Or&&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 aD({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:(i=this.uiObject)==null?void 0:i.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(e,s,C),this.handleTag(s,a,n);const B=new aD(a);(I=this.uiObject)==null||I.add(B)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,n);const B=new aD(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,i={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&&(Fy(s,i),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,i){if(!e.isEndTag){if(e.type.includes("color")){const I=new wM(e,{color:t.color});if(i.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new mA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new wM(e,{fontWeight:700});i.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new wM(e,{fontStyle:"italic"});i.push(I)}}}getText(e,t,i){return e.substring(t.endIndex,i.startIndex)}getNextTag(e,t=0){const i=e.indexOf("<",t),I=e.indexOf(">",i);if(i>=0&&I>=0){const o=e.substring(i+1,I);return{type:o,startIndex:i,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const i=this.font,I=this.getFamilyNameWithCorrectSuffix(i,t);Or&&console.log("Selected font family:"+I);let o=$G.getFontFamily(I);switch(o||(o=$G.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 i=e.lastIndexOf("-");if(i<0)return e;const I=(a=e.substring(i+1))==null?void 0:a.toLowerCase();if(osA.includes(I))return Or&&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,i);switch(Or&&console.log("Select font: ",e,rP[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}}}OC([D()],YI.prototype,"alignment",2);OC([D()],YI.prototype,"verticalOverflow",2);OC([D()],YI.prototype,"horizontalOverflow",2);OC([D()],YI.prototype,"lineSpacing",2);OC([D()],YI.prototype,"supportRichText",2);OC([D(URL)],YI.prototype,"font",2);OC([D()],YI.prototype,"fontStyle",2);OC([D()],YI.prototype,"text",1);OC([D()],YI.prototype,"fontSize",1);class wM{constructor(A,e){r(this,"tag");r(this,"previousValues");this.tag=A,this.previousValues=e}}const osA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ja{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 i;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=[]),(i=this.font)==null||i.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/${JN(this.material)}>`),e.closeBlock()}}r(Ja,"global_id",0);class JS{static singleLine(A,e,t){const i=new Ja("text_"+Ja.getId());return i.content=A,e&&(i.pointSize=e),t&&(i.depth=t),i}static multiLine(A,e,t,i,I,o){const s=new Ja("text_"+Ja.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=i,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const ssA=new MA().makeRotationY(Math.PI),nsA=new MA().makeScale(-1,1,-1);class _u{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const i=nA.getComponent(A,YI);if(!i)return;const I=nA.getComponent(A,LI);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=ssA.clone(),I&&e.matrix.premultiply(nsA);const n=i.color.clone();e.material=new JI({color:n,emissive:n}),e.addEventListener("serialize",(C,a)=>{let B=i.text;B=B.replace(/\r/g,""),B=B.replace(/\n/g,"\\n");const Q=JS.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,i.alignment),this.setOverflow(Q,i),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(i.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 gg.LowerLeft:case gg.MiddleLeft:case gg.UpperLeft:A.horizontalAlignment="left";break;case gg.LowerCenter:case gg.MiddleCenter:case gg.UpperCenter:A.horizontalAlignment="center";break;case gg.LowerRight:case gg.MiddleRight:case gg.UpperRight:A.horizontalAlignment="right";break}switch(e){case gg.LowerLeft:case gg.LowerCenter:case gg.LowerRight:A.verticalAlignment="bottom";break;case gg.MiddleLeft:case gg.MiddleCenter:case gg.MiddleRight:A.verticalAlignment="middle";break;case gg.UpperLeft:case gg.UpperCenter:case gg.UpperRight:A.verticalAlignment="top";break}}}class vS{get extensionName(){return"tmui"}onExportObject(A,e,t){const i=nA.getComponent(A,Og);if(i&&i.activeAndEnabled&&i.renderMode===XO.WorldSpace){const I=new _u,o=nA.getComponent(A,LI),s=nA.getComponent(A,Ir);if(o){o.width,o.height;const n=zI.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=zI.createEmpty();c.matrix.copy(E.matrix);const d=E.parent,h=!!d&&typeof d.textContent=="string"&&d.textContent.length>0;let l=Q.get(d)||1;const p=nA.getComponent(E,Ir);if(p&&(l*=p.alpha),E instanceof lA&&h){const f=E[zo];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 lA&&!h){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),c.geometry=f;const S=new mA,M=E.material.opacity;S.copy(E.material.color),c.material=new Bt({color:S,opacity:M*l,map:E.material.map,transparent:!0})}B.set(E,c),Q.set(E,l);const u=B.get(d);if(!u){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}u.add(c)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,i=e.length/3;t<i;t++){const I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}const qf=IA("debugusdz");function CsA(g,A){var o;const e=[],t=nA.getComponentsInChildren(g,Hg),i=nA.getComponentsInChildren(g,bI),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 Lc;C.animator=s,C.stateName=n.name,C.trigger="start",C.name="PlayAnimationOnClick_implicitAtStart_"+C.stateName;const a=new pA;nA.addComponent(a,C),I.push(a),g.add(a)}else for(const s of t){if(!s||!s.runtimeAnimatorController)continue;qf&&console.log(s);const n=[];for(const C of s.runtimeAnimatorController.enumerateActions()){qf&&console.log(C);const a=C.getClip();n.includes(a)||n.push(a)}e.push({root:s.gameObject,clips:n})}for(const s of i){qf&&console.log(s);const n=[];for(const C of s.animations)n.includes(C)||n.push(C);e.push({root:s.gameObject,clips:n})}qf&&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 asA(g,A){const e=nA.getComponentsInChildren(g,pi),t=nA.getComponentsInChildren(g,or),i=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 or;o.target=I,o.name="PlayAudioOnClick_implicitAtStart_";const s=new pA;nA.addComponent(s,o),console.log("implicit PlayAudioOnStart",s,o),i.push(s),g.add(s)}return i}function $b(g){const A=g.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 i=document.createElement("a");i.id="needle-usdz-link",i.style.display="none",i.rel="ar",i.href="",e.appendChild(i);const I=document.createElement("img");return I.id="button",i.appendChild(I),g.domElement.shadowRoot.appendChild(e),i}var rsA=Object.defineProperty,BsA=Object.getOwnPropertyDescriptor,EI=(g,A,e,t)=>{for(var i=t>1?void 0:t?BsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&rsA(A,e,i),i};const _I=IA("debugusdz");class fr{constructor(){r(this,"callToAction");r(this,"checkoutTitle");r(this,"checkoutSubtitle");r(this,"callToActionURL")}}EI([D()],fr.prototype,"callToAction",2);EI([D()],fr.prototype,"checkoutTitle",2);EI([D()],fr.prototype,"checkoutSubtitle",2);EI([D()],fr.prototype,"callToActionURL",2);var tG;const AR=(tG=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.exportAndOpen()});r(this,"_currentExportTasks",new Map);r(this,"lastCallback")}start(){var A,e,t;_I&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",i=>{switch(i.key){case"t":this.exportAsync();break}}),Ts()&&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 RS),this.extensions.push(new ir),this.extensions.push(new _u),this.extensions.push(new vS))}onEnable(){var t;const A=pc(),e=UE();(_I||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=$b(this.context),this.link.addEventListener("message",this.lastCallback)),_I&&di("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),_I&&di("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var t;let A=this.exportFileName??((t=this.objectToExport)==null?void 0:t.name)??this.name;if(A+="-"+dO(),Ks()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=$b(this.context)),this.customUsdzFile)return _I&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,A),null;const e=await this.export(this.objectToExport);return e?(_I&&console.log("USDZ generation done. Downloading as "+A),this.openInQuickLook(e,A),e):(console.warn("No object to export",this),null)}async export(A){if(!A)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(A);if(e)return e;const t=this.internalExport(A);return t instanceof Promise?(this._currentExportTasks.set(A,t),t.then(i=>(this._currentExportTasks.delete(A),i)).catch(i=>(this._currentExportTasks.delete(A),null))):t}async internalExport(A){it.start("export-usdz",{onProgress:c=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:c}}))}}),it.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),it.report("export-usdz",{message:"Load progressive textures",autoStep:5}),it.start("export-usdz-textures","export-usdz");const e=nA.getComponentsInChildren(A,_i),t=new Array;let i=0;for(const c of e){c.didAutomaticallyUpdateLODLevel=c.automaticallyUpdateLODLevel,c.automaticallyUpdateLODLevel=!1;for(const d of c.sharedMeshes)if(d){const h=c.loadProgressiveMeshes(d,0);h instanceof Promise&&t.push(new Promise((l,p)=>{h.then(()=>{i++,it.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:i,totalSteps:t.length}),l()}).catch(u=>p(u))}))}for(const d of c.sharedMaterials)if(d){const h=c.loadProgressiveTextures(d,0);h instanceof Promise&&t.push(new Promise((l,p)=>{h.then(()=>{i++,it.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:i,totalSteps:t.length}),l()}).catch(u=>p(u))}))}}_I&&di("Progressive Loading: "+t.length),await Promise.all(t),_I&&di("Progressive Loading: done"),it.end("export-usdz-textures");const I=Lg.Global.Mask;Lg.Global.Set(an.AR),this.applyWebARSessionRoot();const o=new diA,s=[...this.extensions],n=new wu(this.quickLookCompatible);s.push(n);const C={self:this,exporter:o,extensions:s,object:A};it.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:C})),it.report("export-usdz","auto export animations and audio sources");const a=new Array;this.autoExportAnimations&&a.push(...CsA(A,n)),this.extensions.find(c=>c.extensionName==="Audio")&&this.autoExportAudioSources&&a.push(...asA(A)),o.debug=_I,o.keepObject=c=>{const d=nA.getComponent(c,_i);return!(d&&!d.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"),it.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"});it.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:C}));for(const c of a)nA.destroy(c);for(const c of e){const d=c.didAutomaticallyUpdateLODLevel;d!=null&&(c.automaticallyUpdateLODLevel=d)}return Lg.Global.Set(I),it.end("export-usdz"),E}openInQuickLook(A,e){const t=A instanceof Blob?URL.createObjectURL(A):A,i=this.buildQuicklookOverlay();_I&&console.log("QuickLook Overlay",i);const I=i.callToAction?encodeURIComponent(i.callToAction):"",o=i.checkoutTitle?encodeURIComponent(i.checkoutTitle):"",s=i.checkoutSubtitle?encodeURIComponent(i.checkoutSubtitle):"";this.link.href=t+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${i.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){AR.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"){_I&&si("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 i=t.get("callToActionURL");_I&&di("Quicklook url: "+i),i&&(Ks()?globalThis.open(i,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",i))}}}}buildQuicklookOverlay(){var t,i,I,o,s,n;const A={};return this.customBranding&&Object.assign(A,this.customBranding),Ks()||(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)||((i=A.checkoutTitle)==null?void 0:i.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=nA.getComponentInParent(this.objectToExport,Uo);const e=A!=null;if(A||(A=nA.getComponentInChildren(this.objectToExport,Uo)),_I&&console.log("applyWebARSessionRoot",A),!A){_I&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:A.gameObject,i=1/A.arScale;t.matrix.makeScale(i,i,i),A.invertForward&&t.matrix.multiply(AR.invertForwardMatrix)}createQuicklookButton(){const e=Wa.getOrCreate().createQuicklookButton();return e.parentNode||this.context.menu.appendChild(e),e}},r(tG,"invertForwardMatrix",new MA().makeRotationY(Math.PI)),tG);let Qg=AR;EI([D(pA)],Qg.prototype,"objectToExport",2);EI([D()],Qg.prototype,"autoExportAnimations",2);EI([D()],Qg.prototype,"autoExportAudioSources",2);EI([D()],Qg.prototype,"exportFileName",2);EI([D(URL)],Qg.prototype,"customUsdzFile",2);EI([D(fr)],Qg.prototype,"customBranding",2);EI([D()],Qg.prototype,"anchoringType",2);EI([D()],Qg.prototype,"maxTextureSize",2);EI([D()],Qg.prototype,"planeAnchoringAlignment",2);EI([D()],Qg.prototype,"interactive",2);EI([D()],Qg.prototype,"allowCreateQuicklookButton",2);EI([D()],Qg.prototype,"quickLookCompatible",2);class Hu extends UA{constructor(){super(...arguments);r(this,"isUsed",!0);r(this,"usedBy",null)}}class rF extends UA{}const AL=IA("debugdeletable");class qS extends Vo{}class BF extends UA{constructor(){super(...arguments);r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=nA.findObjectsOfType(qS,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=nA.getComponentInParent(this.gameObject,Hu);I?AL&&console.warn("Can not delete object with usage marker",this.guid,I):(AL&&console.log("DESTROY",this.gameObject),QS(this.gameObject,this.context.connection))}}}}var QsA=Object.defineProperty,EsA=Object.getOwnPropertyDescriptor,CQ=(g,A,e,t)=>{for(var i=t>1?void 0:t?EsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&QsA(A,e,i),i};const eL=IA("debugpost");class Hs extends QI{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(){eL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const i=t/300,I=2;return te.lerp(I,.01,i)};const e=20;this.aperture.valueProcessor=t=>{const i=1-t/32;return te.lerp(1,e,i)}}onCreateEffect(){if(this.mode===0){eL&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let i=1;Ts()&&(i=.6),this.resolutionScale=new Ye(i*e)}const t=new O_(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{t.cocMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>t.cocMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>t.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>t.resolution.scale=i),[t]}unapply(){}}CQ([D()],Hs.prototype,"mode",2);CQ([D(Ye)],Hs.prototype,"focusDistance",2);CQ([D(Ye)],Hs.prototype,"focalLength",2);CQ([D(Ye)],Hs.prototype,"aperture",2);CQ([D(Ye)],Hs.prototype,"gaussianMaxRadius",2);CQ([D(Ye)],Hs.prototype,"resolutionScale",2);CQ([D(Ye)],Hs.prototype,"bokehScale",2);rs("DepthOfField",Hs);var csA=Object.defineProperty,lsA=Object.getOwnPropertyDescriptor,hsA=(g,A,e,t)=>{for(var i=t>1?void 0:t?lsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&csA(A,e,i),i};class bS extends UA{constructor(){super(...arguments);r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||nA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ts()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}hsA([D()],bS.prototype,"visibleOn",2);class QF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var dsA=Object.defineProperty,usA=Object.getOwnPropertyDescriptor,aQ=(g,A,e,t)=>{for(var i=t>1?void 0:t?usA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&dsA(A,e,i),i};const pn=IA("debugdrag");var BP=(g=>(g[g.XZPlane=0]="XZPlane",g[g.Attached=1]="Attached",g[g.HitNormal=2]="HitNormal",g[g.DynamicViewAngle=3]="DynamicViewAngle",g[g.SnapToSurfaces=4]="SnapToSurfaces",g[g.None=5]="None",g))(BP||{}),gD;const An=(gD=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=nA.findObjectOfType(Rt,this.context),this.gameObject.getComponentInParent(Ro)||this.gameObject.addComponent(Ro)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||A.mode!=="screen"||(A.event.mode==="tracked-pointer"||A.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const i=nA.getComponentInParent(A.object,An);!i||i!==this||(An.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&A.mode==="screen"&&An.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(A){if(!(!this.allowEdit(this.gameObject)||A.used||(A.mode==="tracked-pointer"||A.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(An.lastHovered=A.object,A.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=A),An._active+=1;const i=new fsA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(A.event.space,i),this.orbit&&(this.orbit.enabled=!1),i.onDragStart(A),this._dragHandlers.size===2){const I=this._dragHandlers.values(),o=I.next().value,s=I.next().value,n=new psA(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(pn&&me.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&&(An._active>0&&(An._active-=1),e.onDragEnd&&e.onDragEnd(A),this._dragHandlers.delete(A.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(A),A.use()),An._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 ND(this.context.mainCamera);else return;if(!A||!A.object)return;const e=nA.getComponentInParent(A.object,An);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 i=nA.getComponentInChildren(t,tr);pn&&console.log("DRAG START",i,t),i&&(i.fastMode=!0,i==null||i.requestOwnership()),this._marker=nA.addComponent(t,Hu),this._draggingRigidbodies.length=0;const I=nA.getComponentsInChildren(t,Xt);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;As.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(pn&&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=nA.getComponentInChildren(A.object,tr);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},r(gD,"_active",0),r(gD,"lastHovered"),gD);let os=An;aQ([D()],os.prototype,"dragMode",2);aQ([D()],os.prototype,"snapGridResolution",2);aQ([D()],os.prototype,"keepRotation",2);aQ([D()],os.prototype,"xrDragMode",2);aQ([D()],os.prototype,"xrKeepRotation",2);aQ([D()],os.prototype,"xrDistanceDragFactor",2);aQ([D()],os.prototype,"showGizmo",2);class psA{constructor(A,e,t,i){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 kA);r(this,"_manipulatorPosOffset",new y);r(this,"_manipulatorRotOffset",new kA);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=i,this._followObject=new pA,this._manipulatorObject=new pA,this.context.scene.add(this._manipulatorObject);const I=(s=(o=ye.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?(pn&&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),pn){this._followObject.add(new ts(2)),this._manipulatorObject.add(new ts(5));const n=C=>`${C.x.toFixed(2)}, ${C.y.toFixed(2)}, ${C.z.toFixed(2)}`;me.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),me.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6298
|
+
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Ke(ZoA),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Ke(XoA),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,i,I,o,s,n,C;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(i=this.depthMaterial)==null||i.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){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){yM&&console.error("ContactShadows: not initialized yet");return}const t=this.context.scene,i=this.context.renderer,I=i.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof lA&&(this.gameObject.visible=!1,CE(this.gameObject,!1));const s=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const n=i.getClearAlpha();i.setClearAlpha(0);const C=i.xr.enabled;i.xr.enabled=!1;const a=i.renderLists.get(t,0),B=a.transparent;a.transparent=[],i.setRenderTarget(this.renderTarget),i.clear(),i.render(t,this.shadowCamera),a.transparent=B,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,i.setRenderTarget(I),i.setClearAlpha(n),t.background=s,i.xr.enabled=C}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,i=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(i)}}Yu([D()],pr.prototype,"darkness",2);Yu([D()],pr.prototype,"opacity",2);Yu([D()],pr.prototype,"blur",2);Yu([D()],pr.prototype,"occludeBelowGround",2);Yu([D()],pr.prototype,"backfaceShadows",2);var esA=Object.defineProperty,tsA=Object.getOwnPropertyDescriptor,Tu=(g,A,e,t)=>{for(var i=t>1?void 0:t?tsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&esA(A,e,i),i};const Xb=IA("debugwebxr"),isA=new MA().makeRotationY(Math.PI);class Uo 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 rI);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||e.used)return;let t=this._reticle[0],i=this._hits[0];if(e.origin instanceof cN){const o=this._reticle[e.origin.index];o&&(t=o,i=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=ye.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(ye.active,i)})}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){Xb&&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 i=this.context.scene.children.length-1;i>=0;i--){const I=this.context.scene.children[i];this._placementScene.add(I)}this.context.scene.add(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),nA.addComponent(t,this);for(const i of this._reticle)qs(i);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:on.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:on.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,i,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 BE(this.context)),(i=this.userInput)==null||i.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,i,I){this._hits[t]=i.hit;let o=this._reticle[t];if(!o){if(this.customReticle)if(this.customReticle.asset)o=Sc(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new lA(new KB(.07,.09,32).rotateX(-Math.PI/2),new Bt({side:ut})),o.name="AR Placement Reticle";if(Xb){const s=new ts(1);s.position.y+=.01,o.add(s)}this._reticle[t]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(i.position,this.context.time.deltaTime/.1),o.quaternion.slerp(i.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 i=this._placementScene.children[t];this.context.scene.add(i)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)nA.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),ue()&&si("Hit does not support creating an anchor");return}else{const i=await t.createAnchor(e.viewerPose.transform);e.running&&i&&(this._anchor=i)}}applyViewBasedTransform(e){const t=this.context.mainCamera,i=e,I=t.worldPosition,o=i.worldPosition;I.y=o.y,e.lookAt(I)}onApplyPose(e){var I,o,s,n;const t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject;if(!t){console.warn("No rig object to place");return}(s=ye.active)!=null&&s.rigScale;const i=t.parent||this.context.scene;this._rigPlacementMatrix?(n=this._rigPlacementMatrix)==null||n.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(isA),t.matrix.premultiply(this._startOffset),t.matrix.decompose(t.position,t.quaternion,t.scale),i.add(t)}}Tu([D()],Uo.prototype,"arScale",1);Tu([D()],Uo.prototype,"invertForward",2);Tu([D(ot)],Uo.prototype,"customReticle",2);Tu([D()],Uo.prototype,"useXRAnchor",2);Tu([D()],Uo.prototype,"arTouchTransform",2);const ow=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],i=dT()&&t.clientY<window.innerHeight*.1;this.prev.has(t.identifier)||this.prev.set(t.identifier,{ignore:i,x:0,z:0,screenx:0,screeny:0});const I=this.prev.get(t.identifier);if(I){const o=this.getPositionOnPlane(t.clientX,t.clientY);I.x=o.x,I.z=o.z,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"touchEnd",A=>{A.touches.length<=0&&(this._didMultitouch=!1);for(let e=0;e<A.changedTouches.length;e++){const t=A.changedTouches[e];this.prev.delete(t.identifier)}});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||t.ignore)return;const i=this.getPositionOnPlane(e.clientX,e.clientY),I=i.x-t.x,o=i.z-t.z;if(I===0&&o===0)return;this.oneFingerDrag&&this.addMovement(I,o),t.x=i.x,t.z=i.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],i=this.prev.get(e.identifier),I=this.prev.get(t.identifier);if(!i||!I)return;if(this.twoFingerRotate){const o=Math.atan2(e.clientY-t.clientY,e.clientX-t.clientX),s=Math.atan2(i.screeny-I.screeny,i.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=i.screenx-I.screenx,a=i.screeny-I.screeny,B=Math.sqrt(C*C+a*a),Q=n-B;Math.abs(Q)>2&&this.addScale(Q)}i.screenx=e.clientX,i.screeny=e.clientY,I.screenx=t.clientX,I.screeny=t.clientY}}});r(this,"_raycaster",new PB);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 GI,this.plane.setFromNormalAndCoplanarPoint(ow.up,ow.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:on.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:on.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:on.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:on.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:on.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:on.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 BE=ow;r(BE,"up",new y(0,1,0)),r(BE,"zero",new y(0,0,0)),r(BE,"one",new y(1,1,1));const NK=class{constructor(){r(this,"_quicklookButton");r(this,"_arButton");r(this,"_vrButton");r(this,"_sendToQuestButton")}static create(){return new NK}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 _a.getOrCreate().createQRCode()}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.prepend(uo("view_in_ar")),A.addEventListener("click",()=>{const e=nA.findObjectOfType(Qg);e?(A.classList.add("this-mode-is-requested"),e.exportAndOpen().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 i;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.prepend(uo("view_in_ar")),t.title="Click to start an AR session",t.addEventListener("click",()=>ye.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)"),hB()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>this.updateSessionSupported(t,e)),t}createVRButton(A){var i;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.prepend(uo("panorama_photosphere")),t.title="Click to start a VR session",t.addEventListener("click",()=>ye.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)"),hB()||(i=navigator.xr)==null||i.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.prepend(uo("share_windows")),e.title="Click to send this page to the Oculus Browser on your Quest",e.addEventListener("click",()=>{const i=encodeURIComponent(window.location.href);window.open(A+i)}),this.listenToXRSessionState(e),this.hideElementDuringXRSession(e),hB()||(t=navigator.xr)==null||t.addEventListener("devicechange",()=>{var i;(i=navigator.xr)!=null&&i.isSessionSupported("immersive-vr")?e.style.display="none":e.style.display=""}),e}createQRCode(){return _a.getOrCreate().createQRCode()}updateSessionSupported(A,e){if(!("xr"in navigator)){A.style.display="none";return}ye.isSessionSupported(e).then(t=>{A.style.display=t?"":"none",ue()&&!t&&console.log('[WebXR] "'+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){oS(e=>{A["previous-display"]=A.style.display,A.style.display="none"}),QN(e=>{A["previous-display"]!=null&&(A.style.display=A["previous-display"])})}listenToXRSessionState(A,e){e&&(ye.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"))}),ye.onSessionRequestEnd(t=>{A.classList.remove("this-mode-is-requested"),A.classList.remove("other-mode-is-requested"),A.disabled=A["was-disabled"]}))}};let Wa=NK;r(Wa,"_instance");var gsA=Object.defineProperty,IsA=Object.getOwnPropertyDescriptor,OC=(g,A,e,t)=>{for(var i=t>1?void 0:t?IsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&gsA(A,e,i),i};const Or=IA("debugtext");var gg=(g=>(g[g.UpperLeft=0]="UpperLeft",g[g.UpperCenter=1]="UpperCenter",g[g.UpperRight=2]="UpperRight",g[g.MiddleLeft=3]="MiddleLeft",g[g.MiddleCenter=4]="MiddleCenter",g[g.MiddleRight=5]="MiddleRight",g[g.LowerLeft=6]="LowerLeft",g[g.LowerCenter=7]="LowerCenter",g[g.LowerRight=8]="LowerRight",g))(gg||{}),rP=(g=>(g[g.Normal=0]="Normal",g[g.Bold=1]="Bold",g[g.Italic=2]="Italic",g[g.BoldAndItalic=3]="BoldAndItalic",g))(rP||{});class YI extends gQ{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 mA(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){Or&&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,Or&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Or&&(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 i,I,o;if(Or&&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 aD({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:(i=this.uiObject)==null?void 0:i.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(e,s,C),this.handleTag(s,a,n);const B=new aD(a);(I=this.uiObject)==null||I.add(B)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,n);const B=new aD(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,i={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&&(Fy(s,i),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,i){if(!e.isEndTag){if(e.type.includes("color")){const I=new wM(e,{color:t.color});if(i.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new mA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new wM(e,{fontWeight:700});i.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new wM(e,{fontStyle:"italic"});i.push(I)}}}getText(e,t,i){return e.substring(t.endIndex,i.startIndex)}getNextTag(e,t=0){const i=e.indexOf("<",t),I=e.indexOf(">",i);if(i>=0&&I>=0){const o=e.substring(i+1,I);return{type:o,startIndex:i,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const i=this.font,I=this.getFamilyNameWithCorrectSuffix(i,t);Or&&console.log("Selected font family:"+I);let o=$G.getFontFamily(I);switch(o||(o=$G.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 i=e.lastIndexOf("-");if(i<0)return e;const I=(a=e.substring(i+1))==null?void 0:a.toLowerCase();if(osA.includes(I))return Or&&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,i);switch(Or&&console.log("Select font: ",e,rP[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}}}OC([D()],YI.prototype,"alignment",2);OC([D()],YI.prototype,"verticalOverflow",2);OC([D()],YI.prototype,"horizontalOverflow",2);OC([D()],YI.prototype,"lineSpacing",2);OC([D()],YI.prototype,"supportRichText",2);OC([D(URL)],YI.prototype,"font",2);OC([D()],YI.prototype,"fontStyle",2);OC([D()],YI.prototype,"text",1);OC([D()],YI.prototype,"fontSize",1);class wM{constructor(A,e){r(this,"tag");r(this,"previousValues");this.tag=A,this.previousValues=e}}const osA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ja{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 i;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=[]),(i=this.font)==null||i.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/${JN(this.material)}>`),e.closeBlock()}}r(Ja,"global_id",0);class JS{static singleLine(A,e,t){const i=new Ja("text_"+Ja.getId());return i.content=A,e&&(i.pointSize=e),t&&(i.depth=t),i}static multiLine(A,e,t,i,I,o){const s=new Ja("text_"+Ja.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=i,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const ssA=new MA().makeRotationY(Math.PI),nsA=new MA().makeScale(-1,1,-1);class _u{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const i=nA.getComponent(A,YI);if(!i)return;const I=nA.getComponent(A,LI);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=ssA.clone(),I&&e.matrix.premultiply(nsA);const n=i.color.clone();e.material=new JI({color:n,emissive:n}),e.addEventListener("serialize",(C,a)=>{let B=i.text;B=B.replace(/\r/g,""),B=B.replace(/\n/g,"\\n");const Q=JS.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,i.alignment),this.setOverflow(Q,i),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(i.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 gg.LowerLeft:case gg.MiddleLeft:case gg.UpperLeft:A.horizontalAlignment="left";break;case gg.LowerCenter:case gg.MiddleCenter:case gg.UpperCenter:A.horizontalAlignment="center";break;case gg.LowerRight:case gg.MiddleRight:case gg.UpperRight:A.horizontalAlignment="right";break}switch(e){case gg.LowerLeft:case gg.LowerCenter:case gg.LowerRight:A.verticalAlignment="bottom";break;case gg.MiddleLeft:case gg.MiddleCenter:case gg.MiddleRight:A.verticalAlignment="middle";break;case gg.UpperLeft:case gg.UpperCenter:case gg.UpperRight:A.verticalAlignment="top";break}}}class vS{get extensionName(){return"tmui"}onExportObject(A,e,t){const i=nA.getComponent(A,Og);if(i&&i.activeAndEnabled&&i.renderMode===XO.WorldSpace){const I=new _u,o=nA.getComponent(A,LI),s=nA.getComponent(A,Ir);if(o){o.width,o.height;const n=zI.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=zI.createEmpty();c.matrix.copy(E.matrix);const d=E.parent,h=!!d&&typeof d.textContent=="string"&&d.textContent.length>0;let l=Q.get(d)||1;const p=nA.getComponent(E,Ir);if(p&&(l*=p.alpha),E instanceof lA&&h){const f=E[zo];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 lA&&!h){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),c.geometry=f;const S=new mA,M=E.material.opacity;S.copy(E.material.color),c.material=new Bt({color:S,opacity:M*l,map:E.material.map,transparent:!0})}B.set(E,c),Q.set(E,l);const u=B.get(d);if(!u){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}u.add(c)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,i=e.length/3;t<i;t++){const I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}const qf=IA("debugusdz");function CsA(g,A){var o;const e=[],t=nA.getComponentsInChildren(g,Hg),i=nA.getComponentsInChildren(g,bI),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 Lc;C.animator=s,C.stateName=n.name,C.trigger="start",C.name="PlayAnimationOnClick_implicitAtStart_"+C.stateName;const a=new pA;nA.addComponent(a,C),I.push(a),g.add(a)}else for(const s of t){if(!s||!s.runtimeAnimatorController)continue;qf&&console.log(s);const n=[];for(const C of s.runtimeAnimatorController.enumerateActions()){qf&&console.log(C);const a=C.getClip();n.includes(a)||n.push(a)}e.push({root:s.gameObject,clips:n})}for(const s of i){qf&&console.log(s);const n=[];for(const C of s.animations)n.includes(C)||n.push(C);e.push({root:s.gameObject,clips:n})}qf&&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 asA(g,A){const e=nA.getComponentsInChildren(g,pi),t=nA.getComponentsInChildren(g,or),i=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 or;o.target=I,o.name="PlayAudioOnClick_implicitAtStart_";const s=new pA;nA.addComponent(s,o),console.log("implicit PlayAudioOnStart",s,o),i.push(s),g.add(s)}return i}function $b(g){const A=g.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 i=document.createElement("a");i.id="needle-usdz-link",i.style.display="none",i.rel="ar",i.href="",e.appendChild(i);const I=document.createElement("img");return I.id="button",i.appendChild(I),g.domElement.shadowRoot.appendChild(e),i}var rsA=Object.defineProperty,BsA=Object.getOwnPropertyDescriptor,EI=(g,A,e,t)=>{for(var i=t>1?void 0:t?BsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&rsA(A,e,i),i};const _I=IA("debugusdz");class fr{constructor(){r(this,"callToAction");r(this,"checkoutTitle");r(this,"checkoutSubtitle");r(this,"callToActionURL")}}EI([D()],fr.prototype,"callToAction",2);EI([D()],fr.prototype,"checkoutTitle",2);EI([D()],fr.prototype,"checkoutSubtitle",2);EI([D()],fr.prototype,"callToActionURL",2);var tG;const AR=(tG=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.exportAndOpen()});r(this,"_currentExportTasks",new Map);r(this,"lastCallback")}start(){var A,e,t;_I&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",i=>{switch(i.key){case"t":this.exportAsync();break}}),Ts()&&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 RS),this.extensions.push(new ir),this.extensions.push(new _u),this.extensions.push(new vS))}onEnable(){var t;const A=pc(),e=UE();(_I||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=$b(this.context),this.link.addEventListener("message",this.lastCallback)),_I&&di("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),_I&&di("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var t;let A=this.exportFileName??((t=this.objectToExport)==null?void 0:t.name)??this.name;if(A+="-"+dO(),Ks()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=$b(this.context)),this.customUsdzFile)return _I&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,A),null;const e=await this.export(this.objectToExport);return e?(_I&&console.log("USDZ generation done. Downloading as "+A),this.openInQuickLook(e,A),e):(console.warn("No object to export",this),null)}async export(A){if(!A)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(A);if(e)return e;const t=this.internalExport(A);return t instanceof Promise?(this._currentExportTasks.set(A,t),t.then(i=>(this._currentExportTasks.delete(A),i)).catch(i=>(this._currentExportTasks.delete(A),null))):t}async internalExport(A){it.start("export-usdz",{onProgress:c=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:c}}))}}),it.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),it.report("export-usdz",{message:"Load progressive textures",autoStep:5}),it.start("export-usdz-textures","export-usdz");const e=nA.getComponentsInChildren(A,_i),t=new Array;let i=0;for(const c of e){c.didAutomaticallyUpdateLODLevel=c.automaticallyUpdateLODLevel,c.automaticallyUpdateLODLevel=!1;for(const d of c.sharedMeshes)if(d){const h=c.loadProgressiveMeshes(d,0);h instanceof Promise&&t.push(new Promise((l,p)=>{h.then(()=>{i++,it.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:i,totalSteps:t.length}),l()}).catch(u=>p(u))}))}for(const d of c.sharedMaterials)if(d){const h=c.loadProgressiveTextures(d,0);h instanceof Promise&&t.push(new Promise((l,p)=>{h.then(()=>{i++,it.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:i,totalSteps:t.length}),l()}).catch(u=>p(u))}))}}_I&&di("Progressive Loading: "+t.length),await Promise.all(t),_I&&di("Progressive Loading: done"),it.end("export-usdz-textures");const I=Lg.Global.Mask;Lg.Global.Set(an.AR),this.applyWebARSessionRoot();const o=new diA,s=[...this.extensions],n=new wu(this.quickLookCompatible);s.push(n);const C={self:this,exporter:o,extensions:s,object:A};it.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:C})),it.report("export-usdz","auto export animations and audio sources");const a=new Array;this.autoExportAnimations&&a.push(...CsA(A,n)),this.extensions.find(c=>c.extensionName==="Audio")&&this.autoExportAudioSources&&a.push(...asA(A)),o.debug=_I,o.keepObject=c=>{const d=nA.getComponent(c,_i);return!(d&&!d.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"),it.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"});it.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:C}));for(const c of a)nA.destroy(c);for(const c of e){const d=c.didAutomaticallyUpdateLODLevel;d!=null&&(c.automaticallyUpdateLODLevel=d)}return Lg.Global.Set(I),it.end("export-usdz"),E}openInQuickLook(A,e){const t=A instanceof Blob?URL.createObjectURL(A):A,i=this.buildQuicklookOverlay();_I&&console.log("QuickLook Overlay",i);const I=i.callToAction?encodeURIComponent(i.callToAction):"",o=i.checkoutTitle?encodeURIComponent(i.checkoutTitle):"",s=i.checkoutSubtitle?encodeURIComponent(i.checkoutSubtitle):"";this.link.href=t+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${i.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){AR.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"){_I&&si("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 i=t.get("callToActionURL");_I&&di("Quicklook url: "+i),i&&(Ks()?globalThis.open(i,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",i))}}}}buildQuicklookOverlay(){var t,i,I,o,s,n;const A={};return this.customBranding&&Object.assign(A,this.customBranding),Ks()||(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)||((i=A.checkoutTitle)==null?void 0:i.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=nA.getComponentInParent(this.objectToExport,Uo);const e=A!=null;if(A||(A=nA.getComponentInChildren(this.objectToExport,Uo)),_I&&console.log("applyWebARSessionRoot",A),!A){_I&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:A.gameObject,i=1/A.arScale;t.matrix.makeScale(i,i,i),A.invertForward&&t.matrix.multiply(AR.invertForwardMatrix)}createQuicklookButton(){const e=Wa.getOrCreate().createQuicklookButton();return e.parentNode||this.context.menu.appendChild(e),e}},r(tG,"invertForwardMatrix",new MA().makeRotationY(Math.PI)),tG);let Qg=AR;EI([D(pA)],Qg.prototype,"objectToExport",2);EI([D()],Qg.prototype,"autoExportAnimations",2);EI([D()],Qg.prototype,"autoExportAudioSources",2);EI([D()],Qg.prototype,"exportFileName",2);EI([D(URL)],Qg.prototype,"customUsdzFile",2);EI([D(fr)],Qg.prototype,"customBranding",2);EI([D()],Qg.prototype,"anchoringType",2);EI([D()],Qg.prototype,"maxTextureSize",2);EI([D()],Qg.prototype,"planeAnchoringAlignment",2);EI([D()],Qg.prototype,"interactive",2);EI([D()],Qg.prototype,"allowCreateQuicklookButton",2);EI([D()],Qg.prototype,"quickLookCompatible",2);class Hu extends UA{constructor(){super(...arguments);r(this,"isUsed",!0);r(this,"usedBy",null)}}class rF extends UA{}const AL=IA("debugdeletable");class qS extends Vo{}class BF extends UA{constructor(){super(...arguments);r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=nA.findObjectsOfType(qS,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=nA.getComponentInParent(this.gameObject,Hu);I?AL&&console.warn("Can not delete object with usage marker",this.guid,I):(AL&&console.log("DESTROY",this.gameObject),QS(this.gameObject,this.context.connection))}}}}var QsA=Object.defineProperty,EsA=Object.getOwnPropertyDescriptor,CQ=(g,A,e,t)=>{for(var i=t>1?void 0:t?EsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&QsA(A,e,i),i};const eL=IA("debugpost");class Hs extends QI{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(){eL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const i=t/300,I=2;return te.lerp(I,.01,i)};const e=20;this.aperture.valueProcessor=t=>{const i=1-t/32;return te.lerp(1,e,i)}}onCreateEffect(){if(this.mode===0){eL&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let i=1;Ts()&&(i=.6),this.resolutionScale=new Ye(i*e)}const t=new O_(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{t.cocMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>t.cocMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>t.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>t.resolution.scale=i),[t]}unapply(){}}CQ([D()],Hs.prototype,"mode",2);CQ([D(Ye)],Hs.prototype,"focusDistance",2);CQ([D(Ye)],Hs.prototype,"focalLength",2);CQ([D(Ye)],Hs.prototype,"aperture",2);CQ([D(Ye)],Hs.prototype,"gaussianMaxRadius",2);CQ([D(Ye)],Hs.prototype,"resolutionScale",2);CQ([D(Ye)],Hs.prototype,"bokehScale",2);rs("DepthOfField",Hs);var csA=Object.defineProperty,lsA=Object.getOwnPropertyDescriptor,hsA=(g,A,e,t)=>{for(var i=t>1?void 0:t?lsA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&csA(A,e,i),i};class bS extends UA{constructor(){super(...arguments);r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||nA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ts()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}hsA([D()],bS.prototype,"visibleOn",2);class QF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var dsA=Object.defineProperty,usA=Object.getOwnPropertyDescriptor,aQ=(g,A,e,t)=>{for(var i=t>1?void 0:t?usA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&dsA(A,e,i),i};const pn=IA("debugdrag");var BP=(g=>(g[g.XZPlane=0]="XZPlane",g[g.Attached=1]="Attached",g[g.HitNormal=2]="HitNormal",g[g.DynamicViewAngle=3]="DynamicViewAngle",g[g.SnapToSurfaces=4]="SnapToSurfaces",g[g.None=5]="None",g))(BP||{}),gD;const An=(gD=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=nA.findObjectOfType(Rt,this.context),this.gameObject.getComponentInParent(Ro)||this.gameObject.addComponent(Ro)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||A.mode!=="screen"||(A.event.mode==="tracked-pointer"||A.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const i=nA.getComponentInParent(A.object,An);!i||i!==this||(An.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&A.mode==="screen"&&An.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(A){if(!(!this.allowEdit(this.gameObject)||A.used||(A.mode==="tracked-pointer"||A.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(An.lastHovered=A.object,A.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=A),An._active+=1;const i=new fsA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(A.event.space,i),this.orbit&&(this.orbit.enabled=!1),i.onDragStart(A),this._dragHandlers.size===2){const I=this._dragHandlers.values(),o=I.next().value,s=I.next().value,n=new psA(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(pn&&me.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&&(An._active>0&&(An._active-=1),e.onDragEnd&&e.onDragEnd(A),this._dragHandlers.delete(A.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(A),A.use()),An._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 ND(this.context.mainCamera);else return;if(!A||!A.object)return;const e=nA.getComponentInParent(A.object,An);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 i=nA.getComponentInChildren(t,tr);pn&&console.log("DRAG START",i,t),i&&(i.fastMode=!0,i==null||i.requestOwnership()),this._marker=nA.addComponent(t,Hu),this._draggingRigidbodies.length=0;const I=nA.getComponentsInChildren(t,Xt);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;As.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(pn&&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=nA.getComponentInChildren(A.object,tr);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},r(gD,"_active",0),r(gD,"lastHovered"),gD);let os=An;aQ([D()],os.prototype,"dragMode",2);aQ([D()],os.prototype,"snapGridResolution",2);aQ([D()],os.prototype,"keepRotation",2);aQ([D()],os.prototype,"xrDragMode",2);aQ([D()],os.prototype,"xrKeepRotation",2);aQ([D()],os.prototype,"xrDistanceDragFactor",2);aQ([D()],os.prototype,"showGizmo",2);class psA{constructor(A,e,t,i){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 kA);r(this,"_manipulatorPosOffset",new y);r(this,"_manipulatorRotOffset",new kA);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=i,this._followObject=new pA,this._manipulatorObject=new pA,this.context.scene.add(this._manipulatorObject);const I=(s=(o=ye.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?(pn&&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),pn){this._followObject.add(new ts(2)),this._manipulatorObject.add(new ts(5));const n=C=>`${C.x.toFixed(2)}, ${C.y.toFixed(2)}, ${C.z.toFixed(2)}`;me.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),me.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6294
6299
|
`+n(this._tempVec1)+`
|
|
6295
6300
|
`+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),pn&&(me.DrawLabel(this._tempVec3.clone().add(new y(0,.2,0)),"A:B "+e.toFixed(2),.03),me.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,i=this._followObject;i.updateMatrix(),i.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-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=te.clamp01(this.context.time.deltaTime*A*e),n=t.worldPosition;n.lerp(i.worldPosition,s),t.worldPosition=n;const C=t.worldQuaternion;C.slerp(i.worldQuaternion,s),t.worldQuaternion=C;const a=t.worldScale;a.lerp(i.worldScale,s),t.worldScale=a}setTargetObject(A){this.gameObject=A}}class fsA{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 kA);r(this,"_followObjectStartWorldQuaternion",new kA);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 Mt);r(this,"_dragPlane",new GI(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=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject,i=(t==null?void 0:t.worldScale.x)||1;this._grabStartDistance/=i,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,pn&&(me.DrawLine(e,A.worldPosition,65280,.5,!1),me.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 d=A.event.space,h=d.worldPosition;this.gameObject.worldToLocal(h),this._hitPointInLocalSpace.copy(h);const l=d.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),l.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(l)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const t=this._followObject.parent.worldForward,I=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),I){case 0:const d=new y(0,1,0);this.gameObject.parent&&d.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(d,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 l=new y(0,1,0),p=t,u=l.angleTo(p),f=.5;u>Math.PI/2+f||u<Math.PI/2-f?this._dragPlane.setFromNormalAndCoplanarPoint(new y(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break}const s=new Mt,n=this.gameObject.parent,C=this.gameObject.position.clone(),a=this.gameObject.quaternion.clone(),B=this.gameObject.scale.clone(),Q=this.gameObject.matrixWorld.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 E=new y;s.getCenter(E);const c=new y;s.getSize(c),this._bottomCenter.copy(E.clone().add(new y(0,-c.y/2,0))),this._backCenter.copy(E.clone().add(new y(0,0,c.z/2))),this._backBottomCenter.copy(E.clone().add(new y(0,-c.y/2,c.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.gameObject.matrixWorld.copy(Q),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=ye.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 i=A.worldForward;if(t&&(this._tempMat.copy(t.matrixWorld).invert(),i.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=i.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),pn){let s=e;t&&(s=s.clone(),s.transformDirection(t.matrixWorld)),me.DrawRay(s,i,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,t=this._followObject.parent;this._followObject.updateMatrix();const i=t.worldPosition,I=t.worldForward,o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-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(o&&this._grabStartDistance>.5){const h=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);a=Math.max(0,h),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 $I(i,I);if(n==4){const h=new Is;h.ignore=[e];const l=this.context.physics.raycastFromRay(Q,h);if(l.length>0){const p=l[0];if(this._draggedOverObject===p.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=p.object,this._draggedOverObjectDuration=0),p.face&&this._draggedOverObjectDuration>.15&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(p.face.normal)<.999999)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(p.face.normal);const u=new y,f=new y;this._bounds.getCenter(u),this._bounds.getSize(f),u.sub(f.multiplyScalar(.5).multiply(p.face.normal)),this._hitPointInLocalSpace.copy(u),this._hitNormalInLocalSpace.copy(p.face.normal),this._bounds.getCenter(u),this._bounds.getSize(f),u.add(f.multiplyScalar(.5).multiply(p.face.normal));const S=this._hitPointInLocalSpace.clone().add(u);this._followObject.localToWorld(S);const M=this._followObject.worldPosition.sub(S);this._dragPlane.setFromNormalAndCoplanarPoint(p.face.normal,p.point.sub(M))}}}if(n!==1&&Q.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const h=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(h),pn&&me.DrawLine(h,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(h),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const h=this._followObject.worldPosition,l=this.settings.snapGridResolution;h.x=Math.round(h.x/l)*l,h.y=Math.round(h.y/l)*l,h.z=Math.round(h.z/l)*l,this._followObject.worldPosition=h,this._followObject.updateMatrix()}s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const E=te.clamp01(this.context.time.deltaTime*C*B),c=e.worldPosition;c.lerp(this._followObject.worldPosition,E),e.worldPosition=c;const d=e.worldQuaternion;if(d.slerp(this._followObject.worldQuaternion,E),e.worldQuaternion=d,pn){const h=this._hitPointInLocalSpace.clone();e.localToWorld(h),me.DrawSphere(h,.02,16711680);const l=this._hitNormalInLocalSpace.clone();l.applyQuaternion(d),me.DrawRay(h,l,16711680),me.DrawLabel(c.add(new y(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6296
6301
|
|