@inweb/viewer-visualize 26.9.1 → 26.9.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.
@@ -1446,6 +1446,7 @@
1446
1446
  }
1447
1447
  }
1448
1448
  this.subject.update();
1449
+ this.subject.emitEvent({ type: "changecamera" });
1449
1450
  }
1450
1451
  this.lastFrameTS = timestamp;
1451
1452
  }
@@ -1462,6 +1463,7 @@
1462
1463
  if (dltY !== 0.0)
1463
1464
  this.cameraWalker.turnDown(dltY * this.deltaAngle);
1464
1465
  this.subject.update();
1466
+ this.subject.emitEvent({ type: "changecamera" });
1465
1467
  }
1466
1468
  }
1467
1469
  turnLeft(angle) {
@@ -1769,6 +1771,12 @@
1769
1771
  extView.setView(viewParams.position, viewParams.target, viewParams.upVector, viewParams.viewFieldWidth, viewParams.viewFieldHeight, viewParams.perspective);
1770
1772
  extView.delete();
1771
1773
  (_b = (_a = this._subject.activeDragger()) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
1774
+ this._subject.emitEvent({
1775
+ type: "orbit",
1776
+ });
1777
+ this._subject.emitEvent({
1778
+ type: "changecamera",
1779
+ });
1772
1780
  }
1773
1781
  endAction() {
1774
1782
  this._endInteractivity();
@@ -1971,6 +1979,9 @@
1971
1979
  dX: absoluteX - this._deltaScreenPosition.x,
1972
1980
  dY: absoluteY - this._deltaScreenPosition.y,
1973
1981
  });
1982
+ this._subject.emitEvent({
1983
+ type: "changecamera",
1984
+ });
1974
1985
  this._deltaScreenPosition = { x: absoluteX, y: absoluteY };
1975
1986
  }
1976
1987
  endAction() {
@@ -2042,6 +2053,9 @@
2042
2053
  x: absoluteX,
2043
2054
  y: absoluteY,
2044
2055
  });
2056
+ this._subject.emitEvent({
2057
+ type: "changecamera",
2058
+ });
2045
2059
  }
2046
2060
  }
2047
2061
 
@@ -2537,7 +2551,7 @@
2537
2551
  if (!model.getModelTransformMatrix)
2538
2552
  return; // Model.getModelTransformMatrix() since 24.3.14
2539
2553
  const visLib = viewer.visLib();
2540
- const visViewer = visLib.getViewer();
2554
+ const visViewer = viewer.visViewer();
2541
2555
  const modelItr = visViewer.getModelIterator();
2542
2556
  for (; !modelItr.done(); modelItr.step()) {
2543
2557
  const modelPtr = modelItr.getModel();
@@ -3101,7 +3115,7 @@
3101
3115
  if (!viewer.visualizeJs)
3102
3116
  return;
3103
3117
  const visLib = viewer.visLib();
3104
- const visViewer = visLib.getViewer();
3118
+ const visViewer = viewer.visViewer();
3105
3119
  const selectionSet = new visLib.OdTvSelectionSet();
3106
3120
  handles === null || handles === undefined ? undefined : handles.forEach((handle) => {
3107
3121
  const entityId = visViewer.getEntityByOriginalHandle(handle + "");
@@ -3288,7 +3302,7 @@
3288
3302
  if (!model.getModelTransformMatrix)
3289
3303
  return; // Model.getModelTransformMatrix() since 24.3.14
3290
3304
  const visLib = viewer.visLib();
3291
- const visViewer = visLib.getViewer();
3305
+ const visViewer = viewer.visViewer();
3292
3306
  const viewExt = visViewer.getActiveExtents();
3293
3307
  const centralPoint = viewExt.center();
3294
3308
  const modelItr = visViewer.getModelIterator();
@@ -3484,8 +3498,11 @@
3484
3498
  ///////////////////////////////////////////////////////////////////////////////
3485
3499
  class ResizeCanvasComponent {
3486
3500
  constructor(viewer) {
3487
- this.resizeViewer = () => {
3488
- this.viewer.resize();
3501
+ this.resizeViewer = (entries) => {
3502
+ const { width, height } = entries[0].contentRect;
3503
+ if (!width || !height)
3504
+ return; // <- invisible viewer, or viewer with parent removed
3505
+ this.viewer.setSize(width, height);
3489
3506
  };
3490
3507
  this.viewer = viewer;
3491
3508
  this.resizeObserver = new ResizeObserver(this.resizeViewer);
@@ -3962,6 +3979,7 @@
3962
3979
  async load(file, format, params) {
3963
3980
  if (!this.viewer.visualizeJs)
3964
3981
  return this;
3982
+ const visViewer = this.viewer.visViewer();
3965
3983
  const progress = (event) => {
3966
3984
  const { lengthComputable, loaded, total } = event;
3967
3985
  const progress = lengthComputable ? loaded / total : 1;
@@ -3971,15 +3989,20 @@
3971
3989
  loader.setRequestHeader(params.requestHeader);
3972
3990
  loader.setWithCredentials(params.withCredentials);
3973
3991
  loader.setAbortSignal(this.abortController.signal);
3974
- const buffer = await loader.load(file, progress);
3975
- const data = new Uint8Array(buffer);
3976
- const visLib = this.viewer.visLib();
3977
- const visViewer = visLib.getViewer();
3978
- visViewer.parseFile(data);
3979
- this.viewer.syncOpenCloudVisualStyle(false);
3992
+ const arrayBuffer = await loader.load(file, progress);
3993
+ const data = new Uint8Array(arrayBuffer);
3994
+ if (!this.viewer.visualizeJs)
3995
+ return this;
3996
+ try {
3997
+ visViewer.parseFile(data);
3998
+ }
3999
+ catch (error) {
4000
+ console.error("VSF parse error.", error);
4001
+ throw error;
4002
+ }
3980
4003
  this.viewer.syncOptions();
3981
4004
  this.viewer.syncOverlay();
3982
- this.viewer.resize();
4005
+ this.viewer.update(true);
3983
4006
  this.viewer.emitEvent({ type: "databasechunk", data, file });
3984
4007
  return this;
3985
4008
  }
@@ -4021,8 +4044,7 @@
4021
4044
  async load(model, format) {
4022
4045
  if (!this.viewer.visualizeJs)
4023
4046
  return this;
4024
- const visLib = this.viewer.visLib();
4025
- const visViewer = visLib.getViewer();
4047
+ const visViewer = this.viewer.visViewer();
4026
4048
  const filesToDownload = [model.database, ...model.geometry];
4027
4049
  console.time("File load time");
4028
4050
  for (let i = 0; i < filesToDownload.length; i++) {
@@ -4032,16 +4054,20 @@
4032
4054
  this.viewer.emitEvent({ type: "geometryprogress", data, file: model.file, model });
4033
4055
  };
4034
4056
  const arrayBuffer = await model.downloadResource(dataId, progress, this.abortController.signal);
4057
+ const data = new Uint8Array(arrayBuffer);
4035
4058
  if (!this.viewer.visualizeJs)
4036
4059
  return this;
4037
- const data = new Uint8Array(arrayBuffer);
4038
- visViewer.parseStream(data);
4060
+ try {
4061
+ visViewer.parseStream(data);
4062
+ }
4063
+ catch (error) {
4064
+ console.error("VSF parse error.", error);
4065
+ throw error;
4066
+ }
4039
4067
  if (i === 0) {
4040
- this.viewer.update(true);
4041
- this.viewer.syncOpenCloudVisualStyle(false);
4042
4068
  this.viewer.syncOptions();
4043
4069
  this.viewer.syncOverlay();
4044
- this.viewer.resize();
4070
+ this.viewer.update(true);
4045
4071
  this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
4046
4072
  }
4047
4073
  else {
@@ -4088,6 +4114,7 @@
4088
4114
  async load(file, format, params) {
4089
4115
  if (!this.viewer.visualizeJs)
4090
4116
  return this;
4117
+ const visViewer = this.viewer.visViewer();
4091
4118
  const progress = (event) => {
4092
4119
  const { lengthComputable, loaded, total } = event;
4093
4120
  const progress = lengthComputable ? loaded / total : 1;
@@ -4097,15 +4124,20 @@
4097
4124
  loader.setRequestHeader(params.requestHeader);
4098
4125
  loader.setWithCredentials(params.withCredentials);
4099
4126
  loader.setAbortSignal(this.abortController.signal);
4100
- const buffer = await loader.load(file, progress);
4101
- const data = new Uint8Array(buffer);
4102
- const visLib = this.viewer.visLib();
4103
- const visViewer = visLib.getViewer();
4104
- visViewer.parseVsfx(data);
4105
- this.viewer.syncOpenCloudVisualStyle(false);
4127
+ const arrayBuffer = await loader.load(file, progress);
4128
+ const data = new Uint8Array(arrayBuffer);
4129
+ if (!this.viewer.visualizeJs)
4130
+ return this;
4131
+ try {
4132
+ visViewer.parseVsfx(data);
4133
+ }
4134
+ catch (error) {
4135
+ console.error("VSFX parse error.", error);
4136
+ throw error;
4137
+ }
4106
4138
  this.viewer.syncOptions();
4107
4139
  this.viewer.syncOverlay();
4108
- this.viewer.resize();
4140
+ this.viewer.update(true);
4109
4141
  this.viewer.emitEvent({ type: "databasechunk", data, file });
4110
4142
  return this;
4111
4143
  }
@@ -4148,16 +4180,15 @@
4148
4180
  async load(model, format, params = {}) {
4149
4181
  if (!this.viewer.visualizeJs)
4150
4182
  return Promise.resolve(this);
4151
- const visLib = this.viewer.visLib();
4152
- const visViewer = visLib.getViewer();
4183
+ const visViewer = this.viewer.visViewer();
4153
4184
  const progress = (progress) => {
4154
4185
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
4155
4186
  };
4156
4187
  console.time("File load time");
4157
4188
  const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
4189
+ const data = new Uint8Array(arrayBuffer);
4158
4190
  if (!this.viewer.visualizeJs)
4159
4191
  return this;
4160
- const data = new Uint8Array(arrayBuffer);
4161
4192
  try {
4162
4193
  visViewer.parseVsfx(data);
4163
4194
  }
@@ -4165,10 +4196,9 @@
4165
4196
  console.error("VSFX parse error.", error);
4166
4197
  throw error;
4167
4198
  }
4168
- this.viewer.syncOpenCloudVisualStyle(false);
4169
4199
  this.viewer.syncOptions();
4170
4200
  this.viewer.syncOverlay();
4171
- this.viewer.resize();
4201
+ this.viewer.update(true);
4172
4202
  this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
4173
4203
  console.timeEnd("File load time");
4174
4204
  return this;
@@ -4265,7 +4295,7 @@
4265
4295
  if (!this.viewer.visualizeJs)
4266
4296
  return this;
4267
4297
  const visLib = this.viewer.visLib();
4268
- const visViewer = visLib.getViewer();
4298
+ const visViewer = this.viewer.visViewer();
4269
4299
  const updateController = new UpdateController();
4270
4300
  updateController.initialize(this.viewer);
4271
4301
  let isFireDatabaseChunk = false;
@@ -4280,23 +4310,21 @@
4280
4310
  console.error("VSFX parse error.", error);
4281
4311
  throw error;
4282
4312
  }
4283
- updateController.update(UpdateType.kDelay);
4284
4313
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
4285
- let state = false;
4314
+ let isDatabaseChunk = false;
4286
4315
  if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
4287
4316
  (status === visLib.DatabaseStreamStatus.Complete && !isFireDatabaseChunk)) {
4288
4317
  isFireDatabaseChunk = true;
4289
- state = true;
4318
+ isDatabaseChunk = true;
4290
4319
  }
4291
- if (state) {
4292
- updateController.update(UpdateType.kForce);
4293
- this.viewer.syncOpenCloudVisualStyle(false);
4320
+ if (isDatabaseChunk) {
4294
4321
  this.viewer.syncOptions();
4295
4322
  this.viewer.syncOverlay();
4296
- this.viewer.resize();
4323
+ updateController.update(UpdateType.kForce);
4297
4324
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
4298
4325
  }
4299
4326
  else {
4327
+ updateController.update(UpdateType.kDelay);
4300
4328
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
4301
4329
  }
4302
4330
  };
@@ -4349,8 +4377,7 @@
4349
4377
  async load(model, format) {
4350
4378
  if (!this.viewer.visualizeJs)
4351
4379
  return this;
4352
- const visLib = this.viewer.visLib();
4353
- const visViewer = visLib.getViewer();
4380
+ const visViewer = this.viewer.visViewer();
4354
4381
  let servicePartAborted = false;
4355
4382
  const pendingRequestsMap = new Map();
4356
4383
  let pendingRequestsTimerId = 0;
@@ -4363,25 +4390,23 @@
4363
4390
  const chunkLoadHandler = (progress, chunk, requestId = 0) => {
4364
4391
  if (!this.viewer.visualizeJs)
4365
4392
  return;
4366
- let state;
4393
+ let isDatabaseChunk;
4367
4394
  try {
4368
- state = visViewer.parseVsfxInPartialMode(requestId, chunk);
4395
+ isDatabaseChunk = visViewer.parseVsfxInPartialMode(requestId, chunk);
4369
4396
  }
4370
4397
  catch (error) {
4371
4398
  console.error("VSFX parse error.", error);
4372
4399
  throw error;
4373
4400
  }
4374
- updateController.update(UpdateType.kDelay);
4375
4401
  this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
4376
- if (state) {
4377
- updateController.update(UpdateType.kForce);
4378
- this.viewer.syncOpenCloudVisualStyle(false);
4402
+ if (isDatabaseChunk) {
4379
4403
  this.viewer.syncOptions();
4380
4404
  this.viewer.syncOverlay();
4381
- this.viewer.resize();
4405
+ updateController.update(UpdateType.kForce);
4382
4406
  this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
4383
4407
  }
4384
4408
  else {
4409
+ updateController.update(UpdateType.kDelay);
4385
4410
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
4386
4411
  }
4387
4412
  };
@@ -4569,10 +4594,9 @@
4569
4594
  *
4570
4595
  * this.viewer.visualizeJs.getViewer().parseVsfx(data);
4571
4596
  *
4572
- * this.viewer.syncOpenCloudVisualStyle(false);
4573
4597
  * this.viewer.syncOptions();
4574
4598
  * this.viewer.syncOverlay();
4575
- * this.viewer.resize();
4599
+ * this.viewer.update();
4576
4600
  *
4577
4601
  * this.viewer.emitEvent({ type: "databasechunk", data, file });
4578
4602
  *
@@ -19276,7 +19300,7 @@
19276
19300
  if (!this._viewer.visualizeJs)
19277
19301
  return;
19278
19302
  const visLib = this._viewer.visLib();
19279
- const visViewer = visLib.getViewer();
19303
+ const visViewer = this._viewer.visViewer();
19280
19304
  const activeView = visViewer.activeView;
19281
19305
  this._viewer.syncOverlay();
19282
19306
  const markupColor = viewpoint.custom_fields.markup_color || { r: 255, g: 0, b: 0 };
@@ -19320,7 +19344,7 @@
19320
19344
  return { x: array[0], y: array[1], z: array[2] };
19321
19345
  }
19322
19346
  const visLib = this._viewer.visLib();
19323
- const visViewer = visLib.getViewer();
19347
+ const visViewer = this._viewer.visViewer();
19324
19348
  if (!viewpoint)
19325
19349
  viewpoint = {};
19326
19350
  viewpoint.lines = [];
@@ -19488,7 +19512,7 @@
19488
19512
  this.canvasEvents = CANVAS_EVENTS.slice();
19489
19513
  this.canvaseventlistener = (event) => this.emit(event);
19490
19514
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== undefined ? _a : true;
19491
- this._isNeedRender = false;
19515
+ this._renderNeeded = false;
19492
19516
  this._isRunAsyncUpdate = false;
19493
19517
  this.render = this.render.bind(this);
19494
19518
  this.update = this.update.bind(this);
@@ -19550,14 +19574,15 @@
19550
19574
  */
19551
19575
  async initialize(canvas, onProgress) {
19552
19576
  this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
19553
- if (canvas.style.width === "" && canvas.style.height === "") {
19554
- canvas.style.width = "100%";
19555
- canvas.style.height = "100%";
19556
- }
19577
+ const rect = canvas.parentElement.getBoundingClientRect();
19578
+ const width = rect.width || 1;
19579
+ const height = rect.height || 1;
19580
+ canvas.width = Math.round(width * window.devicePixelRatio);
19581
+ canvas.height = Math.round(height * window.devicePixelRatio);
19582
+ canvas.style.width = width + "px";
19583
+ canvas.style.height = height + "px";
19557
19584
  canvas.parentElement.style.touchAction = "none";
19558
19585
  canvas.style.touchAction = "none";
19559
- canvas.width = canvas.clientWidth * window.devicePixelRatio;
19560
- canvas.height = canvas.clientHeight * window.devicePixelRatio;
19561
19586
  this._visualizeTimestamp = Date.now();
19562
19587
  const visualizeTimestamp = this._visualizeTimestamp;
19563
19588
  const visualizeJs = await loadVisualizeJs(this.visualizeJsUrl, (event) => {
@@ -19569,16 +19594,15 @@
19569
19594
  if (visualizeTimestamp !== this._visualizeTimestamp)
19570
19595
  throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
19571
19596
  this._visualizeJs = visualizeJs;
19572
- this.visualizeJs.canvas = canvas;
19573
- this.visualizeJs.Viewer.create();
19574
- this.visualizeJs.getViewer().resize(0, canvas.width, canvas.height, 0);
19597
+ this._visualizeJs.canvas = canvas;
19598
+ this._viewer = visualizeJs.Viewer.create();
19599
+ this._viewer.resize(0, canvas.width, canvas.height, 0);
19575
19600
  this.canvas = canvas;
19576
19601
  this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
19577
19602
  this._markup.initialize(this.canvas, this.canvasEvents, this, this);
19578
19603
  for (const name of components.getComponents().keys()) {
19579
19604
  this._components.push(components.createComponent(name, this));
19580
19605
  }
19581
- this.syncOpenCloudVisualStyle(true);
19582
19606
  this.syncOptions();
19583
19607
  this.syncOverlay();
19584
19608
  this._renderTime = performance.now();
@@ -19599,10 +19623,11 @@
19599
19623
  this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
19600
19624
  this.canvas = undefined;
19601
19625
  }
19602
- if (this._visualizeJs)
19603
- this._visualizeJs.getViewer().clear();
19626
+ if (this._viewer)
19627
+ this._viewer.clear();
19604
19628
  this._visualizeJs = undefined;
19605
19629
  this._visualizeTimestamp = undefined;
19630
+ this._viewer = undefined;
19606
19631
  return this;
19607
19632
  }
19608
19633
  /**
@@ -19611,6 +19636,19 @@
19611
19636
  isInitialized() {
19612
19637
  return !!this.visualizeJs;
19613
19638
  }
19639
+ setSize(width, height, updateStyle = true) {
19640
+ if (!this.visualizeJs)
19641
+ return;
19642
+ this.canvas.width = Math.round(width * window.devicePixelRatio);
19643
+ this.canvas.height = Math.round(height * window.devicePixelRatio);
19644
+ if (updateStyle) {
19645
+ this.canvas.style.width = width + "px";
19646
+ this.canvas.style.height = height + "px";
19647
+ }
19648
+ this._viewer.resize(0, this.canvas.width, this.canvas.height, 0);
19649
+ this.update(true);
19650
+ this.emitEvent({ type: "resize", width, height });
19651
+ }
19614
19652
  // internal render/resize routines
19615
19653
  render(time) {
19616
19654
  var _a, _b;
@@ -19618,28 +19656,28 @@
19618
19656
  return;
19619
19657
  if (this._isRunAsyncUpdate)
19620
19658
  return;
19621
- const visViewer = this.visualizeJs.getViewer();
19622
- if (visViewer.isRunningAnimation() || this._isNeedRender) {
19623
- visViewer.update();
19624
- (_b = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
19625
- this._isNeedRender = !visViewer.getActiveDevice().isValid();
19626
- const deltaTime = (time - this._renderTime) / 1000;
19627
- this._renderTime = time;
19628
- this.emitEvent({ type: "render", time, deltaTime });
19629
- }
19659
+ const renderNeeded = this.visViewer().isRunningAnimation() || this._renderNeeded;
19660
+ if (!renderNeeded)
19661
+ return;
19662
+ if (!time)
19663
+ time = performance.now();
19664
+ const deltaTime = (time - this._renderTime) / 1000;
19665
+ this._renderTime = time;
19666
+ this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
19667
+ this.visViewer().update();
19668
+ (_b = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
19669
+ this.emitEvent({ type: "render", time, deltaTime });
19630
19670
  }
19631
19671
  resize() {
19672
+ console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
19632
19673
  if (!this.visualizeJs)
19633
19674
  return this;
19634
- const { clientWidth, clientHeight } = this.canvas;
19635
- if (!clientWidth || !clientHeight)
19675
+ if (!this.canvas.parentElement)
19676
+ return this;
19677
+ const { width, height } = this.canvas.parentElement.getBoundingClientRect();
19678
+ if (!width || !height)
19636
19679
  return this; // <- invisible viewer, or viewer with parent removed
19637
- this.canvas.width = clientWidth * window.devicePixelRatio;
19638
- this.canvas.height = clientHeight * window.devicePixelRatio;
19639
- const visViewer = this.visualizeJs.getViewer();
19640
- visViewer.resize(0, this.canvas.width, this.canvas.height, 0);
19641
- this.update(true);
19642
- this.emitEvent({ type: "resize", width: clientWidth, height: clientHeight });
19680
+ this.setSize(width, height);
19643
19681
  return this;
19644
19682
  }
19645
19683
  /**
@@ -19656,15 +19694,10 @@
19656
19694
  * Default is `false`.
19657
19695
  */
19658
19696
  update(force = false) {
19659
- var _a, _b, _c;
19660
19697
  if (this._enableAutoUpdate) {
19661
- if (force) {
19662
- (_a = this.visViewer()) === null || _a === undefined ? undefined : _a.update();
19663
- (_c = (_b = this._activeDragger) === null || _b === undefined ? undefined : _b.updatePreview) === null || _c === undefined ? undefined : _c.call(_b);
19664
- }
19665
- else {
19666
- this._isNeedRender = true;
19667
- }
19698
+ this._renderNeeded = true;
19699
+ if (force)
19700
+ this.render();
19668
19701
  }
19669
19702
  this.emitEvent({ type: "update", data: force });
19670
19703
  }
@@ -19702,9 +19735,11 @@
19702
19735
  * @param maxScheduleUpdateCount - Maximum count of scheduled updates.
19703
19736
  */
19704
19737
  async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
19738
+ if (!this.visualizeJs)
19739
+ return;
19705
19740
  this._isRunAsyncUpdate = true;
19706
- const device = this.visViewer().getActiveDevice();
19707
19741
  try {
19742
+ const device = this.visViewer().getActiveDevice();
19708
19743
  for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
19709
19744
  await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
19710
19745
  }
@@ -19729,22 +19764,21 @@
19729
19764
  * instance.
19730
19765
  */
19731
19766
  visLib() {
19732
- return this.visualizeJs;
19767
+ return this._visualizeJs;
19733
19768
  }
19734
19769
  /**
19735
19770
  * Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/vis/Viewer | Viewer}
19736
19771
  * instance.
19737
19772
  */
19738
19773
  visViewer() {
19739
- var _a;
19740
- return (_a = this.visualizeJs) === null || _a === undefined ? undefined : _a.getViewer();
19774
+ return this._viewer;
19741
19775
  }
19742
19776
  // update the VisualizeJS options
19743
- syncOpenCloudVisualStyle(isInitializing) {
19777
+ syncOpenCloudVisualStyle() {
19744
19778
  if (!this.visualizeJs)
19745
19779
  return this;
19746
19780
  const visLib = this.visLib();
19747
- const visViewer = visLib.getViewer();
19781
+ const visViewer = this.visViewer();
19748
19782
  const device = visViewer.getActiveDevice();
19749
19783
  if (device.isNull())
19750
19784
  return this;
@@ -19781,8 +19815,9 @@
19781
19815
  syncOptions(options = this.options) {
19782
19816
  if (!this.visualizeJs)
19783
19817
  return this;
19818
+ this.syncOpenCloudVisualStyle();
19784
19819
  const visLib = this.visLib();
19785
- const visViewer = visLib.getViewer();
19820
+ const visViewer = this.visViewer();
19786
19821
  const device = visViewer.getActiveDevice();
19787
19822
  if (device.isNull())
19788
19823
  return this;
@@ -19800,7 +19835,7 @@
19800
19835
  if (options.shadows !== visViewer.shadows) {
19801
19836
  visViewer.shadows = options.shadows;
19802
19837
  const canvas = visLib.canvas;
19803
- device.invalidate([0, canvas.clientWidth, canvas.clientHeight, 0]);
19838
+ device.invalidate([0, canvas.width, canvas.height, 0]);
19804
19839
  }
19805
19840
  if (options.groundShadow !== visViewer.groundShadow) {
19806
19841
  visViewer.groundShadow = options.groundShadow;
@@ -19836,7 +19871,7 @@
19836
19871
  return this;
19837
19872
  const params = options.enableCustomHighlight ? options : Options.defaults();
19838
19873
  const visLib = this.visLib();
19839
- const visViewer = visLib.getViewer();
19874
+ const visViewer = this.visViewer();
19840
19875
  const { Entry, OdTvRGBColorDef } = visLib;
19841
19876
  const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
19842
19877
  const highlightStylePtr = highlightStyleId.openObject();
@@ -19866,7 +19901,7 @@
19866
19901
  const device = visViewer.getActiveDevice();
19867
19902
  if (!device.isNull()) {
19868
19903
  const canvas = visLib.canvas;
19869
- device.invalidate([0, canvas.clientWidth, canvas.clientHeight, 0]);
19904
+ device.invalidate([0, canvas.width, canvas.height, 0]);
19870
19905
  device.delete();
19871
19906
  }
19872
19907
  return this;
@@ -20065,7 +20100,7 @@
20065
20100
  if (!this.visualizeJs)
20066
20101
  return;
20067
20102
  const visLib = this.visLib();
20068
- const visViewer = visLib.getViewer();
20103
+ const visViewer = this.visViewer();
20069
20104
  const device = visViewer.getActiveDevice();
20070
20105
  if (isExist(options.sceneGraph)) {
20071
20106
  device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
@@ -20190,16 +20225,14 @@
20190
20225
  this.cancel();
20191
20226
  this.clear();
20192
20227
  this.emitEvent({ type: "open", file: buffer });
20193
- const visLib = this.visLib();
20194
- const visViewer = visLib.getViewer();
20228
+ const visViewer = this.visViewer();
20195
20229
  this.emitEvent({ type: "geometrystart", file: buffer });
20196
20230
  try {
20197
20231
  const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
20198
20232
  visViewer.parseFile(data);
20199
- this.syncOpenCloudVisualStyle(false);
20200
20233
  this.syncOptions();
20201
20234
  this.syncOverlay();
20202
- this.resize();
20235
+ this.update(true);
20203
20236
  this.emitEvent({ type: "geometryprogress", data: 1, file: buffer });
20204
20237
  this.emitEvent({ type: "databasechunk", data, file: buffer });
20205
20238
  }
@@ -20222,16 +20255,14 @@
20222
20255
  this.cancel();
20223
20256
  this.clear();
20224
20257
  this.emitEvent({ type: "open", file: buffer });
20225
- const visLib = this.visLib();
20226
- const visViewer = visLib.getViewer();
20258
+ const visViewer = this.visViewer();
20227
20259
  this.emitEvent({ type: "geometrystart", file: buffer });
20228
20260
  try {
20229
20261
  const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
20230
20262
  visViewer.parseVsfx(data);
20231
- this.syncOpenCloudVisualStyle(false);
20232
20263
  this.syncOptions();
20233
20264
  this.syncOverlay();
20234
- this.resize();
20265
+ this.update(true);
20235
20266
  this.emitEvent({ type: "geometryprogress", data: 1, file: buffer });
20236
20267
  this.emitEvent({ type: "databasechunk", data, file: buffer });
20237
20268
  }
@@ -20253,20 +20284,18 @@
20253
20284
  clear() {
20254
20285
  if (!this.visualizeJs)
20255
20286
  return this;
20256
- const visLib = this.visLib();
20257
- const visViewer = visLib.getViewer();
20287
+ const visViewer = this.visViewer();
20258
20288
  this.setActiveDragger();
20259
20289
  this.clearSlices();
20260
20290
  this.clearOverlay();
20261
20291
  this.clearSelected();
20262
- visViewer.clear();
20263
- visViewer.createLocalDatabase();
20264
20292
  this.loaders.forEach((loader) => loader.dispose());
20265
20293
  this.loaders = [];
20266
- this.syncOpenCloudVisualStyle(true);
20294
+ visViewer.clear();
20295
+ visViewer.createLocalDatabase();
20267
20296
  this.syncOptions();
20268
20297
  this.syncOverlay();
20269
- this.resize();
20298
+ this.update(true);
20270
20299
  this.emitEvent({ type: "clear" });
20271
20300
  return this;
20272
20301
  }