@needle-tools/engine 3.2.1-alpha → 3.2.2-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.
@@ -47,14 +47,16 @@ export class SceneSwitcher extends Behaviour {
47
47
  private _currentScene: AssetReference | undefined = undefined;
48
48
  private _engineElementOverserver: MutationObserver | undefined = undefined;
49
49
 
50
- start() {
51
- if (!this.tryLoadFromQueryParam()) {
50
+ async start() {
51
+ if (this._currentIndex === -1 && !await this.tryLoadFromQueryParam()) {
52
52
  const value = this.context.domElement.getAttribute(ENGINE_ELEMENT_SCENE_ATTRIBUTE_NAME);
53
53
  // let locked = this.lock;
54
54
  try {
55
55
  // this.lock = false;
56
- if (value === null || !this.trySelectSceneFromValue(value))
57
- this.select(0);
56
+ if (value === null || !await this.trySelectSceneFromValue(value)) {
57
+ if (this._currentIndex === -1)
58
+ this.select(0);
59
+ }
58
60
  }
59
61
  finally {
60
62
  // this.lock = locked;
@@ -202,10 +204,10 @@ export class SceneSwitcher extends Behaviour {
202
204
  }
203
205
 
204
206
  private tryLoadFromQueryParam() {
205
- if (!this.queryParameterName?.length) return false;
207
+ if (!this.queryParameterName?.length) return couldNotLoadScenePromise;
206
208
  // try restore the scene from the url
207
209
  const value = getParam(this.queryParameterName);
208
- if (typeof value === "boolean") return false;
210
+ if (typeof value === "boolean") return couldNotLoadScenePromise;
209
211
  return this.trySelectSceneFromValue(value);
210
212
  }
211
213
 
@@ -233,7 +235,7 @@ export class SceneSwitcher extends Behaviour {
233
235
  }
234
236
  }
235
237
 
236
- if (isLocalNetwork()) console.warn("Unknown scene value or index: \"" + value + "\"", this)
238
+ if (isLocalNetwork()) console.warn("Can not find scene: \"" + value + "\"", this)
237
239
 
238
240
  return couldNotLoadScenePromise;
239
241
  }