@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+=r(o);const l=Object.keys(s);let c="";for(let u=0;u<l.length;u++){const d=l[u],p=s[d];if(cg.has(p)){c+="";continue}cg.set(p,!0),c+=d+":"+n(p,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=r(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
4343
|
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const AY=ee("nodevlogs");function $i(i,e=qs.Log){Oa(e,i)}function Qi(i){$i(i,qs.Warn)}function bE(i){$i(i,qs.Error)}let _E;function pt(){return AY?!1:_E!==void 0?_E:Bs()}function yY(i){_E=i}const Eu=new Au,Hr=new S,Vc=new S,Hi=new Me,Gk={X:new S(1,0,0),Y:new S(0,1,0),Z:new S(0,0,1)},xE={type:"change"},Qk={type:"mouseDown"},Hk={type:"mouseUp",mode:null},Vk={type:"objectChange"};class bY 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 n=new SE;this._gizmo=n,this.add(n);const r=new EY;this._plane=r,this.add(r);const s=this;function o(y,b){let _=b;Object.defineProperty(s,y,{get:function(){return _!==void 0?_:b},set:function(E){_!==E&&(_=E,r[y]=E,n[y]=E,s.dispatchEvent({type:y+"-changed",value:E}),s.dispatchEvent(xE))}}),s[y]=b,r[y]=b,n[y]=b}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 S,l=new S,c=new Me,u=new Me,d=new S,p=new Me,f=new S,m=new S,A=new S,v=0,g=new S;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new S,this._startNorm=new S,this._endNorm=new S,this._cameraScale=new S,this._parentPosition=new S,this._parentQuaternion=new Me,this._parentQuaternionInv=new Me,this._parentScale=new S,this._worldScaleStart=new S,this._worldQuaternionInv=new Me,this._worldScale=new S,this._positionStart=new S,this._quaternionStart=new Me,this._scaleStart=new S,this._getPointer=_Y.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&&Eu.setFromCamera(e,this.camera);const t=wE(this._gizmo.picker[this.mode],Eu);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&&Eu.setFromCamera(e,this.camera);const t=wE(this._plane,Eu,!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,Qk.mode=this.mode,this.dispatchEvent(Qk)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let s=this.space;if(n==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Eu.setFromCamera(e,this.camera);const o=wE(this._plane,Eu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="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),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(r.position.applyQuaternion(Hi.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),s==="world"&&(r.parent&&r.position.add(Hr.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Hr.setFromMatrixPosition(r.parent.matrixWorld))));else if(n==="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 Hr.copy(this.pointStart),Vc.copy(this.pointEnd),Hr.applyQuaternion(this._worldQuaternionInv),Vc.applyQuaternion(this._worldQuaternionInv),Vc.divide(Hr),t.search("X")===-1&&(Vc.x=1),t.search("Y")===-1&&(Vc.y=1),t.search("Z")===-1&&(Vc.z=1);r.scale.copy(this._scaleStart).multiply(Vc),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Hr.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Hr.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Gk[t]),Hr.copy(Gk[t]),s==="local"&&Hr.applyQuaternion(this.worldQuaternion),Hr.cross(this.eye),Hr.length()===0?l=!0:this.rotationAngle=this._offset.dot(Hr.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),s==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(Hi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(Hi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(xE),this.dispatchEvent(Vk)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Hk.mode=this.mode,this.dispatchEvent(Hk)),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(xE),this.dispatchEvent(Vk),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Eu}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 _Y(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function xY(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function wY(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function SY(i){this.enabled&&this.pointerMove(this._getPointer(i))}function CY(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function wE(i,e,t){const n=e.intersectObject(i,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const pb=new Fi,Mi=new S(0,1,0),Wk=new S(0,0,0),qk=new Ce,fb=new Me,mb=new Me,La=new S,Xk=new Ce,hg=new S(1,0,0),Mu=new S(0,1,0),ug=new S(0,0,1),gb=new S,dg=new S,pg=new S;class SE extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new oi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new vn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const s=e.clone();s.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 p=e.clone();p.color.setHex(16776960),p.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new Cn(0,.04,.1,12);m.translate(0,.05,0);const A=new Di(.08,.08,.08);A.translate(0,.04,0);const v=new ut;v.setAttribute("position",new ot([0,0,0,1,0,0],3));const g=new Cn(.0075,.0075,.5,3);g.translate(0,.25,0);function y(k,W){const U=new yc(k,.0075,3,64,W*Math.PI*2);return U.rotateY(Math.PI/2),U.rotateX(Math.PI/2),U}function b(){const k=new ut;return k.setAttribute("position",new ot([0,0,0,1,1,1],3)),k}const _={X:[[new ue(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new ue(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new ue(g,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ue(m,o),[0,.5,0]],[new ue(m,o),[0,-.5,0],[Math.PI,0,0]],[new ue(g,o)]],Z:[[new ue(m,a),[0,0,.5],[Math.PI/2,0,0]],[new ue(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new ue(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new ue(new Ac(.1,0),d.clone()),[0,0,0]]],XY:[[new ue(new Di(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new ue(new Di(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Di(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new ue(new Cn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Cn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Cn(.2,0,.6,4),n),[0,.3,0]],[new ue(new Cn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Cn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Cn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Ac(.2,0),n)]],XY:[[new ue(new Di(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new ue(new Di(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Di(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new ue(new Ac(.01,2),r),null,null,null,"helper"]],END:[[new ue(new Ac(.01,2),r),null,null,null,"helper"]],DELTA:[[new An(b(),r),null,null,null,"helper"]],X:[[new An(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new An(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new An(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},T={XYZE:[[new ue(y(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new ue(y(.5,.5),s)]],Y:[[new ue(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new ue(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new ue(y(.75,1),p),null,[0,Math.PI/2,0]]]},M={AXIS:[[new An(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},D={XYZE:[[new ue(new wa(.25,10,8),n)]],X:[[new ue(new yc(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ue(new yc(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ue(new yc(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ue(new yc(.75,.1,2,24),n)]]},C={X:[[new ue(A,s),[.5,0,0],[0,0,-Math.PI/2]],[new ue(g,s),[0,0,0],[0,0,-Math.PI/2]],[new ue(A,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ue(A,o),[0,.5,0]],[new ue(g,o)],[new ue(A,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ue(A,a),[0,0,.5],[Math.PI/2,0,0]],[new ue(g,a),[0,0,0],[Math.PI/2,0,0]],[new ue(A,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ue(new Di(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new ue(new Di(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Di(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Di(.1,.1,.1),d.clone())]]},P={X:[[new ue(new Cn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Cn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Cn(.2,0,.6,4),n),[0,.3,0]],[new ue(new Cn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Cn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Cn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ue(new Di(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new ue(new Di(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Di(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Di(.2,.2,.2),n),[0,0,0]]]},G={X:[[new An(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new An(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new An(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Q(k){const W=new ge;for(const U in k)for(let F=k[U].length;F--;){const z=k[U][F][0].clone(),Z=k[U][F][1],K=k[U][F][2],se=k[U][F][3],Ae=k[U][F][4];z.name=U,z.tag=Ae,Z&&z.position.set(Z[0],Z[1],Z[2]),K&&z.rotation.set(K[0],K[1],K[2]),se&&z.scale.set(se[0],se[1],se[2]),z.updateMatrix();const Re=z.geometry.clone();Re.applyMatrix4(z.matrix),z.geometry=Re,z.renderOrder=1/0,z.position.set(0,0,0),z.rotation.set(0,0,0),z.scale.set(1,1,1),W.add(z)}return W}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Q(_)),this.add(this.gizmo.rotate=Q(T)),this.add(this.gizmo.scale=Q(C)),this.add(this.picker.translate=Q(E)),this.add(this.picker.rotate=Q(D)),this.add(this.picker.scale=Q(P)),this.add(this.helper.translate=Q(I)),this.add(this.helper.rotate=Q(M)),this.add(this.helper.scale=Q(G)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:mb;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 s=n[r];s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(o*this.size/4),s.tag==="helper"){s.visible=!1,s.name==="AXIS"?(s.visible=!!this.axis,this.axis==="X"&&(Hi.setFromEuler(pb.set(0,0,0)),s.quaternion.copy(t).multiply(Hi),Math.abs(Mi.copy(hg).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Y"&&(Hi.setFromEuler(pb.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(Hi),Math.abs(Mi.copy(Mu).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Z"&&(Hi.setFromEuler(pb.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(Hi),Math.abs(Mi.copy(ug).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="XYZE"&&(Hi.setFromEuler(pb.set(0,Math.PI/2,0)),Mi.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(qk.lookAt(Wk,Mi,Mu)),s.quaternion.multiply(Hi),s.visible=this.dragging),this.axis==="E"&&(s.visible=!1)):s.name==="START"?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):s.name==="END"?(s.position.copy(this.worldPosition),s.visible=this.dragging):s.name==="DELTA"?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),Hr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Hr.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(Hr),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=this.axis.search(s.name)!==-1));continue}s.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(s.name==="X"&&Math.abs(Mi.copy(hg).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Y"&&Math.abs(Mi.copy(Mu).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Z"&&Math.abs(Mi.copy(ug).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XY"&&Math.abs(Mi.copy(ug).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="YZ"&&Math.abs(Mi.copy(hg).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XZ"&&Math.abs(Mi.copy(Mu).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):this.mode==="rotate"&&(fb.copy(t),Mi.copy(this.eye).applyQuaternion(Hi.copy(t).invert()),s.name.search("E")!==-1&&s.quaternion.setFromRotationMatrix(qk.lookAt(this.eye,Wk,Mu)),s.name==="X"&&(Hi.setFromAxisAngle(hg,Math.atan2(-Mi.y,Mi.z)),Hi.multiplyQuaternions(fb,Hi),s.quaternion.copy(Hi)),s.name==="Y"&&(Hi.setFromAxisAngle(Mu,Math.atan2(Mi.x,Mi.z)),Hi.multiplyQuaternions(fb,Hi),s.quaternion.copy(Hi)),s.name==="Z"&&(Hi.setFromAxisAngle(ug,Math.atan2(Mi.y,Mi.x)),Hi.multiplyQuaternions(fb,Hi),s.quaternion.copy(Hi))),s.visible=s.visible&&(s.name.indexOf("X")===-1||this.showX),s.visible=s.visible&&(s.name.indexOf("Y")===-1||this.showY),s.visible=s.visible&&(s.name.indexOf("Z")===-1||this.showZ),s.visible=s.visible&&(s.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some(function(a){return s.name===a}))&&(s.material.color.setHex(16776960),s.material.opacity=1)}super.updateMatrixWorld(e)}}class EY extends ue{constructor(){super(new Un(1e5,1e5,2,2),new oi({visible:!1,wireframe:!0,side:hi,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"),gb.copy(hg).applyQuaternion(t==="local"?this.worldQuaternion:mb),dg.copy(Mu).applyQuaternion(t==="local"?this.worldQuaternion:mb),pg.copy(ug).applyQuaternion(t==="local"?this.worldQuaternion:mb),Mi.copy(dg),this.mode){case"translate":case"scale":switch(this.axis){case"X":Mi.copy(this.eye).cross(gb),La.copy(gb).cross(Mi);break;case"Y":Mi.copy(this.eye).cross(dg),La.copy(dg).cross(Mi);break;case"Z":Mi.copy(this.eye).cross(pg),La.copy(pg).cross(Mi);break;case"XY":La.copy(pg);break;case"YZ":La.copy(gb);break;case"XZ":Mi.copy(pg),La.copy(dg);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):(Xk.lookAt(Hr.set(0,0,0),La,Mi),this.quaternion.setFromRotationMatrix(Xk)),super.updateMatrixWorld(e)}}const MY=ee("debugpatch");function vb(i,e,t,n){const r=MY===e;if(!t&&!n)return;const s=e+"___needle";IY(i,e,t,n);const o=Object.getOwnPropertyDescriptor(i,e),a=i[e];r&&console.log("Patch",i.constructor.name,e,o,a),o?(r&&console.log("Apply patch with existing descriptor",i.constructor.name,e,o),typeof o.value=="function"&&(i[e]=Jk(o.value,i,e))):(r&&console.log("Create patch with new property",i.constructor.name,e,o),Object.defineProperty(i,e,{set:function(l){if(typeof l=="function")this[s]=Jk(l,i,e);else{const c=this[s];Kk(i,e,this,c,l),this[s]=l,Zk(i,e,this,c,l)}},get:function(){const l=this[s];return typeof l=="function"&&l[s]?l[s]:l}}))}function TY(i,e,t){const n=EE(i,e);if(n)for(let r=n.length-1;r>=0;r--){const s=n[r];s.prefix===t&&(s.prefix=null),s.postfix===t&&(s.postfix=null),!s.prefix&&!s.postfix&&n.splice(r,1)}}const Yk=Symbol("Needle:Patches:WrappedFunction");function Jk(i,e,t){if(i[Yk])return i;const n=function(...r){Kk(e,t,this,...r);const s=i.apply(this,r);return Zk(e,t,this,s,...r),s};return n[Yk]=!0,n}const Ab="Needle:Patches";function CE(){return globalThis[Ab]||(globalThis[Ab]=new WeakMap),globalThis[Ab]}function EE(i,e){const t=CE().get(i);return t?t.get(e):null}function IY(i,e,t,n){let r=CE().get(i);r||(r=new Map,CE().set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push({prefix:t,postfix:n})}function Kk(i,e,t,...n){var r;if(!t)return;const s=EE(i,e);if(s)for(const o of s)(r=o.prefix)==null||r.call(t,...n)}function Zk(i,e,t,n,...r){var s;if(!t)return;const o=EE(i,e);if(o)for(const a of o)(s=a.postfix)==null||s.call(t,n,...r)}const $k=Symbol("gltf-loader-internal-usage-tracker"),RY=ee("debugusers"),yb=class{constructor(i){h(this,"parser"),h(this,"_getDependency"),h(this,"_loadingId"),h(this,"_loadedObjects",new Set),this.parser=i,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(i){return yb._loadingProcesses>0}beforeRoot(){yb._loadingProcesses++;const i=this,e=this._getDependency;return this.parser.getDependency=function(t,n){const r=e.call(this,t,n);return r.then(s=>(s&&(i._loadedObjects.add(s),s[$k]=i._loadingId),s)),r},null}afterRoot(i){yb._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[$k],e instanceof ge&&(e.parent||e instanceof ue&&setTimeout(()=>{RY&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null},1e3));return null}};let ME=yb;h(ME,"_loadingProcesses",0);class eL{constructor(){window.addEventListener("unhandledrejection",e=>{var t;if(e.defaultPrevented)return;const n=(t=e?.reason)==null?void 0:t.path;if(n){const r=n[0];r&&r.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4344
|
-
`+r.src),e.preventDefault())}})}}const bb=ee("trackresources");function tL(){return bb==="dispose"}let Tu=!0;bb===0&&(Tu=!1);function PY(i){Tu=i}function iL(){return Tu}const nL=Symbol("disposable");function TE(i,e){i&&(i[nL]=e,Iu&&console.warn("Set disposable",e,i))}const rL=Symbol("disposed");function BY(i){return i[rL]===!0}function Ii(i){var e;if(i){if(i[nL]===!1){Iu&&console.warn("Object is marked as not disposable",i);return}if(i[rL]=!0,i instanceof jr)Ii(i.environment),Ii(i.background),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial);else if(i instanceof Hs)Ii(i.geometry),Ii(i.material),Ii(i.skeleton),Ii(i.bindMatrix),Ii(i.bindMatrixInverse),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof ue)Ii(i.geometry),Ii(i.material),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof ut){Tp(i);for(const t of Object.keys(i.attributes)){const n=i.attributes[t];Ii(n)}}else if(i instanceof $e||i instanceof Cs)Iu&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const t of i)t instanceof It&&Ii(t);else if(i instanceof It){Tp(i);for(const n of Object.keys(i)){const r=i[n];r instanceof mt&&(Ii(r),i[n]=null)}const t=i.uniforms;if(t)for(const n of Object.keys(t)){const r=t[n];r instanceof mt?(Ii(r),t[n]=null):r instanceof be&&(Ii(r.value),r.value=null)}}else i instanceof mt?(Tp(i),Tp(i.source),((e=i.source)==null?void 0:e.data)instanceof ImageBitmap&&Tp(i.source.data)):i instanceof tm?(Tp(i.boneTexture),i.boneTexture=null):i instanceof Lm||!(i instanceof ge)&&Iu&&console.warn("Unknown object type",i)}}function Tp(i){i&&((Iu||tL()||bb)&&console.warn("\u{1F9E8} FREE",i),i instanceof ImageBitmap?i.close():i instanceof wl?i.data=null:i.dispose())}function sL(i){(i instanceof ue||i instanceof Hs)&&(i.material=null,i.geometry=null)}const DY=new Set;function _b(i,e,t=null,n){if(n||(n=DY,n.clear()),!i)return n;const r=i[fg];if(r)for(const s of r)n.has(s)||t?.call(null,s)!==!1&&(n.add(s),e&&_b(s,!0,t,n));return n}function OY(i){return i[mg]}const Iu=ee("debugresourceusers")||ee("debugmemory"),fg=Symbol("needle-resource-users"),mg=Symbol("needle-resource-users-count");function hs(i,e){vb(i,e,function(t,n){Tu&&(xb(fg,this,t,!1),xb(fg,this,n,!0))})}Tu&&(hs(ue.prototype,"material"),hs(ue.prototype,"geometry"),hs(It.prototype,"map"),hs(It.prototype,"bumpMap"),hs(It.prototype,"alphaMap"),hs(It.prototype,"normalMap"),hs(It.prototype,"displacementMap"),hs(It.prototype,"roughnessMap"),hs(It.prototype,"metalnessMap"),hs(It.prototype,"emissiveMap"),hs(It.prototype,"specularMap"),hs(It.prototype,"envMap"),hs(It.prototype,"lightMap"),hs(It.prototype,"aoMap"),hs(It.prototype,"gradientMap"));function kY(i){if(Tu===!1)return;const e=i[fg];if(e)for(const t of e)xb(fg,t,i,!1)}Tu&&vb(It.prototype,"dispose",function(){kY(this)});let IE=0;function xb(i,e,t,n){if(IE>0)return;if(Array.isArray(t)){for(const s of t)xb(i,e,s,n);return}if(!t)return;let r=t[i];if(r||(r=new Set),n){if(e&&!r.has(e)){r.add(e);let s=t[mg]||0;s+=1,t[mg]=s,Iu&&console.warn(`\u{1F7E2} Added user of "${t.type}"`,e,t,s,"users:",r)}}else if(e&&r.has(e)){r.delete(e);let s=t[mg]||0;s>0&&(s-=1,t[mg]=s),Iu&&console.warn(`\u{1F534} Removed user of "${t.type}"`,e,t,s,"users:",r),s<=0&&(ME.isLoading(t)||(bb&&console.warn(`\u{1F534} Removed all user of "${t.type}"`,t),tL()&&Ii(t)))}t[i]=r}try{vb(Pl.prototype,"render",function(){IE++},function(){IE--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var gg=(i=>(i.Added="component-added",i.Removing="removing-component",i))(gg||{});const oL=ee("debugcomponentevents");class vg{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let n=this.eventListeners.get(e);n||(n=[]),n.push(t),this.eventListeners.set(e,n),oL&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const n=this.eventListeners.get(e);if(!n)return;const r=n.indexOf(t);r<0||n.splice(r,1)}static dispatchComponentLifecycleEvent(e,t){const n=this.eventListeners.get(e);if(oL&&console.log("Dispatching event "+e,n),!!n)for(const r of n)r(t)}}h(vg,"eventListeners",new Map);const aL=ee("debugdefines");Ip('if(!globalThis[""3.36.3-beta""]) globalThis[""3.36.3-beta""] = "0.0.0";'),Ip('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Ip('if(!globalThis[""Thu Apr 04 2024
|
|
4344
|
+
`+r.src),e.preventDefault())}})}}const bb=ee("trackresources");function tL(){return bb==="dispose"}let Tu=!0;bb===0&&(Tu=!1);function PY(i){Tu=i}function iL(){return Tu}const nL=Symbol("disposable");function TE(i,e){i&&(i[nL]=e,Iu&&console.warn("Set disposable",e,i))}const rL=Symbol("disposed");function BY(i){return i[rL]===!0}function Ii(i){var e;if(i){if(i[nL]===!1){Iu&&console.warn("Object is marked as not disposable",i);return}if(i[rL]=!0,i instanceof jr)Ii(i.environment),Ii(i.background),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial);else if(i instanceof Hs)Ii(i.geometry),Ii(i.material),Ii(i.skeleton),Ii(i.bindMatrix),Ii(i.bindMatrixInverse),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof ue)Ii(i.geometry),Ii(i.material),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof ut){Tp(i);for(const t of Object.keys(i.attributes)){const n=i.attributes[t];Ii(n)}}else if(i instanceof $e||i instanceof Cs)Iu&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const t of i)t instanceof It&&Ii(t);else if(i instanceof It){Tp(i);for(const n of Object.keys(i)){const r=i[n];r instanceof mt&&(Ii(r),i[n]=null)}const t=i.uniforms;if(t)for(const n of Object.keys(t)){const r=t[n];r instanceof mt?(Ii(r),t[n]=null):r instanceof be&&(Ii(r.value),r.value=null)}}else i instanceof mt?(Tp(i),Tp(i.source),((e=i.source)==null?void 0:e.data)instanceof ImageBitmap&&Tp(i.source.data)):i instanceof tm?(Tp(i.boneTexture),i.boneTexture=null):i instanceof Lm||!(i instanceof ge)&&Iu&&console.warn("Unknown object type",i)}}function Tp(i){i&&((Iu||tL()||bb)&&console.warn("\u{1F9E8} FREE",i),i instanceof ImageBitmap?i.close():i instanceof wl?i.data=null:i.dispose())}function sL(i){(i instanceof ue||i instanceof Hs)&&(i.material=null,i.geometry=null)}const DY=new Set;function _b(i,e,t=null,n){if(n||(n=DY,n.clear()),!i)return n;const r=i[fg];if(r)for(const s of r)n.has(s)||t?.call(null,s)!==!1&&(n.add(s),e&&_b(s,!0,t,n));return n}function OY(i){return i[mg]}const Iu=ee("debugresourceusers")||ee("debugmemory"),fg=Symbol("needle-resource-users"),mg=Symbol("needle-resource-users-count");function hs(i,e){vb(i,e,function(t,n){Tu&&(xb(fg,this,t,!1),xb(fg,this,n,!0))})}Tu&&(hs(ue.prototype,"material"),hs(ue.prototype,"geometry"),hs(It.prototype,"map"),hs(It.prototype,"bumpMap"),hs(It.prototype,"alphaMap"),hs(It.prototype,"normalMap"),hs(It.prototype,"displacementMap"),hs(It.prototype,"roughnessMap"),hs(It.prototype,"metalnessMap"),hs(It.prototype,"emissiveMap"),hs(It.prototype,"specularMap"),hs(It.prototype,"envMap"),hs(It.prototype,"lightMap"),hs(It.prototype,"aoMap"),hs(It.prototype,"gradientMap"));function kY(i){if(Tu===!1)return;const e=i[fg];if(e)for(const t of e)xb(fg,t,i,!1)}Tu&&vb(It.prototype,"dispose",function(){kY(this)});let IE=0;function xb(i,e,t,n){if(IE>0)return;if(Array.isArray(t)){for(const s of t)xb(i,e,s,n);return}if(!t)return;let r=t[i];if(r||(r=new Set),n){if(e&&!r.has(e)){r.add(e);let s=t[mg]||0;s+=1,t[mg]=s,Iu&&console.warn(`\u{1F7E2} Added user of "${t.type}"`,e,t,s,"users:",r)}}else if(e&&r.has(e)){r.delete(e);let s=t[mg]||0;s>0&&(s-=1,t[mg]=s),Iu&&console.warn(`\u{1F534} Removed user of "${t.type}"`,e,t,s,"users:",r),s<=0&&(ME.isLoading(t)||(bb&&console.warn(`\u{1F534} Removed all user of "${t.type}"`,t),tL()&&Ii(t)))}t[i]=r}try{vb(Pl.prototype,"render",function(){IE++},function(){IE--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var gg=(i=>(i.Added="component-added",i.Removing="removing-component",i))(gg||{});const oL=ee("debugcomponentevents");class vg{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let n=this.eventListeners.get(e);n||(n=[]),n.push(t),this.eventListeners.set(e,n),oL&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const n=this.eventListeners.get(e);if(!n)return;const r=n.indexOf(t);r<0||n.splice(r,1)}static dispatchComponentLifecycleEvent(e,t){const n=this.eventListeners.get(e);if(oL&&console.log("Dispatching event "+e,n),!!n)for(const r of n)r(t)}}h(vg,"eventListeners",new Map);const aL=ee("debugdefines");Ip('if(!globalThis[""3.36.3-beta.1""]) globalThis[""3.36.3-beta.1""] = "0.0.0";'),Ip('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Ip('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";'),Ip('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.36.3-beta.1";'),Ip('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Ip('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)";');const Fl="3.36.3-beta.1",wb="undefined",RE="Thu Apr 04 2024 21:19:31 GMT+0200 (Central European Summer Time)";aL&&console.log(`Engine version: ${Fl} (generator: ${wb})
|
|
4345
4345
|
Project built at ${RE}`);const Nl="needle_isActiveInHierarchy",Ru="builtin_components",Ag="needle_editor_guid";function Ip(i){try{(0,eval)(i)}catch(e){aL&&console.error(e)}}const yg=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),lL=Symbol("isUsingInstancing"),cL=Symbol("instancingRenderer"),bg=Symbol("instancingAutoUpdateBounds");class qo{static isUsingInstancing(e){return e[lL]===!0}static getRenderer(e){return e[cL]||null}setAutoUpdateBounds(e,t){const n=qo.getRenderer(e);n&&(n[bg]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[yg]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const n of e.children)qo.markDirty(n,!0)}}function Pu(i,e){try{e?i(e):i()}catch(t){return console.error(t),!1}return!0}const PE=ee("debugnewscripts"),LY=ee("debughierarchy"),Vi=[];function UY(){return Vi.length>0}function Sb(i){if(!(i.new_scripts.length<=0)){if(PE&&console.log("Register new components",i.new_scripts.length,[...i.new_scripts],i.alias?"element: "+i.alias:i.hash,i),i.new_scripts_pre_setup_callbacks.length>0){for(const e of i.new_scripts_pre_setup_callbacks)e&&e();i.new_scripts_pre_setup_callbacks.length=0}Vi.length=0,i.new_scripts.length>0&&Vi.push(...i.new_scripts),i.new_scripts.length=0;for(let e=0;e<Vi.length;e++)try{const t=Vi[e];if(t.isComponent!==!0){(pt()||PE)&&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),Vi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Vi.splice(e,1),e--;continue}t.context=i,_g(t.gameObject),BE(t,i)}catch(t){console.error(t),zl(Vi[e],i),Vi.splice(e,1),e--}for(let e=0;e<Vi.length;e++)try{const t=Vi[e];if(t.destroyed){zl(Vi[e],i),Vi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(n){console.error(n)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),_g(t.gameObject),t.activeAndEnabled&&Pu(t.__internalAwake.bind(t)))}catch(t){console.error(t),zl(Vi[e],i),Vi.splice(e,1),e--}for(let e=0;e<Vi.length;e++)try{const t=Vi[e];if(t.destroyed||t.enabled===!1||(_g(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,Pu(t.__internalEnable.bind(t)))}catch(t){console.error(t),zl(Vi[e],i),Vi.splice(e,1),e--}for(let e=0;e<Vi.length;e++)try{const t=Vi[e];if(t.destroyed||!t.gameObject)continue;i.new_script_start.push(t)}catch(t){console.error(t),zl(Vi[e],i),Vi.splice(e,1),e--}Vi.length=0;for(const e of i.new_scripts_post_setup_callbacks)e&&e();i.new_scripts_post_setup_callbacks.length=0}}function FY(i){i&&(i.__internalDisable(!0),zl(i,i.context))}function hL(i,e){for(let t=0;t<i.new_script_start.length;t++)try{const n=i.new_script_start[t];if(e!==void 0&&n.gameObject!==e||n.destroyed||n.activeAndEnabled===!1)continue;Pu(n.__internalAwake.bind(n)),n.enabled&&(Pu(n.__internalEnable.bind(n)),Pu(n.__internalStart.bind(n)),i.new_script_start.splice(t,1),t--)}catch(n){console.error(n),zl(i.new_script_start[t],i),i.new_script_start.splice(t,1),t--}}function BE(i,e){e.scripts.indexOf(i)===-1&&(e.scripts.push(i),i.earlyUpdate&&e.scripts_earlyUpdate.push(i),i.update&&e.scripts_update.push(i),i.lateUpdate&&e.scripts_lateUpdate.push(i),i.onBeforeRender&&e.scripts_onBeforeRender.push(i),i.onAfterRender&&e.scripts_onAfterRender.push(i),i.onPausedChanged&&e.scripts_pausedChanged.push(i),DE(i,null)&&e.new_scripts_xr.push(i),DE(i,"immersive-vr")&&e.scripts_immersive_vr.push(i),DE(i,"immersive-ar")&&e.scripts_immersive_ar.push(i))}function zl(i,e){Eo(i,e.new_scripts),Eo(i,e.new_script_start),Eo(i,e.scripts),Eo(i,e.scripts_earlyUpdate),Eo(i,e.scripts_update),Eo(i,e.scripts_lateUpdate),Eo(i,e.scripts_onBeforeRender),Eo(i,e.scripts_onAfterRender),Eo(i,e.scripts_pausedChanged),Eo(i,e.new_scripts_xr),Eo(i,e.scripts_immersive_vr),Eo(i,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(i)}function Eo(i,e){const t=e.indexOf(i);t>=0&&e.splice(t,1)}function DE(i,e){var t;if(i){const n=i;if(n.onBeforeXR||n.onEnterXR||n.onUpdateXR||n.onLeaveXR||n.onXRControllerAdded||n.onXRControllerRemoved)return!(e!=null&&((t=n.supportsXR)==null?void 0:t.call(n,e))===!1)}return!1}function Cb(i){if(i||(i=ii.Current.scene),!i){console.trace("Invalid call - no current context.");return}const e=Qp(i);uL(i,e,!0)||(PE||pt()?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 s=r.style.cssText,o=document.createElement("div");r.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=d_?.length>1?d_:"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!==r&&r.appendChild(o),r.style.cssText!==s&&(r.style.cssText=s),o.style.cssText!==a&&(o.style.cssText=a)},500),r}let t=e();const n=t.style.cssText;setInterval(()=>{var r;JM===!0&&(t.style.cssText!==n&&(t=e()),i.domElement.shadowRoot?t.parentNode!==i.domElement.shadowRoot&&((r=i.domElement.shadowRoot)==null||r.appendChild(t)):t.parentNode!=document.body&&document.body.appendChild(t))},500)}async function lee(i){try{if(zp()!==!0)return KM(i)}catch(e){return Ro&&console.log("License check failed",e),KM(i)}Ro&&KM(i)}async function KM(i){i.domElement.addEventListener("ready",()=>!0),await Nu?.catch(()=>{}),!zp()&&cee()}let cF=0;async function cee(i){const e=Date.now();if(e-cF<2e3)return;cF=e;const t=`
|
|
5019
5024
|
position: relative;
|
|
5020
5025
|
display: block;
|
|
5021
5026
|
font-size: 18px;
|
|
@@ -5062,7 +5067,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
5062
5067
|
<div class="wrapper">
|
|
5063
5068
|
<img class="logo" src=${bee} />
|
|
5064
5069
|
</div>
|
|
5065
|
-
`,this._root.appendChild(e.content.cloneNode(!0)),this.wrapper=this._root.querySelector(".wrapper"),this._root.appendChild(this.wrapper),this.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),this.wrapper.setAttribute("title","Made with Needle Engine")}static get elementName(){return f_}static create(){return document.createElement(f_)}setLogoVisible(e){this.logoElement.style.display=e?"block":"none"}}customElements.get(f_)||customElements.define(f_,dF);const tT=ee("debugspatialmenu");class _ee{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 s;if(!this.enabled){(s=this.menu)==null||s.removeFromParent();return}tT&&yu()&&this.updateMenu();const o=this._context.xr;if(!(o!=null&&o.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 dE(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 r=(n=this.needleMenu.shadowRoot)==null?void 0:n.querySelector(".options");r?new MutationObserver(s=>{if(this.enabled&&!(this._context.isInXR==!1&&!tT))for(const o of s)o.type==="childList"&&(o.addedNodes.forEach(a=>{this.createButtonFromHTMLNode(a)}),o.removedNodes.forEach(a=>{const l=a,c=this.htmlButtonsMap.get(l);c&&(this.htmlButtonsMap.delete(l),c.remove(),Ei.update())}))}).observe(r,{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 e;const t=(e=this.needleMenu.shadowRoot)==null?void 0:e.querySelector(".options");t&&t.childNodes.forEach(n=>{this.createButtonFromHTMLNode(n)})}onExitXR(){var e;(e=this.menu)==null||e.removeFromParent()}createButtonFromHTMLNode(e){const t=this.getMenu(),n=this.htmlButtonsMap.get(e);if(n){n.add();return}const r=e,s=this.createButton(t,r);this.htmlButtonsMap.set(r,s),s.add()}updateMenu(){var e,t;const n=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(n);const r=this._context.mainCamera,s=this._context.xr,o=s?.rigScale||1;if(r){const a=r.worldPosition,l=r.worldForward.multiplyScalar(-1),c=l.y>.6,u=l.y>.4,d=n.visible?u:c,p=!n.visible&&d;n.visible=d||yu()&&tT,l.multiplyScalar(3*o),a.add(l),p&&(n.position.copy(this._menuTarget.position),n.position.y+=1,this._menuTarget.position.copy(n.position),this.positionFilter.reset(n.position),n.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const f=this._menuTarget.position.distanceTo(a);(p||f>1.5*o)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(a),this._context.scene.add(this._menuTarget),rg(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,n.position,this._context.time.time);const m=5;(e=this.menu)==null||e.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*m),(t=this.menu)==null||t.scale.setScalar(o)}this.uiisDirty&&(this.uiisDirty=!1,Ei.update())}ensureRenderOnTop(e,t=0){e instanceof ue&&(e.material.depthTest=!1,e.material.depthWrite=!1),e.renderOrder=1e3+t*2;for(const n of e.children)this.ensureRenderOnTop(n,t+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new Ei.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 Ye(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const e=q.get("ObjectRaycaster");return e&&nh(this.menu,new e),this.menu}handleNeedleWatermark(){var e;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new Ei.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 pF(this._context,()=>globalThis.open("https://needle.tools","_self"));nh(this._poweredByNeedleElement,t);const n=new Ei.Text({textContent:"Powered by",width:"auto",height:"auto"}),r=new Ei.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ye(0,0,0,.02)});this._poweredByNeedleElement.add(n),this._poweredByNeedleElement.add(r),(e=this.menu)==null||e.add(this._poweredByNeedleElement),this.markDirty(),new Ba().load("./include/needle/poweredbyneedle.webp",s=>{var o;t.allowModifyUI=!1,n.removeFromParent(),r.removeFromParent();const a=s.image.width/s.image.height;(o=this._poweredByNeedleElement)==null||o.set({backgroundImage:s,backgroundOpacity:1,width:.1*a,height:.1}),this.markDirty()})}if(this.menu){const t=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&da())t>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const n=this.menu.children.indexOf(this._poweredByNeedleElement);t!==n&&this.markDirty()}}}ensureFont(){let e=Ei.FontLibrary.getFontFamily(this.familyName);if(!e){e=Ei.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t?.addEventListener("ready",()=>{this.markDirty()})}}createButton(e,t){const n=new Ei.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}),r=new Ei.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});n.add(r),n["needle:use_eventsystem"]=!0;const s=new pF(this._context,()=>t.click());return nh(n,s),new xee(this,e,t,n,r)}}class xee{constructor(e,t,n,r,s){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=n,this.spatialContainer=r,this.spatialText=s,new MutationObserver(o=>{for(const a of o)a.type==="attributes"?a.attributeName==="style"&&this.updateVisible():a.type==="childList"&&this.updateText()}).observe(n,{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(n=>{n.nodeType===Node.TEXT_NODE?e+=n.textContent:n instanceof HTMLElement&&hF(n)&&n.textContent&&(t=n.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 t;if(!this.spatialIcon){const r=await ZM(e);if(r&&!this.spatialIcon){const s=new Ei.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:r,backgroundOpacity:1,margin:new Ye(0,.005,0,0)});this.spatialIcon=s,this.spatialContainer.add(s),this.menu.markDirty()}}if(e!=this._lastTexture){this._lastTexture=e;const r=await ZM(e);r&&((t=this.spatialIcon)==null||t.set({backgroundImage:r}),this.menu.markDirty())}const n=this.spatialContainer.children.indexOf(this.spatialIcon);n>0&&(this.spatialContainer.children.splice(n,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class pF{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}),Ei.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),Ei.update())}onPointerDown(e){e.use()}onPointerUp(e){e.use()}onPointerClick(e){e.use(),this.onclick()}}const Gp="needle-menu",m_=ee("debugmenu"),fF=ee("debugnoncommercial");let wee=class{constructor(i){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,n=t.type;if(n==="needle:menu"){const r=t.button;if(r){if(!r.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!r.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const s=document.createElement("button");if(s.textContent=r.label,r.icon){const o=Ys(r.icon);s.prepend(o)}r.priority&&s.setAttribute("priority",r.priority.toString()),s.onclick=()=>{if(r.onclick){const o=r.onclick.startsWith("http")||r.onclick.startsWith("www."),a=r.target||"_blank";o?globalThis.open(r.onclick,a):console.error("NeedleMenu: onclick is not a valid link",r.onclick)}},this._menu.appendChild(s)}else m_&&console.error("NeedleMenu: unknown postMessage event",t)}else m_&&console.warn("NeedleMenu: unknown postMessage type",n,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=Hw.getOrCreate(i.domElement),this._context=i,this._spatialMenu=new _ee(i,this._menu),window.addEventListener("message",this.onPostMessage),Nb(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(i){this._menu.setPosition(i)}showNeedleLogo(i){var e;this._menu.showNeedleLogo(i),(e=this._spatialMenu)==null||e.showNeedleLogo(i)}showSpatialMenu(i){this._spatialMenu.setEnabled(i)}showAudioPlaybackOption(i){var e;if(!i){(e=this._muteButton)==null||e.remove();return}this._muteButton=jp.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(i){var e;if(!i){(e=this._fullscreenButton)==null||e.remove();return}this._fullscreenButton=jp.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(i){this._menu.appendChild(i)}};class Hw extends HTMLElement{constructor(){var e,t,n,r;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",(u,d)=>{if(!this._domElement)return;const p=this._domElement.clientWidth;if(p<500){this.root.classList.add("compact");return}const f=20*2,m=p-f;if(!d&&Math.abs(m-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=m,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const g=v();g<0?this.root.classList.add("compact"):g>0&&(this.root.classList.remove("compact"),v()<0&&this.root.classList.add("compact"))},200);const A=()=>this.options.clientWidth+this.logoContainer.clientWidth,v=()=>m-A()});const s=document.createElement("template");s.innerHTML=`<style>
|
|
5070
|
+
`,this._root.appendChild(e.content.cloneNode(!0)),this.wrapper=this._root.querySelector(".wrapper"),this._root.appendChild(this.wrapper),this.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),this.wrapper.setAttribute("title","Made with Needle Engine")}static get elementName(){return f_}static create(){return document.createElement(f_)}setLogoVisible(e){this.logoElement.style.display=e?"block":"none"}}customElements.get(f_)||customElements.define(f_,dF);const tT=ee("debugspatialmenu");class _ee{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 s;if(!this.enabled){(s=this.menu)==null||s.removeFromParent();return}tT&&yu()&&this.updateMenu();const o=this._context.xr;if(!(o!=null&&o.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 dE(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 r=(n=this.needleMenu.shadowRoot)==null?void 0:n.querySelector(".options");r?new MutationObserver(s=>{if(this.enabled&&!(this._context.isInXR==!1&&!tT))for(const o of s)o.type==="childList"&&(o.addedNodes.forEach(a=>{this.createButtonFromHTMLNode(a)}),o.removedNodes.forEach(a=>{const l=a,c=this.htmlButtonsMap.get(l);c&&(this.htmlButtonsMap.delete(l),c.remove(),Ei.update())}))}).observe(r,{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 e;const t=(e=this.needleMenu.shadowRoot)==null?void 0:e.querySelector(".options");t&&t.childNodes.forEach(n=>{this.createButtonFromHTMLNode(n)})}onExitXR(){var e;(e=this.menu)==null||e.removeFromParent()}createButtonFromHTMLNode(e){const t=this.getMenu(),n=this.htmlButtonsMap.get(e);if(n){n.add();return}const r=e,s=this.createButton(t,r);this.htmlButtonsMap.set(r,s),s.add()}updateMenu(){var e,t;const n=this.getMenu();this.handleNeedleWatermark(),this._context.scene.add(n);const r=this._context.mainCamera,s=this._context.xr,o=s?.rigScale||1;if(r){const a=r.worldPosition,l=r.worldForward.multiplyScalar(-1),c=l.y>.6,u=l.y>.4,d=n.visible?u:c,p=!n.visible&&d;n.visible=d||yu()&&tT,l.multiplyScalar(3*o),a.add(l),p&&(n.position.copy(this._menuTarget.position),n.position.y+=1,this._menuTarget.position.copy(n.position),this.positionFilter.reset(n.position),n.quaternion.copy(this._menuTarget.quaternion),this.markDirty());const f=this._menuTarget.position.distanceTo(a);(p||f>1.5*o)&&(this.ensureRenderOnTop(this.menu),this._menuTarget.position.copy(a),this._context.scene.add(this._menuTarget),rg(this._menuTarget,this._context.mainCamera,!1,!0),this._menuTarget.removeFromParent()),this.positionFilter.filter(this._menuTarget.position,n.position,this._context.time.time);const m=5;(e=this.menu)==null||e.quaternion.slerp(this._menuTarget.quaternion,this._context.time.deltaTime*m),(t=this.menu)==null||t.scale.setScalar(o)}this.uiisDirty&&(this.uiisDirty=!1,Ei.update())}ensureRenderOnTop(e,t=0){e instanceof ue&&(e.material.depthTest=!1,e.material.depthWrite=!1),e.renderOrder=1e3+t*2;for(const n of e.children)this.ensureRenderOnTop(n,t+1)}getMenu(){if(this.menu)return this.menu;this.ensureFont(),this.menu=new Ei.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 Ye(0,.05,0,.05),borderColor:0,borderOpacity:.05,borderWidth:.005});const e=q.get("ObjectRaycaster");return e&&nh(this.menu,new e),this.menu}handleNeedleWatermark(){var e;if(!this._poweredByNeedleElement){this._poweredByNeedleElement=new Ei.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 pF(this._context,()=>globalThis.open("https://needle.tools","_self"));nh(this._poweredByNeedleElement,t);const n=new Ei.Text({textContent:"Powered by",width:"auto",height:"auto"}),r=new Ei.Text({textContent:"needle",width:"auto",height:"auto",fontSize:.07,margin:new Ye(0,0,0,.02)});this._poweredByNeedleElement.add(n),this._poweredByNeedleElement.add(r),(e=this.menu)==null||e.add(this._poweredByNeedleElement),this.markDirty(),new Ba().load("./include/needle/poweredbyneedle.webp",s=>{var o;t.allowModifyUI=!1,n.removeFromParent(),r.removeFromParent();const a=s.image.width/s.image.height;(o=this._poweredByNeedleElement)==null||o.set({backgroundImage:s,backgroundOpacity:1,width:.1*a,height:.1}),this.markDirty()})}if(this.menu){const t=this.menu.children.indexOf(this._poweredByNeedleElement);if(!this._showNeedleLogo&&da())t>=0&&(this._poweredByNeedleElement.removeFromParent(),this.markDirty());else{this._poweredByNeedleElement.visible=!0,this.menu.add(this._poweredByNeedleElement);const n=this.menu.children.indexOf(this._poweredByNeedleElement);t!==n&&this.markDirty()}}}ensureFont(){let e=Ei.FontLibrary.getFontFamily(this.familyName);if(!e){e=Ei.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t?.addEventListener("ready",()=>{this.markDirty()})}}createButton(e,t){const n=new Ei.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}),r=new Ei.Text({textContent:"",width:"auto",justifyContent:"center",alignItems:"center",backgroundOpacity:0,backgroundColor:16777215,fontFamily:this.familyName,color:0,borderRadius:.02,padding:.01});n.add(r),n["needle:use_eventsystem"]=!0;const s=new pF(this._context,()=>t.click());return nh(n,s),new xee(this,e,t,n,r)}}class xee{constructor(e,t,n,r,s){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=n,this.spatialContainer=r,this.spatialText=s,new MutationObserver(o=>{for(const a of o)a.type==="attributes"?a.attributeName==="style"&&this.updateVisible():a.type==="childList"&&this.updateText()}).observe(n,{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(n=>{n.nodeType===Node.TEXT_NODE?e+=n.textContent:n instanceof HTMLElement&&hF(n)&&n.textContent&&(t=n.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 t;if(!this.spatialIcon){const r=await ZM(e);if(r&&!this.spatialIcon){const s=new Ei.Block({width:.08,height:.08,backgroundColor:16777215,backgroundImage:r,backgroundOpacity:1,margin:new Ye(0,.005,0,0)});this.spatialIcon=s,this.spatialContainer.add(s),this.menu.markDirty()}}if(e!=this._lastTexture){this._lastTexture=e;const r=await ZM(e);r&&((t=this.spatialIcon)==null||t.set({backgroundImage:r}),this.menu.markDirty())}const n=this.spatialContainer.children.indexOf(this.spatialIcon);n>0&&(this.spatialContainer.children.splice(n,1),this.spatialContainer.children.unshift(this.spatialIcon),this.menu.markDirty())}}class pF{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}),Ei.update())}onPointerExit(){this.context.input.setCursorNormal(),this.allowModifyUI&&(this.element.set({backgroundOpacity:0}),Ei.update())}onPointerDown(e){e.use()}onPointerUp(e){e.use()}onPointerClick(e){e.use(),this.onclick()}}const Gp="needle-menu",m_=ee("debugmenu"),fF=ee("debugnoncommercial");let wee=class{constructor(i){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,n=t.type;if(n==="needle:menu"){const r=t.button;if(r){if(!r.label)return console.error("NeedleMenu: buttoninfo.label is required");if(!r.onclick)return console.error("NeedleMenu: buttoninfo.onclick is required");const s=document.createElement("button");if(s.textContent=r.label,r.icon){const o=Ys(r.icon);s.prepend(o)}r.priority&&s.setAttribute("priority",r.priority.toString()),s.onclick=()=>{if(r.onclick){const o=r.onclick.startsWith("http")||r.onclick.startsWith("www."),a=r.target||"_blank";o?globalThis.open(r.onclick,a):console.error("NeedleMenu: onclick is not a valid link",r.onclick)}},this._menu.appendChild(s)}else m_&&console.error("NeedleMenu: unknown postMessage event",t)}else m_&&console.warn("NeedleMenu: unknown postMessage type",n,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=Hw.getOrCreate(i.domElement,i),this._context=i,this._spatialMenu=new _ee(i,this._menu),window.addEventListener("message",this.onPostMessage),Nb(this.onStartXR)}onDestroy(){window.removeEventListener("message",this.onPostMessage),this._menu.remove(),this._spatialMenu.onDestroy()}setPosition(i){this._menu.setPosition(i)}showNeedleLogo(i){var e;this._menu.showNeedleLogo(i),(e=this._spatialMenu)==null||e.showNeedleLogo(i)}showSpatialMenu(i){this._spatialMenu.setEnabled(i)}showAudioPlaybackOption(i){var e;if(!i){(e=this._muteButton)==null||e.remove();return}this._muteButton=jp.getOrCreate().createMuteButton(this._context),this._muteButton.setAttribute("priority","100"),this._menu.appendChild(this._muteButton)}showFullscreenOption(i){var e;if(!i){(e=this._fullscreenButton)==null||e.remove();return}this._fullscreenButton=jp.getOrCreate().createFullscreenButton(this._context),this._fullscreenButton.setAttribute("priority","150"),this._menu.appendChild(this._fullscreenButton)}appendChild(i){this._menu.appendChild(i)}};class Hw extends HTMLElement{constructor(){var e,t,n,r;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",(d,p)=>{if(!this._domElement)return;const f=this._domElement.clientWidth;if(f<500){this.root.classList.add("compact");return}const m=20*2,A=f-m;if(!p&&Math.abs(A-this._lastAvailableWidthChange)<1)return;this._lastAvailableWidthChange=A,clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{const y=g();y<0?this.root.classList.add("compact"):y>0&&(this.root.classList.remove("compact"),g()<0&&this.root.classList.add("compact"))},200);const v=()=>this.options.clientWidth+this.logoContainer.clientWidth,g=()=>A-v()});const s=document.createElement("template");s.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 o=this.attachShadow({mode:"open"});uF(),eT("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()}}),eT("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:o});const a=s.content.cloneNode(!0);o?.appendChild(a),this.root=o.querySelector("#root"),this.wrapper=(e=this.root)==null?void 0:e.querySelector(".wrapper"),this.options=(t=this.root)==null?void 0:t.querySelector(".options"),this.logoContainer=(n=this.root)==null?void 0:n.querySelector(".logo"),(r=this.root)==null||r.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const l=dF.create();l.style.minHeight="1rem",this.logoContainer.append(l),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),ree(
|
|
5263
|
+
`;const o=this.attachShadow({mode:"open"});uF(),eT("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()}}),eT("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block",{element:o});const a=s.content.cloneNode(!0);o?.appendChild(a),this.root=o.querySelector("#root"),this.wrapper=(e=this.root)==null?void 0:e.querySelector(".wrapper"),this.options=(t=this.root)==null?void 0:t.querySelector(".options"),this.logoContainer=(n=this.root)==null?void 0:n.querySelector(".logo"),(r=this.root)==null||r.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const l=dF.create();l.style.minHeight="1rem",this.logoContainer.append(l),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),ree(d=>{d==!0&&da()&&!fF&&(this.logoContainer.style.display=this._userRequestedLogoVisible?"":"none")});let c=this._context;setTimeout(()=>c=this._context);let u=-1;new MutationObserver(d=>{var p;this.onChangeDetected(d);const f=this==null?void 0:this.parentNode;(this.style.display!="flex"||this.style.visibility!="visible"||this.style.opacity!="1"||f!=((p=this._domElement)==null?void 0:p.shadowRoot))&&(da()||(clearInterval(u),u=setInterval(()=>{var m,A,v;c!=null&&c.isInAR&&c.arOverlayElement?f!=c.arOverlayElement&&c.arOverlayElement.appendChild(this):f!=((m=this._domElement)==null?void 0:m.shadowRoot)&&((v=(A=this._domElement)==null?void 0:A.shadowRoot)==null||v.appendChild(this)),this.style.display="flex",this.style.visibility="visible",this.style.opacity="1"},5)))}).observe(this.root,{childList:!0,subtree:!0,attributes:!0}),m_&&this.___insertDebugOptions()}static create(){return document.createElement(Gp,{is:Gp})}static getOrCreate(e,t){let n=e.querySelector(Gp);return!n&&e.shadowRoot&&(n=e.shadowRoot.querySelector(Gp)),n||(n=Hw.create(),n._domElement=e,n._context=t,e.shadowRoot?e.shadowRoot.appendChild(n):e.appendChild(n)),n}connectedCallback(){var e;window.addEventListener("resize",this.handleSizeChange),(e=this._domElement)==null||e.addEventListener("resize",this.handleSizeChange),this.handleMenuVisible(),this._sizeChangeInterval=setInterval(()=>this.handleSizeChange(void 0,!0),5e3)}disconnectedCallback(){var e;window.removeEventListener("resize",this.handleSizeChange),(e=this._domElement)==null||e.removeEventListener("resize",this.handleSizeChange),clearInterval(this._sizeChangeInterval)}showNeedleLogo(e){if(this._userRequestedLogoVisible=e,!da()||fF){pt()&&console.warn("Needle Menu: You need a PRO license to hide the Needle Engine logo.");return}this.logoContainer.style.display=e?"":"none"}setPosition(e){if(e!=="top"&&e!=="bottom")return console.error("NeedleMenu.setPosition: invalid position",e);this.root.classList.remove("top","bottom"),this.root.classList.add(e)}append(...e){for(const t of e)if(typeof t=="string"){const n=document.createTextNode(t);this.options.appendChild(n)}else this.options.appendChild(t)}appendChild(e){return this.options.appendChild(e)}prepend(...e){for(const t of e)if(typeof t=="string"){const n=document.createTextNode(t);this.options.prepend(n)}else this.options.prepend(t)}onChangeDetected(e){if(!this._isHandlingChange){this._isHandlingChange=!0;try{this.handleMenuVisible();for(const t of e)t.target==this.options&&this.onOptionsChildrenChanged(t)}finally{this._isHandlingChange=!1}}}onOptionsChildrenChanged(e){let t=!1;for(let n=0;n<this.options.children.length;n++)if(this.options.children[n].style.display!="none"){t=!0;break}if(this.logoContainer.classList.toggle("any-options",t),this.handleSizeChange(),e.type==="childList"){let n=!1;const r=Date.now();for(let s=0;s<e.addedNodes.length;s++){const o=e.addedNodes[s],a=this._didSort.get(o);typeof a=="number"&&r-a<100||(this._didSort.set(o,r),n=!0)}if(n){const s=Array.from(this.options.children);s.sort((o,a)=>{const l=parseInt(o.getAttribute("priority")||"0"),c=parseInt(a.getAttribute("priority")||"0");return l-c});for(const o of s)this.options.appendChild(o)}}}handleMenuVisible(){m_&&console.log("Update VisibleState: Any Content?",this.hasAnyContent),this.hasAnyContent?this.root.style.display="":this.root.style.display="none"}get hasAnyContent(){if(this.logoContainer.style.display!="none")return!0;for(let e=0;e<this.options.children.length;e++)if(this.options.children[e].style.display!="none")return!0;return!1}___insertDebugOptions(){window.addEventListener("keydown",n=>{n.key==="p"&&this.setPosition(this.root.classList.contains("top")?"bottom":"top")});const e=document.createElement("button");e.textContent="Hide Buttons",e.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(e);const t=document.createElement("button");t.textContent="Toggle Logo",t.addEventListener("click",()=>{this.logoContainer.style.display=this.logoContainer.style.display==="none"?"":"none"}),this.appendChild(t)}}customElements.get(Gp)||customElements.define(Gp,Hw);const br=ee("debugcontext"),See=ee("stats"),Cee=ee("debugactive"),Eee=ee("debugframerate"),Mee=ee("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 Pn=(i=>(i[i.Start=-1]="Start",i[i.EarlyUpdate=0]="EarlyUpdate",i[i.Update=1]="Update",i[i.LateUpdate=2]="LateUpdate",i[i.OnBeforeRender=3]="OnBeforeRender",i[i.OnAfterRender=4]="OnAfterRender",i[i.PrePhysicsStep=9]="PrePhysicsStep",i[i.PostPhysicsStep=10]="PostPhysicsStep",i[i.Undefined=-1]="Undefined",i))(Pn||{});function g_(i,e){if(!i)return;if(!i.isComponent){(pt()||br)&&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
|
`,i);return}const t=e?.new_scripts??Lt.Current.new_scripts;t.includes(i)||t.push(i)}const qi=class{constructor(i){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",n=>{this.domElement.dispatchEvent(new CustomEvent("error",{detail:n.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=i?.name||"",this.alias=i?.alias,this.domElement=i?.domElement||document.body,this.hash=i?.hash,i!=null&&i.renderer&&(this.renderer=i.renderer,this.isManagedExternally=!0),i?.runInBackground!==void 0&&(this.runInBackground=i.runInBackground),i!=null&&i.scene?this.scene=i.scene:this.scene=new jr,i!=null&&i.camera&&(this._camera=i.camera),this.application=new jg(this),this.time=new aF,this.input=new iU(this),this.physics=new Z3(this),this.connection=new T3(this),this.assets=new eL,this.sceneLighting=new rF(this),this.addressables=new XL(this),this.lightmaps=new J$(this),this.players=new eF(this),this.menu=new wee(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(n=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.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()}),ii.register(this)}static get DefaultTargetFrameRate(){return qi._defaultTargetFramerate.value}static set DefaultTargetFrameRate(i){qi._defaultTargetFramerate.value=i}static get DefaultWebGLRendererParameters(){return qi._defaultWebglRendererParameters}get version(){return Fl}static get Current(){return ii.Current}static set Current(i){ii.Current=i}appendHTMLElement(i){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(i):this.domElement.appendChild(i)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(i){if(i!==this._resolutionScaleFactor&&typeof i=="number"){if(i<=0){console.error("Invalid resolution scale factor",i);return}this._resolutionScaleFactor=i,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 i,e;return((e=(i=this.renderer)==null?void 0:i.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var i;return(i=this.xr)==null?void 0:i.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 i,e;return(e=(i=this.renderer)==null?void 0:i.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var i,e;return this.renderer.xr.isPresenting?(e=(i=this.renderer)==null?void 0:i.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const i=this.domElement;return typeof i.getAROverlayContainer=="function"?i.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._camera)return this._camera;if(this.mainCameraComponent){const i=this.mainCameraComponent;return i.cam||i.buildCamera(),i.cam}return null}set mainCamera(i){this._camera=i}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(i){var e,t,n;if((e=this.renderer)==null||e.dispose(),i={...qi.DefaultWebGLRendererParameters,...i},!i.canvas){const r=(n=(t=this.domElement)==null?void 0:t.shadowRoot)==null?void 0:n.querySelector("canvas");r&&(i.canvas=r,br&&console.log("Using canvas from shadow root",r))}br&&console.log("Using Renderer Parameters:",i,this.domElement),this.renderer=new Pl(i),this.renderer.debug.checkShaderErrors=pt()||ee("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=zs,this.renderer.setClearColor(new Se("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=i1,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=dt,this.input.bindEvents()}internalOnUpdateVisible(){var i,e;(i=this._intersectionObserver)==null||i.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(i=!1){var e,t,n;if(i||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const r=this.resolutionScaleFactor;let s=this.domWidth*r,o=this.domHeight*r;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),s=Math.min(this.maxRenderResolution.x,s),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),o=Math.min(this.maxRenderResolution.y,o));const a=this.mainCamera;this.updateAspect(a),this.renderer.setSize(s,o,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((t=this.composer.setSize)==null||t.call(this.composer,s,o),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((n=this.composer.setPixelRatio)==null||n.call(this.composer,window.devicePixelRatio)))}}updateAspect(i,e,t){if(!i)return;e===void 0&&(e=this.domWidth),t===void 0&&(t=this.domHeight);const n=i.aspect;i.aspect=e/t,n!==i.aspect&&i.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(i){return this.create(i)}async create(i){try{this._isCreating=!0,i!==this._originalCreationArgs&&(this._originalCreationArgs=Km(i)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(i);return this._isCreated=!0,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}clear(){var i,e,t,n;ii.dispatchCallback(bn.ContextClearing,this),pa(this.scene,!0,!0),this.scene=new jr,(i=this.addressables)==null||i.dispose(),(e=this.lightmaps)==null||e.clear(),(n=(t=this.physics)==null?void 0:t.engine)==null||n.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),ii.dispatchCallback(bn.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var i,e;this.clear(),(i=this.renderer)==null||i.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(br&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy();for(const t of this._disposeCallbacks)try{t()}catch(n){console.error("Error in on dispose callback:",n,t)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,ii.dispatchCallback(bn.ContextDestroyed,this),ii.unregister(this),qi.Current===this&&(qi.Current=null)}registerCoroutineUpdate(i,e,t){return typeof e?.next!="function"?(console.error("Registered invalid coroutine function from "+i.name+`
|
|
5261
5266
|
Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
@@ -6290,7 +6295,7 @@ Texture LODs available? ${this.hasTextureLODs?"YES":"NO"}`)}updateLODs(){let i=0
|
|
|
6290
6295
|
}`};var Sse=Object.defineProperty,Cse=Object.getOwnPropertyDescriptor,o0=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Sse(e,t,r),r};const GI=ee("debugcontactshadows");class Th extends Ie{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(){GI&&console.log("Create ContactShadows on "+this.gameObject.name,this);const e=512;this.shadowGroup=new os,this.gameObject.add(this.shadowGroup),this.renderTarget=new Ht(e,e),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Ht(e,e),this.renderTargetBlur.texture.generateMipmaps=!1;const t=new Un(1,1).rotateX(Math.PI/2);if(this.gameObject instanceof ue){GI&&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 oi({map:this.renderTarget.texture,opacity:this.opacity,color:0,transparent:!0,depthWrite:!1});this.plane=new ue(t,n),this.plane.scale.y=-1,this.gameObject.add(this.plane)}this.plane&&(this.plane.renderOrder=1),this.occludeBelowGround&&(this.occluderMesh=new ue(this.plane.geometry,new oi({depthWrite:!0,stencilWrite:!0,colorWrite:!1})).translateY(-1e-4),this.occluderMesh.renderOrder=-100,this.gameObject.add(this.occluderMesh)),this.blurPlane=new ue(t),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane),this.shadowCamera=new Rl(-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 Pm,this.depthMaterial.userData.darkness={value:this.darkness},this.depthMaterial.blending=s1,this.depthMaterial.blendEquation=aA,this.backfaceShadows&&(this.depthMaterial.side=hi),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 Tt(xse),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Tt(wse),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,n,r,s,o,a,l;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(n=this.depthMaterial)==null||n.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(s=this.verticalBlurMaterial)==null||s.dispose(),(o=this.blurPlane)==null||o.geometry.dispose(),(a=this.plane)==null||a.geometry.dispose(),(l=this.occluderMesh)==null||l.geometry.dispose()}onBeforeRender(e){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){GI&&console.error("ContactShadows: not initialized yet");return}const t=this.context.scene,n=this.context.renderer,r=n.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const s=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof ue&&(this.gameObject.visible=!1,Ef(this.gameObject,!1));const o=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const a=n.getClearAlpha();n.setClearAlpha(0);const l=n.xr.enabled;n.xr.enabled=!1,n.setRenderTarget(this.renderTarget),n.render(t,this.shadowCamera),t.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=s,n.setRenderTarget(r),n.setClearAlpha(a),t.background=o,n.xr.enabled=l}blurShadow(e){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=e*1/256;const t=this.context.renderer,n=t.getRenderTarget();t.setRenderTarget(this.renderTargetBlur),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=e*1/256,t.setRenderTarget(this.renderTarget),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,t.setRenderTarget(n)}}o0([x()],Th.prototype,"darkness",2),o0([x()],Th.prototype,"opacity",2),o0([x()],Th.prototype,"blur",2),o0([x()],Th.prototype,"occludeBelowGround",2),o0([x()],Th.prototype,"backfaceShadows",2);var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,a0=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ese(e,t,r),r};const Z4=ee("debugwebxr"),Tse=new Ce().makeRotationY(Math.PI);class so extends Ie{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 Ce),h(this,"_createdPlacementObject",null),h(this,"_reparentedComponents",[]),h(this,"_placementScene",new jr),h(this,"_reticle",[]),h(this,"_hits",[]),h(this,"_placementStartTime",-1),h(this,"_rigPlacementMatrix"),h(this,"_anchor",null),h(this,"userInput"),h(this,"onPlaceScene",e=>{var t;if(this._isPlacing==!1||e.used)return;let n=this._reticle[0],r=this._hits[0];if(e.origin instanceof lM){const s=this._reticle[e.origin.index];s&&(n=s,r=this._hits[e.origin.index])}if(!n){console.warn("No reticle to place...");return}if(!n.visible){console.warn("Reticle is not visible (can not place)");return}if((t=bt.active)!=null&&t.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}e.stopImmediatePropagation(),e.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(n),this.useXRAnchor&&this.onCreateAnchor(bt.active,r)})}get arScale(){return this._arScale}set arScale(e){e!==this._arScale&&(this._arScale=e,this.onScaleChanged())}onEnable(){var e;(e=this.customReticle)==null||e.preload()}supportsXR(e){return e==="immersive-ar"}onEnterXR(e){Z4&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const t=new ge;this._createdPlacementObject=t,t.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(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),re.addComponent(t,this);for(const n of this._reticle)pa(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:za.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:za.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,n,r,s;if(e.xr.isTrackingImages){for(const o of this._reticle)o.visible=!1;return}if(this._isPlacing){const o=(t=e.xr.rig)==null?void 0:t.gameObject;o&&o.parent!==this.context.scene&&this.context.scene.add(o);let a=!1;if(e.xr.isPassThrough&&e.xr.controllers.length>0)for(const l of e.xr.controllers){const c=l.getHitTest();c&&(a=!0,this.updateReticleAndHits(e.xr,l.index,c,e.xr.rigScale))}if(!a){const l=e.xr.getHitTest();l&&this.updateReticleAndHits(e.xr,0,l,e.xr.rigScale)}}else{if(this._anchor&&e.xr.referenceSpace){const o=e.xr.frame.getPose(this._anchor.anchorSpace,e.xr.referenceSpace);if(o&&this.context.time.frame%20===0){const a=e.xr.convertSpace(o.transform),l=this._reticle[0];l&&(l.position.copy(a.position),l.quaternion.copy(a.quaternion),this.onApplyPose(l))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new wx(this.context)),(n=this.userInput)==null||n.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&(s=this.userInput)!=null&&s.hasChanged){if(e.xr.rig){const o=e.xr.rig.gameObject;this.userInput.applyMatrixTo(o.matrix,!0),o.matrix.decompose(o.position,o.quaternion,o.scale),this.userInput.factor=o.scale.x}this.userInput.reset()}}}updateReticleAndHits(e,t,n,r){this._hits[t]=n.hit;let s=this._reticle[t];if(!s){if(this.customReticle)if(this.customReticle.asset)s=Hp(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else s=new ue(new Ld(.07,.09,32).rotateX(-Math.PI/2),new oi({side:hi})),s.name="AR Placement Reticle";if(Z4){const o=new bo(1);o.position.y+=.01,s.add(o)}this._reticle[t]=s,s.matrixAutoUpdate=!1,s.visible=!1}s.position.lerp(n.position,this.context.time.deltaTime/.1),s.quaternion.slerp(n.quaternion,this.context.time.deltaTime/.05),s.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(s),s.updateMatrix(),s.visible=!0,s.parent!==this.context.scene&&this.context.scene.add(s),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var e;for(const t of this._reticle)t&&(t.visible=!1,t?.removeFromParent());this._reticle.length=0;for(let t=this._placementScene.children.length-1;t>=0;t--){const n=this._placementScene.children[t];this.context.scene.add(n)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)re.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),pt()&&Qi("Hit does not support creating an anchor");return}else{const n=await t.createAnchor(e.viewerPose.transform);e.running&&n&&(this._anchor=n)}}applyViewBasedTransform(e){const t=this.context.mainCamera,n=e,r=t.worldPosition,s=n.worldPosition;r.y=s.y,e.lookAt(r)}onApplyPose(e){var t,n,r,s;const o=(n=(t=bt.active)==null?void 0:t.rig)==null?void 0:n.gameObject;if(!o){console.warn("No rig object to place");return}(r=bt.active)!=null&&r.rigScale;const a=o.parent||this.context.scene;this._rigPlacementMatrix?(s=this._rigPlacementMatrix)==null||s.decompose(o.position,o.quaternion,o.scale):this._rigPlacementMatrix=o.matrix.clone(),this.applyViewBasedTransform(e),e.updateMatrix(),this.context.scene.add(e),e.attach(o),e.removeFromParent(),o.scale.set(this.arScale,this.arScale,this.arScale),o.position.multiplyScalar(this.arScale),o.updateMatrix(),this.invertForward&&o.matrix.premultiply(Tse),o.matrix.premultiply(this._startOffset),o.matrix.decompose(o.position,o.quaternion,o.scale),a.add(o)}}a0([x()],so.prototype,"arScale",1),a0([x()],so.prototype,"invertForward",2),a0([x(ni)],so.prototype,"customReticle",2),a0([x()],so.prototype,"useXRAnchor",2),a0([x()],so.prototype,"arTouchTransform",2);const QI=class{constructor(i){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 n=e.changedTouches[t],r=_O()&&n.clientY<window.innerHeight*.1;this.prev.has(n.identifier)||this.prev.set(n.identifier,{ignore:r,x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(n.identifier);if(s){const o=this.getPositionOnPlane(n.clientX,n.clientY);s.x=o.x,s.z=o.z,s.screenx=n.clientX,s.screeny=n.clientY}}}),h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1);for(let t=0;t<e.changedTouches.length;t++){const n=e.changedTouches[t];this.prev.delete(n.identifier)}}),h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],n=this.prev.get(t.identifier);if(!n||n.ignore)return;const r=this.getPositionOnPlane(t.clientX,t.clientY),s=r.x-n.x,o=r.z-n.z;if(s===0&&o===0)return;this.oneFingerDrag&&this.addMovement(s,o),n.x=r.x,n.z=r.z,n.screenx=t.clientX,n.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],n=e.touches[1],r=this.prev.get(t.identifier),s=this.prev.get(n.identifier);if(!r||!s)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-n.clientY,t.clientX-n.clientX),a=Math.atan2(r.screeny-s.screeny,r.screenx-s.screenx),l=o-a;Math.abs(l)>.001&&this.addRotation(l)}if(this.twoFingerScale){const o=t.clientX-n.clientX,a=t.clientY-n.clientY,l=Math.sqrt(o*o+a*a),c=r.screenx-s.screenx,u=r.screeny-s.screeny,d=Math.sqrt(c*c+u*u),p=l-d;Math.abs(p)>2&&this.addScale(p)}r.screenx=t.clientX,r.screeny=t.clientY,s.screenx=n.clientX,s.screeny=n.clientY}}}),h(this,"_raycaster",new Au),h(this,"_intersection",new S),h(this,"_screenPos",new S),h(this,"_tempMatrix",new Ce),this.context=i,this.offset=new Ce,this.plane=new ss,this.plane.setFromNormalAndCoplanarPoint(QI.up,QI.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(i,e){this._hasChanged=!1,e?(this.offset.invert(),i.premultiply(this.offset)):i.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:za.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:za.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:za.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:za.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:za.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:za.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(i,e){const t=this.context.mainCamera;return this._screenPos.x=i/window.innerWidth*2-1,this._screenPos.y=-(e/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(t),this._raycaster.set(t.position,this._screenPos.sub(t.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(i,e){i/=this._scale,e/=this._scale,i*=this.factor,e*=this.factor,this.offset.elements[12]+=i,this.offset.elements[14]+=e,(i!==0||e!==0)&&(this._hasChanged=!0)}addScale(i){i/=window.innerWidth,i*=-1,this._scale*=1+i,this._tempMatrix.makeScale(1-i,1-i,1-i),this.offset.premultiply(this._tempMatrix),i!==0&&(this._hasChanged=!0)}addRotation(i){i*=-1,this._tempMatrix.makeRotationY(i),this.offset.premultiply(this._tempMatrix),i!==0&&(this._hasChanged=!0)}};let wx=QI;h(wx,"up",new S(0,1,0)),h(wx,"zero",new S(0,0,0)),h(wx,"one",new S(1,1,1));const $4=class{constructor(){h(this,"_quicklookButton"),h(this,"_arButton"),h(this,"_vrButton"),h(this,"_sendToQuestButton")}static create(){return new $4}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 jp.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const i=document.createElement("button");return this._quicklookButton=i,i.dataset.needle="quicklook-button",i.innerText="Open in Quicklook",i.prepend(Ys("view_in_ar")),i.addEventListener("click",()=>{const e=re.findObjectOfType(Wn);e?(i.classList.add("this-mode-is-requested"),e.exportAndOpen().then(()=>{i.classList.remove("this-mode-is-requested")}).catch(t=>{i.classList.remove("this-mode-is-requested"),console.error(t)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(i),i}createARButton(i){var e;if(this._arButton)return this._arButton;const t="immersive-ar",n=document.createElement("button");return this._arButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-ar-button",n.innerText="Enter AR",n.prepend(Ys("view_in_ar")),n.title="Click to start an AR session",n.addEventListener("click",()=>bt.start(t,i)),this.updateSessionSupported(n,t),this.listenToXRSessionState(n,t),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),bu()||(e=navigator.xr)==null||e.addEventListener("devicechange",()=>this.updateSessionSupported(n,t)),n}createVRButton(i){var e;if(this._vrButton)return this._vrButton;const t="immersive-vr",n=document.createElement("button");return this._vrButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-vr-button",n.innerText="Enter VR",n.prepend(Ys("panorama_photosphere")),n.title="Click to start a VR session",n.addEventListener("click",()=>bt.start(t,i)),this.updateSessionSupported(n,t),this.listenToXRSessionState(n,t),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),bu()||(e=navigator.xr)==null||e.addEventListener("devicechange",()=>this.updateSessionSupported(n,t)),n}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(Ys("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),bu()||(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 jp.getOrCreate().createQRCode()}updateSessionSupported(i,e){if(!("xr"in navigator)){i.style.display="none";return}bt.isSessionSupported(e).then(t=>{i.style.display=t?"":"none",pt()&&!t&&console.log('[WebXR] "'+e+'" is not supported on this device \u2013 make sure your server runs using HTTPS and you have a device connected that supports '+e)})}hideElementDuringXRSession(i){Nb(e=>{i["previous-display"]=i.style.display,i.style.display="none"}),sM(e=>{i["previous-display"]!=null&&(i.style.display=i["previous-display"])})}listenToXRSessionState(i,e){e&&(bt.onSessionRequestStart(t=>{t.mode===e?i.classList.add("this-mode-is-requested"):(i["was-disabled"]=i.disabled,i.disabled=!0,i.classList.add("other-mode-is-requested"))}),bt.onSessionRequestEnd(t=>{i.classList.remove("this-mode-is-requested"),i.classList.remove("other-mode-is-requested"),i.disabled=i["was-disabled"]}))}};let Bf=$4;h(Bf,"_instance");var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,dc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ise(e,t,r),r};const pd=ee("debugtext");var Vn=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Vn||{}),ez=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(ez||{});class xs extends sd{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 Se(1,0,1)),h(this,"_text",""),h(this,"_fontSize",12),h(this,"_textMeshUi",null),h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(e=this.uiObject)==null||e.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(e){this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){pd&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,pd&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),pd&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){var e;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(e=this.canvas)==null||e.registerEventReceiver(this)}onDisable(){var e;super.onDisable(),(e=this.canvas)==null||e.unregisterEventReceiver(this)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var n,r,s;if(pd&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const u=this.uiObject.children[c];u.isUI&&(this.uiObject.remove(u),u.clear())}const l=new lb({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const u=new lb(c);(r=this.uiObject)==null||r.add(u)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const u=new lb(c);(s=this.uiObject)==null||s.add(u)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,n={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let s=0;s<this._textMeshUi.length;s++){if(e[s]===!0)continue;r=!0;const o=this._textMeshUi[s];o.textContent&&(N_(o,n),e[s]=!0)}if(!r)break;yield}}handleTag(e,t,n){if(!e.isEndTag){if(e.type.includes("color")){const r=new HI(e,{color:t.color});if(n.push(r),e.type.length>6){const s=parseInt("0x"+e.type.substring(7));t.color=s}else t.color=new Se(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new HI(e,{fontWeight:700});n.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new HI(e,{fontStyle:"italic"});n.push(r)}}}getText(e,t,n){return e.substring(t.endIndex,n.startIndex)}getNextTag(e,t=0){const n=e.indexOf("<",t),r=e.indexOf(">",n);if(n>=0&&r>=0){const s=e.substring(n+1,r);return{type:s,startIndex:n,endIndex:r+1,isEndTag:s.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const n=this.font,r=this.getFamilyNameWithCorrectSuffix(n,t);pd&&console.log("Selected font family:"+r);let s=hE.getFontFamily(r);switch(s||(s=hE.addFontFamily(r)),e.fontFamily=s,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=s.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=s.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var n;const r=e.lastIndexOf("-");if(r<0)return e;const s=(n=e.substring(r+1))==null?void 0:n.toLowerCase();if(Pse.includes(s))return pd&&console.warn("Unsupported font style: "+s),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=e.substring(0,r);switch(pd&&console.log("Select font: ",e,ez[t],a,l,c),t){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 e}}}dc([x()],xs.prototype,"alignment",2),dc([x()],xs.prototype,"verticalOverflow",2),dc([x()],xs.prototype,"horizontalOverflow",2),dc([x()],xs.prototype,"lineSpacing",2),dc([x()],xs.prototype,"supportRichText",2),dc([x(URL)],xs.prototype,"font",2),dc([x()],xs.prototype,"fontStyle",2),dc([x()],xs.prototype,"text",1),dc([x()],xs.prototype,"fontSize",1);class HI{constructor(e,t){h(this,"tag"),h(this,"previousValues"),this.tag=e,this.previousValues=t}}const Pse=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ih{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 r=this.font.map(s=>`"${s}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),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/${IT(this.material)}>`),t.closeBlock()}}h(Ih,"global_id",0);class Sx{static singleLine(e,t,n){const r=new Ih("text_"+Ih.getId());return r.content=e,t&&(r.pointSize=t),n&&(r.depth=n),r}static multiLine(e,t,n,r,s,o){const a=new Ih("text_"+Ih.getId());return a.content=e,a.width=t,a.height=n,a.horizontalAlignment=r,a.verticalAlignment=s,o!==void 0&&(a.wrapMode=o),a}}const Bse=new Ce().makeRotationY(Math.PI),Dse=new Ce().makeScale(-1,1,-1);class l0{get extensionName(){return"text"}onExportObject(e,t,n){}exportText(e,t,n){const r=re.getComponent(e,xs);if(!r)return;const s=re.getComponent(e,bs);let o=100,a=100;s&&(o=s.width,a=s.height),t.matrix=Bse.clone(),s&&t.matrix.premultiply(Dse);const l=r.color.clone();t.material=new ls({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=r.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const p=Sx.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.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 Vn.LowerLeft:case Vn.MiddleLeft:case Vn.UpperLeft:e.horizontalAlignment="left";break;case Vn.LowerCenter:case Vn.MiddleCenter:case Vn.UpperCenter:e.horizontalAlignment="center";break;case Vn.LowerRight:case Vn.MiddleRight:case Vn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Vn.LowerLeft:case Vn.LowerCenter:case Vn.LowerRight:e.verticalAlignment="bottom";break;case Vn.MiddleLeft:case Vn.MiddleCenter:case Vn.MiddleRight:e.verticalAlignment="middle";break;case Vn.UpperLeft:case Vn.UpperCenter:case Vn.UpperRight:e.verticalAlignment="top";break}}}class Cx{get extensionName(){return"tmui"}onExportObject(e,t,n){const r=re.getComponent(e,Mr);if(r&&r.activeAndEnabled&&r.renderMode===T4.WorldSpace){const s=new l0,o=re.getComponent(e,bs),a=re.getComponent(e,bh);if(o){o.width,o.height;const l=Bo.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=Bo.createEmpty();m.matrix.copy(f.matrix);const A=f.parent,v=!!A&&typeof A.textContent=="string"&&A.textContent.length>0;let g=p.get(A)||1;const y=re.getComponent(f,bh);if(y&&(g*=y.alpha),f instanceof ue&&v){const _=f[ko];_?s.exportText(_.gameObject,m,n):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",f)}if(f instanceof ue&&!v){const _=f.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const E=new Se,I=f.material.opacity;E.copy(f.material.color),m.material=new oi({color:E,opacity:I*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const b=d.get(A);if(!b){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}b.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let n=0,r=t.length/3;n<r;n++){const s=t[n*3];t[n*3]=t[n*3+2],t[n*3+2]=s}e.index.needsUpdate=!0}}const Ex=ee("debugusdz");function Ose(i,e){var t;const n=[],r=re.getComponentsInChildren(i,Sr),s=re.getComponentsInChildren(i,vs),o=new Array;if(e.injectImplicitBehaviours)for(const a of r){if(!a||!a.runtimeAnimatorController)continue;const l=a.runtimeAnimatorController.activeState;if(!l||!l.motion||!l.motion.clip||((t=l.motion.clip.tracks)==null?void 0:t.length)<1)continue;const c=new wf;c.animator=a,c.stateName=l.name,c.trigger="start",c.name="PlayAnimationOnClick_implicitAtStart_"+c.stateName;const u=new ge;re.addComponent(u,c),o.push(u),i.add(u)}else for(const a of r){if(!a||!a.runtimeAnimatorController)continue;Ex&&console.log(a);const l=[];for(const c of a.runtimeAnimatorController.enumerateActions()){Ex&&console.log(c);const u=c.getClip();l.includes(u)||l.push(u)}n.push({root:a.gameObject,clips:l})}for(const a of s){Ex&&console.log(a);const l=[];for(const c of a.animations)l.includes(c)||l.push(c);n.push({root:a.gameObject,clips:l})}Ex&&console.log("USDZ Animation Clips",n);for(const a of n)for(const l of a.clips)e.registerAnimation(a.root,l);return o}function kse(i,e){const t=re.getComponentsInChildren(i,en),n=re.getComponentsInChildren(i,_h),r=new Array;for(const s of n){if(!s.target)continue;const o=t.indexOf(s.target);o>-1&&t.splice(o,1)}for(const s of t){if(!s||!s.clip||s.volume<=0)continue;const o=new _h;o.target=s,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;re.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),r.push(a),i.add(a)}return r}function tz(i){const e=i.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 n=document.createElement("button");n.id="open-in-ar",n.innerText="Open in QuickLook",t.appendChild(n);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const s=document.createElement("img");return s.id="button",r.appendChild(s),i.domElement.shadowRoot.appendChild(t),r}var Lse=Object.defineProperty,Use=Object.getOwnPropertyDescriptor,Kr=(i,e,t,n)=>{for(var r=n>1?void 0:n?Use(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Lse(e,t,r),r};const Us=ee("debugusdz");class Rh{constructor(){h(this,"callToAction"),h(this,"checkoutTitle"),h(this,"checkoutSubtitle"),h(this,"callToActionURL")}}Kr([x()],Rh.prototype,"callToAction",2),Kr([x()],Rh.prototype,"checkoutTitle",2),Kr([x()],Rh.prototype,"checkoutSubtitle",2),Kr([x()],Rh.prototype,"callToActionURL",2);var VI;const WI=(VI=class extends Ie{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",i=>{i.preventDefault(),this.exportAndOpen()}),h(this,"_currentExportTasks",new Map),h(this,"lastCallback")}start(){var i,e,t;Us&&(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),!((e=(i=this.objectToExport)==null?void 0:i.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new ex),this.extensions.push(new zh),this.extensions.push(new l0),this.extensions.push(new Cx))}onEnable(){var i;const e=Sp(),t=Cp();(Us||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=tz(this.context),this.link.addEventListener("message",this.lastCallback)),Us&&$i("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var i,e,t;(i=this.button)==null||i.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),Us&&$i("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+_N(),da()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=tz(this.context)),this.customUsdzFile)return Us&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e),null;const t=await this.export(this.objectToExport);return t?(Us&&console.log("USDZ generation done. Downloading as "+e),this.openInQuickLook(t,e),t):(console.warn("No object to export",this),null)}async export(i){if(!i)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(i);if(e)return e;const t=this.internalExport(i);return t instanceof Promise?(this._currentExportTasks.set(i,t),t.then(n=>(this._currentExportTasks.delete(i),n)).catch(n=>(this._currentExportTasks.delete(i),null))):t}async internalExport(i){Kt.start("export-usdz",{onProgress:p=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:p}}))}}),Kt.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),Kt.report("export-usdz",{message:"Load progressive textures",autoStep:5}),Kt.start("export-usdz-textures","export-usdz");const e=re.getComponentsInChildren(i,Sn),t=new Array;let n=0;for(const p of e){p.didAutomaticallyUpdateLODLevel=p.automaticallyUpdateLODLevel,p.automaticallyUpdateLODLevel=!1;for(const f of p.sharedMeshes)if(f){const m=p.loadProgressiveMeshes(f,0);m instanceof Promise&&t.push(new Promise((A,v)=>{m.then(()=>{n++,Kt.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:n,totalSteps:t.length}),A()}).catch(g=>v(g))}))}for(const f of p.sharedMaterials)if(f){const m=p.loadProgressiveTextures(f,0);m instanceof Promise&&t.push(new Promise((A,v)=>{m.then(()=>{n++,Kt.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:n,totalSteps:t.length}),A()}).catch(g=>v(g))}))}}Us&&$i("Progressive Loading: "+t.length),await Promise.all(t),Us&&$i("Progressive Loading: done"),Kt.end("export-usdz-textures");const r=ys.Global.Mask;ys.Global.Set(Ya.AR),this.applyWebARSessionRoot();const s=new Qte,o=[...this.extensions],a=new Ev(this.quickLookCompatible);o.push(a);const l={self:this,exporter:s,extensions:o,object:i};Kt.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:l})),Kt.report("export-usdz","auto export animations and audio sources");const c=new Array;this.autoExportAnimations&&c.push(...Ose(i,a)),this.extensions.find(p=>p.extensionName==="Audio")&&this.autoExportAudioSources&&c.push(...kse(i)),s.debug=Us,s.keepObject=p=>{const f=re.getComponent(p,Sn);return!(f&&!f.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"),Kt.report("export-usdz","Invoking exporter.parse");const u=await s.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),d=new Blob([u],{type:"model/vnd.usdz+zip"});Kt.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:l}));for(const p of c)re.destroy(p);for(const p of e){const f=p.didAutomaticallyUpdateLODLevel;f!=null&&(p.automaticallyUpdateLODLevel=f)}return ys.Global.Set(r),Kt.end("export-usdz"),d}openInQuickLook(i,e){const t=i instanceof Blob?URL.createObjectURL(i):i,n=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",n);const r=n.callToAction?encodeURIComponent(n.callToAction):"",s=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",o=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=t+`#callToAction=${r}&checkoutTitle=${s}&checkoutSubtitle=${o}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(i,e){WI.save(i,e)}static save(i,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof i=="string"?t.href=i:t.href=URL.createObjectURL(i),t.download=e,t.click(),t.remove()}quicklookCallback(i){if(i?.data=="_apple_ar_quicklook_button_tapped"){Us&&Qi("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const t=new URLSearchParams(this.link.href);if(t){const n=t.get("callToActionURL");Us&&$i("Quicklook url: "+n),n&&(da()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var i,e,t,n,r,s;const o={};return this.customBranding&&Object.assign(o,this.customBranding),da()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),o.callToAction="Close",o.checkoutTitle="\u{1F335} Made with Needle",o.checkoutSubtitle="_"),(((i=o.callToAction)==null?void 0:i.length)||((e=o.checkoutTitle)==null?void 0:e.length)||((t=o.checkoutSubtitle)==null?void 0:t.length))&&((n=o.callToAction)!=null&&n.length||(o.callToAction="\0"),(r=o.checkoutTitle)!=null&&r.length||(o.checkoutTitle="\0"),(s=o.checkoutSubtitle)!=null&&s.length||(o.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:o})),o}applyWebARSessionRoot(){if(!this.objectToExport)return;let i=re.getComponentInParent(this.objectToExport,so);const e=i!=null;if(i||(i=re.getComponentInChildren(this.objectToExport,so)),Us&&console.log("applyWebARSessionRoot",i),!i){Us&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:i.gameObject,n=1/i.arScale;t.matrix.makeScale(n,n,n),i.invertForward&&t.matrix.multiply(WI.invertForwardMatrix)}createQuicklookButton(){const i=Bf.getOrCreate().createQuicklookButton();return i.parentNode||this.context.menu.appendChild(i),i}},h(VI,"invertForwardMatrix",new Ce().makeRotationY(Math.PI)),VI);let Wn=WI;Kr([x(ge)],Wn.prototype,"objectToExport",2),Kr([x()],Wn.prototype,"autoExportAnimations",2),Kr([x()],Wn.prototype,"autoExportAudioSources",2),Kr([x()],Wn.prototype,"exportFileName",2),Kr([x(URL)],Wn.prototype,"customUsdzFile",2),Kr([x(Rh)],Wn.prototype,"customBranding",2),Kr([x()],Wn.prototype,"anchoringType",2),Kr([x()],Wn.prototype,"maxTextureSize",2),Kr([x()],Wn.prototype,"planeAnchoringAlignment",2),Kr([x()],Wn.prototype,"interactive",2),Kr([x()],Wn.prototype,"allowCreateQuicklookButton",2),Kr([x()],Wn.prototype,"quickLookCompatible",2);class c0 extends Ie{constructor(){super(...arguments),h(this,"isUsed",!0),h(this,"usedBy",null)}}class qI extends Ie{}const iz=ee("debugdeletable");class Mx extends Za{}class XI extends Ie{constructor(){super(...arguments),h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=re.findObjectsOfType(Mx,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const n=re.getComponentInParent(this.gameObject,c0);n?iz&&console.warn("Can not delete object with usage marker",this.guid,n):(iz&&console.log("DESTROY",this.gameObject),A_(this.gameObject,this.context.connection))}}}}var Fse=Object.defineProperty,Nse=Object.getOwnPropertyDescriptor,fd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Fse(e,t,r),r};const nz=ee("debugpost");class _a extends Yr{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(){nz&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const n=t/300,r=2;return Ze.lerp(r,.01,n)};const e=20;this.aperture.valueProcessor=t=>{const n=1-t/32;return Ze.lerp(1,e,n)}}onCreateEffect(){if(this.mode===0){nz&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let n=1;ra()&&(n=.6),this.resolutionScale=new Bt(n*e)}const t=new ML(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=n=>{t.cocMaterial.worldFocusDistance=n},this.focalLength.onValueChanged=n=>t.cocMaterial.worldFocusRange=n,this.aperture.onValueChanged=n=>t.bokehScale=n,this.resolutionScale&&(this.resolutionScale.onValueChanged=n=>t.resolution.scale=n),[t]}unapply(){}}fd([x()],_a.prototype,"mode",2),fd([x(Bt)],_a.prototype,"focusDistance",2),fd([x(Bt)],_a.prototype,"focalLength",2),fd([x(Bt)],_a.prototype,"aperture",2),fd([x(Bt)],_a.prototype,"gaussianMaxRadius",2),fd([x(Bt)],_a.prototype,"resolutionScale",2),fd([x(Bt)],_a.prototype,"bokehScale",2),Fo("DepthOfField",_a);var zse=Object.defineProperty,jse=Object.getOwnPropertyDescriptor,Gse=(i,e,t,n)=>{for(var r=n>1?void 0:n?jse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zse(e,t,r),r};class Tx extends Ie{constructor(){super(...arguments),h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||re.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:ra()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Gse([x()],Tx.prototype,"visibleOn",2);class YI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Qse=Object.defineProperty,Hse=Object.getOwnPropertyDescriptor,md=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qse(e,t,r),r};const tl=ee("debugdrag");var rz=(i=>(i[i.XZPlane=0]="XZPlane",i[i.Attached=1]="Attached",i[i.HitNormal=2]="HitNormal",i[i.DynamicViewAngle=3]="DynamicViewAngle",i[i.SnapToSurfaces=4]="SnapToSurfaces",i[i.None=5]="None",i))(rz||{}),Ix;const il=(Ix=class extends Ie{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 S),h(this,"_marker",null),h(this,"_isDragging",!1),h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(i){this.targetObject=i;for(const e of this._dragHandlers.values())e.setTargetObject(i)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new S,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=re.findObjectOfType(bi,this.context),this.gameObject.getComponentInParent(Ks)||this.gameObject.addComponent(Ks)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||i.mode!=="screen"||(i.event.mode==="tracked-pointer"||i.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const e=re.getComponentInParent(i.object,il);!e||e!==this||(il.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&i.mode==="screen"&&il.lastHovered===i.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(i){if(!(!this.allowEdit(this.gameObject)||i.used||(i.mode==="tracked-pointer"||i.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(il.lastHovered=i.object,i.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=i),il._active+=1;const e=new Wse(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(i.event.space,e),this.orbit&&(this.orbit.enabled=!1),e.onDragStart(i),this._dragHandlers.size===2){const t=this._dragHandlers.values(),n=t.next().value,r=t.next().value,s=new Vse(this,this.targetObject||this.gameObject,n,r);this._dragHandlers.set(this.gameObject,s),s.onDragStart(i)}i.use()}}onPointerMove(i){(this._isDragging||this._potentialDragStartEvt!==null)&&i.use()}onPointerUp(i){if(tl&&Ct.DrawLabel(i.point??this.gameObject.worldPosition,"POINTERUP:"+i.pointerId+", "+i.button,.03,3),!this.allowEdit(this.gameObject)||i.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(i.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(i)),e&&(il._active>0&&(il._active-=1),e.onDragEnd&&e.onDragEnd(i),this._dragHandlers.delete(i.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(i),i.use()),il._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const i of this._dragHandlers.values())i.collectMovementInfo&&i.collectMovementInfo(),i.getTotalMovement&&this._totalMovement.add(i.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const i=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(i)}for(const i of this._dragHandlers.values())i.onDragUpdate&&i.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new oz(this.context.mainCamera);else return;if(!i||!i.object)return;const e=re.getComponentInParent(i.object,il);if(!e||e!==this)return;const t=this.targetObject||this.gameObject;if(!t)return;this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const n=re.getComponentInChildren(t,uh);tl&&console.log("DRAG START",n,t),n&&(n.fastMode=!0,n?.requestOwnership()),this._marker=re.addComponent(t,c0),this._draggingRigidbodies.length=0;const r=re.getComponentsInChildren(t,Li);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities(),e.resetForcesAndTorques();const i=this.targetObject||this.gameObject;qo.markDirty(i)}onLastDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const t of this._draggingRigidbodies)t.setVelocity(t.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(tl&&console.log("DRAG END",e,e?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const t=re.getComponentInChildren(i.object,uh);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},h(Ix,"_active",0),h(Ix,"lastHovered"),Ix);let Go=il;md([x()],Go.prototype,"dragMode",2),md([x()],Go.prototype,"snapGridResolution",2),md([x()],Go.prototype,"keepRotation",2),md([x()],Go.prototype,"xrDragMode",2),md([x()],Go.prototype,"xrKeepRotation",2),md([x()],Go.prototype,"xrDistanceDragFactor",2),md([x()],Go.prototype,"showGizmo",2);class Vse{constructor(e,t,n,r){h(this,"handlerA"),h(this,"handlerB"),h(this,"context"),h(this,"settings"),h(this,"gameObject"),h(this,"_handlerAAttachmentPoint",new S),h(this,"_handlerBAttachmentPoint",new S),h(this,"_followObject"),h(this,"_manipulatorObject"),h(this,"_deviceMode"),h(this,"_followObjectStartWorldQuaternion",new Me),h(this,"_manipulatorPosOffset",new S),h(this,"_manipulatorRotOffset",new Me),h(this,"_manipulatorScaleOffset",new S),h(this,"_tempVec1",new S),h(this,"_tempVec2",new S),h(this,"_tempVec3",new S),h(this,"tempLookMatrix",new Ce),h(this,"_initialScale",new S),h(this,"_initialDistance",0);var s,o;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=n,this.handlerB=r,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const a=(o=(s=bt.active)==null?void 0:s.rig)==null?void 0:o.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),a&&(a.worldToLocal(this._tempVec1),a.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(tl&&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 \u2013 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),tl){this._followObject.add(new bo(2)),this._manipulatorObject.add(new bo(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 Tt(xse),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Tt(wse),this.verticalBlurMaterial.depthTest=!1,this.shadowGroup.visible=!1}onDestroy(){var e,t,n,r,s,o,a,l;(e=this.renderTarget)==null||e.dispose(),(t=this.renderTargetBlur)==null||t.dispose(),(n=this.depthMaterial)==null||n.dispose(),(r=this.horizontalBlurMaterial)==null||r.dispose(),(s=this.verticalBlurMaterial)==null||s.dispose(),(o=this.blurPlane)==null||o.geometry.dispose(),(a=this.plane)==null||a.geometry.dispose(),(l=this.occluderMesh)==null||l.geometry.dispose()}onBeforeRender(e){if(!this.renderTarget||!this.renderTargetBlur||!this.depthMaterial||!this.shadowCamera||!this.blurPlane||!this.shadowGroup||!this.plane||!this.horizontalBlurMaterial||!this.verticalBlurMaterial){GI&&console.error("ContactShadows: not initialized yet");return}const t=this.context.scene,n=this.context.renderer,r=n.getRenderTarget();this.shadowGroup.visible=!0,this.occluderMesh&&(this.occluderMesh.visible=!1);const s=this.plane.visible;this.plane.visible=!1,this.gameObject instanceof ue&&(this.gameObject.visible=!1,Ef(this.gameObject,!1));const o=t.background;t.background=null,t.overrideMaterial=this.depthMaterial;const a=n.getClearAlpha();n.setClearAlpha(0);const l=n.xr.enabled;n.xr.enabled=!1;const c=n.renderLists.get(t,0),u=c.transparent;c.transparent=[],n.setRenderTarget(this.renderTarget),n.clear(),n.render(t,this.shadowCamera),c.transparent=u,t.overrideMaterial=null,this.blurShadow(this.blur),this.blurShadow(this.blur*.4),this.shadowGroup.visible=!1,this.occluderMesh&&(this.occluderMesh.visible=!0),this.plane.visible=s,n.setRenderTarget(r),n.setClearAlpha(a),t.background=o,n.xr.enabled=l}blurShadow(e){if(!this.blurPlane||!this.shadowCamera||!this.renderTarget||!this.renderTargetBlur||!this.horizontalBlurMaterial||!this.verticalBlurMaterial)return;this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=e*1/256;const t=this.context.renderer,n=t.getRenderTarget();t.setRenderTarget(this.renderTargetBlur),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.blurPlane.material.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=e*1/256,t.setRenderTarget(this.renderTarget),t.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1,t.setRenderTarget(n)}}o0([x()],Th.prototype,"darkness",2),o0([x()],Th.prototype,"opacity",2),o0([x()],Th.prototype,"blur",2),o0([x()],Th.prototype,"occludeBelowGround",2),o0([x()],Th.prototype,"backfaceShadows",2);var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,a0=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ese(e,t,r),r};const Z4=ee("debugwebxr"),Tse=new Ce().makeRotationY(Math.PI);class so extends Ie{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 Ce),h(this,"_createdPlacementObject",null),h(this,"_reparentedComponents",[]),h(this,"_placementScene",new jr),h(this,"_reticle",[]),h(this,"_hits",[]),h(this,"_placementStartTime",-1),h(this,"_rigPlacementMatrix"),h(this,"_anchor",null),h(this,"userInput"),h(this,"onPlaceScene",e=>{var t;if(this._isPlacing==!1||e.used)return;let n=this._reticle[0],r=this._hits[0];if(e.origin instanceof lM){const s=this._reticle[e.origin.index];s&&(n=s,r=this._hits[e.origin.index])}if(!n){console.warn("No reticle to place...");return}if(!n.visible){console.warn("Reticle is not visible (can not place)");return}if((t=bt.active)!=null&&t.isTrackingImages){console.warn("Scene Placement is disabled while images are being tracked");return}e.stopImmediatePropagation(),e.use(),this._isPlacing=!1,this.context.input.removeEventListener("pointerup",this.onPlaceScene),this.onRevertSceneChanges(),this.onApplyPose(n),this.useXRAnchor&&this.onCreateAnchor(bt.active,r)})}get arScale(){return this._arScale}set arScale(e){e!==this._arScale&&(this._arScale=e,this.onScaleChanged())}onEnable(){var e;(e=this.customReticle)==null||e.preload()}supportsXR(e){return e==="immersive-ar"}onEnterXR(e){Z4&&console.log("ENTER WEBXR: SessionRoot start..."),this._anchor=null,this.gameObject.updateMatrixWorld(),this._startOffset.copy(this.gameObject.matrixWorld);const t=new ge;this._createdPlacementObject=t,t.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(t),this._reparentedComponents.length=0,this._reparentedComponents.push({comp:this,originalObject:this.gameObject}),re.addComponent(t,this);for(const n of this._reticle)pa(n);this._reticle.length=0,this._isPlacing=!0,this.context.input.addEventListener("pointerup",this.onPlaceScene,{queue:za.Late})}onLeaveXR(){this.context.input.removeEventListener("pointerup",this.onPlaceScene,{queue:za.Late}),this.onRevertSceneChanges(),this._anchor=null,this._rigPlacementMatrix=void 0}onUpdateXR(e){var t,n,r,s;if(e.xr.isTrackingImages){for(const o of this._reticle)o.visible=!1;return}if(this._isPlacing){const o=(t=e.xr.rig)==null?void 0:t.gameObject;o&&o.parent!==this.context.scene&&this.context.scene.add(o);let a=!1;if(e.xr.isPassThrough&&e.xr.controllers.length>0)for(const l of e.xr.controllers){const c=l.getHitTest();c&&(a=!0,this.updateReticleAndHits(e.xr,l.index,c,e.xr.rigScale))}if(!a){const l=e.xr.getHitTest();l&&this.updateReticleAndHits(e.xr,0,l,e.xr.rigScale)}}else{if(this._anchor&&e.xr.referenceSpace){const o=e.xr.frame.getPose(this._anchor.anchorSpace,e.xr.referenceSpace);if(o&&this.context.time.frame%20===0){const a=e.xr.convertSpace(o.transform),l=this._reticle[0];l&&(l.position.copy(a.position),l.quaternion.copy(a.quaternion),this.onApplyPose(l))}}if(this.arTouchTransform?(this.userInput||(this.userInput=new wx(this.context)),(n=this.userInput)==null||n.enable()):(r=this.userInput)==null||r.disable(),this.arTouchTransform&&(s=this.userInput)!=null&&s.hasChanged){if(e.xr.rig){const o=e.xr.rig.gameObject;this.userInput.applyMatrixTo(o.matrix,!0),o.matrix.decompose(o.position,o.quaternion,o.scale),this.userInput.factor=o.scale.x}this.userInput.reset()}}}updateReticleAndHits(e,t,n,r){this._hits[t]=n.hit;let s=this._reticle[t];if(!s){if(this.customReticle)if(this.customReticle.asset)s=Hp(this.customReticle.asset);else{this.customReticle.loadAssetAsync();return}else s=new ue(new Ld(.07,.09,32).rotateX(-Math.PI/2),new oi({side:hi})),s.name="AR Placement Reticle";if(Z4){const o=new bo(1);o.position.y+=.01,s.add(o)}this._reticle[t]=s,s.matrixAutoUpdate=!1,s.visible=!1}s.position.lerp(n.position,this.context.time.deltaTime/.1),s.quaternion.slerp(n.quaternion,this.context.time.deltaTime/.05),s.scale.set(r,r,r),this.customReticle&&this.applyViewBasedTransform(s),s.updateMatrix(),s.visible=!0,s.parent!==this.context.scene&&this.context.scene.add(s),this._placementStartTime<0&&(this._placementStartTime=this.context.time.realtimeSinceStartup)}onScaleChanged(){}onRevertSceneChanges(){var e;for(const t of this._reticle)t&&(t.visible=!1,t?.removeFromParent());this._reticle.length=0;for(let t=this._placementScene.children.length-1;t>=0;t--){const n=this._placementScene.children[t];this.context.scene.add(n)}(e=this._createdPlacementObject)==null||e.removeFromParent();for(const t of this._reparentedComponents)re.addComponent(t.originalObject,t.comp)}async onCreateAnchor(e,t){if(t.createAnchor===void 0){console.warn("Hit does not support creating an anchor",t),pt()&&Qi("Hit does not support creating an anchor");return}else{const n=await t.createAnchor(e.viewerPose.transform);e.running&&n&&(this._anchor=n)}}applyViewBasedTransform(e){const t=this.context.mainCamera,n=e,r=t.worldPosition,s=n.worldPosition;r.y=s.y,e.lookAt(r)}onApplyPose(e){var t,n,r,s;const o=(n=(t=bt.active)==null?void 0:t.rig)==null?void 0:n.gameObject;if(!o){console.warn("No rig object to place");return}(r=bt.active)!=null&&r.rigScale;const a=o.parent||this.context.scene;this._rigPlacementMatrix?(s=this._rigPlacementMatrix)==null||s.decompose(o.position,o.quaternion,o.scale):this._rigPlacementMatrix=o.matrix.clone(),this.applyViewBasedTransform(e),e.updateMatrix(),this.context.scene.add(e),e.attach(o),e.removeFromParent(),o.scale.set(this.arScale,this.arScale,this.arScale),o.position.multiplyScalar(this.arScale),o.updateMatrix(),this.invertForward&&o.matrix.premultiply(Tse),o.matrix.premultiply(this._startOffset),o.matrix.decompose(o.position,o.quaternion,o.scale),a.add(o)}}a0([x()],so.prototype,"arScale",1),a0([x()],so.prototype,"invertForward",2),a0([x(ni)],so.prototype,"customReticle",2),a0([x()],so.prototype,"useXRAnchor",2),a0([x()],so.prototype,"arTouchTransform",2);const QI=class{constructor(i){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 n=e.changedTouches[t],r=_O()&&n.clientY<window.innerHeight*.1;this.prev.has(n.identifier)||this.prev.set(n.identifier,{ignore:r,x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(n.identifier);if(s){const o=this.getPositionOnPlane(n.clientX,n.clientY);s.x=o.x,s.z=o.z,s.screenx=n.clientX,s.screeny=n.clientY}}}),h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1);for(let t=0;t<e.changedTouches.length;t++){const n=e.changedTouches[t];this.prev.delete(n.identifier)}}),h(this,"touchMove",e=>{if(!e.defaultPrevented&&this.isActive){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],n=this.prev.get(t.identifier);if(!n||n.ignore)return;const r=this.getPositionOnPlane(t.clientX,t.clientY),s=r.x-n.x,o=r.z-n.z;if(s===0&&o===0)return;this.oneFingerDrag&&this.addMovement(s,o),n.x=r.x,n.z=r.z,n.screenx=t.clientX,n.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],n=e.touches[1],r=this.prev.get(t.identifier),s=this.prev.get(n.identifier);if(!r||!s)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-n.clientY,t.clientX-n.clientX),a=Math.atan2(r.screeny-s.screeny,r.screenx-s.screenx),l=o-a;Math.abs(l)>.001&&this.addRotation(l)}if(this.twoFingerScale){const o=t.clientX-n.clientX,a=t.clientY-n.clientY,l=Math.sqrt(o*o+a*a),c=r.screenx-s.screenx,u=r.screeny-s.screeny,d=Math.sqrt(c*c+u*u),p=l-d;Math.abs(p)>2&&this.addScale(p)}r.screenx=t.clientX,r.screeny=t.clientY,s.screenx=n.clientX,s.screeny=n.clientY}}}),h(this,"_raycaster",new Au),h(this,"_intersection",new S),h(this,"_screenPos",new S),h(this,"_tempMatrix",new Ce),this.context=i,this.offset=new Ce,this.plane=new ss,this.plane.setFromNormalAndCoplanarPoint(QI.up,QI.zero)}reset(){this._scale=1,this.offset.identity()}get hasChanged(){return this._hasChanged}applyMatrixTo(i,e){this._hasChanged=!1,e?(this.offset.invert(),i.premultiply(this.offset)):i.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:za.Early}),this.context.input.addEventListener("pointerdown",this.onPointerDownLate,{queue:za.Late}),this.context.input.addEventListener("pointerup",this.onPointerUpEarly,{queue:za.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:za.Early}),this.context.input.removeEventListener("pointerdown",this.onPointerDownLate,{queue:za.Late}),this.context.input.removeEventListener("pointerup",this.onPointerUpEarly,{queue:za.Early}),window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}getPositionOnPlane(i,e){const t=this.context.mainCamera;return this._screenPos.x=i/window.innerWidth*2-1,this._screenPos.y=-(e/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(t),this._raycaster.set(t.position,this._screenPos.sub(t.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(i,e){i/=this._scale,e/=this._scale,i*=this.factor,e*=this.factor,this.offset.elements[12]+=i,this.offset.elements[14]+=e,(i!==0||e!==0)&&(this._hasChanged=!0)}addScale(i){i/=window.innerWidth,i*=-1,this._scale*=1+i,this._tempMatrix.makeScale(1-i,1-i,1-i),this.offset.premultiply(this._tempMatrix),i!==0&&(this._hasChanged=!0)}addRotation(i){i*=-1,this._tempMatrix.makeRotationY(i),this.offset.premultiply(this._tempMatrix),i!==0&&(this._hasChanged=!0)}};let wx=QI;h(wx,"up",new S(0,1,0)),h(wx,"zero",new S(0,0,0)),h(wx,"one",new S(1,1,1));const $4=class{constructor(){h(this,"_quicklookButton"),h(this,"_arButton"),h(this,"_vrButton"),h(this,"_sendToQuestButton")}static create(){return new $4}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 jp.getOrCreate().createQRCode()}createQuicklookButton(){if(this._quicklookButton)return this._quicklookButton;const i=document.createElement("button");return this._quicklookButton=i,i.dataset.needle="quicklook-button",i.innerText="Open in Quicklook",i.prepend(Ys("view_in_ar")),i.addEventListener("click",()=>{const e=re.findObjectOfType(Wn);e?(i.classList.add("this-mode-is-requested"),e.exportAndOpen().then(()=>{i.classList.remove("this-mode-is-requested")}).catch(t=>{i.classList.remove("this-mode-is-requested"),console.error(t)})):console.warn("No USDZExporter component found in the scene")}),this.hideElementDuringXRSession(i),i}createARButton(i){var e;if(this._arButton)return this._arButton;const t="immersive-ar",n=document.createElement("button");return this._arButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-ar-button",n.innerText="Enter AR",n.prepend(Ys("view_in_ar")),n.title="Click to start an AR session",n.addEventListener("click",()=>bt.start(t,i)),this.updateSessionSupported(n,t),this.listenToXRSessionState(n,t),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),bu()||(e=navigator.xr)==null||e.addEventListener("devicechange",()=>this.updateSessionSupported(n,t)),n}createVRButton(i){var e;if(this._vrButton)return this._vrButton;const t="immersive-vr",n=document.createElement("button");return this._vrButton=n,n.classList.add("webxr-button"),n.dataset.needle="webxr-vr-button",n.innerText="Enter VR",n.prepend(Ys("panorama_photosphere")),n.title="Click to start a VR session",n.addEventListener("click",()=>bt.start(t,i)),this.updateSessionSupported(n,t),this.listenToXRSessionState(n,t),this.hideElementDuringXRSession(n),this.isSecureConnection||(n.disabled=!0,n.title="WebXR requires a secure connection (HTTPS)"),bu()||(e=navigator.xr)==null||e.addEventListener("devicechange",()=>this.updateSessionSupported(n,t)),n}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(Ys("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),bu()||(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 jp.getOrCreate().createQRCode()}updateSessionSupported(i,e){if(!("xr"in navigator)){i.style.display="none";return}bt.isSessionSupported(e).then(t=>{i.style.display=t?"":"none",pt()&&!t&&console.log('[WebXR] "'+e+'" is not supported on this device \u2013 make sure your server runs using HTTPS and you have a device connected that supports '+e)})}hideElementDuringXRSession(i){Nb(e=>{i["previous-display"]=i.style.display,i.style.display="none"}),sM(e=>{i["previous-display"]!=null&&(i.style.display=i["previous-display"])})}listenToXRSessionState(i,e){e&&(bt.onSessionRequestStart(t=>{t.mode===e?i.classList.add("this-mode-is-requested"):(i["was-disabled"]=i.disabled,i.disabled=!0,i.classList.add("other-mode-is-requested"))}),bt.onSessionRequestEnd(t=>{i.classList.remove("this-mode-is-requested"),i.classList.remove("other-mode-is-requested"),i.disabled=i["was-disabled"]}))}};let Bf=$4;h(Bf,"_instance");var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,dc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ise(e,t,r),r};const pd=ee("debugtext");var Vn=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Vn||{}),ez=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(ez||{});class xs extends sd{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 Se(1,0,1)),h(this,"_text",""),h(this,"_fontSize",12),h(this,"_textMeshUi",null),h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(e=this.uiObject)==null||e.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(e){this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){pd&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,pd&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),pd&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){var e;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(e=this.canvas)==null||e.registerEventReceiver(this)}onDisable(){var e;super.onDisable(),(e=this.canvas)==null||e.unregisterEventReceiver(this)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var n,r,s;if(pd&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const u=this.uiObject.children[c];u.isUI&&(this.uiObject.remove(u),u.clear())}const l=new lb({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(n=this.uiObject)==null?void 0:n.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const u=new lb(c);(r=this.uiObject)==null||r.add(u)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const u=new lb(c);(s=this.uiObject)==null||s.add(u)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,n={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let s=0;s<this._textMeshUi.length;s++){if(e[s]===!0)continue;r=!0;const o=this._textMeshUi[s];o.textContent&&(N_(o,n),e[s]=!0)}if(!r)break;yield}}handleTag(e,t,n){if(!e.isEndTag){if(e.type.includes("color")){const r=new HI(e,{color:t.color});if(n.push(r),e.type.length>6){const s=parseInt("0x"+e.type.substring(7));t.color=s}else t.color=new Se(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new HI(e,{fontWeight:700});n.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new HI(e,{fontStyle:"italic"});n.push(r)}}}getText(e,t,n){return e.substring(t.endIndex,n.startIndex)}getNextTag(e,t=0){const n=e.indexOf("<",t),r=e.indexOf(">",n);if(n>=0&&r>=0){const s=e.substring(n+1,r);return{type:s,startIndex:n,endIndex:r+1,isEndTag:s.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const n=this.font,r=this.getFamilyNameWithCorrectSuffix(n,t);pd&&console.log("Selected font family:"+r);let s=hE.getFontFamily(r);switch(s||(s=hE.addFontFamily(r)),e.fontFamily=s,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=s.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=s.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var n;const r=e.lastIndexOf("-");if(r<0)return e;const s=(n=e.substring(r+1))==null?void 0:n.toLowerCase();if(Pse.includes(s))return pd&&console.warn("Unsupported font style: "+s),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=e.substring(0,r);switch(pd&&console.log("Select font: ",e,ez[t],a,l,c),t){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 e}}}dc([x()],xs.prototype,"alignment",2),dc([x()],xs.prototype,"verticalOverflow",2),dc([x()],xs.prototype,"horizontalOverflow",2),dc([x()],xs.prototype,"lineSpacing",2),dc([x()],xs.prototype,"supportRichText",2),dc([x(URL)],xs.prototype,"font",2),dc([x()],xs.prototype,"fontStyle",2),dc([x()],xs.prototype,"text",1),dc([x()],xs.prototype,"fontSize",1);class HI{constructor(e,t){h(this,"tag"),h(this,"previousValues"),this.tag=e,this.previousValues=t}}const Pse=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ih{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 r=this.font.map(s=>`"${s}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),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/${IT(this.material)}>`),t.closeBlock()}}h(Ih,"global_id",0);class Sx{static singleLine(e,t,n){const r=new Ih("text_"+Ih.getId());return r.content=e,t&&(r.pointSize=t),n&&(r.depth=n),r}static multiLine(e,t,n,r,s,o){const a=new Ih("text_"+Ih.getId());return a.content=e,a.width=t,a.height=n,a.horizontalAlignment=r,a.verticalAlignment=s,o!==void 0&&(a.wrapMode=o),a}}const Bse=new Ce().makeRotationY(Math.PI),Dse=new Ce().makeScale(-1,1,-1);class l0{get extensionName(){return"text"}onExportObject(e,t,n){}exportText(e,t,n){const r=re.getComponent(e,xs);if(!r)return;const s=re.getComponent(e,bs);let o=100,a=100;s&&(o=s.width,a=s.height),t.matrix=Bse.clone(),s&&t.matrix.premultiply(Dse);const l=r.color.clone();t.material=new ls({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=r.text;d=d.replace(/\r/g,""),d=d.replace(/\n/g,"\\n");const p=Sx.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.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 Vn.LowerLeft:case Vn.MiddleLeft:case Vn.UpperLeft:e.horizontalAlignment="left";break;case Vn.LowerCenter:case Vn.MiddleCenter:case Vn.UpperCenter:e.horizontalAlignment="center";break;case Vn.LowerRight:case Vn.MiddleRight:case Vn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Vn.LowerLeft:case Vn.LowerCenter:case Vn.LowerRight:e.verticalAlignment="bottom";break;case Vn.MiddleLeft:case Vn.MiddleCenter:case Vn.MiddleRight:e.verticalAlignment="middle";break;case Vn.UpperLeft:case Vn.UpperCenter:case Vn.UpperRight:e.verticalAlignment="top";break}}}class Cx{get extensionName(){return"tmui"}onExportObject(e,t,n){const r=re.getComponent(e,Mr);if(r&&r.activeAndEnabled&&r.renderMode===T4.WorldSpace){const s=new l0,o=re.getComponent(e,bs),a=re.getComponent(e,bh);if(o){o.width,o.height;const l=Bo.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=Bo.createEmpty();m.matrix.copy(f.matrix);const A=f.parent,v=!!A&&typeof A.textContent=="string"&&A.textContent.length>0;let g=p.get(A)||1;const y=re.getComponent(f,bh);if(y&&(g*=y.alpha),f instanceof ue&&v){const _=f[ko];_?s.exportText(_.gameObject,m,n):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",f)}if(f instanceof ue&&!v){const _=f.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const E=new Se,I=f.material.opacity;E.copy(f.material.color),m.material=new oi({color:E,opacity:I*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const b=d.get(A);if(!b){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}b.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let n=0,r=t.length/3;n<r;n++){const s=t[n*3];t[n*3]=t[n*3+2],t[n*3+2]=s}e.index.needsUpdate=!0}}const Ex=ee("debugusdz");function Ose(i,e){var t;const n=[],r=re.getComponentsInChildren(i,Sr),s=re.getComponentsInChildren(i,vs),o=new Array;if(e.injectImplicitBehaviours)for(const a of r){if(!a||!a.runtimeAnimatorController)continue;const l=a.runtimeAnimatorController.activeState;if(!l||!l.motion||!l.motion.clip||((t=l.motion.clip.tracks)==null?void 0:t.length)<1)continue;const c=new wf;c.animator=a,c.stateName=l.name,c.trigger="start",c.name="PlayAnimationOnClick_implicitAtStart_"+c.stateName;const u=new ge;re.addComponent(u,c),o.push(u),i.add(u)}else for(const a of r){if(!a||!a.runtimeAnimatorController)continue;Ex&&console.log(a);const l=[];for(const c of a.runtimeAnimatorController.enumerateActions()){Ex&&console.log(c);const u=c.getClip();l.includes(u)||l.push(u)}n.push({root:a.gameObject,clips:l})}for(const a of s){Ex&&console.log(a);const l=[];for(const c of a.animations)l.includes(c)||l.push(c);n.push({root:a.gameObject,clips:l})}Ex&&console.log("USDZ Animation Clips",n);for(const a of n)for(const l of a.clips)e.registerAnimation(a.root,l);return o}function kse(i,e){const t=re.getComponentsInChildren(i,en),n=re.getComponentsInChildren(i,_h),r=new Array;for(const s of n){if(!s.target)continue;const o=t.indexOf(s.target);o>-1&&t.splice(o,1)}for(const s of t){if(!s||!s.clip||s.volume<=0)continue;const o=new _h;o.target=s,o.name="PlayAudioOnClick_implicitAtStart_";const a=new ge;re.addComponent(a,o),console.log("implicit PlayAudioOnStart",a,o),r.push(a),i.add(a)}return r}function tz(i){const e=i.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 n=document.createElement("button");n.id="open-in-ar",n.innerText="Open in QuickLook",t.appendChild(n);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const s=document.createElement("img");return s.id="button",r.appendChild(s),i.domElement.shadowRoot.appendChild(t),r}var Lse=Object.defineProperty,Use=Object.getOwnPropertyDescriptor,Kr=(i,e,t,n)=>{for(var r=n>1?void 0:n?Use(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Lse(e,t,r),r};const Us=ee("debugusdz");class Rh{constructor(){h(this,"callToAction"),h(this,"checkoutTitle"),h(this,"checkoutSubtitle"),h(this,"callToActionURL")}}Kr([x()],Rh.prototype,"callToAction",2),Kr([x()],Rh.prototype,"checkoutTitle",2),Kr([x()],Rh.prototype,"checkoutSubtitle",2),Kr([x()],Rh.prototype,"callToActionURL",2);var VI;const WI=(VI=class extends Ie{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",i=>{i.preventDefault(),this.exportAndOpen()}),h(this,"_currentExportTasks",new Map),h(this,"lastCallback")}start(){var i,e,t;Us&&(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),!((e=(i=this.objectToExport)==null?void 0:i.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new ex),this.extensions.push(new zh),this.extensions.push(new l0),this.extensions.push(new Cx))}onEnable(){var i;const e=Sp(),t=Cp();(Us||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=tz(this.context),this.link.addEventListener("message",this.lastCallback)),Us&&$i("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var i,e,t;(i=this.button)==null||i.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),Us&&$i("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var i;let e=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(e+="-"+_N(),da()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=tz(this.context)),this.customUsdzFile)return Us&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e),null;const t=await this.export(this.objectToExport);return t?(Us&&console.log("USDZ generation done. Downloading as "+e),this.openInQuickLook(t,e),t):(console.warn("No object to export",this),null)}async export(i){if(!i)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(i);if(e)return e;const t=this.internalExport(i);return t instanceof Promise?(this._currentExportTasks.set(i,t),t.then(n=>(this._currentExportTasks.delete(i),n)).catch(n=>(this._currentExportTasks.delete(i),null))):t}async internalExport(i){Kt.start("export-usdz",{onProgress:p=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:p}}))}}),Kt.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),Kt.report("export-usdz",{message:"Load progressive textures",autoStep:5}),Kt.start("export-usdz-textures","export-usdz");const e=re.getComponentsInChildren(i,Sn),t=new Array;let n=0;for(const p of e){p.didAutomaticallyUpdateLODLevel=p.automaticallyUpdateLODLevel,p.automaticallyUpdateLODLevel=!1;for(const f of p.sharedMeshes)if(f){const m=p.loadProgressiveMeshes(f,0);m instanceof Promise&&t.push(new Promise((A,v)=>{m.then(()=>{n++,Kt.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:n,totalSteps:t.length}),A()}).catch(g=>v(g))}))}for(const f of p.sharedMaterials)if(f){const m=p.loadProgressiveTextures(f,0);m instanceof Promise&&t.push(new Promise((A,v)=>{m.then(()=>{n++,Kt.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:n,totalSteps:t.length}),A()}).catch(g=>v(g))}))}}Us&&$i("Progressive Loading: "+t.length),await Promise.all(t),Us&&$i("Progressive Loading: done"),Kt.end("export-usdz-textures");const r=ys.Global.Mask;ys.Global.Set(Ya.AR),this.applyWebARSessionRoot();const s=new Qte,o=[...this.extensions],a=new Ev(this.quickLookCompatible);o.push(a);const l={self:this,exporter:s,extensions:o,object:i};Kt.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:l})),Kt.report("export-usdz","auto export animations and audio sources");const c=new Array;this.autoExportAnimations&&c.push(...Ose(i,a)),this.extensions.find(p=>p.extensionName==="Audio")&&this.autoExportAudioSources&&c.push(...kse(i)),s.debug=Us,s.keepObject=p=>{const f=re.getComponent(p,Sn);return!(f&&!f.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"),Kt.report("export-usdz","Invoking exporter.parse");const u=await s.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize}),d=new Blob([u],{type:"model/vnd.usdz+zip"});Kt.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:l}));for(const p of c)re.destroy(p);for(const p of e){const f=p.didAutomaticallyUpdateLODLevel;f!=null&&(p.automaticallyUpdateLODLevel=f)}return ys.Global.Set(r),Kt.end("export-usdz"),d}openInQuickLook(i,e){const t=i instanceof Blob?URL.createObjectURL(i):i,n=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",n);const r=n.callToAction?encodeURIComponent(n.callToAction):"",s=n.checkoutTitle?encodeURIComponent(n.checkoutTitle):"",o=n.checkoutSubtitle?encodeURIComponent(n.checkoutSubtitle):"";this.link.href=t+`#callToAction=${r}&checkoutTitle=${s}&checkoutSubtitle=${o}&callToActionURL=${n.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(i,e){WI.save(i,e)}static save(i,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof i=="string"?t.href=i:t.href=URL.createObjectURL(i),t.download=e,t.click(),t.remove()}quicklookCallback(i){if(i?.data=="_apple_ar_quicklook_button_tapped"){Us&&Qi("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const t=new URLSearchParams(this.link.href);if(t){const n=t.get("callToActionURL");Us&&$i("Quicklook url: "+n),n&&(da()?globalThis.open(n,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",n))}}}}buildQuicklookOverlay(){var i,e,t,n,r,s;const o={};return this.customBranding&&Object.assign(o,this.customBranding),da()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),o.callToAction="Close",o.checkoutTitle="\u{1F335} Made with Needle",o.checkoutSubtitle="_"),(((i=o.callToAction)==null?void 0:i.length)||((e=o.checkoutTitle)==null?void 0:e.length)||((t=o.checkoutSubtitle)==null?void 0:t.length))&&((n=o.callToAction)!=null&&n.length||(o.callToAction="\0"),(r=o.checkoutTitle)!=null&&r.length||(o.checkoutTitle="\0"),(s=o.checkoutSubtitle)!=null&&s.length||(o.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:o})),o}applyWebARSessionRoot(){if(!this.objectToExport)return;let i=re.getComponentInParent(this.objectToExport,so);const e=i!=null;if(i||(i=re.getComponentInChildren(this.objectToExport,so)),Us&&console.log("applyWebARSessionRoot",i),!i){Us&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const t=e?this.objectToExport:i.gameObject,n=1/i.arScale;t.matrix.makeScale(n,n,n),i.invertForward&&t.matrix.multiply(WI.invertForwardMatrix)}createQuicklookButton(){const i=Bf.getOrCreate().createQuicklookButton();return i.parentNode||this.context.menu.appendChild(i),i}},h(VI,"invertForwardMatrix",new Ce().makeRotationY(Math.PI)),VI);let Wn=WI;Kr([x(ge)],Wn.prototype,"objectToExport",2),Kr([x()],Wn.prototype,"autoExportAnimations",2),Kr([x()],Wn.prototype,"autoExportAudioSources",2),Kr([x()],Wn.prototype,"exportFileName",2),Kr([x(URL)],Wn.prototype,"customUsdzFile",2),Kr([x(Rh)],Wn.prototype,"customBranding",2),Kr([x()],Wn.prototype,"anchoringType",2),Kr([x()],Wn.prototype,"maxTextureSize",2),Kr([x()],Wn.prototype,"planeAnchoringAlignment",2),Kr([x()],Wn.prototype,"interactive",2),Kr([x()],Wn.prototype,"allowCreateQuicklookButton",2),Kr([x()],Wn.prototype,"quickLookCompatible",2);class c0 extends Ie{constructor(){super(...arguments),h(this,"isUsed",!0),h(this,"usedBy",null)}}class qI extends Ie{}const iz=ee("debugdeletable");class Mx extends Za{}class XI extends Ie{constructor(){super(...arguments),h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=re.findObjectsOfType(Mx,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const n=re.getComponentInParent(this.gameObject,c0);n?iz&&console.warn("Can not delete object with usage marker",this.guid,n):(iz&&console.log("DESTROY",this.gameObject),A_(this.gameObject,this.context.connection))}}}}var Fse=Object.defineProperty,Nse=Object.getOwnPropertyDescriptor,fd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Fse(e,t,r),r};const nz=ee("debugpost");class _a extends Yr{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(){nz&&console.log("DOF: INIT"),this.focalLength.valueProcessor=t=>{const n=t/300,r=2;return Ze.lerp(r,.01,n)};const e=20;this.aperture.valueProcessor=t=>{const n=1-t/32;return Ze.lerp(1,e,n)}}onCreateEffect(){if(this.mode===0){nz&&console.warn("DepthOfField: Mode is set to Off");return}const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let n=1;ra()&&(n=.6),this.resolutionScale=new Bt(n*e)}const t=new ML(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=n=>{t.cocMaterial.worldFocusDistance=n},this.focalLength.onValueChanged=n=>t.cocMaterial.worldFocusRange=n,this.aperture.onValueChanged=n=>t.bokehScale=n,this.resolutionScale&&(this.resolutionScale.onValueChanged=n=>t.resolution.scale=n),[t]}unapply(){}}fd([x()],_a.prototype,"mode",2),fd([x(Bt)],_a.prototype,"focusDistance",2),fd([x(Bt)],_a.prototype,"focalLength",2),fd([x(Bt)],_a.prototype,"aperture",2),fd([x(Bt)],_a.prototype,"gaussianMaxRadius",2),fd([x(Bt)],_a.prototype,"resolutionScale",2),fd([x(Bt)],_a.prototype,"bokehScale",2),Fo("DepthOfField",_a);var zse=Object.defineProperty,jse=Object.getOwnPropertyDescriptor,Gse=(i,e,t,n)=>{for(var r=n>1?void 0:n?jse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zse(e,t,r),r};class Tx extends Ie{constructor(){super(...arguments),h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||re.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:ra()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Gse([x()],Tx.prototype,"visibleOn",2);class YI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Qse=Object.defineProperty,Hse=Object.getOwnPropertyDescriptor,md=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hse(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qse(e,t,r),r};const tl=ee("debugdrag");var rz=(i=>(i[i.XZPlane=0]="XZPlane",i[i.Attached=1]="Attached",i[i.HitNormal=2]="HitNormal",i[i.DynamicViewAngle=3]="DynamicViewAngle",i[i.SnapToSurfaces=4]="SnapToSurfaces",i[i.None=5]="None",i))(rz||{}),Ix;const il=(Ix=class extends Ie{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 S),h(this,"_marker",null),h(this,"_isDragging",!1),h(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(i){this.targetObject=i;for(const e of this._dragHandlers.values())e.setTargetObject(i)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new S,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=re.findObjectOfType(bi,this.context),this.gameObject.getComponentInParent(Ks)||this.gameObject.addComponent(Ks)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||i.mode!=="screen"||(i.event.mode==="tracked-pointer"||i.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const e=re.getComponentInParent(i.object,il);!e||e!==this||(il.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&i.mode==="screen"&&il.lastHovered===i.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(i){if(!(!this.allowEdit(this.gameObject)||i.used||(i.mode==="tracked-pointer"||i.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(il.lastHovered=i.object,i.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=i),il._active+=1;const e=new Wse(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(i.event.space,e),this.orbit&&(this.orbit.enabled=!1),e.onDragStart(i),this._dragHandlers.size===2){const t=this._dragHandlers.values(),n=t.next().value,r=t.next().value,s=new Vse(this,this.targetObject||this.gameObject,n,r);this._dragHandlers.set(this.gameObject,s),s.onDragStart(i)}i.use()}}onPointerMove(i){(this._isDragging||this._potentialDragStartEvt!==null)&&i.use()}onPointerUp(i){if(tl&&Ct.DrawLabel(i.point??this.gameObject.worldPosition,"POINTERUP:"+i.pointerId+", "+i.button,.03,3),!this.allowEdit(this.gameObject)||i.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(i.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(i)),e&&(il._active>0&&(il._active-=1),e.onDragEnd&&e.onDragEnd(i),this._dragHandlers.delete(i.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(i),i.use()),il._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const i of this._dragHandlers.values())i.collectMovementInfo&&i.collectMovementInfo(),i.getTotalMovement&&this._totalMovement.add(i.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const i=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(i)}for(const i of this._dragHandlers.values())i.onDragUpdate&&i.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new oz(this.context.mainCamera);else return;if(!i||!i.object)return;const e=re.getComponentInParent(i.object,il);if(!e||e!==this)return;const t=this.targetObject||this.gameObject;if(!t)return;this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const n=re.getComponentInChildren(t,uh);tl&&console.log("DRAG START",n,t),n&&(n.fastMode=!0,n?.requestOwnership()),this._marker=re.addComponent(t,c0),this._draggingRigidbodies.length=0;const r=re.getComponentsInChildren(t,Li);r&&this._draggingRigidbodies.push(...r)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities(),e.resetForcesAndTorques();const i=this.targetObject||this.gameObject;qo.markDirty(i)}onLastDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const t of this._draggingRigidbodies)t.setVelocity(t.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(tl&&console.log("DRAG END",e,e?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const t=re.getComponentInChildren(i.object,uh);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},h(Ix,"_active",0),h(Ix,"lastHovered"),Ix);let Go=il;md([x()],Go.prototype,"dragMode",2),md([x()],Go.prototype,"snapGridResolution",2),md([x()],Go.prototype,"keepRotation",2),md([x()],Go.prototype,"xrDragMode",2),md([x()],Go.prototype,"xrKeepRotation",2),md([x()],Go.prototype,"xrDistanceDragFactor",2),md([x()],Go.prototype,"showGizmo",2);class Vse{constructor(e,t,n,r){h(this,"handlerA"),h(this,"handlerB"),h(this,"context"),h(this,"settings"),h(this,"gameObject"),h(this,"_handlerAAttachmentPoint",new S),h(this,"_handlerBAttachmentPoint",new S),h(this,"_followObject"),h(this,"_manipulatorObject"),h(this,"_deviceMode"),h(this,"_followObjectStartWorldQuaternion",new Me),h(this,"_manipulatorPosOffset",new S),h(this,"_manipulatorRotOffset",new Me),h(this,"_manipulatorScaleOffset",new S),h(this,"_tempVec1",new S),h(this,"_tempVec2",new S),h(this,"_tempVec3",new S),h(this,"tempLookMatrix",new Ce),h(this,"_initialScale",new S),h(this,"_initialDistance",0);var s,o;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=n,this.handlerB=r,this._followObject=new ge,this._manipulatorObject=new ge,this.context.scene.add(this._manipulatorObject);const a=(o=(s=bt.active)==null?void 0:s.rig)==null?void 0:o.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),a&&(a.worldToLocal(this._tempVec1),a.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(tl&&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 \u2013 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),tl){this._followObject.add(new bo(2)),this._manipulatorObject.add(new bo(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),tl&&(Ct.DrawLabel(this._tempVec3.clone().add(new S(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 n=this.gameObject,r=this._followObject;r.updateMatrix(),r.updateMatrixWorld(!0);const s=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const u=this._followObject.worldPosition,d=this.settings.snapGridResolution;u.x=Math.round(u.x/d)*d,u.y=Math.round(u.y/d)*d,u.z=Math.round(u.z/d)*d,this._followObject.worldPosition=u,this._followObject.updateMatrix()}s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const o=Ze.clamp01(this.context.time.deltaTime*e*t),a=n.worldPosition;a.lerp(r.worldPosition,o),n.worldPosition=a;const l=n.worldQuaternion;l.slerp(r.worldQuaternion,o),n.worldQuaternion=l;const c=n.worldScale;c.lerp(r.worldScale,o),n.worldScale=c}setTargetObject(e){this.gameObject=e}}class Wse{constructor(e,t){h(this,"context"),h(this,"gameObject"),h(this,"settings"),h(this,"_lastRig"),h(this,"_followObject"),h(this,"_totalMovement",new S),h(this,"_totalMovementAlongRayDirection",0),h(this,"_grabStartDistance",0),h(this,"_deviceMode"),h(this,"_followObjectStartPosition",new S),h(this,"_followObjectStartQuaternion",new Me),h(this,"_followObjectStartWorldQuaternion",new Me),h(this,"_lastDragPosRigSpace"),h(this,"_tempVec",new S),h(this,"_tempMat",new Ce),h(this,"_hitPointInLocalSpace",new S),h(this,"_hitNormalInLocalSpace",new S),h(this,"_bottomCenter",new S),h(this,"_backCenter",new S),h(this,"_backBottomCenter",new S),h(this,"_bounds",new gi),h(this,"_dragPlane",new ss(new S(0,1,0))),h(this,"_draggedOverObject",null),h(this,"_draggedOverObjectLastSetUp",null),h(this,"_draggedOverObjectLastNormal",new S),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 e,t;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 n=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),n.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 r=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(r),this._grabStartDistance=r.distanceTo(n.worldPosition);const s=(t=(e=bt.active)==null?void 0:e.rig)==null?void 0:t.gameObject,o=s?.worldScale.x||1;this._grabStartDistance/=o,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,tl&&(Ct.DrawLine(r,n.worldPosition,65280,.5,!1),Ct.DrawLabel(n.worldPosition.add(new S(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 f=e.event.space,m=f.worldPosition;this.gameObject.worldToLocal(m),this._hitPointInLocalSpace.copy(m);const A=f.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),A.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(A)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=e.mode;const t=this._followObject.parent.worldForward,n=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,r=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(r),n){case 0:const f=new S(0,1,0);this.gameObject.parent&&f.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(f,r);break;case 2:const m=this._hitNormalInLocalSpace.clone();m.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(m,r);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,r);break;case 3:const A=new S(0,1,0),v=t,g=A.angleTo(v),y=.5;g>Math.PI/2+y||g<Math.PI/2-y?this._dragPlane.setFromNormalAndCoplanarPoint(new S(0,1,0),r):this._dragPlane.setFromNormalAndCoplanarPoint(t,r);break}const s=new gi,o=this.gameObject.parent,a=this.gameObject.position.clone(),l=this.gameObject.quaternion.clone(),c=this.gameObject.scale.clone(),u=this.gameObject.matrixWorld.clone();o&&o.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1),s.setFromObject(this.gameObject);const d=new S;s.getCenter(d);const p=new S;s.getSize(p),this._bottomCenter.copy(d.clone().add(new S(0,-p.y/2,0))),this._backCenter.copy(d.clone().add(new S(0,0,p.z/2))),this._backBottomCenter.copy(d.clone().add(new S(0,-p.y/2,p.z/2))),this._bounds.copy(s),o&&o.add(this.gameObject),this.gameObject.position.copy(a),this.gameObject.quaternion.copy(l),this.gameObject.scale.copy(c),this.gameObject.matrixWorld.copy(u),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var e,t;if(!this._followObject.parent)return;const n=this._followObject.parent;this._followObject.updateMatrix();const r=n.worldPosition,s=(t=(e=bt.active)==null?void 0:e.rig)==null?void 0:t.gameObject;s&&s.worldToLocal(r),(this._lastDragPosRigSpace===void 0||s!=this._lastRig)&&(this._lastDragPosRigSpace=r.clone(),this._lastRig=s),this._tempVec.copy(r).sub(this._lastDragPosRigSpace);const o=n.worldForward;if(s&&(this._tempMat.copy(s.matrixWorld).invert(),o.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=o.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(r),tl){let a=r;s&&(a=a.clone(),a.transformDirection(s.matrixWorld)),Ct.DrawRay(a,o,255)}}onDragUpdate(e){if(e>1)return;const t=this.gameObject,n=this._followObject.parent;this._followObject.updateMatrix();const r=n.worldPosition,s=n.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 p=new Ts(r,s);if(l==4){const v=new Io;v.ignore=[t];const g=this.context.physics.raycastFromRay(p,v);if(g.length>0){const y=g[0];if(this._draggedOverObject===y.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=y.object,this._draggedOverObjectDuration=0),y.face&&this._draggedOverObjectDuration>.15&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(y.face.normal)<.999999)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(y.face.normal);const b=new S,_=new S;this._bounds.getCenter(b),this._bounds.getSize(_),b.sub(_.multiplyScalar(.5).multiply(y.face.normal)),this._hitPointInLocalSpace.copy(b),this._hitNormalInLocalSpace.copy(y.face.normal),this._bounds.getCenter(b),this._bounds.getSize(_),b.add(_.multiplyScalar(.5).multiply(y.face.normal));const E=this._hitPointInLocalSpace.clone().add(b);this._followObject.localToWorld(E);const I=this._followObject.worldPosition.sub(E);this._dragPlane.setFromNormalAndCoplanarPoint(y.face.normal,y.point.sub(I))}}}if(l!==1&&p.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),tl&&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 f=Ze.clamp01(this.context.time.deltaTime*c*d),m=t.worldPosition;m.lerp(this._followObject.worldPosition,f),t.worldPosition=m;const A=t.worldQuaternion;if(A.slerp(this._followObject.worldQuaternion,f),t.worldQuaternion=A,tl){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 S(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6296
6301
|
|