@needle-tools/engine 3.7.3-alpha.2 → 3.7.4-alpha
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 +3 -0
- package/dist/needle-engine.js +3 -2
- package/dist/needle-engine.light.js +3 -2
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine/engine_context.d.ts +1 -0
- package/lib/engine/engine_context.js +7 -3
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine-components/Component.js +4 -1
- package/lib/engine-components/Component.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_context.ts +9 -6
- package/src/engine-components/Component.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [3.7.4-alpha] - 2023-07-05
|
|
8
|
+
- Change: targetFps, use timestamp that we get from the animation callback event because it is more reliable on Firefox
|
|
9
|
+
|
|
7
10
|
## [3.7.3-alpha] - 2023-06-26
|
|
8
11
|
- Add: physics gravity to `IPhysicsEngine` interface to be available via `this.context.physics.engine.gravity`
|
|
9
12
|
- Fix: USDZ text alignment
|
package/dist/needle-engine.js
CHANGED
|
@@ -38401,6 +38401,7 @@ const si = class {
|
|
|
38401
38401
|
r(this, "_accumulatedTime", 0);
|
|
38402
38402
|
r(this, "_framerateClock", new cf());
|
|
38403
38403
|
r(this, "_dispatchReadyAfterFrame", !1);
|
|
38404
|
+
r(this, "_lastTimestamp", 0);
|
|
38404
38405
|
/** returns true if we should return out of the frame loop */
|
|
38405
38406
|
r(this, "_wasPaused", !1);
|
|
38406
38407
|
this.name = (A == null ? void 0 : A.name) || "", this.alias = A == null ? void 0 : A.alias, this.domElement = (A == null ? void 0 : A.domElement) || document.body, this.hash = A == null ? void 0 : A.hash, A != null && A.renderer ? (this.renderer = A.renderer, this.isManagedExternally = !0) : this.createRenderer(), this.scene = new uI(), Pt.register(this), this.application = new TZ(this), this.time = new KW(), this.input = new cW(this), this.physics = new NW(this), this.connection = new MV(this), this.assets = new Ij(), this.sceneLighting = new xZ(this), this.addressables = new qZ(this), this.lightmaps = new OZ(this), this.players = new VZ(this);
|
|
@@ -38732,7 +38733,7 @@ const si = class {
|
|
|
38732
38733
|
internalRender(A, e) {
|
|
38733
38734
|
var t, g;
|
|
38734
38735
|
if (this._xrFrame = e, this._currentFrameEvent = -1, this.isInXR === !1 && this.targetFrameRate !== void 0) {
|
|
38735
|
-
this._accumulatedTime += this.
|
|
38736
|
+
this._lastTimestamp === 0 && (this._lastTimestamp = A), this._accumulatedTime += (A - this._lastTimestamp) / 1e3, this._lastTimestamp = A;
|
|
38736
38737
|
let I = this.targetFrameRate;
|
|
38737
38738
|
if (typeof I == "object" && (I = I.value), this._accumulatedTime < 1 / (I + 1))
|
|
38738
38739
|
return;
|
|
@@ -39219,7 +39220,7 @@ let qr = (ti = class {
|
|
|
39219
39220
|
return (A = this.gameObject) == null ? void 0 : A.userData.tag;
|
|
39220
39221
|
}
|
|
39221
39222
|
set tag(A) {
|
|
39222
|
-
this.gameObject && (this.gameObject.userData.tag = A);
|
|
39223
|
+
this.gameObject && (this.gameObject.userData || (this.gameObject.userData = {}), this.gameObject.userData.tag = A);
|
|
39223
39224
|
}
|
|
39224
39225
|
get static() {
|
|
39225
39226
|
var A;
|
|
@@ -38401,6 +38401,7 @@ const tn = class {
|
|
|
38401
38401
|
h(this, "_accumulatedTime", 0);
|
|
38402
38402
|
h(this, "_framerateClock", new mb());
|
|
38403
38403
|
h(this, "_dispatchReadyAfterFrame", !1);
|
|
38404
|
+
h(this, "_lastTimestamp", 0);
|
|
38404
38405
|
/** returns true if we should return out of the frame loop */
|
|
38405
38406
|
h(this, "_wasPaused", !1);
|
|
38406
38407
|
this.name = (e == null ? void 0 : e.name) || "", this.alias = e == null ? void 0 : e.alias, this.domElement = (e == null ? void 0 : e.domElement) || document.body, this.hash = e == null ? void 0 : e.hash, e != null && e.renderer ? (this.renderer = e.renderer, this.isManagedExternally = !0) : this.createRenderer(), this.scene = new or(), Yi.register(this), this.application = new A7(this), this.time = new c6(), this.input = new V8(this), this.physics = new l6(this), this.connection = new n9(this), this.assets = new k9(), this.sceneLighting = new g7(this), this.addressables = new u7(this), this.lightmaps = new b7(this), this.players = new w7(this);
|
|
@@ -38732,7 +38733,7 @@ const tn = class {
|
|
|
38732
38733
|
internalRender(e, t) {
|
|
38733
38734
|
var i, s;
|
|
38734
38735
|
if (this._xrFrame = t, this._currentFrameEvent = -1, this.isInXR === !1 && this.targetFrameRate !== void 0) {
|
|
38735
|
-
this._accumulatedTime += this.
|
|
38736
|
+
this._lastTimestamp === 0 && (this._lastTimestamp = e), this._accumulatedTime += (e - this._lastTimestamp) / 1e3, this._lastTimestamp = e;
|
|
38736
38737
|
let r = this.targetFrameRate;
|
|
38737
38738
|
if (typeof r == "object" && (r = r.value), this._accumulatedTime < 1 / (r + 1))
|
|
38738
38739
|
return;
|
|
@@ -39219,7 +39220,7 @@ let hu = (Xi = class {
|
|
|
39219
39220
|
return (e = this.gameObject) == null ? void 0 : e.userData.tag;
|
|
39220
39221
|
}
|
|
39221
39222
|
set tag(e) {
|
|
39222
|
-
this.gameObject && (this.gameObject.userData.tag = e);
|
|
39223
|
+
this.gameObject && (this.gameObject.userData || (this.gameObject.userData = {}), this.gameObject.userData.tag = e);
|
|
39223
39224
|
}
|
|
39224
39225
|
get static() {
|
|
39225
39226
|
var e;
|
|
@@ -3842,7 +3842,7 @@ outputColor=vec4(color,inputColor.a);}`,PD=class extends So{constructor({blendFu
|
|
|
3842
3842
|
irradiance += 0.;
|
|
3843
3843
|
#else
|
|
3844
3844
|
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
3845
|
-
#endif`),Xe.lightmap.lightmapScaleOffset={value:new st(1,1,0,0)};const dq=re("debugplayerview");var $o=(i=>(i.Browser="browser",i.Headset="headset",i.Handheld="handheld",i))($o||{});class ZD{constructor(e,t){h(this,"userId"),h(this,"context"),h(this,"viewDevice","browser"),h(this,"removed",!1),h(this,"_object"),this.userId=e,this.context=t}get currentObject(){return this._object}set currentObject(e){this._object=e}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class $D{constructor(e){h(this,"context"),h(this,"playerViews",new Map),this.context=e}setPlayerView(e,t,s){let r=this.playerViews.get(e);r||(r=new ZD(e,this.context),this.playerViews.set(e,r)),r.viewDevice=s,r.currentObject=t,r.removed=!1}getPlayerView(e){if(!!e){if(!this.context.connection.userIsInRoom(e)){this.playerViews.delete(e);return}return this.playerViews.get(e)}}removePlayerView(e,t){const s=this.playerViews.get(e);s?.viewDevice===t&&(dq&&console.log("REMOVE",e),s.removed=!0,this.playerViews.delete(e))}}const Ld=re("debugcontext"),pq=re("stats"),fq=re("debugactive"),gq=re("debugframerate"),mq=re("debugcoroutine"),vq={};class Aq{constructor(e){h(this,"name"),h(this,"alias"),h(this,"domElement"),h(this,"renderer"),h(this,"hash"),this.domElement=e??document.body}}var mn=(i=>(i[i.EarlyUpdate=0]="EarlyUpdate",i[i.Update=1]="Update",i[i.LateUpdate=2]="LateUpdate",i[i.OnBeforeRender=3]="OnBeforeRender",i[i.OnAfterRender=4]="OnAfterRender",i[i.PrePhysicsStep=9]="PrePhysicsStep",i[i.PostPhysicsStep=10]="PostPhysicsStep",i[i.Undefined=-1]="Undefined",i))(mn||{}),Og=(i=>(i.ImmersiveVR="immersive-vr",i.ImmersiveAR="immersive-ar",i))(Og||{});function By(i,e){if(!i)return;const t=e?.new_scripts??Lt.Current.new_scripts;t.includes(i)||t.push(i)}const ns=class{constructor(i){h(this,"name"),h(this,"alias"),h(this,"isManagedExternally",!1),h(this,"isPaused",!1),h(this,"runInBackground",!1),h(this,"targetFrameRate"),h(this,"hash"),h(this,"domElement"),h(this,"_resolutionScaleFactor",1),h(this,"_boundingClientRectFrame",-1),h(this,"_boundingClientRect",null),h(this,"_domX"),h(this,"_domY"),h(this,"xrSessionMode"),h(this,"_xrFrame",null),h(this,"_currentFrameEvent",-1),h(this,"scene"),h(this,"renderer"),h(this,"composer",null),h(this,"scripts",[]),h(this,"scripts_pausedChanged",[]),h(this,"scripts_earlyUpdate",[]),h(this,"scripts_update",[]),h(this,"scripts_lateUpdate",[]),h(this,"scripts_onBeforeRender",[]),h(this,"scripts_onAfterRender",[]),h(this,"scripts_WithCorroutines",[]),h(this,"coroutines",{}),h(this,"mainCameraComponent"),h(this,"post_setup_callbacks",[]),h(this,"pre_update_callbacks",[]),h(this,"pre_render_callbacks",[]),h(this,"post_render_callbacks",[]),h(this,"new_scripts",[]),h(this,"new_script_start",[]),h(this,"new_scripts_pre_setup_callbacks",[]),h(this,"new_scripts_post_setup_callbacks",[]),h(this,"application"),h(this,"time"),h(this,"input"),h(this,"physics"),h(this,"connection"),h(this,"assets"),h(this,"mainLight",null),h(this,"sceneLighting"),h(this,"addressables"),h(this,"lightmaps"),h(this,"players"),h(this,"_sizeChanged",!1),h(this,"_isCreated",!1),h(this,"_isCreating",!1),h(this,"_isVisible",!1),h(this,"_stats",pq?Y7():null),h(this,"_intersectionObserver",null),h(this,"_disposeCallbacks",[]),h(this,"_cameraStack",[]),h(this,"_onBeforeRenderListeners",new Map),h(this,"_onAfterRenderListeners",new Map),h(this,"_requireDepthTexture",!1),h(this,"_requireColorTexture",!1),h(this,"_renderTarget"),h(this,"_isRendering",!1),h(this,"_accumulatedTime",0),h(this,"_framerateClock",new y0),h(this,"_dispatchReadyAfterFrame",!1),h(this,"_wasPaused",!1),this.name=i?.name||"",this.alias=i?.alias,this.domElement=i?.domElement||document.body,this.hash=i?.hash,i!=null&&i.renderer?(this.renderer=i.renderer,this.isManagedExternally=!0):this.createRenderer(),this.scene=new Vr,Ei.register(this),this.application=new YD(this),this.time=new $B,this.input=new FB(this),this.physics=new JB(this),this.connection=new wk(this),this.assets=new Wk,this.sceneLighting=new qD(this),this.addressables=new VD(this),this.lightmaps=new uq(this),this.players=new $D(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(s=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()})}static get DefaultTargetFrameRate(){return ns._defaultTargetFramerate.value}static set DefaultTargetFrameRate(i){ns._defaultTargetFramerate.value=i}get version(){return oy}static get Current(){return Ei.Current}static set Current(i){Ei.Current=i}appendHTMLElement(i){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(i):this.domElement.appendChild(i)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(i){if(i!==this._resolutionScaleFactor&&typeof i=="number"){if(i<=0){console.error("Invalid resolution scale factor",i);return}this._resolutionScaleFactor=i,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var i;return((i=this.renderer.xr)==null?void 0:i.isPresenting)||!1}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get xrSession(){var i;return(i=this.renderer.xr)==null?void 0:i.getSession()}get xrFrame(){return this._xrFrame}get arOverlayElement(){const i=this.domElement;return typeof i.getAROverlayContainer=="function"?i.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this.mainCameraComponent){const i=this.mainCameraComponent;return i.cam||i.buildCamera(),i.cam}return null}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createRenderer(){var i,e,t;(i=this.renderer)==null||i.dispose();const s={antialias:!0},r=(t=(e=this.domElement)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("canvas");r&&(s.canvas=r),this.renderer=new pd(s),this.renderer.toneMappingExposure=1,this.renderer.toneMapping=_r,this.renderer.setClearColor(new be("lightgrey"),0),this.renderer.antialias=!0,this.renderer.alpha=!1,this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Sw,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputEncoding=yt,this.renderer.physicallyCorrectLights=!0}internalOnUpdateVisible(){var i,e;(i=this._intersectionObserver)==null||i.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}updateSize(){var i,e,t;if(!this.isManagedExternally&&((i=this.renderer.xr)==null?void 0:i.isPresenting)===!1){this._sizeChanged=!1;const s=this.resolutionScaleFactor,r=this.domWidth*s,n=this.domHeight*s,o=this.mainCamera;this.updateAspect(o),this.renderer.setSize(r,n),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((e=this.composer.setSize)==null||e.call(this.composer,r,n),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((t=this.composer.setPixelRatio)==null||t.call(this.composer,window.devicePixelRatio)))}}updateAspect(i,e,t){if(!i)return;e===void 0&&(e=this.domWidth),t===void 0&&(t=this.domHeight);const s=i.aspect;i.aspect=e/t,s!==i.aspect&&i.updateProjectionMatrix()}async onCreate(i,e){try{return this._isCreating=!0,await this.internalOnCreate(i,e)}finally{this._isCreating=!1}}clear(){var i,e,t,s;Ei.dispatchCallback(xr.ContextClearing,this),rl(this.scene,!0,!0),this.scene=new Vr,(i=this.addressables)==null||i.dispose(),(e=this.lightmaps)==null||e.clear(),(s=(t=this.physics)==null?void 0:t.engine)==null||s.clearCaches(),this.isManagedExternally||(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),Ei.dispatchCallback(xr.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var i,e;this.clear(),(i=this.renderer)==null||i.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear()),this.isManagedExternally||this.renderer.dispose(),this.scene=null,this.renderer=null,this.input.dispose();for(const t of this._disposeCallbacks)try{t()}catch(s){console.error("Error in on dispose callback:",s,t)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Ei.dispatchCallback(xr.ContextDestroyed,this),Ei.unregister(this)}registerCoroutineUpdate(i,e,t){return 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(s=>s.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 s=t.length-1;s>=0;s--)t[s].comp===i&&t.splice(s,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 s=i.cam;s.isPerspectiveCamera&&this.updateAspect(s),(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){var t;this._onBeforeRenderListeners.has(i.uuid)||(this._onBeforeRenderListeners.set(i.uuid,[]),i.onBeforeRender=this._createRenderCallbackWrapper(i,this._onBeforeRenderListeners)),(t=this._onBeforeRenderListeners.get(i.uuid))==null||t.push(e)}removeBeforeRenderListener(i,e){if(this._onBeforeRenderListeners.has(i.uuid)){const t=this._onBeforeRenderListeners.get(i.uuid),s=t.indexOf(e);s>=0&&t.splice(s,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),s=t.indexOf(e);s>=0&&t.splice(s,1)}}_createRenderCallbackWrapper(i,e){return(t,s,r,n,o,a)=>{const l=e.get(i.uuid);if(l)for(let c=0;c<l.length;c++){const u=l[c];u(t,s,r,n,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,e){var t,s;this.clear(),(t=this.renderer)==null||t.setAnimationLoop(null),await xf(1),ns.Current=this,await Ei.dispatchCallback(xr.ContextCreationStart,this);let r=!0,n;try{ns.Current=this,i&&(n=await i(this,e))}catch(o){console.error(o),r=!1}if(!r)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return Ld&&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),ns.Current=this,ns.Current=this;for(let o=0;o<this.new_scripts.length;o++){const a=this.new_scripts[o];if(a.gameObject!==void 0&&a.gameObject!==null){a.gameObject.userData===void 0&&(a.gameObject.userData={}),a.gameObject.userData.components===void 0&&(a.gameObject.userData.components=[]);const l=a.gameObject.userData.components;l.includes(a)||l.push(a)}}if(this.post_setup_callbacks)for(let o=0;o<this.post_setup_callbacks.length;o++)ns.Current=this,await this.post_setup_callbacks[o](this);if(!this.mainCamera){ns.Current=this;let o=null;Xh(this.scene,a=>{const l=a;if(l!=null&&l.isCamera){if(Rg(l.gameObject),!l.activeAndEnabled)return;if(l.tag==="MainCamera")return o=l,!0;o=l}}),o?this.setCurrentCamera(o):!Ei.dispatchCallback(xr.MissingCamera,this)&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(ns.Current=this,Ay(this),!this.isManagedExternally&&this.composer&&this.mainCamera){const o=new Ey(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(o),this.composer.setSize(this.domWidth,this.domHeight)}return this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(s=this.domElement.shadowRoot)==null||s.appendChild(this._stats.dom)),Ld&&F0(this.scene,!0),this.targetFrameRate===void 0?(Ld&&console.warn("No target framerate set, using default",ns.DefaultTargetFrameRate),this.targetFrameRate=ns._defaultTargetFramerate):Ld&&console.log("Target framerate set to",this.targetFrameRate),this._isCreating=!1,this.restartRenderLoop(),this._dispatchReadyAfterFrame=!0,Ei.dispatchCallback(xr.ContextCreated,this,{files:n})}restartRenderLoop(){if(!this.renderer)return console.error("Can not start render loop without renderer"),!1;if(this._isCreating)return console.warn("Can not start render loop while creating context"),!1;const i=this.render.bind(this);return this.renderer.setAnimationLoop(i),!0}render(i,e){if(lr()||Ld||q9())try{this.internalRender(i,e)}catch(t){(lr()||Ld)&&t instanceof Error&&rs("Exception during render-loop.<br/>See console for details.",fo.Error),console.error(t),console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null),this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}else this.internalRender(i,e)}internalRender(i,e){var t,s;if(this._xrFrame=e,this._currentFrameEvent=-1,this.isInXR===!1&&this.targetFrameRate!==void 0){this._accumulatedTime+=this._framerateClock.getDelta();let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return;this._accumulatedTime=0}if((t=this._stats)==null||t.begin(),ns.Current=this,!this.onHandlePaused()){for(ns.Current=this,this.time.update(),gq&&console.log("FPS",this.time.smoothedFps.toFixed(0)),Ay(this),yy(this.scene),aD(this);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_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 n=this.scripts_earlyUpdate[r];n.activeAndEnabled&&n.earlyUpdate!==void 0&&(ns.Current=this,n.earlyUpdate())}if(this.executeCoroutines(0),!this.onHandlePaused()){this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const n=this.scripts_update[r];n.activeAndEnabled&&n.update!==void 0&&(ns.Current=this,n.update())}if(this.executeCoroutines(1),!this.onHandlePaused()){this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const n=this.scripts_lateUpdate[r];n.activeAndEnabled&&n.lateUpdate!==void 0&&(ns.Current=this,n.lateUpdate())}if(this.executeCoroutines(2),!this.onHandlePaused()){if(this.physics.engine){const r=this.time.deltaTime/1;for(let n=0;n<1;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(r),this._currentFrameEvent=10,this.executeCoroutines(10);this.physics.engine.postStep()}if(!this.onHandlePaused()){if(this.isVisibleToUser){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const n=this.scripts_onBeforeRender[r];n.activeAndEnabled&&n.onBeforeRender!==void 0&&(ns.Current=this,n.onBeforeRender(e))}if(this.executeCoroutines(3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r]();this.isManagedExternally||(K9(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4);for(let r=0;r<this.scripts_onAfterRender.length;r++){const n=this.scripts_onAfterRender[r];n.activeAndEnabled&&n.onAfterRender!==void 0&&(ns.Current=this,n.onAfterRender())}if(this.executeCoroutines(4),this.post_render_callbacks)for(const r in this.post_render_callbacks)this.post_render_callbacks[r]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),(s=this._stats)==null||s.end(),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")))}}}}}}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){fq&&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&&(ns.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 ei(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new WA(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new Ft,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Wt,this._renderTarget.texture.magFilter=Wt,this._renderTarget.texture.format=wi)}const i=this._renderTarget;i.texture&&(i.texture.encoding=this.renderer.outputEncoding);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(i),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(i){if(this.coroutines[i]){const t=this.coroutines[i];for(let s=0;s<t.length;s++)try{const r=t[s];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){mq&&console.log("Removing coroutine",r.comp,r.comp.enabled),t.splice(s,1),--s;continue}const n=r.chained;if(n&&n.length>0){const l=n[n.length-1].next();if(l.done&&n.pop(),e(l)&&(r.chained||(r.chained=[]),r.chained.push(l.value)),!l.done)continue}const o=r.main.next();if(o.done===!0){t.splice(s,1),--s;continue}const a=o.value;if(e(a)){if(a.next().done)continue;r.chained||(r.chained=[]),r.chained.push(a)}}catch(r){console.error(r)}}function e(t){return!!(t&&t.next&&t.return)}}};let Lt=ns;h(Lt,"_defaultTargetFramerate",{value:60});const xc=re("debugaroverlay"),Kh="ar",eO="quit-ar";class yq{constructor(){h(this,"arContainer",null),h(this,"closeARCallback"),h(this,"currentSession",null),h(this,"registeredCloseEventElements",[]),h(this,"_createdAROnlyElements",[]),h(this,"_reparentedObjects",[]),this.closeARCallback=this.onRequestedEndAR.bind(this)}get ARContainer(){return this.arContainer}requestEndAR(){this.onRequestedEndAR()}onBegin(e,t,s){this.currentSession=s,this.arContainer=t,e.domElement.shadowRoot.querySelectorAll(`.${Kh}`).forEach(n=>{var o;n&&n!==this.arContainer&&(this._reparentedObjects.push({el:n,previousParent:n.parentElement}),(o=this.arContainer)==null||o.appendChild(n))});const r=t.getElementsByClassName(eO);if(!r||r.length<=0)console.warn(`Missing quit AR elements, creating fallback X button. Use class name '${eO}' to override.`),this.createFallbackCloseARButton(this.arContainer);else for(let n=0;n<r.length;n++){const o=r[n];o&&(o.addEventListener("click",this.closeARCallback),this.registeredCloseEventElements.push(o))}}onEnd(e){var t;for(const s of this._createdAROnlyElements)s.remove&&s.remove();for(const s of this._reparentedObjects){const r=s.el;(t=s.previousParent)==null||t.appendChild(r)}this._reparentedObjects.length=0,vw()&&setTimeout(()=>{var s;const r=e.renderer.domElement;r&&((s=e.domElement.shadowRoot)==null||s.prepend(r));const n=document.querySelectorAll("*");for(var o=0;o<n.length;o++){const a=n[o];a&&a._displayChanged!==void 0&&a._displayWas!==void 0&&(a.style.display=a._displayWas)}},10)}findOrCreateARContainer(e){if(xc&&console.log("findOrCreateARContainer"),e.classList.contains(Kh))return xc&&console.log("Found overlay container in needle-engine element"),e;if(e.shadowRoot){const r=e.shadowRoot.querySelector(`.${Kh}`);if(r)return xc&&console.log("Found overlay container in needle-engine element"),r}const t=document.getElementsByClassName(Kh);if(t&&t.length>0)return xc&&console.log("Found overlay container in document"),t[0];xc&&console.log("No overlay container found in document - generating new ony");const s=document.createElement("div");return s.classList.add(Kh),s.style.cssText=`
|
|
3845
|
+
#endif`),Xe.lightmap.lightmapScaleOffset={value:new st(1,1,0,0)};const dq=re("debugplayerview");var $o=(i=>(i.Browser="browser",i.Headset="headset",i.Handheld="handheld",i))($o||{});class ZD{constructor(e,t){h(this,"userId"),h(this,"context"),h(this,"viewDevice","browser"),h(this,"removed",!1),h(this,"_object"),this.userId=e,this.context=t}get currentObject(){return this._object}set currentObject(e){this._object=e}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class $D{constructor(e){h(this,"context"),h(this,"playerViews",new Map),this.context=e}setPlayerView(e,t,s){let r=this.playerViews.get(e);r||(r=new ZD(e,this.context),this.playerViews.set(e,r)),r.viewDevice=s,r.currentObject=t,r.removed=!1}getPlayerView(e){if(!!e){if(!this.context.connection.userIsInRoom(e)){this.playerViews.delete(e);return}return this.playerViews.get(e)}}removePlayerView(e,t){const s=this.playerViews.get(e);s?.viewDevice===t&&(dq&&console.log("REMOVE",e),s.removed=!0,this.playerViews.delete(e))}}const Ld=re("debugcontext"),pq=re("stats"),fq=re("debugactive"),gq=re("debugframerate"),mq=re("debugcoroutine"),vq={};class Aq{constructor(e){h(this,"name"),h(this,"alias"),h(this,"domElement"),h(this,"renderer"),h(this,"hash"),this.domElement=e??document.body}}var mn=(i=>(i[i.EarlyUpdate=0]="EarlyUpdate",i[i.Update=1]="Update",i[i.LateUpdate=2]="LateUpdate",i[i.OnBeforeRender=3]="OnBeforeRender",i[i.OnAfterRender=4]="OnAfterRender",i[i.PrePhysicsStep=9]="PrePhysicsStep",i[i.PostPhysicsStep=10]="PostPhysicsStep",i[i.Undefined=-1]="Undefined",i))(mn||{}),Og=(i=>(i.ImmersiveVR="immersive-vr",i.ImmersiveAR="immersive-ar",i))(Og||{});function By(i,e){if(!i)return;const t=e?.new_scripts??Lt.Current.new_scripts;t.includes(i)||t.push(i)}const ns=class{constructor(i){h(this,"name"),h(this,"alias"),h(this,"isManagedExternally",!1),h(this,"isPaused",!1),h(this,"runInBackground",!1),h(this,"targetFrameRate"),h(this,"hash"),h(this,"domElement"),h(this,"_resolutionScaleFactor",1),h(this,"_boundingClientRectFrame",-1),h(this,"_boundingClientRect",null),h(this,"_domX"),h(this,"_domY"),h(this,"xrSessionMode"),h(this,"_xrFrame",null),h(this,"_currentFrameEvent",-1),h(this,"scene"),h(this,"renderer"),h(this,"composer",null),h(this,"scripts",[]),h(this,"scripts_pausedChanged",[]),h(this,"scripts_earlyUpdate",[]),h(this,"scripts_update",[]),h(this,"scripts_lateUpdate",[]),h(this,"scripts_onBeforeRender",[]),h(this,"scripts_onAfterRender",[]),h(this,"scripts_WithCorroutines",[]),h(this,"coroutines",{}),h(this,"mainCameraComponent"),h(this,"post_setup_callbacks",[]),h(this,"pre_update_callbacks",[]),h(this,"pre_render_callbacks",[]),h(this,"post_render_callbacks",[]),h(this,"new_scripts",[]),h(this,"new_script_start",[]),h(this,"new_scripts_pre_setup_callbacks",[]),h(this,"new_scripts_post_setup_callbacks",[]),h(this,"application"),h(this,"time"),h(this,"input"),h(this,"physics"),h(this,"connection"),h(this,"assets"),h(this,"mainLight",null),h(this,"sceneLighting"),h(this,"addressables"),h(this,"lightmaps"),h(this,"players"),h(this,"_sizeChanged",!1),h(this,"_isCreated",!1),h(this,"_isCreating",!1),h(this,"_isVisible",!1),h(this,"_stats",pq?Y7():null),h(this,"_intersectionObserver",null),h(this,"_disposeCallbacks",[]),h(this,"_cameraStack",[]),h(this,"_onBeforeRenderListeners",new Map),h(this,"_onAfterRenderListeners",new Map),h(this,"_requireDepthTexture",!1),h(this,"_requireColorTexture",!1),h(this,"_renderTarget"),h(this,"_isRendering",!1),h(this,"_accumulatedTime",0),h(this,"_framerateClock",new y0),h(this,"_dispatchReadyAfterFrame",!1),h(this,"_lastTimestamp",0),h(this,"_wasPaused",!1),this.name=i?.name||"",this.alias=i?.alias,this.domElement=i?.domElement||document.body,this.hash=i?.hash,i!=null&&i.renderer?(this.renderer=i.renderer,this.isManagedExternally=!0):this.createRenderer(),this.scene=new Vr,Ei.register(this),this.application=new YD(this),this.time=new $B,this.input=new FB(this),this.physics=new JB(this),this.connection=new wk(this),this.assets=new Wk,this.sceneLighting=new qD(this),this.addressables=new VD(this),this.lightmaps=new uq(this),this.players=new $D(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const t=new ResizeObserver(s=>this._sizeChanged=!0);t.observe(this.domElement),this._disposeCallbacks.push(()=>t.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()})}static get DefaultTargetFrameRate(){return ns._defaultTargetFramerate.value}static set DefaultTargetFrameRate(i){ns._defaultTargetFramerate.value=i}get version(){return oy}static get Current(){return Ei.Current}static set Current(i){Ei.Current=i}appendHTMLElement(i){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(i):this.domElement.appendChild(i)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(i){if(i!==this._resolutionScaleFactor&&typeof i=="number"){if(i<=0){console.error("Invalid resolution scale factor",i);return}this._resolutionScaleFactor=i,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var i;return((i=this.renderer.xr)==null?void 0:i.isPresenting)||!1}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get xrSession(){var i;return(i=this.renderer.xr)==null?void 0:i.getSession()}get xrFrame(){return this._xrFrame}get arOverlayElement(){const i=this.domElement;return typeof i.getAROverlayContainer=="function"?i.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this.mainCameraComponent){const i=this.mainCameraComponent;return i.cam||i.buildCamera(),i.cam}return null}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createRenderer(){var i,e,t;(i=this.renderer)==null||i.dispose();const s={antialias:!0},r=(t=(e=this.domElement)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("canvas");r&&(s.canvas=r),this.renderer=new pd(s),this.renderer.toneMappingExposure=1,this.renderer.toneMapping=_r,this.renderer.setClearColor(new be("lightgrey"),0),this.renderer.antialias=!0,this.renderer.alpha=!1,this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Sw,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputEncoding=yt,this.renderer.physicallyCorrectLights=!0}internalOnUpdateVisible(){var i,e;(i=this._intersectionObserver)==null||i.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}updateSize(){var i,e,t;if(!this.isManagedExternally&&((i=this.renderer.xr)==null?void 0:i.isPresenting)===!1){this._sizeChanged=!1;const s=this.resolutionScaleFactor,r=this.domWidth*s,n=this.domHeight*s,o=this.mainCamera;this.updateAspect(o),this.renderer.setSize(r,n),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((e=this.composer.setSize)==null||e.call(this.composer,r,n),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((t=this.composer.setPixelRatio)==null||t.call(this.composer,window.devicePixelRatio)))}}updateAspect(i,e,t){if(!i)return;e===void 0&&(e=this.domWidth),t===void 0&&(t=this.domHeight);const s=i.aspect;i.aspect=e/t,s!==i.aspect&&i.updateProjectionMatrix()}async onCreate(i,e){try{return this._isCreating=!0,await this.internalOnCreate(i,e)}finally{this._isCreating=!1}}clear(){var i,e,t,s;Ei.dispatchCallback(xr.ContextClearing,this),rl(this.scene,!0,!0),this.scene=new Vr,(i=this.addressables)==null||i.dispose(),(e=this.lightmaps)==null||e.clear(),(s=(t=this.physics)==null?void 0:t.engine)==null||s.clearCaches(),this.isManagedExternally||(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),Ei.dispatchCallback(xr.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var i,e;this.clear(),(i=this.renderer)==null||i.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear()),this.isManagedExternally||this.renderer.dispose(),this.scene=null,this.renderer=null,this.input.dispose();for(const t of this._disposeCallbacks)try{t()}catch(s){console.error("Error in on dispose callback:",s,t)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Ei.dispatchCallback(xr.ContextDestroyed,this),Ei.unregister(this)}registerCoroutineUpdate(i,e,t){return 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(s=>s.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 s=t.length-1;s>=0;s--)t[s].comp===i&&t.splice(s,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 s=i.cam;s.isPerspectiveCamera&&this.updateAspect(s),(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){var t;this._onBeforeRenderListeners.has(i.uuid)||(this._onBeforeRenderListeners.set(i.uuid,[]),i.onBeforeRender=this._createRenderCallbackWrapper(i,this._onBeforeRenderListeners)),(t=this._onBeforeRenderListeners.get(i.uuid))==null||t.push(e)}removeBeforeRenderListener(i,e){if(this._onBeforeRenderListeners.has(i.uuid)){const t=this._onBeforeRenderListeners.get(i.uuid),s=t.indexOf(e);s>=0&&t.splice(s,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),s=t.indexOf(e);s>=0&&t.splice(s,1)}}_createRenderCallbackWrapper(i,e){return(t,s,r,n,o,a)=>{const l=e.get(i.uuid);if(l)for(let c=0;c<l.length;c++){const u=l[c];u(t,s,r,n,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,e){var t,s;this.clear(),(t=this.renderer)==null||t.setAnimationLoop(null),await xf(1),ns.Current=this,await Ei.dispatchCallback(xr.ContextCreationStart,this);let r=!0,n;try{ns.Current=this,i&&(n=await i(this,e))}catch(o){console.error(o),r=!1}if(!r)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return Ld&&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),ns.Current=this,ns.Current=this;for(let o=0;o<this.new_scripts.length;o++){const a=this.new_scripts[o];if(a.gameObject!==void 0&&a.gameObject!==null){a.gameObject.userData===void 0&&(a.gameObject.userData={}),a.gameObject.userData.components===void 0&&(a.gameObject.userData.components=[]);const l=a.gameObject.userData.components;l.includes(a)||l.push(a)}}if(this.post_setup_callbacks)for(let o=0;o<this.post_setup_callbacks.length;o++)ns.Current=this,await this.post_setup_callbacks[o](this);if(!this.mainCamera){ns.Current=this;let o=null;Xh(this.scene,a=>{const l=a;if(l!=null&&l.isCamera){if(Rg(l.gameObject),!l.activeAndEnabled)return;if(l.tag==="MainCamera")return o=l,!0;o=l}}),o?this.setCurrentCamera(o):!Ei.dispatchCallback(xr.MissingCamera,this)&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(ns.Current=this,Ay(this),!this.isManagedExternally&&this.composer&&this.mainCamera){const o=new Ey(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(o),this.composer.setSize(this.domWidth,this.domHeight)}return this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(s=this.domElement.shadowRoot)==null||s.appendChild(this._stats.dom)),Ld&&F0(this.scene,!0),this.targetFrameRate===void 0?(Ld&&console.warn("No target framerate set, using default",ns.DefaultTargetFrameRate),this.targetFrameRate=ns._defaultTargetFramerate):Ld&&console.log("Target framerate set to",this.targetFrameRate),this._isCreating=!1,this.restartRenderLoop(),this._dispatchReadyAfterFrame=!0,Ei.dispatchCallback(xr.ContextCreated,this,{files:n})}restartRenderLoop(){if(!this.renderer)return console.error("Can not start render loop without renderer"),!1;if(this._isCreating)return console.warn("Can not start render loop while creating context"),!1;const i=this.render.bind(this);return this.renderer.setAnimationLoop(i),!0}render(i,e){if(lr()||Ld||q9())try{this.internalRender(i,e)}catch(t){(lr()||Ld)&&t instanceof Error&&rs("Exception during render-loop.<br/>See console for details.",fo.Error),console.error(t),console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null),this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}else this.internalRender(i,e)}internalRender(i,e){var t,s;if(this._xrFrame=e,this._currentFrameEvent=-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;this._accumulatedTime=0}if((t=this._stats)==null||t.begin(),ns.Current=this,!this.onHandlePaused()){for(ns.Current=this,this.time.update(),gq&&console.log("FPS",this.time.smoothedFps.toFixed(0)),Ay(this),yy(this.scene),aD(this);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_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 n=this.scripts_earlyUpdate[r];n.activeAndEnabled&&n.earlyUpdate!==void 0&&(ns.Current=this,n.earlyUpdate())}if(this.executeCoroutines(0),!this.onHandlePaused()){this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const n=this.scripts_update[r];n.activeAndEnabled&&n.update!==void 0&&(ns.Current=this,n.update())}if(this.executeCoroutines(1),!this.onHandlePaused()){this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const n=this.scripts_lateUpdate[r];n.activeAndEnabled&&n.lateUpdate!==void 0&&(ns.Current=this,n.lateUpdate())}if(this.executeCoroutines(2),!this.onHandlePaused()){if(this.physics.engine){const r=this.time.deltaTime/1;for(let n=0;n<1;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(r),this._currentFrameEvent=10,this.executeCoroutines(10);this.physics.engine.postStep()}if(!this.onHandlePaused()){if(this.isVisibleToUser){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const n=this.scripts_onBeforeRender[r];n.activeAndEnabled&&n.onBeforeRender!==void 0&&(ns.Current=this,n.onBeforeRender(e))}if(this.executeCoroutines(3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r]();this.isManagedExternally||(K9(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4);for(let r=0;r<this.scripts_onAfterRender.length;r++){const n=this.scripts_onAfterRender[r];n.activeAndEnabled&&n.onAfterRender!==void 0&&(ns.Current=this,n.onAfterRender())}if(this.executeCoroutines(4),this.post_render_callbacks)for(const r in this.post_render_callbacks)this.post_render_callbacks[r]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),(s=this._stats)==null||s.end(),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")))}}}}}}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){fq&&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&&(ns.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 ei(this.domWidth,this.domHeight),this._requireDepthTexture){const t=new WA(this.domWidth,this.domHeight);this._renderTarget.depthTexture=t}this._requireColorTexture&&(this._renderTarget.texture=new Ft,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Wt,this._renderTarget.texture.magFilter=Wt,this._renderTarget.texture.format=wi)}const i=this._renderTarget;i.texture&&(i.texture.encoding=this.renderer.outputEncoding);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(i),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(i){if(this.coroutines[i]){const t=this.coroutines[i];for(let s=0;s<t.length;s++)try{const r=t[s];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){mq&&console.log("Removing coroutine",r.comp,r.comp.enabled),t.splice(s,1),--s;continue}const n=r.chained;if(n&&n.length>0){const l=n[n.length-1].next();if(l.done&&n.pop(),e(l)&&(r.chained||(r.chained=[]),r.chained.push(l.value)),!l.done)continue}const o=r.main.next();if(o.done===!0){t.splice(s,1),--s;continue}const a=o.value;if(e(a)){if(a.next().done)continue;r.chained||(r.chained=[]),r.chained.push(a)}}catch(r){console.error(r)}}function e(t){return!!(t&&t.next&&t.return)}}};let Lt=ns;h(Lt,"_defaultTargetFramerate",{value:60});const xc=re("debugaroverlay"),Kh="ar",eO="quit-ar";class yq{constructor(){h(this,"arContainer",null),h(this,"closeARCallback"),h(this,"currentSession",null),h(this,"registeredCloseEventElements",[]),h(this,"_createdAROnlyElements",[]),h(this,"_reparentedObjects",[]),this.closeARCallback=this.onRequestedEndAR.bind(this)}get ARContainer(){return this.arContainer}requestEndAR(){this.onRequestedEndAR()}onBegin(e,t,s){this.currentSession=s,this.arContainer=t,e.domElement.shadowRoot.querySelectorAll(`.${Kh}`).forEach(n=>{var o;n&&n!==this.arContainer&&(this._reparentedObjects.push({el:n,previousParent:n.parentElement}),(o=this.arContainer)==null||o.appendChild(n))});const r=t.getElementsByClassName(eO);if(!r||r.length<=0)console.warn(`Missing quit AR elements, creating fallback X button. Use class name '${eO}' to override.`),this.createFallbackCloseARButton(this.arContainer);else for(let n=0;n<r.length;n++){const o=r[n];o&&(o.addEventListener("click",this.closeARCallback),this.registeredCloseEventElements.push(o))}}onEnd(e){var t;for(const s of this._createdAROnlyElements)s.remove&&s.remove();for(const s of this._reparentedObjects){const r=s.el;(t=s.previousParent)==null||t.appendChild(r)}this._reparentedObjects.length=0,vw()&&setTimeout(()=>{var s;const r=e.renderer.domElement;r&&((s=e.domElement.shadowRoot)==null||s.prepend(r));const n=document.querySelectorAll("*");for(var o=0;o<n.length;o++){const a=n[o];a&&a._displayChanged!==void 0&&a._displayWas!==void 0&&(a.style.display=a._displayWas)}},10)}findOrCreateARContainer(e){if(xc&&console.log("findOrCreateARContainer"),e.classList.contains(Kh))return xc&&console.log("Found overlay container in needle-engine element"),e;if(e.shadowRoot){const r=e.shadowRoot.querySelector(`.${Kh}`);if(r)return xc&&console.log("Found overlay container in needle-engine element"),r}const t=document.getElementsByClassName(Kh);if(t&&t.length>0)return xc&&console.log("Found overlay container in document"),t[0];xc&&console.log("No overlay container found in document - generating new ony");const s=document.createElement("div");return s.classList.add(Kh),s.style.cssText=`
|
|
3846
3846
|
position: fixed;
|
|
3847
3847
|
top: 0;
|
|
3848
3848
|
left: 0;
|
|
@@ -3853,7 +3853,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
3853
3853
|
z-index: 9999;
|
|
3854
3854
|
pointer-events: none;
|
|
3855
3855
|
// background: rgba(0,0,0,1);
|
|
3856
|
-
`,xc&&this.createFallbackCloseARButton(e),this.appendElement(s,e)}onRequestedEndAR(){if(this.currentSession){this.currentSession.end(),this.currentSession=null;for(const e of this.registeredCloseEventElements)e.removeEventListener("click",this.closeARCallback);this.registeredCloseEventElements.length=0}}createFallbackCloseARButton(e){const t=document.createElement("slot");t.setAttribute("name","quit-ar"),this.appendElement(t,e),xc&&t.addEventListener("click",()=>console.log("Clicked fallback close button")),t.addEventListener("click",this.closeARCallback),this._createdAROnlyElements.push(t),t.style.pointerEvents="auto";var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.classList.add("quit-ar-button"),s.setAttribute("width","38px"),s.setAttribute("height","38px"),t.appendChild(s);var r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),r.setAttribute("stroke","#ddd"),r.setAttribute("stroke-width","3px"),s.appendChild(r),xc&&console.log("Created fallback close button",s,e)}appendElement(e,t){return t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}class $ extends Me{constructor(){super(...arguments),h(this,"guid")}static isDestroyed(e){return mC(e)}static setActive(e,t,s=!0){e&&(Mg(e,t),yy(e),t&&s&&aD(Lt.Current,e))}static isActiveSelf(e){return Pd(e)}static isActiveInHierarchy(e){return $k(e)}static markAsInstancedRendered(e,t){eD(e,t)}static isUsingInstancing(e){return vy(e)}static foreachComponent(e,t,s=!0){return Xh(e,t,s)}static instantiateSynced(e,t){return e?hC(e,t):null}static instantiate(e,t=null){return Tg(e,t)}static destroySynced(e,t,s=!0){if(!e)return;const r=e;t=t??Lt.Current,ly(r,t.connection,s)}static destroy(e,t=!0,s=!0){return rl(e,t,s)}static add(e,t,s){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}s||(s=Lt.Current),t.add(e),Mg(e,!0),yy(e),s?$.foreachComponent(e,r=>{AC(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var t;e&&((t=e.parent)==null||t.remove(e),Mg(e,!1),yy(e),$.foreachComponent(e,s=>{X9(s)},!0))}static invokeOnChildren(e,t,...s){this.invoke(e,t,!0,s)}static invoke(e,t,s=!1,...r){e&&this.foreachComponent(e,n=>{const o=n[t];o&&typeof o=="function"&&o?.call(n,...r)},s)}static addNewComponent(e,t,s=!0){const r=new t;return qh(e,r,s),r}static addComponent(e,t){return this.moveComponent(e,t)}static moveComponent(e,t){return pC(e,t)}static removeComponent(e){return dC(e.gameObject,e),e}static getOrAddComponent(e,t){return hy(e,t)}static getComponent(e,t){return e===null?null:Td(e,t)}static getComponents(e,t,s=null){return e===null?s??[]:bg(e,t,s)}static findByGuid(e,t){return Ig(e,t)}static findObjectOfType(e,t,s=!0){return Qk(e,t??Lt.Current,s)}static findObjectsOfType(e,t){const s=[];return jk(e,s,t),s}static getComponentInChildren(e,t){return xg(e,t)}static getComponentsInChildren(e,t,s=null){return wg(e,t,s??void 0)}static getComponentInParent(e,t){return _g(e,t)}static getComponentsInParent(e,t,s=null){return uy(e,t,s)}static getAllComponents(e){var t;return[...(t=e.userData)==null?void 0:t.components]}static*iterateComponents(e){var t;const s=(t=e?.userData)==null?void 0:t.components;if(s&&Array.isArray(s))for(let r=0;r<s.length;r++)yield s[r]}}var os;let wc=(os=class{constructor(){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,"_worldPosition"),h(this,"_worldQuaternion"),h(this,"_worldEuler"),h(this,"_worldRotation"),h(this,"_eventListeners",new Map),this.__internalNewInstanceCreated()}get isComponent(){return!0}get context(){return this.__context??Lt.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.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[sl];return i===void 0?!0:i}set __isActiveInHierarchy(i){this.gameObject&&(this.gameObject[sl]=i)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(i,e=mn.Update){return this.context.registerCoroutineUpdate(this,i,e)}stopCoroutine(i,e=mn.Update){this.context.unregisterCoroutineUpdate(i,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(i){return this.__destroyed?(lr()&&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,(i=this.destroy)==null||i.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this})),Uk(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(i){if(this.__destroyed){lr()&&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 this._worldPosition||(this._worldPosition=new S),xt(this.gameObject,this._worldPosition),this._worldPosition}set worldPosition(i){Ki(this.gameObject,i)}setWorldPosition(i,e,t){os._worldPositionBuffer.set(i,e,t),this.worldPosition=os._worldPositionBuffer}get worldQuaternion(){return this._worldQuaternion||(this._worldQuaternion=new Ce),Ss(this.gameObject,this._worldQuaternion)}set worldQuaternion(i){Wr(this.gameObject,i)}setWorldQuaternion(i,e,t,s){os._worldQuaternionBuffer.set(i,e,t,s),this.worldQuaternion=os._worldQuaternionBuffer}get worldEuler(){return this._worldEuler||(this._worldEuler=new vs),this._worldEuler.setFromQuaternion(this.worldQuaternion),this._worldEuler}set worldEuler(i){var e;this._worldQuaternion||(this._worldQuaternion=new Ce),(e=this._worldQuaternion)==null||e.setFromEuler(i),this.worldQuaternion=this._worldQuaternion}get worldRotation(){const i=this.worldEuler;this._worldRotation||(this._worldRotation=new S);const e=this._worldRotation;return e.set(i.x,i.y,i.z),e.x=Je.toDegrees(e.x),e.y=Je.toDegrees(e.y),e.z=Je.toDegrees(e.z),e}set worldRotation(i){this.setWorldRotation(i.x,i.y,i.z,!0)}setWorldRotation(i,e,t,s=!0){s&&(i=Je.toRadians(i),e=Je.toRadians(e),t=Je.toRadians(t)),os._worldEulerBuffer.set(i,e,t),os._worldQuaternionBuffer.setFromEuler(os._worldEulerBuffer),this.worldQuaternion=os._worldQuaternionBuffer}get forward(){return os._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return os._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return os._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(!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(os,"_worldPositionBuffer",new S),h(os,"_worldQuaternionBuffer",new Ce),h(os,"_worldEulerBuffer",new vs),h(os,"_tempQuaternionBuffer2",new Ce),h(os,"_forward",new S),h(os,"_right",new S),h(os,"_up",new S),os);class Ee extends wc{}const bq=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ee,Component:wc,GameObject:$},Symbol.toStringTag,{value:"Module"})),xq='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',wq=new Blob([xq],{type:"image/svg+xml;charset=utf-8"}),_q=URL.createObjectURL(wq),tO=_q,cl=re("debuglicense");let Fd="basic";cl&&console.log("License Type: "+Fd);function Ud(){switch(Fd){case"pro":case"enterprise":return!0}return!1}function iO(){switch(Fd){case"indie":return!0}return!1}function Lg(){return Ud()||iO()}Ei.registerCallback(xr.ContextRegistered,i=>{Sq(i.context),Rq()});let sO;async function Cq(){if(Fd==="basic")try{const i=await fetch("https://engine.needle.tools/licensing/check");if(cl){const e=await i.text();console.log('"'+e+`"
|
|
3856
|
+
`,xc&&this.createFallbackCloseARButton(e),this.appendElement(s,e)}onRequestedEndAR(){if(this.currentSession){this.currentSession.end(),this.currentSession=null;for(const e of this.registeredCloseEventElements)e.removeEventListener("click",this.closeARCallback);this.registeredCloseEventElements.length=0}}createFallbackCloseARButton(e){const t=document.createElement("slot");t.setAttribute("name","quit-ar"),this.appendElement(t,e),xc&&t.addEventListener("click",()=>console.log("Clicked fallback close button")),t.addEventListener("click",this.closeARCallback),this._createdAROnlyElements.push(t),t.style.pointerEvents="auto";var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.classList.add("quit-ar-button"),s.setAttribute("width","38px"),s.setAttribute("height","38px"),t.appendChild(s);var r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),r.setAttribute("stroke","#ddd"),r.setAttribute("stroke-width","3px"),s.appendChild(r),xc&&console.log("Created fallback close button",s,e)}appendElement(e,t){return t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}class $ extends Me{constructor(){super(...arguments),h(this,"guid")}static isDestroyed(e){return mC(e)}static setActive(e,t,s=!0){e&&(Mg(e,t),yy(e),t&&s&&aD(Lt.Current,e))}static isActiveSelf(e){return Pd(e)}static isActiveInHierarchy(e){return $k(e)}static markAsInstancedRendered(e,t){eD(e,t)}static isUsingInstancing(e){return vy(e)}static foreachComponent(e,t,s=!0){return Xh(e,t,s)}static instantiateSynced(e,t){return e?hC(e,t):null}static instantiate(e,t=null){return Tg(e,t)}static destroySynced(e,t,s=!0){if(!e)return;const r=e;t=t??Lt.Current,ly(r,t.connection,s)}static destroy(e,t=!0,s=!0){return rl(e,t,s)}static add(e,t,s){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}s||(s=Lt.Current),t.add(e),Mg(e,!0),yy(e),s?$.foreachComponent(e,r=>{AC(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var t;e&&((t=e.parent)==null||t.remove(e),Mg(e,!1),yy(e),$.foreachComponent(e,s=>{X9(s)},!0))}static invokeOnChildren(e,t,...s){this.invoke(e,t,!0,s)}static invoke(e,t,s=!1,...r){e&&this.foreachComponent(e,n=>{const o=n[t];o&&typeof o=="function"&&o?.call(n,...r)},s)}static addNewComponent(e,t,s=!0){const r=new t;return qh(e,r,s),r}static addComponent(e,t){return this.moveComponent(e,t)}static moveComponent(e,t){return pC(e,t)}static removeComponent(e){return dC(e.gameObject,e),e}static getOrAddComponent(e,t){return hy(e,t)}static getComponent(e,t){return e===null?null:Td(e,t)}static getComponents(e,t,s=null){return e===null?s??[]:bg(e,t,s)}static findByGuid(e,t){return Ig(e,t)}static findObjectOfType(e,t,s=!0){return Qk(e,t??Lt.Current,s)}static findObjectsOfType(e,t){const s=[];return jk(e,s,t),s}static getComponentInChildren(e,t){return xg(e,t)}static getComponentsInChildren(e,t,s=null){return wg(e,t,s??void 0)}static getComponentInParent(e,t){return _g(e,t)}static getComponentsInParent(e,t,s=null){return uy(e,t,s)}static getAllComponents(e){var t;return[...(t=e.userData)==null?void 0:t.components]}static*iterateComponents(e){var t;const s=(t=e?.userData)==null?void 0:t.components;if(s&&Array.isArray(s))for(let r=0;r<s.length;r++)yield s[r]}}var os;let wc=(os=class{constructor(){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,"_worldPosition"),h(this,"_worldQuaternion"),h(this,"_worldEuler"),h(this,"_worldRotation"),h(this,"_eventListeners",new Map),this.__internalNewInstanceCreated()}get isComponent(){return!0}get context(){return this.__context??Lt.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[sl];return i===void 0?!0:i}set __isActiveInHierarchy(i){this.gameObject&&(this.gameObject[sl]=i)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(i,e=mn.Update){return this.context.registerCoroutineUpdate(this,i,e)}stopCoroutine(i,e=mn.Update){this.context.unregisterCoroutineUpdate(i,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(i){return this.__destroyed?(lr()&&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,(i=this.destroy)==null||i.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this})),Uk(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(i){if(this.__destroyed){lr()&&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 this._worldPosition||(this._worldPosition=new S),xt(this.gameObject,this._worldPosition),this._worldPosition}set worldPosition(i){Ki(this.gameObject,i)}setWorldPosition(i,e,t){os._worldPositionBuffer.set(i,e,t),this.worldPosition=os._worldPositionBuffer}get worldQuaternion(){return this._worldQuaternion||(this._worldQuaternion=new Ce),Ss(this.gameObject,this._worldQuaternion)}set worldQuaternion(i){Wr(this.gameObject,i)}setWorldQuaternion(i,e,t,s){os._worldQuaternionBuffer.set(i,e,t,s),this.worldQuaternion=os._worldQuaternionBuffer}get worldEuler(){return this._worldEuler||(this._worldEuler=new vs),this._worldEuler.setFromQuaternion(this.worldQuaternion),this._worldEuler}set worldEuler(i){var e;this._worldQuaternion||(this._worldQuaternion=new Ce),(e=this._worldQuaternion)==null||e.setFromEuler(i),this.worldQuaternion=this._worldQuaternion}get worldRotation(){const i=this.worldEuler;this._worldRotation||(this._worldRotation=new S);const e=this._worldRotation;return e.set(i.x,i.y,i.z),e.x=Je.toDegrees(e.x),e.y=Je.toDegrees(e.y),e.z=Je.toDegrees(e.z),e}set worldRotation(i){this.setWorldRotation(i.x,i.y,i.z,!0)}setWorldRotation(i,e,t,s=!0){s&&(i=Je.toRadians(i),e=Je.toRadians(e),t=Je.toRadians(t)),os._worldEulerBuffer.set(i,e,t),os._worldQuaternionBuffer.setFromEuler(os._worldEulerBuffer),this.worldQuaternion=os._worldQuaternionBuffer}get forward(){return os._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return os._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return os._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(!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(os,"_worldPositionBuffer",new S),h(os,"_worldQuaternionBuffer",new Ce),h(os,"_worldEulerBuffer",new vs),h(os,"_tempQuaternionBuffer2",new Ce),h(os,"_forward",new S),h(os,"_right",new S),h(os,"_up",new S),os);class Ee extends wc{}const bq=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ee,Component:wc,GameObject:$},Symbol.toStringTag,{value:"Module"})),xq='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',wq=new Blob([xq],{type:"image/svg+xml;charset=utf-8"}),_q=URL.createObjectURL(wq),tO=_q,cl=re("debuglicense");let Fd="basic";cl&&console.log("License Type: "+Fd);function Ud(){switch(Fd){case"pro":case"enterprise":return!0}return!1}function iO(){switch(Fd){case"indie":return!0}return!1}function Lg(){return Ud()||iO()}Ei.registerCallback(xr.ContextRegistered,i=>{Sq(i.context),Rq()});let sO;async function Cq(){if(Fd==="basic")try{const i=await fetch("https://engine.needle.tools/licensing/check");if(cl){const e=await i.text();console.log('"'+e+`"
|
|
3857
3857
|
`,i)}i.status===200&&(Fd="pro")}catch(i){cl&&console.error("License check failed",i)}}sO=Cq();async function Sq(i){try{if(Lg()!==!0)return NC(i)}catch(e){return cl&&console.log("License check failed",e),NC(i)}cl&&NC(i)}const rO="needle-license-element",FC=5e3,UC=200;async function NC(i){await sO,!Lg()&&(Mq(),i.domElement.addEventListener("ready",()=>{setTimeout(()=>{Eq(i)},1e3)}))}function Eq(i){const e=Iq(),t=Tq(),s=setInterval(()=>{if(!e)return;const l=i.domElement.shadowRoot||i.domElement;e.parentNode!==l&&(l.appendChild(e),t&&l.appendChild(t))},100);let r=`<img class="logo" src="${tO}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`;const n=document.createElement("div");n.innerHTML=r,n.classList.add("logo"),e.appendChild(n);const o=document.createElement("div");o.classList.add("text"),e.appendChild(o),e.title="Needle Engine",Lg()||(e.title+=" No active license found - Non Commercial Use"),e.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")});const a=FC+UC;setTimeout(()=>{clearInterval(s),e?.remove(),t?.remove()},a)}let nO=0;async function Mq(i){const e=Date.now();if(e-nO<2e3)return;nO=e,console.log("%c Needle Engine \u2014 No license active, commercial use is not allowed. Visit https://needle.tools/pricing for more information and licensing options.",`
|
|
3858
3858
|
position: relative;
|
|
3859
3859
|
display: block;
|
|
@@ -3842,7 +3842,7 @@ outputColor=vec4(color,inputColor.a);}`,IF=class extends ta{constructor({blendFu
|
|
|
3842
3842
|
irradiance += 0.;
|
|
3843
3843
|
#else
|
|
3844
3844
|
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
3845
|
-
#endif`);Ye.lightmap.lightmapScaleOffset={value:new ot(1,1,0,0)};const Aq=oe("debugplayerview");var Ba=(n=>(n.Browser="browser",n.Headset="headset",n.Handheld="handheld",n))(Ba||{});class GF{constructor(e,t){h(this,"userId");h(this,"context");h(this,"viewDevice","browser");h(this,"removed",!1);h(this,"_object");this.userId=e,this.context=t}get currentObject(){return this._object}set currentObject(e){this._object=e}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class QF{constructor(e){h(this,"context");h(this,"playerViews",new Map);this.context=e}setPlayerView(e,t,i){let s=this.playerViews.get(e);s||(s=new GF(e,this.context),this.playerViews.set(e,s)),s.viewDevice=i,s.currentObject=t,s.removed=!1}getPlayerView(e){if(!e)return;if(!this.context.connection.userIsInRoom(e)){this.playerViews.delete(e);return}return this.playerViews.get(e)}removePlayerView(e,t){const i=this.playerViews.get(e);(i==null?void 0:i.viewDevice)===t&&(Aq&&console.log("REMOVE",e),i.removed=!0,this.playerViews.delete(e))}}const wd=oe("debugcontext"),vq=oe("stats"),yq=oe("debugactive"),bq=oe("debugframerate"),_q=oe("debugcoroutine"),xq={};class wq{constructor(e){h(this,"name");h(this,"alias");h(this,"domElement");h(this,"renderer");h(this,"hash");this.domElement=e??document.body}}var Nr=(n=>(n[n.EarlyUpdate=0]="EarlyUpdate",n[n.Update=1]="Update",n[n.LateUpdate=2]="LateUpdate",n[n.OnBeforeRender=3]="OnBeforeRender",n[n.OnAfterRender=4]="OnAfterRender",n[n.PrePhysicsStep=9]="PrePhysicsStep",n[n.PostPhysicsStep=10]="PostPhysicsStep",n[n.Undefined=-1]="Undefined",n))(Nr||{}),Tm=(n=>(n.ImmersiveVR="immersive-vr",n.ImmersiveAR="immersive-ar",n))(Tm||{});function k_(n,e){if(!n)return;const t=(e==null?void 0:e.new_scripts)??kt.Current.new_scripts;t.includes(n)||t.push(n)}const rn=class{constructor(e){h(this,"name");h(this,"alias");h(this,"isManagedExternally",!1);h(this,"isPaused",!1);h(this,"runInBackground",!1);h(this,"targetFrameRate");h(this,"hash");h(this,"domElement");h(this,"_resolutionScaleFactor",1);h(this,"_boundingClientRectFrame",-1);h(this,"_boundingClientRect",null);h(this,"_domX");h(this,"_domY");h(this,"xrSessionMode");h(this,"_xrFrame",null);h(this,"_currentFrameEvent",-1);h(this,"scene");h(this,"renderer");h(this,"composer",null);h(this,"scripts",[]);h(this,"scripts_pausedChanged",[]);h(this,"scripts_earlyUpdate",[]);h(this,"scripts_update",[]);h(this,"scripts_lateUpdate",[]);h(this,"scripts_onBeforeRender",[]);h(this,"scripts_onAfterRender",[]);h(this,"scripts_WithCorroutines",[]);h(this,"coroutines",{});h(this,"mainCameraComponent");h(this,"post_setup_callbacks",[]);h(this,"pre_update_callbacks",[]);h(this,"pre_render_callbacks",[]);h(this,"post_render_callbacks",[]);h(this,"new_scripts",[]);h(this,"new_script_start",[]);h(this,"new_scripts_pre_setup_callbacks",[]);h(this,"new_scripts_post_setup_callbacks",[]);h(this,"application");h(this,"time");h(this,"input");h(this,"physics");h(this,"connection");h(this,"assets");h(this,"mainLight",null);h(this,"sceneLighting");h(this,"addressables");h(this,"lightmaps");h(this,"players");h(this,"_sizeChanged",!1);h(this,"_isCreated",!1);h(this,"_isCreating",!1);h(this,"_isVisible",!1);h(this,"_stats",vq?eq():null);h(this,"_intersectionObserver",null);h(this,"_disposeCallbacks",[]);h(this,"_cameraStack",[]);h(this,"_onBeforeRenderListeners",new Map);h(this,"_onAfterRenderListeners",new Map);h(this,"_requireDepthTexture",!1);h(this,"_requireColorTexture",!1);h(this,"_renderTarget");h(this,"_isRendering",!1);h(this,"_accumulatedTime",0);h(this,"_framerateClock",new l_);h(this,"_dispatchReadyAfterFrame",!1);h(this,"_wasPaused",!1);this.name=(e==null?void 0:e.name)||"",this.alias=e==null?void 0:e.alias,this.domElement=(e==null?void 0:e.domElement)||document.body,this.hash=e==null?void 0:e.hash,e!=null&&e.renderer?(this.renderer=e.renderer,this.isManagedExternally=!0):this.createRenderer(),this.scene=new pr,Li.register(this),this.application=new zF(this),this.time=new LO,this.input=new EO(this),this.physics=new OO(this),this.connection=new BL(this),this.assets=new KL,this.sceneLighting=new UF(this),this.addressables=new LF(this),this.lightmaps=new mq(this),this.players=new QF(this);const t=()=>this._sizeChanged=!0;window.addEventListener("resize",t),this._disposeCallbacks.push(()=>window.removeEventListener("resize",t));const i=new ResizeObserver(s=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()})}static get DefaultTargetFrameRate(){return rn._defaultTargetFramerate.value}static set DefaultTargetFrameRate(e){rn._defaultTargetFramerate.value=e}get version(){return C_}static get Current(){return Li.Current}static set Current(e){Li.Current=e}appendHTMLElement(e){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(e):this.domElement.appendChild(e)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(e){if(e!==this._resolutionScaleFactor&&typeof e=="number"){if(e<=0){console.error("Invalid resolution scale factor",e);return}this._resolutionScaleFactor=e,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var e;return((e=this.renderer.xr)==null?void 0:e.isPresenting)||!1}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get xrSession(){var e;return(e=this.renderer.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get arOverlayElement(){const e=this.domElement;return typeof e.getAROverlayContainer=="function"?e.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this.mainCameraComponent){const e=this.mainCameraComponent;return e.cam||e.buildCamera(),e.cam}return null}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createRenderer(){var i,s,r;(i=this.renderer)==null||i.dispose();const e={antialias:!0},t=(r=(s=this.domElement)==null?void 0:s.shadowRoot)==null?void 0:r.querySelector("canvas");t&&(e.canvas=t),this.renderer=new zf(e),this.renderer.toneMappingExposure=1,this.renderer.toneMapping=Qs,this.renderer.setClearColor(new ye("lightgrey"),0),this.renderer.antialias=!0,this.renderer.alpha=!1,this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=HE,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputEncoding=yt,this.renderer.physicallyCorrectLights=!0}internalOnUpdateVisible(){var e,t;(e=this._intersectionObserver)==null||e.disconnect(),(t=this._intersectionObserver)==null||t.observe(this.domElement)}updateSize(){var e,t,i;if(!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const s=this.resolutionScaleFactor,r=this.domWidth*s,o=this.domHeight*s,a=this.mainCamera;this.updateAspect(a),this.renderer.setSize(r,o),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((t=this.composer.setSize)==null||t.call(this.composer,r,o),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((i=this.composer.setPixelRatio)==null||i.call(this.composer,window.devicePixelRatio)))}}updateAspect(e,t,i){if(!e)return;t===void 0&&(t=this.domWidth),i===void 0&&(i=this.domHeight);const s=e.aspect;e.aspect=t/i,s!==e.aspect&&e.updateProjectionMatrix()}async onCreate(e,t){try{return this._isCreating=!0,await this.internalOnCreate(e,t)}finally{this._isCreating=!1}}clear(){var e,t,i,s;Li.dispatchCallback(zs.ContextClearing,this),Gl(this.scene,!0,!0),this.scene=new pr,(e=this.addressables)==null||e.dispose(),(t=this.lightmaps)==null||t.clear(),(s=(i=this.physics)==null?void 0:i.engine)==null||s.clearCaches(),this.isManagedExternally||(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),Li.dispatchCallback(zs.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var e,t;this.clear(),(e=this.renderer)==null||e.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear()),this.isManagedExternally||this.renderer.dispose(),this.scene=null,this.renderer=null,this.input.dispose();for(const i of this._disposeCallbacks)try{i()}catch(s){console.error("Error in on dispose callback:",s,i)}(t=this.domElement)!=null&&t.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Li.dispatchCallback(zs.ContextDestroyed,this),Li.unregister(this)}registerCoroutineUpdate(e,t,i){return this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:e,main:t}),t}unregisterCoroutineUpdate(e,t){if(!this.coroutines[t])return;const i=this.coroutines[t].findIndex(s=>s.main===e);i>=0&&this.coroutines[t].splice(i,1)}stopAllCoroutinesFrom(e){for(const t in this.coroutines){const i=this.coroutines[t];for(let s=i.length-1;s>=0;s--)i[s].comp===e&&i.splice(s,1)}}setCurrentCamera(e){var s;if(!e)return;if(e.cam||e.buildCamera(),!e.cam){console.warn("Camera component is missing camera",e);return}const t=this._cameraStack.indexOf(e);t>=0&&this._cameraStack.splice(t,1),this._cameraStack.push(e),this.mainCameraComponent=e;const i=e.cam;i.isPerspectiveCamera&&this.updateAspect(i),(s=this.mainCameraComponent)==null||s.applyClearFlagsIfIsActiveCamera()}removeCamera(e){if(!e)return;const t=this._cameraStack.indexOf(e);if(t>=0&&this._cameraStack.splice(t,1),this.mainCameraComponent===e&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(e,t){var i;this._onBeforeRenderListeners.has(e.uuid)||(this._onBeforeRenderListeners.set(e.uuid,[]),e.onBeforeRender=this._createRenderCallbackWrapper(e,this._onBeforeRenderListeners)),(i=this._onBeforeRenderListeners.get(e.uuid))==null||i.push(t)}removeBeforeRenderListener(e,t){if(this._onBeforeRenderListeners.has(e.uuid)){const i=this._onBeforeRenderListeners.get(e.uuid),s=i.indexOf(t);s>=0&&i.splice(s,1)}}addAfterRenderListener(e,t){var i;this._onAfterRenderListeners.has(e.uuid)||(this._onAfterRenderListeners.set(e.uuid,[]),e.onAfterRender=this._createRenderCallbackWrapper(e,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(e.uuid))==null||i.push(t)}removeAfterRenderListener(e,t){if(this._onAfterRenderListeners.has(e.uuid)){const i=this._onAfterRenderListeners.get(e.uuid),s=i.indexOf(t);s>=0&&i.splice(s,1)}}_createRenderCallbackWrapper(e,t){return(i,s,r,o,a,l)=>{const c=t.get(e.uuid);if(c)for(let u=0;u<c.length;u++){const d=c[u];d(i,s,r,o,a,l)}}}get isRendering(){return this._isRendering}setRequireDepth(e){this._requireDepthTexture=e}setRequireColor(e){this._requireColorTexture=e}get depthTexture(){var e;return((e=this._renderTarget)==null?void 0:e.depthTexture)||null}get opaqueColorTexture(){var e;return((e=this._renderTarget)==null?void 0:e.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const e=getComputedStyle(this.domElement);return e.visibility!=="hidden"&&e.display!=="none"&&e.opacity!=="0"}async internalOnCreate(e,t){var r,o;this.clear(),(r=this.renderer)==null||r.setAnimationLoop(null),await tA(1),rn.Current=this,await Li.dispatchCallback(zs.ContextCreationStart,this);let i=!0,s;try{rn.Current=this,e&&(s=await e(this,t))}catch(a){console.error(a),i=!1}if(!i)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return wd&&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),rn.Current=this,rn.Current=this;for(let a=0;a<this.new_scripts.length;a++){const l=this.new_scripts[a];if(l.gameObject!==void 0&&l.gameObject!==null){l.gameObject.userData===void 0&&(l.gameObject.userData={}),l.gameObject.userData.components===void 0&&(l.gameObject.userData.components=[]);const c=l.gameObject.userData.components;c.includes(l)||c.push(l)}}if(this.post_setup_callbacks)for(let a=0;a<this.post_setup_callbacks.length;a++)rn.Current=this,await this.post_setup_callbacks[a](this);if(!this.mainCamera){rn.Current=this;let a=null;xu(this.scene,l=>{const c=l;if(c!=null&&c.isCamera){if(Vg(c.gameObject),!c.activeAndEnabled)return;if(c.tag==="MainCamera")return a=c,!0;a=c}}),a?this.setCurrentCamera(a):!Li.dispatchCallback(zs.MissingCamera,this)&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(rn.Current=this,sb(this),!this.isManagedExternally&&this.composer&&this.mainCamera){const a=new D_(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(a),this.composer.setSize(this.domWidth,this.domHeight)}return this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(o=this.domElement.shadowRoot)==null||o.appendChild(this._stats.dom)),wd&&$0(this.scene,!0),this.targetFrameRate===void 0?(wd&&console.warn("No target framerate set, using default",rn.DefaultTargetFrameRate),this.targetFrameRate=rn._defaultTargetFramerate):wd&&console.log("Target framerate set to",this.targetFrameRate),this._isCreating=!1,this.restartRenderLoop(),this._dispatchReadyAfterFrame=!0,Li.dispatchCallback(zs.ContextCreated,this,{files:s})}restartRenderLoop(){if(!this.renderer)return console.error("Can not start render loop without renderer"),!1;if(this._isCreating)return console.warn("Can not start render loop while creating context"),!1;const e=this.render.bind(this);return this.renderer.setAnimationLoop(e),!0}render(e,t){if(Ss()||wd||ZW())try{this.internalRender(e,t)}catch(i){(Ss()||wd)&&i instanceof Error&&yn("Exception during render-loop.<br/>See console for details.",qo.Error),console.error(i),console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null),this.domElement.dispatchEvent(new CustomEvent("error",{detail:i}))}else this.internalRender(e,t)}internalRender(e,t){var i,s;if(this._xrFrame=t,this._currentFrameEvent=-1,this.isInXR===!1&&this.targetFrameRate!==void 0){this._accumulatedTime+=this._framerateClock.getDelta();let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return;this._accumulatedTime=0}if((i=this._stats)==null||i.begin(),rn.Current=this,!this.onHandlePaused()){for(rn.Current=this,this.time.update(),bq&&console.log("FPS",this.time.smoothedFps.toFixed(0)),sb(this),f0(this.scene),hF(this);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_callbacks)for(const r in this.pre_update_callbacks)this.pre_update_callbacks[r]();this._currentFrameEvent=0;for(let r=0;r<this.scripts_earlyUpdate.length;r++){const o=this.scripts_earlyUpdate[r];o.activeAndEnabled&&o.earlyUpdate!==void 0&&(rn.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),!this.onHandlePaused()){this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const o=this.scripts_update[r];o.activeAndEnabled&&o.update!==void 0&&(rn.Current=this,o.update())}if(this.executeCoroutines(1),!this.onHandlePaused()){this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const o=this.scripts_lateUpdate[r];o.activeAndEnabled&&o.lateUpdate!==void 0&&(rn.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),!this.onHandlePaused()){if(this.physics.engine){const o=this.time.deltaTime/1;for(let a=0;a<1;a++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(o),this._currentFrameEvent=10,this.executeCoroutines(10);this.physics.engine.postStep()}if(!this.onHandlePaused()){if(this.isVisibleToUser){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const o=this.scripts_onBeforeRender[r];o.activeAndEnabled&&o.onBeforeRender!==void 0&&(rn.Current=this,o.onBeforeRender(t))}if(this.executeCoroutines(3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r]();this.isManagedExternally||(tj(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4);for(let r=0;r<this.scripts_onAfterRender.length;r++){const o=this.scripts_onAfterRender[r];o.activeAndEnabled&&o.onAfterRender!==void 0&&(rn.Current=this,o.onAfterRender())}if(this.executeCoroutines(4),this.post_render_callbacks)for(const r in this.post_render_callbacks)this.post_render_callbacks[r]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),(s=this._stats)==null||s.end(),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")))}}}}}}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){yq&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(rn.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new si(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Yb(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Gt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Yt,this._renderTarget.texture.magFilter=Yt,this._renderTarget.texture.format=Ti)}const e=this._renderTarget;e.texture&&(e.texture.encoding=this.renderer.outputEncoding);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){if(this.coroutines[e]){const i=this.coroutines[e];for(let s=0;s<i.length;s++)try{const r=i[s];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){_q&&console.log("Removing coroutine",r.comp,r.comp.enabled),i.splice(s,1),--s;continue}const a=r.chained;if(a&&a.length>0){const d=a[a.length-1].next();if(d.done&&a.pop(),t(d)&&(r.chained||(r.chained=[]),r.chained.push(d.value)),!d.done)continue}const l=r.main.next();if(l.done===!0){i.splice(s,1),--s;continue}const c=l.value;if(t(c)){if(c.next().done)continue;r.chained||(r.chained=[]),r.chained.push(c)}}catch(r){console.error(r)}}function t(i){return!!(i&&i.next&&i.return)}}};let kt=rn;h(kt,"_defaultTargetFramerate",{value:60});const _c=oe("debugaroverlay"),Kh="ar",XR="quit-ar";class Cq{constructor(){h(this,"arContainer",null);h(this,"closeARCallback");h(this,"currentSession",null);h(this,"registeredCloseEventElements",[]);h(this,"_createdAROnlyElements",[]);h(this,"_reparentedObjects",[]);this.closeARCallback=this.onRequestedEndAR.bind(this)}get ARContainer(){return this.arContainer}requestEndAR(){this.onRequestedEndAR()}onBegin(e,t,i){this.currentSession=i,this.arContainer=t,e.domElement.shadowRoot.querySelectorAll(`.${Kh}`).forEach(o=>{var a;o&&o!==this.arContainer&&(this._reparentedObjects.push({el:o,previousParent:o.parentElement}),(a=this.arContainer)==null||a.appendChild(o))});const r=t.getElementsByClassName(XR);if(!r||r.length<=0)console.warn(`Missing quit AR elements, creating fallback X button. Use class name '${XR}' to override.`),this.createFallbackCloseARButton(this.arContainer);else for(let o=0;o<r.length;o++){const a=r[o];a&&(a.addEventListener("click",this.closeARCallback),this.registeredCloseEventElements.push(a))}}onEnd(e){var t;for(const i of this._createdAROnlyElements)i.remove&&i.remove();for(const i of this._reparentedObjects){const s=i.el;(t=i.previousParent)==null||t.appendChild(s)}this._reparentedObjects.length=0,zE()&&setTimeout(()=>{var o;const i=e.renderer.domElement;i&&((o=e.domElement.shadowRoot)==null||o.prepend(i));const s=document.querySelectorAll("*");for(var r=0;r<s.length;r++){const a=s[r];a&&a._displayChanged!==void 0&&a._displayWas!==void 0&&(a.style.display=a._displayWas)}},10)}findOrCreateARContainer(e){if(_c&&console.log("findOrCreateARContainer"),e.classList.contains(Kh))return _c&&console.log("Found overlay container in needle-engine element"),e;if(e.shadowRoot){const s=e.shadowRoot.querySelector(`.${Kh}`);if(s)return _c&&console.log("Found overlay container in needle-engine element"),s}const t=document.getElementsByClassName(Kh);if(t&&t.length>0)return _c&&console.log("Found overlay container in document"),t[0];_c&&console.log("No overlay container found in document - generating new ony");const i=document.createElement("div");return i.classList.add(Kh),i.style.cssText=`
|
|
3845
|
+
#endif`);Ye.lightmap.lightmapScaleOffset={value:new ot(1,1,0,0)};const Aq=oe("debugplayerview");var Ba=(n=>(n.Browser="browser",n.Headset="headset",n.Handheld="handheld",n))(Ba||{});class GF{constructor(e,t){h(this,"userId");h(this,"context");h(this,"viewDevice","browser");h(this,"removed",!1);h(this,"_object");this.userId=e,this.context=t}get currentObject(){return this._object}set currentObject(e){this._object=e}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class QF{constructor(e){h(this,"context");h(this,"playerViews",new Map);this.context=e}setPlayerView(e,t,i){let s=this.playerViews.get(e);s||(s=new GF(e,this.context),this.playerViews.set(e,s)),s.viewDevice=i,s.currentObject=t,s.removed=!1}getPlayerView(e){if(!e)return;if(!this.context.connection.userIsInRoom(e)){this.playerViews.delete(e);return}return this.playerViews.get(e)}removePlayerView(e,t){const i=this.playerViews.get(e);(i==null?void 0:i.viewDevice)===t&&(Aq&&console.log("REMOVE",e),i.removed=!0,this.playerViews.delete(e))}}const wd=oe("debugcontext"),vq=oe("stats"),yq=oe("debugactive"),bq=oe("debugframerate"),_q=oe("debugcoroutine"),xq={};class wq{constructor(e){h(this,"name");h(this,"alias");h(this,"domElement");h(this,"renderer");h(this,"hash");this.domElement=e??document.body}}var Nr=(n=>(n[n.EarlyUpdate=0]="EarlyUpdate",n[n.Update=1]="Update",n[n.LateUpdate=2]="LateUpdate",n[n.OnBeforeRender=3]="OnBeforeRender",n[n.OnAfterRender=4]="OnAfterRender",n[n.PrePhysicsStep=9]="PrePhysicsStep",n[n.PostPhysicsStep=10]="PostPhysicsStep",n[n.Undefined=-1]="Undefined",n))(Nr||{}),Tm=(n=>(n.ImmersiveVR="immersive-vr",n.ImmersiveAR="immersive-ar",n))(Tm||{});function k_(n,e){if(!n)return;const t=(e==null?void 0:e.new_scripts)??kt.Current.new_scripts;t.includes(n)||t.push(n)}const rn=class{constructor(e){h(this,"name");h(this,"alias");h(this,"isManagedExternally",!1);h(this,"isPaused",!1);h(this,"runInBackground",!1);h(this,"targetFrameRate");h(this,"hash");h(this,"domElement");h(this,"_resolutionScaleFactor",1);h(this,"_boundingClientRectFrame",-1);h(this,"_boundingClientRect",null);h(this,"_domX");h(this,"_domY");h(this,"xrSessionMode");h(this,"_xrFrame",null);h(this,"_currentFrameEvent",-1);h(this,"scene");h(this,"renderer");h(this,"composer",null);h(this,"scripts",[]);h(this,"scripts_pausedChanged",[]);h(this,"scripts_earlyUpdate",[]);h(this,"scripts_update",[]);h(this,"scripts_lateUpdate",[]);h(this,"scripts_onBeforeRender",[]);h(this,"scripts_onAfterRender",[]);h(this,"scripts_WithCorroutines",[]);h(this,"coroutines",{});h(this,"mainCameraComponent");h(this,"post_setup_callbacks",[]);h(this,"pre_update_callbacks",[]);h(this,"pre_render_callbacks",[]);h(this,"post_render_callbacks",[]);h(this,"new_scripts",[]);h(this,"new_script_start",[]);h(this,"new_scripts_pre_setup_callbacks",[]);h(this,"new_scripts_post_setup_callbacks",[]);h(this,"application");h(this,"time");h(this,"input");h(this,"physics");h(this,"connection");h(this,"assets");h(this,"mainLight",null);h(this,"sceneLighting");h(this,"addressables");h(this,"lightmaps");h(this,"players");h(this,"_sizeChanged",!1);h(this,"_isCreated",!1);h(this,"_isCreating",!1);h(this,"_isVisible",!1);h(this,"_stats",vq?eq():null);h(this,"_intersectionObserver",null);h(this,"_disposeCallbacks",[]);h(this,"_cameraStack",[]);h(this,"_onBeforeRenderListeners",new Map);h(this,"_onAfterRenderListeners",new Map);h(this,"_requireDepthTexture",!1);h(this,"_requireColorTexture",!1);h(this,"_renderTarget");h(this,"_isRendering",!1);h(this,"_accumulatedTime",0);h(this,"_framerateClock",new l_);h(this,"_dispatchReadyAfterFrame",!1);h(this,"_lastTimestamp",0);h(this,"_wasPaused",!1);this.name=(e==null?void 0:e.name)||"",this.alias=e==null?void 0:e.alias,this.domElement=(e==null?void 0:e.domElement)||document.body,this.hash=e==null?void 0:e.hash,e!=null&&e.renderer?(this.renderer=e.renderer,this.isManagedExternally=!0):this.createRenderer(),this.scene=new pr,Li.register(this),this.application=new zF(this),this.time=new LO,this.input=new EO(this),this.physics=new OO(this),this.connection=new BL(this),this.assets=new KL,this.sceneLighting=new UF(this),this.addressables=new LF(this),this.lightmaps=new mq(this),this.players=new QF(this);const t=()=>this._sizeChanged=!0;window.addEventListener("resize",t),this._disposeCallbacks.push(()=>window.removeEventListener("resize",t));const i=new ResizeObserver(s=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()})}static get DefaultTargetFrameRate(){return rn._defaultTargetFramerate.value}static set DefaultTargetFrameRate(e){rn._defaultTargetFramerate.value=e}get version(){return C_}static get Current(){return Li.Current}static set Current(e){Li.Current=e}appendHTMLElement(e){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(e):this.domElement.appendChild(e)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(e){if(e!==this._resolutionScaleFactor&&typeof e=="number"){if(e<=0){console.error("Invalid resolution scale factor",e);return}this._resolutionScaleFactor=e,this.updateSize()}}calculateBoundingClientRect(){if(this.isInAR){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var e;return((e=this.renderer.xr)==null?void 0:e.isPresenting)||!1}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get xrSession(){var e;return(e=this.renderer.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get arOverlayElement(){const e=this.domElement;return typeof e.getAROverlayContainer=="function"?e.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this.mainCameraComponent){const e=this.mainCameraComponent;return e.cam||e.buildCamera(),e.cam}return null}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createRenderer(){var i,s,r;(i=this.renderer)==null||i.dispose();const e={antialias:!0},t=(r=(s=this.domElement)==null?void 0:s.shadowRoot)==null?void 0:r.querySelector("canvas");t&&(e.canvas=t),this.renderer=new zf(e),this.renderer.toneMappingExposure=1,this.renderer.toneMapping=Qs,this.renderer.setClearColor(new ye("lightgrey"),0),this.renderer.antialias=!0,this.renderer.alpha=!1,this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=HE,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputEncoding=yt,this.renderer.physicallyCorrectLights=!0}internalOnUpdateVisible(){var e,t;(e=this._intersectionObserver)==null||e.disconnect(),(t=this._intersectionObserver)==null||t.observe(this.domElement)}updateSize(){var e,t,i;if(!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const s=this.resolutionScaleFactor,r=this.domWidth*s,o=this.domHeight*s,a=this.mainCamera;this.updateAspect(a),this.renderer.setSize(r,o),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((t=this.composer.setSize)==null||t.call(this.composer,r,o),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((i=this.composer.setPixelRatio)==null||i.call(this.composer,window.devicePixelRatio)))}}updateAspect(e,t,i){if(!e)return;t===void 0&&(t=this.domWidth),i===void 0&&(i=this.domHeight);const s=e.aspect;e.aspect=t/i,s!==e.aspect&&e.updateProjectionMatrix()}async onCreate(e,t){try{return this._isCreating=!0,await this.internalOnCreate(e,t)}finally{this._isCreating=!1}}clear(){var e,t,i,s;Li.dispatchCallback(zs.ContextClearing,this),Gl(this.scene,!0,!0),this.scene=new pr,(e=this.addressables)==null||e.dispose(),(t=this.lightmaps)==null||t.clear(),(s=(i=this.physics)==null?void 0:i.engine)==null||s.clearCaches(),this.isManagedExternally||(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),Li.dispatchCallback(zs.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var e,t;this.clear(),(e=this.renderer)==null||e.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear()),this.isManagedExternally||this.renderer.dispose(),this.scene=null,this.renderer=null,this.input.dispose();for(const i of this._disposeCallbacks)try{i()}catch(s){console.error("Error in on dispose callback:",s,i)}(t=this.domElement)!=null&&t.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Li.dispatchCallback(zs.ContextDestroyed,this),Li.unregister(this)}registerCoroutineUpdate(e,t,i){return this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:e,main:t}),t}unregisterCoroutineUpdate(e,t){if(!this.coroutines[t])return;const i=this.coroutines[t].findIndex(s=>s.main===e);i>=0&&this.coroutines[t].splice(i,1)}stopAllCoroutinesFrom(e){for(const t in this.coroutines){const i=this.coroutines[t];for(let s=i.length-1;s>=0;s--)i[s].comp===e&&i.splice(s,1)}}setCurrentCamera(e){var s;if(!e)return;if(e.cam||e.buildCamera(),!e.cam){console.warn("Camera component is missing camera",e);return}const t=this._cameraStack.indexOf(e);t>=0&&this._cameraStack.splice(t,1),this._cameraStack.push(e),this.mainCameraComponent=e;const i=e.cam;i.isPerspectiveCamera&&this.updateAspect(i),(s=this.mainCameraComponent)==null||s.applyClearFlagsIfIsActiveCamera()}removeCamera(e){if(!e)return;const t=this._cameraStack.indexOf(e);if(t>=0&&this._cameraStack.splice(t,1),this.mainCameraComponent===e&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(e,t){var i;this._onBeforeRenderListeners.has(e.uuid)||(this._onBeforeRenderListeners.set(e.uuid,[]),e.onBeforeRender=this._createRenderCallbackWrapper(e,this._onBeforeRenderListeners)),(i=this._onBeforeRenderListeners.get(e.uuid))==null||i.push(t)}removeBeforeRenderListener(e,t){if(this._onBeforeRenderListeners.has(e.uuid)){const i=this._onBeforeRenderListeners.get(e.uuid),s=i.indexOf(t);s>=0&&i.splice(s,1)}}addAfterRenderListener(e,t){var i;this._onAfterRenderListeners.has(e.uuid)||(this._onAfterRenderListeners.set(e.uuid,[]),e.onAfterRender=this._createRenderCallbackWrapper(e,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(e.uuid))==null||i.push(t)}removeAfterRenderListener(e,t){if(this._onAfterRenderListeners.has(e.uuid)){const i=this._onAfterRenderListeners.get(e.uuid),s=i.indexOf(t);s>=0&&i.splice(s,1)}}_createRenderCallbackWrapper(e,t){return(i,s,r,o,a,l)=>{const c=t.get(e.uuid);if(c)for(let u=0;u<c.length;u++){const d=c[u];d(i,s,r,o,a,l)}}}get isRendering(){return this._isRendering}setRequireDepth(e){this._requireDepthTexture=e}setRequireColor(e){this._requireColorTexture=e}get depthTexture(){var e;return((e=this._renderTarget)==null?void 0:e.depthTexture)||null}get opaqueColorTexture(){var e;return((e=this._renderTarget)==null?void 0:e.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const e=getComputedStyle(this.domElement);return e.visibility!=="hidden"&&e.display!=="none"&&e.opacity!=="0"}async internalOnCreate(e,t){var r,o;this.clear(),(r=this.renderer)==null||r.setAnimationLoop(null),await tA(1),rn.Current=this,await Li.dispatchCallback(zs.ContextCreationStart,this);let i=!0,s;try{rn.Current=this,e&&(s=await e(this,t))}catch(a){console.error(a),i=!1}if(!i)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return wd&&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),rn.Current=this,rn.Current=this;for(let a=0;a<this.new_scripts.length;a++){const l=this.new_scripts[a];if(l.gameObject!==void 0&&l.gameObject!==null){l.gameObject.userData===void 0&&(l.gameObject.userData={}),l.gameObject.userData.components===void 0&&(l.gameObject.userData.components=[]);const c=l.gameObject.userData.components;c.includes(l)||c.push(l)}}if(this.post_setup_callbacks)for(let a=0;a<this.post_setup_callbacks.length;a++)rn.Current=this,await this.post_setup_callbacks[a](this);if(!this.mainCamera){rn.Current=this;let a=null;xu(this.scene,l=>{const c=l;if(c!=null&&c.isCamera){if(Vg(c.gameObject),!c.activeAndEnabled)return;if(c.tag==="MainCamera")return a=c,!0;a=c}}),a?this.setCurrentCamera(a):!Li.dispatchCallback(zs.MissingCamera,this)&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(rn.Current=this,sb(this),!this.isManagedExternally&&this.composer&&this.mainCamera){const a=new D_(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(a),this.composer.setSize(this.domWidth,this.domHeight)}return this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),(o=this.domElement.shadowRoot)==null||o.appendChild(this._stats.dom)),wd&&$0(this.scene,!0),this.targetFrameRate===void 0?(wd&&console.warn("No target framerate set, using default",rn.DefaultTargetFrameRate),this.targetFrameRate=rn._defaultTargetFramerate):wd&&console.log("Target framerate set to",this.targetFrameRate),this._isCreating=!1,this.restartRenderLoop(),this._dispatchReadyAfterFrame=!0,Li.dispatchCallback(zs.ContextCreated,this,{files:s})}restartRenderLoop(){if(!this.renderer)return console.error("Can not start render loop without renderer"),!1;if(this._isCreating)return console.warn("Can not start render loop while creating context"),!1;const e=this.render.bind(this);return this.renderer.setAnimationLoop(e),!0}render(e,t){if(Ss()||wd||ZW())try{this.internalRender(e,t)}catch(i){(Ss()||wd)&&i instanceof Error&&yn("Exception during render-loop.<br/>See console for details.",qo.Error),console.error(i),console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null),this.domElement.dispatchEvent(new CustomEvent("error",{detail:i}))}else this.internalRender(e,t)}internalRender(e,t){var i,s;if(this._xrFrame=t,this._currentFrameEvent=-1,this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=e),this._accumulatedTime+=(e-this._lastTimestamp)/1e3,this._lastTimestamp=e;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return;this._accumulatedTime=0}if((i=this._stats)==null||i.begin(),rn.Current=this,!this.onHandlePaused()){for(rn.Current=this,this.time.update(),bq&&console.log("FPS",this.time.smoothedFps.toFixed(0)),sb(this),f0(this.scene),hF(this);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_callbacks)for(const r in this.pre_update_callbacks)this.pre_update_callbacks[r]();this._currentFrameEvent=0;for(let r=0;r<this.scripts_earlyUpdate.length;r++){const o=this.scripts_earlyUpdate[r];o.activeAndEnabled&&o.earlyUpdate!==void 0&&(rn.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),!this.onHandlePaused()){this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const o=this.scripts_update[r];o.activeAndEnabled&&o.update!==void 0&&(rn.Current=this,o.update())}if(this.executeCoroutines(1),!this.onHandlePaused()){this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const o=this.scripts_lateUpdate[r];o.activeAndEnabled&&o.lateUpdate!==void 0&&(rn.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),!this.onHandlePaused()){if(this.physics.engine){const o=this.time.deltaTime/1;for(let a=0;a<1;a++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(o),this._currentFrameEvent=10,this.executeCoroutines(10);this.physics.engine.postStep()}if(!this.onHandlePaused()){if(this.isVisibleToUser){this._currentFrameEvent=3;for(let r=0;r<this.scripts_onBeforeRender.length;r++){const o=this.scripts_onBeforeRender[r];o.activeAndEnabled&&o.onBeforeRender!==void 0&&(rn.Current=this,o.onBeforeRender(t))}if(this.executeCoroutines(3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r]();this.isManagedExternally||(tj(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4);for(let r=0;r<this.scripts_onAfterRender.length;r++){const o=this.scripts_onAfterRender[r];o.activeAndEnabled&&o.onAfterRender!==void 0&&(rn.Current=this,o.onAfterRender())}if(this.executeCoroutines(4),this.post_render_callbacks)for(const r in this.post_render_callbacks)this.post_render_callbacks[r]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),(s=this._stats)==null||s.end(),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")))}}}}}}renderNow(e){return!e&&(e=this.mainCamera,!e)?!1:(this._isRendering=!0,this.renderRequiredTextures(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):e&&this.renderer.render(this.scene,e),this._isRendering=!1,!0)}onHandlePaused(){const e=this.evaluatePaused();if(this._wasPaused!==e){yq&&console.log("Paused?",e,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(rn.Current=this,i.onPausedChanged(e,this._wasPaused))}}return this._wasPaused=e,e}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new si(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new Yb(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Gt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Yt,this._renderTarget.texture.magFilter=Yt,this._renderTarget.texture.format=Ti)}const e=this._renderTarget;e.texture&&(e.texture.encoding=this.renderer.outputEncoding);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(e){if(this.coroutines[e]){const i=this.coroutines[e];for(let s=0;s<i.length;s++)try{const r=i[s];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){_q&&console.log("Removing coroutine",r.comp,r.comp.enabled),i.splice(s,1),--s;continue}const a=r.chained;if(a&&a.length>0){const d=a[a.length-1].next();if(d.done&&a.pop(),t(d)&&(r.chained||(r.chained=[]),r.chained.push(d.value)),!d.done)continue}const l=r.main.next();if(l.done===!0){i.splice(s,1),--s;continue}const c=l.value;if(t(c)){if(c.next().done)continue;r.chained||(r.chained=[]),r.chained.push(c)}}catch(r){console.error(r)}}function t(i){return!!(i&&i.next&&i.return)}}};let kt=rn;h(kt,"_defaultTargetFramerate",{value:60});const _c=oe("debugaroverlay"),Kh="ar",XR="quit-ar";class Cq{constructor(){h(this,"arContainer",null);h(this,"closeARCallback");h(this,"currentSession",null);h(this,"registeredCloseEventElements",[]);h(this,"_createdAROnlyElements",[]);h(this,"_reparentedObjects",[]);this.closeARCallback=this.onRequestedEndAR.bind(this)}get ARContainer(){return this.arContainer}requestEndAR(){this.onRequestedEndAR()}onBegin(e,t,i){this.currentSession=i,this.arContainer=t,e.domElement.shadowRoot.querySelectorAll(`.${Kh}`).forEach(o=>{var a;o&&o!==this.arContainer&&(this._reparentedObjects.push({el:o,previousParent:o.parentElement}),(a=this.arContainer)==null||a.appendChild(o))});const r=t.getElementsByClassName(XR);if(!r||r.length<=0)console.warn(`Missing quit AR elements, creating fallback X button. Use class name '${XR}' to override.`),this.createFallbackCloseARButton(this.arContainer);else for(let o=0;o<r.length;o++){const a=r[o];a&&(a.addEventListener("click",this.closeARCallback),this.registeredCloseEventElements.push(a))}}onEnd(e){var t;for(const i of this._createdAROnlyElements)i.remove&&i.remove();for(const i of this._reparentedObjects){const s=i.el;(t=i.previousParent)==null||t.appendChild(s)}this._reparentedObjects.length=0,zE()&&setTimeout(()=>{var o;const i=e.renderer.domElement;i&&((o=e.domElement.shadowRoot)==null||o.prepend(i));const s=document.querySelectorAll("*");for(var r=0;r<s.length;r++){const a=s[r];a&&a._displayChanged!==void 0&&a._displayWas!==void 0&&(a.style.display=a._displayWas)}},10)}findOrCreateARContainer(e){if(_c&&console.log("findOrCreateARContainer"),e.classList.contains(Kh))return _c&&console.log("Found overlay container in needle-engine element"),e;if(e.shadowRoot){const s=e.shadowRoot.querySelector(`.${Kh}`);if(s)return _c&&console.log("Found overlay container in needle-engine element"),s}const t=document.getElementsByClassName(Kh);if(t&&t.length>0)return _c&&console.log("Found overlay container in document"),t[0];_c&&console.log("No overlay container found in document - generating new ony");const i=document.createElement("div");return i.classList.add(Kh),i.style.cssText=`
|
|
3846
3846
|
position: fixed;
|
|
3847
3847
|
top: 0;
|
|
3848
3848
|
left: 0;
|
|
@@ -3853,7 +3853,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
3853
3853
|
z-index: 9999;
|
|
3854
3854
|
pointer-events: none;
|
|
3855
3855
|
// background: rgba(0,0,0,1);
|
|
3856
|
-
`,_c&&this.createFallbackCloseARButton(e),this.appendElement(i,e)}onRequestedEndAR(){if(this.currentSession){this.currentSession.end(),this.currentSession=null;for(const e of this.registeredCloseEventElements)e.removeEventListener("click",this.closeARCallback);this.registeredCloseEventElements.length=0}}createFallbackCloseARButton(e){const t=document.createElement("slot");t.setAttribute("name","quit-ar"),this.appendElement(t,e),_c&&t.addEventListener("click",()=>console.log("Clicked fallback close button")),t.addEventListener("click",this.closeARCallback),this._createdAROnlyElements.push(t),t.style.pointerEvents="auto";var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("quit-ar-button"),i.setAttribute("width","38px"),i.setAttribute("height","38px"),t.appendChild(i);var s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),s.setAttribute("stroke","#ddd"),s.setAttribute("stroke-width","3px"),i.appendChild(s),_c&&console.log("Created fallback close button",i,e)}appendElement(e,t){return t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}class Z extends Ie{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return J1(t)}static setActive(t,i,s=!0){t&&(Hg(t,i),f0(t),i&&s&&hF(kt.Current,t))}static isActiveSelf(t){return Zf(t)}static isActiveInHierarchy(t){return nF(t)}static markAsInstancedRendered(t,i){sF(t,i)}static isUsingInstancing(t){return P_(t)}static foreachComponent(t,i,s=!0){return xu(t,i,s)}static instantiateSynced(t,i){return t?j1(t,i):null}static instantiate(t,i=null){return MA(t,i)}static destroySynced(t,i,s=!0){if(!t)return;const r=t;i=i??kt.Current,S_(r,i.connection,s)}static destroy(t,i=!0,s=!0){return Gl(t,i,s)}static add(t,i,s){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}s||(s=kt.Current),i.add(t),Hg(t,!0),f0(t),s?Z.foreachComponent(t,r=>{$1(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Hg(t,!1),f0(t),Z.foreachComponent(t,s=>{$W(s)},!0))}static invokeOnChildren(t,i,...s){this.invoke(t,i,!0,s)}static invoke(t,i,s=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},s)}static addNewComponent(t,i,s=!0){const r=new i;return Bu(t,r,s),r}static addComponent(t,i){return this.moveComponent(t,i)}static moveComponent(t,i){return X1(t,i)}static removeComponent(t){return q1(t.gameObject,t),t}static getOrAddComponent(t,i){return I_(t,i)}static getComponent(t,i){return t===null?null:Jf(t,i)}static getComponents(t,i,s=null){return t===null?s??[]:CA(t,i,s)}static findByGuid(t,i){return IA(t,i)}static findObjectOfType(t,i,s=!0){return qL(t,i??kt.Current,s)}static findObjectsOfType(t,i){const s=[];return XL(t,s,i),s}static getComponentInChildren(t,i){return SA(t,i)}static getComponentsInChildren(t,i,s=null){return EA(t,i,s??void 0)}static getComponentInParent(t,i){return Im(t,i)}static getComponentsInParent(t,i,s=null){return M_(t,i,s)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var s;const i=(s=t==null?void 0:t.userData)==null?void 0:s.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ji;let ch=(Ji=class{constructor(){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,"_worldPosition");h(this,"_worldQuaternion");h(this,"_worldEuler");h(this,"_worldRotation");h(this,"_eventListeners",new Map);this.__internalNewInstanceCreated()}get isComponent(){return!0}get context(){return this.__context??kt.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[Dl];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[Dl]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Nr.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Nr.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(Ss()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,(e=this.destroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this})),WL(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){Ss()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return this._worldPosition||(this._worldPosition=new S),wt(this.gameObject,this._worldPosition),this._worldPosition}set worldPosition(e){hn(this.gameObject,e)}setWorldPosition(e,t,i){Ji._worldPositionBuffer.set(e,t,i),this.worldPosition=Ji._worldPositionBuffer}get worldQuaternion(){return this._worldQuaternion||(this._worldQuaternion=new xe),Ln(this.gameObject,this._worldQuaternion)}set worldQuaternion(e){gr(this.gameObject,e)}setWorldQuaternion(e,t,i,s){Ji._worldQuaternionBuffer.set(e,t,i,s),this.worldQuaternion=Ji._worldQuaternionBuffer}get worldEuler(){return this._worldEuler||(this._worldEuler=new xn),this._worldEuler.setFromQuaternion(this.worldQuaternion),this._worldEuler}set worldEuler(e){var t;this._worldQuaternion||(this._worldQuaternion=new xe),(t=this._worldQuaternion)==null||t.setFromEuler(e),this.worldQuaternion=this._worldQuaternion}get worldRotation(){const e=this.worldEuler;this._worldRotation||(this._worldRotation=new S);const t=this._worldRotation;return t.set(e.x,e.y,e.z),t.x=$e.toDegrees(t.x),t.y=$e.toDegrees(t.y),t.z=$e.toDegrees(t.z),t}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,s=!0){s&&(e=$e.toRadians(e),t=$e.toRadians(t),i=$e.toRadians(i)),Ji._worldEulerBuffer.set(e,t,i),Ji._worldQuaternionBuffer.setFromEuler(Ji._worldEulerBuffer),this.worldQuaternion=Ji._worldQuaternionBuffer}get forward(){return Ji._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ji._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ji._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ji,"_worldPositionBuffer",new S),h(Ji,"_worldQuaternionBuffer",new xe),h(Ji,"_worldEulerBuffer",new xn),h(Ji,"_tempQuaternionBuffer2",new xe),h(Ji,"_forward",new S),h(Ji,"_right",new S),h(Ji,"_up",new S),Ji);class Ce extends ch{}const Sq=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ce,Component:ch,GameObject:Z},Symbol.toStringTag,{value:"Module"})),Eq='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',Iq=new Blob([Eq],{type:"image/svg+xml;charset=utf-8"}),Mq=URL.createObjectURL(Iq),HF=Mq,Tl=oe("debuglicense");let Tf="basic";Tl&&console.log("License Type: "+Tf);function hf(){switch(Tf){case"pro":case"enterprise":return!0}return!1}function VF(){switch(Tf){case"indie":return!0}return!1}function PA(){return hf()||VF()}Li.registerCallback(zs.ContextRegistered,n=>{Pq(n.context),Oq()});let WF;async function Tq(){if(Tf==="basic")try{const e=await fetch("https://engine.needle.tools/licensing/check");if(Tl){const t=await e.text();console.log('"'+t+`"
|
|
3856
|
+
`,_c&&this.createFallbackCloseARButton(e),this.appendElement(i,e)}onRequestedEndAR(){if(this.currentSession){this.currentSession.end(),this.currentSession=null;for(const e of this.registeredCloseEventElements)e.removeEventListener("click",this.closeARCallback);this.registeredCloseEventElements.length=0}}createFallbackCloseARButton(e){const t=document.createElement("slot");t.setAttribute("name","quit-ar"),this.appendElement(t,e),_c&&t.addEventListener("click",()=>console.log("Clicked fallback close button")),t.addEventListener("click",this.closeARCallback),this._createdAROnlyElements.push(t),t.style.pointerEvents="auto";var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("quit-ar-button"),i.setAttribute("width","38px"),i.setAttribute("height","38px"),t.appendChild(i);var s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),s.setAttribute("stroke","#ddd"),s.setAttribute("stroke-width","3px"),i.appendChild(s),_c&&console.log("Created fallback close button",i,e)}appendElement(e,t){return t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}class Z extends Ie{constructor(){super(...arguments);h(this,"guid")}static isDestroyed(t){return J1(t)}static setActive(t,i,s=!0){t&&(Hg(t,i),f0(t),i&&s&&hF(kt.Current,t))}static isActiveSelf(t){return Zf(t)}static isActiveInHierarchy(t){return nF(t)}static markAsInstancedRendered(t,i){sF(t,i)}static isUsingInstancing(t){return P_(t)}static foreachComponent(t,i,s=!0){return xu(t,i,s)}static instantiateSynced(t,i){return t?j1(t,i):null}static instantiate(t,i=null){return MA(t,i)}static destroySynced(t,i,s=!0){if(!t)return;const r=t;i=i??kt.Current,S_(r,i.connection,s)}static destroy(t,i=!0,s=!0){return Gl(t,i,s)}static add(t,i,s){if(!(!t||!i)){if(t===i){console.warn("Can not add object to self",t);return}s||(s=kt.Current),i.add(t),Hg(t,!0),f0(t),s?Z.foreachComponent(t,r=>{$1(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(t){var i;t&&((i=t.parent)==null||i.remove(t),Hg(t,!1),f0(t),Z.foreachComponent(t,s=>{$W(s)},!0))}static invokeOnChildren(t,i,...s){this.invoke(t,i,!0,s)}static invoke(t,i,s=!1,...r){t&&this.foreachComponent(t,o=>{const a=o[i];a&&typeof a=="function"&&(a==null||a.call(o,...r))},s)}static addNewComponent(t,i,s=!0){const r=new i;return Bu(t,r,s),r}static addComponent(t,i){return this.moveComponent(t,i)}static moveComponent(t,i){return X1(t,i)}static removeComponent(t){return q1(t.gameObject,t),t}static getOrAddComponent(t,i){return I_(t,i)}static getComponent(t,i){return t===null?null:Jf(t,i)}static getComponents(t,i,s=null){return t===null?s??[]:CA(t,i,s)}static findByGuid(t,i){return IA(t,i)}static findObjectOfType(t,i,s=!0){return qL(t,i??kt.Current,s)}static findObjectsOfType(t,i){const s=[];return XL(t,s,i),s}static getComponentInChildren(t,i){return SA(t,i)}static getComponentsInChildren(t,i,s=null){return EA(t,i,s??void 0)}static getComponentInParent(t,i){return Im(t,i)}static getComponentsInParent(t,i,s=null){return M_(t,i,s)}static getAllComponents(t){var r;return[...(r=t.userData)==null?void 0:r.components]}static*iterateComponents(t){var s;const i=(s=t==null?void 0:t.userData)==null?void 0:s.components;if(i&&Array.isArray(i))for(let r=0;r<i.length;r++)yield i[r]}}var Ji;let ch=(Ji=class{constructor(){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,"_worldPosition");h(this,"_worldQuaternion");h(this,"_worldEuler");h(this,"_worldRotation");h(this,"_eventListeners",new Map);this.__internalNewInstanceCreated()}get isComponent(){return!0}get context(){return this.__context??kt.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){var e,t;return(t=(e=this.gameObject)==null?void 0:e.userData)==null?void 0:t.layer}get name(){var e,t;return(e=this.gameObject)!=null&&e.name?this.gameObject.name:(t=this.gameObject)==null?void 0:t.userData.name}set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){var e;return(e=this.gameObject)==null?void 0:e.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){var e;return(e=this.gameObject)==null?void 0:e.userData.static}get hideFlags(){var e;return(e=this.gameObject)==null?void 0:e.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[Dl];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[Dl]=e)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=Nr.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=Nr.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(Ss()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var e;this.__destroyed||(this.__destroyed=!0,(e=this.destroy)==null||e.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this})),WL(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){Ss()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return this._worldPosition||(this._worldPosition=new S),wt(this.gameObject,this._worldPosition),this._worldPosition}set worldPosition(e){hn(this.gameObject,e)}setWorldPosition(e,t,i){Ji._worldPositionBuffer.set(e,t,i),this.worldPosition=Ji._worldPositionBuffer}get worldQuaternion(){return this._worldQuaternion||(this._worldQuaternion=new xe),Ln(this.gameObject,this._worldQuaternion)}set worldQuaternion(e){gr(this.gameObject,e)}setWorldQuaternion(e,t,i,s){Ji._worldQuaternionBuffer.set(e,t,i,s),this.worldQuaternion=Ji._worldQuaternionBuffer}get worldEuler(){return this._worldEuler||(this._worldEuler=new xn),this._worldEuler.setFromQuaternion(this.worldQuaternion),this._worldEuler}set worldEuler(e){var t;this._worldQuaternion||(this._worldQuaternion=new xe),(t=this._worldQuaternion)==null||t.setFromEuler(e),this.worldQuaternion=this._worldQuaternion}get worldRotation(){const e=this.worldEuler;this._worldRotation||(this._worldRotation=new S);const t=this._worldRotation;return t.set(e.x,e.y,e.z),t.x=$e.toDegrees(t.x),t.y=$e.toDegrees(t.y),t.z=$e.toDegrees(t.z),t}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,s=!0){s&&(e=$e.toRadians(e),t=$e.toRadians(t),i=$e.toRadians(i)),Ji._worldEulerBuffer.set(e,t,i),Ji._worldQuaternionBuffer.setFromEuler(Ji._worldEulerBuffer),this.worldQuaternion=Ji._worldQuaternionBuffer}get forward(){return Ji._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Ji._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Ji._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}},h(Ji,"_worldPositionBuffer",new S),h(Ji,"_worldQuaternionBuffer",new xe),h(Ji,"_worldEulerBuffer",new xn),h(Ji,"_tempQuaternionBuffer2",new xe),h(Ji,"_forward",new S),h(Ji,"_right",new S),h(Ji,"_up",new S),Ji);class Ce extends ch{}const Sq=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Ce,Component:ch,GameObject:Z},Symbol.toStringTag,{value:"Module"})),Eq='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',Iq=new Blob([Eq],{type:"image/svg+xml;charset=utf-8"}),Mq=URL.createObjectURL(Iq),HF=Mq,Tl=oe("debuglicense");let Tf="basic";Tl&&console.log("License Type: "+Tf);function hf(){switch(Tf){case"pro":case"enterprise":return!0}return!1}function VF(){switch(Tf){case"indie":return!0}return!1}function PA(){return hf()||VF()}Li.registerCallback(zs.ContextRegistered,n=>{Pq(n.context),Oq()});let WF;async function Tq(){if(Tf==="basic")try{const e=await fetch("https://engine.needle.tools/licensing/check");if(Tl){const t=await e.text();console.log('"'+t+`"
|
|
3857
3857
|
`,e)}e.status===200&&(Tf="pro")}catch(n){Tl&&console.error("License check failed",n)}}WF=Tq();async function Pq(n){try{if(PA()!==!0)return kw(n)}catch(e){return Tl&&console.log("License check failed",e),kw(n)}Tl&&kw(n)}const jF="needle-license-element",jS=5e3,qS=200;async function kw(n){await WF,!PA()&&(Bq(),n.domElement.addEventListener("ready",()=>{setTimeout(()=>{Rq(n)},1e3)}))}function Rq(n){const e=Dq(),t=kq(),i=setInterval(()=>{if(!e)return;const l=n.domElement.shadowRoot||n.domElement;e.parentNode!==l&&(l.appendChild(e),t&&l.appendChild(t))},100);let s=`<img class="logo" src="${HF}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`;const r=document.createElement("div");r.innerHTML=s,r.classList.add("logo"),e.appendChild(r);const o=document.createElement("div");o.classList.add("text"),e.appendChild(o),e.title="Needle Engine",PA()||(e.title+=" No active license found - Non Commercial Use"),e.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")});const a=jS+qS;setTimeout(()=>{clearInterval(i),e==null||e.remove(),t==null||t.remove()},a)}let YR=0;async function Bq(n){const e=Date.now();if(e-YR<2e3)return;YR=e;const i=`
|
|
3858
3858
|
position: relative;
|
|
3859
3859
|
display: block;
|