@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
|
`;a+=n(o);const l=Object.keys(r);let c="";for(let u=0;u<l.length;u++){const d=l[u],f=r[d];if(Lm.has(f)){c+="";continue}Lm.set(f,!0),c+=d+":"+i(f,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=n(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
4343
|
}`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const AY=ne("nodevlogs");function un(s,e=ho.Log){sl(e,s)}function tn(s){un(s,ho.Warn)}function kI(s){un(s,ho.Error)}let O1;function vt(){return AY?!1:O1!==void 0?O1:Hr()}function yY(s){O1=s}const fu=new bd,Js=new w,Vc=new w,Ki=new Ce,W2={X:new w(1,0,0),Y:new w(0,1,0),Z:new w(0,0,1)},aC={type:"change"},j2={type:"mouseDown"},q2={type:"mouseUp",mode:null},X2={type:"objectChange"};class _Y extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const i=new FI;this._gizmo=i,this.add(i);const n=new EY;this._plane=n,this.add(n);const r=this;function o(_,y){let b=y;Object.defineProperty(r,_,{get:function(){return b!==void 0?b:y},set:function(C){b!==C&&(b=C,n[_]=C,i[_]=C,r.dispatchEvent({type:_+"-changed",value:C}),r.dispatchEvent(aC))}}),r[_]=y,n[_]=y,i[_]=y}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new w,l=new w,c=new Ce,u=new Ce,d=new w,f=new Ce,p=new w,m=new w,A=new w,v=0,g=new w;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",p),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new w,this._startNorm=new w,this._endNorm=new w,this._cameraScale=new w,this._parentPosition=new w,this._parentQuaternion=new Ce,this._parentQuaternionInv=new Ce,this._parentScale=new w,this._worldScaleStart=new w,this._worldQuaternionInv=new Ce,this._worldScale=new w,this._positionStart=new w,this._quaternionStart=new Ce,this._scaleStart=new w,this._getPointer=bY.bind(this),this._onPointerDown=wY.bind(this),this._onPointerHover=xY.bind(this),this._onPointerMove=SY.bind(this),this._onPointerUp=CY.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&fu.setFromCamera(e,this.camera);const t=lC(this._gizmo.picker[this.mode],fu);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&fu.setFromCamera(e,this.camera);const t=lC(this._plane,fu,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,j2.mode=this.mode,this.dispatchEvent(j2)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&fu.setFromCamera(e,this.camera);const o=lC(this._plane,fu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(Ki.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(Js.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Js.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Vc.set(a,a,a)}else Js.copy(this.pointStart),Vc.copy(this.pointEnd),Js.applyQuaternion(this._worldQuaternionInv),Vc.applyQuaternion(this._worldQuaternionInv),Vc.divide(Js),t.search("X")===-1&&(Vc.x=1),t.search("Y")===-1&&(Vc.y=1),t.search("Z")===-1&&(Vc.z=1);n.scale.copy(this._scaleStart).multiply(Vc),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Js.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Js.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(W2[t]),Js.copy(W2[t]),r==="local"&&Js.applyQuaternion(this.worldQuaternion),Js.cross(this.eye),Js.length()===0?l=!0:this.rotationAngle=this._offset.dot(Js.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(Ki.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Ki.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(aC),this.dispatchEvent(X2)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(q2.mode=this.mode,this.dispatchEvent(q2)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(aC),this.dispatchEvent(X2),this.pointStart.copy(this.pointEnd))}getRaycaster(){return fu}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function bY(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function xY(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function wY(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function SY(s){this.enabled&&this.pointerMove(this._getPointer(s))}function CY(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function lC(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const C0=new Vi,Pi=new w(0,1,0),Y2=new w(0,0,0),J2=new we,E0=new Ce,M_=new Ce,La=new w,K2=new we,dg=new w(1,0,0),Ru=new w(0,1,0),fg=new w(0,0,1),M0=new w,km=new w,Fm=new w;class FI extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new ci({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Bn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const A=new Mn(0,.04,.1,12);A.translate(0,.05,0);const v=new ki(.08,.08,.08);v.translate(0,.04,0);const g=new mt;g.setAttribute("position",new ut([0,0,0,1,0,0],3));const _=new Mn(.0075,.0075,.5,3);_.translate(0,.25,0);function y(V,L){const k=new $l(V,.0075,3,64,L*Math.PI*2);return k.rotateY(Math.PI/2),k.rotateX(Math.PI/2),k}function b(){const V=new mt;return V.setAttribute("position",new ut([0,0,0,1,1,1],3)),V}const C={X:[[new de(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new de(A,r),[-.5,0,0],[0,0,Math.PI/2]],[new de(_,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new de(A,o),[0,.5,0]],[new de(A,o),[0,-.5,0],[Math.PI,0,0]],[new de(_,o)]],Z:[[new de(A,a),[0,0,.5],[Math.PI/2,0,0]],[new de(A,a),[0,0,-.5],[-Math.PI/2,0,0]],[new de(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new de(new oc(.1,0),d.clone()),[0,0,0]]],XY:[[new de(new ki(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new de(new ki(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new de(new Mn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new de(new Mn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new de(new Mn(.2,0,.6,4),i),[0,.3,0]],[new de(new Mn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new de(new Mn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new de(new Mn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new de(new oc(.2,0),i)]],XY:[[new de(new ki(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new de(new ki(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},T={START:[[new de(new oc(.01,2),n),null,null,null,"helper"]],END:[[new de(new oc(.01,2),n),null,null,null,"helper"]],DELTA:[[new In(b(),n),null,null,null,"helper"]],X:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new In(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new In(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},E={XYZE:[[new de(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new de(y(.5,.5),r)]],Y:[[new de(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new de(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new de(y(.75,1),f),null,[0,Math.PI/2,0]]]},B={AXIS:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new de(new Ta(.25,10,8),i)]],X:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new de(new $l(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new de(new $l(.75,.1,2,24),i)]]},I={X:[[new de(v,r),[.5,0,0],[0,0,-Math.PI/2]],[new de(_,r),[0,0,0],[0,0,-Math.PI/2]],[new de(v,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new de(v,o),[0,.5,0]],[new de(_,o)],[new de(v,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new de(v,a),[0,0,.5],[Math.PI/2,0,0]],[new de(_,a),[0,0,0],[Math.PI/2,0,0]],[new de(v,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new de(new ki(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new de(new ki(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new de(new ki(.1,.1,.1),d.clone())]]},Q={X:[[new de(new Mn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new de(new Mn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new de(new Mn(.2,0,.6,4),i),[0,.3,0]],[new de(new Mn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new de(new Mn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new de(new Mn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new de(new ki(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new de(new ki(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new de(new ki(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new de(new ki(.2,.2,.2),i),[0,0,0]]]},N={X:[[new In(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new In(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new In(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function O(V){const L=new ge;for(const k in V)for(let G=V[k].length;G--;){const J=V[k][G][0].clone(),$=V[k][G][1],re=V[k][G][2],ce=V[k][G][3],Re=V[k][G][4];J.name=k,J.tag=Re,$&&J.position.set($[0],$[1],$[2]),re&&J.rotation.set(re[0],re[1],re[2]),ce&&J.scale.set(ce[0],ce[1],ce[2]),J.updateMatrix();const ie=J.geometry.clone();ie.applyMatrix4(J.matrix),J.geometry=ie,J.renderOrder=1/0,J.position.set(0,0,0),J.rotation.set(0,0,0),J.scale.set(1,1,1),L.add(J)}return L}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=O(C)),this.add(this.gizmo.rotate=O(E)),this.add(this.gizmo.scale=O(I)),this.add(this.picker.translate=O(M)),this.add(this.picker.rotate=O(S)),this.add(this.picker.scale=O(Q)),this.add(this.helper.translate=O(T)),this.add(this.helper.rotate=O(B)),this.add(this.helper.scale=O(N)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:M_;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const o=n[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Ki.setFromEuler(C0.set(0,0,0)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(dg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Ki.setFromEuler(C0.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Ki.setFromEuler(C0.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(Ki),Math.abs(Pi.copy(fg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Ki.setFromEuler(C0.set(0,Math.PI/2,0)),Pi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(J2.lookAt(Y2,Pi,Ru)),o.quaternion.multiply(Ki),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Js.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Js.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Js),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Pi.copy(dg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Pi.copy(fg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Pi.copy(fg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Pi.copy(dg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Pi.copy(Ru).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(E0.copy(i),Pi.copy(this.eye).applyQuaternion(Ki.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(J2.lookAt(this.eye,Y2,Ru)),o.name==="X"&&(Ki.setFromAxisAngle(dg,Math.atan2(-Pi.y,Pi.z)),Ki.multiplyQuaternions(E0,Ki),o.quaternion.copy(Ki)),o.name==="Y"&&(Ki.setFromAxisAngle(Ru,Math.atan2(Pi.x,Pi.z)),Ki.multiplyQuaternions(E0,Ki),o.quaternion.copy(Ki)),o.name==="Z"&&(Ki.setFromAxisAngle(fg,Math.atan2(Pi.y,Pi.x)),Ki.multiplyQuaternions(E0,Ki),o.quaternion.copy(Ki))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class EY extends de{constructor(){super(new Gn(1e5,1e5,2,2),new ci({visible:!1,wireframe:!0,side:mi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),M0.copy(dg).applyQuaternion(t==="local"?this.worldQuaternion:M_),km.copy(Ru).applyQuaternion(t==="local"?this.worldQuaternion:M_),Fm.copy(fg).applyQuaternion(t==="local"?this.worldQuaternion:M_),Pi.copy(km),this.mode){case"translate":case"scale":switch(this.axis){case"X":Pi.copy(this.eye).cross(M0),La.copy(M0).cross(Pi);break;case"Y":Pi.copy(this.eye).cross(km),La.copy(km).cross(Pi);break;case"Z":Pi.copy(this.eye).cross(Fm),La.copy(Fm).cross(Pi);break;case"XY":La.copy(Fm);break;case"YZ":La.copy(M0);break;case"XZ":Pi.copy(Fm),La.copy(km);break;case"XYZ":case"E":La.set(0,0,0);break}break;case"rotate":default:La.set(0,0,0)}La.length()===0?this.quaternion.copy(this.cameraQuaternion):(K2.lookAt(Js.set(0,0,0),La,Pi),this.quaternion.setFromRotationMatrix(K2)),super.updateMatrixWorld(e)}}const MY=ne("debugpatch");function Kx(s,e,t,i){const n=MY===e;if(!t&&!i)return;const r=e+"___needle";IY(s,e,t,i);const o=Object.getOwnPropertyDescriptor(s,e),a=s[e];n&&console.log("Patch",s.constructor.name,e,o,a),o?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,e,o),typeof o.value=="function"&&(s[e]=$2(o.value,s,e))):(n&&console.log("Create patch with new property",s.constructor.name,e,o),Object.defineProperty(s,e,{set:function(l){if(typeof l=="function")this[r]=$2(l,s,e);else{const c=this[r];NN(s,e,this,c,l),this[r]=l,zN(s,e,this,c,l)}},get:function(){const l=this[r];return typeof l=="function"&&l[r]?l[r]:l}}))}function TY(s,e,t){const i=UI(s,e);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(n,1)}}const Z2=Symbol("Needle:Patches:WrappedFunction");function $2(s,e,t){if(s[Z2])return s;const i=function(...n){NN(e,t,this,...n);const r=s.apply(this,n);return zN(e,t,this,r,...n),r};return i[Z2]=!0,i}const T_="Needle:Patches";function L1(){return globalThis[T_]||(globalThis[T_]=new WeakMap),globalThis[T_]}function UI(s,e){const t=L1().get(s);return t?t.get(e):null}function IY(s,e,t,i){let n=L1().get(s);n||(n=new Map,L1().set(s,n));let r=n.get(e);r||(r=[],n.set(e,r)),r.push({prefix:t,postfix:i})}function NN(s,e,t,...i){var r;if(!t)return;const n=UI(s,e);if(n)for(const o of n)(r=o.prefix)==null||r.call(t,...i)}function zN(s,e,t,i,...n){var o;if(!t)return;const r=UI(s,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...n)}const eD=Symbol("gltf-loader-internal-usage-tracker"),RY=ne("debugusers"),sv=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return sv._loadingProcesses>0}beforeRoot(){sv._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const r=t.call(this,i,n);return r.then(o=>(o&&(e._loadedObjects.add(o),o[eD]=e._loadingId),o)),r},null}afterRoot(e){sv._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[eD],t instanceof ge&&(t.parent||t instanceof de&&setTimeout(()=>{RY&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}};let Ug=sv;h(Ug,"_loadingProcesses",0);class GN{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const n=t[0];n&&n.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4344
|
-
`+n.src),e.preventDefault())}})}}const Zx=ne("trackresources");function HN(){return Zx==="dispose"}let wd=!0;Zx===0&&(wd=!1);function PY(s){wd=s}function QN(){return wd}const VN=Symbol("disposable");function NI(s,e){s&&(s[VN]=e,Ju&&console.warn("Set disposable",e,s))}const WN=Symbol("disposed");function BY(s){return s[WN]===!0}function Oi(s){var e;if(s){if(s[VN]===!1){Ju&&console.warn("Object is marked as not disposable",s);return}if(s[WN]=!0,s instanceof ir)Oi(s.environment),Oi(s.background),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial);else if(s instanceof go)Oi(s.geometry),Oi(s.material),Oi(s.skeleton),Oi(s.bindMatrix),Oi(s.bindMatrixInverse),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof de)Oi(s.geometry),Oi(s.material),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof mt){_f(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Oi(i)}}else if(s instanceof tt||s instanceof wr)Ju&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Ot&&Oi(t);else if(s instanceof Ot){_f(s);for(const i of Object.keys(s)){const n=s[i];n instanceof xt&&(Oi(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof xt?(Oi(n),t[i]=null):n instanceof _e&&(Oi(n.value),n.value=null)}}else s instanceof xt?(_f(s),_f(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&_f(s.source.data)):s instanceof Vp?(_f(s.boneTexture),s.boneTexture=null):s instanceof cA||!(s instanceof ge)&&Ju&&console.warn("Unknown object type",s)}}function _f(s){s&&((Ju||HN()||Zx)&&console.warn("๐งจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof rc?s.data=null:s.dispose())}function jN(s){(s instanceof de||s instanceof go)&&(s.material=null,s.geometry=null)}const DY=new Set;function $x(s,e,t=null,i){if(i||(i=DY,i.clear()),!s)return i;const n=s[Bv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&$x(r,!0,t,i));return i}function OY(s){return s[pg]}const Ju=ne("debugresourceusers")||ne("debugmemory"),Bv=Symbol("needle-resource-users"),pg=Symbol("needle-resource-users-count");function cr(s,e){Kx(s,e,function(t,i){wd&&(Cb(Bv,this,t,!1),Cb(Bv,this,i,!0))})}wd&&(cr(de.prototype,"material"),cr(de.prototype,"geometry"),cr(Ot.prototype,"map"),cr(Ot.prototype,"bumpMap"),cr(Ot.prototype,"alphaMap"),cr(Ot.prototype,"normalMap"),cr(Ot.prototype,"displacementMap"),cr(Ot.prototype,"roughnessMap"),cr(Ot.prototype,"metalnessMap"),cr(Ot.prototype,"emissiveMap"),cr(Ot.prototype,"specularMap"),cr(Ot.prototype,"envMap"),cr(Ot.prototype,"lightMap"),cr(Ot.prototype,"aoMap"),cr(Ot.prototype,"gradientMap"));function LY(s){if(wd===!1)return;const e=s[Bv];if(e)for(const t of e)Cb(Bv,t,s,!1)}wd&&Kx(Ot.prototype,"dispose",function(){LY(this)});let k1=0;function Cb(s,e,t,i){if(k1>0)return;if(Array.isArray(t)){for(const r of t)Cb(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[pg]||0;r+=1,t[pg]=r,Ju&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[pg]||0;r>0&&(r-=1,t[pg]=r),Ju&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Ug.isLoading(t)||(Zx&&console.warn(`๐ด Removed all user of "${t.type}"`,t),HN()&&Oi(t)))}t[s]=n}try{Kx(xc.prototype,"render",function(){k1++},function(){k1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var bA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(bA||{});const tD=ne("debugcomponentevents");class xA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),tD&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(tD&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(xA,"eventListeners",new Map);const qN=ne("debugdefines");qp('if(!globalThis[""3.36.3-beta""]) globalThis[""3.36.3-beta""] = "0.0.0";');qp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');qp('if(!globalThis[""Thu Apr 04 2024
|
|
4344
|
+
`+n.src),e.preventDefault())}})}}const Zx=ne("trackresources");function HN(){return Zx==="dispose"}let wd=!0;Zx===0&&(wd=!1);function PY(s){wd=s}function QN(){return wd}const VN=Symbol("disposable");function NI(s,e){s&&(s[VN]=e,Ju&&console.warn("Set disposable",e,s))}const WN=Symbol("disposed");function BY(s){return s[WN]===!0}function Oi(s){var e;if(s){if(s[VN]===!1){Ju&&console.warn("Object is marked as not disposable",s);return}if(s[WN]=!0,s instanceof ir)Oi(s.environment),Oi(s.background),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial);else if(s instanceof go)Oi(s.geometry),Oi(s.material),Oi(s.skeleton),Oi(s.bindMatrix),Oi(s.bindMatrixInverse),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof de)Oi(s.geometry),Oi(s.material),Oi(s.customDepthMaterial),Oi(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof mt){_f(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Oi(i)}}else if(s instanceof tt||s instanceof wr)Ju&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Ot&&Oi(t);else if(s instanceof Ot){_f(s);for(const i of Object.keys(s)){const n=s[i];n instanceof xt&&(Oi(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof xt?(Oi(n),t[i]=null):n instanceof _e&&(Oi(n.value),n.value=null)}}else s instanceof xt?(_f(s),_f(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&_f(s.source.data)):s instanceof Vp?(_f(s.boneTexture),s.boneTexture=null):s instanceof cA||!(s instanceof ge)&&Ju&&console.warn("Unknown object type",s)}}function _f(s){s&&((Ju||HN()||Zx)&&console.warn("๐งจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof rc?s.data=null:s.dispose())}function jN(s){(s instanceof de||s instanceof go)&&(s.material=null,s.geometry=null)}const DY=new Set;function $x(s,e,t=null,i){if(i||(i=DY,i.clear()),!s)return i;const n=s[Bv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&$x(r,!0,t,i));return i}function OY(s){return s[pg]}const Ju=ne("debugresourceusers")||ne("debugmemory"),Bv=Symbol("needle-resource-users"),pg=Symbol("needle-resource-users-count");function cr(s,e){Kx(s,e,function(t,i){wd&&(Cb(Bv,this,t,!1),Cb(Bv,this,i,!0))})}wd&&(cr(de.prototype,"material"),cr(de.prototype,"geometry"),cr(Ot.prototype,"map"),cr(Ot.prototype,"bumpMap"),cr(Ot.prototype,"alphaMap"),cr(Ot.prototype,"normalMap"),cr(Ot.prototype,"displacementMap"),cr(Ot.prototype,"roughnessMap"),cr(Ot.prototype,"metalnessMap"),cr(Ot.prototype,"emissiveMap"),cr(Ot.prototype,"specularMap"),cr(Ot.prototype,"envMap"),cr(Ot.prototype,"lightMap"),cr(Ot.prototype,"aoMap"),cr(Ot.prototype,"gradientMap"));function LY(s){if(wd===!1)return;const e=s[Bv];if(e)for(const t of e)Cb(Bv,t,s,!1)}wd&&Kx(Ot.prototype,"dispose",function(){LY(this)});let k1=0;function Cb(s,e,t,i){if(k1>0)return;if(Array.isArray(t)){for(const r of t)Cb(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[pg]||0;r+=1,t[pg]=r,Ju&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[pg]||0;r>0&&(r-=1,t[pg]=r),Ju&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Ug.isLoading(t)||(Zx&&console.warn(`๐ด Removed all user of "${t.type}"`,t),HN()&&Oi(t)))}t[s]=n}try{Kx(xc.prototype,"render",function(){k1++},function(){k1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var bA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(bA||{});const tD=ne("debugcomponentevents");class xA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),tD&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(tD&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(xA,"eventListeners",new Map);const qN=ne("debugdefines");qp('if(!globalThis[""3.36.3-beta.1""]) globalThis[""3.36.3-beta.1""] = "0.0.0";');qp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');qp('if(!globalThis[""Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)""]) globalThis[""Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)""] = "unknown";');qp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.3-beta.1";');qp('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');qp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)";');const ol="3.36.3-beta.1",ew="undefined",zI="Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)";qN&&console.log(`Engine version: ${ol} (generator: ${ew})
|
|
4345
4345
|
Project built at ${zI}`);const dc="needle_isActiveInHierarchy",Du="builtin_components",Ng="needle_editor_guid";function qp(s){try{(0,eval)(s)}catch(e){qN&&console.error(e)}}const Dv=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),XN=Symbol("isUsingInstancing"),YN=Symbol("instancingRenderer"),mg=Symbol("instancingAutoUpdateBounds");class Qo{static isUsingInstancing(e){return e[XN]===!0}static getRenderer(e){return e[YN]||null}setAutoUpdateBounds(e,t){const i=Qo.getRenderer(e);i&&(i[mg]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[Dv]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)Qo.markDirty(i,!0)}}function Ku(s,e){try{e?s(e):s()}catch(t){return console.error(t),!1}return!0}const F1=ne("debugnewscripts"),kY=ne("debughierarchy"),Yi=[];function FY(){return Yi.length>0}function Eb(s){if(!(s.new_scripts.length<=0)){if(F1&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}Yi.length=0,s.new_scripts.length>0&&Yi.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.isComponent!==!0){(vt()||F1)&&console.error(`Registered script is not a Needle Engine component.
|
|
4346
4346
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
4347
4347
|
`,t),Yi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Yi.splice(e,1),e--;continue}t.context=s,zg(t.gameObject),GI(t,s)}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed){ec(Yi[e],s),Yi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),zg(t.gameObject),t.activeAndEnabled&&Ku(t.__internalAwake.bind(t)))}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed||t.enabled===!1||(zg(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,Ku(t.__internalEnable.bind(t)))}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}for(let e=0;e<Yi.length;e++)try{const t=Yi[e];if(t.destroyed||!t.gameObject)continue;s.new_script_start.push(t)}catch(t){console.error(t),ec(Yi[e],s),Yi.splice(e,1),e--}Yi.length=0;for(const e of s.new_scripts_post_setup_callbacks)e&&e();s.new_scripts_post_setup_callbacks.length=0}}function UY(s){s&&(s.__internalDisable(!0),ec(s,s.context))}function JN(s,e){for(let t=0;t<s.new_script_start.length;t++)try{const i=s.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;Ku(i.__internalAwake.bind(i)),i.enabled&&(Ku(i.__internalEnable.bind(i)),Ku(i.__internalStart.bind(i)),s.new_script_start.splice(t,1),t--)}catch(i){console.error(i),ec(s.new_script_start[t],s),s.new_script_start.splice(t,1),t--}}function GI(s,e){e.scripts.indexOf(s)===-1&&(e.scripts.push(s),s.earlyUpdate&&e.scripts_earlyUpdate.push(s),s.update&&e.scripts_update.push(s),s.lateUpdate&&e.scripts_lateUpdate.push(s),s.onBeforeRender&&e.scripts_onBeforeRender.push(s),s.onAfterRender&&e.scripts_onAfterRender.push(s),s.onPausedChanged&&e.scripts_pausedChanged.push(s),cC(s,null)&&e.new_scripts_xr.push(s),cC(s,"immersive-vr")&&e.scripts_immersive_vr.push(s),cC(s,"immersive-ar")&&e.scripts_immersive_ar.push(s))}function ec(s,e){Io(s,e.new_scripts),Io(s,e.new_script_start),Io(s,e.scripts),Io(s,e.scripts_earlyUpdate),Io(s,e.scripts_update),Io(s,e.scripts_lateUpdate),Io(s,e.scripts_onBeforeRender),Io(s,e.scripts_onAfterRender),Io(s,e.scripts_pausedChanged),Io(s,e.new_scripts_xr),Io(s,e.scripts_immersive_vr),Io(s,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(s)}function Io(s,e){const t=e.indexOf(s);t>=0&&e.splice(t,1)}function cC(s,e){var t;if(s){const i=s;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(e!=null&&((t=i.supportsXR)==null?void 0:t.call(i,e))===!1)}return!1}function I_(s){if(s||(s=oi.Current.scene),!s){console.trace("Invalid call - no current context.");return}const e=Jp(s);KN(s,e,!0)||(F1||vt()?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 r=n.style.cssText,o=document.createElement("div");n.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 a=o.style.cssText,l=(bg==null?void 0:bg.length)>1?bg:"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=l,setInterval(()=>{o.innerHTML!==l&&(o.innerHTML=l),o.parentNode!==n&&n.appendChild(o),n.style.cssText!==r&&(n.style.cssText=r),o.style.cssText!==a&&(o.style.cssText=a)},500),n}let t=e();const i=t.style.cssText;setInterval(()=>{var n;uM===!0&&(t.style.cssText!==i&&(t=e()),s.domElement.shadowRoot?t.parentNode!==s.domElement.shadowRoot&&((n=s.domElement.shadowRoot)==null||n.appendChild(t)):t.parentNode!=document.body&&document.body.appendChild(t))},500)}async function lee(s){try{if(Lp()!==!0)return CC(s)}catch(e){return Uo&&console.log("License check failed",e),CC(s)}Uo&&CC(s)}async function CC(s){s.domElement.addEventListener("ready",()=>!0),await(bh==null?void 0:bh.catch(()=>{})),!Lp()&&cee()}let oO=0;async function cee(s){const e=Date.now();if(e-oO<2e3)return;oO=e;const i=`
|
|
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=${_ee} />
|
|
5064
5069
|
</div>
|
|
5065
|
-
`,this._root.appendChild(t.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 zb}static create(){return document.createElement(zb)}setLogoVisible(t){this.logoElement.style.display=t?"block":"none"}}customElements.get(zb)||customElements.define(zb,Yz);const EC=ne("debugspatialmenu");class bee{constructor(e,t){h(this,"_context");h(this,"needleMenu");h(this,"htmlButtonsMap",new Map);h(this,"enabled",!0);h(this,"uiisDirty",!1);h(this,"_showNeedleLogo");h(this,"_wasInXR",!1);h(this,"preRender",()=>{var t;if(!this.enabled){(t=this.menu)==null||t.removeFromParent();return}EC&&dd()&&this.updateMenu();const e=this._context.xr;if(!(e!=null&&e.running)){this._wasInXR&&(this._wasInXR=!1,this.onExitXR());return}this._wasInXR||(this._wasInXR=!0,this.onEnterXR()),this.updateMenu()});h(this,"_menuTarget",new ge);h(this,"positionFilter",new II(90,.5));h(this,"familyName","Needle Spatial Menu");h(this,"menu");h(this,"_poweredByNeedleElement");var n;this._context=e,this._context.pre_render_callbacks.push(this.preRender),this.needleMenu=t;const i=(n=this.needleMenu.shadowRoot)==null?void 0:n.querySelector(".options");i?new MutationObserver(o=>{if(this.enabled&&!(this._context.isInXR==!1&&!EC))for(const a of o)a.type==="childList"&&(a.addedNodes.forEach(l=>{this.createButtonFromHTMLNode(l)}),a.removedNodes.forEach(l=>{const c=l,u=this.htmlButtonsMap.get(c);u&&(this.htmlButtonsMap.delete(c),u.remove(),Bi.update())}))}).observe(i,{childList:!0}):console.error("Could not find options container in needle menu")}setEnabled(e){var t;this.enabled=e,e||(t=this.menu)==null||t.removeFromParent()}onDestroy(){const e=this._context.pre_render_callbacks.indexOf(this.preRender);e>-1&&this._context.pre_render_callbacks.splice(e,1)}markDirty(){this.uiisDirty=!0}showNeedleLogo(e){this._showNeedleLogo=e}onEnterXR(){var t;const e=(t=this.needleMenu.shadowRoot)==null?void 0:t.querySelector(".options");e&&e.childNodes.forEach(i=>{this.createButtonFromHTMLNode(i)})}onExitXR(){var e;(e=this.menu)==null||e.removeFromParent()}createButtonFromHTMLNode(e){const t=this.getMenu(),i=this.htmlButtonsMap.get(e);if(i){i.add();return}const n=e,r=this.createButton(t,n);this.htmlButtonsMap.set(n,r),r.add()}updateMenu(){var r,o;const e=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(e);const t=this._context.mainCamera,i=this._context.xr,n=(i==null?void 0:i.rigScale)||1;if(t){const a=t.worldPosition,l=t.worldForward.multiplyScalar(-1),c=l.y>.6,u=l.y>.4,d=e.visible?u:c,f=!e.visible&&d;e.visible=d||dd()&&EC,l.multiplyScalar(3*n),a.add(l),(f||!1)&&(e.position.copy(this._menuTarget.position),e.position.y+=1,this._menuTarget.position.copy(e.position),this.positionFilter.reset(e.position),e.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const m=this._menuTarget.position.distanceTo(a);(f||m>1.5*n)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(a),this._context.scene.add(this._menuTarget),AA(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,e.position,this._context.time.time);const A=5;(r=this.menu)==null||r.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*A),(o=this.menu)==null||o.scale.setScalar(n)}this.uiisDirty&&(this.uiisDirty=!1,Bi.update())}ensureRenderOnTop(e,t=0){e instanceof de&&(e.material.depthTest=!1,e.material.depthWrite=!1),e.renderOrder=1e3+t*2;for(const i of e.children)this.ensureRenderOnTop(i,t+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new Bi.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 Ze(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const e=Y.get("ObjectRaycaster");return e&&wh(this.menu,new e),this.menu}handleNeedleWatermark(){var e;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new Bi.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 t=new aO(this._context,()=>globalThis.open("https://needle.tools","_self"));wh(this._poweredByNeedleElement,t);const i=new Bi.Text({textContent:"Powered by",width:"auto",height:"auto"}),n=new Bi.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ze(0,0,0,.02)});this._poweredByNeedleElement.add(i),this._poweredByNeedleElement.add(n),(e=this.menu)==null||e.add(this._poweredByNeedleElement),this.markDirty(),new dl().load("./include/needle/poweredbyneedle.webp",o=>{var l;t.allowModifyUI=!1,i.removeFromParent(),n.removeFromParent();const a=o.image.width/o.image.height;(l=this._poweredByNeedleElement)==null||l.set({backgroundImage:o,backgroundOpacity:1,width:.1*a,height:.1}),this.markDirty()})}if(this.menu){const t=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&xa())t>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const i=this.menu.children.indexOf(this._poweredByNeedleElement);t!==i&&this.markDirty()}}}ensureFont(){let e=Bi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Bi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{this.markDirty()})}}createButton(e,t){const i=new Bi.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}),n=new Bi.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});i.add(n),i["needle:use_eventsystem"]=!0;const r=new aO(this._context,()=>t.click());return wh(i,r),new xee(this,e,t,i,n)}}class xee{constructor(e,t,i,n,r){h(this,"menu");h(this,"root");h(this,"htmlbutton");h(this,"spatialContainer");h(this,"spatialText");h(this,"spatialIcon");h(this,"_lastText","");h(this,"_lastTexture");this.menu=e,this.root=t,this.htmlbutton=i,this.spatialContainer=n,this.spatialText=r,new MutationObserver(a=>{for(const l of a)l.type==="attributes"?l.attributeName==="style"&&this.updateVisible():l.type==="childList"&&this.updateText()}).observe(i,{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 e=this.spatialContainer.visible;this.spatialContainer.visible=this.htmlbutton.style.display!=="none",e!==this.spatialContainer.visible&&this.menu.markDirty()}updateText(){let e="",t="";this.htmlbutton.childNodes.forEach(i=>{i.nodeType===Node.TEXT_NODE?e+=i.textContent:i instanceof HTMLElement&&qz(i)&&i.textContent&&(t=i.textContent)}),this._lastText!==e&&(this._lastText=e,this.spatialText.name=e,this.spatialText.set({textContent:e}),this.menu.markDirty()),e.length<=0?this.spatialText.parent&&(this.spatialText.removeFromParent(),this.menu.markDirty()):this.spatialText.parent||(this.spatialContainer.add(this.spatialText),this.menu.markDirty()),t&&this.createIcon(t)}async createIcon(e){var i;if(!this.spatialIcon){const n=await dM(e);if(n&&!this.spatialIcon){const o=new Bi.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:n,backgroundOpacity:1,margin:new Ze(0,.005,0,0)});this.spatialIcon=o,this.spatialContainer.add(o),this.menu.markDirty()}}if(e!=this._lastTexture){this._lastTexture=e;const n=await dM(e);n&&((i=this.spatialIcon)==null||i.set({backgroundImage:n}),this.menu.markDirty())}const t=this.spatialContainer.children.indexOf(this.spatialIcon);t>0&&(this.spatialContainer.children.splice(t,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class aO{constructor(e,t){h(this,"isComponent",!0);h(this,"enabled",!0);h(this,"gameObject");h(this,"allowModifyUI",!0);h(this,"context");h(this,"onclick");this.context=e,this.onclick=t}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}),Bi.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),Bi.update())}onPointerDown(e){e.use()}onPointerUp(e){e.use()}onPointerClick(e){e.use(),this.onclick()}}const Jf="needle-menu",Gb=ne("debugmenu"),lO=ne("debugnoncommercial");let wee=class{constructor(e){h(this,"_context");h(this,"_menu");h(this,"_spatialMenu");h(this,"onPostMessage",e=>{if(e.origin===globalThis.location.origin&&typeof e.data=="object"){const t=e.data,i=t.type;if(i==="needle:menu"){const n=t.button;if(n){if(!n.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!n.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const r=document.createElement("button");if(r.textContent=n.label,n.icon){const o=lo(n.icon);r.prepend(o)}n.priority&&r.setAttribute("priority",n.priority.toString()),r.onclick=()=>{if(n.onclick){const o=n.onclick.startsWith("http")||n.onclick.startsWith("www."),a=n.target||"_blank";o?globalThis.open(n.onclick,a):console.error("NeedleMenu: onclick is not a valid link",n.onclick)}},this._menu.appendChild(r)}else Gb&&console.error("NeedleMenu: unknown postMessage event",t)}else Gb&&console.warn("NeedleMenu: unknown postMessage type",i,t)}});h(this,"onStartXR",e=>{e.session.isScreenBasedAR&&(this._menu.previousParent=this._menu.parentNode,this._context.arOverlayElement.appendChild(this._menu),e.session.session.addEventListener("end",this.onExitXR))});h(this,"onExitXR",()=>{this._menu.previousParent&&(this._menu.previousParent.appendChild(this._menu),delete this._menu.previousParent)});h(this,"_muteButton");h(this,"_fullscreenButton");this._menu=cw.getOrCreate(e.domElement),this._context=e,this._spatialMenu=new bee(e,this._menu),window.addEventListener("message",this.onPostMessage),sw(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(e){this._menu.setPosition(e)}showNeedleLogo(e){var t;this._menu.showNeedleLogo(e),(t=this._spatialMenu)==null||t.showNeedleLogo(e)}showSpatialMenu(e){this._spatialMenu.setEnabled(e)}showAudioPlaybackOption(e){var t;if(!e){(t=this._muteButton)==null||t.remove();return}this._muteButton=xh.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(e){var t;if(!e){(t=this._fullscreenButton)==null||t.remove();return}this._fullscreenButton=xh.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(e){this._menu.appendChild(e)}};class cw extends HTMLElement{constructor(){var l,c,u,d;super();h(this,"_domElement",null);h(this,"_sizeChangeInterval");h(this,"_userRequestedLogoVisible");h(this,"root");h(this,"wrapper");h(this,"options");h(this,"logoContainer");h(this,"_isHandlingChange",!1);h(this,"_didSort",new Map);h(this,"_lastAvailableWidthChange",0);h(this,"_timeoutHandle",0);h(this,"handleSizeChange",(t,i)=>{if(!this._domElement)return;const n=this._domElement.clientWidth;if(n<500){this.root.classList.add("compact");return}const r=20*2,o=n-r;if(!i&&Math.abs(o-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=o,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const c=l();c<0?this.root.classList.add("compact"):c>0&&(this.root.classList.remove("compact"),l()<0&&this.root.classList.add("compact"))},200);const a=()=>this.options.clientWidth+this.logoContainer.clientWidth,l=()=>o-a()});const t=document.createElement("template");t.innerHTML=`<style>
|
|
5070
|
+
`,this._root.appendChild(t.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 zb}static create(){return document.createElement(zb)}setLogoVisible(t){this.logoElement.style.display=t?"block":"none"}}customElements.get(zb)||customElements.define(zb,Yz);const EC=ne("debugspatialmenu");class bee{constructor(e,t){h(this,"_context");h(this,"needleMenu");h(this,"htmlButtonsMap",new Map);h(this,"enabled",!0);h(this,"uiisDirty",!1);h(this,"_showNeedleLogo");h(this,"_wasInXR",!1);h(this,"preRender",()=>{var t;if(!this.enabled){(t=this.menu)==null||t.removeFromParent();return}EC&&dd()&&this.updateMenu();const e=this._context.xr;if(!(e!=null&&e.running)){this._wasInXR&&(this._wasInXR=!1,this.onExitXR());return}this._wasInXR||(this._wasInXR=!0,this.onEnterXR()),this.updateMenu()});h(this,"_menuTarget",new ge);h(this,"positionFilter",new II(90,.5));h(this,"familyName","Needle Spatial Menu");h(this,"menu");h(this,"_poweredByNeedleElement");var n;this._context=e,this._context.pre_render_callbacks.push(this.preRender),this.needleMenu=t;const i=(n=this.needleMenu.shadowRoot)==null?void 0:n.querySelector(".options");i?new MutationObserver(o=>{if(this.enabled&&!(this._context.isInXR==!1&&!EC))for(const a of o)a.type==="childList"&&(a.addedNodes.forEach(l=>{this.createButtonFromHTMLNode(l)}),a.removedNodes.forEach(l=>{const c=l,u=this.htmlButtonsMap.get(c);u&&(this.htmlButtonsMap.delete(c),u.remove(),Bi.update())}))}).observe(i,{childList:!0}):console.error("Could not find options container in needle menu")}setEnabled(e){var t;this.enabled=e,e||(t=this.menu)==null||t.removeFromParent()}onDestroy(){const e=this._context.pre_render_callbacks.indexOf(this.preRender);e>-1&&this._context.pre_render_callbacks.splice(e,1)}markDirty(){this.uiisDirty=!0}showNeedleLogo(e){this._showNeedleLogo=e}onEnterXR(){var t;const e=(t=this.needleMenu.shadowRoot)==null?void 0:t.querySelector(".options");e&&e.childNodes.forEach(i=>{this.createButtonFromHTMLNode(i)})}onExitXR(){var e;(e=this.menu)==null||e.removeFromParent()}createButtonFromHTMLNode(e){const t=this.getMenu(),i=this.htmlButtonsMap.get(e);if(i){i.add();return}const n=e,r=this.createButton(t,n);this.htmlButtonsMap.set(n,r),r.add()}updateMenu(){var r,o;const e=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(e);const t=this._context.mainCamera,i=this._context.xr,n=(i==null?void 0:i.rigScale)||1;if(t){const a=t.worldPosition,l=t.worldForward.multiplyScalar(-1),c=l.y>.6,u=l.y>.4,d=e.visible?u:c,f=!e.visible&&d;e.visible=d||dd()&&EC,l.multiplyScalar(3*n),a.add(l),(f||!1)&&(e.position.copy(this._menuTarget.position),e.position.y+=1,this._menuTarget.position.copy(e.position),this.positionFilter.reset(e.position),e.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const m=this._menuTarget.position.distanceTo(a);(f||m>1.5*n)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(a),this._context.scene.add(this._menuTarget),AA(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,e.position,this._context.time.time);const A=5;(r=this.menu)==null||r.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*A),(o=this.menu)==null||o.scale.setScalar(n)}this.uiisDirty&&(this.uiisDirty=!1,Bi.update())}ensureRenderOnTop(e,t=0){e instanceof de&&(e.material.depthTest=!1,e.material.depthWrite=!1),e.renderOrder=1e3+t*2;for(const i of e.children)this.ensureRenderOnTop(i,t+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new Bi.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 Ze(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const e=Y.get("ObjectRaycaster");return e&&wh(this.menu,new e),this.menu}handleNeedleWatermark(){var e;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new Bi.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 t=new aO(this._context,()=>globalThis.open("https://needle.tools","_self"));wh(this._poweredByNeedleElement,t);const i=new Bi.Text({textContent:"Powered by",width:"auto",height:"auto"}),n=new Bi.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ze(0,0,0,.02)});this._poweredByNeedleElement.add(i),this._poweredByNeedleElement.add(n),(e=this.menu)==null||e.add(this._poweredByNeedleElement),this.markDirty(),new dl().load("./include/needle/poweredbyneedle.webp",o=>{var l;t.allowModifyUI=!1,i.removeFromParent(),n.removeFromParent();const a=o.image.width/o.image.height;(l=this._poweredByNeedleElement)==null||l.set({backgroundImage:o,backgroundOpacity:1,width:.1*a,height:.1}),this.markDirty()})}if(this.menu){const t=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&xa())t>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const i=this.menu.children.indexOf(this._poweredByNeedleElement);t!==i&&this.markDirty()}}}ensureFont(){let e=Bi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Bi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{this.markDirty()})}}createButton(e,t){const i=new Bi.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}),n=new Bi.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});i.add(n),i["needle:use_eventsystem"]=!0;const r=new aO(this._context,()=>t.click());return wh(i,r),new xee(this,e,t,i,n)}}class xee{constructor(e,t,i,n,r){h(this,"menu");h(this,"root");h(this,"htmlbutton");h(this,"spatialContainer");h(this,"spatialText");h(this,"spatialIcon");h(this,"_lastText","");h(this,"_lastTexture");this.menu=e,this.root=t,this.htmlbutton=i,this.spatialContainer=n,this.spatialText=r,new MutationObserver(a=>{for(const l of a)l.type==="attributes"?l.attributeName==="style"&&this.updateVisible():l.type==="childList"&&this.updateText()}).observe(i,{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 e=this.spatialContainer.visible;this.spatialContainer.visible=this.htmlbutton.style.display!=="none",e!==this.spatialContainer.visible&&this.menu.markDirty()}updateText(){let e="",t="";this.htmlbutton.childNodes.forEach(i=>{i.nodeType===Node.TEXT_NODE?e+=i.textContent:i instanceof HTMLElement&&qz(i)&&i.textContent&&(t=i.textContent)}),this._lastText!==e&&(this._lastText=e,this.spatialText.name=e,this.spatialText.set({textContent:e}),this.menu.markDirty()),e.length<=0?this.spatialText.parent&&(this.spatialText.removeFromParent(),this.menu.markDirty()):this.spatialText.parent||(this.spatialContainer.add(this.spatialText),this.menu.markDirty()),t&&this.createIcon(t)}async createIcon(e){var i;if(!this.spatialIcon){const n=await dM(e);if(n&&!this.spatialIcon){const o=new Bi.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:n,backgroundOpacity:1,margin:new Ze(0,.005,0,0)});this.spatialIcon=o,this.spatialContainer.add(o),this.menu.markDirty()}}if(e!=this._lastTexture){this._lastTexture=e;const n=await dM(e);n&&((i=this.spatialIcon)==null||i.set({backgroundImage:n}),this.menu.markDirty())}const t=this.spatialContainer.children.indexOf(this.spatialIcon);t>0&&(this.spatialContainer.children.splice(t,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class aO{constructor(e,t){h(this,"isComponent",!0);h(this,"enabled",!0);h(this,"gameObject");h(this,"allowModifyUI",!0);h(this,"context");h(this,"onclick");this.context=e,this.onclick=t}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}),Bi.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),Bi.update())}onPointerDown(e){e.use()}onPointerUp(e){e.use()}onPointerClick(e){e.use(),this.onclick()}}const Jf="needle-menu",Gb=ne("debugmenu"),lO=ne("debugnoncommercial");let wee=class{constructor(e){h(this,"_context");h(this,"_menu");h(this,"_spatialMenu");h(this,"onPostMessage",e=>{if(e.origin===globalThis.location.origin&&typeof e.data=="object"){const t=e.data,i=t.type;if(i==="needle:menu"){const n=t.button;if(n){if(!n.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!n.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const r=document.createElement("button");if(r.textContent=n.label,n.icon){const o=lo(n.icon);r.prepend(o)}n.priority&&r.setAttribute("priority",n.priority.toString()),r.onclick=()=>{if(n.onclick){const o=n.onclick.startsWith("http")||n.onclick.startsWith("www."),a=n.target||"_blank";o?globalThis.open(n.onclick,a):console.error("NeedleMenu: onclick is not a valid link",n.onclick)}},this._menu.appendChild(r)}else Gb&&console.error("NeedleMenu: unknown postMessage event",t)}else Gb&&console.warn("NeedleMenu: unknown postMessage type",i,t)}});h(this,"onStartXR",e=>{e.session.isScreenBasedAR&&(this._menu.previousParent=this._menu.parentNode,this._context.arOverlayElement.appendChild(this._menu),e.session.session.addEventListener("end",this.onExitXR))});h(this,"onExitXR",()=>{this._menu.previousParent&&(this._menu.previousParent.appendChild(this._menu),delete this._menu.previousParent)});h(this,"_muteButton");h(this,"_fullscreenButton");this._menu=cw.getOrCreate(e.domElement,e),this._context=e,this._spatialMenu=new bee(e,this._menu),window.addEventListener("message",this.onPostMessage),sw(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(e){this._menu.setPosition(e)}showNeedleLogo(e){var t;this._menu.showNeedleLogo(e),(t=this._spatialMenu)==null||t.showNeedleLogo(e)}showSpatialMenu(e){this._spatialMenu.setEnabled(e)}showAudioPlaybackOption(e){var t;if(!e){(t=this._muteButton)==null||t.remove();return}this._muteButton=xh.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(e){var t;if(!e){(t=this._fullscreenButton)==null||t.remove();return}this._fullscreenButton=xh.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(e){this._menu.appendChild(e)}};class cw extends HTMLElement{constructor(){var c,u,d,f;super();h(this,"_domElement",null);h(this,"_context",null);h(this,"_sizeChangeInterval");h(this,"_userRequestedLogoVisible");h(this,"root");h(this,"wrapper");h(this,"options");h(this,"logoContainer");h(this,"_isHandlingChange",!1);h(this,"_didSort",new Map);h(this,"_lastAvailableWidthChange",0);h(this,"_timeoutHandle",0);h(this,"handleSizeChange",(t,i)=>{if(!this._domElement)return;const n=this._domElement.clientWidth;if(n<500){this.root.classList.add("compact");return}const r=20*2,o=n-r;if(!i&&Math.abs(o-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=o,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const c=l();c<0?this.root.classList.add("compact"):c>0&&(this.root.classList.remove("compact"),l()<0&&this.root.classList.add("compact"))},200);const a=()=>this.options.clientWidth+this.logoContainer.clientWidth,l=()=>o-a()});const t=document.createElement("template");t.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 i=this.attachShadow({mode:"open"});Xz(),fM("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()}}),fM("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:i});const n=t.content.cloneNode(!0);i==null||i.appendChild(n),this.root=i.querySelector("#root"),this.wrapper=(
|
|
5263
|
+
`;const i=this.attachShadow({mode:"open"});Xz(),fM("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()}}),fM("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:i});const n=t.content.cloneNode(!0);i==null||i.appendChild(n),this.root=i.querySelector("#root"),this.wrapper=(c=this.root)==null?void 0:c.querySelector(".wrapper"),this.options=(u=this.root)==null?void 0:u.querySelector(".options"),this.logoContainer=(d=this.root)==null?void 0:d.querySelector(".logo"),(f=this.root)==null||f.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const r=Yz.create();r.style.minHeight="1rem",this.logoContainer.append(r),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),see(p=>{p==!0&&xa()&&!lO&&(this.logoContainer.style.display=this._userRequestedLogoVisible?"":"none")});let o=this._context;setTimeout(()=>o=this._context);let a=-1;new MutationObserver(p=>{var A;this.onChangeDetected(p);const m=this==null?void 0:this.parentNode;(this.style.display!="flex"||this.style.visibility!="visible"||this.style.opacity!="1"||m!=((A=this._domElement)==null?void 0:A.shadowRoot))&&(xa()||(clearInterval(a),a=setInterval(()=>{var v,g,_;o!=null&&o.isInAR&&o.arOverlayElement?m!=o.arOverlayElement&&o.arOverlayElement.appendChild(this):m!=((v=this._domElement)==null?void 0:v.shadowRoot)&&((_=(g=this._domElement)==null?void 0:g.shadowRoot)==null||_.appendChild(this)),this.style.display="flex",this.style.visibility="visible",this.style.opacity="1"},5)))}).observe(this.root,{childList:!0,subtree:!0,attributes:!0}),Gb&&this.___insertDebugOptions()}static create(){return document.createElement(Jf,{is:Jf})}static getOrCreate(t,i){let n=t.querySelector(Jf);return!n&&t.shadowRoot&&(n=t.shadowRoot.querySelector(Jf)),n||(n=cw.create(),n._domElement=t,n._context=i,t.shadowRoot?t.shadowRoot.appendChild(n):t.appendChild(n)),n}connectedCallback(){var t;window.addEventListener("resize",this.handleSizeChange),(t=this._domElement)==null||t.addEventListener("resize",this.handleSizeChange),this.handleMenuVisible(),this._sizeChangeInterval=setInterval(()=>this.handleSizeChange(void 0,!0),5e3)}disconnectedCallback(){var t;window.removeEventListener("resize",this.handleSizeChange),(t=this._domElement)==null||t.removeEventListener("resize",this.handleSizeChange),clearInterval(this._sizeChangeInterval)}showNeedleLogo(t){if(this._userRequestedLogoVisible=t,!xa()||lO){vt()&&console.warn("Needle Menu: You need a PRO license to hide the Needle Engine logo.");return}this.logoContainer.style.display=t?"":"none"}setPosition(t){if(t!=="top"&&t!=="bottom")return console.error("NeedleMenu.setPosition: invalid position",t);this.root.classList.remove("top","bottom"),this.root.classList.add(t)}append(...t){for(const i of t)if(typeof i=="string"){const n=document.createTextNode(i);this.options.appendChild(n)}else this.options.appendChild(i)}appendChild(t){return this.options.appendChild(t)}prepend(...t){for(const i of t)if(typeof i=="string"){const n=document.createTextNode(i);this.options.prepend(n)}else this.options.prepend(i)}onChangeDetected(t){if(!this._isHandlingChange){this._isHandlingChange=!0;try{this.handleMenuVisible();for(const i of t)i.target==this.options&&this.onOptionsChildrenChanged(i)}finally{this._isHandlingChange=!1}}}onOptionsChildrenChanged(t){let i=!1;for(let n=0;n<this.options.children.length;n++)if(this.options.children[n].style.display!="none"){i=!0;break}if(this.logoContainer.classList.toggle("any-options",i),this.handleSizeChange(),t.type==="childList"){let n=!1;const r=Date.now();for(let o=0;o<t.addedNodes.length;o++){const a=t.addedNodes[o],l=this._didSort.get(a);typeof l=="number"&&r-l<100||(this._didSort.set(a,r),n=!0)}if(n){const o=Array.from(this.options.children);o.sort((a,l)=>{const c=parseInt(a.getAttribute("priority")||"0"),u=parseInt(l.getAttribute("priority")||"0");return c-u});for(const a of o)this.options.appendChild(a)}}}handleMenuVisible(){Gb&&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 t=0;t<this.options.children.length;t++)if(this.options.children[t].style.display!="none")return!0;return!1}___insertDebugOptions(){window.addEventListener("keydown",n=>{n.key==="p"&&this.setPosition(this.root.classList.contains("top")?"bottom":"top")});const t=document.createElement("button");t.textContent="Hide Buttons",t.onclick=()=>{const n=new Array(this.options.children.length);for(let r=0;r<this.options.children.length;r++)n[r]=this.options.children[r];for(const r of n)this.options.removeChild(r);setTimeout(()=>{for(const r of n)this.options.appendChild(r)},1e3)},this.appendChild(t);const i=document.createElement("button");i.textContent="Toggle Logo",i.addEventListener("click",()=>{this.logoContainer.style.display=this.logoContainer.style.display==="none"?"":"none"}),this.appendChild(i)}}customElements.get(Jf)||customElements.define(Jf,cw);const xs=ne("debugcontext"),See=ne("stats"),Cee=ne("debugactive"),Eee=ne("debugframerate"),Mee=ne("debugcoroutine"),Tee={};class Iee{constructor(){h(this,"name");h(this,"alias");h(this,"hash");h(this,"runInBackground");h(this,"domElement");h(this,"renderer");h(this,"camera");h(this,"scene")}}var Nn=(s=>(s[s.Start=-1]="Start",s[s.EarlyUpdate=0]="EarlyUpdate",s[s.Update=1]="Update",s[s.LateUpdate=2]="LateUpdate",s[s.OnBeforeRender=3]="OnBeforeRender",s[s.OnAfterRender=4]="OnAfterRender",s[s.PrePhysicsStep=9]="PrePhysicsStep",s[s.PostPhysicsStep=10]="PostPhysicsStep",s[s.Undefined=-1]="Undefined",s))(Nn||{});function hw(s,e){if(!s)return;if(!s.isComponent){(vt()||xs)&&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
|
`,s);return}const t=(e==null?void 0:e.new_scripts)??Ut.Current.new_scripts;t.includes(s)||t.push(s)}const zi=class{constructor(e){h(this,"name");h(this,"alias");h(this,"isManagedExternally",!1);h(this,"isPaused",!1);h(this,"runInBackground",!1);h(this,"targetFrameRate");h(this,"physicsSteps",1);h(this,"hash");h(this,"domElement");h(this,"_resolutionScaleFactor",1);h(this,"_boundingClientRectFrame",-1);h(this,"_boundingClientRect",null);h(this,"_domX");h(this,"_domY");h(this,"xr",null);h(this,"_xrFrame",null);h(this,"_currentFrameEvent",-1);h(this,"scene");h(this,"renderer");h(this,"composer",null);h(this,"scripts",[]);h(this,"scripts_pausedChanged",[]);h(this,"scripts_earlyUpdate",[]);h(this,"scripts_update",[]);h(this,"scripts_lateUpdate",[]);h(this,"scripts_onBeforeRender",[]);h(this,"scripts_onAfterRender",[]);h(this,"scripts_WithCorroutines",[]);h(this,"scripts_immersive_vr",[]);h(this,"scripts_immersive_ar",[]);h(this,"coroutines",{});h(this,"post_setup_callbacks",[]);h(this,"pre_update_callbacks",[]);h(this,"pre_render_callbacks",[]);h(this,"post_render_callbacks",[]);h(this,"pre_update_oneshot_callbacks",[]);h(this,"new_scripts",[]);h(this,"new_script_start",[]);h(this,"new_scripts_pre_setup_callbacks",[]);h(this,"new_scripts_post_setup_callbacks",[]);h(this,"new_scripts_xr",[]);h(this,"mainCameraComponent");h(this,"_camera",null);h(this,"application");h(this,"time");h(this,"input");h(this,"physics");h(this,"connection");h(this,"assets");h(this,"mainLight",null);h(this,"sceneLighting");h(this,"addressables");h(this,"lightmaps");h(this,"players");h(this,"menu");h(this,"_sizeChanged",!1);h(this,"_isCreated",!1);h(this,"_isCreating",!1);h(this,"_isVisible",!1);h(this,"_stats",See?new YK:null);h(this,"_intersectionObserver",null);h(this,"_disposeCallbacks",[]);h(this,"maxRenderResolution");h(this,"_originalCreationArgs");h(this,"onUnhandledRejection",e=>{this.domElement.dispatchEvent(new CustomEvent("error",{detail:e.reason}))});h(this,"_cameraStack",[]);h(this,"_onBeforeRenderListeners",new Map);h(this,"_onAfterRenderListeners",new Map);h(this,"_requireDepthTexture",!1);h(this,"_requireColorTexture",!1);h(this,"_renderTarget");h(this,"_isRendering",!1);h(this,"_createId",0);h(this,"_renderlooperrors",0);h(this,"_lastTimestamp",0);h(this,"_accumulatedTime",0);h(this,"_dispatchReadyAfterFrame",!1);h(this,"_wasPaused",!1);this.name=(e==null?void 0:e.name)||"",this.alias=e==null?void 0:e.alias,this.domElement=(e==null?void 0:e.domElement)||document.body,this.hash=e==null?void 0:e.hash,e!=null&&e.renderer&&(this.renderer=e.renderer,this.isManagedExternally=!0),(e==null?void 0:e.runInBackground)!==void 0&&(this.runInBackground=e.runInBackground),e!=null&&e.scene?this.scene=e.scene:this.scene=new ir,e!=null&&e.camera&&(this._camera=e.camera),this.application=new kv(this),this.time=new Wz,this.input=new R3(this),this.physics=new Nz(this),this.connection=new Ez(this),this.assets=new GN,this.sceneLighting=new Qz(this),this.addressables=new S3(this),this.lightmaps=new J$(this),this.players=new Gz(this),this.menu=new wee(this);const t=()=>this._sizeChanged=!0;window.addEventListener("resize",t),this._disposeCallbacks.push(()=>window.removeEventListener("resize",t));const i=new ResizeObserver(n=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(n=>{this._isVisible=n[0].isIntersecting}),this._disposeCallbacks.push(()=>{var n;return(n=this._intersectionObserver)==null?void 0:n.disconnect()}),oi.register(this)}static get DefaultTargetFrameRate(){return zi._defaultTargetFramerate.value}static set DefaultTargetFrameRate(e){zi._defaultTargetFramerate.value=e}static get DefaultWebGLRendererParameters(){return zi._defaultWebglRendererParameters}get version(){return ol}static get Current(){return oi.Current}static set Current(e){oi.Current=e}appendHTMLElement(e){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(e):this.domElement.appendChild(e)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(e){if(e!==this._resolutionScaleFactor&&typeof e=="number"){if(e<=0){console.error("Invalid resolution scale factor",e);return}this._resolutionScaleFactor=e,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 e,t;return((t=(e=this.renderer)==null?void 0:e.xr)==null?void 0:t.isPresenting)||!1}get xrSessionMode(){var e;return(e=this.xr)==null?void 0:e.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 e,t;return(t=(e=this.renderer)==null?void 0:e.xr)==null?void 0:t.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var e,t;return this.renderer.xr.isPresenting?(t=(e=this.renderer)==null?void 0:e.xr)==null?void 0:t.getCamera():void 0}get arOverlayElement(){const e=this.domElement;return typeof e.getAROverlayContainer=="function"?e.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._camera)return this._camera;if(this.mainCameraComponent){const e=this.mainCameraComponent;return e.cam||e.buildCamera(),e.cam}return null}set mainCamera(e){this._camera=e}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(e){var t,i,n;if((t=this.renderer)==null||t.dispose(),e={...zi.DefaultWebGLRendererParameters,...e},!e.canvas){const r=(n=(i=this.domElement)==null?void 0:i.shadowRoot)==null?void 0:n.querySelector("canvas");r&&(e.canvas=r,xs&&console.log("Using canvas from shadow root",r))}xs&&console.log("Using Renderer Parameters:",e,this.domElement),this.renderer=new xc(e),this.renderer.debug.checkShaderErrors=vt()||ne("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=po,this.renderer.setClearColor(new xe("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=sT,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=gt,this.input.bindEvents()}internalOnUpdateVisible(){var e,t;(e=this._intersectionObserver)==null||e.disconnect(),(t=this._intersectionObserver)==null||t.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(e=!1){var t,i,n;if(e||!this.isManagedExternally&&((t=this.renderer.xr)==null?void 0:t.isPresenting)===!1){this._sizeChanged=!1;const r=this.resolutionScaleFactor;let o=this.domWidth*r,a=this.domHeight*r;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),a=Math.min(this.maxRenderResolution.y,a));const l=this.mainCamera;this.updateAspect(l),this.renderer.setSize(o,a,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((i=this.composer.setSize)==null||i.call(this.composer,o,a),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((n=this.composer.setPixelRatio)==null||n.call(this.composer,window.devicePixelRatio)))}}updateAspect(e,t,i){if(!e)return;t===void 0&&(t=this.domWidth),i===void 0&&(i=this.domHeight);const n=e.aspect;e.aspect=t/i,n!==e.aspect&&e.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(e){return this.create(e)}async create(e){try{this._isCreating=!0,e!==this._originalCreationArgs&&(this._originalCreationArgs=pA(e)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const t=await this.internalOnCreate(e);return this._isCreated=!0,t}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}clear(){var e,t,i,n;oi.dispatchCallback(Rn.ContextClearing,this),Ca(this.scene,!0,!0),this.scene=new ir,(e=this.addressables)==null||e.dispose(),(t=this.lightmaps)==null||t.clear(),(n=(i=this.physics)==null?void 0:i.engine)==null||n.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),oi.dispatchCallback(Rn.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var e,t;this.clear(),(e=this.renderer)==null||e.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(xs&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy();for(const i of this._disposeCallbacks)try{i()}catch(n){console.error("Error in on dispose callback:",n,i)}(t=this.domElement)!=null&&t.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,oi.dispatchCallback(Rn.ContextDestroyed,this),oi.unregister(this),zi.Current===this&&(zi.Current=null)}registerCoroutineUpdate(e,t,i){return typeof(t==null?void 0:t.next)!="function"?(console.error("Registered invalid coroutine function from "+e.name+`
|
|
5261
5266
|
Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
@@ -6290,7 +6295,7 @@ Texture LODs available? ${this.hasTextureLODs?"YES":"NO"}`)}updateLODs(){let e=0
|
|
|
6290
6295
|
}`};var Sre=Object.defineProperty,Cre=Object.getOwnPropertyDescriptor,sy=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Sre(e,t,n),n};const tE=ne("debugcontactshadows");class Jh extends Me{constructor(){super(...arguments);h(this,"darkness",.5);h(this,"opacity",.5);h(this,"blur",4);h(this,"occludeBelowGround",!0);h(this,"backfaceShadows",!0);h(this,"shadowCamera");h(this,"shadowGroup");h(this,"renderTarget");h(this,"renderTargetBlur");h(this,"plane");h(this,"occluderMesh");h(this,"blurPlane");h(this,"depthMaterial");h(this,"horizontalBlurMaterial");h(this,"verticalBlurMaterial")}start(){tE&&console.log("Create ContactShadows on "+this.gameObject.name,this);const t=512;this.shadowGroup=new xr,this.gameObject.add(this.shadowGroup),this.renderTarget=new Yt(t,t),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Yt(t,t),this.renderTargetBlur.texture.generateMipmaps=!1;const i=new Gn(1,1).rotateX(Math.PI/2);if(this.gameObject instanceof de){tE&&console.log("ContactShadows: use existing mesh",this.gameObject),this.plane=this.gameObject;const n=this.plane.material=this.plane.material.clone();n.map=this.renderTarget.texture,n.opacity=this.opacity}else{const n=new ci({map:this.renderTarget.texture,opacity:this.opacity,color:0,transparent:!0,depthWrite:!1});this.plane=new de(i,n),this.plane.scale.y=-1,this.gameObject.add(this.plane)}this.plane&&(this.plane.renderOrder=1),this.occludeBelowGround&&(this.occluderMesh=new de(this.plane.geometry,new ci({depthWrite:!0,stencilWrite:!0,colorWrite:!1})).translateY(-1e-4),this.occluderMesh.renderOrder=-100,this.gameObject.add(this.occluderMesh)),this.blurPlane=new de(i),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 aA,this.depthMaterial.userData.darkness={value:this.darkness},this.depthMaterial.blending=rT,this.depthMaterial.blendEquation=eb,this.backfaceShadows&&(this.depthMaterial.side=mi),this.depthMaterial.onBeforeCompile=n=>{this.depthMaterial&&(n.uniforms.darkness=this.depthMaterial.userData.darkness,n.fragmentShader=`
|
|
6291
6296
|
uniform float darkness;
|
|
6292
6297
|
${n.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 Bt(xre),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Bt(wre),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var t,i,n,r,o,a,l,c;(t=this.renderTarget)==null||t.dispose(),(i=this.renderTargetBlur)==null||i.dispose(),(n=this.depthMaterial)==null||n.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(a=this.blurPlane)==null||a.geometry.dispose(),(l=this.plane)==null||l.geometry.dispose(),(c=this.occluderMesh)==null||c.geometry.dispose()}onBeforeRender(t){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){tE&&console.error("ContactShadows: not initialized yet");return}const i=this.context.scene,n=this.context.renderer,r=n.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof de&&(this.gameObject.visible=!1,Nf(this.gameObject,!1));const a=i.background;i.background=null,i.overrideMaterial=this.depthMaterial;const l=n.getClearAlpha();n.setClearAlpha(0);const c=n.xr.enabled;n.xr.enabled=!1,n.setRenderTarget(this.renderTarget),n.render(i,this.shadowCamera),i.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=o,n.setRenderTarget(r),n.setClearAlpha(l),i.background=a,n.xr.enabled=c}blurShadow(t){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=t*1/256;const i=this.context.renderer,n=i.getRenderTarget();i.setRenderTarget(this.renderTargetBlur),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=t*1/256,i.setRenderTarget(this.renderTarget),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,i.setRenderTarget(n)}}sy([x()],Jh.prototype,"darkness",2);sy([x()],Jh.prototype,"opacity",2);sy([x()],Jh.prototype,"blur",2);sy([x()],Jh.prototype,"occludeBelowGround",2);sy([x()],Jh.prototype,"backfaceShadows",2);var Ere=Object.defineProperty,Mre=Object.getOwnPropertyDescriptor,ry=(s,e,t,i)=>{for(var n=i>1?void 0:i?Mre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ere(e,t,n),n};const aL=ne("debugwebxr"),Tre=new we().makeRotationY(Math.PI);class bo extends Me{constructor(){super(...arguments);h(this,"_arScale",1);h(this,"invertForward",!1);h(this,"customReticle");h(this,"useXRAnchor",!1);h(this,"arTouchTransform",!1);h(this,"_isPlacing",!0);h(this,"_startOffset",new we);h(this,"_createdPlacementObject",null);h(this,"_reparentedComponents",[]);h(this,"_placementScene",new ir);h(this,"_reticle",[]);h(this,"_hits",[]);h(this,"_placementStartTime",-1);h(this,"_rigPlacementMatrix");h(this,"_anchor",null);h(this,"userInput");h(this,"onPlaceScene",t=>{var r;if(this._isPlacing==!1||t.used)return;let i=this._reticle[0],n=this._hits[0];if(t.origin instanceof $I){const o=this._reticle[t.origin.index];o&&(i=o,n=this._hits[t.origin.index])}if(!i){console.warn("No reticle to place...");return}if(!i.visible){console.warn("Reticle is not visible (can not place)");return}if((r=bt.active)!=null&&r.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}t.stopImmediatePropagation(),t.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(i),this.useXRAnchor&&this.onCreateAnchor(bt.active,n)})}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){aL&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new ge;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let n=this.context.scene.children.length-1;n>=0;n--){const r=this.context.scene.children[n];this._placementScene.add(r)}this.context.scene.add(i),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),oe.addComponent(i,this);for(const n of this._reticle)Ca(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:Xa.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:Xa.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,n,r,o;if(t.xr.isTrackingImages){for(const a of this._reticle)a.visible=!1;return}if(this._isPlacing){const a=(i=t.xr.rig)==null?void 0:i.gameObject;a&&a.parent!==this.context.scene&&this.context.scene.add(a);let l=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0)for(const c of t.xr.controllers){const u=c.getHitTest();u&&(l=!0,this.updateReticleAndHits(t.xr,c.index,u,t.xr.rigScale))}if(!l){const c=t.xr.getHitTest();c&&this.updateReticleAndHits(t.xr,0,c,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const a=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(a&&this.context.time.frame%20===0){const l=t.xr.convertSpace(a.transform),c=this._reticle[0];c&&(c.position.copy(l.position),c.quaternion.copy(l.quaternion),this.onApplyPose(c))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new Hf(this.context)),(n=this.userInput)==null||n.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(t.xr.rig){const a=t.xr.rig.gameObject;this.userInput.applyMatrixTo(a.matrix,!0),a.matrix.decompose(a.position,a.quaternion,a.scale),this.userInput.factor=a.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,n,r){this._hits[i]=n.hit;let o=this._reticle[i];if(!o){if(this.customReticle)if(this.customReticle.asset)o=Kp(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new de(new ud(.07,.09,32).rotateX(-Math.PI/2),new ci({side:mi})),o.name="AR Placement Reticle";if(aL){const a=new Wo(1);a.position.y+=.01,o.add(a)}this._reticle[i]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(n.position,this.context.time.deltaTime/.1),o.quaternion.slerp(n.quaternion,this.context.time.deltaTime/.05),o.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(o),o.updateMatrix(),o.visible=!0,o.parent!==this.context.scene&&this.context.scene.add(o),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i==null||i.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const n=this._placementScene.children[i];this.context.scene.add(n)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)oe.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),vt()&&tn("Hit does not support creating an anchor");return}else{const n=await i.createAnchor(t.viewerPose.transform);t.running&&n&&(this._anchor=n)}}applyViewBasedTransform(t){const i=this.context.mainCamera,n=t,r=i.worldPosition,o=n.worldPosition;r.y=o.y,t.lookAt(r)}onApplyPose(t){var r,o,a,l;const i=(o=(r=bt.active)==null?void 0:r.rig)==null?void 0:o.gameObject;if(!i){console.warn("No rig object to place");return}(a=bt.active)!=null&&a.rigScale;const n=i.parent||this.context.scene;this._rigPlacementMatrix?(l=this._rigPlacementMatrix)==null||l.decompose(i.position,i.quaternion,i.scale):this._rigPlacementMatrix=i.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(i),t.removeFromParent(),i.scale.set(this.arScale,this.arScale,this.arScale),i.position.multiplyScalar(this.arScale),i.updateMatrix(),this.invertForward&&i.matrix.premultiply(Tre),i.matrix.premultiply(this._startOffset),i.matrix.decompose(i.position,i.quaternion,i.scale),n.add(i)}}ry([x()],bo.prototype,"arScale",1);ry([x()],bo.prototype,"invertForward",2);ry([x(ni)],bo.prototype,"customReticle",2);ry([x()],bo.prototype,"useXRAnchor",2);ry([x()],bo.prototype,"arTouchTransform",2);const sx=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"factor",1);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_hasChanged",!1);h(this,"_enabled",!1);h(this,"currentlyUsedPointerIds",new Set);h(this,"currentlyUnusedPointerIds",new Set);h(this,"onPointerDownEarly",e=>{this.isActive&&e.stopPropagation()});h(this,"onPointerDownLate",e=>{e.used?this.currentlyUsedPointerIds.add(e.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(e.pointerId)});h(this,"onPointerUpEarly",e=>{this.currentlyUsedPointerIds.delete(e.pointerId),this.currentlyUnusedPointerIds.delete(e.pointerId)});h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=kU()&&i.clientY<window.innerHeight*.1;this.prev.has(i.identifier)||this.prev.set(i.identifier,{ignore:n,x:0,z:0,screenx:0,screeny:0});const r=this.prev.get(i.identifier);if(r){const o=this.getPositionOnPlane(i.clientX,i.clientY);r.x=o.x,r.z=o.z,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1);for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.delete(i.identifier)}});h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i||i.ignore)return;const n=this.getPositionOnPlane(t.clientX,t.clientY),r=n.x-i.x,o=n.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=n.x,i.z=n.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],n=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!n||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(n.screeny-r.screeny,n.screenx-r.screenx),l=o-a;Math.abs(l)>.001&&this.addRotation(l)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,l=Math.sqrt(o*o+a*a),c=n.screenx-r.screenx,u=n.screeny-r.screeny,d=Math.sqrt(c*c+u*u),f=l-d;Math.abs(f)>2&&this.addScale(f)}n.screenx=t.clientX,n.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new bd);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new we);this.context=e,this.offset=new we,this.plane=new Ar,this.plane.setFromNormalAndCoplanarPoint(sx.up,sx.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(e,t){this._hasChanged=!1,t?(this.offset.invert(),e.premultiply(this.offset)):e.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,{queue:Xa.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:Xa.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:Xa.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:Xa.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:Xa.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:Xa.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e/=this._scale,t/=this._scale,e*=this.factor,t*=this.factor,this.offset.elements[12]+=e,this.offset.elements[14]+=t,(e!==0||t!==0)&&(this._hasChanged=!0)}addScale(e){e/=window.innerWidth,e*=-1,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}addRotation(e){e*=-1,this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}};let Hf=sx;h(Hf,"up",new w(0,1,0)),h(Hf,"zero",new w(0,0,0)),h(Hf,"one",new w(1,1,1));const GP=class{constructor(){h(this,"_quicklookButton");h(this,"_arButton");h(this,"_vrButton");h(this,"_sendToQuestButton")}static create(){return new GP}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 xh.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const e=document.createElement("button");return this._quicklookButton=e,e.dataset.needle="quicklook-button",e.innerText="Open in Quicklook",e.prepend(lo("view_in_ar")),e.addEventListener("click",()=>{const t=oe.findObjectOfType(ts);t?(e.classList.add("this-mode-is-requested"),t.exportAndOpen().then(()=>{e.classList.remove("this-mode-is-requested")}).catch(i=>{e.classList.remove("this-mode-is-requested"),console.error(i)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(e),e}createARButton(e){var n;if(this._arButton)return this._arButton;const t="immersive-ar",i=document.createElement("button");return this._arButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-ar-button",i.innerText="Enter AR",i.prepend(lo("view_in_ar")),i.title="Click to start an AR session",i.addEventListener("click",()=>bt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),Xu()||(n=navigator.xr)==null||n.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createVRButton(e){var n;if(this._vrButton)return this._vrButton;const t="immersive-vr",i=document.createElement("button");return this._vrButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-vr-button",i.innerText="Enter VR",i.prepend(lo("panorama_photosphere")),i.title="Click to start a VR session",i.addEventListener("click",()=>bt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),Xu()||(n=navigator.xr)==null||n.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createSendToQuestButton(){var i;if(this._sendToQuestButton)return this._sendToQuestButton;const e="https://oculus.com/open_url/?url=",t=document.createElement("button");return this._sendToQuestButton=t,t.dataset.needle="webxr-sendtoquest-button",t.innerText="Open on Quest",t.prepend(lo("share_windows")),t.title="Click to send this page to the Oculus Browser on your Quest",t.addEventListener("click",()=>{const n=encodeURIComponent(window.location.href);window.open(e+n)}),this.listenToXRSessionState(t),this.hideElementDuringXRSession(t),Xu()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>{var n;(n=navigator.xr)!=null&&n.isSessionSupported("immersive-vr")?t.style.display="none":t.style.display=""}),t}createQRCode(){return xh.getOrCreate().createQRCode()}updateSessionSupported(e,t){if(!("xr"in navigator)){e.style.display="none";return}bt.isSessionSupported(t).then(i=>{e.style.display=i?"":"none",vt()&&!i&&console.log('[WebXR] "'+t+'" is not supported on this device โ make sure your server runs using HTTPS and you have a device connected that supports '+t)})}hideElementDuringXRSession(e){sw(t=>{e["previous-display"]=e.style.display,e.style.display="none"}),KI(t=>{e["previous-display"]!=null&&(e.style.display=e["previous-display"])})}listenToXRSessionState(e,t){t&&(bt.onSessionRequestStart(i=>{i.mode===t?e.classList.add("this-mode-is-requested"):(e["was-disabled"]=e.disabled,e.disabled=!0,e.classList.add("other-mode-is-requested"))}),bt.onSessionRequestEnd(i=>{e.classList.remove("this-mode-is-requested"),e.classList.remove("other-mode-is-requested"),e.disabled=e["was-disabled"]}))}};let Eh=GP;h(Eh,"_instance");var Ire=Object.defineProperty,Rre=Object.getOwnPropertyDescriptor,Tc=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ire(e,t,n),n};const bu=ne("debugtext");var jn=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(jn||{}),IG=(s=>(s[s.Normal=0]="Normal",s[s.Bold=1]="Bold",s[s.Italic=2]="Italic",s[s.BoldAndItalic=3]="BoldAndItalic",s))(IG||{});class Pr extends Dd{constructor(){super(...arguments);h(this,"alignment",0);h(this,"verticalOverflow",0);h(this,"horizontalOverflow",0);h(this,"lineSpacing",1);h(this,"supportRichText",!1);h(this,"font");h(this,"fontStyle",0);h(this,"sRGBTextColor",new xe(1,0,1));h(this,"_text","");h(this,"_fontSize",12);h(this,"_textMeshUi",null);h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){bu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,bu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),bu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var n,r,o;if(bu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let u=this.uiObject.children.length-1;u>=0;u--){const d=this.uiObject.children[u];d.isUI&&(this.uiObject.remove(d),d.clear())}const c=new C_({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(c)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const l=[];for(;a;){const c=this.getNextTag(t,a.endIndex),u={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(c){u.textContent=this.getText(t,a,c),this.handleTag(a,u,l);const d=new C_(u);(r=this.uiObject)==null||r.add(d)}else{u.textContent=t.substring(a.endIndex),this.handleTag(a,u,l);const d=new C_(u);(o=this.uiObject)==null||o.add(d)}a=c}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,n={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(Qb(a,n),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,n){if(!t.isEndTag){if(t.type.includes("color")){const r=new iE(t,{color:i.color});if(n.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new xe(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new iE(t,{fontWeight:700});n.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new iE(t,{fontStyle:"italic"});n.push(r)}}}getText(t,i,n){return t.substring(i.endIndex,n.startIndex)}getNextTag(t,i=0){const n=t.indexOf("<",i),r=t.indexOf(">",n);if(n>=0&&r>=0){const o=t.substring(n+1,r);return{type:o,startIndex:n,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const n=this.font,r=this.getFamilyNameWithCorrectSuffix(n,i);bu&&console.log("Selected font family:"+r);let o=D1.getFontFamily(r);switch(o||(o=D1.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let l=r;l!=null&&l.endsWith("-msdf.json")||(l+="-msdf.json");let c=r;c!=null&&c.endsWith(".png")||(c+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,l,c),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var u;const n=t.lastIndexOf("-");if(n<0)return t;const r=(u=t.substring(n+1))==null?void 0:u.toLowerCase();if(Pre.includes(r))return bu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=t.substring(0,n);switch(bu&&console.log("Select font: ",t,IG[i],a,l,c),i){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return t}}}Tc([x()],Pr.prototype,"alignment",2);Tc([x()],Pr.prototype,"verticalOverflow",2);Tc([x()],Pr.prototype,"horizontalOverflow",2);Tc([x()],Pr.prototype,"lineSpacing",2);Tc([x()],Pr.prototype,"supportRichText",2);Tc([x(URL)],Pr.prototype,"font",2);Tc([x()],Pr.prototype,"fontStyle",2);Tc([x()],Pr.prototype,"text",1);Tc([x()],Pr.prototype,"fontSize",1);class iE{constructor(e,t){h(this,"tag");h(this,"previousValues");this.tag=e,this.previousValues=t}}const Pre=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class gh{constructor(e){h(this,"id");h(this,"content","");h(this,"font",[]);h(this,"pointSize",144);h(this,"width");h(this,"height");h(this,"depth");h(this,"wrapMode");h(this,"horizontalAlignment");h(this,"verticalAlignment");h(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var n;t.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),t.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),t.closeBlock(")"),t.beginBlock(),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(n=this.font)==null||n.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </StageRoot/Materials/${yR(this.material)}>`),t.closeBlock()}}h(gh,"global_id",0);class Dw{static singleLine(e,t,i){const n=new gh("text_"+gh.getId());return n.content=e,t&&(n.pointSize=t),i&&(n.depth=i),n}static multiLine(e,t,i,n,r,o){const a=new gh("text_"+gh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=n,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Bre=new we().makeRotationY(Math.PI),Dre=new we().makeScale(-1,1,-1);class oy{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const n=oe.getComponent(e,Pr);if(!n)return;const r=oe.getComponent(e,Ir);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Bre.clone(),r&&t.matrix.premultiply(Dre);const l=n.color.clone();t.material=new Cr({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=n.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const f=Dw.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,n.alignment),this.setOverflow(f,n),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(n.fontSize),f.depth=.001,f.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case jn.LowerLeft:case jn.MiddleLeft:case jn.UpperLeft:e.horizontalAlignment="left";break;case jn.LowerCenter:case jn.MiddleCenter:case jn.UpperCenter:e.horizontalAlignment="center";break;case jn.LowerRight:case jn.MiddleRight:case jn.UpperRight:e.horizontalAlignment="right";break}switch(t){case jn.LowerLeft:case jn.LowerCenter:case jn.LowerRight:e.verticalAlignment="bottom";break;case jn.MiddleLeft:case jn.MiddleCenter:case jn.MiddleRight:e.verticalAlignment="middle";break;case jn.UpperLeft:case jn.UpperCenter:case jn.UpperRight:e.verticalAlignment="top";break}}}class Ow{get extensionName(){return"tmui"}onExportObject(e,t,i){const n=oe.getComponent(e,Ls);if(n&&n.activeAndEnabled&&n.renderMode===gG.WorldSpace){const r=new oy,o=oe.getComponent(e,Ir),a=oe.getComponent(e,Fh);if(o){o.width,o.height;const l=Nr.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,f=new Map;d.set(c,l),f.set(c,a?a.alpha:1),c.traverse(p=>{if(p===c)return;const m=Nr.createEmpty();m.matrix.copy(p.matrix);const A=p.parent,v=!!A&&typeof A.textContent=="string"&&A.textContent.length>0;let g=f.get(A)||1;const _=oe.getComponent(p,Fh);if(_&&(g*=_.alpha),p instanceof de&&v){const b=p[No];b?r.exportText(b.gameObject,m,i):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",p)}if(p instanceof de&&!v){const b=p.geometry.clone();b.scale(1,1,-1),this.flipWindingOrder(b),m.geometry=b;const C=new xe,M=p.material.opacity;C.copy(p.material.color),m.material=new ci({color:C,opacity:M*g,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,n=t.length/3;i<n;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}const Z0=ne("debugusdz");function Ore(s,e){var o;const t=[],i=oe.getComponentsInChildren(s,Os),n=oe.getComponentsInChildren(s,Tr),r=new Array;if(e.injectImplicitBehaviours)for(const a of i){if(!a||!a.runtimeAnimatorController)continue;const l=a.runtimeAnimatorController.activeState;if(!l||!l.motion||!l.motion.clip||((o=l.motion.clip.tracks)==null?void 0:o.length)<1)continue;const c=new um;c.animator=a,c.stateName=l.name,c.trigger="start",c.name="PlayAnimationOnClick_implicitAtStart_"+c.stateName;const u=new ge;oe.addComponent(u,c),r.push(u),s.add(u)}else for(const a of i){if(!a||!a.runtimeAnimatorController)continue;Z0&&console.log(a);const l=[];for(const c of a.runtimeAnimatorController.enumerateActions()){Z0&&console.log(c);const u=c.getClip();l.includes(u)||l.push(u)}t.push({root:a.gameObject,clips:l})}for(const a of n){Z0&&console.log(a);const l=[];for(const c of a.animations)l.includes(c)||l.push(c);t.push({root:a.gameObject,clips:l})}Z0&&console.log("USDZ Animation Clips",t);for(const a of t)for(const l of a.clips)e.registerAnimation(a.root,l);return r}function Lre(s,e){const t=oe.getComponentsInChildren(s,fn),i=oe.getComponentsInChildren(s,Uh),n=new Array;for(const r of i){if(!r.target)continue;const o=t.indexOf(r.target);o>-1&&t.splice(o,1)}for(const r of t){if(!r||!r.clip||r.volume<=0)continue;const o=new Uh;o.target=r,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;oe.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),n.push(a),s.add(a)}return n}function lL(s){const e=s.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const n=document.createElement("a");n.id="needle-usdz-link",n.style.display="none",n.rel="ar",n.href="",t.appendChild(n);const r=document.createElement("img");return r.id="button",n.appendChild(r),s.domElement.shadowRoot.appendChild(t),n}var kre=Object.defineProperty,Fre=Object.getOwnPropertyDescriptor,rr=(s,e,t,i)=>{for(var n=i>1?void 0:i?Fre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&kre(e,t,n),n};const Dr=ne("debugusdz");class Kh{constructor(){h(this,"callToAction");h(this,"checkoutTitle");h(this,"checkoutSubtitle");h(this,"callToActionURL")}}rr([x()],Kh.prototype,"callToAction",2);rr([x()],Kh.prototype,"checkoutTitle",2);rr([x()],Kh.prototype,"checkoutSubtitle",2);rr([x()],Kh.prototype,"callToActionURL",2);var kE;const OM=(kE=class extends Me{constructor(){super(...arguments);h(this,"objectToExport");h(this,"autoExportAnimations",!1);h(this,"autoExportAudioSources",!0);h(this,"exportFileName");h(this,"customUsdzFile");h(this,"customBranding");h(this,"anchoringType","plane");h(this,"maxTextureSize",2048);h(this,"planeAnchoringAlignment","horizontal");h(this,"interactive",!0);h(this,"allowCreateQuicklookButton",!0);h(this,"quickLookCompatible",!0);h(this,"extensions",[]);h(this,"link");h(this,"button");h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAndOpen()});h(this,"_currentExportTasks",new Map);h(this,"lastCallback")}start(){var e,t,i;Dr&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",n=>{switch(n.key){case"t":this.exportAsync();break}}),Ra()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Tw),this.extensions.push(new Lh),this.extensions.push(new oy),this.extensions.push(new Ow))}onEnable(){var i;const e=jp(),t=cp();(Dr||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=lL(this.context),this.link.addEventListener("message",this.lastCallback)),Dr&&un("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t,i;(e=this.button)==null||e.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Dr&&un("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+k4(),xa()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=lL(this.context)),this.customUsdzFile)return Dr&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e),null;const t=await this.export(this.objectToExport);return t?(Dr&&console.log("USDZ generation done. Downloading as "+e),this.openInQuickLook(t,e),t):(console.warn("No object to export",this),null)}async export(e){if(!e)return console.warn("No object to export"),null;const t=this._currentExportTasks.get(e);if(t)return t;const i=this.internalExport(e);return i instanceof Promise?(this._currentExportTasks.set(e,i),i.then(n=>(this._currentExportTasks.delete(e),n)).catch(n=>(this._currentExportTasks.delete(e),null))):i}async internalExport(e){ti.start("export-usdz",{onProgress:m=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:m}}))}}),ti.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ti.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ti.start("export-usdz-textures","export-usdz");const t=oe.getComponentsInChildren(e,Dn),i=new Array;let n=0;for(const m of t){m.didAutomaticallyUpdateLODLevel=m.automaticallyUpdateLODLevel,m.automaticallyUpdateLODLevel=!1;for(const A of m.sharedMeshes)if(A){const v=m.loadProgressiveMeshes(A,0);v instanceof Promise&&i.push(new Promise((g,_)=>{v.then(()=>{n++,ti.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:n,totalSteps:i.length}),g()}).catch(y=>_(y))}))}for(const A of m.sharedMaterials)if(A){const v=m.loadProgressiveTextures(A,0);v instanceof Promise&&i.push(new Promise((g,_)=>{v.then(()=>{n++,ti.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:n,totalSteps:i.length}),g()}).catch(y=>_(y))}))}}Dr&&un("Progressive Loading: "+i.length),await Promise.all(i),Dr&&un("Progressive Loading: done"),ti.end("export-usdz-textures");const r=Is.Global.Mask;Is.Global.Set(Za.AR),this.applyWebARSessionRoot();const o=new Qte,a=[...this.extensions],l=new GA(this.quickLookCompatible);a.push(l);const c={self:this,exporter:o,extensions:a,object:e};ti.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:c})),ti.report("export-usdz","auto export animations and audio sources");const u=new Array;this.autoExportAnimations&&u.push(...Ore(e,l)),this.extensions.find(m=>m.extensionName==="Audio")&&this.autoExportAudioSources&&u.push(...Lre(e)),o.debug=Dr,o.keepObject=m=>{const A=oe.getComponent(m,Dn);return!(A&&!A.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"),ti.report("export-usdz","Invoking exporter.parse");const f=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),p=new Blob([f],{type:"model/vnd.usdz+zip"});ti.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:c}));for(const m of u)oe.destroy(m);for(const m of t){const A=m.didAutomaticallyUpdateLODLevel;A!=null&&(m.automaticallyUpdateLODLevel=A)}return Is.Global.Set(r),ti.end("export-usdz"),p}openInQuickLook(e,t){const i=e instanceof Blob?URL.createObjectURL(e):e,n=this.buildQuicklookOverlay();Dr&&console.log("QuickLook Overlay",n);const r=n.callToAction?encodeURIComponent(n.callToAction):"",o=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",a=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=i+`#callToAction=${r}&checkoutTitle=${o}&checkoutSubtitle=${a}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(e,t){OM.save(e,t)}static save(e,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof e=="string"?i.href=e:i.href=URL.createObjectURL(e),i.download=t,i.click(),i.remove()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Dr&&tn("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const n=i.get("callToActionURL");Dr&&un("Quicklook url: "+n),n&&(xa()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var i,n,r,o,a,l;const e={};return this.customBranding&&Object.assign(e,this.customBranding),xa()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="๐ต Made with Needle",e.checkoutSubtitle="_"),(((i=e.callToAction)==null?void 0:i.length)||((n=e.checkoutTitle)==null?void 0:n.length)||((r=e.checkoutSubtitle)==null?void 0:r.length))&&((o=e.callToAction)!=null&&o.length||(e.callToAction="\0"),(a=e.checkoutTitle)!=null&&a.length||(e.checkoutTitle="\0"),(l=e.checkoutSubtitle)!=null&&l.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=oe.getComponentInParent(this.objectToExport,bo);const t=e!=null;if(e||(e=oe.getComponentInChildren(this.objectToExport,bo)),Dr&&console.log("applyWebARSessionRoot",e),!e){Dr&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=t?this.objectToExport:e.gameObject,n=1/e.arScale;i.matrix.makeScale(n,n,n),e.invertForward&&i.matrix.multiply(OM.invertForwardMatrix)}createQuicklookButton(){const t=Eh.getOrCreate().createQuicklookButton();return t.parentNode||this.context.menu.appendChild(t),t}},h(kE,"invertForwardMatrix",new we().makeRotationY(Math.PI)),kE);let ts=OM;rr([x(ge)],ts.prototype,"objectToExport",2);rr([x()],ts.prototype,"autoExportAnimations",2);rr([x()],ts.prototype,"autoExportAudioSources",2);rr([x()],ts.prototype,"exportFileName",2);rr([x(URL)],ts.prototype,"customUsdzFile",2);rr([x(Kh)],ts.prototype,"customBranding",2);rr([x()],ts.prototype,"anchoringType",2);rr([x()],ts.prototype,"maxTextureSize",2);rr([x()],ts.prototype,"planeAnchoringAlignment",2);rr([x()],ts.prototype,"interactive",2);rr([x()],ts.prototype,"allowCreateQuicklookButton",2);rr([x()],ts.prototype,"quickLookCompatible",2);class ay extends Me{constructor(){super(...arguments);h(this,"isUsed",!0);h(this,"usedBy",null)}}class YR extends Me{}const cL=ne("debugdeletable");class Lw extends zo{}class JR extends Me{constructor(){super(...arguments);h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=oe.findObjectsOfType(Lw,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=oe.getComponentInParent(this.gameObject,ay);r?cL&&console.warn("Can not delete object with usage marker",this.guid,r):(cL&&console.log("DESTROY",this.gameObject),uw(this.gameObject,this.context.connection))}}}}var Ure=Object.defineProperty,Nre=Object.getOwnPropertyDescriptor,Ud=(s,e,t,i)=>{for(var n=i>1?void 0:i?Nre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ure(e,t,n),n};const hL=ne("debugpost");class Ba extends sr{constructor(){super(...arguments);h(this,"mode");h(this,"focusDistance");h(this,"focalLength");h(this,"aperture");h(this,"gaussianMaxRadius");h(this,"resolutionScale");h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){hL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=i=>{const n=i/300,r=2;return et.lerp(r,.01,n)};const t=20;this.aperture.valueProcessor=i=>{const n=1-i/32;return et.lerp(1,t,n)}}onCreateEffect(){if(this.mode===0){hL&&console.warn("DepthOfField: Mode is set to Off");return}const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let n=1;Ra()&&(n=.6),this.resolutionScale=new Nt(n*t)}const i=new c3(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=n=>{i.cocMaterial.worldFocusDistance=n},this.focalLength.onValueChanged=n=>i.cocMaterial.worldFocusRange=n,this.aperture.onValueChanged=n=>i.bokehScale=n,this.resolutionScale&&(this.resolutionScale.onValueChanged=n=>i.resolution.scale=n),[i]}unapply(){}}Ud([x()],Ba.prototype,"mode",2);Ud([x(Nt)],Ba.prototype,"focusDistance",2);Ud([x(Nt)],Ba.prototype,"focalLength",2);Ud([x(Nt)],Ba.prototype,"aperture",2);Ud([x(Nt)],Ba.prototype,"gaussianMaxRadius",2);Ud([x(Nt)],Ba.prototype,"resolutionScale",2);Ud([x(Nt)],Ba.prototype,"bokehScale",2);ea("DepthOfField",Ba);var zre=Object.defineProperty,Gre=Object.getOwnPropertyDescriptor,Hre=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zre(e,t,n),n};class kw extends Me{constructor(){super(...arguments);h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||oe.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ra()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Hre([x()],kw.prototype,"visibleOn",2);class KR{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Qre=Object.defineProperty,Vre=Object.getOwnPropertyDescriptor,Nd=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qre(e,t,n),n};const cl=ne("debugdrag");var RG=(s=>(s[s.XZPlane=0]="XZPlane",s[s.Attached=1]="Attached",s[s.HitNormal=2]="HitNormal",s[s.DynamicViewAngle=3]="DynamicViewAngle",s[s.SnapToSurfaces=4]="SnapToSurfaces",s[s.None=5]="None",s))(RG||{}),y_;const Ha=(y_=class extends Me{constructor(){super(...arguments);h(this,"dragMode",3);h(this,"snapGridResolution",0);h(this,"keepRotation",!0);h(this,"xrDragMode",1);h(this,"xrKeepRotation",!1);h(this,"xrDistanceDragFactor",1);h(this,"showGizmo",!1);h(this,"targetObject",null);h(this,"orbit",null);h(this,"_dragHelper",null);h(this,"_draggingRigidbodies",[]);h(this,"_potentialDragStartEvt",null);h(this,"_dragHandlers",new Map);h(this,"_totalMovement",new w);h(this,"_marker",null);h(this,"_isDragging",!1);h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(e){this.targetObject=e;for(const t of this._dragHandlers.values())t.setTargetObject(e)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new w,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=oe.findObjectOfType(Ci,this.context),this.gameObject.getComponentInParent(_o)||this.gameObject.addComponent(_o)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||e.mode!=="screen"||(e.event.mode==="tracked-pointer"||e.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const n=oe.getComponentInParent(e.object,Ha);!n||n!==this||(Ha.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&e.mode==="screen"&&Ha.lastHovered===e.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(e){if(!(!this.allowEdit(this.gameObject)||e.used||(e.mode==="tracked-pointer"||e.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(Ha.lastHovered=e.object,e.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=e),Ha._active+=1;const n=new jre(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(e.event.space,n),this.orbit&&(this.orbit.enabled=!1),n.onDragStart(e),this._dragHandlers.size===2){const r=this._dragHandlers.values(),o=r.next().value,a=r.next().value,l=new Wre(this,this.targetObject||this.gameObject,o,a);this._dragHandlers.set(this.gameObject,l),l.onDragStart(e)}e.use()}}onPointerMove(e){(this._isDragging||this._potentialDragStartEvt!==null)&&e.use()}onPointerUp(e){if(cl&&Ct.DrawLabel(e.point??this.gameObject.worldPosition,"POINTERUP:"+e.pointerId+", "+e.button,.03,3),!this.allowEdit(this.gameObject)||e.button!==0)return;this._potentialDragStartEvt=null;const t=this._dragHandlers.get(e.event.space),i=this._dragHandlers.get(this.gameObject);i&&(i.handlerA===t||i.handlerB===t)&&(this._dragHandlers.delete(this.gameObject),i.onDragEnd(e)),t&&(Ha._active>0&&(Ha._active-=1),t.onDragEnd&&t.onDragEnd(e),this._dragHandlers.delete(e.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(e),e.use()),Ha._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const e of this._dragHandlers.values())e.collectMovementInfo&&e.collectMovementInfo(),e.getTotalMovement&&this._totalMovement.add(e.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const e=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(e)}for(const e of this._dragHandlers.values())e.onDragUpdate&&e.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new q_(this.context.mainCamera);else return;if(!e||!e.object)return;const t=oe.getComponentInParent(e.object,Ha);if(!t||t!==this)return;const i=this.targetObject||this.gameObject;if(!i)return;this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const n=oe.getComponentInChildren(i,Oh);cl&&console.log("DRAG START",n,i),n&&(n.fastMode=!0,n==null||n.requestOwnership()),this._marker=oe.addComponent(i,ay),this._draggingRigidbodies.length=0;const r=oe.getComponentsInChildren(i,Wi);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities(),t.resetForcesAndTorques();const e=this.targetObject||this.gameObject;Qo.markDirty(e)}onLastDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(cl&&console.log("DRAG END",t,t==null?void 0:t.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const i=oe.getComponentInChildren(e.object,Oh);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy()}},h(y_,"_active",0),h(y_,"lastHovered"),y_);let Yo=Ha;Nd([x()],Yo.prototype,"dragMode",2);Nd([x()],Yo.prototype,"snapGridResolution",2);Nd([x()],Yo.prototype,"keepRotation",2);Nd([x()],Yo.prototype,"xrDragMode",2);Nd([x()],Yo.prototype,"xrKeepRotation",2);Nd([x()],Yo.prototype,"xrDistanceDragFactor",2);Nd([x()],Yo.prototype,"showGizmo",2);class Wre{constructor(e,t,i,n){h(this,"handlerA");h(this,"handlerB");h(this,"context");h(this,"settings");h(this,"gameObject");h(this,"_handlerAAttachmentPoint",new w);h(this,"_handlerBAttachmentPoint",new w);h(this,"_followObject");h(this,"_manipulatorObject");h(this,"_deviceMode");h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_manipulatorPosOffset",new w);h(this,"_manipulatorRotOffset",new Ce);h(this,"_manipulatorScaleOffset",new w);h(this,"_tempVec1",new w);h(this,"_tempVec2",new w);h(this,"_tempVec3",new w);h(this,"tempLookMatrix",new we);h(this,"_initialScale",new w);h(this,"_initialDistance",0);var o,a;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=i,this.handlerB=n,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const r=(a=(o=bt.active)==null?void 0:o.rig)==null?void 0:a.gameObject;if(!this.handlerA||!this.handlerB||!this.handlerA.hitPointInLocalSpace||!this.handlerB.hitPointInLocalSpace){console.error("Invalid: MultiTouchDragHandler needs two valid DragPointerHandlers with hitPointInLocalSpace set.");return}if(this._tempVec1.copy(this.handlerA.hitPointInLocalSpace),this._tempVec2.copy(this.handlerB.hitPointInLocalSpace),this.gameObject.localToWorld(this._tempVec1),this.gameObject.localToWorld(this._tempVec2),r&&(r.worldToLocal(this._tempVec1),r.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(cl&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now โ controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(t.scale),cl){this._followObject.add(new Wo(2)),this._manipulatorObject.add(new Wo(5));const l=c=>`${c.x.toFixed(2)}, ${c.y.toFixed(2)}, ${c.z.toFixed(2)}`;Ct.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),Ct.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6298
|
+
`)},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Bt(xre),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Bt(wre),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var t,i,n,r,o,a,l,c;(t=this.renderTarget)==null||t.dispose(),(i=this.renderTargetBlur)==null||i.dispose(),(n=this.depthMaterial)==null||n.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(o=this.verticalBlurMaterial)==null||o.dispose(),(a=this.blurPlane)==null||a.geometry.dispose(),(l=this.plane)==null||l.geometry.dispose(),(c=this.occluderMesh)==null||c.geometry.dispose()}onBeforeRender(t){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){tE&&console.error("ContactShadows: not initialized yet");return}const i=this.context.scene,n=this.context.renderer,r=n.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const o=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof de&&(this.gameObject.visible=!1,Nf(this.gameObject,!1));const a=i.background;i.background=null,i.overrideMaterial=this.depthMaterial;const l=n.getClearAlpha();n.setClearAlpha(0);const c=n.xr.enabled;n.xr.enabled=!1;const u=n.renderLists.get(i,0),d=u.transparent;u.transparent=[],n.setRenderTarget(this.renderTarget),n.clear(),n.render(i,this.shadowCamera),u.transparent=d,i.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=o,n.setRenderTarget(r),n.setClearAlpha(l),i.background=a,n.xr.enabled=c}blurShadow(t){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=t*1/256;const i=this.context.renderer,n=i.getRenderTarget();i.setRenderTarget(this.renderTargetBlur),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=t*1/256,i.setRenderTarget(this.renderTarget),i.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,i.setRenderTarget(n)}}sy([x()],Jh.prototype,"darkness",2);sy([x()],Jh.prototype,"opacity",2);sy([x()],Jh.prototype,"blur",2);sy([x()],Jh.prototype,"occludeBelowGround",2);sy([x()],Jh.prototype,"backfaceShadows",2);var Ere=Object.defineProperty,Mre=Object.getOwnPropertyDescriptor,ry=(s,e,t,i)=>{for(var n=i>1?void 0:i?Mre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ere(e,t,n),n};const aL=ne("debugwebxr"),Tre=new we().makeRotationY(Math.PI);class bo extends Me{constructor(){super(...arguments);h(this,"_arScale",1);h(this,"invertForward",!1);h(this,"customReticle");h(this,"useXRAnchor",!1);h(this,"arTouchTransform",!1);h(this,"_isPlacing",!0);h(this,"_startOffset",new we);h(this,"_createdPlacementObject",null);h(this,"_reparentedComponents",[]);h(this,"_placementScene",new ir);h(this,"_reticle",[]);h(this,"_hits",[]);h(this,"_placementStartTime",-1);h(this,"_rigPlacementMatrix");h(this,"_anchor",null);h(this,"userInput");h(this,"onPlaceScene",t=>{var r;if(this._isPlacing==!1||t.used)return;let i=this._reticle[0],n=this._hits[0];if(t.origin instanceof $I){const o=this._reticle[t.origin.index];o&&(i=o,n=this._hits[t.origin.index])}if(!i){console.warn("No reticle to place...");return}if(!i.visible){console.warn("Reticle is not visible (can not place)");return}if((r=bt.active)!=null&&r.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}t.stopImmediatePropagation(),t.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(i),this.useXRAnchor&&this.onCreateAnchor(bt.active,n)})}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.onScaleChanged())}onEnable(){var t;(t=this.customReticle)==null||t.preload()}supportsXR(t){return t==="immersive-ar"}onEnterXR(t){aL&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const i=new ge;this._createdPlacementObject=i,i.name="AR Session Root",this._placementScene.name="AR Placement Scene",this._placementScene.children.length=0;for(let n=this.context.scene.children.length-1;n>=0;n--){const r=this.context.scene.children[n];this._placementScene.add(r)}this.context.scene.add(i),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),oe.addComponent(i,this);for(const n of this._reticle)Ca(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:Xa.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:Xa.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(t){var i,n,r,o;if(t.xr.isTrackingImages){for(const a of this._reticle)a.visible=!1;return}if(this._isPlacing){const a=(i=t.xr.rig)==null?void 0:i.gameObject;a&&a.parent!==this.context.scene&&this.context.scene.add(a);let l=!1;if(t.xr.isPassThrough&&t.xr.controllers.length>0)for(const c of t.xr.controllers){const u=c.getHitTest();u&&(l=!0,this.updateReticleAndHits(t.xr,c.index,u,t.xr.rigScale))}if(!l){const c=t.xr.getHitTest();c&&this.updateReticleAndHits(t.xr,0,c,t.xr.rigScale)}}else{if(this._anchor&&t.xr.referenceSpace){const a=t.xr.frame.getPose(this._anchor.anchorSpace,t.xr.referenceSpace);if(a&&this.context.time.frame%20===0){const l=t.xr.convertSpace(a.transform),c=this._reticle[0];c&&(c.position.copy(l.position),c.quaternion.copy(l.quaternion),this.onApplyPose(c))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new Hf(this.context)),(n=this.userInput)==null||n.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&((o=this.userInput)!=null&&o.hasChanged)){if(t.xr.rig){const a=t.xr.rig.gameObject;this.userInput.applyMatrixTo(a.matrix,!0),a.matrix.decompose(a.position,a.quaternion,a.scale),this.userInput.factor=a.scale.x}this.userInput.reset()}}}updateReticleAndHits(t,i,n,r){this._hits[i]=n.hit;let o=this._reticle[i];if(!o){if(this.customReticle)if(this.customReticle.asset)o=Kp(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else o=new de(new ud(.07,.09,32).rotateX(-Math.PI/2),new ci({side:mi})),o.name="AR Placement Reticle";if(aL){const a=new Wo(1);a.position.y+=.01,o.add(a)}this._reticle[i]=o,o.matrixAutoUpdate=!1,o.visible=!1}o.position.lerp(n.position,this.context.time.deltaTime/.1),o.quaternion.slerp(n.quaternion,this.context.time.deltaTime/.05),o.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(o),o.updateMatrix(),o.visible=!0,o.parent!==this.context.scene&&this.context.scene.add(o),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var t;for(const i of this._reticle)i&&(i.visible=!1,i==null||i.removeFromParent());this._reticle.length=0;for(let i=this._placementScene.children.length-1;i>=0;i--){const n=this._placementScene.children[i];this.context.scene.add(n)}(t=this._createdPlacementObject)==null||t.removeFromParent();for(const i of this._reparentedComponents)oe.addComponent(i.originalObject,i.comp)}async onCreateAnchor(t,i){if(i.createAnchor===void 0){console.warn("Hit does not support creating an anchor",i),vt()&&tn("Hit does not support creating an anchor");return}else{const n=await i.createAnchor(t.viewerPose.transform);t.running&&n&&(this._anchor=n)}}applyViewBasedTransform(t){const i=this.context.mainCamera,n=t,r=i.worldPosition,o=n.worldPosition;r.y=o.y,t.lookAt(r)}onApplyPose(t){var r,o,a,l;const i=(o=(r=bt.active)==null?void 0:r.rig)==null?void 0:o.gameObject;if(!i){console.warn("No rig object to place");return}(a=bt.active)!=null&&a.rigScale;const n=i.parent||this.context.scene;this._rigPlacementMatrix?(l=this._rigPlacementMatrix)==null||l.decompose(i.position,i.quaternion,i.scale):this._rigPlacementMatrix=i.matrix.clone(),this.applyViewBasedTransform(t),t.updateMatrix(),this.context.scene.add(t),t.attach(i),t.removeFromParent(),i.scale.set(this.arScale,this.arScale,this.arScale),i.position.multiplyScalar(this.arScale),i.updateMatrix(),this.invertForward&&i.matrix.premultiply(Tre),i.matrix.premultiply(this._startOffset),i.matrix.decompose(i.position,i.quaternion,i.scale),n.add(i)}}ry([x()],bo.prototype,"arScale",1);ry([x()],bo.prototype,"invertForward",2);ry([x(ni)],bo.prototype,"customReticle",2);ry([x()],bo.prototype,"useXRAnchor",2);ry([x()],bo.prototype,"arTouchTransform",2);const sx=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"factor",1);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_hasChanged",!1);h(this,"_enabled",!1);h(this,"currentlyUsedPointerIds",new Set);h(this,"currentlyUnusedPointerIds",new Set);h(this,"onPointerDownEarly",e=>{this.isActive&&e.stopPropagation()});h(this,"onPointerDownLate",e=>{e.used?this.currentlyUsedPointerIds.add(e.pointerId):this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.add(e.pointerId)});h(this,"onPointerUpEarly",e=>{this.currentlyUsedPointerIds.delete(e.pointerId),this.currentlyUnusedPointerIds.delete(e.pointerId)});h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=kU()&&i.clientY<window.innerHeight*.1;this.prev.has(i.identifier)||this.prev.set(i.identifier,{ignore:n,x:0,z:0,screenx:0,screeny:0});const r=this.prev.get(i.identifier);if(r){const o=this.getPositionOnPlane(i.clientX,i.clientY);r.x=o.x,r.z=o.z,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1);for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.delete(i.identifier)}});h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i||i.ignore)return;const n=this.getPositionOnPlane(t.clientX,t.clientY),r=n.x-i.x,o=n.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=n.x,i.z=n.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],n=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!n||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(n.screeny-r.screeny,n.screenx-r.screenx),l=o-a;Math.abs(l)>.001&&this.addRotation(l)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,l=Math.sqrt(o*o+a*a),c=n.screenx-r.screenx,u=n.screeny-r.screeny,d=Math.sqrt(c*c+u*u),f=l-d;Math.abs(f)>2&&this.addScale(f)}n.screenx=t.clientX,n.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new bd);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new we);this.context=e,this.offset=new we,this.plane=new Ar,this.plane.setFromNormalAndCoplanarPoint(sx.up,sx.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(e,t){this._hasChanged=!1,t?(this.offset.invert(),e.premultiply(this.offset)):e.multiply(this.offset)}get isActive(){return this.currentlyUsedPointerIds.size<=0&&this.currentlyUnusedPointerIds.size>0}enable(){this._enabled||(this._enabled=!0,this.context.input.addEventListener("pointerdown",this.onPointerDownEarly,{queue:Xa.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:Xa.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:Xa.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:Xa.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:Xa.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:Xa.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e/=this._scale,t/=this._scale,e*=this.factor,t*=this.factor,this.offset.elements[12]+=e,this.offset.elements[14]+=t,(e!==0||t!==0)&&(this._hasChanged=!0)}addScale(e){e/=window.innerWidth,e*=-1,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}addRotation(e){e*=-1,this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix),e!==0&&(this._hasChanged=!0)}};let Hf=sx;h(Hf,"up",new w(0,1,0)),h(Hf,"zero",new w(0,0,0)),h(Hf,"one",new w(1,1,1));const GP=class{constructor(){h(this,"_quicklookButton");h(this,"_arButton");h(this,"_vrButton");h(this,"_sendToQuestButton")}static create(){return new GP}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 xh.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const e=document.createElement("button");return this._quicklookButton=e,e.dataset.needle="quicklook-button",e.innerText="Open in Quicklook",e.prepend(lo("view_in_ar")),e.addEventListener("click",()=>{const t=oe.findObjectOfType(ts);t?(e.classList.add("this-mode-is-requested"),t.exportAndOpen().then(()=>{e.classList.remove("this-mode-is-requested")}).catch(i=>{e.classList.remove("this-mode-is-requested"),console.error(i)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(e),e}createARButton(e){var n;if(this._arButton)return this._arButton;const t="immersive-ar",i=document.createElement("button");return this._arButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-ar-button",i.innerText="Enter AR",i.prepend(lo("view_in_ar")),i.title="Click to start an AR session",i.addEventListener("click",()=>bt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),Xu()||(n=navigator.xr)==null||n.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createVRButton(e){var n;if(this._vrButton)return this._vrButton;const t="immersive-vr",i=document.createElement("button");return this._vrButton=i,i.classList.add("webxr-button"),i.dataset.needle="webxr-vr-button",i.innerText="Enter VR",i.prepend(lo("panorama_photosphere")),i.title="Click to start a VR session",i.addEventListener("click",()=>bt.start(t,e)),this.updateSessionSupported(i,t),this.listenToXRSessionState(i,t),this.hideElementDuringXRSession(i),this.isSecureConnection||(i.disabled=!0,i.title="WebXR requires a secure connection (HTTPS)"),Xu()||(n=navigator.xr)==null||n.addEventListener("devicechange",()=>this.updateSessionSupported(i,t)),i}createSendToQuestButton(){var i;if(this._sendToQuestButton)return this._sendToQuestButton;const e="https://oculus.com/open_url/?url=",t=document.createElement("button");return this._sendToQuestButton=t,t.dataset.needle="webxr-sendtoquest-button",t.innerText="Open on Quest",t.prepend(lo("share_windows")),t.title="Click to send this page to the Oculus Browser on your Quest",t.addEventListener("click",()=>{const n=encodeURIComponent(window.location.href);window.open(e+n)}),this.listenToXRSessionState(t),this.hideElementDuringXRSession(t),Xu()||(i=navigator.xr)==null||i.addEventListener("devicechange",()=>{var n;(n=navigator.xr)!=null&&n.isSessionSupported("immersive-vr")?t.style.display="none":t.style.display=""}),t}createQRCode(){return xh.getOrCreate().createQRCode()}updateSessionSupported(e,t){if(!("xr"in navigator)){e.style.display="none";return}bt.isSessionSupported(t).then(i=>{e.style.display=i?"":"none",vt()&&!i&&console.log('[WebXR] "'+t+'" is not supported on this device โ make sure your server runs using HTTPS and you have a device connected that supports '+t)})}hideElementDuringXRSession(e){sw(t=>{e["previous-display"]=e.style.display,e.style.display="none"}),KI(t=>{e["previous-display"]!=null&&(e.style.display=e["previous-display"])})}listenToXRSessionState(e,t){t&&(bt.onSessionRequestStart(i=>{i.mode===t?e.classList.add("this-mode-is-requested"):(e["was-disabled"]=e.disabled,e.disabled=!0,e.classList.add("other-mode-is-requested"))}),bt.onSessionRequestEnd(i=>{e.classList.remove("this-mode-is-requested"),e.classList.remove("other-mode-is-requested"),e.disabled=e["was-disabled"]}))}};let Eh=GP;h(Eh,"_instance");var Ire=Object.defineProperty,Rre=Object.getOwnPropertyDescriptor,Tc=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ire(e,t,n),n};const bu=ne("debugtext");var jn=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(jn||{}),IG=(s=>(s[s.Normal=0]="Normal",s[s.Bold=1]="Bold",s[s.Italic=2]="Italic",s[s.BoldAndItalic=3]="BoldAndItalic",s))(IG||{});class Pr extends Dd{constructor(){super(...arguments);h(this,"alignment",0);h(this,"verticalOverflow",0);h(this,"horizontalOverflow",0);h(this,"lineSpacing",1);h(this,"supportRichText",!1);h(this,"font");h(this,"fontStyle",0);h(this,"sRGBTextColor",new xe(1,0,1));h(this,"_text","");h(this,"_fontSize",12);h(this,"_textMeshUi",null);h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(t=this.uiObject)==null||t.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(t){this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){bu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,bu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),bu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){var t;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(t=this.canvas)==null||t.registerEventReceiver(this)}onDisable(){var t;super.onDisable(),(t=this.canvas)==null||t.unregisterEventReceiver(this)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var n,r,o;if(bu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let u=this.uiObject.children.length-1;u>=0;u--){const d=this.uiObject.children[u];d.isUI&&(this.uiObject.remove(d),d.clear())}const c=new C_({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(c)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const l=[];for(;a;){const c=this.getNextTag(t,a.endIndex),u={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(c){u.textContent=this.getText(t,a,c),this.handleTag(a,u,l);const d=new C_(u);(r=this.uiObject)==null||r.add(d)}else{u.textContent=t.substring(a.endIndex),this.handleTag(a,u,l);const d=new C_(u);(o=this.uiObject)==null||o.add(d)}a=c}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,n={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(Qb(a,n),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,n){if(!t.isEndTag){if(t.type.includes("color")){const r=new iE(t,{color:i.color});if(n.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new xe(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new iE(t,{fontWeight:700});n.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new iE(t,{fontStyle:"italic"});n.push(r)}}}getText(t,i,n){return t.substring(i.endIndex,n.startIndex)}getNextTag(t,i=0){const n=t.indexOf("<",i),r=t.indexOf(">",n);if(n>=0&&r>=0){const o=t.substring(n+1,r);return{type:o,startIndex:n,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const n=this.font,r=this.getFamilyNameWithCorrectSuffix(n,i);bu&&console.log("Selected font family:"+r);let o=D1.getFontFamily(r);switch(o||(o=D1.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let l=r;l!=null&&l.endsWith("-msdf.json")||(l+="-msdf.json");let c=r;c!=null&&c.endsWith(".png")||(c+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,l,c),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var u;const n=t.lastIndexOf("-");if(n<0)return t;const r=(u=t.substring(n+1))==null?void 0:u.toLowerCase();if(Pre.includes(r))return bu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=t.substring(0,n);switch(bu&&console.log("Select font: ",t,IG[i],a,l,c),i){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return t}}}Tc([x()],Pr.prototype,"alignment",2);Tc([x()],Pr.prototype,"verticalOverflow",2);Tc([x()],Pr.prototype,"horizontalOverflow",2);Tc([x()],Pr.prototype,"lineSpacing",2);Tc([x()],Pr.prototype,"supportRichText",2);Tc([x(URL)],Pr.prototype,"font",2);Tc([x()],Pr.prototype,"fontStyle",2);Tc([x()],Pr.prototype,"text",1);Tc([x()],Pr.prototype,"fontSize",1);class iE{constructor(e,t){h(this,"tag");h(this,"previousValues");this.tag=e,this.previousValues=t}}const Pre=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class gh{constructor(e){h(this,"id");h(this,"content","");h(this,"font",[]);h(this,"pointSize",144);h(this,"width");h(this,"height");h(this,"depth");h(this,"wrapMode");h(this,"horizontalAlignment");h(this,"verticalAlignment");h(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var n;t.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),t.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),t.closeBlock(")"),t.beginBlock(),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(n=this.font)==null||n.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </StageRoot/Materials/${yR(this.material)}>`),t.closeBlock()}}h(gh,"global_id",0);class Dw{static singleLine(e,t,i){const n=new gh("text_"+gh.getId());return n.content=e,t&&(n.pointSize=t),i&&(n.depth=i),n}static multiLine(e,t,i,n,r,o){const a=new gh("text_"+gh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=n,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Bre=new we().makeRotationY(Math.PI),Dre=new we().makeScale(-1,1,-1);class oy{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const n=oe.getComponent(e,Pr);if(!n)return;const r=oe.getComponent(e,Ir);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Bre.clone(),r&&t.matrix.premultiply(Dre);const l=n.color.clone();t.material=new Cr({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=n.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const f=Dw.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,n.alignment),this.setOverflow(f,n),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(n.fontSize),f.depth=.001,f.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case jn.LowerLeft:case jn.MiddleLeft:case jn.UpperLeft:e.horizontalAlignment="left";break;case jn.LowerCenter:case jn.MiddleCenter:case jn.UpperCenter:e.horizontalAlignment="center";break;case jn.LowerRight:case jn.MiddleRight:case jn.UpperRight:e.horizontalAlignment="right";break}switch(t){case jn.LowerLeft:case jn.LowerCenter:case jn.LowerRight:e.verticalAlignment="bottom";break;case jn.MiddleLeft:case jn.MiddleCenter:case jn.MiddleRight:e.verticalAlignment="middle";break;case jn.UpperLeft:case jn.UpperCenter:case jn.UpperRight:e.verticalAlignment="top";break}}}class Ow{get extensionName(){return"tmui"}onExportObject(e,t,i){const n=oe.getComponent(e,Ls);if(n&&n.activeAndEnabled&&n.renderMode===gG.WorldSpace){const r=new oy,o=oe.getComponent(e,Ir),a=oe.getComponent(e,Fh);if(o){o.width,o.height;const l=Nr.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,f=new Map;d.set(c,l),f.set(c,a?a.alpha:1),c.traverse(p=>{if(p===c)return;const m=Nr.createEmpty();m.matrix.copy(p.matrix);const A=p.parent,v=!!A&&typeof A.textContent=="string"&&A.textContent.length>0;let g=f.get(A)||1;const _=oe.getComponent(p,Fh);if(_&&(g*=_.alpha),p instanceof de&&v){const b=p[No];b?r.exportText(b.gameObject,m,i):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",p)}if(p instanceof de&&!v){const b=p.geometry.clone();b.scale(1,1,-1),this.flipWindingOrder(b),m.geometry=b;const C=new xe,M=p.material.opacity;C.copy(p.material.color),m.material=new ci({color:C,opacity:M*g,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,n=t.length/3;i<n;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}const Z0=ne("debugusdz");function Ore(s,e){var o;const t=[],i=oe.getComponentsInChildren(s,Os),n=oe.getComponentsInChildren(s,Tr),r=new Array;if(e.injectImplicitBehaviours)for(const a of i){if(!a||!a.runtimeAnimatorController)continue;const l=a.runtimeAnimatorController.activeState;if(!l||!l.motion||!l.motion.clip||((o=l.motion.clip.tracks)==null?void 0:o.length)<1)continue;const c=new um;c.animator=a,c.stateName=l.name,c.trigger="start",c.name="PlayAnimationOnClick_implicitAtStart_"+c.stateName;const u=new ge;oe.addComponent(u,c),r.push(u),s.add(u)}else for(const a of i){if(!a||!a.runtimeAnimatorController)continue;Z0&&console.log(a);const l=[];for(const c of a.runtimeAnimatorController.enumerateActions()){Z0&&console.log(c);const u=c.getClip();l.includes(u)||l.push(u)}t.push({root:a.gameObject,clips:l})}for(const a of n){Z0&&console.log(a);const l=[];for(const c of a.animations)l.includes(c)||l.push(c);t.push({root:a.gameObject,clips:l})}Z0&&console.log("USDZ Animation Clips",t);for(const a of t)for(const l of a.clips)e.registerAnimation(a.root,l);return r}function Lre(s,e){const t=oe.getComponentsInChildren(s,fn),i=oe.getComponentsInChildren(s,Uh),n=new Array;for(const r of i){if(!r.target)continue;const o=t.indexOf(r.target);o>-1&&t.splice(o,1)}for(const r of t){if(!r||!r.clip||r.volume<=0)continue;const o=new Uh;o.target=r,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;oe.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),n.push(a),s.add(a)}return n}function lL(s){const e=s.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const n=document.createElement("a");n.id="needle-usdz-link",n.style.display="none",n.rel="ar",n.href="",t.appendChild(n);const r=document.createElement("img");return r.id="button",n.appendChild(r),s.domElement.shadowRoot.appendChild(t),n}var kre=Object.defineProperty,Fre=Object.getOwnPropertyDescriptor,rr=(s,e,t,i)=>{for(var n=i>1?void 0:i?Fre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&kre(e,t,n),n};const Dr=ne("debugusdz");class Kh{constructor(){h(this,"callToAction");h(this,"checkoutTitle");h(this,"checkoutSubtitle");h(this,"callToActionURL")}}rr([x()],Kh.prototype,"callToAction",2);rr([x()],Kh.prototype,"checkoutTitle",2);rr([x()],Kh.prototype,"checkoutSubtitle",2);rr([x()],Kh.prototype,"callToActionURL",2);var kE;const OM=(kE=class extends Me{constructor(){super(...arguments);h(this,"objectToExport");h(this,"autoExportAnimations",!1);h(this,"autoExportAudioSources",!0);h(this,"exportFileName");h(this,"customUsdzFile");h(this,"customBranding");h(this,"anchoringType","plane");h(this,"maxTextureSize",2048);h(this,"planeAnchoringAlignment","horizontal");h(this,"interactive",!0);h(this,"allowCreateQuicklookButton",!0);h(this,"quickLookCompatible",!0);h(this,"extensions",[]);h(this,"link");h(this,"button");h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAndOpen()});h(this,"_currentExportTasks",new Map);h(this,"lastCallback")}start(){var e,t,i;Dr&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",n=>{switch(n.key){case"t":this.exportAsync();break}}),Ra()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Tw),this.extensions.push(new Lh),this.extensions.push(new oy),this.extensions.push(new Ow))}onEnable(){var i;const e=jp(),t=cp();(Dr||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=lL(this.context),this.link.addEventListener("message",this.lastCallback)),Dr&&un("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t,i;(e=this.button)==null||e.remove(),(t=this.link)==null||t.removeEventListener("message",this.lastCallback),Dr&&un("USDZ Exporter disabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+k4(),xa()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=lL(this.context)),this.customUsdzFile)return Dr&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e),null;const t=await this.export(this.objectToExport);return t?(Dr&&console.log("USDZ generation done. Downloading as "+e),this.openInQuickLook(t,e),t):(console.warn("No object to export",this),null)}async export(e){if(!e)return console.warn("No object to export"),null;const t=this._currentExportTasks.get(e);if(t)return t;const i=this.internalExport(e);return i instanceof Promise?(this._currentExportTasks.set(e,i),i.then(n=>(this._currentExportTasks.delete(e),n)).catch(n=>(this._currentExportTasks.delete(e),null))):i}async internalExport(e){ti.start("export-usdz",{onProgress:m=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:m}}))}}),ti.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ti.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ti.start("export-usdz-textures","export-usdz");const t=oe.getComponentsInChildren(e,Dn),i=new Array;let n=0;for(const m of t){m.didAutomaticallyUpdateLODLevel=m.automaticallyUpdateLODLevel,m.automaticallyUpdateLODLevel=!1;for(const A of m.sharedMeshes)if(A){const v=m.loadProgressiveMeshes(A,0);v instanceof Promise&&i.push(new Promise((g,_)=>{v.then(()=>{n++,ti.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:n,totalSteps:i.length}),g()}).catch(y=>_(y))}))}for(const A of m.sharedMaterials)if(A){const v=m.loadProgressiveTextures(A,0);v instanceof Promise&&i.push(new Promise((g,_)=>{v.then(()=>{n++,ti.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:n,totalSteps:i.length}),g()}).catch(y=>_(y))}))}}Dr&&un("Progressive Loading: "+i.length),await Promise.all(i),Dr&&un("Progressive Loading: done"),ti.end("export-usdz-textures");const r=Is.Global.Mask;Is.Global.Set(Za.AR),this.applyWebARSessionRoot();const o=new Qte,a=[...this.extensions],l=new GA(this.quickLookCompatible);a.push(l);const c={self:this,exporter:o,extensions:a,object:e};ti.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:c})),ti.report("export-usdz","auto export animations and audio sources");const u=new Array;this.autoExportAnimations&&u.push(...Ore(e,l)),this.extensions.find(m=>m.extensionName==="Audio")&&this.autoExportAudioSources&&u.push(...Lre(e)),o.debug=Dr,o.keepObject=m=>{const A=oe.getComponent(m,Dn);return!(A&&!A.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"),ti.report("export-usdz","Invoking exporter.parse");const f=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),p=new Blob([f],{type:"model/vnd.usdz+zip"});ti.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:c}));for(const m of u)oe.destroy(m);for(const m of t){const A=m.didAutomaticallyUpdateLODLevel;A!=null&&(m.automaticallyUpdateLODLevel=A)}return Is.Global.Set(r),ti.end("export-usdz"),p}openInQuickLook(e,t){const i=e instanceof Blob?URL.createObjectURL(e):e,n=this.buildQuicklookOverlay();Dr&&console.log("QuickLook Overlay",n);const r=n.callToAction?encodeURIComponent(n.callToAction):"",o=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",a=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=i+`#callToAction=${r}&checkoutTitle=${o}&checkoutSubtitle=${a}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}download(e,t){OM.save(e,t)}static save(e,t){const i=document.createElement("a");i.style.display="none",document.body.appendChild(i),typeof e=="string"?i.href=e:i.href=URL.createObjectURL(e),i.download=t,i.click(),i.remove()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Dr&&tn("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const n=i.get("callToActionURL");Dr&&un("Quicklook url: "+n),n&&(xa()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var i,n,r,o,a,l;const e={};return this.customBranding&&Object.assign(e,this.customBranding),xa()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="๐ต Made with Needle",e.checkoutSubtitle="_"),(((i=e.callToAction)==null?void 0:i.length)||((n=e.checkoutTitle)==null?void 0:n.length)||((r=e.checkoutSubtitle)==null?void 0:r.length))&&((o=e.callToAction)!=null&&o.length||(e.callToAction="\0"),(a=e.checkoutTitle)!=null&&a.length||(e.checkoutTitle="\0"),(l=e.checkoutSubtitle)!=null&&l.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=oe.getComponentInParent(this.objectToExport,bo);const t=e!=null;if(e||(e=oe.getComponentInChildren(this.objectToExport,bo)),Dr&&console.log("applyWebARSessionRoot",e),!e){Dr&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=t?this.objectToExport:e.gameObject,n=1/e.arScale;i.matrix.makeScale(n,n,n),e.invertForward&&i.matrix.multiply(OM.invertForwardMatrix)}createQuicklookButton(){const t=Eh.getOrCreate().createQuicklookButton();return t.parentNode||this.context.menu.appendChild(t),t}},h(kE,"invertForwardMatrix",new we().makeRotationY(Math.PI)),kE);let ts=OM;rr([x(ge)],ts.prototype,"objectToExport",2);rr([x()],ts.prototype,"autoExportAnimations",2);rr([x()],ts.prototype,"autoExportAudioSources",2);rr([x()],ts.prototype,"exportFileName",2);rr([x(URL)],ts.prototype,"customUsdzFile",2);rr([x(Kh)],ts.prototype,"customBranding",2);rr([x()],ts.prototype,"anchoringType",2);rr([x()],ts.prototype,"maxTextureSize",2);rr([x()],ts.prototype,"planeAnchoringAlignment",2);rr([x()],ts.prototype,"interactive",2);rr([x()],ts.prototype,"allowCreateQuicklookButton",2);rr([x()],ts.prototype,"quickLookCompatible",2);class ay extends Me{constructor(){super(...arguments);h(this,"isUsed",!0);h(this,"usedBy",null)}}class YR extends Me{}const cL=ne("debugdeletable");class Lw extends zo{}class JR extends Me{constructor(){super(...arguments);h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=oe.findObjectsOfType(Lw,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=oe.getComponentInParent(this.gameObject,ay);r?cL&&console.warn("Can not delete object with usage marker",this.guid,r):(cL&&console.log("DESTROY",this.gameObject),uw(this.gameObject,this.context.connection))}}}}var Ure=Object.defineProperty,Nre=Object.getOwnPropertyDescriptor,Ud=(s,e,t,i)=>{for(var n=i>1?void 0:i?Nre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ure(e,t,n),n};const hL=ne("debugpost");class Ba extends sr{constructor(){super(...arguments);h(this,"mode");h(this,"focusDistance");h(this,"focalLength");h(this,"aperture");h(this,"gaussianMaxRadius");h(this,"resolutionScale");h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){hL&&console.log("DOF: INIT"),this.focalLength.valueProcessor=i=>{const n=i/300,r=2;return et.lerp(r,.01,n)};const t=20;this.aperture.valueProcessor=i=>{const n=1-i/32;return et.lerp(1,t,n)}}onCreateEffect(){if(this.mode===0){hL&&console.warn("DepthOfField: Mode is set to Off");return}const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let n=1;Ra()&&(n=.6),this.resolutionScale=new Nt(n*t)}const i=new c3(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=n=>{i.cocMaterial.worldFocusDistance=n},this.focalLength.onValueChanged=n=>i.cocMaterial.worldFocusRange=n,this.aperture.onValueChanged=n=>i.bokehScale=n,this.resolutionScale&&(this.resolutionScale.onValueChanged=n=>i.resolution.scale=n),[i]}unapply(){}}Ud([x()],Ba.prototype,"mode",2);Ud([x(Nt)],Ba.prototype,"focusDistance",2);Ud([x(Nt)],Ba.prototype,"focalLength",2);Ud([x(Nt)],Ba.prototype,"aperture",2);Ud([x(Nt)],Ba.prototype,"gaussianMaxRadius",2);Ud([x(Nt)],Ba.prototype,"resolutionScale",2);Ud([x(Nt)],Ba.prototype,"bokehScale",2);ea("DepthOfField",Ba);var zre=Object.defineProperty,Gre=Object.getOwnPropertyDescriptor,Hre=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zre(e,t,n),n};class kw extends Me{constructor(){super(...arguments);h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||oe.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ra()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Hre([x()],kw.prototype,"visibleOn",2);class KR{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Qre=Object.defineProperty,Vre=Object.getOwnPropertyDescriptor,Nd=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vre(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Qre(e,t,n),n};const cl=ne("debugdrag");var RG=(s=>(s[s.XZPlane=0]="XZPlane",s[s.Attached=1]="Attached",s[s.HitNormal=2]="HitNormal",s[s.DynamicViewAngle=3]="DynamicViewAngle",s[s.SnapToSurfaces=4]="SnapToSurfaces",s[s.None=5]="None",s))(RG||{}),y_;const Ha=(y_=class extends Me{constructor(){super(...arguments);h(this,"dragMode",3);h(this,"snapGridResolution",0);h(this,"keepRotation",!0);h(this,"xrDragMode",1);h(this,"xrKeepRotation",!1);h(this,"xrDistanceDragFactor",1);h(this,"showGizmo",!1);h(this,"targetObject",null);h(this,"orbit",null);h(this,"_dragHelper",null);h(this,"_draggingRigidbodies",[]);h(this,"_potentialDragStartEvt",null);h(this,"_dragHandlers",new Map);h(this,"_totalMovement",new w);h(this,"_marker",null);h(this,"_isDragging",!1);h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(e){this.targetObject=e;for(const t of this._dragHandlers.values())t.setTargetObject(e)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new w,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=oe.findObjectOfType(Ci,this.context),this.gameObject.getComponentInParent(_o)||this.gameObject.addComponent(_o)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||e.mode!=="screen"||(e.event.mode==="tracked-pointer"||e.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const n=oe.getComponentInParent(e.object,Ha);!n||n!==this||(Ha.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&e.mode==="screen"&&Ha.lastHovered===e.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(e){if(!(!this.allowEdit(this.gameObject)||e.used||(e.mode==="tracked-pointer"||e.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(Ha.lastHovered=e.object,e.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=e),Ha._active+=1;const n=new jre(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(e.event.space,n),this.orbit&&(this.orbit.enabled=!1),n.onDragStart(e),this._dragHandlers.size===2){const r=this._dragHandlers.values(),o=r.next().value,a=r.next().value,l=new Wre(this,this.targetObject||this.gameObject,o,a);this._dragHandlers.set(this.gameObject,l),l.onDragStart(e)}e.use()}}onPointerMove(e){(this._isDragging||this._potentialDragStartEvt!==null)&&e.use()}onPointerUp(e){if(cl&&Ct.DrawLabel(e.point??this.gameObject.worldPosition,"POINTERUP:"+e.pointerId+", "+e.button,.03,3),!this.allowEdit(this.gameObject)||e.button!==0)return;this._potentialDragStartEvt=null;const t=this._dragHandlers.get(e.event.space),i=this._dragHandlers.get(this.gameObject);i&&(i.handlerA===t||i.handlerB===t)&&(this._dragHandlers.delete(this.gameObject),i.onDragEnd(e)),t&&(Ha._active>0&&(Ha._active-=1),t.onDragEnd&&t.onDragEnd(e),this._dragHandlers.delete(e.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(e),e.use()),Ha._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const e of this._dragHandlers.values())e.collectMovementInfo&&e.collectMovementInfo(),e.getTotalMovement&&this._totalMovement.add(e.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const e=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(e)}for(const e of this._dragHandlers.values())e.onDragUpdate&&e.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new q_(this.context.mainCamera);else return;if(!e||!e.object)return;const t=oe.getComponentInParent(e.object,Ha);if(!t||t!==this)return;const i=this.targetObject||this.gameObject;if(!i)return;this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const n=oe.getComponentInChildren(i,Oh);cl&&console.log("DRAG START",n,i),n&&(n.fastMode=!0,n==null||n.requestOwnership()),this._marker=oe.addComponent(i,ay),this._draggingRigidbodies.length=0;const r=oe.getComponentsInChildren(i,Wi);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities(),t.resetForcesAndTorques();const e=this.targetObject||this.gameObject;Qo.markDirty(e)}onLastDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(cl&&console.log("DRAG END",t,t==null?void 0:t.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const i=oe.getComponentInChildren(e.object,Oh);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy()}},h(y_,"_active",0),h(y_,"lastHovered"),y_);let Yo=Ha;Nd([x()],Yo.prototype,"dragMode",2);Nd([x()],Yo.prototype,"snapGridResolution",2);Nd([x()],Yo.prototype,"keepRotation",2);Nd([x()],Yo.prototype,"xrDragMode",2);Nd([x()],Yo.prototype,"xrKeepRotation",2);Nd([x()],Yo.prototype,"xrDistanceDragFactor",2);Nd([x()],Yo.prototype,"showGizmo",2);class Wre{constructor(e,t,i,n){h(this,"handlerA");h(this,"handlerB");h(this,"context");h(this,"settings");h(this,"gameObject");h(this,"_handlerAAttachmentPoint",new w);h(this,"_handlerBAttachmentPoint",new w);h(this,"_followObject");h(this,"_manipulatorObject");h(this,"_deviceMode");h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_manipulatorPosOffset",new w);h(this,"_manipulatorRotOffset",new Ce);h(this,"_manipulatorScaleOffset",new w);h(this,"_tempVec1",new w);h(this,"_tempVec2",new w);h(this,"_tempVec3",new w);h(this,"tempLookMatrix",new we);h(this,"_initialScale",new w);h(this,"_initialDistance",0);var o,a;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=i,this.handlerB=n,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const r=(a=(o=bt.active)==null?void 0:o.rig)==null?void 0:a.gameObject;if(!this.handlerA||!this.handlerB||!this.handlerA.hitPointInLocalSpace||!this.handlerB.hitPointInLocalSpace){console.error("Invalid: MultiTouchDragHandler needs two valid DragPointerHandlers with hitPointInLocalSpace set.");return}if(this._tempVec1.copy(this.handlerA.hitPointInLocalSpace),this._tempVec2.copy(this.handlerB.hitPointInLocalSpace),this.gameObject.localToWorld(this._tempVec1),this.gameObject.localToWorld(this._tempVec2),r&&(r.worldToLocal(this._tempVec1),r.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(cl&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now โ controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(t.scale),cl){this._followObject.add(new Wo(2)),this._manipulatorObject.add(new Wo(5));const l=c=>`${c.x.toFixed(2)}, ${c.y.toFixed(2)}, ${c.z.toFixed(2)}`;Ct.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),Ct.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6294
6299
|
`+l(this._tempVec1)+`
|
|
6295
6300
|
`+l(this._tempVec2),.03,5)}}onDragStart(e){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=e.mode,this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this.alignManipulator(),this._manipulatorObject.attach(this._followObject),this._manipulatorPosOffset.copy(this._followObject.position),this._manipulatorRotOffset.copy(this._followObject.quaternion),this._manipulatorScaleOffset.copy(this._followObject.scale)}onDragEnd(e){if(!this.handlerA||!this.handlerB){console.error("onDragEnd called on MultiTouchDragHandler without valid handlers. This is likely a bug.");return}this.handlerA.recenter(),this.handlerB.recenter(),this._manipulatorObject.removeFromParent(),this._followObject.removeFromParent(),this._manipulatorObject.destroy(),this._followObject.destroy()}alignManipulator(){if(!this.handlerA||!this.handlerB){console.error("alignManipulator called on MultiTouchDragHandler without valid handlers. This is likely a bug.",this);return}if(!this.handlerA.followObject||!this.handlerB.followObject){console.error("alignManipulator called on MultiTouchDragHandler without valid follow objects. This is likely a bug.",this.handlerA,this.handlerB);return}this._tempVec1.copy(this._handlerAAttachmentPoint),this._tempVec2.copy(this._handlerBAttachmentPoint),this.handlerA.followObject.localToWorld(this._tempVec1),this.handlerB.followObject.localToWorld(this._tempVec2),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._manipulatorObject.position.copy(this._tempVec3);const e=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,e.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const t=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(t/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),cl&&(Ct.DrawLabel(this._tempVec3.clone().add(new w(0,.2,0)),"A:B "+t.toFixed(2),.03),Ct.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const e=30,t=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const i=this.gameObject,n=this._followObject;n.updateMatrix(),n.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const d=this._followObject.worldPosition,f=this.settings.snapGridResolution;d.x=Math.round(d.x/f)*f,d.y=Math.round(d.y/f)*f,d.z=Math.round(d.z/f)*f,this._followObject.worldPosition=d,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const a=et.clamp01(this.context.time.deltaTime*e*t),l=i.worldPosition;l.lerp(n.worldPosition,a),i.worldPosition=l;const c=i.worldQuaternion;c.slerp(n.worldQuaternion,a),i.worldQuaternion=c;const u=i.worldScale;u.lerp(n.worldScale,a),i.worldScale=u}setTargetObject(e){this.gameObject=e}}class jre{constructor(e,t){h(this,"context");h(this,"gameObject");h(this,"settings");h(this,"_lastRig");h(this,"_followObject");h(this,"_totalMovement",new w);h(this,"_totalMovementAlongRayDirection",0);h(this,"_grabStartDistance",0);h(this,"_deviceMode");h(this,"_followObjectStartPosition",new w);h(this,"_followObjectStartQuaternion",new Ce);h(this,"_followObjectStartWorldQuaternion",new Ce);h(this,"_lastDragPosRigSpace");h(this,"_tempVec",new w);h(this,"_tempMat",new we);h(this,"_hitPointInLocalSpace",new w);h(this,"_hitNormalInLocalSpace",new w);h(this,"_bottomCenter",new w);h(this,"_backCenter",new w);h(this,"_backBottomCenter",new w);h(this,"_bounds",new xi);h(this,"_dragPlane",new Ar(new w(0,1,0)));h(this,"_draggedOverObject",null);h(this,"_draggedOverObjectLastSetUp",null);h(this,"_draggedOverObjectLastNormal",new w);h(this,"_draggedOverObjectDuration",0);this.settings=e,this.context=e.context,this.gameObject=t,this._followObject=new ge}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(e){this.gameObject=e}recenter(){var r,o;if(!this._followObject.parent){console.warn("Error: space follow object doesn't have parent but recenter() is called. This is likely a bug");return}const e=this._followObject.parent;this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.position.set(0,0,0),this._followObject.quaternion.set(0,0,0,1),this._followObject.scale.set(1,1,1),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0),e.attach(this._followObject),this._followObjectStartPosition.copy(this._followObject.position),this._followObjectStartQuaternion.copy(this._followObject.quaternion),this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const t=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(t),this._grabStartDistance=t.distanceTo(e.worldPosition);const i=(o=(r=bt.active)==null?void 0:r.rig)==null?void 0:o.gameObject,n=(i==null?void 0:i.worldScale.x)||1;this._grabStartDistance/=n,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,cl&&(Ct.DrawLine(t,e.worldPosition,65280,.5,!1),Ct.DrawLabel(e.worldPosition.add(new w(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(e){if(e.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,e.point&&e.normal)this._hitPointInLocalSpace.copy(e.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(e.normal);else if(e){const A=e.event.space,v=A.worldPosition;this.gameObject.worldToLocal(v),this._hitPointInLocalSpace.copy(v);const g=A.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),g.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(g)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=e.mode;const i=this._followObject.parent.worldForward,r=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),r){case 0:const A=new w(0,1,0);this.gameObject.parent&&A.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(A,o);break;case 2:const v=this._hitNormalInLocalSpace.clone();v.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(v,o);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(i,o);break;case 3:const g=new w(0,1,0),_=i,y=g.angleTo(_),b=.5;y>Math.PI/2+b||y<Math.PI/2-b?this._dragPlane.setFromNormalAndCoplanarPoint(new w(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(i,o);break}const a=new xi,l=this.gameObject.parent,c=this.gameObject.position.clone(),u=this.gameObject.quaternion.clone(),d=this.gameObject.scale.clone(),f=this.gameObject.matrixWorld.clone();l&&l.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1),a.setFromObject(this.gameObject);const p=new w;a.getCenter(p);const m=new w;a.getSize(m),this._bottomCenter.copy(p.clone().add(new w(0,-m.y/2,0))),this._backCenter.copy(p.clone().add(new w(0,0,m.z/2))),this._backBottomCenter.copy(p.clone().add(new w(0,-m.y/2,m.z/2))),this._bounds.copy(a),l&&l.add(this.gameObject),this.gameObject.position.copy(c),this.gameObject.quaternion.copy(u),this.gameObject.scale.copy(d),this.gameObject.matrixWorld.copy(f),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var r,o;if(!this._followObject.parent)return;const e=this._followObject.parent;this._followObject.updateMatrix();const t=e.worldPosition,i=(o=(r=bt.active)==null?void 0:r.rig)==null?void 0:o.gameObject;i&&i.worldToLocal(t),(this._lastDragPosRigSpace===void 0||i!=this._lastRig)&&(this._lastDragPosRigSpace=t.clone(),this._lastRig=i),this._tempVec.copy(t).sub(this._lastDragPosRigSpace);const n=e.worldForward;if(i&&(this._tempMat.copy(i.matrixWorld).invert(),n.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=n.dot(this._tempVec),this._tempVec.x=Math.abs(this._tempVec.x),this._tempVec.y=Math.abs(this._tempVec.y),this._tempVec.z=Math.abs(this._tempVec.z),this._totalMovement.add(this._tempVec),this._lastDragPosRigSpace.copy(t),cl){let a=t;i&&(a=a.clone(),a.transformDirection(i.matrixWorld)),Ct.DrawRay(a,n,255)}}onDragUpdate(e){if(e>1)return;const t=this.gameObject,i=this._followObject.parent;this._followObject.updateMatrix();const n=i.worldPosition,r=i.worldForward,o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",a=o?this.settings.xrKeepRotation:this.settings.keepRotation,l=o?this.settings.xrDragMode:this.settings.dragMode;if(l===5)return;const c=10;a&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let u=1,d=1;if(o&&this._grabStartDistance>.5){const v=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);u=Math.max(0,v),u=u*u*u}else this._grabStartDistance<=.5&&(d=3);this._followObject.position.copy(this._followObjectStartPosition),a||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(u),this._followObject.updateMatrix();const f=new Qr(n,r);if(l==4){const v=new Xo;v.ignore=[t];const g=this.context.physics.raycastFromRay(f,v);if(g.length>0){const _=g[0];if(this._draggedOverObject===_.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=_.object,this._draggedOverObjectDuration=0),_.face&&this._draggedOverObjectDuration>.15&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(_.face.normal)<.999999)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(_.face.normal);const y=new w,b=new w;this._bounds.getCenter(y),this._bounds.getSize(b),y.sub(b.multiplyScalar(.5).multiply(_.face.normal)),this._hitPointInLocalSpace.copy(y),this._hitNormalInLocalSpace.copy(_.face.normal),this._bounds.getCenter(y),this._bounds.getSize(b),y.add(b.multiplyScalar(.5).multiply(_.face.normal));const C=this._hitPointInLocalSpace.clone().add(y);this._followObject.localToWorld(C);const M=this._followObject.worldPosition.sub(C);this._dragPlane.setFromNormalAndCoplanarPoint(_.face.normal,_.point.sub(M))}}}if(l!==1&&f.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const v=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(v),cl&&Ct.DrawLine(v,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(v),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const v=this._followObject.worldPosition,g=this.settings.snapGridResolution;v.x=Math.round(v.x/g)*g,v.y=Math.round(v.y/g)*g,v.z=Math.round(v.z/g)*g,this._followObject.worldPosition=v,this._followObject.updateMatrix()}a&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const p=et.clamp01(this.context.time.deltaTime*c*d),m=t.worldPosition;m.lerp(this._followObject.worldPosition,p),t.worldPosition=m;const A=t.worldQuaternion;if(A.slerp(this._followObject.worldQuaternion,p),t.worldQuaternion=A,cl){const v=this._hitPointInLocalSpace.clone();t.localToWorld(v),Ct.DrawSphere(v,.02,16711680);const g=this._hitNormalInLocalSpace.clone();g.applyQuaternion(A),Ct.DrawRay(v,g,16711680),Ct.DrawLabel(m.add(new w(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6296
6301
|
|