@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.
- package/README.md +26 -18
- package/dist/viewer-three.js +9963 -6031
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -2
- package/dist/viewer-three.module.js +2648 -353
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/IDisposable.d.ts +6 -0
- package/lib/Viewer/Viewer.d.ts +119 -14
- package/lib/Viewer/commands/ApplyModelTransform.d.ts +1 -0
- package/lib/Viewer/commands/ClearMarkup.d.ts +1 -0
- package/lib/Viewer/commands/ClearSelected.d.ts +1 -0
- package/lib/Viewer/commands/ClearSlices.d.ts +1 -0
- package/lib/Viewer/commands/CreatePreview.d.ts +1 -0
- package/lib/Viewer/commands/Explode.d.ts +1 -0
- package/lib/Viewer/commands/GetDefaultViewPositions.d.ts +1 -0
- package/lib/Viewer/commands/GetModels.d.ts +1 -0
- package/lib/Viewer/commands/GetSelected.d.ts +1 -0
- package/lib/Viewer/commands/HideSelected.d.ts +1 -0
- package/lib/Viewer/commands/IsolateSelected.d.ts +1 -0
- package/lib/Viewer/commands/RegenerateAll.d.ts +1 -0
- package/lib/Viewer/commands/ResetView.d.ts +1 -0
- package/lib/Viewer/commands/SelectModel.d.ts +1 -0
- package/lib/Viewer/commands/SetActiveDragger.d.ts +1 -0
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +13 -0
- package/lib/Viewer/commands/SetMarkupColor.d.ts +1 -0
- package/lib/Viewer/commands/SetSelected.d.ts +1 -0
- package/lib/Viewer/commands/ShowAll.d.ts +1 -0
- package/lib/Viewer/commands/ZoomToExtents.d.ts +1 -0
- package/lib/Viewer/commands/ZoomToObjects.d.ts +1 -0
- package/lib/Viewer/commands/ZoomToSelected.d.ts +1 -0
- package/lib/Viewer/commands/index.d.ts +22 -0
- package/lib/Viewer/components/AxesHelperComponent.d.ts +10 -0
- package/lib/Viewer/components/BackgroundComponent.d.ts +4 -4
- package/lib/Viewer/components/{DefaultCameraPositionComponent.d.ts → DefaultPositionComponent.d.ts} +3 -2
- package/lib/Viewer/components/ExtentsComponent.d.ts +8 -0
- package/lib/Viewer/components/ExtentsHelperComponent.d.ts +9 -0
- package/lib/Viewer/components/LightComponent.d.ts +5 -5
- package/lib/Viewer/components/RenderLoopComponent.d.ts +3 -3
- package/lib/Viewer/components/ResizeCanvasComponent.d.ts +2 -2
- package/lib/Viewer/components/SelectionComponent.d.ts +19 -0
- package/lib/Viewer/components/ViewPositionComponent.d.ts +31 -0
- package/lib/Viewer/components/WCSHelperComponent.d.ts +9 -0
- package/lib/Viewer/controls/WalkControls.d.ts +26 -0
- package/lib/Viewer/draggers/CuttingPlaneDragger.d.ts +17 -0
- package/lib/Viewer/draggers/CuttingPlaneXAxis.d.ts +5 -0
- package/lib/Viewer/draggers/CuttingPlaneYAxis.d.ts +5 -0
- package/lib/Viewer/draggers/CuttingPlaneZAxis.d.ts +5 -0
- package/lib/Viewer/draggers/OrbitDragger.d.ts +10 -6
- package/lib/Viewer/draggers/WalkDragger.d.ts +7 -33
- package/lib/Viewer/helpers/PlaneHelper.d.ts +11 -0
- package/lib/Viewer/helpers/WCSHelper.d.ts +10 -0
- package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +3 -3
- package/lib/index.d.ts +1 -0
- package/package.json +6 -5
- package/src/Viewer/IDisposable.ts +29 -0
- package/src/Viewer/Viewer.ts +240 -49
- package/src/Viewer/commands/ApplyModelTransform.ts +33 -0
- package/src/Viewer/commands/ClearMarkup.ts +29 -0
- package/src/Viewer/commands/ClearSelected.ts +38 -0
- package/src/Viewer/commands/ClearSlices.ts +32 -0
- package/src/Viewer/commands/CreatePreview.ts +32 -0
- package/src/Viewer/commands/Explode.ts +83 -0
- package/src/Viewer/commands/GetDefaultViewPositions.ts +31 -0
- package/src/Viewer/commands/GetModels.ts +32 -0
- package/src/Viewer/commands/GetSelected.ts +31 -0
- package/src/Viewer/commands/HideSelected.ts +40 -0
- package/src/Viewer/commands/IsolateSelected.ts +50 -0
- package/src/Viewer/commands/RegenerateAll.ts +32 -0
- package/src/Viewer/commands/ResetView.ts +41 -0
- package/src/Viewer/commands/SelectModel.ts +32 -0
- package/src/Viewer/commands/SetActiveDragger.ts +29 -0
- package/src/Viewer/commands/SetDefaultViewPosition.ts +83 -0
- package/src/Viewer/commands/SetMarkupColor.ts +30 -0
- package/src/Viewer/commands/SetSelected.ts +44 -0
- package/src/Viewer/commands/ShowAll.ts +34 -0
- package/src/Viewer/commands/ZoomToExtents.ts +47 -0
- package/src/Viewer/commands/ZoomToObjects.ts +55 -0
- package/src/Viewer/commands/ZoomToSelected.ts +51 -0
- package/src/Viewer/commands/index.ts +45 -0
- package/src/Viewer/components/AxesHelperComponent.ts +70 -0
- package/src/Viewer/components/BackgroundComponent.ts +9 -7
- package/src/Viewer/components/{DefaultCameraPositionComponent.ts → DefaultPositionComponent.ts} +11 -22
- package/src/Viewer/components/ExtentsComponent.ts +54 -0
- package/src/Viewer/components/ExtentsHelperComponent.ts +58 -0
- package/src/Viewer/components/LightComponent.ts +14 -10
- package/src/Viewer/components/RenderLoopComponent.ts +6 -6
- package/src/Viewer/components/ResizeCanvasComponent.ts +2 -2
- package/src/Viewer/components/SelectionComponent.ts +132 -0
- package/src/Viewer/components/ViewPositionComponent.ts +165 -0
- package/src/Viewer/components/WCSHelperComponent.ts +46 -0
- package/src/Viewer/controls/OrbitControls.js +1007 -0
- package/src/Viewer/controls/WalkControls.ts +222 -0
- package/src/Viewer/draggers/CuttingPlaneDragger.ts +110 -0
- package/src/Viewer/draggers/CuttingPlaneXAxis.ts +33 -0
- package/src/Viewer/draggers/CuttingPlaneYAxis.ts +33 -0
- package/src/Viewer/draggers/CuttingPlaneZAxis.ts +33 -0
- package/src/Viewer/draggers/OrbitDragger.ts +70 -23
- package/src/Viewer/draggers/PanDragger.ts +4 -3
- package/src/Viewer/draggers/WalkDragger.ts +27 -216
- package/src/Viewer/draggers/ZoomDragger.ts +4 -3
- package/src/Viewer/helpers/PlaneHelper.ts +99 -0
- package/src/Viewer/helpers/WCSHelper.ts +119 -0
- package/src/Viewer/loaders/GLTFLoadingManager.ts +6 -6
- package/src/index.ts +2 -0
- package/lib/Viewer/IComponent.d.ts +0 -3
- package/lib/Viewer/components/ObjectSelectionComponent.d.ts +0 -16
- package/lib/Viewer/draggers/ClippingPlaneDragger.d.ts +0 -17
- package/src/Viewer/IComponent.ts +0 -3
- package/src/Viewer/components/ObjectSelectionComponent.ts +0 -105
- package/src/Viewer/draggers/ClippingPlaneDragger.ts +0 -120
|
@@ -0,0 +1,44 @@
|
|
|
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 setSelected(viewer: Viewer, handles: string[] = []): void {
|
|
29
|
+
const handleSet = new Set(handles);
|
|
30
|
+
const objects = [];
|
|
31
|
+
viewer.scene.traverseVisible((child) => {
|
|
32
|
+
if (handleSet.has(child.userData?.handle)) objects.push(child);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const selection = new SelectionComponent(viewer);
|
|
36
|
+
selection.clearSelection();
|
|
37
|
+
objects.forEach((object) => selection.select(object));
|
|
38
|
+
selection.dispose();
|
|
39
|
+
|
|
40
|
+
viewer.update();
|
|
41
|
+
viewer.emitEvent({ type: "select", data: undefined, handles });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
commands("ThreeJS").registerCommand("setSelected", setSelected);
|
|
@@ -0,0 +1,34 @@
|
|
|
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 showAll(viewer: Viewer): void {
|
|
28
|
+
viewer.scene.traverse((object) => (object.visible = true));
|
|
29
|
+
|
|
30
|
+
viewer.update();
|
|
31
|
+
viewer.emitEvent({ type: "showall" });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
commands("ThreeJS").registerCommand("showAll", showAll);
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
function zoomToExtents(viewer: Viewer): void {
|
|
30
|
+
if (viewer.extents.isEmpty()) return;
|
|
31
|
+
|
|
32
|
+
const center = viewer.extents.getCenter(new Vector3());
|
|
33
|
+
const distance = viewer.extents.getBoundingSphere(new Sphere()).radius;
|
|
34
|
+
|
|
35
|
+
const delta = new Vector3(0, 0, 1);
|
|
36
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
37
|
+
delta.multiplyScalar(distance * 3);
|
|
38
|
+
|
|
39
|
+
viewer.camera.position.copy(center).add(delta);
|
|
40
|
+
viewer.target.copy(center);
|
|
41
|
+
|
|
42
|
+
viewer.update();
|
|
43
|
+
viewer.emitEvent({ type: "zoom" });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
commands("ThreeJS").registerCommand("zoomToExtents", zoomToExtents);
|
|
47
|
+
commands("ThreeJS").registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
@@ -0,0 +1,55 @@
|
|
|
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, Sphere, Vector3 } from "three";
|
|
25
|
+
|
|
26
|
+
import { commands } from "@inweb/viewer-core";
|
|
27
|
+
import type { Viewer } from "../Viewer";
|
|
28
|
+
|
|
29
|
+
function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
|
|
30
|
+
const handleSet = new Set(handles);
|
|
31
|
+
const objects = [];
|
|
32
|
+
viewer.scene.traverseVisible((child) => {
|
|
33
|
+
if (handleSet.has(child.userData?.handle)) objects.push(child);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const extents = objects.reduce((result, object) => {
|
|
37
|
+
const objectExtents = new Box3().setFromObject(object);
|
|
38
|
+
return result.isEmpty() ? result.copy(objectExtents) : result.union(objectExtents);
|
|
39
|
+
}, new Box3());
|
|
40
|
+
|
|
41
|
+
const center = extents.getCenter(new Vector3());
|
|
42
|
+
const distance = extents.getBoundingSphere(new Sphere()).radius;
|
|
43
|
+
|
|
44
|
+
const delta = new Vector3(0, 0, 1);
|
|
45
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
46
|
+
delta.multiplyScalar(distance * 3);
|
|
47
|
+
|
|
48
|
+
viewer.camera.position.copy(center).add(delta);
|
|
49
|
+
viewer.target.copy(center);
|
|
50
|
+
|
|
51
|
+
viewer.update();
|
|
52
|
+
viewer.emitEvent({ type: "zoom" });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
commands("ThreeJS").registerCommand("zoomToObjects", zoomToObjects);
|
|
@@ -0,0 +1,51 @@
|
|
|
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, Sphere, Vector3 } from "three";
|
|
25
|
+
|
|
26
|
+
import { commands } from "@inweb/viewer-core";
|
|
27
|
+
import type { Viewer } from "../Viewer";
|
|
28
|
+
|
|
29
|
+
function zoomToSelected(viewer: Viewer): void {
|
|
30
|
+
const extents = viewer.selected.reduce((result, object) => {
|
|
31
|
+
const objectExtents = new Box3().setFromObject(object);
|
|
32
|
+
return result.isEmpty() ? result.copy(objectExtents) : result.union(objectExtents);
|
|
33
|
+
}, new Box3());
|
|
34
|
+
|
|
35
|
+
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
36
|
+
|
|
37
|
+
const center = extents.getCenter(new Vector3());
|
|
38
|
+
const distance = extents.getBoundingSphere(new Sphere()).radius;
|
|
39
|
+
|
|
40
|
+
const delta = new Vector3(0, 0, 1);
|
|
41
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
42
|
+
delta.multiplyScalar(distance * 3);
|
|
43
|
+
|
|
44
|
+
viewer.camera.position.copy(center).add(delta);
|
|
45
|
+
viewer.target.copy(center);
|
|
46
|
+
|
|
47
|
+
viewer.update();
|
|
48
|
+
viewer.emitEvent({ type: "zoom" });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
commands("ThreeJS").registerCommand("zoomToSelected", zoomToSelected);
|
|
@@ -0,0 +1,45 @@
|
|
|
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 "./ApplyModelTransform";
|
|
25
|
+
import "./ClearMarkup";
|
|
26
|
+
import "./ClearSelected";
|
|
27
|
+
import "./ClearSlices";
|
|
28
|
+
import "./CreatePreview";
|
|
29
|
+
import "./Explode";
|
|
30
|
+
import "./GetDefaultViewPositions";
|
|
31
|
+
import "./GetModels";
|
|
32
|
+
import "./GetSelected";
|
|
33
|
+
import "./HideSelected";
|
|
34
|
+
import "./IsolateSelected";
|
|
35
|
+
import "./RegenerateAll";
|
|
36
|
+
import "./ResetView";
|
|
37
|
+
import "./SelectModel";
|
|
38
|
+
import "./SetActiveDragger";
|
|
39
|
+
import "./SetDefaultViewPosition";
|
|
40
|
+
import "./SetMarkupColor";
|
|
41
|
+
import "./SetSelected";
|
|
42
|
+
import "./ShowAll";
|
|
43
|
+
import "./ZoomToExtents";
|
|
44
|
+
import "./ZoomToObjects";
|
|
45
|
+
import "./ZoomToSelected";
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { AxesHelper, Vector3 } from "three";
|
|
25
|
+
|
|
26
|
+
import { IDisposable } from "../IDisposable";
|
|
27
|
+
import type { Viewer } from "../Viewer";
|
|
28
|
+
|
|
29
|
+
export class AxesHelperComponent implements IDisposable {
|
|
30
|
+
private viewer: Viewer;
|
|
31
|
+
private axesHelper1: AxesHelper;
|
|
32
|
+
private axesHelper2: AxesHelper;
|
|
33
|
+
|
|
34
|
+
constructor(viewer: Viewer) {
|
|
35
|
+
this.axesHelper1 = new AxesHelper();
|
|
36
|
+
this.axesHelper2 = new AxesHelper();
|
|
37
|
+
this.viewer = viewer;
|
|
38
|
+
this.viewer.addEventListener("geometryend", this.geometryEnd);
|
|
39
|
+
this.viewer.addEventListener("clear", this.geometryEnd);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
dispose() {
|
|
43
|
+
this.axesHelper1.removeFromParent();
|
|
44
|
+
this.axesHelper1 = undefined;
|
|
45
|
+
|
|
46
|
+
this.axesHelper2.removeFromParent();
|
|
47
|
+
this.axesHelper2 = undefined;
|
|
48
|
+
|
|
49
|
+
this.viewer.removeEventListener("geometryend", this.geometryEnd);
|
|
50
|
+
this.viewer.removeEventListener("clear", this.geometryEnd);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
geometryEnd = () => {
|
|
54
|
+
this.axesHelper1.removeFromParent();
|
|
55
|
+
this.axesHelper2.removeFromParent();
|
|
56
|
+
|
|
57
|
+
if (!this.viewer.extents.isEmpty()) {
|
|
58
|
+
const size = this.viewer.extents.getSize(new Vector3()).length();
|
|
59
|
+
const center = this.viewer.extents.getCenter(new Vector3());
|
|
60
|
+
|
|
61
|
+
this.axesHelper1 = new AxesHelper(size);
|
|
62
|
+
this.axesHelper1.position.copy(center);
|
|
63
|
+
this.viewer.helpers.add(this.axesHelper1);
|
|
64
|
+
|
|
65
|
+
this.axesHelper2 = new AxesHelper(size);
|
|
66
|
+
this.axesHelper2.position.set(0, 0, 0);
|
|
67
|
+
this.viewer.helpers.add(this.axesHelper2);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -21,23 +21,25 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import
|
|
24
|
+
import { Color, PMREMGenerator } from "three";
|
|
25
25
|
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
import { IDisposable } from "../IDisposable";
|
|
27
28
|
import type { Viewer } from "../Viewer";
|
|
28
29
|
|
|
29
|
-
export class BackgroundComponent implements
|
|
30
|
+
export class BackgroundComponent implements IDisposable {
|
|
30
31
|
protected viewer: Viewer;
|
|
31
|
-
protected backgroundColor:
|
|
32
|
+
protected backgroundColor: Color;
|
|
32
33
|
|
|
33
34
|
constructor(viewer: Viewer) {
|
|
34
35
|
this.viewer = viewer;
|
|
35
36
|
|
|
36
|
-
this.backgroundColor = new
|
|
37
|
+
this.backgroundColor = new Color(0xffffff);
|
|
37
38
|
|
|
38
39
|
const environment = new RoomEnvironment();
|
|
39
|
-
const pmremGenerator = new
|
|
40
|
+
const pmremGenerator = new PMREMGenerator(this.viewer.renderer);
|
|
40
41
|
|
|
42
|
+
this.viewer.renderer.setClearColor(this.backgroundColor);
|
|
41
43
|
this.viewer.scene.background = this.backgroundColor;
|
|
42
44
|
this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;
|
|
43
45
|
this.viewer.addEventListener("optionschange", this.syncOptions);
|
|
@@ -45,7 +47,7 @@ export class BackgroundComponent implements IComponent {
|
|
|
45
47
|
environment.dispose();
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
dispose()
|
|
50
|
+
dispose() {
|
|
49
51
|
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
50
52
|
this.viewer.scene.environment = undefined;
|
|
51
53
|
this.viewer.scene.background = undefined;
|
package/src/Viewer/components/{DefaultCameraPositionComponent.ts → DefaultPositionComponent.ts}
RENAMED
|
@@ -21,46 +21,35 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
+
import { Vector3 } from "three";
|
|
25
|
+
|
|
24
26
|
import { GeometryEndEvent } from "@inweb/viewer-core";
|
|
25
|
-
import
|
|
26
|
-
import { IComponent } from "../IComponent";
|
|
27
|
+
import { IDisposable } from "../IDisposable";
|
|
27
28
|
import type { Viewer } from "../Viewer";
|
|
28
29
|
|
|
29
|
-
export class
|
|
30
|
+
export class DefaultPositionComponent implements IDisposable {
|
|
30
31
|
protected viewer: Viewer;
|
|
32
|
+
public defaultCameraPositions: any;
|
|
31
33
|
|
|
32
34
|
constructor(viewer: Viewer) {
|
|
33
35
|
this.viewer = viewer;
|
|
34
36
|
this.viewer.addEventListener("geometryend", this.geometryEnd);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
dispose()
|
|
39
|
+
dispose() {
|
|
38
40
|
this.viewer.removeEventListener("geometryend", this.geometryEnd);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
geometryEnd = (event: GeometryEndEvent) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
scene.updateMatrixWorld();
|
|
45
|
-
|
|
46
|
-
const box = new THREE.Box3().setFromObject(scene);
|
|
47
|
-
const size = box.getSize(new THREE.Vector3()).length();
|
|
48
|
-
const center = box.getCenter(new THREE.Vector3());
|
|
49
|
-
|
|
50
|
-
scene.position.x += scene.position.x - center.x;
|
|
51
|
-
scene.position.y += scene.position.y - center.y;
|
|
52
|
-
scene.position.z += scene.position.z - center.z;
|
|
44
|
+
const box = this.viewer.extents;
|
|
45
|
+
const size = box.getSize(new Vector3()).length();
|
|
53
46
|
|
|
54
47
|
this.viewer.camera.near = size / 100;
|
|
55
48
|
this.viewer.camera.far = size * 100;
|
|
56
|
-
|
|
57
|
-
this.viewer.camera.position.copy(center);
|
|
58
|
-
this.viewer.camera.position.x += size / 2.0;
|
|
59
|
-
this.viewer.camera.position.y += size / 5.0;
|
|
60
|
-
this.viewer.camera.position.z += size / 2.0;
|
|
61
|
-
|
|
62
49
|
this.viewer.camera.updateMatrixWorld();
|
|
63
50
|
this.viewer.camera.updateProjectionMatrix();
|
|
64
|
-
|
|
51
|
+
|
|
52
|
+
// this.viewer.executeCommand("setDefaultViewPosition", "sw");
|
|
53
|
+
this.viewer.executeCommand("zoomToExtents");
|
|
65
54
|
};
|
|
66
55
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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, Vector3 } from "three";
|
|
25
|
+
|
|
26
|
+
import { IDisposable } from "../IDisposable";
|
|
27
|
+
import type { Viewer } from "../Viewer";
|
|
28
|
+
|
|
29
|
+
export class ExtentsComponent implements IDisposable {
|
|
30
|
+
private viewer: Viewer;
|
|
31
|
+
|
|
32
|
+
constructor(viewer: Viewer) {
|
|
33
|
+
this.viewer = viewer;
|
|
34
|
+
this.viewer.addEventListener("geometryend", this.syncExtents);
|
|
35
|
+
this.viewer.addEventListener("clear", this.syncExtents);
|
|
36
|
+
this.viewer.on("explode", this.syncExtents);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dispose() {
|
|
40
|
+
this.viewer.removeEventListener("geometryend", this.syncExtents);
|
|
41
|
+
this.viewer.removeEventListener("clear", this.syncExtents);
|
|
42
|
+
this.viewer.off("explode", this.syncExtents);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
syncExtents = () => {
|
|
46
|
+
const extents = this.viewer.models.reduce((result, gltf) => {
|
|
47
|
+
const modelExtents = new Box3().setFromObject(gltf.scene);
|
|
48
|
+
return result.isEmpty() ? result.copy(modelExtents) : result.union(modelExtents);
|
|
49
|
+
}, new Box3());
|
|
50
|
+
|
|
51
|
+
this.viewer.extents.copy(extents);
|
|
52
|
+
this.viewer.target.copy(extents.getCenter(new Vector3()));
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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, Box3Helper, Color } from "three";
|
|
25
|
+
|
|
26
|
+
import { IDisposable } from "../IDisposable";
|
|
27
|
+
import type { Viewer } from "../Viewer";
|
|
28
|
+
|
|
29
|
+
export class ExtentsHelperComponent implements IDisposable {
|
|
30
|
+
private viewer: Viewer;
|
|
31
|
+
private boxHelper: Box3Helper;
|
|
32
|
+
|
|
33
|
+
constructor(viewer: Viewer) {
|
|
34
|
+
this.boxHelper = new Box3Helper(new Box3());
|
|
35
|
+
this.viewer = viewer;
|
|
36
|
+
this.viewer.on("geometryend", this.geometryEnd);
|
|
37
|
+
this.viewer.on("explode", this.geometryEnd);
|
|
38
|
+
this.viewer.on("clear", this.geometryEnd);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
dispose() {
|
|
42
|
+
this.boxHelper.removeFromParent();
|
|
43
|
+
this.boxHelper = undefined;
|
|
44
|
+
|
|
45
|
+
this.viewer.off("geometryend", this.geometryEnd);
|
|
46
|
+
this.viewer.off("explode", this.geometryEnd);
|
|
47
|
+
this.viewer.off("clear", this.geometryEnd);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
geometryEnd = () => {
|
|
51
|
+
this.boxHelper.removeFromParent();
|
|
52
|
+
|
|
53
|
+
if (!this.viewer.extents.isEmpty()) {
|
|
54
|
+
this.boxHelper = new Box3Helper(this.viewer.extents, new Color(0xff0000));
|
|
55
|
+
this.viewer.helpers.add(this.boxHelper);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -21,28 +21,32 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import
|
|
25
|
-
|
|
24
|
+
import { AmbientLight, DirectionalLight } from "three";
|
|
25
|
+
|
|
26
|
+
import { IDisposable } from "../IDisposable";
|
|
26
27
|
import type { Viewer } from "../Viewer";
|
|
27
28
|
|
|
28
|
-
export class LightComponent implements
|
|
29
|
+
export class LightComponent implements IDisposable {
|
|
29
30
|
protected viewer: Viewer;
|
|
30
|
-
protected ambientLight:
|
|
31
|
-
protected
|
|
31
|
+
protected ambientLight: AmbientLight;
|
|
32
|
+
protected directionalLight: DirectionalLight;
|
|
32
33
|
|
|
33
34
|
constructor(viewer: Viewer) {
|
|
34
35
|
this.viewer = viewer;
|
|
35
36
|
|
|
36
|
-
this.ambientLight = new
|
|
37
|
+
this.ambientLight = new AmbientLight(0xffffff, 0);
|
|
37
38
|
this.viewer.camera.add(this.ambientLight);
|
|
38
39
|
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.viewer.camera.add(this.
|
|
40
|
+
this.directionalLight = new DirectionalLight(0xffffff, 1);
|
|
41
|
+
this.directionalLight.position.set(0.5, 0, 0.866); // ~60º
|
|
42
|
+
this.viewer.camera.add(this.directionalLight);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
dispose(): void {
|
|
45
46
|
this.ambientLight.removeFromParent();
|
|
46
|
-
this.
|
|
47
|
+
this.ambientLight = undefined;
|
|
48
|
+
|
|
49
|
+
this.directionalLight.removeFromParent();
|
|
50
|
+
this.directionalLight = undefined;
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -21,24 +21,24 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { IDisposable } from "../IDisposable";
|
|
25
25
|
import type { Viewer } from "../Viewer";
|
|
26
26
|
|
|
27
|
-
export class RenderLoopComponent implements
|
|
27
|
+
export class RenderLoopComponent implements IDisposable {
|
|
28
28
|
protected viewer: Viewer;
|
|
29
|
-
protected
|
|
29
|
+
protected requestId: number;
|
|
30
30
|
|
|
31
31
|
constructor(viewer: Viewer) {
|
|
32
32
|
this.viewer = viewer;
|
|
33
33
|
this.animate();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
dispose()
|
|
37
|
-
cancelAnimationFrame(this.
|
|
36
|
+
dispose() {
|
|
37
|
+
cancelAnimationFrame(this.requestId);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
animate = (time = 0) => {
|
|
41
|
-
this.
|
|
41
|
+
this.requestId = requestAnimationFrame(this.animate);
|
|
42
42
|
this.viewer.render(time);
|
|
43
43
|
};
|
|
44
44
|
}
|