@needle-tools/engine 3.2.11-alpha → 3.2.12-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "3.2.11-alpha",
3
+ "version": "3.2.12-alpha",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "type": "module",
@@ -34,6 +34,7 @@ const debug = utils.getParam("debugSetup");
34
34
  const stats = utils.getParam("stats");
35
35
  const debugActive = utils.getParam("debugactive");
36
36
  const debugframerate = utils.getParam("debugframerate");
37
+ const debugCoroutine = utils.getParam("debugcoroutine");
37
38
 
38
39
  // this is where functions that setup unity scenes will be pushed into
39
40
  // those will be accessed from our custom html element to load them into their context
@@ -859,6 +860,7 @@ export class Context implements IContext {
859
860
  // TODO we might want to keep coroutines playing even if the component is disabled or inactive
860
861
  const remove = !evt.comp || evt.comp.destroyed || !evt.main || evt.comp["enabled"] === false;
861
862
  if (remove) {
863
+ if (debugCoroutine) console.log("Removing coroutine", evt.comp, evt.comp["enabled"])
862
864
  evts.splice(i, 1);
863
865
  --i;
864
866
  continue;
@@ -150,7 +150,7 @@ export function processNewScripts(context: IContext) {
150
150
 
151
151
  export function processRemoveFromScene(script: IComponent) {
152
152
  if (!script) return;
153
- script.__internalDisable();
153
+ script.__internalDisable(true);
154
154
  removeScriptFromContext(script, script.context);
155
155
  }
156
156
 
@@ -123,9 +123,9 @@ export interface IComponent {
123
123
  /** @internal */
124
124
  __internalStart();
125
125
  /** @internal */
126
- __internalEnable();
126
+ __internalEnable(isAddingOrRemovingFromScene?: boolean);
127
127
  /** @internal */
128
- __internalDisable();
128
+ __internalDisable(isAddingOrRemovingFromScene?: boolean);
129
129
  /** @internal */
130
130
  __internalDestroy();
131
131
  /** @internal */
@@ -470,7 +470,7 @@ export class Component implements IComponent, EventTarget {
470
470
 
471
471
 
472
472
  /** @internal */
473
- __internalEnable(): boolean {
473
+ __internalEnable(isAddingToScene?: boolean): boolean {
474
474
  if (this.__destroyed) {
475
475
  if (isDevEnvironment()) {
476
476
  console.warn("[Needle Engine Dev] Trying to enable destroyed component");
@@ -481,7 +481,10 @@ export class Component implements IComponent, EventTarget {
481
481
  // But a user can change enable during awake
482
482
  if (!this.__didAwake) return false;
483
483
  if (this.__didEnable) {
484
- this.__isEnabled = true;
484
+ // We dont want to change the enable state if we are adding to scene
485
+ // But we want to change the state when e.g. a user changes the enable state during awake
486
+ if (isAddingToScene !== true)
487
+ this.__isEnabled = true;
485
488
  return false;
486
489
  }
487
490
  // console.trace("INTERNAL ENABLE");
@@ -492,12 +495,14 @@ export class Component implements IComponent, EventTarget {
492
495
  }
493
496
 
494
497
  /** @internal */
495
- __internalDisable() {
498
+ __internalDisable(isRemovingFromScene?: boolean) {
496
499
  // Don't change enable before awake
497
500
  // But a user can change enable during awake
498
501
  if (!this.__didAwake) return;
499
502
  if (!this.__didEnable) {
500
- this.__isEnabled = false;
503
+ // We dont want to change the enable state if we are removing from a scene
504
+ if (isRemovingFromScene !== true)
505
+ this.__isEnabled = false;
501
506
  return;
502
507
  }
503
508
  this.__didEnable = false;