@inweb/viewer-visualize 27.4.7 → 27.5.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.
@@ -650,16 +650,16 @@ class MeasureLineDragger extends OdBaseDragger {
650
650
  this.m_overlayElement.style.zIndex = "1";
651
651
  this.m_overlayElement.style.pointerEvents = "none";
652
652
  document.body.appendChild(this.m_overlayElement);
653
- this.optionsChange = this.optionsChange.bind(this);
653
+ this.updateUnits = this.updateUnits.bind(this);
654
654
  this.updatePreview = this.updatePreview.bind(this);
655
- this.subject.addEventListener("optionschange", this.optionsChange);
655
+ this.subject.addEventListener("optionschange", this.updateUnits);
656
656
  this.subject.addEventListener("render", this.updatePreview);
657
657
  this.resize();
658
658
  }
659
659
  dispose() {
660
660
  super.dispose();
661
661
  this.m_overlayElement.remove();
662
- this.subject.removeEventListener("optionschange", this.optionsChange);
662
+ this.subject.removeEventListener("optionschange", this.updateUnits);
663
663
  this.subject.removeEventListener("render", this.updatePreview);
664
664
  }
665
665
  updatePreview() {
@@ -761,7 +761,7 @@ class MeasureLineDragger extends OdBaseDragger {
761
761
  this.items.push(item);
762
762
  return item;
763
763
  }
764
- optionsChange(event) {
764
+ updateUnits(event) {
765
765
  var _a, _b;
766
766
  const options = event.data;
767
767
  const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
@@ -1544,9 +1544,8 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1544
1544
  plane.set(this.toGePoint(this.m_center), this.m_normal);
1545
1545
  avp.addCuttingPlane(plane);
1546
1546
  this.index = avp.numCuttingPlanes() - 1;
1547
- const { red, green, blue } = this.subject.options.cuttingPlaneFillColor;
1548
- avp.setEnableCuttingPlaneFill(true, red, green, blue);
1549
- avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kSlantRight, 0x0, 0x0, 0x0);
1547
+ this.subject.syncOptions();
1548
+ this.subject.emitEvent({ type: "changecuttingplanes" });
1550
1549
  this.m_model = this.getModel();
1551
1550
  this.createPreview();
1552
1551
  this.deleteAll([ext, avp, plane]);
@@ -1586,6 +1585,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1586
1585
  const plane = this.createPlane();
1587
1586
  plane.set(this.toGePoint(this.m_center), this.m_normal);
1588
1587
  avp.updateCuttingPlane(this.index, plane);
1588
+ this.subject.emitEvent({ type: "changecuttingplanes" });
1589
1589
  this.drawPreview();
1590
1590
  this.deleteAll([avp, plane, oldCenter, delta, oldLast]);
1591
1591
  const device = this.getViewer().getActiveDevice();
@@ -1601,6 +1601,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1601
1601
  const plane = this.createPlane();
1602
1602
  plane.set(this.toGePoint(this.m_center), this.m_normal);
1603
1603
  avp.updateCuttingPlane(this.index, plane);
1604
+ this.subject.emitEvent({ type: "changecuttingplanes" });
1604
1605
  this.deleteAll([avp, plane, this.m_last]);
1605
1606
  const device = this.getViewer().getActiveDevice();
1606
1607
  device.invalidate(device.getSize());
@@ -1686,7 +1687,7 @@ class OdCuttingPlaneYAxisDragger extends OdBaseCuttingPlaneDragger {
1686
1687
 
1687
1688
  class OdCuttingPlaneZAxisDragger extends OdBaseCuttingPlaneDragger {
1688
1689
  createNormal() {
1689
- return [0, 0, 1];
1690
+ return [0, 0, -1];
1690
1691
  }
1691
1692
  handleDelta(delta) {
1692
1693
  delta.x = 0.0;
@@ -2851,24 +2852,34 @@ commands.registerCommand("zoomToExtents", zoomToExtents);
2851
2852
  commands.registerCommand("zoomToObjects", zoomToObjects);
2852
2853
  commands.registerCommand("zoomToSelected", zoomToSelected);
2853
2854
  commands.registerCommand("autoTransformAllModelsToCentralPoint", autoTransformAllModelsToCentralPoint);
2854
- commands.registerCommand("k3DViewTop", (viewer) => setDefaultViewPosition(viewer, "k3DViewTop"));
2855
- commands.registerCommand("k3DViewBottom", (viewer) => setDefaultViewPosition(viewer, "k3DViewBottom"));
2856
- commands.registerCommand("k3DViewLeft", (viewer) => setDefaultViewPosition(viewer, "k3DViewLeft"));
2857
- commands.registerCommand("k3DViewRight", (viewer) => setDefaultViewPosition(viewer, "k3DViewRight"));
2858
- commands.registerCommand("k3DViewFront", (viewer) => setDefaultViewPosition(viewer, "k3DViewFront"));
2859
- commands.registerCommand("k3DViewBack", (viewer) => setDefaultViewPosition(viewer, "k3DViewBack"));
2860
- commands.registerCommand("k3DViewSE", (viewer) => setDefaultViewPosition(viewer, "k3DViewSE"));
2861
- commands.registerCommand("k3DViewSW", (viewer) => setDefaultViewPosition(viewer, "k3DViewSW"));
2862
- commands.registerCommand("k3DViewNE", (viewer) => setDefaultViewPosition(viewer, "k3DViewNE"));
2863
- commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
2855
+ commands.registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "k3DViewTop"));
2856
+ commands.registerCommand("bottom", (viewer) => setDefaultViewPosition(viewer, "k3DViewBottom"));
2857
+ commands.registerCommand("left", (viewer) => setDefaultViewPosition(viewer, "k3DViewLeft"));
2858
+ commands.registerCommand("right", (viewer) => setDefaultViewPosition(viewer, "k3DViewRight"));
2859
+ commands.registerCommand("front", (viewer) => setDefaultViewPosition(viewer, "k3DViewFront"));
2860
+ commands.registerCommand("back", (viewer) => setDefaultViewPosition(viewer, "k3DViewBack"));
2861
+ commands.registerCommand("se", (viewer) => setDefaultViewPosition(viewer, "k3DViewSE"));
2862
+ commands.registerCommand("sw", (viewer) => setDefaultViewPosition(viewer, "k3DViewSW"));
2863
+ commands.registerCommand("ne", (viewer) => setDefaultViewPosition(viewer, "k3DViewNE"));
2864
+ commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
2864
2865
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
2865
2866
  commands.registerCommandAlias("clearSelected", "unselect");
2866
2867
  commands.registerCommandAlias("getSnapshot", "createPreview");
2867
2868
  commands.registerCommandAlias("zoomToExtents", "zoomExtents");
2869
+ commands.registerCommandAlias("top", "k3DViewTop");
2870
+ commands.registerCommandAlias("bottom", "k3DViewBottom");
2871
+ commands.registerCommandAlias("left", "k3DViewLeft");
2872
+ commands.registerCommandAlias("right", "k3DViewRight");
2873
+ commands.registerCommandAlias("front", "k3DViewFront");
2874
+ commands.registerCommandAlias("back", "k3DViewBack");
2875
+ commands.registerCommandAlias("se", "k3DViewSE");
2876
+ commands.registerCommandAlias("sw", "k3DViewSW");
2877
+ commands.registerCommandAlias("ne", "k3DViewNE");
2878
+ commands.registerCommandAlias("nw", "k3DViewNW");
2868
2879
 
2869
2880
  class CameraComponent {
2870
2881
  constructor(viewer) {
2871
- this.optionsChange = () => {
2882
+ this.syncOptions = () => {
2872
2883
  this.switchCameraMode(this.viewer.options.cameraMode);
2873
2884
  };
2874
2885
  this.geometryEnd = () => {
@@ -2881,14 +2892,14 @@ class CameraComponent {
2881
2892
  this.viewer = viewer;
2882
2893
  this.viewer.addEventListener("databasechunk", this.geometryEnd);
2883
2894
  this.viewer.addEventListener("clear", this.geometryEnd);
2884
- this.viewer.addEventListener("optionschange", this.optionsChange);
2885
- this.viewer.addEventListener("initialize", this.optionsChange);
2895
+ this.viewer.addEventListener("optionschange", this.syncOptions);
2896
+ this.viewer.addEventListener("initialize", this.syncOptions);
2886
2897
  }
2887
2898
  dispose() {
2888
2899
  this.viewer.removeEventListener("databasechunk", this.geometryEnd);
2889
2900
  this.viewer.removeEventListener("clear", this.geometryEnd);
2890
- this.viewer.removeEventListener("optionschange", this.optionsChange);
2891
- this.viewer.removeEventListener("initialize", this.optionsChange);
2901
+ this.viewer.removeEventListener("optionschange", this.syncOptions);
2902
+ this.viewer.removeEventListener("initialize", this.syncOptions);
2892
2903
  }
2893
2904
  getCameraMode(view) {
2894
2905
  return view.perspective ? "perspective" : "orthographic";
@@ -3627,7 +3638,7 @@ class VSFXCloudStreamingLoader extends Loader {
3627
3638
  }
3628
3639
  else {
3629
3640
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
3630
- this.viewer.update();
3641
+ this.viewer.update(500);
3631
3642
  }
3632
3643
  };
3633
3644
  await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
@@ -3685,7 +3696,7 @@ class VSFXCloudPartialLoader extends Loader {
3685
3696
  }
3686
3697
  else {
3687
3698
  this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
3688
- this.viewer.update();
3699
+ this.viewer.update(500);
3689
3700
  }
3690
3701
  };
3691
3702
  const downloadResourceRange = async (dataId, requestId, ranges) => {
@@ -4060,7 +4071,6 @@ class Viewer extends EventEmitter2 {
4060
4071
  this.canvaseventlistener = (event) => this.emit(event);
4061
4072
  this._activeDragger = null;
4062
4073
  this._components = [];
4063
- this._updateDelay = 1000;
4064
4074
  this._renderNeeded = false;
4065
4075
  this._renderTime = 0;
4066
4076
  this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
@@ -4085,7 +4095,7 @@ class Viewer extends EventEmitter2 {
4085
4095
  return this._markup;
4086
4096
  }
4087
4097
  configure(params) {
4088
- this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/27.4/Visualize.js";
4098
+ this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/27.5/Visualize.js";
4089
4099
  this._crossOrigin = params.crossOrigin;
4090
4100
  return this;
4091
4101
  }
@@ -4141,8 +4151,11 @@ class Viewer extends EventEmitter2 {
4141
4151
  this.removeAllListeners();
4142
4152
  this.setActiveDragger();
4143
4153
  this._components.forEach((component) => component.dispose());
4144
- this._components = [];
4145
- this._markup.dispose();
4154
+ this._components.length = 0;
4155
+ if (this._markup) {
4156
+ this._markup.dispose();
4157
+ this._markup = undefined;
4158
+ }
4146
4159
  if (this.canvas) {
4147
4160
  this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
4148
4161
  this.canvas = undefined;
@@ -4172,13 +4185,14 @@ class Viewer extends EventEmitter2 {
4172
4185
  }
4173
4186
  update(force = false) {
4174
4187
  const time = performance.now();
4175
- force = force || time - this._renderTime >= this._updateDelay;
4188
+ if (typeof force === "number" && time - this._renderTime >= force)
4189
+ force = true;
4176
4190
  if (this._enableAutoUpdate) {
4177
4191
  this._renderNeeded = true;
4178
4192
  if (force)
4179
4193
  this.render(time);
4180
4194
  }
4181
- this.emitEvent({ type: "update", force });
4195
+ this.emitEvent({ type: "update", force: !!force });
4182
4196
  }
4183
4197
  render(time) {
4184
4198
  if (!this.visualizeJs)
@@ -4292,9 +4306,9 @@ class Viewer extends EventEmitter2 {
4292
4306
  this.clearOverlay();
4293
4307
  this.clearSelected();
4294
4308
  this.loaders.forEach((loader) => loader.dispose());
4295
- this.loaders = [];
4309
+ this.loaders.length = 0;
4296
4310
  this.models.forEach((model) => model.dispose());
4297
- this.models = [];
4311
+ this.models.length = 0;
4298
4312
  visViewer.clear();
4299
4313
  visViewer.createLocalDatabase();
4300
4314
  this.syncOptions();
@@ -4384,6 +4398,8 @@ class Viewer extends EventEmitter2 {
4384
4398
  visualStyleId.delete();
4385
4399
  activeView.delete();
4386
4400
  }
4401
+ view.setEnableCuttingPlaneFill(options.enableSectionFill, options.sectionFillColor.r, options.sectionFillColor.g, options.sectionFillColor.b);
4402
+ view.setCuttingPlaneFillPatternEnabled(options.enableSectionHatch, visLib.CuttingPlaneFillStyle.kSlantRight, options.sectionHatchColor.r, options.sectionHatchColor.g, options.sectionHatchColor.b);
4387
4403
  const params = options.enableCustomHighlight ? options : Options.defaults();
4388
4404
  const { Entry, OdTvRGBColorDef } = visLib;
4389
4405
  const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
@@ -4455,6 +4471,7 @@ class Viewer extends EventEmitter2 {
4455
4471
  const activeView = visViewer.activeView;
4456
4472
  activeView.removeCuttingPlanes();
4457
4473
  activeView.delete();
4474
+ this.emitEvent({ type: "changecuttingplanes" });
4458
4475
  this.emitEvent({ type: "clearslices" });
4459
4476
  this.update();
4460
4477
  }
@@ -4566,6 +4583,7 @@ class Viewer extends EventEmitter2 {
4566
4583
  activeView.addCuttingPlane(cuttingPlane);
4567
4584
  activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
4568
4585
  }
4586
+ this.emitEvent({ type: "changecuttingplanes" });
4569
4587
  }
4570
4588
  };
4571
4589
  const setSelection = (selection) => {