@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
@@ -0,0 +1,36 @@
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 select(viewer: Viewer, handles: string | string[] = []): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ viewer.show(handles2);
31
+ viewer.selector.select(handles2);
32
+
33
+ viewer.emitEvent({ type: "select" });
34
+ viewer.emitEvent({ type: "select2" }); // @deprecated
35
+ viewer.update();
36
+ }
@@ -22,16 +22,12 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
- import type { SelectionComponent } from "../components/SelectionComponent";
26
25
 
27
26
  export function selectModel(viewer: Viewer, id: string): void {
28
- const selection = viewer.getComponent("SelectionComponent") as SelectionComponent;
29
- selection.clearSelection();
27
+ let handles = [];
30
28
 
31
- viewer.models.filter((model) => model.id === id).forEach((model) => selection.select(model.getObjects(), model));
29
+ const model = viewer.models.find((model) => model.id === id);
30
+ if (model) handles = model.getHandles();
32
31
 
33
- viewer.update();
34
-
35
- viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
36
- viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
32
+ viewer.setSelected(handles);
37
33
  }
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { Quaternion, Vector3 } from "three";
25
25
  import type { Viewer } from "../Viewer";
26
- import { zoomTo } from "./ZoomTo";
26
+ import { zoom } from "./Zoom";
27
27
 
28
28
  export const defaultViewPositions = {
29
29
  front: new Vector3(0, 0, -1),
@@ -59,5 +59,5 @@ export function setDefaultViewPosition(viewer: Viewer, position = "sw"): void {
59
59
  viewer.update();
60
60
  viewer.emit({ type: "viewposition", data: position });
61
61
 
62
- zoomTo(viewer, viewer.extents);
62
+ zoom(viewer, viewer.extents);
63
63
  }
@@ -22,18 +22,15 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
+ import { toHandles2 } from "./ToHandles2";
25
26
 
26
- export function setSelected(viewer: Viewer, handles: string[] = []): void {
27
- const handles2: string[] = [];
27
+ export function setSelected(viewer: Viewer, handles: string | string[] = []): void {
28
+ const handles2 = toHandles2(viewer, handles);
28
29
 
29
- handles.forEach((handle) => {
30
- if (handle.includes(":")) {
31
- handles2.push(handle);
32
- } else
33
- viewer.models.forEach((model) => {
34
- handles2.push(`${model.id}:${handle}`);
35
- });
36
- });
30
+ viewer.show(handles2);
31
+ viewer.selector.setSelected(handles2);
37
32
 
38
- viewer.executeCommand("setSelected2", handles2);
33
+ viewer.emitEvent({ type: "select" });
34
+ viewer.emitEvent({ type: "select2" }); // @deprecated
35
+ viewer.update();
39
36
  }
@@ -22,21 +22,10 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
- import type { SelectionComponent } from "../components/SelectionComponent";
26
25
 
27
- export function setSelected2(viewer: Viewer, handles: string[] = []): void {
28
- const selectionComponent = viewer.getComponent("SelectionComponent") as SelectionComponent;
29
- selectionComponent.clearSelection();
30
-
31
- viewer.models.forEach((model) => {
32
- const objects = model.getObjectsByHandles(handles);
33
- model.showObjects(objects);
34
- selectionComponent.select(objects, model);
35
- });
36
-
37
- viewer.update();
38
-
39
- viewer.emitEvent({ type: "show" });
40
- viewer.emitEvent({ type: "select", data: undefined, handles: viewer.getSelected() });
41
- viewer.emitEvent({ type: "select2", data: undefined, handles });
26
+ export function setSelected2(viewer: Viewer, handles2: string | string[] = []): void {
27
+ console.warn(
28
+ "setSelected2 command has been deprecated since 27.11 and will be removed in a future release, use setSelected instead"
29
+ );
30
+ viewer.executeCommand("setSelected", handles2);
42
31
  }
@@ -0,0 +1,34 @@
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 show(viewer: Viewer, handles: string | string[]): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ viewer.visibilityManager.show(handles2);
31
+
32
+ viewer.emitEvent({ type: "show" });
33
+ viewer.update();
34
+ }
@@ -24,8 +24,8 @@
24
24
  import type { Viewer } from "../Viewer";
25
25
 
26
26
  export function showAll(viewer: Viewer): void {
27
- viewer.models.forEach((model) => model.showAllObjects());
27
+ viewer.visibilityManager.showAll();
28
28
 
29
- viewer.update();
30
29
  viewer.emitEvent({ type: "showall" });
30
+ viewer.update();
31
31
  }
@@ -21,18 +21,15 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { Box3 } from "three";
25
24
  import type { Viewer } from "../Viewer";
26
- import { zoomTo } from "./ZoomTo";
27
25
 
28
- export function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
29
- const extents = new Box3();
26
+ export function toHandles(viewer: Viewer, handles2: string | string[]): string[] {
27
+ if (!Array.isArray(handles2)) handles2 = [handles2];
30
28
 
31
- viewer.models.forEach((model) => {
32
- const objects = model.getObjectsByHandles(handles);
33
- objects.forEach((object) => extents.expandByObject(object));
34
- });
35
- if (extents.isEmpty()) extents.copy(viewer.extents);
29
+ if (handles2.length === 0) return handles2;
30
+ if (!handles2[0].includes(":")) return handles2;
36
31
 
37
- zoomTo(viewer, extents);
32
+ const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
33
+
34
+ return handles;
38
35
  }
@@ -0,0 +1,43 @@
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 toHandles2(viewer: Viewer, handles: string | string[] = []): string[] {
27
+ if (!Array.isArray(handles)) handles = [handles];
28
+
29
+ if (handles.length === 0) return handles;
30
+ if (handles[0].includes(":")) return handles;
31
+
32
+ const handles2: string[] = [];
33
+ handles.forEach((handle) => {
34
+ if (handle.includes(":")) {
35
+ handles2.push(handle);
36
+ } else
37
+ viewer.models.forEach((model) => {
38
+ handles2.push(`${model.id}:${handle}`);
39
+ });
40
+ });
41
+
42
+ return handles2;
43
+ }
@@ -0,0 +1,40 @@
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 toggleSelection(viewer: Viewer, handles: string | string[] = []): void {
28
+ const handles2 = toHandles2(viewer, handles);
29
+
30
+ if (viewer.selector.selected.has(handles2[0])) {
31
+ viewer.selector.deselect(handles2);
32
+ } else {
33
+ viewer.show(handles2);
34
+ viewer.selector.select(handles2);
35
+ }
36
+
37
+ viewer.emitEvent({ type: "select" });
38
+ viewer.emitEvent({ type: "select2" }); // @deprecated
39
+ viewer.update();
40
+ }
@@ -0,0 +1,66 @@
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 { Box3, MathUtils, Vector2, Vector3 } from "three";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ export function zoom(viewer: Viewer, box: Box3): void {
28
+ if (box.isEmpty()) return;
29
+
30
+ const boxCenter = box.getCenter(new Vector3());
31
+ const boxSize = box.getSize(new Vector3()).length() || 1;
32
+
33
+ const rendererSize = viewer.renderer.getSize(new Vector2());
34
+ const aspectRatio = rendererSize.x / rendererSize.y;
35
+
36
+ const camera = viewer.camera as any;
37
+
38
+ if (camera.isPerspectiveCamera) {
39
+ const offset = new Vector3(0, 0, 1)
40
+ .applyQuaternion(camera.quaternion)
41
+ .multiplyScalar(boxSize / (2 * Math.tan(MathUtils.degToRad(camera.fov * 0.5))));
42
+
43
+ camera.position.copy(offset).add(boxCenter);
44
+ camera.updateMatrixWorld();
45
+ }
46
+ if (camera.isOrthographicCamera) {
47
+ camera.top = boxSize / 2;
48
+ camera.bottom = -boxSize / 2;
49
+ camera.left = camera.bottom * aspectRatio;
50
+ camera.right = camera.top * aspectRatio;
51
+ camera.zoom = 1;
52
+ camera.updateProjectionMatrix();
53
+
54
+ const offset = new Vector3(0, 0, 1)
55
+ .applyQuaternion(camera.quaternion)
56
+ .multiplyScalar(viewer.extents.getSize(new Vector3()).length() || 1);
57
+
58
+ camera.position.copy(offset).add(boxCenter);
59
+ camera.updateMatrixWorld();
60
+ }
61
+
62
+ viewer.target.copy(boxCenter);
63
+
64
+ viewer.update();
65
+ viewer.emitEvent({ type: "zoom" });
66
+ }
@@ -22,8 +22,8 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import type { Viewer } from "../Viewer";
25
- import { zoomTo } from "./ZoomTo";
25
+ import { zoom } from "./Zoom";
26
26
 
27
- export function zoomToExtents(viewer: Viewer): void {
28
- zoomTo(viewer, viewer.extents);
27
+ export function zoomExtents(viewer: Viewer): void {
28
+ zoom(viewer, viewer.extents);
29
29
  }
@@ -21,46 +21,20 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { Box3, MathUtils, Vector2, Vector3 } from "three";
24
+ import { Box3 } from "three";
25
25
  import type { Viewer } from "../Viewer";
26
+ import { zoom } from "./Zoom";
27
+ import { toHandles2 } from "./ToHandles2";
26
28
 
27
- export function zoomTo(viewer: Viewer, box: Box3): void {
28
- if (box.isEmpty()) return;
29
+ export function zoomTo(viewer: Viewer, handles: string | string[] = []): void {
30
+ const handles2 = toHandles2(viewer, handles);
29
31
 
30
- const boxCenter = box.getCenter(new Vector3());
31
- const boxSize = box.getSize(new Vector3()).length() || 1;
32
+ const extents = new Box3();
33
+ viewer.models.forEach((model) => {
34
+ const objects = model.getObjectsByHandles(handles2);
35
+ objects.forEach((object) => extents.expandByObject(object));
36
+ });
37
+ if (extents.isEmpty()) extents.copy(viewer.extents);
32
38
 
33
- const rendererSize = viewer.renderer.getSize(new Vector2());
34
- const aspectRatio = rendererSize.x / rendererSize.y;
35
-
36
- const camera = viewer.camera as any;
37
-
38
- if (camera.isPerspectiveCamera) {
39
- const offset = new Vector3(0, 0, 1)
40
- .applyQuaternion(camera.quaternion)
41
- .multiplyScalar(boxSize / (2 * Math.tan(MathUtils.degToRad(camera.fov * 0.5))));
42
-
43
- camera.position.copy(offset).add(boxCenter);
44
- camera.updateMatrixWorld();
45
- }
46
- if (camera.isOrthographicCamera) {
47
- camera.top = boxSize / 2;
48
- camera.bottom = -boxSize / 2;
49
- camera.left = camera.bottom * aspectRatio;
50
- camera.right = camera.top * aspectRatio;
51
- camera.zoom = 1;
52
- camera.updateProjectionMatrix();
53
-
54
- const offset = new Vector3(0, 0, 1)
55
- .applyQuaternion(camera.quaternion)
56
- .multiplyScalar(viewer.extents.getSize(new Vector3()).length() || 1);
57
-
58
- camera.position.copy(offset).add(boxCenter);
59
- camera.updateMatrixWorld();
60
- }
61
-
62
- viewer.target.copy(boxCenter);
63
-
64
- viewer.update();
65
- viewer.emitEvent({ type: "zoom" });
39
+ zoom(viewer, extents);
66
40
  }
@@ -21,15 +21,9 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { Box3 } from "three";
25
24
  import type { Viewer } from "../Viewer";
26
25
  import { zoomTo } from "./ZoomTo";
27
26
 
28
27
  export function zoomToSelected(viewer: Viewer): void {
29
- const extents = new Box3();
30
-
31
- viewer.selected.forEach((object) => extents.expandByObject(object));
32
- if (extents.isEmpty()) extents.copy(viewer.extents);
33
-
34
- zoomTo(viewer, extents);
28
+ zoomTo(viewer, viewer.getSelected(true));
35
29
  }
@@ -27,25 +27,34 @@ import { applyModelTransform } from "./ApplyModelTransform";
27
27
  import { clearMarkup } from "./ClearMarkup";
28
28
  import { clearSelected } from "./ClearSelected";
29
29
  import { clearSlices } from "./ClearSlices";
30
+ import { deselect } from "./Deselect";
30
31
  import { getSnapshot } from "./GetSnapshot";
31
32
  import { explode, collect } from "./Explode";
32
33
  import { getDefaultViewPositions } from "./GetDefaultViewPositions";
33
34
  import { getModels } from "./GetModels";
34
35
  import { getSelected } from "./GetSelected";
35
36
  import { getSelected2 } from "./GetSelected2";
37
+ import { getHidden } from "./GetHidden";
38
+ import { getIsolated } from "./GetIsolated";
39
+ import { hide } from "./Hide";
40
+ import { hideAll } from "./HideAll";
36
41
  import { hideSelected } from "./HideSelected";
42
+ import { isolate } from "./Isolate";
37
43
  import { isolateSelected } from "./IsolateSelected";
38
44
  import { regenerateAll } from "./RegenerateAll";
39
45
  import { resetView } from "./ResetView";
46
+ import { select } from "./Select";
40
47
  import { selectModel } from "./SelectModel";
41
48
  import { setActiveDragger } from "./SetActiveDragger";
42
49
  import { setDefaultViewPosition } from "./SetDefaultViewPosition";
43
50
  import { setMarkupColor } from "./SetMarkupColor";
44
51
  import { setSelected } from "./SetSelected";
45
52
  import { setSelected2 } from "./SetSelected2";
53
+ import { show } from "./Show";
46
54
  import { showAll } from "./ShowAll";
47
- import { zoomToExtents } from "./ZoomToExtents";
48
- import { zoomToObjects } from "./ZoomToObjects";
55
+ import { toggleSelection } from "./ToggleSelection";
56
+ import { zoomExtents } from "./ZoomExtents";
57
+ import { zoomTo } from "./ZoomTo";
49
58
  import { zoomToSelected } from "./ZoomToSelected";
50
59
 
51
60
  /**
@@ -83,25 +92,34 @@ commands.registerCommand("clearMarkup", clearMarkup);
83
92
  commands.registerCommand("clearSelected", clearSelected);
84
93
  commands.registerCommand("clearSlices", clearSlices);
85
94
  commands.registerCommand("collect", collect);
95
+ commands.registerCommand("deselect", deselect);
86
96
  commands.registerCommand("getSnapshot", getSnapshot);
87
97
  commands.registerCommand("explode", explode);
88
98
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
89
99
  commands.registerCommand("getModels", getModels);
90
100
  commands.registerCommand("getSelected", getSelected);
91
101
  commands.registerCommand("getSelected2", getSelected2);
102
+ commands.registerCommand("getHidden", getHidden);
103
+ commands.registerCommand("getIsolated", getIsolated);
104
+ commands.registerCommand("hide", hide);
105
+ commands.registerCommand("hideAll", hideAll);
92
106
  commands.registerCommand("hideSelected", hideSelected);
107
+ commands.registerCommand("isolate", isolate);
93
108
  commands.registerCommand("isolateSelected", isolateSelected);
94
109
  commands.registerCommand("regenerateAll", regenerateAll);
95
110
  commands.registerCommand("resetView", resetView);
111
+ commands.registerCommand("select", select);
96
112
  commands.registerCommand("selectModel", selectModel);
97
113
  commands.registerCommand("setActiveDragger", setActiveDragger);
98
114
  commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
99
115
  commands.registerCommand("setMarkupColor", setMarkupColor);
100
116
  commands.registerCommand("setSelected", setSelected);
101
117
  commands.registerCommand("setSelected2", setSelected2);
118
+ commands.registerCommand("show", show);
102
119
  commands.registerCommand("showAll", showAll);
103
- commands.registerCommand("zoomToExtents", zoomToExtents);
104
- commands.registerCommand("zoomToObjects", zoomToObjects);
120
+ commands.registerCommand("toggleSelection", toggleSelection);
121
+ commands.registerCommand("zoomExtents", zoomExtents);
122
+ commands.registerCommand("zoomTo", zoomTo);
105
123
  commands.registerCommand("zoomToSelected", zoomToSelected);
106
124
 
107
125
  commands.registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "top"));
@@ -118,7 +136,8 @@ commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"))
118
136
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
119
137
  commands.registerCommandAlias("clearSelected", "unselect");
120
138
  commands.registerCommandAlias("getSnapshot", "createPreview");
121
- commands.registerCommandAlias("zoomToExtents", "zoomExtents");
139
+ commands.registerCommandAlias("zoomExtents", "zoomToExtents");
140
+ commands.registerCommandAlias("zoomTo", "zoomToObjects");
122
141
 
123
142
  commands.registerCommandAlias("top", "k3DViewTop");
124
143
  commands.registerCommandAlias("bottom", "k3DViewBottom");
@@ -37,9 +37,10 @@ import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
37
37
 
38
38
  import { IComponent, Options, ResizeEvent } from "@inweb/viewer-core";
39
39
  import { Viewer } from "../Viewer";
40
+ import { IHighlighter } from "../models/Highlighter.types";
40
41
  import { HighlighterUtils } from "./HighlighterUtils";
41
42
 
42
- export class HighlighterComponent implements IComponent {
43
+ export class HighlighterComponent implements IComponent, IHighlighter {
43
44
  protected viewer: Viewer;
44
45
  public renderTarget: WebGLRenderTarget;
45
46
  public facesMaterial: MeshPhongMaterial;
@@ -74,10 +75,7 @@ export class HighlighterComponent implements IComponent {
74
75
  this.viewer.removeEventListener("resize", this.viewerResize);
75
76
  }
76
77
 
77
- highlight(objects: Object3D | Object3D[]) {
78
- const { edgesVisibility } = this.viewer.options;
79
-
80
- if (!Array.isArray(objects)) objects = [objects];
78
+ highlightObjects(objects: Object3D[]): void {
81
79
  if (objects.length === 0) return;
82
80
 
83
81
  objects
@@ -93,7 +91,7 @@ export class HighlighterComponent implements IComponent {
93
91
  : HighlighterUtils.fromNonIndexedLine(positions, object.isLineSegments);
94
92
 
95
93
  const wireframe = new Wireframe(lineGeometry, this.lineGlowMaterial);
96
- wireframe.visible = edgesVisibility;
94
+ wireframe.visible = this.viewer.options.edgesVisibility;
97
95
  wireframe.userData.isHighlightWireframe = true;
98
96
 
99
97
  object.add(wireframe);
@@ -106,7 +104,7 @@ export class HighlighterComponent implements IComponent {
106
104
  const lineGeometry = new LineSegmentsGeometry().fromEdgesGeometry(edgesGeometry);
107
105
 
108
106
  const wireframe = new Wireframe(lineGeometry, this.edgesMaterial);
109
- wireframe.visible = edgesVisibility;
107
+ wireframe.visible = this.viewer.options.edgesVisibility;
110
108
  wireframe.userData.isHighlightWireframe = true;
111
109
 
112
110
  object.add(wireframe);
@@ -118,15 +116,16 @@ export class HighlighterComponent implements IComponent {
118
116
  });
119
117
  }
120
118
 
121
- unhighlight(objects: Object3D | Object3D[]) {
122
- if (!Array.isArray(objects)) objects = [objects];
119
+ unhighlightObjects(objects: Object3D[]): void {
123
120
  if (objects.length === 0) return;
124
121
 
125
122
  objects.forEach((object: any) => {
126
123
  if (!object.userData.isHighlighted) return;
127
124
 
128
125
  object.material = object.userData.originalMaterial;
129
- object.userData.highlightWireframe.removeFromParent();
126
+
127
+ object.userData.highlightWireframe?.removeFromParent();
128
+ object.userData.highlightWireframe?.geometry?.dispose();
130
129
 
131
130
  delete object.userData.isHighlighted;
132
131
  delete object.userData.originalMaterial;
@@ -196,8 +195,11 @@ export class HighlighterComponent implements IComponent {
196
195
  this.lineGlowMaterial.depthTest = !edgesOverlap;
197
196
  this.lineGlowMaterial.depthWrite = !edgesOverlap;
198
197
 
199
- this.viewer.selected.forEach((selected) => {
200
- const wireframe = selected.userData.highlightWireframe;
198
+ const handles = this.viewer.getSelected(true);
199
+ const objects = this.viewer.models.flatMap((model) => model.getObjectsByHandles(handles));
200
+
201
+ objects.forEach((object) => {
202
+ const wireframe = object.userData.highlightWireframe;
201
203
  if (wireframe) wireframe.visible = edgesVisibility;
202
204
  });
203
205
  }