@inweb/viewer-three 27.10.0 → 27.11.0

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.
Files changed (105) hide show
  1. package/dist/extensions/loaders/GLTFCloudLoader.js +4 -2
  2. package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
  3. package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
  4. package/dist/extensions/loaders/GLTFCloudLoader.module.js +4 -2
  5. package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +1 -1
  6. package/dist/extensions/loaders/GLTFFileLoader.js +2 -0
  7. package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
  8. package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
  9. package/dist/extensions/loaders/GLTFFileLoader.module.js +2 -0
  10. package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -1
  11. package/dist/extensions/loaders/IFCXLoader.js +6 -2
  12. package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
  13. package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
  14. package/dist/extensions/loaders/IFCXLoader.module.js +6 -2
  15. package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -1
  16. package/dist/extensions/loaders/PotreeLoader.js +2 -0
  17. package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
  18. package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
  19. package/dist/extensions/loaders/PotreeLoader.module.js +2 -0
  20. package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -1
  21. package/dist/viewer-three.js +880 -258
  22. package/dist/viewer-three.js.map +1 -1
  23. package/dist/viewer-three.min.js +4 -4
  24. package/dist/viewer-three.module.js +765 -258
  25. package/dist/viewer-three.module.js.map +1 -1
  26. package/extensions/loaders/GLTFCloudLoader.ts +5 -3
  27. package/extensions/loaders/GLTFFileLoader.ts +2 -0
  28. package/extensions/loaders/IFCX/IFCXCloudLoader.ts +5 -3
  29. package/extensions/loaders/IFCX/IFCXFileLoader.ts +2 -0
  30. package/extensions/loaders/Potree/PotreeFileLoader.ts +2 -0
  31. package/lib/Viewer/Viewer.d.ts +27 -9
  32. package/lib/Viewer/commands/Deselect.d.ts +2 -0
  33. package/lib/Viewer/commands/Explode.d.ts +1 -1
  34. package/lib/Viewer/commands/GetHidden.d.ts +2 -0
  35. package/lib/Viewer/commands/GetIsolated.d.ts +2 -0
  36. package/lib/Viewer/commands/GetSelected.d.ts +1 -1
  37. package/lib/Viewer/commands/Hide.d.ts +2 -0
  38. package/lib/Viewer/commands/HideAll.d.ts +2 -0
  39. package/lib/Viewer/commands/Isolate.d.ts +2 -0
  40. package/lib/Viewer/commands/Select.d.ts +2 -0
  41. package/lib/Viewer/commands/SetSelected.d.ts +1 -1
  42. package/lib/Viewer/commands/SetSelected2.d.ts +1 -1
  43. package/lib/Viewer/commands/Show.d.ts +2 -0
  44. package/lib/Viewer/commands/ToHandles.d.ts +2 -0
  45. package/lib/Viewer/commands/ToHandles2.d.ts +2 -0
  46. package/lib/Viewer/commands/ToggleSelection.d.ts +2 -0
  47. package/lib/Viewer/commands/Zoom.d.ts +3 -0
  48. package/lib/Viewer/commands/ZoomExtents.d.ts +2 -0
  49. package/lib/Viewer/commands/ZoomTo.d.ts +1 -2
  50. package/lib/Viewer/components/HighlighterComponent.d.ts +4 -3
  51. package/lib/Viewer/components/SelectionComponent.d.ts +1 -9
  52. package/lib/Viewer/components/index.d.ts +1 -1
  53. package/lib/Viewer/draggers/index.d.ts +2 -2
  54. package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +10 -8
  55. package/lib/Viewer/loaders/GLTFCloudDynamicLoader.d.ts +5 -1
  56. package/lib/Viewer/loaders/GLTFFileDynamicLoader.d.ts +5 -1
  57. package/lib/Viewer/loaders/index.d.ts +5 -1
  58. package/lib/Viewer/models/Highlighter.types.d.ts +5 -0
  59. package/lib/Viewer/models/ModelImpl.d.ts +14 -10
  60. package/lib/Viewer/models/ModelImpl.types.d.ts +6 -10
  61. package/package.json +5 -5
  62. package/src/Viewer/Viewer.ts +131 -26
  63. package/src/Viewer/commands/ClearSelected.ts +3 -6
  64. package/src/Viewer/commands/Deselect.ts +35 -0
  65. package/src/Viewer/commands/Explode.ts +4 -3
  66. package/src/Viewer/commands/GetHidden.ts +30 -0
  67. package/src/Viewer/commands/GetIsolated.ts +30 -0
  68. package/src/Viewer/commands/GetSelected.ts +4 -4
  69. package/src/Viewer/commands/GetSelected2.ts +4 -7
  70. package/src/Viewer/commands/Hide.ts +35 -0
  71. package/src/Viewer/commands/HideAll.ts +32 -0
  72. package/src/Viewer/commands/HideSelected.ts +1 -11
  73. package/src/Viewer/commands/Isolate.ts +41 -0
  74. package/src/Viewer/commands/IsolateSelected.ts +1 -4
  75. package/src/Viewer/commands/ResetView.ts +1 -1
  76. package/src/Viewer/commands/Select.ts +36 -0
  77. package/src/Viewer/commands/SelectModel.ts +4 -8
  78. package/src/Viewer/commands/SetDefaultViewPosition.ts +2 -2
  79. package/src/Viewer/commands/SetSelected.ts +8 -11
  80. package/src/Viewer/commands/SetSelected2.ts +5 -16
  81. package/src/Viewer/commands/Show.ts +34 -0
  82. package/src/Viewer/commands/ShowAll.ts +2 -2
  83. package/src/Viewer/commands/{ZoomToObjects.ts → ToHandles.ts} +7 -10
  84. package/src/Viewer/commands/ToHandles2.ts +43 -0
  85. package/src/Viewer/commands/ToggleSelection.ts +40 -0
  86. package/src/Viewer/commands/Zoom.ts +66 -0
  87. package/src/Viewer/commands/{ZoomToExtents.ts → ZoomExtents.ts} +3 -3
  88. package/src/Viewer/commands/ZoomTo.ts +12 -38
  89. package/src/Viewer/commands/ZoomToSelected.ts +1 -7
  90. package/src/Viewer/commands/index.ts +24 -5
  91. package/src/Viewer/components/HighlighterComponent.ts +14 -12
  92. package/src/Viewer/components/SelectionComponent.ts +12 -76
  93. package/src/Viewer/components/index.ts +1 -1
  94. package/src/Viewer/draggers/OrbitDragger.ts +2 -2
  95. package/src/Viewer/draggers/index.ts +2 -2
  96. package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +429 -2
  97. package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +26 -35
  98. package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +33 -3
  99. package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +32 -2
  100. package/src/Viewer/loaders/index.ts +5 -1
  101. package/src/Viewer/models/Highlighter.types.ts +30 -0
  102. package/src/Viewer/models/ModelImpl.ts +68 -57
  103. package/src/Viewer/models/ModelImpl.types.ts +8 -17
  104. package/lib/Viewer/commands/ZoomToExtents.d.ts +0 -2
  105. package/lib/Viewer/commands/ZoomToObjects.d.ts +0 -2
@@ -26,7 +26,6 @@ import {
26
26
  Group,
27
27
  LinearSRGBColorSpace,
28
28
  // LinearToneMapping,
29
- Object3D,
30
29
  OrthographicCamera,
31
30
  PerspectiveCamera,
32
31
  Plane,
@@ -63,9 +62,12 @@ import {
63
62
  IPoint,
64
63
  IViewer,
65
64
  IViewpoint,
65
+ IVisibility,
66
66
  Options,
67
67
  OptionsEventMap,
68
+ Selector,
68
69
  ViewerEventMap,
70
+ VisibilityManager,
69
71
  } from "@inweb/viewer-core";
70
72
  import { IMarkup, IWorldTransform, Markup } from "@inweb/markup";
71
73
 
@@ -74,6 +76,7 @@ import { commands } from "./commands";
74
76
  import { components } from "./components";
75
77
  import { loaders } from "./loaders";
76
78
  import { IModelImpl } from "./models/ModelImpl.types";
79
+ import { toHandles } from "./commands/ToHandles";
77
80
 
78
81
  /**
79
82
  * 3D viewer powered by {@link https://threejs.org/ | Three.js}.
@@ -102,13 +105,16 @@ export class Viewer
102
105
  public ssaaRenderPass: SSAARenderPass | undefined;
103
106
  public outputPass: OutputPass | undefined;
104
107
  public composer: EffectComposer | undefined;
105
- public selected: Object3D[];
108
+
109
+ public selector: Selector;
110
+ public visibilityManager: VisibilityManager;
111
+ public explodeScale: number;
112
+ public clippingPlanes: Plane[];
106
113
  public extents: Box3;
107
114
  public target: Vector3;
108
- public clippingPlanes: Plane[];
109
115
 
110
116
  private _activeDragger: IDragger | null;
111
- private _components: IComponent[];
117
+ private _components: Map<string, IComponent>;
112
118
 
113
119
  private _renderNeeded: boolean;
114
120
  private _renderTime: DOMHighResTimeStamp;
@@ -131,13 +137,15 @@ export class Viewer
131
137
  this.canvasEvents = CANVAS_EVENTS.slice();
132
138
  this.canvaseventlistener = (event: Event) => this.emit(event);
133
139
 
134
- this.selected = [];
140
+ this.selector = new Selector(this.models);
141
+ this.visibilityManager = new VisibilityManager(this.models);
142
+ this.explodeScale = 0;
143
+ this.clippingPlanes = [];
135
144
  this.extents = new Box3();
136
145
  this.target = new Vector3(0, 0, 0);
137
- this.clippingPlanes = [];
138
146
 
139
147
  this._activeDragger = null;
140
- this._components = [];
148
+ this._components = new Map();
141
149
 
142
150
  this._renderNeeded = false;
143
151
  this._renderTime = 0;
@@ -227,7 +235,7 @@ export class Viewer
227
235
 
228
236
  for (const name of components.getComponents().keys()) {
229
237
  const component = components.createComponent(name, this);
230
- if (component) this._components.push(component);
238
+ if (component) this._components.set(name, component);
231
239
  }
232
240
 
233
241
  this.syncOptions();
@@ -257,7 +265,7 @@ export class Viewer
257
265
  this.setActiveDragger();
258
266
 
259
267
  this._components.forEach((component: IComponent) => component.dispose());
260
- this._components.length = 0;
268
+ this._components.clear();
261
269
 
262
270
  this._markup.dispose();
263
271
 
@@ -317,7 +325,7 @@ export class Viewer
317
325
 
318
326
  update(force: boolean | number = false): void {
319
327
  const time = performance.now();
320
- if (typeof force === "number" && time - this._renderTime >= force) force = true;
328
+ if (typeof force === "number") force = time - this._renderTime >= force;
321
329
 
322
330
  this._renderNeeded = true;
323
331
  if (force) this.render(time);
@@ -400,11 +408,15 @@ export class Viewer
400
408
  * @param params.mode - File opening mode. Can be one of:
401
409
  *
402
410
  * - `file` - Single file mode. Unloads an open file and opens a new one. This is default mode.
403
- * - `assembly` - Assembly mode. Appends a file to an already open file.
411
+ * - `assembly` - Multi-model mode. Appends a file to an already open file.
412
+ *
413
+ * @param params.modelId - Unique model ID in the multi-model scene. Used as a model prefix when
414
+ * selecting, hiding or isolating objects. Must not contain the ":" (colon). Required when loading a
415
+ * file as `ArrayBuffer` or `Data URL`. Default value depends on the `FileSource`:
416
+ *
417
+ * - `file ID` - when loading a file from Open Cloud Server.
418
+ * - `file name` - when loading from local File or URL.
404
419
  *
405
- * @param params.modelId - Unique model ID in the assembly (multi-model scene). Used as a model prefix
406
- * when selecting objects (see {@link getSelected2}). Must not contain the ":" (colon). Required when
407
- * loading a file as `ArrayBuffer` or `Data URL`.
408
420
  * @param params.requestHeader - The
409
421
  * {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
410
422
  * request.
@@ -461,6 +473,7 @@ export class Viewer
461
473
 
462
474
  const loader: ILoader | null = loaders.createLoader(this, model, format);
463
475
  if (!loader) throw new Error(`Format not supported (${format})`);
476
+
464
477
  this.loaders.push(loader);
465
478
 
466
479
  this.emitEvent({ type: "geometrystart", file, model });
@@ -567,8 +580,8 @@ export class Viewer
567
580
  this.update();
568
581
  }
569
582
 
570
- getSelected(): string[] {
571
- return this.executeCommand("getSelected");
583
+ getSelected(multimodel?: boolean): string[] {
584
+ return this.executeCommand("getSelected", multimodel);
572
585
  }
573
586
 
574
587
  getSelected2(): string[] {
@@ -583,22 +596,70 @@ export class Viewer
583
596
  this.executeCommand("setSelected2", handles);
584
597
  }
585
598
 
599
+ select(handles: string | string[]): void {
600
+ this.executeCommand("select", handles);
601
+ }
602
+
603
+ deselect(handles: string | string[]): void {
604
+ this.executeCommand("deselect", handles);
605
+ }
606
+
607
+ toggleSelection(handles: string | string[]): void {
608
+ this.executeCommand("toggleSelection", handles);
609
+ }
610
+
586
611
  clearSelected(): void {
587
612
  this.executeCommand("clearSelected");
588
613
  }
589
614
 
615
+ getHidden(multimodel?: boolean): string[] {
616
+ return this.executeCommand("getHidden", multimodel);
617
+ }
618
+
619
+ getIsolated(multimodel?: boolean): string[] {
620
+ return this.executeCommand("getIsolated", multimodel);
621
+ }
622
+
623
+ hide(handle: string | string[]): void {
624
+ this.executeCommand("hide", handle);
625
+ }
626
+
590
627
  hideSelected(): void {
591
628
  this.executeCommand("hideSelected");
592
629
  }
593
630
 
631
+ hideAll(): void {
632
+ this.executeCommand("hideAll");
633
+ }
634
+
635
+ isolate(handle: string | string[]): void {
636
+ this.executeCommand("isolate", handle);
637
+ }
638
+
594
639
  isolateSelected(): void {
595
640
  this.executeCommand("isolateSelected");
596
641
  }
597
642
 
643
+ show(handle: string | string[]): void {
644
+ this.executeCommand("show", handle);
645
+ }
646
+
598
647
  showAll(): void {
599
648
  this.executeCommand("showAll");
600
649
  }
601
650
 
651
+ zoomExtents(): void {
652
+ this.executeCommand("zoomExtents");
653
+ }
654
+
655
+ zoomTo(handles: string | string[]): void {
656
+ this.executeCommand("zoomTo", handles);
657
+ }
658
+
659
+ zoomToSelected(): void {
660
+ this.executeCommand("zoomToSelected");
661
+ }
662
+
602
663
  explode(index = 0): void {
603
664
  this.executeCommand("explode", index);
604
665
  }
@@ -646,7 +707,7 @@ export class Viewer
646
707
  }
647
708
 
648
709
  getComponent(name: string): IComponent | null {
649
- return this._components.find((component) => component.name === name) || null;
710
+ return this._components.get(name) || null;
650
711
  }
651
712
 
652
713
  drawViewpoint(viewpoint: IViewpoint): void {
@@ -728,7 +789,26 @@ export class Viewer
728
789
  };
729
790
 
730
791
  const setSelection = (selection: IEntity[]) => {
731
- if (selection) this.setSelected(selection.map((component) => component.handle));
792
+ if (selection) {
793
+ this.setSelected(selection.map(({ handle }) => handle));
794
+ }
795
+ };
796
+
797
+ const setVisibility = (visibility: IVisibility) => {
798
+ if (visibility && visibility.exceptions)
799
+ if (visibility.default_visibility) {
800
+ this.hide(visibility.exceptions.map(({ handle }) => handle));
801
+ } else {
802
+ this.isolate(visibility.exceptions.map(({ handle }) => handle));
803
+ }
804
+ };
805
+
806
+ const setExplodeScale = (scale: number) => {
807
+ if (scale > 0) this.explode(scale);
808
+ };
809
+
810
+ const setCameraTarget = (target: IPoint) => {
811
+ if (target) this.target = getVector3FromPoint3d(target);
732
812
  };
733
813
 
734
814
  const draggerName = this._activeDragger?.name;
@@ -737,18 +817,19 @@ export class Viewer
737
817
  this.clearSlices();
738
818
  this.clearOverlay();
739
819
  this.clearSelected();
740
-
741
820
  this.showAll();
742
821
  this.explode();
743
822
 
744
823
  setOrthogonalCamera(viewpoint.orthogonal_camera);
745
824
  setPerspectiveCamera(viewpoint.perspective_camera);
746
825
  setClippingPlanes(viewpoint.clipping_planes);
826
+ setVisibility(viewpoint.custom_fields?.visibility2 || viewpoint.visibility);
747
827
  setSelection(viewpoint.custom_fields?.selection2 || viewpoint.selection);
828
+ setExplodeScale(viewpoint.custom_fields?.explodeScale);
748
829
 
749
- this._markup.setViewpoint(viewpoint);
830
+ setCameraTarget(viewpoint.custom_fields?.camera_target);
750
831
 
751
- this.target.copy(getVector3FromPoint3d(viewpoint.custom_fields?.camera_target ?? this.target));
832
+ this.markup.setViewpoint(viewpoint);
752
833
 
753
834
  this.syncOverlay();
754
835
  this.setActiveDragger(draggerName);
@@ -799,11 +880,31 @@ export class Viewer
799
880
  };
800
881
 
801
882
  const getSelection = (): IEntity[] => {
802
- return this.getSelected().map((handle) => ({ handle }));
883
+ const selected2 = Array.from(this.selector.selected);
884
+ const selected = toHandles(this, selected2);
885
+ return selected.map((handle) => ({ handle }));
803
886
  };
804
887
 
805
888
  const getSelection2 = (): IEntity[] => {
806
- return this.getSelected2().map((handle) => ({ handle }));
889
+ const selected2 = Array.from(this.selector.selected);
890
+ return selected2.map((handle) => ({ handle }));
891
+ };
892
+
893
+ const getVisibility = (): IVisibility => {
894
+ const exceptions2 = Array.from(this.visibilityManager.exceptions);
895
+ const exceptions = toHandles(this, exceptions2);
896
+ return {
897
+ default_visibility: this.visibilityManager.defaultVisible,
898
+ exceptions: exceptions.map((handle) => ({ handle })),
899
+ };
900
+ };
901
+
902
+ const getVisibility2 = (): IVisibility => {
903
+ const exceptions = Array.from(this.visibilityManager.exceptions);
904
+ return {
905
+ default_visibility: this.visibilityManager.defaultVisible,
906
+ exceptions: exceptions.map((handle) => ({ handle })),
907
+ };
807
908
  };
808
909
 
809
910
  const viewpoint: IViewpoint = { custom_fields: {} };
@@ -812,13 +913,17 @@ export class Viewer
812
913
  viewpoint.perspective_camera = getPerspectiveCamera();
813
914
  viewpoint.clipping_planes = getClippingPlanes();
814
915
  viewpoint.selection = getSelection();
916
+ viewpoint.visibility = getVisibility();
815
917
  viewpoint.description = new Date().toDateString();
816
918
  viewpoint.snapshot = { data: this.getSnapshot() };
817
919
 
818
- this._markup.getViewpoint(viewpoint);
819
-
820
- viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
821
920
  viewpoint.custom_fields.selection2 = getSelection2();
921
+ viewpoint.custom_fields.visibility2 = getVisibility2();
922
+ viewpoint.custom_fields.explodeScale = this.explodeScale;
923
+ viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
924
+ viewpoint.custom_fields.files = this.models.map((model) => model.id);
925
+
926
+ this.markup.getViewpoint(viewpoint);
822
927
 
823
928
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
824
929
 
@@ -22,14 +22,11 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
- import type { SelectionComponent } from "../components/SelectionComponent";
26
25
 
27
26
  export function clearSelected(viewer: Viewer): void {
28
- const selection = viewer.getComponent("SelectionComponent") as SelectionComponent;
29
- selection.clearSelection();
27
+ viewer.selector.clearSelected();
30
28
 
29
+ viewer.emitEvent({ type: "select" });
30
+ viewer.emitEvent({ type: "select2" }); // @deprecated
31
31
  viewer.update();
32
-
33
- viewer.emitEvent({ type: "select", handles: [] });
34
- viewer.emitEvent({ type: "select2", handles: [] });
35
32
  }
@@ -0,0 +1,35 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+ import { toHandles2 } from "./ToHandles2";
26
+
27
+ export function deselect(viewer: Viewer, handles: string | string[] = []): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ viewer.selector.deselect(handles2);
31
+
32
+ viewer.emitEvent({ type: "select" });
33
+ viewer.emitEvent({ type: "select2" }); // @deprecated
34
+ viewer.update();
35
+ }
@@ -23,11 +23,12 @@
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
25
 
26
- export function explode(viewer: Viewer, index = 0): void {
27
- viewer.models.forEach((model) => model.explode(index));
26
+ export function explode(viewer: Viewer, scale = 0): void {
27
+ viewer.models.forEach((model) => model.explode(scale));
28
+ viewer.explodeScale = scale;
28
29
 
29
30
  viewer.update();
30
- viewer.emitEvent({ type: "explode", data: index });
31
+ viewer.emitEvent({ type: "explode", data: scale });
31
32
  }
32
33
 
33
34
  export function collect(viewer: Viewer) {
@@ -0,0 +1,30 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+ import { toHandles } from "./ToHandles";
26
+
27
+ export function getHidden(viewer: Viewer, multimodel = false): string[] {
28
+ const handles2 = Array.from(viewer.visibilityManager.hidden);
29
+ return multimodel ? handles2 : toHandles(viewer, handles2);
30
+ }
@@ -0,0 +1,30 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+ import { toHandles } from "./ToHandles";
26
+
27
+ export function getIsolated(viewer: Viewer, multimodel = false): string[] {
28
+ const handles2 = Array.from(viewer.visibilityManager.isolated);
29
+ return multimodel ? handles2 : toHandles(viewer, handles2);
30
+ }
@@ -22,9 +22,9 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
+ import { toHandles } from "./ToHandles";
25
26
 
26
- export function getSelected(viewer: Viewer): string[] {
27
- const handles2 = viewer.executeCommand("getSelected2");
28
- const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
29
- return handles;
27
+ export function getSelected(viewer: Viewer, multimodel = false): string[] {
28
+ const handles2 = Array.from(viewer.selector.selected);
29
+ return multimodel ? handles2 : toHandles(viewer, handles2);
30
30
  }
@@ -24,11 +24,8 @@
24
24
  import type { Viewer } from "../Viewer";
25
25
 
26
26
  export function getSelected2(viewer: Viewer): string[] {
27
- const handles2: string[][] = [];
28
-
29
- viewer.models.forEach((model) => {
30
- handles2.push(model.getHandlesByObjects(viewer.selected));
31
- });
32
-
33
- return handles2.flat();
27
+ console.warn(
28
+ "getSelected2 command has been deprecated since 27.11 and will be removed in a future release, use getSelected instead"
29
+ );
30
+ return viewer.executeCommand("getSelected", true);
34
31
  }
@@ -0,0 +1,35 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance ("the Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+ import { toHandles2 } from "./ToHandles2";
26
+
27
+ export function hide(viewer: Viewer, handles: string | string[]): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ viewer.deselect(handles2);
31
+ viewer.visibilityManager.hide(handles2);
32
+
33
+ viewer.emitEvent({ type: "hide" });
34
+ viewer.update();
35
+ }
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance ("the Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+
26
+ export function hideAll(viewer: Viewer): void {
27
+ viewer.clearSelected();
28
+ viewer.visibilityManager.hideAll();
29
+
30
+ viewer.emitEvent({ type: "hideall" });
31
+ viewer.update();
32
+ }
@@ -22,17 +22,7 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
- import type { SelectionComponent } from "../components/SelectionComponent";
26
25
 
27
26
  export function hideSelected(viewer: Viewer): void {
28
- viewer.models.forEach((model) => model.hideObjects(viewer.selected));
29
-
30
- const selection = viewer.getComponent("SelectionComponent") as SelectionComponent;
31
- selection.clearSelection();
32
-
33
- viewer.update();
34
-
35
- viewer.emitEvent({ type: "hide" });
36
- viewer.emitEvent({ type: "select", handles: [] });
37
- viewer.emitEvent({ type: "select2", handles: [] });
27
+ viewer.hide(viewer.getSelected(true));
38
28
  }
@@ -0,0 +1,41 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, Open Design Alliance ("the Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import type { Viewer } from "../Viewer";
25
+ import { toHandles2 } from "./ToHandles2";
26
+
27
+ export function isolate(viewer: Viewer, handles: string | string[]): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ const handlesSet = new Set(handles2);
31
+ const toDeselect = [];
32
+ for (const handle of viewer.selector.selected) {
33
+ if (!handlesSet.has(handle)) toDeselect.push(handle);
34
+ }
35
+
36
+ viewer.deselect(toDeselect);
37
+ viewer.visibilityManager.isolate(handles2);
38
+
39
+ viewer.emitEvent({ type: "isolate" });
40
+ viewer.update();
41
+ }
@@ -24,8 +24,5 @@
24
24
  import type { Viewer } from "../Viewer";
25
25
 
26
26
  export function isolateSelected(viewer: Viewer): void {
27
- viewer.models.forEach((model) => model.isolateObjects(viewer.selected));
28
-
29
- viewer.update();
30
- viewer.emitEvent({ type: "isolate" });
27
+ viewer.isolate(viewer.getSelected(true));
31
28
  }
@@ -31,7 +31,7 @@ export function resetView(viewer: Viewer): void {
31
31
  viewer.executeCommand("clearSelected");
32
32
  viewer.executeCommand("showAll");
33
33
  viewer.executeCommand("explode", 0);
34
- viewer.executeCommand("zoomToExtents", true);
34
+ viewer.executeCommand("zoomExtents");
35
35
 
36
36
  viewer.emit({ type: "resetview" });
37
37
  }