@inweb/viewer-three 25.9.8 → 25.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 (110) hide show
  1. package/README.md +26 -18
  2. package/dist/viewer-three.js +9963 -6031
  3. package/dist/viewer-three.js.map +1 -1
  4. package/dist/viewer-three.min.js +3 -2
  5. package/dist/viewer-three.module.js +2648 -353
  6. package/dist/viewer-three.module.js.map +1 -1
  7. package/lib/Viewer/IDisposable.d.ts +6 -0
  8. package/lib/Viewer/Viewer.d.ts +119 -14
  9. package/lib/Viewer/commands/ApplyModelTransform.d.ts +1 -0
  10. package/lib/Viewer/commands/ClearMarkup.d.ts +1 -0
  11. package/lib/Viewer/commands/ClearSelected.d.ts +1 -0
  12. package/lib/Viewer/commands/ClearSlices.d.ts +1 -0
  13. package/lib/Viewer/commands/CreatePreview.d.ts +1 -0
  14. package/lib/Viewer/commands/Explode.d.ts +1 -0
  15. package/lib/Viewer/commands/GetDefaultViewPositions.d.ts +1 -0
  16. package/lib/Viewer/commands/GetModels.d.ts +1 -0
  17. package/lib/Viewer/commands/GetSelected.d.ts +1 -0
  18. package/lib/Viewer/commands/HideSelected.d.ts +1 -0
  19. package/lib/Viewer/commands/IsolateSelected.d.ts +1 -0
  20. package/lib/Viewer/commands/RegenerateAll.d.ts +1 -0
  21. package/lib/Viewer/commands/ResetView.d.ts +1 -0
  22. package/lib/Viewer/commands/SelectModel.d.ts +1 -0
  23. package/lib/Viewer/commands/SetActiveDragger.d.ts +1 -0
  24. package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +13 -0
  25. package/lib/Viewer/commands/SetMarkupColor.d.ts +1 -0
  26. package/lib/Viewer/commands/SetSelected.d.ts +1 -0
  27. package/lib/Viewer/commands/ShowAll.d.ts +1 -0
  28. package/lib/Viewer/commands/ZoomToExtents.d.ts +1 -0
  29. package/lib/Viewer/commands/ZoomToObjects.d.ts +1 -0
  30. package/lib/Viewer/commands/ZoomToSelected.d.ts +1 -0
  31. package/lib/Viewer/commands/index.d.ts +22 -0
  32. package/lib/Viewer/components/AxesHelperComponent.d.ts +10 -0
  33. package/lib/Viewer/components/BackgroundComponent.d.ts +4 -4
  34. package/lib/Viewer/components/{DefaultCameraPositionComponent.d.ts → DefaultPositionComponent.d.ts} +3 -2
  35. package/lib/Viewer/components/ExtentsComponent.d.ts +8 -0
  36. package/lib/Viewer/components/ExtentsHelperComponent.d.ts +9 -0
  37. package/lib/Viewer/components/LightComponent.d.ts +5 -5
  38. package/lib/Viewer/components/RenderLoopComponent.d.ts +3 -3
  39. package/lib/Viewer/components/ResizeCanvasComponent.d.ts +2 -2
  40. package/lib/Viewer/components/SelectionComponent.d.ts +19 -0
  41. package/lib/Viewer/components/ViewPositionComponent.d.ts +31 -0
  42. package/lib/Viewer/components/WCSHelperComponent.d.ts +9 -0
  43. package/lib/Viewer/controls/WalkControls.d.ts +26 -0
  44. package/lib/Viewer/draggers/CuttingPlaneDragger.d.ts +17 -0
  45. package/lib/Viewer/draggers/CuttingPlaneXAxis.d.ts +5 -0
  46. package/lib/Viewer/draggers/CuttingPlaneYAxis.d.ts +5 -0
  47. package/lib/Viewer/draggers/CuttingPlaneZAxis.d.ts +5 -0
  48. package/lib/Viewer/draggers/OrbitDragger.d.ts +10 -6
  49. package/lib/Viewer/draggers/WalkDragger.d.ts +7 -33
  50. package/lib/Viewer/helpers/PlaneHelper.d.ts +11 -0
  51. package/lib/Viewer/helpers/WCSHelper.d.ts +10 -0
  52. package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +3 -3
  53. package/lib/index.d.ts +1 -0
  54. package/package.json +6 -5
  55. package/src/Viewer/IDisposable.ts +29 -0
  56. package/src/Viewer/Viewer.ts +240 -49
  57. package/src/Viewer/commands/ApplyModelTransform.ts +33 -0
  58. package/src/Viewer/commands/ClearMarkup.ts +29 -0
  59. package/src/Viewer/commands/ClearSelected.ts +38 -0
  60. package/src/Viewer/commands/ClearSlices.ts +32 -0
  61. package/src/Viewer/commands/CreatePreview.ts +32 -0
  62. package/src/Viewer/commands/Explode.ts +83 -0
  63. package/src/Viewer/commands/GetDefaultViewPositions.ts +31 -0
  64. package/src/Viewer/commands/GetModels.ts +32 -0
  65. package/src/Viewer/commands/GetSelected.ts +31 -0
  66. package/src/Viewer/commands/HideSelected.ts +40 -0
  67. package/src/Viewer/commands/IsolateSelected.ts +50 -0
  68. package/src/Viewer/commands/RegenerateAll.ts +32 -0
  69. package/src/Viewer/commands/ResetView.ts +41 -0
  70. package/src/Viewer/commands/SelectModel.ts +32 -0
  71. package/src/Viewer/commands/SetActiveDragger.ts +29 -0
  72. package/src/Viewer/commands/SetDefaultViewPosition.ts +83 -0
  73. package/src/Viewer/commands/SetMarkupColor.ts +30 -0
  74. package/src/Viewer/commands/SetSelected.ts +44 -0
  75. package/src/Viewer/commands/ShowAll.ts +34 -0
  76. package/src/Viewer/commands/ZoomToExtents.ts +47 -0
  77. package/src/Viewer/commands/ZoomToObjects.ts +55 -0
  78. package/src/Viewer/commands/ZoomToSelected.ts +51 -0
  79. package/src/Viewer/commands/index.ts +45 -0
  80. package/src/Viewer/components/AxesHelperComponent.ts +70 -0
  81. package/src/Viewer/components/BackgroundComponent.ts +9 -7
  82. package/src/Viewer/components/{DefaultCameraPositionComponent.ts → DefaultPositionComponent.ts} +11 -22
  83. package/src/Viewer/components/ExtentsComponent.ts +54 -0
  84. package/src/Viewer/components/ExtentsHelperComponent.ts +58 -0
  85. package/src/Viewer/components/LightComponent.ts +14 -10
  86. package/src/Viewer/components/RenderLoopComponent.ts +6 -6
  87. package/src/Viewer/components/ResizeCanvasComponent.ts +2 -2
  88. package/src/Viewer/components/SelectionComponent.ts +132 -0
  89. package/src/Viewer/components/ViewPositionComponent.ts +165 -0
  90. package/src/Viewer/components/WCSHelperComponent.ts +46 -0
  91. package/src/Viewer/controls/OrbitControls.js +1007 -0
  92. package/src/Viewer/controls/WalkControls.ts +222 -0
  93. package/src/Viewer/draggers/CuttingPlaneDragger.ts +110 -0
  94. package/src/Viewer/draggers/CuttingPlaneXAxis.ts +33 -0
  95. package/src/Viewer/draggers/CuttingPlaneYAxis.ts +33 -0
  96. package/src/Viewer/draggers/CuttingPlaneZAxis.ts +33 -0
  97. package/src/Viewer/draggers/OrbitDragger.ts +70 -23
  98. package/src/Viewer/draggers/PanDragger.ts +4 -3
  99. package/src/Viewer/draggers/WalkDragger.ts +27 -216
  100. package/src/Viewer/draggers/ZoomDragger.ts +4 -3
  101. package/src/Viewer/helpers/PlaneHelper.ts +99 -0
  102. package/src/Viewer/helpers/WCSHelper.ts +119 -0
  103. package/src/Viewer/loaders/GLTFLoadingManager.ts +6 -6
  104. package/src/index.ts +2 -0
  105. package/lib/Viewer/IComponent.d.ts +0 -3
  106. package/lib/Viewer/components/ObjectSelectionComponent.d.ts +0 -16
  107. package/lib/Viewer/draggers/ClippingPlaneDragger.d.ts +0 -17
  108. package/src/Viewer/IComponent.ts +0 -3
  109. package/src/Viewer/components/ObjectSelectionComponent.ts +0 -105
  110. package/src/Viewer/draggers/ClippingPlaneDragger.ts +0 -120
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function clearSlices(viewer: Viewer) {
28
+ viewer.renderer.clippingPlanes = [];
29
+ viewer.update();
30
+ }
31
+
32
+ commands("ThreeJS").registerCommand("clearSlices", clearSlices);
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function createPreview(viewer: Viewer, type = "image/jpeg", encoderOptions = 0.25): string {
28
+ viewer.update(true);
29
+ return viewer.canvas.toDataURL(type, encoderOptions);
30
+ }
31
+
32
+ commands("ThreeJS").registerCommand("createPreview", createPreview);
@@ -0,0 +1,83 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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, Object3D, Vector3 } from "three";
25
+
26
+ import { commands } from "@inweb/viewer-core";
27
+ import type { Viewer } from "../Viewer";
28
+
29
+ function calcObjectDepth(object: Object3D, depth: number) {
30
+ let res = depth;
31
+ object.children.forEach((x) => {
32
+ const objectDepth = calcObjectDepth(x, depth + 1);
33
+ if (res < objectDepth) res = objectDepth;
34
+ });
35
+
36
+ (object as any).originalPosition = object.position.clone();
37
+
38
+ return res;
39
+ }
40
+
41
+ function explodeScene(scene: Object3D, scale = 0) {
42
+ scale /= 100;
43
+
44
+ if (!(scene as any).maxDepth) (scene as any).maxDepth = calcObjectDepth(scene, 1);
45
+ const maxDepth = (scene as any).maxDepth;
46
+
47
+ let explodeDepth = scale * (maxDepth - 1) + 1;
48
+ if (maxDepth === 1) explodeDepth = 1;
49
+
50
+ function explodeObject(object: Object3D, depth: number, parentCenter: Vector3, parentOffset: Vector3) {
51
+ const objectBox = new Box3().setFromObject(object);
52
+ const objectCenter = objectBox.getCenter(new Vector3());
53
+
54
+ const objectOffset = parentOffset.clone();
55
+ if (depth > 0 && depth <= explodeDepth) {
56
+ const offset = objectCenter.clone().sub(parentCenter).multiplyScalar(scale);
57
+ objectOffset.add(offset);
58
+ }
59
+
60
+ object.children.forEach((object) => explodeObject(object, depth + 1, objectCenter, objectOffset));
61
+
62
+ const originalPosition = (object as any).originalPosition;
63
+ object.position.copy(originalPosition);
64
+ if (scale > 0) {
65
+ const direction = objectCenter.sub(parentCenter).normalize();
66
+ object.position.add(direction.add(objectOffset));
67
+ }
68
+ }
69
+
70
+ const sceneExtents = new Box3().setFromObject(scene);
71
+ const sceneCenter = sceneExtents.getCenter(new Vector3());
72
+ explodeObject(scene, 0, sceneCenter, new Vector3(0, 0, 0));
73
+ }
74
+
75
+ function explode(viewer: Viewer, index = 0): void {
76
+ viewer.models.forEach((gltf) => explodeScene(gltf.scene, index));
77
+
78
+ viewer.update();
79
+ viewer.emitEvent({ type: "explode", data: index });
80
+ }
81
+
82
+ commands("ThreeJS").registerCommand("explode", explode);
83
+ commands("ThreeJS").registerCommand("collect", (viewer: any) => explode(viewer, 0));
@@ -0,0 +1,31 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import { defaultViewPositions } from "./SetDefaultViewPosition";
26
+
27
+ function getDefaultViewPositions(): string[] {
28
+ return Object.keys(defaultViewPositions);
29
+ }
30
+
31
+ commands("ThreeJS").registerCommand("getDefaultViewPositions", getDefaultViewPositions);
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function getModels(viewer: Viewer): string[] {
28
+ const handles: string[] = viewer.models.map((model) => model.userData.handle || "").filter((handle) => handle);
29
+ return handles;
30
+ }
31
+
32
+ commands("ThreeJS").registerCommand("getModels", getModels);
@@ -0,0 +1,31 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function getSelected(viewer: Viewer): string[] {
28
+ return viewer.selected.map((object) => object.userData?.handle).filter((handle) => handle);
29
+ }
30
+
31
+ commands("ThreeJS").registerCommand("getSelected", getSelected);
@@ -0,0 +1,40 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+ import { SelectionComponent } from "../components/SelectionComponent";
27
+
28
+ function hideSelected(viewer: Viewer): void {
29
+ viewer.selected.forEach((object) => (object.visible = false));
30
+
31
+ const selection = new SelectionComponent(viewer);
32
+ selection.clearSelection();
33
+ selection.dispose();
34
+
35
+ viewer.update();
36
+ viewer.emitEvent({ type: "hide" });
37
+ viewer.emitEvent({ type: "select", data: undefined, handles: [] });
38
+ }
39
+
40
+ commands("ThreeJS").registerCommand("hideSelected", hideSelected);
@@ -0,0 +1,50 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { Object3D } from "three";
25
+
26
+ import { commands } from "@inweb/viewer-core";
27
+ import type { Viewer } from "../Viewer";
28
+
29
+ function isolateSelected(viewer: Viewer): void {
30
+ const selectedSet = new Set(viewer.selected);
31
+
32
+ function isolateObject(object: Object3D, depth: number): boolean {
33
+ let canBeIsolated = true;
34
+ object.children.forEach((object) => {
35
+ if (selectedSet.has(object)) canBeIsolated = false;
36
+ else isolateObject(object, depth + 1);
37
+ });
38
+
39
+ if (canBeIsolated && depth > 0) object.visible = false;
40
+
41
+ return canBeIsolated;
42
+ }
43
+
44
+ isolateObject(viewer.scene, 0);
45
+
46
+ viewer.update();
47
+ viewer.emitEvent({ type: "isolate" });
48
+ }
49
+
50
+ commands("ThreeJS").registerCommand("isolateSelected", isolateSelected);
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function regenerateAll(viewer: Viewer): void {
28
+ console.warn("regenerateAll not implemented");
29
+ viewer.emit({ type: "regenerateall" });
30
+ }
31
+
32
+ commands("ThreeJS").registerCommand("regenerateAll", regenerateAll);
@@ -0,0 +1,41 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function resetView(viewer: Viewer): void {
28
+ viewer.executeCommand("setActiveDragger", "");
29
+ viewer.executeCommand("clearSlices");
30
+ viewer.executeCommand("clearOverlay");
31
+ viewer.executeCommand("setMarkupColor");
32
+ viewer.executeCommand("clearSelected");
33
+ viewer.executeCommand("showAll");
34
+ viewer.executeCommand("explode", 0);
35
+ viewer.executeCommand("zoomToExtents", true);
36
+ viewer.executeCommand("k3DViewSW");
37
+
38
+ viewer.emit({ type: "resetview" });
39
+ }
40
+
41
+ commands("ThreeJS").registerCommand("resetView", resetView);
@@ -0,0 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ function selectModel(viewer: Viewer, handle: string): void {
28
+ console.warn("selectModel not implemented");
29
+ viewer.emit({ type: "select", data: [] });
30
+ }
31
+
32
+ commands("ThreeJS").registerCommand("selectModel", selectModel);
@@ -0,0 +1,29 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ commands("ThreeJS").registerCommand("setActiveDragger", (viewer: Viewer, dragger = "") => {
28
+ viewer.setActiveDragger(dragger);
29
+ });
@@ -0,0 +1,83 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { Sphere, Vector3 } from "three";
25
+
26
+ import { commands } from "@inweb/viewer-core";
27
+ import type { Viewer } from "../Viewer";
28
+
29
+ export const defaultViewPositions = {
30
+ top: new Vector3(0, 0, 1),
31
+ bottom: new Vector3(0, 0, -1),
32
+ left: new Vector3(-1, 0, 0),
33
+ right: new Vector3(1, 0, 0),
34
+ front: new Vector3(0, 1, 0),
35
+ back: new Vector3(0, -1, 0),
36
+ sw: new Vector3(-0.5, -0.5, 1.0).normalize(),
37
+ se: new Vector3(0.5, -0.5, 1.0).normalize(),
38
+ ne: new Vector3(0.5, 0.5, 1.0).normalize(),
39
+ nw: new Vector3(-0.5, 0.5, 1.0).normalize(),
40
+ };
41
+
42
+ function setDefaultViewPosition(viewer: Viewer, position: string): void {
43
+ const direction = defaultViewPositions[position] || defaultViewPositions["sw"];
44
+
45
+ const camera = viewer.camera;
46
+ const center = viewer.extents.getCenter(new Vector3());
47
+ const sphere = viewer.extents.getBoundingSphere(new Sphere());
48
+ const offset = new Vector3().copy(direction).multiplyScalar(sphere.radius);
49
+
50
+ camera.position.copy(center);
51
+ camera.position.add(offset);
52
+ camera.rotation.set(0, 0, 0);
53
+ camera.lookAt(center);
54
+ camera.updateProjectionMatrix();
55
+
56
+ viewer.update();
57
+ viewer.emit({ type: "viewposition", data: position });
58
+
59
+ viewer.executeCommand("zoomToExtents");
60
+ }
61
+
62
+ commands("ThreeJS").registerCommand("setDefaultViewPosition", setDefaultViewPosition);
63
+ commands("ThreeJS").registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "top"));
64
+ commands("ThreeJS").registerCommand("bottom", (viewer) => setDefaultViewPosition(viewer, "bottom"));
65
+ commands("ThreeJS").registerCommand("left", (viewer) => setDefaultViewPosition(viewer, "left"));
66
+ commands("ThreeJS").registerCommand("right", (viewer) => setDefaultViewPosition(viewer, "right"));
67
+ commands("ThreeJS").registerCommand("front", (viewer) => setDefaultViewPosition(viewer, "front"));
68
+ commands("ThreeJS").registerCommand("back", (viewer) => setDefaultViewPosition(viewer, "back"));
69
+ commands("ThreeJS").registerCommand("sw", (viewer) => setDefaultViewPosition(viewer, "sw"));
70
+ commands("ThreeJS").registerCommand("se", (viewer) => setDefaultViewPosition(viewer, "se"));
71
+ commands("ThreeJS").registerCommand("ne", (viewer) => setDefaultViewPosition(viewer, "ne"));
72
+ commands("ThreeJS").registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"));
73
+
74
+ commands("ThreeJS").registerCommandAlias("top", "k3DViewTop");
75
+ commands("ThreeJS").registerCommandAlias("bottom", "k3DViewBottom");
76
+ commands("ThreeJS").registerCommandAlias("left", "k3DViewLeft");
77
+ commands("ThreeJS").registerCommandAlias("right", "k3DViewRight");
78
+ commands("ThreeJS").registerCommandAlias("front", "k3DViewFront");
79
+ commands("ThreeJS").registerCommandAlias("back", "k3DViewBack");
80
+ commands("ThreeJS").registerCommandAlias("se", "k3DViewSE");
81
+ commands("ThreeJS").registerCommandAlias("sw", "k3DViewSW");
82
+ commands("ThreeJS").registerCommandAlias("ne", "k3DViewNE");
83
+ commands("ThreeJS").registerCommandAlias("nw", "k3DViewNW");
@@ -0,0 +1,30 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { commands } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ commands("ThreeJS").registerCommand("setMarkupColor", (viewer: Viewer, r = 255, g = 0, b = 0) => {
28
+ console.warn("setMarkupColor not implemented");
29
+ // viewer.setMarkupColor(r, g, b);
30
+ });