@xviewer.js/core 1.0.5-alhpa.0 → 1.0.5-alhpa.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -4348,6 +4348,9 @@ function _getMipBlurMaterial(lodMax, width, height) {
4348
4348
  }
4349
4349
 
4350
4350
  class TaskManager {
4351
+ get isComplete() {
4352
+ return this._taskIndex >= this._tasks.length;
4353
+ }
4351
4354
  destroy() {
4352
4355
  this._tasks = [];
4353
4356
  this._taskIndex = 0;
@@ -4480,6 +4483,9 @@ class ResourceManager {
4480
4483
  }
4481
4484
  return settings;
4482
4485
  }
4486
+ get isComplete() {
4487
+ return this._loaded >= this._totalCount;
4488
+ }
4483
4489
  destroy() {
4484
4490
  this._loaders.clear();
4485
4491
  }
@@ -4504,6 +4510,7 @@ class ResourceManager {
4504
4510
  ...props,
4505
4511
  onProgress,
4506
4512
  onLoad: (asset)=>{
4513
+ this._loaded++;
4507
4514
  this._resources.set(url, asset);
4508
4515
  resolve(asset);
4509
4516
  },
@@ -4512,6 +4519,7 @@ class ResourceManager {
4512
4519
  reject(err);
4513
4520
  }
4514
4521
  });
4522
+ this._totalCount++;
4515
4523
  } else {
4516
4524
  reject("ResourceManager.loadAsset: missing loader for " + sel);
4517
4525
  }
@@ -4523,6 +4531,8 @@ class ResourceManager {
4523
4531
  constructor(viewer){
4524
4532
  this._loaders = new Map();
4525
4533
  this._resources = new Map();
4534
+ this._loaded = 0;
4535
+ this._totalCount = 0;
4526
4536
  this._viewer = viewer;
4527
4537
  }
4528
4538
  }
@@ -4737,9 +4747,9 @@ class Viewer extends EventEmitter {
4737
4747
  }
4738
4748
  }
4739
4749
  loop(dt) {
4740
- if (!this._loading) {
4750
+ if (this._resourceManager.isComplete) {
4741
4751
  this._taskManager.update();
4742
- if (!this._tasking) {
4752
+ if (this._taskManager.isComplete) {
4743
4753
  this._running = true;
4744
4754
  }
4745
4755
  }
@@ -5150,14 +5160,8 @@ class Viewer extends EventEmitter {
5150
5160
  this._renderer.sortObjects = sortObjects;
5151
5161
  this._targetFrameRate = targetFrameRate;
5152
5162
  this._windowSize = typeof resize === "function" ? resize : resize === ResizeMode.AUTO ? this._windowSize : null;
5153
- const complete = (set, cb)=>{
5154
- set();
5155
- cb && cb();
5156
- };
5157
- this._taskManager = new TaskManager(()=>complete(()=>this._tasking = false, tasker.onComplete), tasker.onProgress, tasker.onError);
5158
- this._taskManager.onStart = ()=>this._tasking = true;
5159
- this._loadingManager = new LoadingManager(()=>complete(()=>this._loading = false, loader.onComplete), loader.onProgress, loader.onError);
5160
- this._loadingManager.onStart = ()=>this._loading = true;
5163
+ this._taskManager = new TaskManager(tasker.onComplete, tasker.onProgress, tasker.onError);
5164
+ this._loadingManager = new LoadingManager(loader.onComplete, loader.onProgress, loader.onError);
5161
5165
  this._resourceManager = new ResourceManager(this);
5162
5166
  this._componentManager = new ComponentManager(this);
5163
5167
  this._resourceOptions = {