@inweb/viewer-visualize 27.1.0 → 27.1.2

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.
@@ -171,6 +171,11 @@
171
171
  cancel() {
172
172
  this.abortController.abort();
173
173
  }
174
+ yield() {
175
+ return new Promise((resolve) => {
176
+ setTimeout(resolve, 0);
177
+ });
178
+ }
174
179
  extractFileName(file) {
175
180
  const regex = /[^/\\?#:]+(?=\?|#|$)/;
176
181
  if (typeof file === "string")
@@ -3431,13 +3436,13 @@
3431
3436
 
3432
3437
  class RenderLoopComponent {
3433
3438
  constructor(viewer) {
3434
- this.animate = (time = 0) => {
3439
+ this.animate = (time) => {
3435
3440
  this.requestId = requestAnimationFrame(this.animate);
3436
3441
  this.viewer.render(time);
3437
3442
  this.viewer.emitEvent({ type: "animate", time });
3438
3443
  };
3439
3444
  this.viewer = viewer;
3440
- this.animate();
3445
+ this.requestId = requestAnimationFrame(this.animate);
3441
3446
  }
3442
3447
  dispose() {
3443
3448
  cancelAnimationFrame(this.requestId);
@@ -3837,8 +3842,8 @@
3837
3842
  this.viewer.models.push(modelImpl);
3838
3843
  this.viewer.syncOptions();
3839
3844
  this.viewer.syncOverlay();
3840
- this.viewer.update(true);
3841
3845
  this.viewer.emitEvent({ type: "databasechunk", data, file });
3846
+ this.viewer.update(true);
3842
3847
  return this;
3843
3848
  }
3844
3849
  }
@@ -3882,12 +3887,12 @@
3882
3887
  this.viewer.models.push(modelImpl);
3883
3888
  this.viewer.syncOptions();
3884
3889
  this.viewer.syncOverlay();
3885
- this.viewer.update(true);
3886
3890
  this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
3891
+ this.viewer.update(true);
3887
3892
  }
3888
3893
  else {
3889
- this.viewer.update();
3890
3894
  this.viewer.emitEvent({ type: "geometrychunk", data, file: model.file, model });
3895
+ this.viewer.update();
3891
3896
  }
3892
3897
  }
3893
3898
  return this;
@@ -3932,8 +3937,8 @@
3932
3937
  this.viewer.models.push(modelImpl);
3933
3938
  this.viewer.syncOptions();
3934
3939
  this.viewer.syncOverlay();
3935
- this.viewer.update(true);
3936
3940
  this.viewer.emitEvent({ type: "databasechunk", data, file });
3941
+ this.viewer.update(true);
3937
3942
  return this;
3938
3943
  }
3939
3944
  }
@@ -3973,8 +3978,8 @@
3973
3978
  this.viewer.models.push(modelImpl);
3974
3979
  this.viewer.syncOptions();
3975
3980
  this.viewer.syncOverlay();
3976
- this.viewer.update(true);
3977
3981
  this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
3982
+ this.viewer.update(true);
3978
3983
  return this;
3979
3984
  }
3980
3985
  }
@@ -4023,12 +4028,12 @@
4023
4028
  this.viewer.models.push(modelImpl);
4024
4029
  this.viewer.syncOptions();
4025
4030
  this.viewer.syncOverlay();
4026
- this.viewer.update(true);
4027
4031
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
4032
+ this.viewer.update(true);
4028
4033
  }
4029
4034
  else {
4030
- this.viewer.update();
4031
4035
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
4036
+ this.viewer.update();
4032
4037
  }
4033
4038
  };
4034
4039
  await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
@@ -4081,12 +4086,12 @@
4081
4086
  this.viewer.models.push(modelImpl);
4082
4087
  this.viewer.syncOptions();
4083
4088
  this.viewer.syncOverlay();
4084
- this.viewer.update(true);
4085
4089
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
4090
+ this.viewer.update(true);
4086
4091
  }
4087
4092
  else {
4088
- this.viewer.update();
4089
4093
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
4094
+ this.viewer.update();
4090
4095
  }
4091
4096
  };
4092
4097
  const downloadResourceRange = async (dataId, requestId, ranges) => {
@@ -18172,8 +18177,8 @@ js: import "konva/skia-backend";
18172
18177
  this.syncOptions();
18173
18178
  this.syncOverlay();
18174
18179
  this._renderTime = performance.now();
18175
- this.render(this._renderTime);
18176
18180
  this.emitEvent({ type: "initialize" });
18181
+ this.update(true);
18177
18182
  return this;
18178
18183
  }
18179
18184
  dispose() {
@@ -18209,8 +18214,8 @@ js: import "konva/skia-backend";
18209
18214
  this.canvas.style.height = height + "px";
18210
18215
  }
18211
18216
  this._viewer.resize(0, this.canvas.width, this.canvas.height, 0);
18212
- this.update(true);
18213
18217
  this.emitEvent({ type: "resize", width, height });
18218
+ this.update(true);
18214
18219
  }
18215
18220
  resize() {
18216
18221
  console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
@@ -18277,6 +18282,8 @@ js: import "konva/skia-backend";
18277
18282
  return this;
18278
18283
  }
18279
18284
  applyModelTransformMatrix(model) {
18285
+ if (!this.visualizeJs)
18286
+ return;
18280
18287
  this.executeCommand("applyModelTransform", model);
18281
18288
  }
18282
18289
  applySceneGraphSettings(options = this.options) {
@@ -18305,10 +18312,8 @@ js: import "konva/skia-backend";
18305
18312
  if (model && typeof model.database === "string") {
18306
18313
  file = model.file;
18307
18314
  }
18308
- if (!model)
18309
- throw new Error(`Format not supported`);
18310
18315
  let format = params.format;
18311
- if (!format && typeof file["type"] === "string")
18316
+ if (!format && file && typeof file["type"] === "string")
18312
18317
  format = file["type"].split(".").pop();
18313
18318
  if (!format && typeof file === "string")
18314
18319
  format = file.split(".").pop();
@@ -18316,22 +18321,21 @@ js: import "konva/skia-backend";
18316
18321
  format = file.name.split(".").pop();
18317
18322
  const loader = loaders.createLoader(this, model, format);
18318
18323
  if (!loader)
18319
- throw new Error(`Format not supported`);
18324
+ throw new Error(`Format not supported (${format})`);
18320
18325
  this.loaders.push(loader);
18321
18326
  this.emitEvent({ type: "geometrystart", file, model });
18322
18327
  try {
18323
18328
  await this.loadReferences(model);
18324
18329
  await loader.load(model, format, params);
18330
+ this.applyModelTransformMatrix(model);
18331
+ this.applySceneGraphSettings();
18325
18332
  }
18326
18333
  catch (error) {
18327
18334
  this.emitEvent({ type: "geometryerror", data: error, file, model });
18328
18335
  throw error;
18329
18336
  }
18330
18337
  this.emitEvent({ type: "geometryend", file, model });
18331
- if (this.visualizeJs) {
18332
- this.applyModelTransformMatrix(model);
18333
- this.applySceneGraphSettings();
18334
- }
18338
+ this.update(true);
18335
18339
  return this;
18336
18340
  }
18337
18341
  openVsfFile(buffer) {
@@ -18348,7 +18352,6 @@ js: import "konva/skia-backend";
18348
18352
  visViewer.parseFile(data);
18349
18353
  this.syncOptions();
18350
18354
  this.syncOverlay();
18351
- this.update(true);
18352
18355
  this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18353
18356
  this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18354
18357
  }
@@ -18357,6 +18360,7 @@ js: import "konva/skia-backend";
18357
18360
  throw error;
18358
18361
  }
18359
18362
  this.emitEvent({ type: "geometryend", file: "", buffer });
18363
+ this.update(true);
18360
18364
  return this;
18361
18365
  }
18362
18366
  openVsfxFile(buffer) {
@@ -18373,7 +18377,6 @@ js: import "konva/skia-backend";
18373
18377
  visViewer.parseVsfx(data);
18374
18378
  this.syncOptions();
18375
18379
  this.syncOverlay();
18376
- this.update(true);
18377
18380
  this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
18378
18381
  this.emitEvent({ type: "databasechunk", data, file: "", buffer });
18379
18382
  }
@@ -18382,6 +18385,7 @@ js: import "konva/skia-backend";
18382
18385
  throw error;
18383
18386
  }
18384
18387
  this.emitEvent({ type: "geometryend", file: "", buffer });
18388
+ this.update(true);
18385
18389
  return this;
18386
18390
  }
18387
18391
  cancel() {
@@ -18408,8 +18412,8 @@ js: import "konva/skia-backend";
18408
18412
  visViewer.createLocalDatabase();
18409
18413
  this.syncOptions();
18410
18414
  this.syncOverlay();
18411
- this.update(true);
18412
18415
  this.emitEvent({ type: "clear" });
18416
+ this.update(true);
18413
18417
  return this;
18414
18418
  }
18415
18419
  is3D() {
@@ -18702,7 +18706,7 @@ js: import "konva/skia-backend";
18702
18706
  this.syncOverlay();
18703
18707
  this.setActiveDragger(draggerName);
18704
18708
  this.emitEvent({ type: "drawviewpoint", data: viewpoint });
18705
- this.update();
18709
+ this.update(true);
18706
18710
  }
18707
18711
  createViewpoint() {
18708
18712
  if (!this.visualizeJs)