@needle-tools/engine 3.5.7-alpha → 3.5.8-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.5.7-alpha",
3
+ "version": "3.5.8-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",
@@ -1,4 +1,9 @@
1
1
 
2
2
  //@ts-ignore
3
3
  import _logo from "./logo.svg"
4
- export const logoSVG = _logo;
4
+ let logoUrl = _logo;
5
+ // in next dev mode the logo is { src: string }
6
+ if (typeof logoUrl === "object") {
7
+ logoUrl = (logoUrl as any).src;
8
+ }
9
+ export const logoSVG: string = logoUrl;
@@ -197,7 +197,7 @@ export class AudioSource extends Behaviour {
197
197
  private onVisibilityChanged = () => {
198
198
  switch (document.visibilityState) {
199
199
  case "hidden":
200
- if (this.playInBackground === false) {
200
+ if (this.playInBackground === false || utils.isMobileDevice()) {
201
201
  this.wasPlaying = this.isPlaying;
202
202
  if (this.isPlaying) {
203
203
  this.pause();
@@ -663,6 +663,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
663
663
  }
664
664
  }
665
665
 
666
+ @serializable()
667
+ playOnAwake: boolean = true;
668
+
666
669
  @serializable(ColorOverLifetimeModule)
667
670
  readonly colorOverLifetime!: ColorOverLifetimeModule;
668
671
 
@@ -881,7 +884,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
881
884
  this.inheritVelocity.system = this;
882
885
  if (this._batchSystem)
883
886
  this._batchSystem.visible = true;
884
- this.play();
887
+ if (this.playOnAwake)
888
+ this.play();
889
+ this._isPlaying = this.playOnAwake;
885
890
  }
886
891
 
887
892
  onDisable() {
@@ -77,6 +77,10 @@ export class SceneSwitcher extends Behaviour {
77
77
 
78
78
  private _preloadScheduler?: PreLoadScheduler;
79
79
 
80
+ awake(): void {
81
+ if(debug) console.log("SceneSwitcher", this);
82
+ }
83
+
80
84
  async start() {
81
85
  if (this._currentIndex === -1 && !await this.tryLoadFromQueryParam()) {
82
86
  const value = this.context.domElement.getAttribute(ENGINE_ELEMENT_SCENE_ATTRIBUTE_NAME);
@@ -351,12 +355,12 @@ class PreLoadScheduler {
351
355
  maxConcurrent: number;
352
356
 
353
357
  private _isRunning: boolean = false;
354
- private _rooms: SceneSwitcher;
355
- private _roomTasks: LoadTask[] = [];
358
+ private _switcher: SceneSwitcher;
359
+ private _loadTasks: LoadTask[] = [];
356
360
  private _maxConcurrentLoads: number = 1;
357
361
 
358
362
  constructor(rooms: SceneSwitcher, ahead: number = 1, behind: number = 1, maxConcurrent: number = 2) {
359
- this._rooms = rooms;
363
+ this._switcher = rooms;
360
364
  this.maxLoadAhead = ahead;
361
365
  this.maxLoadBehind = behind;
362
366
  this.maxConcurrent = maxConcurrent;
@@ -369,7 +373,7 @@ class PreLoadScheduler {
369
373
  let lastRoom: number = -1;
370
374
  let searchDistance: number;
371
375
  let searchCall: number;
372
- const array = this._rooms.scenes;
376
+ const array = this._switcher.scenes;
373
377
  let interval = setInterval(() => {
374
378
  if (this.allLoaded()) {
375
379
  if (debug)
@@ -381,8 +385,8 @@ class PreLoadScheduler {
381
385
  return;
382
386
  }
383
387
  if (this.canLoadNewScene() === false) return;
384
- if (lastRoom !== this._rooms.currentIndex) {
385
- lastRoom = this._rooms.currentIndex;
388
+ if (lastRoom !== this._switcher.currentIndex) {
389
+ lastRoom = this._switcher.currentIndex;
386
390
  searchCall = 0;
387
391
  searchDistance = 0;
388
392
  }
@@ -396,7 +400,7 @@ class PreLoadScheduler {
396
400
  // if (roomIndex < 0) roomIndex = array.length + roomIndex;
397
401
  if (roomIndex < 0 || roomIndex >= array.length) return;
398
402
  const scene = array[roomIndex];
399
- new LoadTask(roomIndex, scene, this._roomTasks);
403
+ new LoadTask(roomIndex, scene, this._loadTasks);
400
404
  }, 200);
401
405
  }
402
406
 
@@ -405,12 +409,12 @@ class PreLoadScheduler {
405
409
  }
406
410
 
407
411
  canLoadNewScene(): boolean {
408
- return this._roomTasks.length < this._maxConcurrentLoads;
412
+ return this._loadTasks.length < this._maxConcurrentLoads;
409
413
  }
410
414
 
411
415
  allLoaded(): boolean {
412
- for (const room of this._rooms.scenes) {
413
- if (room.isLoaded() === false) return false;
416
+ for (const scene of this._switcher.scenes) {
417
+ if (scene?.isLoaded() === false) return false;
414
418
  }
415
419
  return true;
416
420
  }