@needle-tools/engine 3.35.0-beta → 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 +1 -0
- 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 +66 -66
- package/dist/needle-engine.min.js +3 -3
- package/dist/needle-engine.umd.cjs +3 -3
- 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/engine_gameobject.ts +4 -4
- package/src/engine-components/Component.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
## [3.35.0-beta] - 2023-03-25
|
|
8
8
|
- Add: Support for `transient-pointer` input sources for VisionOS
|
|
9
9
|
- Add: add metadata and intersections to `NEPointerEvent` type. Intersections are filled in from EventSystem. This information can be access via `this.input.addEventListener` or the input event callbacks
|
|
10
|
+
- Fix: `GameObject.destroy` should not dispose resources
|
|
10
11
|
- Change: `ObjectUtils.createPrimitive` now has types strings e.g. `ObjectUtils.createPrimitive("Cube")`
|
|
11
12
|
- Change: ChangeMaterialOnClick doesnt require a Renderer component anymore
|
|
12
13
|
|
package/dist/needle-engine.js
CHANGED
|
@@ -30203,13 +30203,13 @@ class Py {
|
|
|
30203
30203
|
}
|
|
30204
30204
|
r(Py, "eventListeners", /* @__PURE__ */ new Map());
|
|
30205
30205
|
const sT = IA("debugdefines");
|
|
30206
|
-
kE('if(!globalThis[""3.35.0-beta""]) globalThis[""3.35.0-beta""] = "0.0.0";');
|
|
30206
|
+
kE('if(!globalThis[""3.35.0-beta.1""]) globalThis[""3.35.0-beta.1""] = "0.0.0";');
|
|
30207
30207
|
kE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');
|
|
30208
|
-
kE('if(!globalThis[""
|
|
30209
|
-
kE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta";');
|
|
30208
|
+
kE('if(!globalThis[""Tue Mar 26 2024 10:41:14 GMT+0100 (Central European Standard Time)""]) globalThis[""Tue Mar 26 2024 10:41:14 GMT+0100 (Central European Standard Time)""] = "unknown";');
|
|
30209
|
+
kE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta.1";');
|
|
30210
30210
|
kE('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');
|
|
30211
|
-
kE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "
|
|
30212
|
-
const sC = "3.35.0-beta", OR = "undefined", nT = "
|
|
30211
|
+
kE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 26 2024 10:41:14 GMT+0100 (Central European Standard Time)";');
|
|
30212
|
+
const sC = "3.35.0-beta.1", OR = "undefined", nT = "Tue Mar 26 2024 10:41:14 GMT+0100 (Central European Standard Time)";
|
|
30213
30213
|
sT && console.log(`Engine version: ${sC} (generator: ${OR})
|
|
30214
30214
|
Project built at ${nT}`);
|
|
30215
30215
|
const Sa = "needle_isActiveInHierarchy", lQ = "builtin_components", Wp = "needle_editor_guid";
|
|
@@ -53020,42 +53020,42 @@ function Jq(g, A = !0) {
|
|
|
53020
53020
|
}
|
|
53021
53021
|
const of = [], sf = [];
|
|
53022
53022
|
function Bn(g, A = !0, e = !1) {
|
|
53023
|
-
of.length = 0, sf.length = 0, qG(g, A,
|
|
53023
|
+
of.length = 0, sf.length = 0, qG(g, A, !0);
|
|
53024
53024
|
for (const t of of)
|
|
53025
53025
|
t.gameObject = null, t.context = null;
|
|
53026
53026
|
for (const t of sf)
|
|
53027
53027
|
LAA(t, !0), e && Ot(t), cX(t);
|
|
53028
53028
|
sf.length = 0, of.length = 0;
|
|
53029
53029
|
}
|
|
53030
|
-
function qG(g, A = !0, e = !
|
|
53031
|
-
var
|
|
53030
|
+
function qG(g, A = !0, e = !0) {
|
|
53031
|
+
var o;
|
|
53032
53032
|
if (g == null)
|
|
53033
53033
|
return;
|
|
53034
|
-
const
|
|
53035
|
-
if (
|
|
53036
|
-
if (
|
|
53034
|
+
const t = g;
|
|
53035
|
+
if (t.isComponent) {
|
|
53036
|
+
if (t[JG])
|
|
53037
53037
|
return;
|
|
53038
|
-
of.push(
|
|
53039
|
-
const
|
|
53040
|
-
|
|
53038
|
+
of.push(t);
|
|
53039
|
+
const s = t.gameObject;
|
|
53040
|
+
t.__internalDisable(), t.__internalDestroy(), t.gameObject = s;
|
|
53041
53041
|
return;
|
|
53042
53042
|
}
|
|
53043
53043
|
if (g[JG])
|
|
53044
53044
|
return;
|
|
53045
|
-
const
|
|
53046
|
-
tf && console.log(
|
|
53047
|
-
const
|
|
53048
|
-
if (
|
|
53049
|
-
let
|
|
53050
|
-
for (let
|
|
53051
|
-
const
|
|
53052
|
-
qG(
|
|
53045
|
+
const i = g;
|
|
53046
|
+
tf && console.log(i), sf.push(i);
|
|
53047
|
+
const I = (o = i.userData) == null ? void 0 : o.components;
|
|
53048
|
+
if (I != null && Array.isArray(I)) {
|
|
53049
|
+
let s = I.length;
|
|
53050
|
+
for (let n = 0; n < I.length; n++) {
|
|
53051
|
+
const C = I[n];
|
|
53052
|
+
qG(C, A, !1), I.length < s && (s = I.length, n--);
|
|
53053
53053
|
}
|
|
53054
53054
|
}
|
|
53055
|
-
if (A &&
|
|
53056
|
-
for (const
|
|
53057
|
-
qG(
|
|
53058
|
-
|
|
53055
|
+
if (A && i.children)
|
|
53056
|
+
for (const s of i.children)
|
|
53057
|
+
qG(s, A, !1);
|
|
53058
|
+
e && i.removeFromParent();
|
|
53059
53059
|
}
|
|
53060
53060
|
function QE(g, A, e = !0) {
|
|
53061
53061
|
return X2(g, A, e);
|
|
@@ -53603,8 +53603,8 @@ class nA extends pA {
|
|
|
53603
53603
|
* @param instance object to destroy
|
|
53604
53604
|
* @param recursive if true, all children will be destroyed as well. true by default
|
|
53605
53605
|
*/
|
|
53606
|
-
static destroy(e, t = !0
|
|
53607
|
-
return Bn(e, t
|
|
53606
|
+
static destroy(e, t = !0) {
|
|
53607
|
+
return Bn(e, t);
|
|
53608
53608
|
}
|
|
53609
53609
|
/**
|
|
53610
53610
|
* Add an object to parent and also ensure all components are being registered
|
|
@@ -30203,13 +30203,13 @@ class Vb {
|
|
|
30203
30203
|
}
|
|
30204
30204
|
h(Vb, "eventListeners", /* @__PURE__ */ new Map());
|
|
30205
30205
|
const CU = ne("debugdefines");
|
|
30206
|
-
tp('if(!globalThis[""3.35.0-beta""]) globalThis[""3.35.0-beta""] = "0.0.0";');
|
|
30206
|
+
tp('if(!globalThis[""3.35.0-beta.1""]) globalThis[""3.35.0-beta.1""] = "0.0.0";');
|
|
30207
30207
|
tp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');
|
|
30208
|
-
tp('if(!globalThis[""
|
|
30209
|
-
tp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta";');
|
|
30208
|
+
tp('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";');
|
|
30209
|
+
tp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta.1";');
|
|
30210
30210
|
tp('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');
|
|
30211
|
-
tp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "
|
|
30212
|
-
const ql = "3.35.0-beta", IT = "undefined", EU = "
|
|
30211
|
+
tp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";');
|
|
30212
|
+
const ql = "3.35.0-beta.1", IT = "undefined", EU = "Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";
|
|
30213
30213
|
CU && console.log(`Engine version: ${ql} (generator: ${IT})
|
|
30214
30214
|
Project built at ${EU}`);
|
|
30215
30215
|
const rh = "needle_isActiveInHierarchy", Wd = "builtin_components", c0 = "needle_editor_guid";
|
|
@@ -53020,42 +53020,42 @@ function V2(s, e = !0) {
|
|
|
53020
53020
|
}
|
|
53021
53021
|
const b0 = [], x0 = [];
|
|
53022
53022
|
function tl(s, e = !0, t = !1) {
|
|
53023
|
-
b0.length = 0, x0.length = 0, g1(s, e,
|
|
53023
|
+
b0.length = 0, x0.length = 0, g1(s, e, !0);
|
|
53024
53024
|
for (const i of b0)
|
|
53025
53025
|
i.gameObject = null, i.context = null;
|
|
53026
53026
|
for (const i of x0)
|
|
53027
53027
|
h$(i, !0), t && Ui(i), zq(i);
|
|
53028
53028
|
x0.length = 0, b0.length = 0;
|
|
53029
53029
|
}
|
|
53030
|
-
function g1(s, e = !0, t = !
|
|
53031
|
-
var
|
|
53030
|
+
function g1(s, e = !0, t = !0) {
|
|
53031
|
+
var o;
|
|
53032
53032
|
if (s == null)
|
|
53033
53033
|
return;
|
|
53034
|
-
const
|
|
53035
|
-
if (
|
|
53036
|
-
if (
|
|
53034
|
+
const i = s;
|
|
53035
|
+
if (i.isComponent) {
|
|
53036
|
+
if (i[m1])
|
|
53037
53037
|
return;
|
|
53038
|
-
b0.push(
|
|
53039
|
-
const
|
|
53040
|
-
|
|
53038
|
+
b0.push(i);
|
|
53039
|
+
const a = i.gameObject;
|
|
53040
|
+
i.__internalDisable(), i.__internalDestroy(), i.gameObject = a;
|
|
53041
53041
|
return;
|
|
53042
53042
|
}
|
|
53043
53043
|
if (s[m1])
|
|
53044
53044
|
return;
|
|
53045
|
-
const
|
|
53046
|
-
A0 && console.log(
|
|
53047
|
-
const
|
|
53048
|
-
if (
|
|
53049
|
-
let
|
|
53050
|
-
for (let
|
|
53051
|
-
const
|
|
53052
|
-
g1(
|
|
53045
|
+
const n = s;
|
|
53046
|
+
A0 && console.log(n), x0.push(n);
|
|
53047
|
+
const r = (o = n.userData) == null ? void 0 : o.components;
|
|
53048
|
+
if (r != null && Array.isArray(r)) {
|
|
53049
|
+
let a = r.length;
|
|
53050
|
+
for (let l = 0; l < r.length; l++) {
|
|
53051
|
+
const c = r[l];
|
|
53052
|
+
g1(c, e, !1), r.length < a && (a = r.length, l--);
|
|
53053
53053
|
}
|
|
53054
53054
|
}
|
|
53055
|
-
if (e &&
|
|
53056
|
-
for (const
|
|
53057
|
-
g1(
|
|
53058
|
-
|
|
53055
|
+
if (e && n.children)
|
|
53056
|
+
for (const a of n.children)
|
|
53057
|
+
g1(a, e, !1);
|
|
53058
|
+
t && n.removeFromParent();
|
|
53059
53059
|
}
|
|
53060
53060
|
function jf(s, e, t = !0) {
|
|
53061
53061
|
return g3(s, e, t);
|
|
@@ -53603,8 +53603,8 @@ class oe extends ge {
|
|
|
53603
53603
|
* @param instance object to destroy
|
|
53604
53604
|
* @param recursive if true, all children will be destroyed as well. true by default
|
|
53605
53605
|
*/
|
|
53606
|
-
static destroy(t, i = !0
|
|
53607
|
-
return tl(t, i
|
|
53606
|
+
static destroy(t, i = !0) {
|
|
53607
|
+
return tl(t, i);
|
|
53608
53608
|
}
|
|
53609
53609
|
/**
|
|
53610
53610
|
* Add an object to parent and also ensure all components are being registered
|
|
@@ -4341,7 +4341,7 @@ void main() {
|
|
|
4341
4341
|
`;a+=r(o);const l=Object.keys(s);let c="";for(let u=0;u<l.length;u++){const d=l[u],p=s[d];if(tg.has(p)){c+="";continue}tg.set(p,!0),c+=d+":"+n(p,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=r(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
4343
|
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const iY=ee("nodevlogs");function cn(i,e=Vs.Log){Ra(e,i)}function ji(i){cn(i,Vs.Warn)}function Tk(i){cn(i,Vs.Error)}let sE;function pt(){return iY?!1:sE!==void 0?sE:Ps()}function nY(i){sE=i}const wu=new mu,Hr=new S,Gc=new S,Qi=new Me,Ik={X:new S(1,0,0),Y:new S(0,1,0),Z:new S(0,0,1)},oE={type:"change"},Rk={type:"mouseDown"},Pk={type:"mouseUp",mode:null},Bk={type:"objectChange"};class rY extends ge{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new lE;this._gizmo=n,this.add(n);const r=new hY;this._plane=r,this.add(r);const s=this;function o(y,b){let _=b;Object.defineProperty(s,y,{get:function(){return _!==void 0?_:b},set:function(E){_!==E&&(_=E,r[y]=E,n[y]=E,s.dispatchEvent({type:y+"-changed",value:E}),s.dispatchEvent(oE))}}),s[y]=b,r[y]=b,n[y]=b}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const a=new S,l=new S,c=new Me,u=new Me,d=new S,p=new Me,f=new S,m=new S,A=new S,v=0,g=new S;o("worldPosition",a),o("worldPositionStart",l),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",A),o("rotationAngle",v),o("eye",g),this._offset=new S,this._startNorm=new S,this._endNorm=new S,this._cameraScale=new S,this._parentPosition=new S,this._parentQuaternion=new Me,this._parentQuaternionInv=new Me,this._parentScale=new S,this._worldScaleStart=new S,this._worldQuaternionInv=new Me,this._worldScale=new S,this._positionStart=new S,this._quaternionStart=new Me,this._scaleStart=new S,this._getPointer=sY.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&&wu.setFromCamera(e,this.camera);const t=aE(this._gizmo.picker[this.mode],wu);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&&wu.setFromCamera(e,this.camera);const t=aE(this._plane,wu,!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,Rk.mode=this.mode,this.dispatchEvent(Rk)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let s=this.space;if(n==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&wu.setFromCamera(e,this.camera);const o=aE(this._plane,wu,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(r.position.applyQuaternion(Qi.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),s==="world"&&(r.parent&&r.position.add(Hr.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Hr.setFromMatrixPosition(r.parent.matrixWorld))));else if(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Gc.set(a,a,a)}else Hr.copy(this.pointStart),Gc.copy(this.pointEnd),Hr.applyQuaternion(this._worldQuaternionInv),Gc.applyQuaternion(this._worldQuaternionInv),Gc.divide(Hr),t.search("X")===-1&&(Gc.x=1),t.search("Y")===-1&&(Gc.y=1),t.search("Z")===-1&&(Gc.z=1);r.scale.copy(this._scaleStart).multiply(Gc),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Hr.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Hr.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Ik[t]),Hr.copy(Ik[t]),s==="local"&&Hr.applyQuaternion(this.worldQuaternion),Hr.cross(this.eye),Hr.length()===0?l=!0:this.rotationAngle=this._offset.dot(Hr.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(Qi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(Qi.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(oE),this.dispatchEvent(Bk)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Pk.mode=this.mode,this.dispatchEvent(Pk)),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(oE),this.dispatchEvent(Bk),this.pointStart.copy(this.pointEnd))}getRaycaster(){return wu}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 sY(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function oY(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function aY(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function lY(i){this.enabled&&this.pointerMove(this._getPointer(i))}function cY(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function aE(i,e,t){const n=e.intersectObject(i,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const Zy=new Li,Mi=new S(0,1,0),Dk=new S(0,0,0),Ok=new Ee,$y=new Me,eb=new Me,Ba=new S,kk=new Ee,ig=new S(1,0,0),Su=new S(0,1,0),ng=new S(0,0,1),tb=new S,rg=new S,sg=new S;class lE extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new ii({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new mn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const s=e.clone();s.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const d=e.clone();d.opacity=.25;const p=e.clone();p.color.setHex(16776960),p.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new wn(0,.04,.1,12);m.translate(0,.05,0);const A=new Bi(.08,.08,.08);A.translate(0,.04,0);const v=new yt;v.setAttribute("position",new ot([0,0,0,1,0,0],3));const g=new wn(.0075,.0075,.5,3);g.translate(0,.25,0);function y(k,W){const U=new Ac(k,.0075,3,64,W*Math.PI*2);return U.rotateY(Math.PI/2),U.rotateX(Math.PI/2),U}function b(){const k=new yt;return k.setAttribute("position",new ot([0,0,0,1,1,1],3)),k}const _={X:[[new me(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new me(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new me(g,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new me(m,o),[0,.5,0]],[new me(m,o),[0,-.5,0],[Math.PI,0,0]],[new me(g,o)]],Z:[[new me(m,a),[0,0,.5],[Math.PI/2,0,0]],[new me(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new me(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new me(new vc(.1,0),d.clone()),[0,0,0]]],XY:[[new me(new Bi(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new me(new Bi(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Bi(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new me(new wn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new me(new wn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new me(new wn(.2,0,.6,4),n),[0,.3,0]],[new me(new wn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new me(new wn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new me(new wn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new me(new vc(.2,0),n)]],XY:[[new me(new Bi(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new me(new Bi(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Bi(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new me(new vc(.01,2),r),null,null,null,"helper"]],END:[[new me(new vc(.01,2),r),null,null,null,"helper"]],DELTA:[[new gn(b(),r),null,null,null,"helper"]],X:[[new gn(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new gn(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new gn(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new me(y(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new me(y(.5,.5),s)]],Y:[[new me(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new me(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new me(y(.75,1),p),null,[0,Math.PI/2,0]]]},T={AXIS:[[new gn(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},D={XYZE:[[new me(new va(.25,10,8),n)]],X:[[new me(new Ac(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new me(new Ac(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new me(new Ac(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new me(new Ac(.75,.1,2,24),n)]]},C={X:[[new me(A,s),[.5,0,0],[0,0,-Math.PI/2]],[new me(g,s),[0,0,0],[0,0,-Math.PI/2]],[new me(A,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new me(A,o),[0,.5,0]],[new me(g,o)],[new me(A,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new me(A,a),[0,0,.5],[Math.PI/2,0,0]],[new me(g,a),[0,0,0],[Math.PI/2,0,0]],[new me(A,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new me(new Bi(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new me(new Bi(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Bi(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new me(new Bi(.1,.1,.1),d.clone())]]},P={X:[[new me(new wn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new me(new wn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new me(new wn(.2,0,.6,4),n),[0,.3,0]],[new me(new wn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new me(new wn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new me(new wn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new me(new Bi(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new me(new Bi(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new me(new Bi(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new me(new Bi(.2,.2,.2),n),[0,0,0]]]},Q={X:[[new gn(v,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new gn(v,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new gn(v,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function G(k){const W=new ge;for(const U in k)for(let F=k[U].length;F--;){const z=k[U][F][0].clone(),Z=k[U][F][1],K=k[U][F][2],re=k[U][F][3],Ae=k[U][F][4];z.name=U,z.tag=Ae,Z&&z.position.set(Z[0],Z[1],Z[2]),K&&z.rotation.set(K[0],K[1],K[2]),re&&z.scale.set(re[0],re[1],re[2]),z.updateMatrix();const Re=z.geometry.clone();Re.applyMatrix4(z.matrix),z.geometry=Re,z.renderOrder=1/0,z.position.set(0,0,0),z.rotation.set(0,0,0),z.scale.set(1,1,1),W.add(z)}return W}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=G(_)),this.add(this.gizmo.rotate=G(M)),this.add(this.gizmo.scale=G(C)),this.add(this.picker.translate=G(E)),this.add(this.picker.rotate=G(D)),this.add(this.picker.scale=G(P)),this.add(this.helper.translate=G(I)),this.add(this.helper.rotate=G(T)),this.add(this.helper.scale=G(Q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:eb;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let r=0;r<n.length;r++){const s=n[r];s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(o*this.size/4),s.tag==="helper"){s.visible=!1,s.name==="AXIS"?(s.visible=!!this.axis,this.axis==="X"&&(Qi.setFromEuler(Zy.set(0,0,0)),s.quaternion.copy(t).multiply(Qi),Math.abs(Mi.copy(ig).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Y"&&(Qi.setFromEuler(Zy.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(Qi),Math.abs(Mi.copy(Su).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Z"&&(Qi.setFromEuler(Zy.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(Qi),Math.abs(Mi.copy(ng).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="XYZE"&&(Qi.setFromEuler(Zy.set(0,Math.PI/2,0)),Mi.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(Ok.lookAt(Dk,Mi,Su)),s.quaternion.multiply(Qi),s.visible=this.dragging),this.axis==="E"&&(s.visible=!1)):s.name==="START"?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):s.name==="END"?(s.position.copy(this.worldPosition),s.visible=this.dragging):s.name==="DELTA"?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),Hr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Hr.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(Hr),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=this.axis.search(s.name)!==-1));continue}s.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(s.name==="X"&&Math.abs(Mi.copy(ig).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Y"&&Math.abs(Mi.copy(Su).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Z"&&Math.abs(Mi.copy(ng).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XY"&&Math.abs(Mi.copy(ng).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="YZ"&&Math.abs(Mi.copy(ig).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XZ"&&Math.abs(Mi.copy(Su).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):this.mode==="rotate"&&($y.copy(t),Mi.copy(this.eye).applyQuaternion(Qi.copy(t).invert()),s.name.search("E")!==-1&&s.quaternion.setFromRotationMatrix(Ok.lookAt(this.eye,Dk,Su)),s.name==="X"&&(Qi.setFromAxisAngle(ig,Math.atan2(-Mi.y,Mi.z)),Qi.multiplyQuaternions($y,Qi),s.quaternion.copy(Qi)),s.name==="Y"&&(Qi.setFromAxisAngle(Su,Math.atan2(Mi.x,Mi.z)),Qi.multiplyQuaternions($y,Qi),s.quaternion.copy(Qi)),s.name==="Z"&&(Qi.setFromAxisAngle(ng,Math.atan2(Mi.y,Mi.x)),Qi.multiplyQuaternions($y,Qi),s.quaternion.copy(Qi))),s.visible=s.visible&&(s.name.indexOf("X")===-1||this.showX),s.visible=s.visible&&(s.name.indexOf("Y")===-1||this.showY),s.visible=s.visible&&(s.name.indexOf("Z")===-1||this.showZ),s.visible=s.visible&&(s.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some(function(a){return s.name===a}))&&(s.material.color.setHex(16776960),s.material.opacity=1)}super.updateMatrixWorld(e)}}class hY extends me{constructor(){super(new Ln(1e5,1e5,2,2),new ii({visible:!1,wireframe:!0,side:hi,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),tb.copy(ig).applyQuaternion(t==="local"?this.worldQuaternion:eb),rg.copy(Su).applyQuaternion(t==="local"?this.worldQuaternion:eb),sg.copy(ng).applyQuaternion(t==="local"?this.worldQuaternion:eb),Mi.copy(rg),this.mode){case"translate":case"scale":switch(this.axis){case"X":Mi.copy(this.eye).cross(tb),Ba.copy(tb).cross(Mi);break;case"Y":Mi.copy(this.eye).cross(rg),Ba.copy(rg).cross(Mi);break;case"Z":Mi.copy(this.eye).cross(sg),Ba.copy(sg).cross(Mi);break;case"XY":Ba.copy(sg);break;case"YZ":Ba.copy(tb);break;case"XZ":Mi.copy(sg),Ba.copy(rg);break;case"XYZ":case"E":Ba.set(0,0,0);break}break;case"rotate":default:Ba.set(0,0,0)}Ba.length()===0?this.quaternion.copy(this.cameraQuaternion):(kk.lookAt(Hr.set(0,0,0),Ba,Mi),this.quaternion.setFromRotationMatrix(kk)),super.updateMatrixWorld(e)}}const uY=ee("debugpatch");function ib(i,e,t,n){const r=uY===e;if(!t&&!n)return;const s=e+"___needle";pY(i,e,t,n);const o=Object.getOwnPropertyDescriptor(i,e),a=i[e];r&&console.log("Patch",i.constructor.name,e,o,a),o?(r&&console.log("Apply patch with existing descriptor",i.constructor.name,e,o),typeof o.value=="function"&&(i[e]=Uk(o.value,i,e))):(r&&console.log("Create patch with new property",i.constructor.name,e,o),Object.defineProperty(i,e,{set:function(l){if(typeof l=="function")this[s]=Uk(l,i,e);else{const c=this[s];Fk(i,e,this,c,l),this[s]=l,Nk(i,e,this,c,l)}},get:function(){const l=this[s];return typeof l=="function"&&l[s]?l[s]:l}}))}function dY(i,e,t){const n=hE(i,e);if(n)for(let r=n.length-1;r>=0;r--){const s=n[r];s.prefix===t&&(s.prefix=null),s.postfix===t&&(s.postfix=null),!s.prefix&&!s.postfix&&n.splice(r,1)}}const Lk=Symbol("Needle:Patches:WrappedFunction");function Uk(i,e,t){if(i[Lk])return i;const n=function(...r){Fk(e,t,this,...r);const s=i.apply(this,r);return Nk(e,t,this,s,...r),s};return n[Lk]=!0,n}const nb="Needle:Patches";function cE(){return globalThis[nb]||(globalThis[nb]=new WeakMap),globalThis[nb]}function hE(i,e){const t=cE().get(i);return t?t.get(e):null}function pY(i,e,t,n){let r=cE().get(i);r||(r=new Map,cE().set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push({prefix:t,postfix:n})}function Fk(i,e,t,...n){var r;if(!t)return;const s=hE(i,e);if(s)for(const o of s)(r=o.prefix)==null||r.call(t,...n)}function Nk(i,e,t,n,...r){var s;if(!t)return;const o=hE(i,e);if(o)for(const a of o)(s=a.postfix)==null||s.call(t,n,...r)}const zk=Symbol("gltf-loader-internal-usage-tracker"),fY=ee("debugusers"),rb=class{constructor(i){h(this,"parser"),h(this,"_getDependency"),h(this,"_loadingId"),h(this,"_loadedObjects",new Set),this.parser=i,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(i){return rb._loadingProcesses>0}beforeRoot(){rb._loadingProcesses++;const i=this,e=this._getDependency;return this.parser.getDependency=function(t,n){const r=e.call(this,t,n);return r.then(s=>(s&&(i._loadedObjects.add(s),s[zk]=i._loadingId),s)),r},null}afterRoot(i){rb._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[zk],e instanceof ge&&(e.parent||e instanceof me&&(fY&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null));return null}};let uE=rb;h(uE,"_loadingProcesses",0);class jk{constructor(){window.addEventListener("unhandledrejection",e=>{var t;if(e.defaultPrevented)return;const n=(t=e?.reason)==null?void 0:t.path;if(n){const r=n[0];r&&r.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4344
|
-
`+r.src),e.preventDefault())}})}}const sb=ee("trackresources");function Qk(){return sb==="dispose"}let Cu=!0;sb===0&&(Cu=!1);function mY(i){Cu=i}function Gk(){return Cu}const Hk=Symbol("disposable");function dE(i,e){i&&(i[Hk]=e,Eu&&console.warn("Set disposable",e,i))}const Vk=Symbol("disposed");function gY(i){return i[Vk]===!0}function Ii(i){var e;if(i){if(i[Hk]===!1){Eu&&console.warn("Object is marked as not disposable",i);return}if(i[Vk]=!0,i instanceof jr)Ii(i.environment),Ii(i.background),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial);else if(i instanceof Ko)Ii(i.geometry),Ii(i.material),Ii(i.skeleton),Ii(i.bindMatrix),Ii(i.bindMatrixInverse),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof me)Ii(i.geometry),Ii(i.material),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof yt){wp(i);for(const t of Object.keys(i.attributes)){const n=i.attributes[t];Ii(n)}}else if(i instanceof $e||i instanceof xs)Eu&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const t of i)t instanceof Ot&&Ii(t);else if(i instanceof Ot){wp(i);for(const n of Object.keys(i)){const r=i[n];r instanceof Tt&&(Ii(r),i[n]=null)}const t=i.uniforms;if(t)for(const n of Object.keys(t)){const r=t[n];r instanceof Tt?(Ii(r),t[n]=null):r instanceof be&&(Ii(r.value),r.value=null)}}else i instanceof Tt?(wp(i),wp(i.source),((e=i.source)==null?void 0:e.data)instanceof ImageBitmap&&wp(i.source.data)):i instanceof Wf?(wp(i.boneTexture),i.boneTexture=null):i instanceof Tm||!(i instanceof ge)&&Eu&&console.warn("Unknown object type",i)}}function wp(i){i&&((Eu||Qk()||sb)&&console.warn("\u{1F9E8} FREE",i),i instanceof ImageBitmap?i.close():i instanceof _l?i.data=null:i.dispose())}function Wk(i){(i instanceof me||i instanceof Ko)&&(i.material=null,i.geometry=null)}const vY=new Set;function pE(i,e,t=null,n){if(n||(n=vY,n.clear()),!i)return n;const r=i[og];if(r)for(const s of r)n.has(s)||t?.call(null,s)!==!1&&(n.add(s),e&&pE(s,!0,t,n));return n}function AY(i){return i[ag]}const Eu=ee("debugresourceusers")||ee("debugmemory"),og=Symbol("needle-resource-users"),ag=Symbol("needle-resource-users-count");function as(i,e){ib(i,e,function(t,n){Cu&&(ob(og,this,t,!1),ob(og,this,n,!0))})}Cu&&(as(me.prototype,"material"),as(me.prototype,"geometry"),as(Ot.prototype,"map"),as(Ot.prototype,"bumpMap"),as(Ot.prototype,"alphaMap"),as(Ot.prototype,"normalMap"),as(Ot.prototype,"displacementMap"),as(Ot.prototype,"roughnessMap"),as(Ot.prototype,"metalnessMap"),as(Ot.prototype,"emissiveMap"),as(Ot.prototype,"specularMap"),as(Ot.prototype,"envMap"),as(Ot.prototype,"lightMap"),as(Ot.prototype,"aoMap"),as(Ot.prototype,"gradientMap"));function yY(i){if(Cu===!1)return;const e=i[og];if(e)for(const t of e)ob(og,t,i,!1)}Cu&&ib(Ot.prototype,"dispose",function(){yY(this)});let fE=0;function ob(i,e,t,n){if(fE>0)return;if(Array.isArray(t)){for(const s of t)ob(i,e,s,n);return}if(!t)return;let r=t[i];if(r||(r=new Set),n){if(e&&!r.has(e)){r.add(e);let s=t[ag]||0;s+=1,t[ag]=s,Eu&&console.warn(`\u{1F7E2} Added user of "${t.type}"`,e,t,s,"users:",r)}}else if(e&&r.has(e)){r.delete(e);let s=t[ag]||0;s>0&&(s-=1,t[ag]=s),Eu&&console.warn(`\u{1F534} Removed user of "${t.type}"`,e,t,s,"users:",r),s<=0&&(uE.isLoading(t)||(sb&&console.warn(`\u{1F534} Removed all user of "${t.type}"`,t),Qk()&&Ii(t)))}t[i]=r}try{ib(Il.prototype,"render",function(){fE++},function(){fE--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var lg=(i=>(i.Added="component-added",i.Removing="removing-component",i))(lg||{});const qk=ee("debugcomponentevents");class cg{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let n=this.eventListeners.get(e);n||(n=[]),n.push(t),this.eventListeners.set(e,n),qk&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const n=this.eventListeners.get(e);if(!n)return;const r=n.indexOf(t);r<0||n.splice(r,1)}static dispatchComponentLifecycleEvent(e,t){const n=this.eventListeners.get(e);if(qk&&console.log("Dispatching event "+e,n),!!n)for(const r of n)r(t)}}h(cg,"eventListeners",new Map);const Xk=ee("debugdefines");Sp('if(!globalThis[""3.35.0-beta""]) globalThis[""3.35.0-beta""] = "0.0.0";'),Sp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Sp('if(!globalThis[""
|
|
4344
|
+
`+r.src),e.preventDefault())}})}}const sb=ee("trackresources");function Qk(){return sb==="dispose"}let Cu=!0;sb===0&&(Cu=!1);function mY(i){Cu=i}function Gk(){return Cu}const Hk=Symbol("disposable");function dE(i,e){i&&(i[Hk]=e,Eu&&console.warn("Set disposable",e,i))}const Vk=Symbol("disposed");function gY(i){return i[Vk]===!0}function Ii(i){var e;if(i){if(i[Hk]===!1){Eu&&console.warn("Object is marked as not disposable",i);return}if(i[Vk]=!0,i instanceof jr)Ii(i.environment),Ii(i.background),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial);else if(i instanceof Ko)Ii(i.geometry),Ii(i.material),Ii(i.skeleton),Ii(i.bindMatrix),Ii(i.bindMatrixInverse),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof me)Ii(i.geometry),Ii(i.material),Ii(i.customDepthMaterial),Ii(i.customDistanceMaterial),i.geometry=null,i.material=null;else if(i instanceof yt){wp(i);for(const t of Object.keys(i.attributes)){const n=i.attributes[t];Ii(n)}}else if(i instanceof $e||i instanceof xs)Eu&&console.warn("BufferAttribute dispose not supported",i.count);else if(i instanceof Array)for(const t of i)t instanceof Ot&&Ii(t);else if(i instanceof Ot){wp(i);for(const n of Object.keys(i)){const r=i[n];r instanceof Tt&&(Ii(r),i[n]=null)}const t=i.uniforms;if(t)for(const n of Object.keys(t)){const r=t[n];r instanceof Tt?(Ii(r),t[n]=null):r instanceof be&&(Ii(r.value),r.value=null)}}else i instanceof Tt?(wp(i),wp(i.source),((e=i.source)==null?void 0:e.data)instanceof ImageBitmap&&wp(i.source.data)):i instanceof Wf?(wp(i.boneTexture),i.boneTexture=null):i instanceof Tm||!(i instanceof ge)&&Eu&&console.warn("Unknown object type",i)}}function wp(i){i&&((Eu||Qk()||sb)&&console.warn("\u{1F9E8} FREE",i),i instanceof ImageBitmap?i.close():i instanceof _l?i.data=null:i.dispose())}function Wk(i){(i instanceof me||i instanceof Ko)&&(i.material=null,i.geometry=null)}const vY=new Set;function pE(i,e,t=null,n){if(n||(n=vY,n.clear()),!i)return n;const r=i[og];if(r)for(const s of r)n.has(s)||t?.call(null,s)!==!1&&(n.add(s),e&&pE(s,!0,t,n));return n}function AY(i){return i[ag]}const Eu=ee("debugresourceusers")||ee("debugmemory"),og=Symbol("needle-resource-users"),ag=Symbol("needle-resource-users-count");function as(i,e){ib(i,e,function(t,n){Cu&&(ob(og,this,t,!1),ob(og,this,n,!0))})}Cu&&(as(me.prototype,"material"),as(me.prototype,"geometry"),as(Ot.prototype,"map"),as(Ot.prototype,"bumpMap"),as(Ot.prototype,"alphaMap"),as(Ot.prototype,"normalMap"),as(Ot.prototype,"displacementMap"),as(Ot.prototype,"roughnessMap"),as(Ot.prototype,"metalnessMap"),as(Ot.prototype,"emissiveMap"),as(Ot.prototype,"specularMap"),as(Ot.prototype,"envMap"),as(Ot.prototype,"lightMap"),as(Ot.prototype,"aoMap"),as(Ot.prototype,"gradientMap"));function yY(i){if(Cu===!1)return;const e=i[og];if(e)for(const t of e)ob(og,t,i,!1)}Cu&&ib(Ot.prototype,"dispose",function(){yY(this)});let fE=0;function ob(i,e,t,n){if(fE>0)return;if(Array.isArray(t)){for(const s of t)ob(i,e,s,n);return}if(!t)return;let r=t[i];if(r||(r=new Set),n){if(e&&!r.has(e)){r.add(e);let s=t[ag]||0;s+=1,t[ag]=s,Eu&&console.warn(`\u{1F7E2} Added user of "${t.type}"`,e,t,s,"users:",r)}}else if(e&&r.has(e)){r.delete(e);let s=t[ag]||0;s>0&&(s-=1,t[ag]=s),Eu&&console.warn(`\u{1F534} Removed user of "${t.type}"`,e,t,s,"users:",r),s<=0&&(uE.isLoading(t)||(sb&&console.warn(`\u{1F534} Removed all user of "${t.type}"`,t),Qk()&&Ii(t)))}t[i]=r}try{ib(Il.prototype,"render",function(){fE++},function(){fE--})}catch(i){console.warn("Could not wrap WebGLRenderer.render",i)}var lg=(i=>(i.Added="component-added",i.Removing="removing-component",i))(lg||{});const qk=ee("debugcomponentevents");class cg{static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let n=this.eventListeners.get(e);n||(n=[]),n.push(t),this.eventListeners.set(e,n),qk&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const n=this.eventListeners.get(e);if(!n)return;const r=n.indexOf(t);r<0||n.splice(r,1)}static dispatchComponentLifecycleEvent(e,t){const n=this.eventListeners.get(e);if(qk&&console.log("Dispatching event "+e,n),!!n)for(const r of n)r(t)}}h(cg,"eventListeners",new Map);const Xk=ee("debugdefines");Sp('if(!globalThis[""3.35.0-beta.1""]) globalThis[""3.35.0-beta.1""] = "0.0.0";'),Sp('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Sp('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";'),Sp('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.35.0-beta.1";'),Sp('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Sp('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";');const Ll="3.35.0-beta.1",ab="undefined",mE="Tue Mar 26 2024 10:41:24 GMT+0100 (Central European Standard Time)";Xk&&console.log(`Engine version: ${Ll} (generator: ${ab})
|
|
4345
4345
|
Project built at ${mE}`);const Ul="needle_isActiveInHierarchy",Mu="builtin_components",hg="needle_editor_guid";function Sp(i){try{(0,eval)(i)}catch(e){Xk&&console.error(e)}}const ug=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),Yk=Symbol("isUsingInstancing"),Jk=Symbol("instancingRenderer"),gE=Symbol("instancingAutoUpdateBounds");class ba{static isUsingInstancing(e){return e[Yk]===!0}static getRenderer(e){return e[Jk]||null}setAutoUpdateBounds(e,t){const n=ba.getRenderer(e);n&&(n[gE]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[ug]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const n of e.children)ba.markDirty(n,!0)}}function Tu(i,e){try{e?i(e):i()}catch(t){return console.error(t),!1}return!0}const vE=ee("debugnewscripts"),bY=ee("debughierarchy"),Gi=[];function _Y(){return Gi.length>0}function lb(i){if(!(i.new_scripts.length<=0)){if(vE&&console.log("Register new components",i.new_scripts.length,[...i.new_scripts],i.alias?"element: "+i.alias:i.hash,i),i.new_scripts_pre_setup_callbacks.length>0){for(const e of i.new_scripts_pre_setup_callbacks)e&&e();i.new_scripts_pre_setup_callbacks.length=0}Gi.length=0,i.new_scripts.length>0&&Gi.push(...i.new_scripts),i.new_scripts.length=0;for(let e=0;e<Gi.length;e++)try{const t=Gi[e];if(t.isComponent!==!0){(pt()||vE)&&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),Gi.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Gi.splice(e,1),e--;continue}t.context=i,dg(t.gameObject),AE(t,i)}catch(t){console.error(t),Fl(Gi[e],i),Gi.splice(e,1),e--}for(let e=0;e<Gi.length;e++)try{const t=Gi[e];if(t.destroyed){Fl(Gi[e],i),Gi.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(n){console.error(n)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),dg(t.gameObject),t.activeAndEnabled&&Tu(t.__internalAwake.bind(t)))}catch(t){console.error(t),Fl(Gi[e],i),Gi.splice(e,1),e--}for(let e=0;e<Gi.length;e++)try{const t=Gi[e];if(t.destroyed||t.enabled===!1||(dg(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,Tu(t.__internalEnable.bind(t)))}catch(t){console.error(t),Fl(Gi[e],i),Gi.splice(e,1),e--}for(let e=0;e<Gi.length;e++)try{const t=Gi[e];if(t.destroyed||!t.gameObject)continue;i.new_script_start.push(t)}catch(t){console.error(t),Fl(Gi[e],i),Gi.splice(e,1),e--}Gi.length=0;for(const e of i.new_scripts_post_setup_callbacks)e&&e();i.new_scripts_post_setup_callbacks.length=0}}function xY(i){i&&(i.__internalDisable(!0),Fl(i,i.context))}function Kk(i,e){for(let t=0;t<i.new_script_start.length;t++)try{const n=i.new_script_start[t];if(e!==void 0&&n.gameObject!==e||n.destroyed||n.activeAndEnabled===!1)continue;Tu(n.__internalAwake.bind(n)),n.enabled&&(Tu(n.__internalEnable.bind(n)),Tu(n.__internalStart.bind(n)),i.new_script_start.splice(t,1),t--)}catch(n){console.error(n),Fl(i.new_script_start[t],i),i.new_script_start.splice(t,1),t--}}function AE(i,e){e.scripts.indexOf(i)===-1&&(e.scripts.push(i),i.earlyUpdate&&e.scripts_earlyUpdate.push(i),i.update&&e.scripts_update.push(i),i.lateUpdate&&e.scripts_lateUpdate.push(i),i.onBeforeRender&&e.scripts_onBeforeRender.push(i),i.onAfterRender&&e.scripts_onAfterRender.push(i),i.onPausedChanged&&e.scripts_pausedChanged.push(i),yE(i,null)&&e.new_scripts_xr.push(i),yE(i,"immersive-vr")&&e.scripts_immersive_vr.push(i),yE(i,"immersive-ar")&&e.scripts_immersive_ar.push(i))}function Fl(i,e){wo(i,e.new_scripts),wo(i,e.new_script_start),wo(i,e.scripts),wo(i,e.scripts_earlyUpdate),wo(i,e.scripts_update),wo(i,e.scripts_lateUpdate),wo(i,e.scripts_onBeforeRender),wo(i,e.scripts_onAfterRender),wo(i,e.scripts_pausedChanged),wo(i,e.new_scripts_xr),wo(i,e.scripts_immersive_vr),wo(i,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(i)}function wo(i,e){const t=e.indexOf(i);t>=0&&e.splice(t,1)}function yE(i,e){var t;if(i){const n=i;if(n.onBeforeXR||n.onEnterXR||n.onUpdateXR||n.onLeaveXR||n.onXRControllerAdded||n.onXRControllerRemoved)return!(e!=null&&((t=n.supportsXR)==null?void 0:t.call(n,e))===!1)}return!1}function cb(i){if(i||(i=li.Current.scene),!i){console.trace("Invalid call - no current context.");return}const e=Lp(i);Zk(i,e,!0)||(vE||pt()?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())"`),e):(this.coroutines[t]||(this.coroutines[t]=[]),this.coroutines[t].push({comp:i,main:e}),e)}unregisterCoroutineUpdate(i,e){if(!this.coroutines[e])return;const t=this.coroutines[e].findIndex(n=>n.main===i);t>=0&&this.coroutines[e].splice(t,1)}stopAllCoroutinesFrom(i){for(const e in this.coroutines){const t=this.coroutines[e];for(let n=t.length-1;n>=0;n--)t[n].comp===i&&t.splice(n,1)}}setCurrentCamera(i){var e;if(!i)return;if(i.cam||i.buildCamera(),!i.cam){console.warn("Camera component is missing camera",i);return}const t=this._cameraStack.indexOf(i);t>=0&&this._cameraStack.splice(t,1),this._cameraStack.push(i),this.mainCameraComponent=i;const n=i.cam;n.isPerspectiveCamera&&this.updateAspect(n),(e=this.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()}removeCamera(i){if(!i)return;const e=this._cameraStack.indexOf(i);if(e>=0&&this._cameraStack.splice(e,1),this.mainCameraComponent===i&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const t=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(t)}}addBeforeRenderListener(i,e){this._onBeforeRenderListeners.has(i.uuid)||(this._onBeforeRenderListeners.set(i.uuid,[]),i.onBeforeRender=this._createRenderCallbackWrapper(i,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(i.uuid).push(e)}removeBeforeRenderListener(i,e){if(this._onBeforeRenderListeners.has(i.uuid)){const t=this._onBeforeRenderListeners.get(i.uuid),n=t.indexOf(e);n>=0&&t.splice(n,1)}}addAfterRenderListener(i,e){var t;this._onAfterRenderListeners.has(i.uuid)||(this._onAfterRenderListeners.set(i.uuid,[]),i.onAfterRender=this._createRenderCallbackWrapper(i,this._onAfterRenderListeners)),(t=this._onAfterRenderListeners.get(i.uuid))==null||t.push(e)}removeAfterRenderListener(i,e){if(this._onAfterRenderListeners.has(i.uuid)){const t=this._onAfterRenderListeners.get(i.uuid),n=t.indexOf(e);n>=0&&t.splice(n,1)}}_createRenderCallbackWrapper(i,e){return(t,n,r,s,o,a)=>{const l=e.get(i.uuid);if(l)for(let c=0;c<l.length;c++){const u=l[c];u(t,n,r,s,o,a)}}}get isRendering(){return this._isRendering}setRequireDepth(i){this._requireDepthTexture=i}setRequireColor(i){this._requireColorTexture=i}get depthTexture(){var i;return((i=this._renderTarget)==null?void 0:i.depthTexture)||null}get opaqueColorTexture(){var i;return((i=this._renderTarget)==null?void 0:i.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const i=getComputedStyle(this.domElement);return i.visibility!=="hidden"&&i.display!=="none"&&i.opacity!=="0"}async internalOnCreate(i){var e,t,n,r,s;const o=++this._createId;br&&console.log("Creating context",this.name,i);const a=globalThis["needle:dependencies:ready"];a instanceof Promise&&(br&&console.log("Waiting for dependencies to be ready"),await a.catch(d=>{(br||pt())&&console.error("Needle Engine dependencies failed to load",d)}).then(()=>{br&&console.log("Needle Engine dependencies are ready")})),this.clear(),this.isManagedExternally===!1&&(this.createNewRenderer(),(e=this.renderer)==null||e.setAnimationLoop(null)),await ea(1),Vi.Current=this,await li.dispatchCallback(En.ContextCreationStart,this);let l=!0,c;try{Vi.Current=this,i?c=await this.internalLoadInitialContent(o,i):c=[]}catch(d){console.error(d),l=!1}if(!l||o!==this._createId)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return br&&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),Vi.Current=this,Vi.Current=this;for(let d=0;d<this.new_scripts.length;d++){const p=this.new_scripts[d];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 f=p.gameObject.userData.components;f.includes(p)||f.push(p)}}if(this.post_setup_callbacks)for(let d=0;d<this.post_setup_callbacks.length;d++)Vi.Current=this,await this.post_setup_callbacks[d](this);if(!this.mainCamera){Vi.Current=this;let d=null;Fu(this.scene,p=>{const f=p;if(f!=null&&f.isCamera){if(dg(f.gameObject),!f.activeAndEnabled)return;if(f.tag==="MainCamera")return d=f,!0;d=f}}),d?this.setCurrentCamera(d):!li.dispatchCallback(En.MissingCamera,this,{files:c})&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(this.input.bindEvents(),Vi.Current=this,lb(this),this.physics.engine&&((t=this.physics.engine)==null||t.step(0),(n=this.physics.engine)==null||n.postStep()),!this.isManagedExternally&&this.composer&&this.mainCamera){const d=new pb(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(d),this.composer.setSize(this.domWidth,this.domHeight)}this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(r=this.domElement.shadowRoot)==null||r.appendChild(this._stats.dom)),br&&Jy(this.scene,!0),this.targetFrameRate===void 0?(br&&console.warn("No target framerate set, using default",Vi.DefaultTargetFrameRate),this.targetFrameRate=Vi._defaultTargetFramerate):br&&console.log("Target framerate set to",this.targetFrameRate),this._dispatchReadyAfterFrame=!0;const u=li.dispatchCallback(En.ContextCreated,this,{files:c});return u&&("internalSetLoadingMessage"in this.domElement&&typeof this.domElement.internalSetLoadingMessage=="function"&&((s=this.domElement)==null||s.internalSetLoadingMessage("finish loading")),await u),Pu(this,En.ContextCreated),br&&console.log("Context Created...",this.renderer,this.renderer.domElement),this._isCreating=!1,this.isManagedExternally||this.restartRenderLoop(),u}async internalLoadInitialContent(i,e){var t,n;const r=new Array;if(e.files.length===0)return r;const s=[...e.files],o={name:"",progress:null,index:0,count:s.length},a=Vo(),l=0;for(let c=0;c<s.length;c++){if(i!==this._createId){br&&console.log("Aborting loading because create id changed",i,this._createId);break}const u=s[c];if(!u.includes(".glb")&&!u.includes(".gltf")){const p=`Needle Engine: found suspicious src "${u}"`;console.warn(p),Ps()&&ji(p)}(t=e?.onLoadingStart)==null||t.call(this,c,u),br&&console.log("Context Load "+u);const d=await a.loadSync(this,u,u,l,p=>{var f;o.name=u,o.progress=p,o.index=c,o.count=s.length,(f=e.onLoadingProgress)==null||f.call(this,o)});(n=e?.onLoadingFinished)==null||n.call(this,c,u,d??null),d?r.push({src:u,file:d}):console.warn("Could not load file: "+u)}if(i!==this._createId){for(const c of r)if(c&&c.file)for(const u of c.file.scenes)la(u,!0,!0)}else for(const c of r)c&&c.file&&this.scene.add(c.file.scene);return r}restartRenderLoop(){return this.renderer?this._isCreating?(console.warn("Can not start render loop while creating context"),!1):(this.renderer.setAnimationLoop((i,e)=>{this.isManagedExternally||this.update(i,e)}),!0):(console.error("Can not start render loop without renderer"),!1)}update(i,e){if(e===void 0&&(e=null),pt()||br||_Y())try{this.internalStep(i,e),this._renderlooperrors=0}catch(t){this._renderlooperrors+=1,(pt()||br)&&(t instanceof Error||t instanceof TypeError)&&cn("Caught unhandled exception during render-loop - see console for details.",Vs.Error),console.error("Frame #"+this.time.frame+`
|
|
5255
5255
|
`,t),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}else this.internalStep(i,e)}updatePhysics(i){this.internalUpdatePhysics(i)}internalStep(i,e){this.internalOnBeforeRender(i,e)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(i,e){var t;const n=e!==null&&this._xrFrame===null;if(this._xrFrame=e,n&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:e}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=i),this._accumulatedTime+=(i-this._lastTimestamp)/1e3,this._lastTimestamp=i;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return!1;this._accumulatedTime=0}if((t=this._stats)==null||t.begin(),Vi.Current=this,this.onHandlePaused())return!1;for(Vi.Current=this,this.time.update(),uee&&console.log("FPS",this.time.smoothedFps.toFixed(0)),lb(this),cb(this.scene),Kk(this),Pu(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 s=this.scripts_earlyUpdate[r];s.activeAndEnabled&&s.earlyUpdate!==void 0&&(Vi.Current=this,s.earlyUpdate())}if(this.executeCoroutines(0),Pu(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const s=this.scripts_update[r];s.activeAndEnabled&&s.update!==void 0&&(Vi.Current=this,s.update())}if(this.executeCoroutines(1),Pu(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const s=this.scripts_lateUpdate[r];s.activeAndEnabled&&s.lateUpdate!==void 0&&(Vi.Current=this,s.lateUpdate())}if(this.executeCoroutines(2),Pu(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 s=this.scripts_onBeforeRender[r];s.activeAndEnabled&&s.onBeforeRender!==void 0&&(Vi.Current=this,s.onBeforeRender(e))}if(this.executeCoroutines(3),Pu(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r](e)}return!0}internalUpdatePhysics(i){if(!this.physics.engine)return!1;const e=i,t=this.time.deltaTime/e;for(let n=0;n<e;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(t),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 i=0;i<this.scripts_onAfterRender.length;i++){const e=this.scripts_onAfterRender[i];e.activeAndEnabled&&e.onAfterRender!==void 0&&(Vi.Current=this,e.onAfterRender())}if(this.executeCoroutines(4),Pu(this,4),this.post_render_callbacks)for(const i in this.post_render_callbacks)this.post_render_callbacks[i]()}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")),li.dispatchCallback(En.ContextFirstFrameRendered,this))}renderNow(i){return!i&&(i=this.mainCamera,!i)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):i&&this.renderer.render(this.scene,i),this._isRendering=!1,!0)}onHandlePaused(){const i=this.evaluatePaused();if(this._wasPaused!==i){hee&&console.log("Paused?",i,"context:"+this.alias);for(let e=0;e<this.scripts_pausedChanged.length;e++){const t=this.scripts_pausedChanged[e];t.activeAndEnabled&&t.onPausedChanged!==void 0&&(Vi.Current=this,t.onPausedChanged(i,this._wasPaused))}}return this._wasPaused=i,i}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 Ht(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new sp(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new Tt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ut,this._renderTarget.texture.magFilter=Ut,this._renderTarget.texture.format=di)}const i=this._renderTarget;i.texture&&(i.texture.colorSpace=this.renderer.outputColorSpace);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(i),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(i){var e;if(this.coroutines[i]){const n=this.coroutines[i];for(let r=0;r<n.length;r++)try{const s=n[r];if(!s.comp||s.comp.destroyed||!s.main||s.comp.enabled===!1){dee&&console.log("Removing coroutine",s.comp,s.comp.enabled),n.splice(r,1),--r;continue}const o=s.chained;if(o&&o.length>0){const c=o[o.length-1].next();if(c.done&&o.pop(),t(c)&&(s.chained||(s.chained=[]),s.chained.push(c.value)),!c.done)continue}const a=s.main.next();if(a.done===!0){n.splice(r,1),--r;continue}const l=a.value;if(t(l)){if(l.next().done)continue;s.chained||(s.chained=[]),s.chained.push(l)}else if(l instanceof Promise){const c=l;s.chained||(s.chained=[]);const u=_3(c);(e=s.chained)==null||e.push(u);continue}}catch(s){console.error(s)}}function t(n){return!!(n&&n.next&&n.return)}}};let kt=Vi;h(kt,"_defaultTargetFramerate",{value:60}),h(kt,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"}),li.registerCallback(En.ContextCreated,i=>{const e=i.context;aF(e),sF(e)});const e_=ee("debugcomponents"),tF="eff8ba80-635d-11ec-90d6-0242ac120003";class or{constructor(e){h(this,"_originalSeed"),h(this,"_seed"),typeof e=="string"&&(e=or.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 tL(e,tF);const t=this._seed;return this._seed-=1,tL(t.toString(),tF)}initialize(e){typeof e=="string"?this._seed=or.hash(e):this._seed=e}static createFromString(e){return new or(this.hash(e))}static hash(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return t}}var iF=(i=>(i.NewInstanceCreated="new-instance-created",i.InstanceDestroyed="instance-destroyed",i))(iF||{});class nF{constructor(e){h(this,"guid"),this.guid=e}}function t_(i,e,t=!0){if(!i)return;const n=i;if(la(i,t),!e){console.warn("Can not send destroy: No networking connection provided",i.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",i.guid);return}let r=i.guid;if(!r&&n.uuid&&(r=n.uuid),!r){console.warn("Can not send destroy: failed to find guid",i);return}const s=new nF(r);e.send("instance-destroyed",s,ra.Queued)}function rF(i,e){const t=new nF(i);e.send("instance-destroyed",t,ra.Queued)}function sF(i){i.connection.beginListen("instance-destroyed",e=>{e_&&console.log("[Remote] Destroyed",i.scene,e);const t=Ng(e.guid,i.scene);t&&la(t)})}class mee{constructor(e,t,n){h(this,"filename"),h(this,"hash"),h(this,"size"),this.filename=e,this.hash=t,this.size=n}}class oF{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 QM(i,e,t,n){var r;const s=i;if(!s.guid)return console.warn("Can not instantiate: No guid",s),null;if(e.context||(e.context=kt.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const o=e?{...e}:null,{instance:a,seed:l}=gee(s,e);if(a){const c=a;if(c.guid){e_&&console.log("[Local] new instance","gameobject:",a?.guid);const u=new oF(s.guid,c.guid);u.seed=l,o&&(o.position&&(u.position={x:o.position.x,y:o.position.y,z:o.position.z}),o.rotation&&(u.rotation={x:o.rotation.x,y:o.rotation.y,z:o.rotation.z,w:o.rotation.w}),o.scale&&(u.scale={x:o.scale.x,y:o.scale.y,z:o.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=s.visible,o!=null&&o.parent&&(typeof o.parent=="string"?u.parent=o.parent:u.parent=o.parent.guid),u.hostData=t,n===!1&&(u.dontSave=!0),(r=e?.context)==null||r.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return a}function i_(){return Math.random()*9999999}function aF(i){i.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,i.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const n=new Aa;e.position&&(n.position=new S(e.position.x,e.position.y,e.position.z)),e.rotation&&(n.rotation=new Me(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(n.scale=new S(e.scale.x,e.scale.y,e.scale.z)),n.parent=e.parent,e.seed&&(n.idProvider=new or(e.seed)),n.visible=e.visible,n.context=i,e_&&i.alias&&console.log("[Remote] instantiate in: "+i.alias);const r=Up(t,n);r&&(e.parent==="scene"&&i.scene.add(r),e_&&console.log("[Remote] new instance","gameobject:",r?.guid,t))})}function gee(i,e){const t=i_(),n=e??new Aa;n.idProvider=new or(t);const r=Up(i,n);return{seed:t,instance:r}}const lF={};function cF(i,e){lF[i]=e}async function vee(i,e){const t=lF[i];if(t!=null){const n=await t(i);if(n)return n}return hF(i,e)}function hF(i,e){if(e===null||!i)return null;if(e.guid===i)return e;if(e.children)for(const t of e.children){const n=hF(i,t);if(n)return n}return null}const n_=ee("debuggetcomponent"),r_=ee("debuginstantiate");var uF=(i=>(i[i.None=0]="None",i[i.HideInHierarchy=1]="HideInHierarchy",i[i.HideInInspector=2]="HideInInspector",i[i.DontSaveInEditor=4]="DontSaveInEditor",i[i.NotEditable=8]="NotEditable",i[i.DontSaveInBuild=16]="DontSaveInBuild",i[i.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",i[i.DontSave=52]="DontSave",i[i.HideAndDontSave=61]="HideAndDontSave",i))(uF||{});class Aa{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 e,t,n;const r=new Aa;return r.idProvider=this.idProvider,r.parent=this.parent,r.keepWorldPosition=this.keepWorldPosition,r.position=(e=this.position)==null?void 0:e.clone(),r.rotation=(t=this.rotation)==null?void 0:t.clone(),r.scale=(n=this.scale)==null?void 0:n.clone(),r}cloneAssign(e){var t,n,r;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(n=e.rotation)==null?void 0:n.clone(),this.scale=(r=e.scale)==null?void 0:r.clone()}}function Lp(i){return i.visible}function Fg(i,e){return typeof e=="number"&&(e=e>.5),i.visible=e,i.visible}function dF(i){return i[Ul]||s_(i)}function pF(i,e){i[Yk]=e}function s_(i){return ba.isUsingInstancing(i)}function Ng(i,e){return vp(i,e,!0,!0)}const fF=Symbol("isDestroyed");function Uu(i){return i[fF]}function mF(i,e){i[fF]=e}const GM=Symbol("isDontDestroy");function HM(i,e=!0){i[GM]=e}const o_=[],a_=[];function la(i,e=!0,t=!1){o_.length=0,a_.length=0,VM(i,e,t,!0);for(const n of o_)n.gameObject=null,n.context=null;for(const n of a_)mF(n,!0),t&&Ii(n),Wk(n);a_.length=0,o_.length=0}function VM(i,e=!0,t=!1,n=!0){var r;if(i==null)return;const s=i;if(s.isComponent){if(s[GM])return;o_.push(s);const l=s.gameObject;s.__internalDisable(),s.__internalDestroy(),s.gameObject=l;return}if(i[GM])return;const o=i;n_&&console.log(o),a_.push(o);const a=(r=o.userData)==null?void 0:r.components;if(a!=null&&Array.isArray(a)){let l=a.length;for(let c=0;c<a.length;c++){const u=a[c];VM(u,e,t,!1),a.length<l&&(l=a.length,c--)}}if(e&&o.children)for(const l of o.children)VM(l,e,t,!1);n&&o.removeFromParent()}function Fu(i,e,t=!0){return gF(i,e,t)}function*WM(i,e,t=!1,n=999,r=0){if(i!=null&&i.userData.components&&!(r>n)){for(const s of i.userData.components)e&&s?.isComponent===!0&&s instanceof e?yield s:yield s;if(t===!0)for(const s of i.children)yield*WM(s,e,!0,n,r+1)}}function gF(i,e,t,n=0){var r;if(i){if(i.isObject3D,n>1e3){console.warn("Failed to iterate components: too many levels");return}if((r=i.userData)!=null&&r.components)for(let s=0;s<i.userData.components.length;s++){const o=i.userData.components[s];if(o?.isComponent===!0){const a=e(o);if(a!==void 0)return a}}if(t&&i.children){const s=n+1;for(let o=0;o<i.children.length;o++){const a=i.children[o];if(!a)continue;const l=gF(a,e,t,s);if(l!==void 0)return l}}}}function Up(i,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Aa,t.position=e):t=e);let n=kt.Current;t!=null&&t.context&&(n=t.context),n_&&n.alias&&console.log("context",n.alias),t&&!t.idProvider&&(t.idProvider=new or(Date.now()));const r=[],s={},o={},a=vF(n,i,t,r,s,o);a&&(yee(s),Aee(o,s)),n_&&(Jy(i,!0),Jy(a,!0));const l={};for(const c in r){const u=r[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,n_&&console.log(u.name,u.guid)),$b(u,n),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in r){const u=r[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return lb(n),a}function vF(i,e,t,n,r,s){var o;if(!e)return null;const a=e.userData;e.userData={};const l=e.children;e.children=[];const c=e.clone(!1);if(l_(c),e.userData=a,e.children=l,r[e.uuid]={original:e,clone:c},r_&&console.log("ADD",e,c),e.type==="SkinnedMesh"&&(s[e.uuid]={original:e,clone:c}),t?.visible!==void 0&&(c.visible=t.visible),t!=null&&t.idProvider){c.uuid=t.idProvider.generateUUID();const d=c;d&&(d.guid=c.uuid)}e.animations&&e.animations.length>0&&(c.animations=[...e.animations]);const u=e.parent;if(u&&u.add(c),t!=null&&t.position?Gr(c,t.position):c.position.copy(e.position),t!=null&&t.rotation?xo(c,t.rotation):c.quaternion.copy(e.quaternion),t!=null&&t.scale?c.scale.copy(t.scale):c.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=vp(t.parent,i.scene,!0):d=t.parent,d){const p=t.keepWorldPosition===!0?d.attach:d.add;p?p.call(d,c):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,p]of Object.entries(e.userData))d!=="components"&&(c.userData[d]=p);if((o=e.userData)!=null&&o.components){const d=e.userData.components,p=[];c.userData.components=p;for(let f=0;f<d.length;f++){const m=d[f],A=new m.constructor;Tp(A,m),m[hg]!==void 0&&(A[hg]=m[hg]),p.push(A),A.gameObject=c,n.push(A),cg.dispatchComponentLifecycleEvent(lg.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 p=e.children[d],f=vF(i,p,t,n,r,s);f&&c.add(f)}return c}function Aee(i,e){for(const t in i){const n=i[t],r=n.original,s=r.skeleton,o=n.clone;if(!s){console.warn("Skinned mesh has no skeleton?",n);continue}const a=s.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(r.bindMatrix),o.bindMatrixInverse.copy(r.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 i){const n=i[t].clone;n.skeleton.update(),n.bind(n.skeleton,n.bindMatrix),n.updateMatrixWorld(!0)}}function yee(i){var e;for(const t in i){const n=i[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const s=n.userData.components[r],o=Object.entries(s);for(const[a,l]of o)if(Array.isArray(l)){const c=[];s[a]=c;for(let u=0;u<l.length;u++){const d=l[u];if(typeof d!="object"){c.push(d);continue}const p=AF(s,a,d,i);p!==void 0?c.push(p):c.push(d)}}else if(typeof l=="object"){const c=AF(s,a,l,i);c!==void 0&&(s[a]=c)}}}}function AF(i,e,t,n){var r,s;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(r=n[a])==null?void 0:r.clone;if(!l){r_&&console.log("reference did not change",e,i,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return r_&&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=(s=n[a])==null?void 0:s.clone;if(l)return r_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler||t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const yF=new Map;function bee(i,e){if(!i)return;if(!e){console.warn("No prototype found",i,i.prototype,i.constructor);return}const t=yF.get(e);t&&t.apply(i)}function _ee(i){const e=xee(i.prototype);yF.set(i,e)}function xee(i){return new wee(i)}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 n=this.extensions[t],r=Object.getOwnPropertyDescriptor(e,n);r&&this.descriptors.push(r)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const n=this.extensions[t],r=this.descriptors[t];r&&Object.defineProperty(e,n,r)}}}}function l_(i){i&&i.isObject3D===!0&&bee(i,ge)}ge.prototype.SetActive=function(i){this.visible=i},ge.prototype.setActive=function(i){this.visible=i},ge.prototype.destroy=function(){la(this)},ge.prototype.addComponent=function(i,e){return Nu(this,i,e)},ge.prototype.addNewComponent=function(i,e){return Nu(this,i,e)},ge.prototype.removeComponent=function(i){return qM(this,i)},ge.prototype.getOrAddComponent=function(i,e){return c_(this,i,e)},ge.prototype.getComponent=function(i){return Fp(this,i)},ge.prototype.getComponents=function(i,e){return zg(this,i,e)},ge.prototype.getComponentInChildren=function(i){return jg(this,i)},ge.prototype.getComponentsInChildren=function(i,e){return Qg(this,i,e)},ge.prototype.getComponentInParent=function(i){return Gg(this,i)},ge.prototype.getComponentsInParent=function(i,e){return h_(this,i,e)},Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Lp(this)},set:function(i){Fg(this,i)}}),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 lE?It(this.object):It(this)},set:function(i){Gr(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof lE?xi(this.object):xi(this)},set:function(i){xo(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return Zm(this)},set:function(i){rE(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return Ji(this)},set:function(i){Km(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return An().set(0,0,1).applyQuaternion(xi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return An().set(1,0,0).applyQuaternion(xi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return An().set(0,1,0).applyQuaternion(xi(this))}}),_ee(ge);const See=ee("debuggetcomponent"),bF=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(i){return i==null||i.isObject3D?i:i.object&&i.object.isObject3D?i.object:i}function qM(i,e){if(!i||!i.userData.components)return e;const t=i.userData.components.indexOf(e);return t<0||(cg.dispatchComponentLifecycleEvent(lg.Removing,e),e.gameObject=null,i.userData.components.splice(t,1)),e}function c_(i,e,t){return Fp(i,e)||Nu(i,e,t)}const _F=new or("addComponentIdProvider");function th(i,e,t=!0){i.userData||(i.userData={}),i.userData.components||(i.userData.components=[]),i.userData.components.push(e),e.gameObject=i,(e.guid===void 0||e.guid==="invalid")&&(e.guid=_F.generateUUID()),l_(i),$b(e);try{t&&e.__internalAwake&&(dg(i),e.activeAndEnabled&&e.__internalAwake()),cg.dispatchComponentLifecycleEvent(lg.Added,e)}catch(n){console.error(n)}return e}function Nu(i,e,t,n){if(typeof e=="function"){const r=new e;t&&r.__internalNewInstanceCreated(t);let s=!0;return n?.callAwake!=null&&(s=n.callAwake),th(i,r,s)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===i)return e;if(e.gameObject&&e.gameObject.userData.components){const r=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(r,1)}if(!i.userData.components)i.userData.components=[];else if(i.userData.components.includes(e))return e;return i.userData.components.push(e),e.gameObject=i,(e.guid===void 0||e.guid==="invalid")&&(e.guid=_F.generateUUID()),t&&e._internalInit(t),$b(e),e}function xF(i){if(i.gameObject&&i.gameObject.userData.components){const e=i.gameObject.userData.components.indexOf(i);i.gameObject.userData.components.splice(e,1)}i.__internalDisable&&i.__internalDisable(),Fl(i,i.context??kt.Current),i.destroy(),i.gameObject=null}let wF=!1;function SF(i,e,t){var n;if(i==null)return null;if(!i.isObject3D)return console.error("Object is not object3D"),null;if(!((n=i?.userData)!=null&&n.components)||(typeof e=="string"&&(wF||(wF=!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")),li.dispatchCallback(En.ContextFirstFrameRendered,this))}renderNow(i){return!i&&(i=this.mainCamera,!i)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):i&&this.renderer.render(this.scene,i),this._isRendering=!1,!0)}onHandlePaused(){const i=this.evaluatePaused();if(this._wasPaused!==i){hee&&console.log("Paused?",i,"context:"+this.alias);for(let e=0;e<this.scripts_pausedChanged.length;e++){const t=this.scripts_pausedChanged[e];t.activeAndEnabled&&t.onPausedChanged!==void 0&&(Vi.Current=this,t.onPausedChanged(i,this._wasPaused))}}return this._wasPaused=i,i}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 Ht(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new sp(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new Tt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ut,this._renderTarget.texture.magFilter=Ut,this._renderTarget.texture.format=di)}const i=this._renderTarget;i.texture&&(i.texture.colorSpace=this.renderer.outputColorSpace);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(i),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(i){var e;if(this.coroutines[i]){const n=this.coroutines[i];for(let r=0;r<n.length;r++)try{const s=n[r];if(!s.comp||s.comp.destroyed||!s.main||s.comp.enabled===!1){dee&&console.log("Removing coroutine",s.comp,s.comp.enabled),n.splice(r,1),--r;continue}const o=s.chained;if(o&&o.length>0){const c=o[o.length-1].next();if(c.done&&o.pop(),t(c)&&(s.chained||(s.chained=[]),s.chained.push(c.value)),!c.done)continue}const a=s.main.next();if(a.done===!0){n.splice(r,1),--r;continue}const l=a.value;if(t(l)){if(l.next().done)continue;s.chained||(s.chained=[]),s.chained.push(l)}else if(l instanceof Promise){const c=l;s.chained||(s.chained=[]);const u=_3(c);(e=s.chained)==null||e.push(u);continue}}catch(s){console.error(s)}}function t(n){return!!(n&&n.next&&n.return)}}};let kt=Vi;h(kt,"_defaultTargetFramerate",{value:60}),h(kt,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:"high-performance"}),li.registerCallback(En.ContextCreated,i=>{const e=i.context;aF(e),sF(e)});const e_=ee("debugcomponents"),tF="eff8ba80-635d-11ec-90d6-0242ac120003";class or{constructor(e){h(this,"_originalSeed"),h(this,"_seed"),typeof e=="string"&&(e=or.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 tL(e,tF);const t=this._seed;return this._seed-=1,tL(t.toString(),tF)}initialize(e){typeof e=="string"?this._seed=or.hash(e):this._seed=e}static createFromString(e){return new or(this.hash(e))}static hash(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return t}}var iF=(i=>(i.NewInstanceCreated="new-instance-created",i.InstanceDestroyed="instance-destroyed",i))(iF||{});class nF{constructor(e){h(this,"guid"),this.guid=e}}function t_(i,e,t=!0){if(!i)return;const n=i;if(la(i,t),!e){console.warn("Can not send destroy: No networking connection provided",i.guid);return}if(!e.isConnected){console.warn("Can not send destroy: not connected",i.guid);return}let r=i.guid;if(!r&&n.uuid&&(r=n.uuid),!r){console.warn("Can not send destroy: failed to find guid",i);return}const s=new nF(r);e.send("instance-destroyed",s,ra.Queued)}function rF(i,e){const t=new nF(i);e.send("instance-destroyed",t,ra.Queued)}function sF(i){i.connection.beginListen("instance-destroyed",e=>{e_&&console.log("[Remote] Destroyed",i.scene,e);const t=Ng(e.guid,i.scene);t&&la(t)})}class mee{constructor(e,t,n){h(this,"filename"),h(this,"hash"),h(this,"size"),this.filename=e,this.hash=t,this.size=n}}class oF{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 QM(i,e,t,n){var r;const s=i;if(!s.guid)return console.warn("Can not instantiate: No guid",s),null;if(e.context||(e.context=kt.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const o=e?{...e}:null,{instance:a,seed:l}=gee(s,e);if(a){const c=a;if(c.guid){e_&&console.log("[Local] new instance","gameobject:",a?.guid);const u=new oF(s.guid,c.guid);u.seed=l,o&&(o.position&&(u.position={x:o.position.x,y:o.position.y,z:o.position.z}),o.rotation&&(u.rotation={x:o.rotation.x,y:o.rotation.y,z:o.rotation.z,w:o.rotation.w}),o.scale&&(u.scale={x:o.scale.x,y:o.scale.y,z:o.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=s.visible,o!=null&&o.parent&&(typeof o.parent=="string"?u.parent=o.parent:u.parent=o.parent.guid),u.hostData=t,n===!1&&(u.dontSave=!0),(r=e?.context)==null||r.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",c)}return a}function i_(){return Math.random()*9999999}function aF(i){i.connection.beginListen("new-instance-created",async e=>{const t=await vee(e.originalGuid,i.scene);if(e.preventCreation===!0)return;if(!t){console.warn("could not find object that was instantiated: "+e.guid);return}const n=new Aa;e.position&&(n.position=new S(e.position.x,e.position.y,e.position.z)),e.rotation&&(n.rotation=new Me(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(n.scale=new S(e.scale.x,e.scale.y,e.scale.z)),n.parent=e.parent,e.seed&&(n.idProvider=new or(e.seed)),n.visible=e.visible,n.context=i,e_&&i.alias&&console.log("[Remote] instantiate in: "+i.alias);const r=Up(t,n);r&&(e.parent==="scene"&&i.scene.add(r),e_&&console.log("[Remote] new instance","gameobject:",r?.guid,t))})}function gee(i,e){const t=i_(),n=e??new Aa;n.idProvider=new or(t);const r=Up(i,n);return{seed:t,instance:r}}const lF={};function cF(i,e){lF[i]=e}async function vee(i,e){const t=lF[i];if(t!=null){const n=await t(i);if(n)return n}return hF(i,e)}function hF(i,e){if(e===null||!i)return null;if(e.guid===i)return e;if(e.children)for(const t of e.children){const n=hF(i,t);if(n)return n}return null}const n_=ee("debuggetcomponent"),r_=ee("debuginstantiate");var uF=(i=>(i[i.None=0]="None",i[i.HideInHierarchy=1]="HideInHierarchy",i[i.HideInInspector=2]="HideInInspector",i[i.DontSaveInEditor=4]="DontSaveInEditor",i[i.NotEditable=8]="NotEditable",i[i.DontSaveInBuild=16]="DontSaveInBuild",i[i.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",i[i.DontSave=52]="DontSave",i[i.HideAndDontSave=61]="HideAndDontSave",i))(uF||{});class Aa{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 e,t,n;const r=new Aa;return r.idProvider=this.idProvider,r.parent=this.parent,r.keepWorldPosition=this.keepWorldPosition,r.position=(e=this.position)==null?void 0:e.clone(),r.rotation=(t=this.rotation)==null?void 0:t.clone(),r.scale=(n=this.scale)==null?void 0:n.clone(),r}cloneAssign(e){var t,n,r;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(t=e.position)==null?void 0:t.clone(),this.rotation=(n=e.rotation)==null?void 0:n.clone(),this.scale=(r=e.scale)==null?void 0:r.clone()}}function Lp(i){return i.visible}function Fg(i,e){return typeof e=="number"&&(e=e>.5),i.visible=e,i.visible}function dF(i){return i[Ul]||s_(i)}function pF(i,e){i[Yk]=e}function s_(i){return ba.isUsingInstancing(i)}function Ng(i,e){return vp(i,e,!0,!0)}const fF=Symbol("isDestroyed");function Uu(i){return i[fF]}function mF(i,e){i[fF]=e}const GM=Symbol("isDontDestroy");function HM(i,e=!0){i[GM]=e}const o_=[],a_=[];function la(i,e=!0,t=!1){o_.length=0,a_.length=0,VM(i,e,!0);for(const n of o_)n.gameObject=null,n.context=null;for(const n of a_)mF(n,!0),t&&Ii(n),Wk(n);a_.length=0,o_.length=0}function VM(i,e=!0,t=!0){var n;if(i==null)return;const r=i;if(r.isComponent){if(r[GM])return;o_.push(r);const a=r.gameObject;r.__internalDisable(),r.__internalDestroy(),r.gameObject=a;return}if(i[GM])return;const s=i;n_&&console.log(s),a_.push(s);const o=(n=s.userData)==null?void 0:n.components;if(o!=null&&Array.isArray(o)){let a=o.length;for(let l=0;l<o.length;l++){const c=o[l];VM(c,e,!1),o.length<a&&(a=o.length,l--)}}if(e&&s.children)for(const a of s.children)VM(a,e,!1);t&&s.removeFromParent()}function Fu(i,e,t=!0){return gF(i,e,t)}function*WM(i,e,t=!1,n=999,r=0){if(i!=null&&i.userData.components&&!(r>n)){for(const s of i.userData.components)e&&s?.isComponent===!0&&s instanceof e?yield s:yield s;if(t===!0)for(const s of i.children)yield*WM(s,e,!0,n,r+1)}}function gF(i,e,t,n=0){var r;if(i){if(i.isObject3D,n>1e3){console.warn("Failed to iterate components: too many levels");return}if((r=i.userData)!=null&&r.components)for(let s=0;s<i.userData.components.length;s++){const o=i.userData.components[s];if(o?.isComponent===!0){const a=e(o);if(a!==void 0)return a}}if(t&&i.children){const s=n+1;for(let o=0;o<i.children.length;o++){const a=i.children[o];if(!a)continue;const l=gF(a,e,t,s);if(l!==void 0)return l}}}}function Up(i,e=null){let t=null;e!==null&&(e.x!==void 0?(t=new Aa,t.position=e):t=e);let n=kt.Current;t!=null&&t.context&&(n=t.context),n_&&n.alias&&console.log("context",n.alias),t&&!t.idProvider&&(t.idProvider=new or(Date.now()));const r=[],s={},o={},a=vF(n,i,t,r,s,o);a&&(yee(s),Aee(o,s)),n_&&(Jy(i,!0),Jy(a,!0));const l={};for(const c in r){const u=r[c],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),l[d]=u.guid,n_&&console.log(u.name,u.guid)),$b(u,n),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const c in r){const u=r[c];u.resolveGuids&&u.resolveGuids(l),u.enabled!==!1&&(u.enabled=!0)}return lb(n),a}function vF(i,e,t,n,r,s){var o;if(!e)return null;const a=e.userData;e.userData={};const l=e.children;e.children=[];const c=e.clone(!1);if(l_(c),e.userData=a,e.children=l,r[e.uuid]={original:e,clone:c},r_&&console.log("ADD",e,c),e.type==="SkinnedMesh"&&(s[e.uuid]={original:e,clone:c}),t?.visible!==void 0&&(c.visible=t.visible),t!=null&&t.idProvider){c.uuid=t.idProvider.generateUUID();const d=c;d&&(d.guid=c.uuid)}e.animations&&e.animations.length>0&&(c.animations=[...e.animations]);const u=e.parent;if(u&&u.add(c),t!=null&&t.position?Gr(c,t.position):c.position.copy(e.position),t!=null&&t.rotation?xo(c,t.rotation):c.quaternion.copy(e.quaternion),t!=null&&t.scale?c.scale.copy(t.scale):c.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=vp(t.parent,i.scene,!0):d=t.parent,d){const p=t.keepWorldPosition===!0?d.attach:d.add;p?p.call(d,c):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,p]of Object.entries(e.userData))d!=="components"&&(c.userData[d]=p);if((o=e.userData)!=null&&o.components){const d=e.userData.components,p=[];c.userData.components=p;for(let f=0;f<d.length;f++){const m=d[f],A=new m.constructor;Tp(A,m),m[hg]!==void 0&&(A[hg]=m[hg]),p.push(A),A.gameObject=c,n.push(A),cg.dispatchComponentLifecycleEvent(lg.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 p=e.children[d],f=vF(i,p,t,n,r,s);f&&c.add(f)}return c}function Aee(i,e){for(const t in i){const n=i[t],r=n.original,s=r.skeleton,o=n.clone;if(!s){console.warn("Skinned mesh has no skeleton?",n);continue}const a=s.bones,l=o.skeleton.clone();o.skeleton=l,o.bindMatrix.clone().copy(r.bindMatrix),o.bindMatrixInverse.copy(r.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 i){const n=i[t].clone;n.skeleton.update(),n.bind(n.skeleton,n.bindMatrix),n.updateMatrixWorld(!0)}}function yee(i){var e;for(const t in i){const n=i[t].clone;if((e=n.userData)!=null&&e.components)for(let r=0;r<n.userData.components.length;r++){const s=n.userData.components[r],o=Object.entries(s);for(const[a,l]of o)if(Array.isArray(l)){const c=[];s[a]=c;for(let u=0;u<l.length;u++){const d=l[u];if(typeof d!="object"){c.push(d);continue}const p=AF(s,a,d,i);p!==void 0?c.push(p):c.push(d)}}else if(typeof l=="object"){const c=AF(s,a,l,i);c!==void 0&&(s[a]=c)}}}}function AF(i,e,t,n){var r,s;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,l=(r=n[a])==null?void 0:r.clone;if(!l){r_&&console.log("reference did not change",e,i,t);return}const c=o.userData.components.indexOf(t);if(c>=0)return r_&&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=(s=n[a])==null?void 0:s.clone;if(l)return r_&&console.log(e,"old",t,"new",l),l}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler||t.isColor===!0)return t.clone();if(t.isEventList===!0)return new t.constructor}}const yF=new Map;function bee(i,e){if(!i)return;if(!e){console.warn("No prototype found",i,i.prototype,i.constructor);return}const t=yF.get(e);t&&t.apply(i)}function _ee(i){const e=xee(i.prototype);yF.set(i,e)}function xee(i){return new wee(i)}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 n=this.extensions[t],r=Object.getOwnPropertyDescriptor(e,n);r&&this.descriptors.push(r)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let t=0;t<this.extensions.length;t++){const n=this.extensions[t],r=this.descriptors[t];r&&Object.defineProperty(e,n,r)}}}}function l_(i){i&&i.isObject3D===!0&&bee(i,ge)}ge.prototype.SetActive=function(i){this.visible=i},ge.prototype.setActive=function(i){this.visible=i},ge.prototype.destroy=function(){la(this)},ge.prototype.addComponent=function(i,e){return Nu(this,i,e)},ge.prototype.addNewComponent=function(i,e){return Nu(this,i,e)},ge.prototype.removeComponent=function(i){return qM(this,i)},ge.prototype.getOrAddComponent=function(i,e){return c_(this,i,e)},ge.prototype.getComponent=function(i){return Fp(this,i)},ge.prototype.getComponents=function(i,e){return zg(this,i,e)},ge.prototype.getComponentInChildren=function(i){return jg(this,i)},ge.prototype.getComponentsInChildren=function(i,e){return Qg(this,i,e)},ge.prototype.getComponentInParent=function(i){return Gg(this,i)},ge.prototype.getComponentsInParent=function(i,e){return h_(this,i,e)},Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return Lp(this)},set:function(i){Fg(this,i)}}),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 lE?It(this.object):It(this)},set:function(i){Gr(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof lE?xi(this.object):xi(this)},set:function(i){xo(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return Zm(this)},set:function(i){rE(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return Ji(this)},set:function(i){Km(this,i)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return An().set(0,0,1).applyQuaternion(xi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return An().set(1,0,0).applyQuaternion(xi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return An().set(0,1,0).applyQuaternion(xi(this))}}),_ee(ge);const See=ee("debuggetcomponent"),bF=()=>See||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function Cee(i){return i==null||i.isObject3D?i:i.object&&i.object.isObject3D?i.object:i}function qM(i,e){if(!i||!i.userData.components)return e;const t=i.userData.components.indexOf(e);return t<0||(cg.dispatchComponentLifecycleEvent(lg.Removing,e),e.gameObject=null,i.userData.components.splice(t,1)),e}function c_(i,e,t){return Fp(i,e)||Nu(i,e,t)}const _F=new or("addComponentIdProvider");function th(i,e,t=!0){i.userData||(i.userData={}),i.userData.components||(i.userData.components=[]),i.userData.components.push(e),e.gameObject=i,(e.guid===void 0||e.guid==="invalid")&&(e.guid=_F.generateUUID()),l_(i),$b(e);try{t&&e.__internalAwake&&(dg(i),e.activeAndEnabled&&e.__internalAwake()),cg.dispatchComponentLifecycleEvent(lg.Added,e)}catch(n){console.error(n)}return e}function Nu(i,e,t,n){if(typeof e=="function"){const r=new e;t&&r.__internalNewInstanceCreated(t);let s=!0;return n?.callAwake!=null&&(s=n.callAwake),th(i,r,s)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===i)return e;if(e.gameObject&&e.gameObject.userData.components){const r=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(r,1)}if(!i.userData.components)i.userData.components=[];else if(i.userData.components.includes(e))return e;return i.userData.components.push(e),e.gameObject=i,(e.guid===void 0||e.guid==="invalid")&&(e.guid=_F.generateUUID()),t&&e._internalInit(t),$b(e),e}function xF(i){if(i.gameObject&&i.gameObject.userData.components){const e=i.gameObject.userData.components.indexOf(i);i.gameObject.userData.components.splice(e,1)}i.__internalDisable&&i.__internalDisable(),Fl(i,i.context??kt.Current),i.destroy(),i.gameObject=null}let wF=!1;function SF(i,e,t){var n;if(i==null)return null;if(!i.isObject3D)return console.error("Object is not object3D"),null;if(!((n=i?.userData)!=null&&n.components)||(typeof e=="string"&&(wF||(wF=!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))),bF()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let r=0;r<i.userData.components.length;r++){const s=i.userData.components[r];let o=Object.getPrototypeOf(s);for(;o;){if(o===e.prototype)if(bF()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(s);else return s;o=Object.getPrototypeOf(o)}}return t||null}function Fp(i,e){const t=SF(i,e);return t?Array.isArray(t)?t[0]:t:null}function zg(i,e,t,n=!0){return t||(t=[]),n&&(t.length=0),SF(i,e,t),t}function jg(i,e,t){var n;const r=Fp(i,e);if(t===!1&&r?.enabled===!1)return null;if(r)return r;for(let s=0;s<((n=i?.children)==null?void 0:n.length);s++){const o=jg(i.children[s],e);if(o)return o}return null}function Qg(i,e,t,n=!0){var r;t||(t=[]),n&&(t.length=0),zg(i,e,t,!1);for(let s=0;s<((r=i?.children)==null?void 0:r.length);s++)Qg(i.children[s],e,t,!1);return t}function Gg(i,e){if(!i)return null;if(Array.isArray(i)){for(let n=0;n<i.length;n++){const r=Cee(i[n]),s=Gg(r,e);if(s)return s}return null}return Fp(i,e)||(i.parent?Gg(i.parent,e):null)}function h_(i,e,t,n=!0){return t||(t=[]),n&&(t.length=0),i?(zg(i,e,t,!1),i.parent?h_(i.parent,e,t,!1):t):t}function CF(i,e,t){if(!i)return null;if(!e&&(e=kt.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let n=e;if(n.isScene||(n=e?.scene),!n)return null;for(const r in n.children){const s=n.children[r];if(t===!1&&s[Ul]===!1)continue;const o=jg(s,i);if(o)return o}return null}function EF(i,e,t){if(!i)return e;if(e||(e=[]),e.length=0,!t&&(t=kt.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const n=t.isScene===!0||t.isObject3D===!0?t:t?.scene;if(!n)return e;for(const r in n.children){const s=n.children[r];if(s.constructor==i)return s;Qg(s,i,e,!1)}return e}class se extends ge{constructor(){super(...arguments),h(this,"guid")}static isDestroyed(e){return Uu(e)}static setActive(e,t,n=!0){e&&(Fg(e,t),cb(e),t&&n&&Kk(kt.Current,e))}static isActiveSelf(e){return Lp(e)}static isActiveInHierarchy(e){return dF(e)}static markAsInstancedRendered(e,t){pF(e,t)}static isUsingInstancing(e){return s_(e)}static foreachComponent(e,t,n=!0){return Fu(e,t,n)}static instantiateSynced(e,t){return e?QM(e,t):null}static instantiate(e,t=null){return Up(e,t)}static destroySynced(e,t,n=!0){if(!e)return;const r=e;t=t??kt.Current,t_(r,t.connection,n)}static destroy(e,t=!0,n=!0){return la(e,t,n)}static add(e,t,n){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}n||(n=kt.Current),t.add(e),Fg(e,!0),cb(e),n?se.foreachComponent(e,r=>{AE(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var t;e&&((t=e.parent)==null||t.remove(e),Fg(e,!1),cb(e),se.foreachComponent(e,n=>{xY(n)},!0))}static invokeOnChildren(e,t,...n){this.invoke(e,t,!0,n)}static invoke(e,t,n=!1,...r){e&&this.foreachComponent(e,s=>{const o=s[t];o&&typeof o=="function"&&o?.call(s,...r)},n)}static addNewComponent(e,t,n,r=!0){return Nu(e,t,n,{callAwake:r})}static addComponent(e,t,n,r){return Nu(e,t,n,r)}static moveComponent(e,t){return Nu(e,t)}static removeComponent(e){return qM(e.gameObject,e),e}static getOrAddComponent(e,t){return c_(e,t)}static getComponent(e,t){return e===null?null:Fp(e,t)}static getComponents(e,t,n=null){return e===null?n??[]:zg(e,t,n)}static findByGuid(e,t){return Ng(e,t)}static findObjectOfType(e,t,n=!0){return CF(e,t??kt.Current,n)}static findObjectsOfType(e,t){const n=[];return EF(e,n,t),n}static getComponentInChildren(e,t){return jg(e,t)}static getComponentsInChildren(e,t,n=null){return Qg(e,t,n??void 0)}static getComponentInParent(e,t){return Gg(e,t)}static getComponentsInParent(e,t,n=null){return h_(e,t,n)}static getAllComponents(e){var t;return[...(t=e.userData)==null?void 0:t.components]}static*iterateComponents(e){var t;const n=(t=e?.userData)==null?void 0:t.components;if(n&&Array.isArray(n))for(let r=0;r<n.length;r++)yield n[r]}}var ih;let Ie=(ih=class{constructor(i){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(i)}get isComponent(){return!0}get context(){return this.__context??kt.Current}set context(i){this.__context=i}get scene(){return this.context.scene}get layer(){var i,e;return(e=(i=this.gameObject)==null?void 0:i.userData)==null?void 0:e.layer}get name(){var i,e;return(i=this.gameObject)!=null&&i.name?this.gameObject.name:(e=this.gameObject)==null?void 0:e.userData.name}set name(i){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=i,this.__name=i):this.__name=i}get tag(){var i;return(i=this.gameObject)==null?void 0:i.userData.tag}set tag(i){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=i)}get static(){var i;return(i=this.gameObject)==null?void 0:i.userData.static}get hideFlags(){var i;return(i=this.gameObject)==null?void 0:i.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 i=this.gameObject[Ul];return i===void 0?!0:i}set __isActiveInHierarchy(i){this.gameObject&&(this.gameObject[Ul]=i)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(i,e=Rn.Update){return this.context.registerCoroutineUpdate(this,i,e)}stopCoroutine(i,e=Rn.Update){this.context.unregisterCoroutineUpdate(i,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(i){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(i),this}_internalInit(i){if(typeof i=="object")for(const e of Object.keys(i)){const t=i[e];typeof t!="function"&&(this[e]=t)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(i){return this.__destroyed?(pt()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(i!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(i){if(this.__didAwake){if(!this.__didEnable){i!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var i;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((i=this.onDestroy)==null||i.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),xF(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(i){if(this.__destroyed){pt()&&console.warn(`[Needle Engine Dev] Trying to ${i?"enable":"disable"} destroyed component`);return}if(typeof i=="number"&&(i>=.5?i=!0:i=!1),!this.__didAwake){this.__isEnabled=i;return}i?this.__internalEnable():this.__internalDisable()}get worldPosition(){return It(this.gameObject)}set worldPosition(i){Gr(this.gameObject,i)}setWorldPosition(i,e,t){_u(this.gameObject,i,e,t)}get worldQuaternion(){return xi(this.gameObject)}set worldQuaternion(i){xo(this.gameObject,i)}setWorldQuaternion(i,e,t,n){eE(this.gameObject,i,e,t,n)}get worldEuler(){return iE(this.gameObject)}set worldEuler(i){nE(this.gameObject,i)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(i){this.setWorldRotation(i.x,i.y,i.z,!0)}setWorldRotation(i,e,t,n=!0){$m(this.gameObject,i,e,t,n)}get forward(){return ih._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return ih._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return ih._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(i,e){this._eventListeners[i]=this._eventListeners[i]||[],this._eventListeners[i].push(e)}removeEventListener(i,e){if(!this._eventListeners[i])return;const t=this._eventListeners[i].indexOf(e);t>=0&&this._eventListeners[i].splice(t,1)}dispatchEvent(i){if(!i||!this._eventListeners[i.type])return!1;const e=this._eventListeners[i.type];for(let t=0;t<e.length;t++)e[t](i);return!1}},h(ih,"_forward",new S),h(ih,"_right",new S),h(ih,"_up",new S),ih);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ie,Component:Ie,GameObject:se},Symbol.toStringTag,{value:"Module"})),zu=ee("debugloading"),Hg=ee("debugloadingrendering"),MF=ee("debuglicense");class Mee{constructor(){h(this,"className"),h(this,"additionalClasses")}}let Vg=0,TF;function XM(i){zu&&console.log(i.progress.loaded.toFixed(0)+"/"+i.progress.total.toFixed(0),i);const e=i.count,t=i.progress.total;t===0||t===void 0?(TF!==i.name&&(Vg=0),TF=i.name,Vg+=(1-Vg)*.001,zu&&ji("Loading "+i.name+" did not report total size")):Vg=i.progress.loaded/t;const n=i.index/e+Vg/e;return Ze.clamp01(n)}const YM=class{constructor(i,e){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=i,this._loadingElementOptions=e}async onLoadingBegin(i){const e=this._element.shadowRoot||this._element;if(zu&&console.warn("Begin Loading"),!this._loadingElement){for(let t=0;t<e.children.length;t++){const n=e.children[t];if(n.classList.contains(YM.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){zu&&console.warn("Remove custom loading container"),e.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",e.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(i??"")}onLoadingUpdate(i,e){var t;if(!((t=this._loadingElement)!=null&&t.parentNode))return;let n=0;typeof i=="number"?n=i:("index"in i&&(n=XM(i)),!e&&"name"in i&&this.setMessage("loading "+i.name)),this.loadingProgress=n,e&&this.setMessage(e),this.updateDisplay()}onLoadingFinished(){zu&&console.warn("Finished Loading"),Hg||(this.loadingProgress=1,this.onDoneLoading())}setMessage(i){this._messageContainer&&(this._messageContainer.innerText=i)}smoothProgressLoop(){if(this._progressLoop)return;let i=1/12;Hg&&(i=1/500,typeof Hg=="number"&&(i*=Hg)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Hg&&(i=.9),this._progress=Ze.lerp(this._progress,this.loadingProgress,i*this.loadingProgress),this.updateDisplay()},i)}onDoneLoading(){this._loadingElement&&(zu&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const i=this._progress,e=(i*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=i*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=e)}createLoadingElement(i){var e,t;zu&&!i&&console.log("Creating loading element"),this._loadingElement=i||document.createElement("div");let n=this._element.getAttribute("loading-style");(!n||n==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?n="dark":n="light");const r=za();if(!i&&(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",n==="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",n==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",r&&this._element)){const A=this._element.getAttribute("loading-background-color");A&&(this._loadingElement.style.backgroundColor=A);const v=this._element.getAttribute("loading-text-color");v&&(this._loadingElement.style.color=v)}const s=((e=this._loadingElementOptions)==null?void 0:e.className)??YM.LoadingContainerClassName;if(this._loadingElement.classList.add(s),(t=this._loadingElementOptions)!=null&&t.additionalClasses)for(const A of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(A);const o=document.createElement("div");this._loadingElement.appendChild(o);const a=document.createElement("img"),l=120;a.style.width=`${l}px`,a.style.height=`${l}px`,a.style.borderRadius="80px",a.style.padding="20px",a.style.margin="-20px",a.style.marginBottom="-10px",a.style.userSelect="none",a.style.objectFit="contain",a.style.transition="transform 2s ease-out, opacity 1s ease-in-out",a.style.transform="translateY(10px)",setTimeout(()=>{a.style.transform="translateY(0px)"},1),a.src=$$;let c=!1;if(r&&this._element){const A=this._element.getAttribute("loading-logo-src");A&&(c=!0,a.src=A)}c||(a.style.cursor="pointer",a.style.pointerEvents="all",a.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),o.appendChild(a);const u=document.createElement("div");u.style.cssText=`
|
|
5262
|
+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),bF()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let r=0;r<i.userData.components.length;r++){const s=i.userData.components[r];let o=Object.getPrototypeOf(s);for(;o;){if(o===e.prototype)if(bF()&&console.log("[onGetComponent] MATCH BY PROTOYPE",o),t)t.push(s);else return s;o=Object.getPrototypeOf(o)}}return t||null}function Fp(i,e){const t=SF(i,e);return t?Array.isArray(t)?t[0]:t:null}function zg(i,e,t,n=!0){return t||(t=[]),n&&(t.length=0),SF(i,e,t),t}function jg(i,e,t){var n;const r=Fp(i,e);if(t===!1&&r?.enabled===!1)return null;if(r)return r;for(let s=0;s<((n=i?.children)==null?void 0:n.length);s++){const o=jg(i.children[s],e);if(o)return o}return null}function Qg(i,e,t,n=!0){var r;t||(t=[]),n&&(t.length=0),zg(i,e,t,!1);for(let s=0;s<((r=i?.children)==null?void 0:r.length);s++)Qg(i.children[s],e,t,!1);return t}function Gg(i,e){if(!i)return null;if(Array.isArray(i)){for(let n=0;n<i.length;n++){const r=Cee(i[n]),s=Gg(r,e);if(s)return s}return null}return Fp(i,e)||(i.parent?Gg(i.parent,e):null)}function h_(i,e,t,n=!0){return t||(t=[]),n&&(t.length=0),i?(zg(i,e,t,!1),i.parent?h_(i.parent,e,t,!1):t):t}function CF(i,e,t){if(!i)return null;if(!e&&(e=kt.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let n=e;if(n.isScene||(n=e?.scene),!n)return null;for(const r in n.children){const s=n.children[r];if(t===!1&&s[Ul]===!1)continue;const o=jg(s,i);if(o)return o}return null}function EF(i,e,t){if(!i)return e;if(e||(e=[]),e.length=0,!t&&(t=kt.Current,!t))return console.error("Can not search object without any needle context or scene!!!"),e;const n=t.isScene===!0||t.isObject3D===!0?t:t?.scene;if(!n)return e;for(const r in n.children){const s=n.children[r];if(s.constructor==i)return s;Qg(s,i,e,!1)}return e}class se extends ge{constructor(){super(...arguments),h(this,"guid")}static isDestroyed(e){return Uu(e)}static setActive(e,t,n=!0){e&&(Fg(e,t),cb(e),t&&n&&Kk(kt.Current,e))}static isActiveSelf(e){return Lp(e)}static isActiveInHierarchy(e){return dF(e)}static markAsInstancedRendered(e,t){pF(e,t)}static isUsingInstancing(e){return s_(e)}static foreachComponent(e,t,n=!0){return Fu(e,t,n)}static instantiateSynced(e,t){return e?QM(e,t):null}static instantiate(e,t=null){return Up(e,t)}static destroySynced(e,t,n=!0){if(!e)return;const r=e;t=t??kt.Current,t_(r,t.connection,n)}static destroy(e,t=!0){return la(e,t)}static add(e,t,n){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}n||(n=kt.Current),t.add(e),Fg(e,!0),cb(e),n?se.foreachComponent(e,r=>{AE(r,n),!r.__internalDidAwakeAndStart&&n.new_script_start.includes(r)===!1&&n.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var t;e&&((t=e.parent)==null||t.remove(e),Fg(e,!1),cb(e),se.foreachComponent(e,n=>{xY(n)},!0))}static invokeOnChildren(e,t,...n){this.invoke(e,t,!0,n)}static invoke(e,t,n=!1,...r){e&&this.foreachComponent(e,s=>{const o=s[t];o&&typeof o=="function"&&o?.call(s,...r)},n)}static addNewComponent(e,t,n,r=!0){return Nu(e,t,n,{callAwake:r})}static addComponent(e,t,n,r){return Nu(e,t,n,r)}static moveComponent(e,t){return Nu(e,t)}static removeComponent(e){return qM(e.gameObject,e),e}static getOrAddComponent(e,t){return c_(e,t)}static getComponent(e,t){return e===null?null:Fp(e,t)}static getComponents(e,t,n=null){return e===null?n??[]:zg(e,t,n)}static findByGuid(e,t){return Ng(e,t)}static findObjectOfType(e,t,n=!0){return CF(e,t??kt.Current,n)}static findObjectsOfType(e,t){const n=[];return EF(e,n,t),n}static getComponentInChildren(e,t){return jg(e,t)}static getComponentsInChildren(e,t,n=null){return Qg(e,t,n??void 0)}static getComponentInParent(e,t){return Gg(e,t)}static getComponentsInParent(e,t,n=null){return h_(e,t,n)}static getAllComponents(e){var t;return[...(t=e.userData)==null?void 0:t.components]}static*iterateComponents(e){var t;const n=(t=e?.userData)==null?void 0:t.components;if(n&&Array.isArray(n))for(let r=0;r<n.length;r++)yield n[r]}}var ih;let Ie=(ih=class{constructor(i){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(i)}get isComponent(){return!0}get context(){return this.__context??kt.Current}set context(i){this.__context=i}get scene(){return this.context.scene}get layer(){var i,e;return(e=(i=this.gameObject)==null?void 0:i.userData)==null?void 0:e.layer}get name(){var i,e;return(i=this.gameObject)!=null&&i.name?this.gameObject.name:(e=this.gameObject)==null?void 0:e.userData.name}set name(i){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=i,this.__name=i):this.__name=i}get tag(){var i;return(i=this.gameObject)==null?void 0:i.userData.tag}set tag(i){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=i)}get static(){var i;return(i=this.gameObject)==null?void 0:i.userData.static}get hideFlags(){var i;return(i=this.gameObject)==null?void 0:i.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 i=this.gameObject[Ul];return i===void 0?!0:i}set __isActiveInHierarchy(i){this.gameObject&&(this.gameObject[Ul]=i)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(i,e=Rn.Update){return this.context.registerCoroutineUpdate(this,i,e)}stopCoroutine(i,e=Rn.Update){this.context.unregisterCoroutineUpdate(i,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(i){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(i),this}_internalInit(i){if(typeof i=="object")for(const e of Object.keys(i)){const t=i[e];typeof t!="function"&&(this[e]=t)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(i){return this.__destroyed?(pt()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(i!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(i){if(this.__didAwake){if(!this.__didEnable){i!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var i;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((i=this.onDestroy)==null||i.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),xF(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(i){if(this.__destroyed){pt()&&console.warn(`[Needle Engine Dev] Trying to ${i?"enable":"disable"} destroyed component`);return}if(typeof i=="number"&&(i>=.5?i=!0:i=!1),!this.__didAwake){this.__isEnabled=i;return}i?this.__internalEnable():this.__internalDisable()}get worldPosition(){return It(this.gameObject)}set worldPosition(i){Gr(this.gameObject,i)}setWorldPosition(i,e,t){_u(this.gameObject,i,e,t)}get worldQuaternion(){return xi(this.gameObject)}set worldQuaternion(i){xo(this.gameObject,i)}setWorldQuaternion(i,e,t,n){eE(this.gameObject,i,e,t,n)}get worldEuler(){return iE(this.gameObject)}set worldEuler(i){nE(this.gameObject,i)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(i){this.setWorldRotation(i.x,i.y,i.z,!0)}setWorldRotation(i,e,t,n=!0){$m(this.gameObject,i,e,t,n)}get forward(){return ih._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return ih._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return ih._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(i,e){this._eventListeners[i]=this._eventListeners[i]||[],this._eventListeners[i].push(e)}removeEventListener(i,e){if(!this._eventListeners[i])return;const t=this._eventListeners[i].indexOf(e);t>=0&&this._eventListeners[i].splice(t,1)}dispatchEvent(i){if(!i||!this._eventListeners[i.type])return!1;const e=this._eventListeners[i.type];for(let t=0;t<e.length;t++)e[t](i);return!1}},h(ih,"_forward",new S),h(ih,"_right",new S),h(ih,"_up",new S),ih);const Eee=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ie,Component:Ie,GameObject:se},Symbol.toStringTag,{value:"Module"})),zu=ee("debugloading"),Hg=ee("debugloadingrendering"),MF=ee("debuglicense");class Mee{constructor(){h(this,"className"),h(this,"additionalClasses")}}let Vg=0,TF;function XM(i){zu&&console.log(i.progress.loaded.toFixed(0)+"/"+i.progress.total.toFixed(0),i);const e=i.count,t=i.progress.total;t===0||t===void 0?(TF!==i.name&&(Vg=0),TF=i.name,Vg+=(1-Vg)*.001,zu&&ji("Loading "+i.name+" did not report total size")):Vg=i.progress.loaded/t;const n=i.index/e+Vg/e;return Ze.clamp01(n)}const YM=class{constructor(i,e){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=i,this._loadingElementOptions=e}async onLoadingBegin(i){const e=this._element.shadowRoot||this._element;if(zu&&console.warn("Begin Loading"),!this._loadingElement){for(let t=0;t<e.children.length;t++){const n=e.children[t];if(n.classList.contains(YM.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){zu&&console.warn("Remove custom loading container"),e.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",e.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(i??"")}onLoadingUpdate(i,e){var t;if(!((t=this._loadingElement)!=null&&t.parentNode))return;let n=0;typeof i=="number"?n=i:("index"in i&&(n=XM(i)),!e&&"name"in i&&this.setMessage("loading "+i.name)),this.loadingProgress=n,e&&this.setMessage(e),this.updateDisplay()}onLoadingFinished(){zu&&console.warn("Finished Loading"),Hg||(this.loadingProgress=1,this.onDoneLoading())}setMessage(i){this._messageContainer&&(this._messageContainer.innerText=i)}smoothProgressLoop(){if(this._progressLoop)return;let i=1/12;Hg&&(i=1/500,typeof Hg=="number"&&(i*=Hg)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!Hg&&(i=.9),this._progress=Ze.lerp(this._progress,this.loadingProgress,i*this.loadingProgress),this.updateDisplay()},i)}onDoneLoading(){this._loadingElement&&(zu&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const i=this._progress,e=(i*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=i*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=e)}createLoadingElement(i){var e,t;zu&&!i&&console.log("Creating loading element"),this._loadingElement=i||document.createElement("div");let n=this._element.getAttribute("loading-style");(!n||n==="auto")&&(window.matchMedia("(prefers-color-scheme: dark)").matches?n="dark":n="light");const r=za();if(!i&&(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",n==="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",n==="light"?this._loadingElement.style.color="rgba(0,0,0,.6)":this._loadingElement.style.color="rgba(255,255,255,.3)",r&&this._element)){const A=this._element.getAttribute("loading-background-color");A&&(this._loadingElement.style.backgroundColor=A);const v=this._element.getAttribute("loading-text-color");v&&(this._loadingElement.style.color=v)}const s=((e=this._loadingElementOptions)==null?void 0:e.className)??YM.LoadingContainerClassName;if(this._loadingElement.classList.add(s),(t=this._loadingElementOptions)!=null&&t.additionalClasses)for(const A of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(A);const o=document.createElement("div");this._loadingElement.appendChild(o);const a=document.createElement("img"),l=120;a.style.width=`${l}px`,a.style.height=`${l}px`,a.style.borderRadius="80px",a.style.padding="20px",a.style.margin="-20px",a.style.marginBottom="-10px",a.style.userSelect="none",a.style.objectFit="contain",a.style.transition="transform 2s ease-out, opacity 1s ease-in-out",a.style.transform="translateY(10px)",setTimeout(()=>{a.style.transform="translateY(0px)"},1),a.src=$$;let c=!1;if(r&&this._element){const A=this._element.getAttribute("loading-logo-src");A&&(c=!0,a.src=A)}c||(a.style.cursor="pointer",a.style.pointerEvents="all",a.addEventListener("click",()=>window.open("https://needle.tools","_blank"))),o.appendChild(a);const u=document.createElement("div");u.style.cssText=`
|
|
5263
5263
|
display: flex;
|
|
5264
5264
|
flex-direction: column;
|
|
5265
5265
|
align-items: center;
|