@needle-tools/engine 3.35.0-alpha โ 3.35.0-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 +2 -1
- package/dist/needle-engine.js +28 -28
- package/dist/needle-engine.light.js +28 -28
- package/dist/needle-engine.light.min.js +3 -3
- package/dist/needle-engine.light.umd.cjs +3 -3
- package/dist/needle-engine.min.js +3 -3
- package/dist/needle-engine.umd.cjs +102 -102
- package/lib/engine/engine_gameobject.js +4 -4
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -1
- package/lib/engine-components/Component.js +2 -2
- package/lib/engine-components/Component.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/codegen/register_types.ts +2 -2
- package/src/engine/engine_gameobject.ts +4 -4
- package/src/engine-components/Component.ts +2 -2
|
@@ -4341,7 +4341,7 @@ void main() {
|
|
|
4341
4341
|
`;a+=n(o);const l=Object.keys(r);let c="";for(let u=0;u<l.length;u++){const d=l[u],f=r[d];if(Sm.has(f)){c+="";continue}Sm.set(f,!0),c+=d+":"+i(f,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=n(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
4343
|
}`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const iY=ne("nodevlogs");function yn(s,e=ao.Log){$a(e,s)}function $i(s){yn(s,ao.Warn)}function SN(s){yn(s,ao.Error)}let S1;function At(){return iY?!1:S1!==void 0?S1:Gr()}function nY(s){S1=s}const hu=new pd,Ys=new w,Qc=new w,Yi=new Ce,P2={X:new w(1,0,0),Y:new w(0,1,0),Z:new w(0,0,1)},JS={type:"change"},B2={type:"mouseDown"},D2={type:"mouseUp",mode:null},O2={type:"objectChange"};class sY extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const i=new SI;this._gizmo=i,this.add(i);const n=new hY;this._plane=n,this.add(n);const r=this;function o(_,y){let b=y;Object.defineProperty(r,_,{get:function(){return b!==void 0?b:y},set:function(E){b!==E&&(b=E,n[_]=E,i[_]=E,r.dispatchEvent({type:_+"-changed",value:E}),r.dispatchEvent(JS))}}),r[_]=y,n[_]=y,i[_]=y}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new w,l=new w,c=new Ce,u=new Ce,d=new w,f=new Ce,p=new w,m=new w,A=new w,v=0,g=new w;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",p),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new w,this._startNorm=new w,this._endNorm=new w,this._cameraScale=new w,this._parentPosition=new w,this._parentQuaternion=new Ce,this._parentQuaternionInv=new Ce,this._parentScale=new w,this._worldScaleStart=new w,this._worldQuaternionInv=new Ce,this._worldScale=new w,this._positionStart=new w,this._quaternionStart=new Ce,this._scaleStart=new w,this._getPointer=rY.bind(this),this._onPointerDown=aY.bind(this),this._onPointerHover=oY.bind(this),this._onPointerMove=lY.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&&hu.setFromCamera(e,this.camera);const t=KS(this._gizmo.picker[this.mode],hu);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&&hu.setFromCamera(e,this.camera);const t=KS(this._plane,hu,!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,B2.mode=this.mode,this.dispatchEvent(B2)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&hu.setFromCamera(e,this.camera);const o=KS(this._plane,hu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(n.position.applyQuaternion(Yi.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),r==="world"&&(n.parent&&n.position.add(Ys.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(Ys.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Qc.set(a,a,a)}else Ys.copy(this.pointStart),Qc.copy(this.pointEnd),Ys.applyQuaternion(this._worldQuaternionInv),Qc.applyQuaternion(this._worldQuaternionInv),Qc.divide(Ys),t.search("X")===-1&&(Qc.x=1),t.search("Y")===-1&&(Qc.y=1),t.search("Z")===-1&&(Qc.z=1);n.scale.copy(this._scaleStart).multiply(Qc),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Ys.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ys.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(P2[t]),Ys.copy(P2[t]),r==="local"&&Ys.applyQuaternion(this.worldQuaternion),Ys.cross(this.eye),Ys.length()===0?l=!0:this.rotationAngle=this._offset.dot(Ys.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(Yi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Yi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(JS),this.dispatchEvent(O2)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(D2.mode=this.mode,this.dispatchEvent(D2)),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(JS),this.dispatchEvent(O2),this.pointStart.copy(this.pointEnd))}getRaycaster(){return hu}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 rY(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function oY(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function aY(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function lY(s){this.enabled&&this.pointerMove(this._getPointer(s))}function cY(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function KS(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const u0=new Gi,Pi=new w(0,1,0),L2=new w(0,0,0),k2=new we,d0=new Ce,f_=new Ce,Ra=new w,F2=new we,tg=new w(1,0,0),Eu=new w(0,1,0),ig=new w(0,0,1),f0=new w,Cm=new w,Em=new w;class SI extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new ai({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Rn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const A=new Sn(0,.04,.1,12);A.translate(0,.05,0);const v=new Li(.08,.08,.08);v.translate(0,.04,0);const g=new wt;g.setAttribute("position",new ut([0,0,0,1,0,0],3));const _=new Sn(.0075,.0075,.5,3);_.translate(0,.25,0);function y(V,L){const k=new Jl(V,.0075,3,64,L*Math.PI*2);return k.rotateY(Math.PI/2),k.rotateX(Math.PI/2),k}function b(){const V=new wt;return V.setAttribute("position",new ut([0,0,0,1,1,1],3)),V}const E={X:[[new pe(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new pe(A,r),[-.5,0,0],[0,0,Math.PI/2]],[new pe(_,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new pe(A,o),[0,.5,0]],[new pe(A,o),[0,-.5,0],[Math.PI,0,0]],[new pe(_,o)]],Z:[[new pe(A,a),[0,0,.5],[Math.PI/2,0,0]],[new pe(A,a),[0,0,-.5],[-Math.PI/2,0,0]],[new pe(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new pe(new nc(.1,0),d.clone()),[0,0,0]]],XY:[[new pe(new Li(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new pe(new Li(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new pe(new Sn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new pe(new Sn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new pe(new Sn(.2,0,.6,4),i),[0,.3,0]],[new pe(new Sn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new pe(new Sn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new pe(new Sn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new pe(new nc(.2,0),i)]],XY:[[new pe(new Li(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new pe(new Li(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},T={START:[[new pe(new nc(.01,2),n),null,null,null,"helper"]],END:[[new pe(new nc(.01,2),n),null,null,null,"helper"]],DELTA:[[new Mn(b(),n),null,null,null,"helper"]],X:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mn(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mn(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new pe(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new pe(y(.5,.5),r)]],Y:[[new pe(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new pe(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new pe(y(.75,1),f),null,[0,Math.PI/2,0]]]},B={AXIS:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new pe(new Sa(.25,10,8),i)]],X:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new pe(new Jl(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new pe(new Jl(.75,.1,2,24),i)]]},R={X:[[new pe(v,r),[.5,0,0],[0,0,-Math.PI/2]],[new pe(_,r),[0,0,0],[0,0,-Math.PI/2]],[new pe(v,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new pe(v,o),[0,.5,0]],[new pe(_,o)],[new pe(v,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new pe(v,a),[0,0,.5],[Math.PI/2,0,0]],[new pe(_,a),[0,0,0],[Math.PI/2,0,0]],[new pe(v,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new pe(new Li(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new pe(new Li(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new pe(new Li(.1,.1,.1),d.clone())]]},Q={X:[[new pe(new Sn(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new pe(new Sn(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new pe(new Sn(.2,0,.6,4),i),[0,.3,0]],[new pe(new Sn(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new pe(new Sn(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new pe(new Sn(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new pe(new Li(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new pe(new Li(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new pe(new Li(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new pe(new Li(.2,.2,.2),i),[0,0,0]]]},z={X:[[new Mn(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Mn(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Mn(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function O(V){const L=new ge;for(const k in V)for(let G=V[k].length;G--;){const Y=V[k][G][0].clone(),$=V[k][G][1],re=V[k][G][2],ce=V[k][G][3],Re=V[k][G][4];Y.name=k,Y.tag=Re,$&&Y.position.set($[0],$[1],$[2]),re&&Y.rotation.set(re[0],re[1],re[2]),ce&&Y.scale.set(ce[0],ce[1],ce[2]),Y.updateMatrix();const ie=Y.geometry.clone();ie.applyMatrix4(Y.matrix),Y.geometry=ie,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),L.add(Y)}return L}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=O(E)),this.add(this.gizmo.rotate=O(C)),this.add(this.gizmo.scale=O(R)),this.add(this.picker.translate=O(M)),this.add(this.picker.rotate=O(S)),this.add(this.picker.scale=O(Q)),this.add(this.helper.translate=O(T)),this.add(this.helper.rotate=O(B)),this.add(this.helper.scale=O(z)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:f_;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const o=n[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Yi.setFromEuler(u0.set(0,0,0)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Yi.setFromEuler(u0.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Yi.setFromEuler(u0.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(Yi),Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Yi.setFromEuler(u0.set(0,Math.PI/2,0)),Pi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(k2.lookAt(L2,Pi,Eu)),o.quaternion.multiply(Yi),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Ys.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ys.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Ys),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Pi.copy(ig).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Pi.copy(tg).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Pi.copy(Eu).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(d0.copy(i),Pi.copy(this.eye).applyQuaternion(Yi.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(k2.lookAt(this.eye,L2,Eu)),o.name==="X"&&(Yi.setFromAxisAngle(tg,Math.atan2(-Pi.y,Pi.z)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi)),o.name==="Y"&&(Yi.setFromAxisAngle(Eu,Math.atan2(Pi.x,Pi.z)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi)),o.name==="Z"&&(Yi.setFromAxisAngle(ig,Math.atan2(Pi.y,Pi.x)),Yi.multiplyQuaternions(d0,Yi),o.quaternion.copy(Yi))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class hY extends pe{constructor(){super(new zn(1e5,1e5,2,2),new ai({visible:!1,wireframe:!0,side:mi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),f0.copy(tg).applyQuaternion(t==="local"?this.worldQuaternion:f_),Cm.copy(Eu).applyQuaternion(t==="local"?this.worldQuaternion:f_),Em.copy(ig).applyQuaternion(t==="local"?this.worldQuaternion:f_),Pi.copy(Cm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Pi.copy(this.eye).cross(f0),Ra.copy(f0).cross(Pi);break;case"Y":Pi.copy(this.eye).cross(Cm),Ra.copy(Cm).cross(Pi);break;case"Z":Pi.copy(this.eye).cross(Em),Ra.copy(Em).cross(Pi);break;case"XY":Ra.copy(Em);break;case"YZ":Ra.copy(f0);break;case"XZ":Pi.copy(Em),Ra.copy(Cm);break;case"XYZ":case"E":Ra.set(0,0,0);break}break;case"rotate":default:Ra.set(0,0,0)}Ra.length()===0?this.quaternion.copy(this.cameraQuaternion):(F2.lookAt(Ys.set(0,0,0),Ra,Pi),this.quaternion.setFromRotationMatrix(F2)),super.updateMatrixWorld(e)}}const uY=ne("debugpatch");function Gx(s,e,t,i){const n=uY===e;if(!t&&!i)return;const r=e+"___needle";fY(s,e,t,i);const o=Object.getOwnPropertyDescriptor(s,e),a=s[e];n&&console.log("Patch",s.constructor.name,e,o,a),o?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,e,o),typeof o.value=="function"&&(s[e]=N2(o.value,s,e))):(n&&console.log("Create patch with new property",s.constructor.name,e,o),Object.defineProperty(s,e,{set:function(l){if(typeof l=="function")this[r]=N2(l,s,e);else{const c=this[r];CN(s,e,this,c,l),this[r]=l,EN(s,e,this,c,l)}},get:function(){const l=this[r];return typeof l=="function"&&l[r]?l[r]:l}}))}function dY(s,e,t){const i=CI(s,e);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(n,1)}}const U2=Symbol("Needle:Patches:WrappedFunction");function N2(s,e,t){if(s[U2])return s;const i=function(...n){CN(e,t,this,...n);const r=s.apply(this,n);return EN(e,t,this,r,...n),r};return i[U2]=!0,i}const p_="Needle:Patches";function C1(){return globalThis[p_]||(globalThis[p_]=new WeakMap),globalThis[p_]}function CI(s,e){const t=C1().get(s);return t?t.get(e):null}function fY(s,e,t,i){let n=C1().get(s);n||(n=new Map,C1().set(s,n));let r=n.get(e);r||(r=[],n.set(e,r)),r.push({prefix:t,postfix:i})}function CN(s,e,t,...i){var r;if(!t)return;const n=CI(s,e);if(n)for(const o of n)(r=o.prefix)==null||r.call(t,...i)}function EN(s,e,t,i,...n){var o;if(!t)return;const r=CI(s,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...n)}const z2=Symbol("gltf-loader-internal-usage-tracker"),pY=ne("debugusers"),jg=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return jg._loadingProcesses>0}beforeRoot(){jg._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const r=t.call(this,i,n);return r.then(o=>(o&&(e._loadedObjects.add(o),o[z2]=e._loadingId),o)),r},null}afterRoot(e){jg._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[z2],t instanceof ge&&(t.parent||t instanceof pe&&(pY&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null));return null}};let Cg=jg;h(Cg,"_loadingProcesses",0);class MN{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const n=t[0];n&&n.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4344
|
-
`+n.src),e.preventDefault())}})}}const Hx=ne("trackresources");function TN(){return Hx==="dispose"}let gd=!0;Hx===0&&(gd=!1);function mY(s){gd=s}function IN(){return gd}const RN=Symbol("disposable");function EI(s,e){s&&(s[RN]=e,Wu&&console.warn("Set disposable",e,s))}const PN=Symbol("disposed");function gY(s){return s[PN]===!0}function Di(s){var e;if(s){if(s[RN]===!1){Wu&&console.warn("Object is marked as not disposable",s);return}if(s[PN]=!0,s instanceof ir)Di(s.environment),Di(s.background),Di(s.customDepthMaterial),Di(s.customDistanceMaterial);else if(s instanceof ga)Di(s.geometry),Di(s.material),Di(s.skeleton),Di(s.bindMatrix),Di(s.bindMatrixInverse),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof pe)Di(s.geometry),Di(s.material),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof wt){df(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Di(i)}}else if(s instanceof it||s instanceof xr)Wu&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Nt&&Di(t);else if(s instanceof Nt){df(s);for(const i of Object.keys(s)){const n=s[i];n instanceof Dt&&(Di(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof Dt?(Di(n),t[i]=null):n instanceof _e&&(Di(n.value),n.value=null)}}else s instanceof Dt?(df(s),df(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&df(s.source.data)):s instanceof Pp?(df(s.boneTexture),s.boneTexture=null):s instanceof Jv||!(s instanceof ge)&&Wu&&console.warn("Unknown object type",s)}}function df(s){s&&((Wu||TN()||Hx)&&console.warn("๐งจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof ic?s.data=null:s.dispose())}function BN(s){(s instanceof pe||s instanceof ga)&&(s.material=null,s.geometry=null)}const vY=new Set;function MI(s,e,t=null,i){if(i||(i=vY,i.clear()),!s)return i;const n=s[yv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&MI(r,!0,t,i));return i}function AY(s){return s[ng]}const Wu=ne("debugresourceusers")||ne("debugmemory"),yv=Symbol("needle-resource-users"),ng=Symbol("needle-resource-users-count");function cr(s,e){Gx(s,e,function(t,i){gd&&(db(yv,this,t,!1),db(yv,this,i,!0))})}gd&&(cr(pe.prototype,"material"),cr(pe.prototype,"geometry"),cr(Nt.prototype,"map"),cr(Nt.prototype,"bumpMap"),cr(Nt.prototype,"alphaMap"),cr(Nt.prototype,"normalMap"),cr(Nt.prototype,"displacementMap"),cr(Nt.prototype,"roughnessMap"),cr(Nt.prototype,"metalnessMap"),cr(Nt.prototype,"emissiveMap"),cr(Nt.prototype,"specularMap"),cr(Nt.prototype,"envMap"),cr(Nt.prototype,"lightMap"),cr(Nt.prototype,"aoMap"),cr(Nt.prototype,"gradientMap"));function yY(s){if(gd===!1)return;const e=s[yv];if(e)for(const t of e)db(yv,t,s,!1)}gd&&Gx(Nt.prototype,"dispose",function(){yY(this)});let E1=0;function db(s,e,t,i){if(E1>0)return;if(Array.isArray(t)){for(const r of t)db(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[ng]||0;r+=1,t[ng]=r,Wu&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[ng]||0;r>0&&(r-=1,t[ng]=r),Wu&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Cg.isLoading(t)||(Hx&&console.warn(`๐ด Removed all user of "${t.type}"`,t),TN()&&Di(t)))}t[s]=n}try{Gx(_c.prototype,"render",function(){E1++},function(){E1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var lA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(lA||{});const G2=ne("debugcomponentevents");class cA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),G2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(G2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(cA,"eventListeners",new Map);const DN=ne("debugdefines");Op('if(!globalThis[""3.35.0-
|
|
4344
|
+
`+n.src),e.preventDefault())}})}}const Hx=ne("trackresources");function TN(){return Hx==="dispose"}let gd=!0;Hx===0&&(gd=!1);function mY(s){gd=s}function IN(){return gd}const RN=Symbol("disposable");function EI(s,e){s&&(s[RN]=e,Wu&&console.warn("Set disposable",e,s))}const PN=Symbol("disposed");function gY(s){return s[PN]===!0}function Di(s){var e;if(s){if(s[RN]===!1){Wu&&console.warn("Object is marked as not disposable",s);return}if(s[PN]=!0,s instanceof ir)Di(s.environment),Di(s.background),Di(s.customDepthMaterial),Di(s.customDistanceMaterial);else if(s instanceof ga)Di(s.geometry),Di(s.material),Di(s.skeleton),Di(s.bindMatrix),Di(s.bindMatrixInverse),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof pe)Di(s.geometry),Di(s.material),Di(s.customDepthMaterial),Di(s.customDistanceMaterial),s.geometry=null,s.material=null;else if(s instanceof wt){df(s);for(const t of Object.keys(s.attributes)){const i=s.attributes[t];Di(i)}}else if(s instanceof it||s instanceof xr)Wu&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const t of s)t instanceof Nt&&Di(t);else if(s instanceof Nt){df(s);for(const i of Object.keys(s)){const n=s[i];n instanceof Dt&&(Di(n),s[i]=null)}const t=s.uniforms;if(t)for(const i of Object.keys(t)){const n=t[i];n instanceof Dt?(Di(n),t[i]=null):n instanceof _e&&(Di(n.value),n.value=null)}}else s instanceof Dt?(df(s),df(s.source),((e=s.source)==null?void 0:e.data)instanceof ImageBitmap&&df(s.source.data)):s instanceof Pp?(df(s.boneTexture),s.boneTexture=null):s instanceof Jv||!(s instanceof ge)&&Wu&&console.warn("Unknown object type",s)}}function df(s){s&&((Wu||TN()||Hx)&&console.warn("๐งจ FREE",s),s instanceof ImageBitmap?s.close():s instanceof ic?s.data=null:s.dispose())}function BN(s){(s instanceof pe||s instanceof ga)&&(s.material=null,s.geometry=null)}const vY=new Set;function MI(s,e,t=null,i){if(i||(i=vY,i.clear()),!s)return i;const n=s[yv];if(n)for(const r of n)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&MI(r,!0,t,i));return i}function AY(s){return s[ng]}const Wu=ne("debugresourceusers")||ne("debugmemory"),yv=Symbol("needle-resource-users"),ng=Symbol("needle-resource-users-count");function cr(s,e){Gx(s,e,function(t,i){gd&&(db(yv,this,t,!1),db(yv,this,i,!0))})}gd&&(cr(pe.prototype,"material"),cr(pe.prototype,"geometry"),cr(Nt.prototype,"map"),cr(Nt.prototype,"bumpMap"),cr(Nt.prototype,"alphaMap"),cr(Nt.prototype,"normalMap"),cr(Nt.prototype,"displacementMap"),cr(Nt.prototype,"roughnessMap"),cr(Nt.prototype,"metalnessMap"),cr(Nt.prototype,"emissiveMap"),cr(Nt.prototype,"specularMap"),cr(Nt.prototype,"envMap"),cr(Nt.prototype,"lightMap"),cr(Nt.prototype,"aoMap"),cr(Nt.prototype,"gradientMap"));function yY(s){if(gd===!1)return;const e=s[yv];if(e)for(const t of e)db(yv,t,s,!1)}gd&&Gx(Nt.prototype,"dispose",function(){yY(this)});let E1=0;function db(s,e,t,i){if(E1>0)return;if(Array.isArray(t)){for(const r of t)db(s,e,r,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let r=t[ng]||0;r+=1,t[ng]=r,Wu&&console.warn(`๐ข Added user of "${t.type}"`,e,t,r,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let r=t[ng]||0;r>0&&(r-=1,t[ng]=r),Wu&&console.warn(`๐ด Removed user of "${t.type}"`,e,t,r,"users:",n),r<=0&&(Cg.isLoading(t)||(Hx&&console.warn(`๐ด Removed all user of "${t.type}"`,t),TN()&&Di(t)))}t[s]=n}try{Gx(_c.prototype,"render",function(){E1++},function(){E1--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}var lA=(s=>(s.Added="component-added",s.Removing="removing-component",s))(lA||{});const G2=ne("debugcomponentevents");class cA{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),G2&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(G2&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}h(cA,"eventListeners",new Map);const DN=ne("debugdefines");Op('if(!globalThis[""3.35.0-beta.1""]) globalThis[""3.35.0-beta.1""] = "0.0.0";');Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');Op('if(!globalThis[""Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)""]) globalThis[""Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)""] = "unknown";');Op('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta.1";');Op('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');Op('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";');const tl="3.35.0-beta.1",Qx="undefined",TI="Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";DN&&console.log(`Engine version: ${tl} (generator: ${Qx})
|
|
4345
4345
|
Project built at ${TI}`);const cc="needle_isActiveInHierarchy",Iu="builtin_components",Eg="needle_editor_guid";function Op(s){try{(0,eval)(s)}catch(e){DN&&console.error(e)}}const _v=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),ON=Symbol("isUsingInstancing"),LN=Symbol("instancingRenderer"),M1=Symbol("instancingAutoUpdateBounds");class Aa{static isUsingInstancing(e){return e[ON]===!0}static getRenderer(e){return e[LN]||null}setAutoUpdateBounds(e,t){const i=Aa.getRenderer(e);i&&(i[M1]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[_v]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)Aa.markDirty(i,!0)}}function qu(s,e){try{e?s(e):s()}catch(t){return console.error(t),!1}return!0}const T1=ne("debugnewscripts"),_Y=ne("debughierarchy"),qi=[];function bY(){return qi.length>0}function fb(s){if(!(s.new_scripts.length<=0)){if(T1&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}qi.length=0,s.new_scripts.length>0&&qi.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.isComponent!==!0){(At()||T1)&&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),qi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),qi.splice(e,1),e--;continue}t.context=s,Mg(t.gameObject),II(t,s)}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed){Kl(qi[e],s),qi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),Mg(t.gameObject),t.activeAndEnabled&&qu(t.__internalAwake.bind(t)))}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed||t.enabled===!1||(Mg(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,qu(t.__internalEnable.bind(t)))}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}for(let e=0;e<qi.length;e++)try{const t=qi[e];if(t.destroyed||!t.gameObject)continue;s.new_script_start.push(t)}catch(t){console.error(t),Kl(qi[e],s),qi.splice(e,1),e--}qi.length=0;for(const e of s.new_scripts_post_setup_callbacks)e&&e();s.new_scripts_post_setup_callbacks.length=0}}function xY(s){s&&(s.__internalDisable(!0),Kl(s,s.context))}function kN(s,e){for(let t=0;t<s.new_script_start.length;t++)try{const i=s.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;qu(i.__internalAwake.bind(i)),i.enabled&&(qu(i.__internalEnable.bind(i)),qu(i.__internalStart.bind(i)),s.new_script_start.splice(t,1),t--)}catch(i){console.error(i),Kl(s.new_script_start[t],s),s.new_script_start.splice(t,1),t--}}function II(s,e){e.scripts.indexOf(s)===-1&&(e.scripts.push(s),s.earlyUpdate&&e.scripts_earlyUpdate.push(s),s.update&&e.scripts_update.push(s),s.lateUpdate&&e.scripts_lateUpdate.push(s),s.onBeforeRender&&e.scripts_onBeforeRender.push(s),s.onAfterRender&&e.scripts_onAfterRender.push(s),s.onPausedChanged&&e.scripts_pausedChanged.push(s),ZS(s,null)&&e.new_scripts_xr.push(s),ZS(s,"immersive-vr")&&e.scripts_immersive_vr.push(s),ZS(s,"immersive-ar")&&e.scripts_immersive_ar.push(s))}function Kl(s,e){Eo(s,e.new_scripts),Eo(s,e.new_script_start),Eo(s,e.scripts),Eo(s,e.scripts_earlyUpdate),Eo(s,e.scripts_update),Eo(s,e.scripts_lateUpdate),Eo(s,e.scripts_onBeforeRender),Eo(s,e.scripts_onAfterRender),Eo(s,e.scripts_pausedChanged),Eo(s,e.new_scripts_xr),Eo(s,e.scripts_immersive_vr),Eo(s,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(s)}function Eo(s,e){const t=e.indexOf(s);t>=0&&e.splice(t,1)}function ZS(s,e){var t;if(s){const i=s;if(i.onBeforeXR||i.onEnterXR||i.onUpdateXR||i.onLeaveXR||i.onXRControllerAdded||i.onXRControllerRemoved)return!(e!=null&&((t=i.supportsXR)==null?void 0:t.call(i,e))===!1)}return!1}function m_(s){if(s||(s=hi.Current.scene),!s){console.trace("Invalid call - no current context.");return}const e=Up(s);FN(s,e,!0)||(T1||At()?console.error(`Error updating hierarchy
|
|
@@ -5254,12 +5254,12 @@ Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
|
5254
5254
|
Start a coroutine from a component by calling "this.startCoroutine(myCoroutine())"`),t):(this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:e,main:t}),t)}unregisterCoroutineUpdate(e,t){if(!this.coroutines[t])return;const i=this.coroutines[t].findIndex(n=>n.main===e);i>=0&&this.coroutines[t].splice(i,1)}stopAllCoroutinesFrom(e){for(const t in this.coroutines){const i=this.coroutines[t];for(let n=i.length-1;n>=0;n--)i[n].comp===e&&i.splice(n,1)}}setCurrentCamera(e){var n;if(!e)return;if(e.cam||e.buildCamera(),!e.cam){console.warn("Camera component is missing camera",e);return}const t=this._cameraStack.indexOf(e);t>=0&&this._cameraStack.splice(t,1),this._cameraStack.push(e),this.mainCameraComponent=e;const i=e.cam;i.isPerspectiveCamera&&this.updateAspect(i),(n=this.mainCameraComponent)==null||n.applyClearFlagsIfIsActiveCamera()}removeCamera(e){if(!e)return;const t=this._cameraStack.indexOf(e);if(t>=0&&this._cameraStack.splice(t,1),this.mainCameraComponent===e&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(e,t){this._onBeforeRenderListeners.has(e.uuid)||(this._onBeforeRenderListeners.set(e.uuid,[]),e.onBeforeRender=this._createRenderCallbackWrapper(e,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(e.uuid).push(t)}removeBeforeRenderListener(e,t){if(this._onBeforeRenderListeners.has(e.uuid)){const i=this._onBeforeRenderListeners.get(e.uuid),n=i.indexOf(t);n>=0&&i.splice(n,1)}}addAfterRenderListener(e,t){var i;this._onAfterRenderListeners.has(e.uuid)||(this._onAfterRenderListeners.set(e.uuid,[]),e.onAfterRender=this._createRenderCallbackWrapper(e,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(e.uuid))==null||i.push(t)}removeAfterRenderListener(e,t){if(this._onAfterRenderListeners.has(e.uuid)){const i=this._onAfterRenderListeners.get(e.uuid),n=i.indexOf(t);n>=0&&i.splice(n,1)}}_createRenderCallbackWrapper(e,t){return(i,n,r,o,a,l)=>{const c=t.get(e.uuid);if(c)for(let u=0;u<c.length;u++){const d=c[u];d(i,n,r,o,a,l)}}}get isRendering(){return this._isRendering}setRequireDepth(e){this._requireDepthTexture=e}setRequireColor(e){this._requireColorTexture=e}get depthTexture(){var e;return((e=this._renderTarget)==null?void 0:e.depthTexture)||null}get opaqueColorTexture(){var e;return((e=this._renderTarget)==null?void 0:e.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const e=getComputedStyle(this.domElement);return e.visibility!=="hidden"&&e.display!=="none"&&e.opacity!=="0"}async internalOnCreate(e){var a,l,c,u,d;const t=++this._createId;xs&&console.log("Creating context",this.name,e);const i=globalThis["needle:dependencies:ready"];i instanceof Promise&&(xs&&console.log("Waiting for dependencies to be ready"),await i.catch(f=>{(xs||At())&&console.error("Needle Engine dependencies failed to load",f)}).then(()=>{xs&&console.log("Needle Engine dependencies are ready")})),this.clear(),this.isManagedExternally===!1&&(this.createNewRenderer(),(a=this.renderer)==null||a.setAnimationLoop(null)),await _a(1),Ui.Current=this,await hi.dispatchCallback(kn.ContextCreationStart,this);let n=!0,r;try{Ui.Current=this,e?r=await this.internalLoadInitialContent(t,e):r=[]}catch(f){console.error(f),n=!1}if(!n||t!==this._createId)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return xs&&console.warn("Context has no renderer (perhaps it was disconnected?",this.domElement.isConnected),!1;!this.isManagedExternally&&!this.domElement.shadowRoot&&this.domElement.prepend(this.renderer.domElement),Ui.Current=this,Ui.Current=this;for(let f=0;f<this.new_scripts.length;f++){const p=this.new_scripts[f];if(p.gameObject!==void 0&&p.gameObject!==null){p.gameObject.userData===void 0&&(p.gameObject.userData={}),p.gameObject.userData.components===void 0&&(p.gameObject.userData.components=[]);const m=p.gameObject.userData.components;m.includes(p)||m.push(p)}}if(this.post_setup_callbacks)for(let f=0;f<this.post_setup_callbacks.length;f++)Ui.Current=this,await this.post_setup_callbacks[f](this);if(!this.mainCamera){Ui.Current=this;let f=null;hd(this.scene,p=>{const m=p;if(m!=null&&m.isCamera){if(Mg(m.gameObject),!m.activeAndEnabled)return;if(m.tag==="MainCamera")return f=m,!0;f=m}}),f?this.setCurrentCamera(f):!hi.dispatchCallback(kn.MissingCamera,this,{files:r})&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(this.input.bindEvents(),Ui.Current=this,fb(this),this.physics.engine&&((l=this.physics.engine)==null||l.step(0),(c=this.physics.engine)==null||c.postStep()),!this.isManagedExternally&&this.composer&&this.mainCamera){const f=new jx(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(f),this.composer.setSize(this.domWidth,this.domHeight)}this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(u=this.domElement.shadowRoot)==null||u.appendChild(this._stats.dom)),xs&&ub(this.scene,!0),this.targetFrameRate===void 0?(xs&&console.warn("No target framerate set, using default",Ui.DefaultTargetFrameRate),this.targetFrameRate=Ui._defaultTargetFramerate):xs&&console.log("Target framerate set to",this.targetFrameRate),this._dispatchReadyAfterFrame=!0;const o=hi.dispatchCallback(kn.ContextCreated,this,{files:r});return o&&("internalSetLoadingMessage"in this.domElement&&typeof this.domElement.internalSetLoadingMessage=="function"&&((d=this.domElement)==null||d.internalSetLoadingMessage("finish loading")),await o),uu(this,kn.ContextCreated),xs&&console.log("Context Created...",this.renderer,this.renderer.domElement),this._isCreating=!1,this.isManagedExternally||this.restartRenderLoop(),o}async internalLoadInitialContent(e,t){var l,c;const i=new Array;if(t.files.length===0)return i;const n=[...t.files],r={name:"",progress:null,index:0,count:n.length},o=ya(),a=0;for(let u=0;u<n.length;u++){if(e!==this._createId){xs&&console.log("Aborting loading because create id changed",e,this._createId);break}const d=n[u];if(!d.includes(".glb")&&!d.includes(".gltf")){const p=`Needle Engine: found suspicious src "${d}"`;console.warn(p),Gr()&&$i(p)}(l=t==null?void 0:t.onLoadingStart)==null||l.call(this,u,d),xs&&console.log("Context Load "+d);const f=await o.loadSync(this,d,d,a,p=>{var m;r.name=d,r.progress=p,r.index=u,r.count=n.length,(m=t.onLoadingProgress)==null||m.call(this,r)});(c=t==null?void 0:t.onLoadingFinished)==null||c.call(this,u,d,f??null),f?i.push({src:d,file:f}):console.warn("Could not load file: "+d)}if(e!==this._createId){for(const u of i)if(u&&u.file)for(const d of u.file.scenes)ba(d,!0,!0)}else for(const u of i)u&&u.file&&this.scene.add(u.file.scene);return i}restartRenderLoop(){return this.renderer?this._isCreating?(console.warn("Can not start render loop while creating context"),!1):(this.renderer.setAnimationLoop((e,t)=>{this.isManagedExternally||this.update(e,t)}),!0):(console.error("Can not start render loop without renderer"),!1)}update(e,t){if(t===void 0&&(t=null),At()||xs||bY())try{this.internalStep(e,t),this._renderlooperrors=0}catch(i){this._renderlooperrors+=1,(At()||xs)&&(i instanceof Error||i instanceof TypeError)&&yn("Caught unhandled exception during render-loop - see console for details.",ao.Error),console.error("Frame #"+this.time.frame+`
|
|
5255
5255
|
`,i),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:i}))}else this.internalStep(e,t)}updatePhysics(e){this.internalUpdatePhysics(e)}internalStep(e,t){this.internalOnBeforeRender(e,t)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(e,t){var n;const i=t!==null&&this._xrFrame===null;if(this._xrFrame=t,i&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:t}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=e),this._accumulatedTime+=(e-this._lastTimestamp)/1e3,this._lastTimestamp=e;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return!1;this._accumulatedTime=0}if((n=this._stats)==null||n.begin(),Ui.Current=this,this.onHandlePaused())return!1;for(Ui.Current=this,this.time.update(),uee&&console.log("FPS",this.time.smoothedFps.toFixed(0)),fb(this),m_(this.scene),kN(this),uu(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const r=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(r)}if(this.pre_update_oneshot_callbacks){for(const r in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[r]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const r in this.pre_update_callbacks)this.pre_update_callbacks[r]();this._currentFrameEvent=0;for(let r=0;r<this.scripts_earlyUpdate.length;r++){const o=this.scripts_earlyUpdate[r];o.activeAndEnabled&&o.earlyUpdate!==void 0&&(Ui.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),uu(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const o=this.scripts_update[r];o.activeAndEnabled&&o.update!==void 0&&(Ui.Current=this,o.update())}if(this.executeCoroutines(1),uu(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const o=this.scripts_lateUpdate[r];o.activeAndEnabled&&o.lateUpdate!==void 0&&(Ui.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),uu(this,2),this.onHandlePaused()||(this.physicsSteps===void 0&&(this.physicsSteps=1),this.physics.engine&&this.physicsSteps>0&&this.internalUpdatePhysics(this.physicsSteps),this.onHandlePaused()))return!1;if(this.isVisibleToUser||this.runInBackground){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const o=this.scripts_onBeforeRender[r];o.activeAndEnabled&&o.onBeforeRender!==void 0&&(Ui.Current=this,o.onBeforeRender(t))}if(this.executeCoroutines(3),uu(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r](t)}return!0}internalUpdatePhysics(e){if(!this.physics.engine)return!1;const t=e,i=this.time.deltaTime/t;for(let n=0;n<t;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(i),this._currentFrameEvent=10,this.executeCoroutines(10);return this.physics.engine.postStep(),!0}internalOnRender(){this.isManagedExternally||(SY(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let e=0;e<this.scripts_onAfterRender.length;e++){const t=this.scripts_onAfterRender[e];t.activeAndEnabled&&t.onAfterRender!==void 0&&(Ui.Current=this,t.onAfterRender())}if(this.executeCoroutines(4),uu(this,4),this.post_render_callbacks)for(const e in this.post_render_callbacks)this.post_render_callbacks[e]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log(this.renderer.info.render.calls+" DrawCalls",`
|
|
5256
5256
|
Render:`,{...this.renderer.info.render},`
|
|
5257
|
-
Memory:`,{...this.renderer.info.memory})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),hi.dispatchCallback(kn.ContextFirstFrameRendered,this))}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){hee&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ui.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Yt(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Ip(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Dt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ht,this._renderTarget.texture.magFilter=Ht,this._renderTarget.texture.format=Ai)}const e=this._renderTarget;e.texture&&(e.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){var i;if(this.coroutines[e]){const n=this.coroutines[e];for(let r=0;r<n.length;r++)try{const o=n[r];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){dee&&console.log("Removing coroutine",o.comp,o.comp.enabled),n.splice(r,1),--r;continue}const l=o.chained;if(l&&l.length>0){const f=l[l.length-1].next();if(f.done&&l.pop(),t(f)&&(o.chained||(o.chained=[]),o.chained.push(f.value)),!f.done)continue}const c=o.main.next();if(c.done===!0){n.splice(r,1),--r;continue}const u=c.value;if(t(u)){if(u.next().done)continue;o.chained||(o.chained=[]),o.chained.push(u)}else if(u instanceof Promise){const d=u;o.chained||(o.chained=[]);const f=gz(d);(i=o.chained)==null||i.push(f);continue}}catch(o){console.error(o)}}function t(n){return!!(n&&n.next&&n.return)}}};let Ft=Ui;h(Ft,"_defaultTargetFramerate",{value:60}),h(Ft,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"});hi.registerCallback(kn.ContextCreated,s=>{const e=s.context;Nz(e),Fz(e)});const Rb=ne("debugcomponents"),JD="eff8ba80-635d-11ec-90d6-0242ac120003";class ds{constructor(e){h(this,"_originalSeed");h(this,"_seed");typeof e=="string"&&(e=ds.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return V2(e,JD);const t=this._seed;return this._seed-=1,V2(t.toString(),JD)}initialize(e){typeof e=="string"?this._seed=ds.hash(e):this._seed=e}static createFromString(e){return new ds(this.hash(e))}static hash(e){let t=0;for(let i=0;i<e.length;i++)t=e.charCodeAt(i)+((t<<5)-t);return t}}var Oz=(s=>(s.NewInstanceCreated="new-instance-created",s.InstanceDestroyed="instance-destroyed",s))(Oz||{});class Lz{constructor(e){h(this,"guid");this.guid=e}}function $x(s,e,t=!0){if(!s)return;const i=s;if(ba(s,t),!e){console.warn("Can not send destroy: No networking connection provided",s.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",s.guid);return}let n=s.guid;if(!n&&i.uuid&&(n=i.uuid),!n){console.warn("Can not send destroy: failed to find guid",s);return}const r=new Lz(n);e.send("instance-destroyed",r,ha.Queued)}function kz(s,e){const t=new Lz(s);e.send("instance-destroyed",t,ha.Queued)}function Fz(s){s.connection.beginListen("instance-destroyed",e=>{Rb&&console.log("[Remote] Destroyed",s.scene,e);const t=gA(e.guid,s.scene);t&&ba(t)})}class mee{constructor(e,t,i){h(this,"filename");h(this,"hash");h(this,"size");this.filename=e,this.hash=t,this.size=i}}class Uz{constructor(e,t){h(this,"guid");h(this,"originalGuid");h(this,"seed");h(this,"visible");h(this,"hostData");h(this,"dontSave");h(this,"parent");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"preventCreation");this.originalGuid=e,this.guid=t}}function tR(s,e,t,i){var l;const n=s;if(!n.guid)return console.warn("Can not instantiate: No guid",n),null;if(e.context||(e.context=Ft.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const r=e?{...e}:null,{instance:o,seed:a}=gee(n,e);if(o){const c=o;if(c.guid){Rb&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const u=new Uz(n.guid,c.guid);u.seed=a,r&&(r.position&&(u.position={x:r.position.x,y:r.position.y,z:r.position.z}),r.rotation&&(u.rotation={x:r.rotation.x,y:r.rotation.y,z:r.rotation.z,w:r.rotation.w}),r.scale&&(u.scale={x:r.scale.x,y:r.scale.y,z:r.scale.z})),u.position||(u.position={x:c.position.x,y:c.position.y,z:c.position.z}),u.rotation||(u.rotation={x:c.quaternion.x,y:c.quaternion.y,z:c.quaternion.z,w:c.quaternion.w}),u.scale||(u.scale={x:c.scale.x,y:c.scale.y,z:c.scale.z}),u.visible=n.visible,r!=null&&r.parent&&(typeof r.parent=="string"?u.parent=r.parent:u.parent=r.parent.guid),u.hostData=t,i===!1&&(u.dontSave=!0),(l=e==null?void 0:e.context)==null||l.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return o}function ew(){return Math.random()*9999999}function Nz(s){s.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,s.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const i=new Ea;e.position&&(i.position=new w(e.position.x,e.position.y,e.position.z)),e.rotation&&(i.rotation=new Ce(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(i.scale=new w(e.scale.x,e.scale.y,e.scale.z)),i.parent=e.parent,e.seed&&(i.idProvider=new ds(e.seed)),i.visible=e.visible,i.context=s,Rb&&s.alias&&console.log("[Remote] instantiate in: "+s.alias);const n=Np(t,i);n&&(e.parent==="scene"&&s.scene.add(n),Rb&&console.log("[Remote] new instance","gameobject:",n==null?void 0:n.guid,t))})}function gee(s,e){const t=ew(),i=e??new Ea;i.idProvider=new ds(t);const n=Np(s,i);return{seed:t,instance:n}}const zz={};function Gz(s,e){zz[s]=e}async function vee(s,e){const t=zz[s];if(t!=null){const i=await t(s);if(i)return i}return Hz(s,e)}function Hz(s,e){if(e===null||!s)return null;if(e.guid===s)return e;if(e.children)for(const t of e.children){const i=Hz(s,t);if(i)return i}return null}const w_=ne("debuggetcomponent"),S_=ne("debuginstantiate");var Qz=(s=>(s[s.None=0]="None",s[s.HideInHierarchy=1]="HideInHierarchy",s[s.HideInInspector=2]="HideInInspector",s[s.DontSaveInEditor=4]="DontSaveInEditor",s[s.NotEditable=8]="NotEditable",s[s.DontSaveInBuild=16]="DontSaveInBuild",s[s.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",s[s.DontSave=52]="DontSave",s[s.HideAndDontSave=61]="HideAndDontSave",s))(Qz||{});class Ea{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}clone(){var t,i,n;const e=new Ea;return e.idProvider=this.idProvider,e.parent=this.parent,e.keepWorldPosition=this.keepWorldPosition,e.position=(t=this.position)==null?void 0:t.clone(),e.rotation=(i=this.rotation)==null?void 0:i.clone(),e.scale=(n=this.scale)==null?void 0:n.clone(),e}cloneAssign(e){var t,i,n;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(i=e.rotation)==null?void 0:i.clone(),this.scale=(n=e.scale)==null?void 0:n.clone()}}function Up(s){return s.visible}function Og(s,e){return typeof e=="number"&&(e=e>.5),s.visible=e,s.visible}function Vz(s){return s[cc]||tw(s)}function jz(s,e){s[ON]=e}function tw(s){return Aa.isUsingInstancing(s)}function gA(s,e){return gp(s,e,!0,!0)}const Wz=Symbol("isDestroyed");function cd(s){return s[Wz]}function qz(s,e){s[Wz]=e}const sM=Symbol("isDontDestroy");function rM(s,e=!0){s[sM]=e}const C_=[],E_=[];function ba(s,e=!0,t=!1){C_.length=0,E_.length=0,oM(s,e,t,!0);for(const i of C_)i.gameObject=null,i.context=null;for(const i of E_)qz(i,!0),t&&Di(i),BN(i);E_.length=0,C_.length=0}function oM(s,e=!0,t=!1,i=!0){var a;if(s==null)return;const n=s;if(n.isComponent){if(n[sM])return;C_.push(n);const l=n.gameObject;n.__internalDisable(),n.__internalDestroy(),n.gameObject=l;return}if(s[sM])return;const r=s;w_&&console.log(r),E_.push(r);const o=(a=r.userData)==null?void 0:a.components;if(o!=null&&Array.isArray(o)){let l=o.length;for(let c=0;c<o.length;c++){const u=o[c];oM(u,e,t,!1),o.length<l&&(l=o.length,c--)}}if(e&&r.children)for(const l of r.children)oM(l,e,t,!1);i&&r.removeFromParent()}function hd(s,e,t=!0){return Xz(s,e,t)}function*iR(s,e,t=!1,i=999,n=0){if(s!=null&&s.userData.components&&!(n>i)){for(const r of s.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of s.children)yield*iR(r,e,!0,i,n+1)}}function Xz(s,e,t,i=0){var n;if(s){if(s.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((n=s.userData)!=null&&n.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&s.children){const r=i+1;for(let o=0;o<s.children.length;o++){const a=s.children[o];if(!a)continue;const l=Xz(a,e,t,r);if(l!==void 0)return l}}}}function Np(s,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Ea,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),w_&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new ds(Date.now()));const n=[],r={},o={},a=Yz(i,s,t,n,r,o);a&&(yee(r),Aee(o,r)),w_&&(ub(s,!0),ub(a,!0));const l={};for(const c in n){const u=n[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,w_&&console.log(u.name,u.guid)),Zx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in n){const u=n[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return fb(i),a}function Yz(s,e,t,i,n,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const l=e.clone(!1);if(iw(l),e.userData=o,e.children=a,n[e.uuid]={original:e,clone:l},S_&&console.log("ADD",e,l),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:l}),(t==null?void 0:t.visible)!==void 0&&(l.visible=t.visible),t!=null&&t.idProvider){l.uuid=t.idProvider.generateUUID();const d=l;d&&(d.guid=l.uuid)}e.animations&&e.animations.length>0&&(l.animations=[...e.animations]);const c=e.parent;if(c&&c.add(l),t!=null&&t.position?tr(l,t.position):l.position.copy(e.position),t!=null&&t.rotation?Vo(l,t.rotation):l.quaternion.copy(e.quaternion),t!=null&&t.scale?l.scale.copy(t.scale):l.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=gp(t.parent,s.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,l):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(l.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];l.userData.components=f;for(let p=0;p<d.length;p++){const m=d[p],A=new m.constructor;_p(A,m),m[Eg]!==void 0&&(A[Eg]=m[Eg]),f.push(A),A.gameObject=l,i.push(A),cA.dispatchComponentLifecycleEvent(lA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=Yz(s,f,t,i,n,r);p&&l.add(p)}return l}function Aee(s,e){for(const t in s){const i=s[t],n=i.original,r=n.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(n.bindMatrix),o.bindMatrixInverse.copy(n.bindMatrixInverse);const c=[];l.bones=c;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;c.push(p)}}for(const t in s){const i=s[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function yee(s){var e;for(const t in s){const n=s[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const u=[];o[l]=u;for(let d=0;d<c.length;d++){const f=c[d];if(typeof f!="object"){u.push(f);continue}const p=KD(o,l,f,s);p!==void 0?u.push(p):u.push(f)}}else if(typeof c=="object"){const u=KD(o,l,c,s);u!==void 0&&(o[l]=u)}}}}function KD(s,e,t,i){var n,r;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(n=i[a])==null?void 0:n.clone;if(!l){S_&&console.log("reference did not change",e,s,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return S_&&console.log(e,a),l.userData.components[c];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,l=(r=i[a])==null?void 0:r.clone;if(l)return S_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone();if(t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const Jz=new Map;function _ee(s,e){if(!s)return;if(!e){console.warn("No prototype found",s,s.prototype,s.constructor);return}const t=Jz.get(e);t&&t.apply(s)}function bee(s){const e=xee(s.prototype);Jz.set(s,e)}function xee(s){return new wee(s)}class wee{constructor(e){h(this,"$symbol");h(this,"extensions");h(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=Object.getOwnPropertyDescriptor(e,i);n&&this.descriptors.push(n)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=this.descriptors[t];n&&Object.defineProperty(e,i,n)}}}}function iw(s){s&&s.isObject3D===!0&&_ee(s,ge)}ge.prototype.SetActive=function(s){this.visible=s};ge.prototype.setActive=function(s){this.visible=s};ge.prototype.destroy=function(){ba(this)};ge.prototype.addComponent=function(s,e){return Yu(this,s,e)};ge.prototype.addNewComponent=function(s,e){return Yu(this,s,e)};ge.prototype.removeComponent=function(s){return nR(this,s)};ge.prototype.getOrAddComponent=function(s,e){return nw(this,s,e)};ge.prototype.getComponent=function(s){return zp(this,s)};ge.prototype.getComponents=function(s,e){return vA(this,s,e)};ge.prototype.getComponentInChildren=function(s){return AA(this,s)};ge.prototype.getComponentsInChildren=function(s,e){return yA(this,s,e)};ge.prototype.getComponentInParent=function(s){return Cv(this,s)};ge.prototype.getComponentsInParent=function(s,e){return sw(this,s,e)};Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Up(this)},set:function(s){Og(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"transform")||Object.defineProperty(ge.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof SI?kt(this.object):kt(this)},set:function(s){tr(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof SI?Mi(this.object):Mi(this)},set:function(s){Vo(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return oA(this)},set:function(s){wI(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return an(this)},set:function(s){Av(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return En().set(0,0,1).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return En().set(1,0,0).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return En().set(0,1,0).applyQuaternion(Mi(this))}});bee(ge);const See=ne("debuggetcomponent"),ZD=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(s){return s==null||s.isObject3D?s:s.object&&s.object.isObject3D?s.object:s}function nR(s,e){if(!s||!s.userData.components)return e;const t=s.userData.components.indexOf(e);return t<0||(cA.dispatchComponentLifecycleEvent(lA.Removing,e),e.gameObject=null,s.userData.components.splice(t,1)),e}function nw(s,e,t){const i=zp(s,e);return i||Yu(s,e,t)}const Kz=new ds("addComponentIdProvider");function bh(s,e,t=!0){s.userData||(s.userData={}),s.userData.components||(s.userData.components=[]),s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),iw(s),Zx(e);try{t&&e.__internalAwake&&(Mg(s),e.activeAndEnabled&&e.__internalAwake()),cA.dispatchComponentLifecycleEvent(lA.Added,e)}catch(i){console.error(i)}return e}function Yu(s,e,t,i){if(typeof e=="function"){const n=new e;t&&n.__internalNewInstanceCreated(t);let r=!0;return(i==null?void 0:i.callAwake)!=null&&(r=i.callAwake),bh(s,n,r)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===s)return e;if(e.gameObject&&e.gameObject.userData.components){const n=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(n,1)}if(!s.userData.components)s.userData.components=[];else if(s.userData.components.includes(e))return e;return s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),t&&e._internalInit(t),Zx(e),e}function Zz(s){if(s.gameObject&&s.gameObject.userData.components){const e=s.gameObject.userData.components.indexOf(s);s.gameObject.userData.components.splice(e,1)}s.__internalDisable&&s.__internalDisable(),Kl(s,s.context??Ft.Current),s.destroy(),s.gameObject=null}let $D=!1;function $z(s,e,t){var i;if(s==null)return null;if(!s.isObject3D)return console.error("Object is not object3D"),null;if(!((i=s==null?void 0:s.userData)!=null&&i.components)||(typeof e=="string"&&($D||($D=!0,console.warn(`Accessing components by name is not supported.
|
|
5257
|
+
Memory:`,{...this.renderer.info.memory})),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),hi.dispatchCallback(kn.ContextFirstFrameRendered,this))}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){hee&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ui.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Yt(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Ip(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Dt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ht,this._renderTarget.texture.magFilter=Ht,this._renderTarget.texture.format=Ai)}const e=this._renderTarget;e.texture&&(e.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){var i;if(this.coroutines[e]){const n=this.coroutines[e];for(let r=0;r<n.length;r++)try{const o=n[r];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){dee&&console.log("Removing coroutine",o.comp,o.comp.enabled),n.splice(r,1),--r;continue}const l=o.chained;if(l&&l.length>0){const f=l[l.length-1].next();if(f.done&&l.pop(),t(f)&&(o.chained||(o.chained=[]),o.chained.push(f.value)),!f.done)continue}const c=o.main.next();if(c.done===!0){n.splice(r,1),--r;continue}const u=c.value;if(t(u)){if(u.next().done)continue;o.chained||(o.chained=[]),o.chained.push(u)}else if(u instanceof Promise){const d=u;o.chained||(o.chained=[]);const f=gz(d);(i=o.chained)==null||i.push(f);continue}}catch(o){console.error(o)}}function t(n){return!!(n&&n.next&&n.return)}}};let Ft=Ui;h(Ft,"_defaultTargetFramerate",{value:60}),h(Ft,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"});hi.registerCallback(kn.ContextCreated,s=>{const e=s.context;Nz(e),Fz(e)});const Rb=ne("debugcomponents"),JD="eff8ba80-635d-11ec-90d6-0242ac120003";class ds{constructor(e){h(this,"_originalSeed");h(this,"_seed");typeof e=="string"&&(e=ds.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return V2(e,JD);const t=this._seed;return this._seed-=1,V2(t.toString(),JD)}initialize(e){typeof e=="string"?this._seed=ds.hash(e):this._seed=e}static createFromString(e){return new ds(this.hash(e))}static hash(e){let t=0;for(let i=0;i<e.length;i++)t=e.charCodeAt(i)+((t<<5)-t);return t}}var Oz=(s=>(s.NewInstanceCreated="new-instance-created",s.InstanceDestroyed="instance-destroyed",s))(Oz||{});class Lz{constructor(e){h(this,"guid");this.guid=e}}function $x(s,e,t=!0){if(!s)return;const i=s;if(ba(s,t),!e){console.warn("Can not send destroy: No networking connection provided",s.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",s.guid);return}let n=s.guid;if(!n&&i.uuid&&(n=i.uuid),!n){console.warn("Can not send destroy: failed to find guid",s);return}const r=new Lz(n);e.send("instance-destroyed",r,ha.Queued)}function kz(s,e){const t=new Lz(s);e.send("instance-destroyed",t,ha.Queued)}function Fz(s){s.connection.beginListen("instance-destroyed",e=>{Rb&&console.log("[Remote] Destroyed",s.scene,e);const t=gA(e.guid,s.scene);t&&ba(t)})}class mee{constructor(e,t,i){h(this,"filename");h(this,"hash");h(this,"size");this.filename=e,this.hash=t,this.size=i}}class Uz{constructor(e,t){h(this,"guid");h(this,"originalGuid");h(this,"seed");h(this,"visible");h(this,"hostData");h(this,"dontSave");h(this,"parent");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"preventCreation");this.originalGuid=e,this.guid=t}}function tR(s,e,t,i){var l;const n=s;if(!n.guid)return console.warn("Can not instantiate: No guid",n),null;if(e.context||(e.context=Ft.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const r=e?{...e}:null,{instance:o,seed:a}=gee(n,e);if(o){const c=o;if(c.guid){Rb&&console.log("[Local] new instance","gameobject:",o==null?void 0:o.guid);const u=new Uz(n.guid,c.guid);u.seed=a,r&&(r.position&&(u.position={x:r.position.x,y:r.position.y,z:r.position.z}),r.rotation&&(u.rotation={x:r.rotation.x,y:r.rotation.y,z:r.rotation.z,w:r.rotation.w}),r.scale&&(u.scale={x:r.scale.x,y:r.scale.y,z:r.scale.z})),u.position||(u.position={x:c.position.x,y:c.position.y,z:c.position.z}),u.rotation||(u.rotation={x:c.quaternion.x,y:c.quaternion.y,z:c.quaternion.z,w:c.quaternion.w}),u.scale||(u.scale={x:c.scale.x,y:c.scale.y,z:c.scale.z}),u.visible=n.visible,r!=null&&r.parent&&(typeof r.parent=="string"?u.parent=r.parent:u.parent=r.parent.guid),u.hostData=t,i===!1&&(u.dontSave=!0),(l=e==null?void 0:e.context)==null||l.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return o}function ew(){return Math.random()*9999999}function Nz(s){s.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,s.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const i=new Ea;e.position&&(i.position=new w(e.position.x,e.position.y,e.position.z)),e.rotation&&(i.rotation=new Ce(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(i.scale=new w(e.scale.x,e.scale.y,e.scale.z)),i.parent=e.parent,e.seed&&(i.idProvider=new ds(e.seed)),i.visible=e.visible,i.context=s,Rb&&s.alias&&console.log("[Remote] instantiate in: "+s.alias);const n=Np(t,i);n&&(e.parent==="scene"&&s.scene.add(n),Rb&&console.log("[Remote] new instance","gameobject:",n==null?void 0:n.guid,t))})}function gee(s,e){const t=ew(),i=e??new Ea;i.idProvider=new ds(t);const n=Np(s,i);return{seed:t,instance:n}}const zz={};function Gz(s,e){zz[s]=e}async function vee(s,e){const t=zz[s];if(t!=null){const i=await t(s);if(i)return i}return Hz(s,e)}function Hz(s,e){if(e===null||!s)return null;if(e.guid===s)return e;if(e.children)for(const t of e.children){const i=Hz(s,t);if(i)return i}return null}const w_=ne("debuggetcomponent"),S_=ne("debuginstantiate");var Qz=(s=>(s[s.None=0]="None",s[s.HideInHierarchy=1]="HideInHierarchy",s[s.HideInInspector=2]="HideInInspector",s[s.DontSaveInEditor=4]="DontSaveInEditor",s[s.NotEditable=8]="NotEditable",s[s.DontSaveInBuild=16]="DontSaveInBuild",s[s.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",s[s.DontSave=52]="DontSave",s[s.HideAndDontSave=61]="HideAndDontSave",s))(Qz||{});class Ea{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}clone(){var t,i,n;const e=new Ea;return e.idProvider=this.idProvider,e.parent=this.parent,e.keepWorldPosition=this.keepWorldPosition,e.position=(t=this.position)==null?void 0:t.clone(),e.rotation=(i=this.rotation)==null?void 0:i.clone(),e.scale=(n=this.scale)==null?void 0:n.clone(),e}cloneAssign(e){var t,i,n;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(i=e.rotation)==null?void 0:i.clone(),this.scale=(n=e.scale)==null?void 0:n.clone()}}function Up(s){return s.visible}function Og(s,e){return typeof e=="number"&&(e=e>.5),s.visible=e,s.visible}function Vz(s){return s[cc]||tw(s)}function jz(s,e){s[ON]=e}function tw(s){return Aa.isUsingInstancing(s)}function gA(s,e){return gp(s,e,!0,!0)}const Wz=Symbol("isDestroyed");function cd(s){return s[Wz]}function qz(s,e){s[Wz]=e}const sM=Symbol("isDontDestroy");function rM(s,e=!0){s[sM]=e}const C_=[],E_=[];function ba(s,e=!0,t=!1){C_.length=0,E_.length=0,oM(s,e,!0);for(const i of C_)i.gameObject=null,i.context=null;for(const i of E_)qz(i,!0),t&&Di(i),BN(i);E_.length=0,C_.length=0}function oM(s,e=!0,t=!0){var o;if(s==null)return;const i=s;if(i.isComponent){if(i[sM])return;C_.push(i);const a=i.gameObject;i.__internalDisable(),i.__internalDestroy(),i.gameObject=a;return}if(s[sM])return;const n=s;w_&&console.log(n),E_.push(n);const r=(o=n.userData)==null?void 0:o.components;if(r!=null&&Array.isArray(r)){let a=r.length;for(let l=0;l<r.length;l++){const c=r[l];oM(c,e,!1),r.length<a&&(a=r.length,l--)}}if(e&&n.children)for(const a of n.children)oM(a,e,!1);t&&n.removeFromParent()}function hd(s,e,t=!0){return Xz(s,e,t)}function*iR(s,e,t=!1,i=999,n=0){if(s!=null&&s.userData.components&&!(n>i)){for(const r of s.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of s.children)yield*iR(r,e,!0,i,n+1)}}function Xz(s,e,t,i=0){var n;if(s){if(s.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((n=s.userData)!=null&&n.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&s.children){const r=i+1;for(let o=0;o<s.children.length;o++){const a=s.children[o];if(!a)continue;const l=Xz(a,e,t,r);if(l!==void 0)return l}}}}function Np(s,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Ea,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),w_&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new ds(Date.now()));const n=[],r={},o={},a=Yz(i,s,t,n,r,o);a&&(yee(r),Aee(o,r)),w_&&(ub(s,!0),ub(a,!0));const l={};for(const c in n){const u=n[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,w_&&console.log(u.name,u.guid)),Zx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in n){const u=n[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return fb(i),a}function Yz(s,e,t,i,n,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const l=e.clone(!1);if(iw(l),e.userData=o,e.children=a,n[e.uuid]={original:e,clone:l},S_&&console.log("ADD",e,l),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:l}),(t==null?void 0:t.visible)!==void 0&&(l.visible=t.visible),t!=null&&t.idProvider){l.uuid=t.idProvider.generateUUID();const d=l;d&&(d.guid=l.uuid)}e.animations&&e.animations.length>0&&(l.animations=[...e.animations]);const c=e.parent;if(c&&c.add(l),t!=null&&t.position?tr(l,t.position):l.position.copy(e.position),t!=null&&t.rotation?Vo(l,t.rotation):l.quaternion.copy(e.quaternion),t!=null&&t.scale?l.scale.copy(t.scale):l.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=gp(t.parent,s.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,l):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(l.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];l.userData.components=f;for(let p=0;p<d.length;p++){const m=d[p],A=new m.constructor;_p(A,m),m[Eg]!==void 0&&(A[Eg]=m[Eg]),f.push(A),A.gameObject=l,i.push(A),cA.dispatchComponentLifecycleEvent(lA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=Yz(s,f,t,i,n,r);p&&l.add(p)}return l}function Aee(s,e){for(const t in s){const i=s[t],n=i.original,r=n.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(n.bindMatrix),o.bindMatrixInverse.copy(n.bindMatrixInverse);const c=[];l.bones=c;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;c.push(p)}}for(const t in s){const i=s[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function yee(s){var e;for(const t in s){const n=s[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const u=[];o[l]=u;for(let d=0;d<c.length;d++){const f=c[d];if(typeof f!="object"){u.push(f);continue}const p=KD(o,l,f,s);p!==void 0?u.push(p):u.push(f)}}else if(typeof c=="object"){const u=KD(o,l,c,s);u!==void 0&&(o[l]=u)}}}}function KD(s,e,t,i){var n,r;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(n=i[a])==null?void 0:n.clone;if(!l){S_&&console.log("reference did not change",e,s,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return S_&&console.log(e,a),l.userData.components[c];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,l=(r=i[a])==null?void 0:r.clone;if(l)return S_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone();if(t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const Jz=new Map;function _ee(s,e){if(!s)return;if(!e){console.warn("No prototype found",s,s.prototype,s.constructor);return}const t=Jz.get(e);t&&t.apply(s)}function bee(s){const e=xee(s.prototype);Jz.set(s,e)}function xee(s){return new wee(s)}class wee{constructor(e){h(this,"$symbol");h(this,"extensions");h(this,"descriptors");this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=Object.getOwnPropertyDescriptor(e,i);n&&this.descriptors.push(n)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const i=this.extensions[t],n=this.descriptors[t];n&&Object.defineProperty(e,i,n)}}}}function iw(s){s&&s.isObject3D===!0&&_ee(s,ge)}ge.prototype.SetActive=function(s){this.visible=s};ge.prototype.setActive=function(s){this.visible=s};ge.prototype.destroy=function(){ba(this)};ge.prototype.addComponent=function(s,e){return Yu(this,s,e)};ge.prototype.addNewComponent=function(s,e){return Yu(this,s,e)};ge.prototype.removeComponent=function(s){return nR(this,s)};ge.prototype.getOrAddComponent=function(s,e){return nw(this,s,e)};ge.prototype.getComponent=function(s){return zp(this,s)};ge.prototype.getComponents=function(s,e){return vA(this,s,e)};ge.prototype.getComponentInChildren=function(s){return AA(this,s)};ge.prototype.getComponentsInChildren=function(s,e){return yA(this,s,e)};ge.prototype.getComponentInParent=function(s){return Cv(this,s)};ge.prototype.getComponentsInParent=function(s,e){return sw(this,s,e)};Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Up(this)},set:function(s){Og(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"transform")||Object.defineProperty(ge.prototype,"transform",{get:function(){return this}});Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof SI?kt(this.object):kt(this)},set:function(s){tr(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof SI?Mi(this.object):Mi(this)},set:function(s){Vo(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return oA(this)},set:function(s){wI(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return an(this)},set:function(s){Av(this,s)}});Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return En().set(0,0,1).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return En().set(1,0,0).applyQuaternion(Mi(this))}});Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return En().set(0,1,0).applyQuaternion(Mi(this))}});bee(ge);const See=ne("debuggetcomponent"),ZD=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(s){return s==null||s.isObject3D?s:s.object&&s.object.isObject3D?s.object:s}function nR(s,e){if(!s||!s.userData.components)return e;const t=s.userData.components.indexOf(e);return t<0||(cA.dispatchComponentLifecycleEvent(lA.Removing,e),e.gameObject=null,s.userData.components.splice(t,1)),e}function nw(s,e,t){const i=zp(s,e);return i||Yu(s,e,t)}const Kz=new ds("addComponentIdProvider");function bh(s,e,t=!0){s.userData||(s.userData={}),s.userData.components||(s.userData.components=[]),s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),iw(s),Zx(e);try{t&&e.__internalAwake&&(Mg(s),e.activeAndEnabled&&e.__internalAwake()),cA.dispatchComponentLifecycleEvent(lA.Added,e)}catch(i){console.error(i)}return e}function Yu(s,e,t,i){if(typeof e=="function"){const n=new e;t&&n.__internalNewInstanceCreated(t);let r=!0;return(i==null?void 0:i.callAwake)!=null&&(r=i.callAwake),bh(s,n,r)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===s)return e;if(e.gameObject&&e.gameObject.userData.components){const n=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(n,1)}if(!s.userData.components)s.userData.components=[];else if(s.userData.components.includes(e))return e;return s.userData.components.push(e),e.gameObject=s,(e.guid===void 0||e.guid==="invalid")&&(e.guid=Kz.generateUUID()),t&&e._internalInit(t),Zx(e),e}function Zz(s){if(s.gameObject&&s.gameObject.userData.components){const e=s.gameObject.userData.components.indexOf(s);s.gameObject.userData.components.splice(e,1)}s.__internalDisable&&s.__internalDisable(),Kl(s,s.context??Ft.Current),s.destroy(),s.gameObject=null}let $D=!1;function $z(s,e,t){var i;if(s==null)return null;if(!s.isObject3D)return console.error("Object is not object3D"),null;if(!((i=s==null?void 0:s.userData)!=null&&i.components)||(typeof e=="string"&&($D||($D=!0,console.warn(`Accessing components by name is not supported.
|
|
5258
5258
|
Please use the component type instead. This may keep working in local development but it will fail when bundling your application.
|
|
5259
5259
|
|
|
5260
5260
|
You can import other modules your main module to get access to types
|
|
5261
5261
|
or if you use npmdefs you can make types available globally using globalThis:
|
|
5262
|
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),ZD()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let n=0;n<s.userData.components.length;n++){const r=s.userData.components[n];let o=Object.getPrototypeOf(r);for(;o;){if(o===e.prototype)if(ZD()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(r);else return r;o=Object.getPrototypeOf(o)}}return t||null}function zp(s,e){const t=$z(s,e);return t?Array.isArray(t)?t[0]:t:null}function vA(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),$z(s,e,t),t}function AA(s,e,t){var n;const i=zp(s,e);if(t===!1&&(i==null?void 0:i.enabled)===!1)return null;if(i)return i;for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++){const o=AA(s.children[r],e);if(o)return o}return null}function yA(s,e,t,i=!0){var n;t||(t=[]),i&&(t.length=0),vA(s,e,t,!1);for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++)yA(s.children[r],e,t,!1);return t}function Cv(s,e){if(!s)return null;if(Array.isArray(s)){for(let i=0;i<s.length;i++){const n=Cee(s[i]),r=Cv(n,e);if(r)return r}return null}const t=zp(s,e);return t||(s.parent?Cv(s.parent,e):null)}function sw(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),s?(vA(s,e,t,!1),s.parent?sw(s.parent,e,t,!1):t):t}function e4(s,e,t){if(!s)return null;if(!e&&(e=Ft.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let i=e;if(i.isScene||(i=e==null?void 0:e.scene),!i)return null;for(const n in i.children){const r=i.children[n];if(t===!1&&r[cc]===!1)continue;const o=AA(r,s);if(o)return o}return null}function t4(s,e,t){if(!s)return e;if(e||(e=[]),e.length=0,!t&&(t=Ft.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const i=t.isScene===!0||t.isObject3D===!0?t:t==null?void 0:t.scene;if(!i)return e;for(const n in i.children){const r=i.children[n];if(r.constructor==s)return r;yA(r,s,e,!1)}return e}class oe extends ge{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return cd(t)}static setActive(t,i,n=!0){t&&(Og(t,i),m_(t),i&&n&&kN(Ft.Current,t))}static isActiveSelf(t){return Up(t)}static isActiveInHierarchy(t){return Vz(t)}static markAsInstancedRendered(t,i){jz(t,i)}static isUsingInstancing(t){return tw(t)}static foreachComponent(t,i,n=!0){return hd(t,i,n)}static instantiateSynced(t,i){return t?tR(t,i):null}static instantiate(t,i=null){return Np(t,i)}static destroySynced(t,i,n=!0){if(!t)return;const r=t;i=i??Ft.Current,$x(r,i.connection,n)}static destroy(t,i=!0,n=!0){return ba(t,i,n)}static add(t,i,n){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}n||(n=Ft.Current),i.add(t),Og(t,!0),m_(t),n?oe.foreachComponent(t,r=>{II(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Og(t,!1),m_(t),oe.foreachComponent(t,n=>{xY(n)},!0))}static invokeOnChildren(t,i,...n){this.invoke(t,i,!0,n)}static invoke(t,i,n=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},n)}static addNewComponent(t,i,n,r=!0){return Yu(t,i,n,{callAwake:r})}static addComponent(t,i,n,r){return Yu(t,i,n,r)}static moveComponent(t,i){return Yu(t,i)}static removeComponent(t){return nR(t.gameObject,t),t}static getOrAddComponent(t,i){return nw(t,i)}static getComponent(t,i){return t===null?null:zp(t,i)}static getComponents(t,i,n=null){return t===null?n??[]:vA(t,i,n)}static findByGuid(t,i){return gA(t,i)}static findObjectOfType(t,i,n=!0){return e4(t,i??Ft.Current,n)}static findObjectsOfType(t,i){const n=[];return t4(t,n,i),n}static getComponentInChildren(t,i){return AA(t,i)}static getComponentsInChildren(t,i,n=null){return yA(t,i,n??void 0)}static getComponentInParent(t,i){return Cv(t,i)}static getComponentsInParent(t,i,n=null){return sw(t,i,n)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var n;const i=(n=t==null?void 0:t.userData)==null?void 0:n.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ka;let Me=(Ka=class{constructor(e){h(this,"__context");h(this,"__name");h(this,"gameObject");h(this,"guid","invalid");h(this,"sourceId");h(this,"__didAwake",!1);h(this,"__didStart",!1);h(this,"__didEnable",!1);h(this,"__isEnabled");h(this,"__destroyed",!1);h(this,"_eventListeners",new Map);this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e)}get isComponent(){return!0}get context(){return this.__context??Ft.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[cc];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[cc]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Un.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Un.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(At()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((e=this.onDestroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),Zz(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){At()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return kt(this.gameObject)}set worldPosition(e){tr(this.gameObject,e)}setWorldPosition(e,t,i){ad(this.gameObject,e,t,i)}get worldQuaternion(){return Mi(this.gameObject)}set worldQuaternion(e){Vo(this.gameObject,e)}setWorldQuaternion(e,t,i,n){yI(this.gameObject,e,t,i,n)}get worldEuler(){return bI(this.gameObject)}set worldEuler(e){xI(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){aA(this.gameObject,e,t,i,n)}get forward(){return Ka._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ka._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ka._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ka,"_forward",new w),h(Ka,"_right",new w),h(Ka,"_up",new w),Ka);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Me,Component:Me,GameObject:oe},Symbol.toStringTag,{value:"Module"})),Ru=ne("debugloading"),Dm=ne("debugloadingrendering"),eO=ne("debuglicense");class Mee{constructor(){h(this,"className");h(this,"additionalClasses")}}let Om=0,tO;function sR(s){Ru&&console.log(s.progress.loaded.toFixed(0)+"/"+s.progress.total.toFixed(0),s);const e=s.count,t=s.progress.total;t===0||t===void 0?(tO!==s.name&&(Om=0),tO=s.name,Om+=(1-Om)*.001,Ru&&$i("Loading "+s.name+" did not report total size")):Om=s.progress.loaded/t;const i=s.index/e+Om/e;return et.clamp01(i)}const Vb=class{constructor(e,t){h(this,"loadingProgress",0);h(this,"_element");h(this,"_progress",0);h(this,"_allowCustomLoadingElement",!0);h(this,"_loadingElement");h(this,"_loadingTextContainer",null);h(this,"_loadingBar",null);h(this,"_messageContainer",null);h(this,"_loadingElementOptions");h(this,"_progressLoop");this._element=e,this._loadingElementOptions=t}async onLoadingBegin(e){const t=this._element.shadowRoot||this._element;if(Ru&&console.warn("Begin Loading"),!this._loadingElement){for(let i=0;i<t.children.length;i++){const n=t.children[i];if(n.classList.contains(Vb.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){Ru&&console.warn("Remove custom loading container"),t.removeChild(n);continue}this._loadingElement=this.createLoadingElement(n)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",t.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(e??"")}onLoadingUpdate(e,t){var n;if(!((n=this._loadingElement)!=null&&n.parentNode))return;let i=0;typeof e=="number"?i=e:("index"in e&&(i=sR(e)),!t&&"name"in e&&this.setMessage("loading "+e.name)),this.loadingProgress=i,t&&this.setMessage(t),this.updateDisplay()}onLoadingFinished(){Ru&&console.warn("Finished Loading"),Dm||(this.loadingProgress=1,this.onDoneLoading())}setMessage(e){this._messageContainer&&(this._messageContainer.innerText=e)}smoothProgressLoop(){if(this._progressLoop)return;let e=1/12;Dm&&(e=1/500,typeof Dm=="number"&&(e*=Dm)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Dm&&(e=.9),this._progress=et.lerp(this._progress,this.loadingProgress,e*this.loadingProgress),this.updateDisplay()},e)}onDoneLoading(){this._loadingElement&&(Ru&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const e=this._progress,t=(e*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=e*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=t)}createLoadingElement(e){var m,A;Ru&&!e&&console.log("Creating loading element"),this._loadingElement=e||document.createElement("div");let t=this._element.getAttribute("loading-style");(!t||t==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?t="dark":t="light");const i=cl();if(!e&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",t==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",this._loadingElement.style.fontFamily="Roboto, sans-serif, Arial",t==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",i&&this._element)){const v=this._element.getAttribute("loading-background-color");v&&(this._loadingElement.style.backgroundColor=v);const g=this._element.getAttribute("loading-text-color");g&&(this._loadingElement.style.color=g)}const n=((m=this._loadingElementOptions)==null?void 0:m.className)??Vb.LoadingContainerClassName;if(this._loadingElement.classList.add(n),(A=this._loadingElementOptions)!=null&&A.additionalClasses)for(const v of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(v);const r=document.createElement("div");this._loadingElement.appendChild(r);const o=document.createElement("img"),a=120;o.style.width=`${a}px`,o.style.height=`${a}px`,o.style.borderRadius="80px",o.style.padding="20px",o.style.margin="-20px",o.style.marginBottom="-10px",o.style.userSelect="none",o.style.objectFit="contain",o.style.transition="transform 2s ease-out, opacity 1s ease-in-out",o.style.transform="translateY(10px)",setTimeout(()=>{o.style.transform="translateY(0px)"},1),o.src=$$;let l=!1;if(i&&this._element){const v=this._element.getAttribute("loading-logo-src");v&&(l=!0,o.src=v)}l||(o.style.cursor="pointer",o.style.pointerEvents="all",o.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),r.appendChild(o);const c=document.createElement("div");c.style.cssText=`
|
|
5262
|
+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),ZD()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let n=0;n<s.userData.components.length;n++){const r=s.userData.components[n];let o=Object.getPrototypeOf(r);for(;o;){if(o===e.prototype)if(ZD()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(r);else return r;o=Object.getPrototypeOf(o)}}return t||null}function zp(s,e){const t=$z(s,e);return t?Array.isArray(t)?t[0]:t:null}function vA(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),$z(s,e,t),t}function AA(s,e,t){var n;const i=zp(s,e);if(t===!1&&(i==null?void 0:i.enabled)===!1)return null;if(i)return i;for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++){const o=AA(s.children[r],e);if(o)return o}return null}function yA(s,e,t,i=!0){var n;t||(t=[]),i&&(t.length=0),vA(s,e,t,!1);for(let r=0;r<((n=s==null?void 0:s.children)==null?void 0:n.length);r++)yA(s.children[r],e,t,!1);return t}function Cv(s,e){if(!s)return null;if(Array.isArray(s)){for(let i=0;i<s.length;i++){const n=Cee(s[i]),r=Cv(n,e);if(r)return r}return null}const t=zp(s,e);return t||(s.parent?Cv(s.parent,e):null)}function sw(s,e,t,i=!0){return t||(t=[]),i&&(t.length=0),s?(vA(s,e,t,!1),s.parent?sw(s.parent,e,t,!1):t):t}function e4(s,e,t){if(!s)return null;if(!e&&(e=Ft.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let i=e;if(i.isScene||(i=e==null?void 0:e.scene),!i)return null;for(const n in i.children){const r=i.children[n];if(t===!1&&r[cc]===!1)continue;const o=AA(r,s);if(o)return o}return null}function t4(s,e,t){if(!s)return e;if(e||(e=[]),e.length=0,!t&&(t=Ft.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const i=t.isScene===!0||t.isObject3D===!0?t:t==null?void 0:t.scene;if(!i)return e;for(const n in i.children){const r=i.children[n];if(r.constructor==s)return r;yA(r,s,e,!1)}return e}class oe extends ge{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return cd(t)}static setActive(t,i,n=!0){t&&(Og(t,i),m_(t),i&&n&&kN(Ft.Current,t))}static isActiveSelf(t){return Up(t)}static isActiveInHierarchy(t){return Vz(t)}static markAsInstancedRendered(t,i){jz(t,i)}static isUsingInstancing(t){return tw(t)}static foreachComponent(t,i,n=!0){return hd(t,i,n)}static instantiateSynced(t,i){return t?tR(t,i):null}static instantiate(t,i=null){return Np(t,i)}static destroySynced(t,i,n=!0){if(!t)return;const r=t;i=i??Ft.Current,$x(r,i.connection,n)}static destroy(t,i=!0){return ba(t,i)}static add(t,i,n){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}n||(n=Ft.Current),i.add(t),Og(t,!0),m_(t),n?oe.foreachComponent(t,r=>{II(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Og(t,!1),m_(t),oe.foreachComponent(t,n=>{xY(n)},!0))}static invokeOnChildren(t,i,...n){this.invoke(t,i,!0,n)}static invoke(t,i,n=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},n)}static addNewComponent(t,i,n,r=!0){return Yu(t,i,n,{callAwake:r})}static addComponent(t,i,n,r){return Yu(t,i,n,r)}static moveComponent(t,i){return Yu(t,i)}static removeComponent(t){return nR(t.gameObject,t),t}static getOrAddComponent(t,i){return nw(t,i)}static getComponent(t,i){return t===null?null:zp(t,i)}static getComponents(t,i,n=null){return t===null?n??[]:vA(t,i,n)}static findByGuid(t,i){return gA(t,i)}static findObjectOfType(t,i,n=!0){return e4(t,i??Ft.Current,n)}static findObjectsOfType(t,i){const n=[];return t4(t,n,i),n}static getComponentInChildren(t,i){return AA(t,i)}static getComponentsInChildren(t,i,n=null){return yA(t,i,n??void 0)}static getComponentInParent(t,i){return Cv(t,i)}static getComponentsInParent(t,i,n=null){return sw(t,i,n)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var n;const i=(n=t==null?void 0:t.userData)==null?void 0:n.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ka;let Me=(Ka=class{constructor(e){h(this,"__context");h(this,"__name");h(this,"gameObject");h(this,"guid","invalid");h(this,"sourceId");h(this,"__didAwake",!1);h(this,"__didStart",!1);h(this,"__didEnable",!1);h(this,"__isEnabled");h(this,"__destroyed",!1);h(this,"_eventListeners",new Map);this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e)}get isComponent(){return!0}get context(){return this.__context??Ft.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[cc];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[cc]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Un.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Un.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(At()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((e=this.onDestroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),Zz(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){At()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return kt(this.gameObject)}set worldPosition(e){tr(this.gameObject,e)}setWorldPosition(e,t,i){ad(this.gameObject,e,t,i)}get worldQuaternion(){return Mi(this.gameObject)}set worldQuaternion(e){Vo(this.gameObject,e)}setWorldQuaternion(e,t,i,n){yI(this.gameObject,e,t,i,n)}get worldEuler(){return bI(this.gameObject)}set worldEuler(e){xI(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){aA(this.gameObject,e,t,i,n)}get forward(){return Ka._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ka._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ka._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ka,"_forward",new w),h(Ka,"_right",new w),h(Ka,"_up",new w),Ka);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Me,Component:Me,GameObject:oe},Symbol.toStringTag,{value:"Module"})),Ru=ne("debugloading"),Dm=ne("debugloadingrendering"),eO=ne("debuglicense");class Mee{constructor(){h(this,"className");h(this,"additionalClasses")}}let Om=0,tO;function sR(s){Ru&&console.log(s.progress.loaded.toFixed(0)+"/"+s.progress.total.toFixed(0),s);const e=s.count,t=s.progress.total;t===0||t===void 0?(tO!==s.name&&(Om=0),tO=s.name,Om+=(1-Om)*.001,Ru&&$i("Loading "+s.name+" did not report total size")):Om=s.progress.loaded/t;const i=s.index/e+Om/e;return et.clamp01(i)}const Vb=class{constructor(e,t){h(this,"loadingProgress",0);h(this,"_element");h(this,"_progress",0);h(this,"_allowCustomLoadingElement",!0);h(this,"_loadingElement");h(this,"_loadingTextContainer",null);h(this,"_loadingBar",null);h(this,"_messageContainer",null);h(this,"_loadingElementOptions");h(this,"_progressLoop");this._element=e,this._loadingElementOptions=t}async onLoadingBegin(e){const t=this._element.shadowRoot||this._element;if(Ru&&console.warn("Begin Loading"),!this._loadingElement){for(let i=0;i<t.children.length;i++){const n=t.children[i];if(n.classList.contains(Vb.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){Ru&&console.warn("Remove custom loading container"),t.removeChild(n);continue}this._loadingElement=this.createLoadingElement(n)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",t.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(e??"")}onLoadingUpdate(e,t){var n;if(!((n=this._loadingElement)!=null&&n.parentNode))return;let i=0;typeof e=="number"?i=e:("index"in e&&(i=sR(e)),!t&&"name"in e&&this.setMessage("loading "+e.name)),this.loadingProgress=i,t&&this.setMessage(t),this.updateDisplay()}onLoadingFinished(){Ru&&console.warn("Finished Loading"),Dm||(this.loadingProgress=1,this.onDoneLoading())}setMessage(e){this._messageContainer&&(this._messageContainer.innerText=e)}smoothProgressLoop(){if(this._progressLoop)return;let e=1/12;Dm&&(e=1/500,typeof Dm=="number"&&(e*=Dm)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Dm&&(e=.9),this._progress=et.lerp(this._progress,this.loadingProgress,e*this.loadingProgress),this.updateDisplay()},e)}onDoneLoading(){this._loadingElement&&(Ru&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const e=this._progress,t=(e*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=e*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=t)}createLoadingElement(e){var m,A;Ru&&!e&&console.log("Creating loading element"),this._loadingElement=e||document.createElement("div");let t=this._element.getAttribute("loading-style");(!t||t==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?t="dark":t="light");const i=cl();if(!e&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",t==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",this._loadingElement.style.fontFamily="Roboto, sans-serif, Arial",t==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",i&&this._element)){const v=this._element.getAttribute("loading-background-color");v&&(this._loadingElement.style.backgroundColor=v);const g=this._element.getAttribute("loading-text-color");g&&(this._loadingElement.style.color=g)}const n=((m=this._loadingElementOptions)==null?void 0:m.className)??Vb.LoadingContainerClassName;if(this._loadingElement.classList.add(n),(A=this._loadingElementOptions)!=null&&A.additionalClasses)for(const v of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(v);const r=document.createElement("div");this._loadingElement.appendChild(r);const o=document.createElement("img"),a=120;o.style.width=`${a}px`,o.style.height=`${a}px`,o.style.borderRadius="80px",o.style.padding="20px",o.style.margin="-20px",o.style.marginBottom="-10px",o.style.userSelect="none",o.style.objectFit="contain",o.style.transition="transform 2s ease-out, opacity 1s ease-in-out",o.style.transform="translateY(10px)",setTimeout(()=>{o.style.transform="translateY(0px)"},1),o.src=$$;let l=!1;if(i&&this._element){const v=this._element.getAttribute("loading-logo-src");v&&(l=!0,o.src=v)}l||(o.style.cursor="pointer",o.style.pointerEvents="all",o.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),r.appendChild(o);const c=document.createElement("div");c.style.cssText=`
|
|
5263
5263
|
display: flex;
|
|
5264
5264
|
flex-direction: column;
|
|
5265
5265
|
align-items: center;
|