@inweb/viewer-three 25.12.0 → 26.1.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/dist/viewer-three.js +44826 -44145
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -3
- package/dist/viewer-three.module.js +1571 -1444
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +4 -4
- package/lib/Viewer/commands/ApplyModelTransform.d.ts +3 -1
- package/lib/Viewer/commands/ClearMarkup.d.ts +2 -1
- package/lib/Viewer/commands/ClearSelected.d.ts +2 -1
- package/lib/Viewer/commands/ClearSlices.d.ts +2 -1
- package/lib/Viewer/commands/CreatePreview.d.ts +2 -1
- package/lib/Viewer/commands/Explode.d.ts +3 -1
- package/lib/Viewer/commands/GetDefaultViewPositions.d.ts +1 -1
- package/lib/Viewer/commands/GetModels.d.ts +2 -1
- package/lib/Viewer/commands/GetSelected.d.ts +2 -1
- package/lib/Viewer/commands/HideSelected.d.ts +2 -1
- package/lib/Viewer/commands/IsolateSelected.d.ts +2 -1
- package/lib/Viewer/commands/RegenerateAll.d.ts +2 -1
- package/lib/Viewer/commands/ResetView.d.ts +2 -1
- package/lib/Viewer/commands/SelectModel.d.ts +2 -1
- package/lib/Viewer/commands/SetActiveDragger.d.ts +2 -1
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +2 -0
- package/lib/Viewer/commands/SetMarkupColor.d.ts +2 -1
- package/lib/Viewer/commands/SetSelected.d.ts +2 -1
- package/lib/Viewer/commands/ShowAll.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToExtents.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToObjects.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToSelected.d.ts +2 -1
- package/lib/Viewer/commands/index.d.ts +22 -22
- package/lib/Viewer/components/AxesHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/BackgroundComponent.d.ts +2 -2
- package/lib/Viewer/components/DefaultPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/ExtentsComponent.d.ts +2 -2
- package/lib/Viewer/components/ExtentsHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/LightComponent.d.ts +2 -2
- package/lib/Viewer/components/RenderLoopComponent.d.ts +2 -2
- package/lib/Viewer/components/ResizeCanvasComponent.d.ts +2 -2
- package/lib/Viewer/components/SelectionComponent.d.ts +2 -2
- package/lib/Viewer/components/ViewPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/WCSHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/index.d.ts +40 -0
- package/lib/Viewer/draggers/OrbitDragger.d.ts +2 -2
- package/lib/Viewer/draggers/WalkDragger.d.ts +2 -1
- package/lib/Viewer/draggers/index.d.ts +39 -0
- package/lib/index.d.ts +4 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +37 -68
- package/src/Viewer/commands/ApplyModelTransform.ts +2 -6
- package/src/Viewer/commands/ClearMarkup.ts +3 -3
- package/src/Viewer/commands/ClearSelected.ts +1 -5
- package/src/Viewer/commands/ClearSlices.ts +3 -2
- package/src/Viewer/commands/CreatePreview.ts +1 -4
- package/src/Viewer/commands/Explode.ts +4 -5
- package/src/Viewer/commands/GetDefaultViewPositions.ts +1 -4
- package/src/Viewer/commands/GetModels.ts +2 -6
- package/src/Viewer/commands/GetSelected.ts +1 -4
- package/src/Viewer/commands/HideSelected.ts +1 -4
- package/src/Viewer/commands/IsolateSelected.ts +1 -5
- package/src/Viewer/commands/RegenerateAll.ts +1 -5
- package/src/Viewer/commands/ResetView.ts +1 -4
- package/src/Viewer/commands/SelectModel.ts +1 -4
- package/src/Viewer/commands/SetActiveDragger.ts +2 -3
- package/src/Viewer/commands/SetDefaultViewPosition.ts +1 -26
- package/src/Viewer/commands/SetMarkupColor.ts +3 -5
- package/src/Viewer/commands/SetSelected.ts +1 -4
- package/src/Viewer/commands/ShowAll.ts +1 -4
- package/src/Viewer/commands/ZoomToExtents.ts +1 -6
- package/src/Viewer/commands/ZoomToObjects.ts +1 -5
- package/src/Viewer/commands/ZoomToSelected.ts +1 -5
- package/src/Viewer/commands/index.ts +98 -22
- package/src/Viewer/components/AxesHelperComponent.ts +2 -2
- package/src/Viewer/components/BackgroundComponent.ts +2 -2
- package/src/Viewer/components/DefaultPositionComponent.ts +2 -3
- package/src/Viewer/components/ExtentsComponent.ts +2 -2
- package/src/Viewer/components/ExtentsHelperComponent.ts +2 -2
- package/src/Viewer/components/LightComponent.ts +2 -2
- package/src/Viewer/components/RenderLoopComponent.ts +2 -2
- package/src/Viewer/components/ResizeCanvasComponent.ts +2 -2
- package/src/Viewer/components/SelectionComponent.ts +2 -2
- package/src/Viewer/components/ViewPositionComponent.ts +2 -3
- package/src/Viewer/components/WCSHelperComponent.ts +2 -2
- package/src/Viewer/components/index.ts +91 -0
- package/src/Viewer/draggers/OrbitDragger.ts +3 -2
- package/src/Viewer/draggers/WalkDragger.ts +2 -1
- package/src/Viewer/draggers/index.ts +83 -0
- package/src/index.ts +5 -2
- package/lib/Viewer/IDisposable.d.ts +0 -6
- package/src/Viewer/IDisposable.ts +0 -29
|
@@ -21,25 +21,101 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import "
|
|
25
|
-
|
|
26
|
-
import "./
|
|
27
|
-
import "./
|
|
28
|
-
import "./
|
|
29
|
-
import "./
|
|
30
|
-
import "./
|
|
31
|
-
import "./
|
|
32
|
-
import "./
|
|
33
|
-
import "./
|
|
34
|
-
import "./
|
|
35
|
-
import "./
|
|
36
|
-
import "./
|
|
37
|
-
import "./
|
|
38
|
-
import "./
|
|
39
|
-
import "./
|
|
40
|
-
import "./
|
|
41
|
-
import "./
|
|
42
|
-
import "./
|
|
43
|
-
import "./
|
|
44
|
-
import "./
|
|
45
|
-
import "./
|
|
24
|
+
import { ICommandsRegistry, commandsRegistry } from "@inweb/viewer-core";
|
|
25
|
+
|
|
26
|
+
import { applyModelTransform } from "./ApplyModelTransform";
|
|
27
|
+
import { clearMarkup } from "./ClearMarkup";
|
|
28
|
+
import { clearSelected } from "./ClearSelected";
|
|
29
|
+
import { clearSlices } from "./ClearSlices";
|
|
30
|
+
import { createPreview } from "./CreatePreview";
|
|
31
|
+
import { explode, collect } from "./Explode";
|
|
32
|
+
import { getDefaultViewPositions } from "./GetDefaultViewPositions";
|
|
33
|
+
import { getModels } from "./GetModels";
|
|
34
|
+
import { getSelected } from "./GetSelected";
|
|
35
|
+
import { hideSelected } from "./HideSelected";
|
|
36
|
+
import { isolateSelected } from "./IsolateSelected";
|
|
37
|
+
import { regenerateAll } from "./RegenerateAll";
|
|
38
|
+
import { resetView } from "./ResetView";
|
|
39
|
+
import { selectModel } from "./SelectModel";
|
|
40
|
+
import { setActiveDragger } from "./SetActiveDragger";
|
|
41
|
+
import { setDefaultViewPosition } from "./SetDefaultViewPosition";
|
|
42
|
+
import { setMarkupColor } from "./SetMarkupColor";
|
|
43
|
+
import { setSelected } from "./SetSelected";
|
|
44
|
+
import { showAll } from "./ShowAll";
|
|
45
|
+
import { zoomToExtents } from "./ZoomToExtents";
|
|
46
|
+
import { zoomToObjects } from "./ZoomToObjects";
|
|
47
|
+
import { zoomToSelected } from "./ZoomToSelected";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A commands registry. Use this registry to register custom commands.
|
|
51
|
+
*
|
|
52
|
+
* To implement custom command:
|
|
53
|
+
*
|
|
54
|
+
* 1. Define a command handler with a first `viewer` parameter.
|
|
55
|
+
* 2. Register command handler in the commands registry by calling the {@link commands.registerCommand}.
|
|
56
|
+
*
|
|
57
|
+
* @example <caption>Implementing a custom command.</caption>
|
|
58
|
+
* import { commands, Viewer } from "@inweb/viewer-three";
|
|
59
|
+
*
|
|
60
|
+
* function commandHandler(viewer: Viewer, name = "world"): void {
|
|
61
|
+
* console.log(`Hello ${name}!!!`);
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* commands.registerCommand("sayHello", commandHandler);
|
|
65
|
+
*
|
|
66
|
+
* @example <caption>Calling a custom command.</caption>
|
|
67
|
+
* viewer.executeCommand("sayHello", "user");
|
|
68
|
+
*/
|
|
69
|
+
export const commands: ICommandsRegistry = commandsRegistry("threejs");
|
|
70
|
+
|
|
71
|
+
// build-in commands
|
|
72
|
+
|
|
73
|
+
commands.registerCommand("applyModelTransform", applyModelTransform);
|
|
74
|
+
commands.registerCommand("clearMarkup", clearMarkup);
|
|
75
|
+
commands.registerCommand("clearSelected", clearSelected);
|
|
76
|
+
commands.registerCommand("clearSlices", clearSlices);
|
|
77
|
+
commands.registerCommand("createPreview", createPreview);
|
|
78
|
+
commands.registerCommand("explode", explode);
|
|
79
|
+
commands.registerCommand("collect", collect);
|
|
80
|
+
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
81
|
+
commands.registerCommand("getModels", getModels);
|
|
82
|
+
commands.registerCommand("getSelected", getSelected);
|
|
83
|
+
commands.registerCommand("hideSelected", hideSelected);
|
|
84
|
+
commands.registerCommand("isolateSelected", isolateSelected);
|
|
85
|
+
commands.registerCommand("regenerateAll", regenerateAll);
|
|
86
|
+
commands.registerCommand("resetView", resetView);
|
|
87
|
+
commands.registerCommand("selectModel", selectModel);
|
|
88
|
+
commands.registerCommand("setActiveDragger", setActiveDragger);
|
|
89
|
+
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
90
|
+
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
91
|
+
commands.registerCommand("setSelected", setSelected);
|
|
92
|
+
commands.registerCommand("showAll", showAll);
|
|
93
|
+
commands.registerCommand("zoomToExtents", zoomToExtents);
|
|
94
|
+
commands.registerCommand("zoomToObjects", zoomToObjects);
|
|
95
|
+
commands.registerCommand("zoomToSelected", zoomToSelected);
|
|
96
|
+
|
|
97
|
+
commands.registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "top"));
|
|
98
|
+
commands.registerCommand("bottom", (viewer) => setDefaultViewPosition(viewer, "bottom"));
|
|
99
|
+
commands.registerCommand("left", (viewer) => setDefaultViewPosition(viewer, "left"));
|
|
100
|
+
commands.registerCommand("right", (viewer) => setDefaultViewPosition(viewer, "right"));
|
|
101
|
+
commands.registerCommand("front", (viewer) => setDefaultViewPosition(viewer, "front"));
|
|
102
|
+
commands.registerCommand("back", (viewer) => setDefaultViewPosition(viewer, "back"));
|
|
103
|
+
commands.registerCommand("sw", (viewer) => setDefaultViewPosition(viewer, "sw"));
|
|
104
|
+
commands.registerCommand("se", (viewer) => setDefaultViewPosition(viewer, "se"));
|
|
105
|
+
commands.registerCommand("ne", (viewer) => setDefaultViewPosition(viewer, "ne"));
|
|
106
|
+
commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"));
|
|
107
|
+
|
|
108
|
+
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
109
|
+
commands.registerCommandAlias("clearSelected", "unselect");
|
|
110
|
+
commands.registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
111
|
+
|
|
112
|
+
commands.registerCommandAlias("top", "k3DViewTop");
|
|
113
|
+
commands.registerCommandAlias("bottom", "k3DViewBottom");
|
|
114
|
+
commands.registerCommandAlias("left", "k3DViewLeft");
|
|
115
|
+
commands.registerCommandAlias("right", "k3DViewRight");
|
|
116
|
+
commands.registerCommandAlias("front", "k3DViewFront");
|
|
117
|
+
commands.registerCommandAlias("back", "k3DViewBack");
|
|
118
|
+
commands.registerCommandAlias("se", "k3DViewSE");
|
|
119
|
+
commands.registerCommandAlias("sw", "k3DViewSW");
|
|
120
|
+
commands.registerCommandAlias("ne", "k3DViewNE");
|
|
121
|
+
commands.registerCommandAlias("nw", "k3DViewNW");
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { AxesHelper, Vector3 } from "three";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
|
|
29
|
-
export class AxesHelperComponent implements
|
|
29
|
+
export class AxesHelperComponent implements IComponent {
|
|
30
30
|
private viewer: Viewer;
|
|
31
31
|
private axesHelper1: AxesHelper;
|
|
32
32
|
private axesHelper2: AxesHelper;
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
import { Color, PMREMGenerator } from "three";
|
|
25
25
|
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
28
28
|
import type { Viewer } from "../Viewer";
|
|
29
29
|
|
|
30
|
-
export class BackgroundComponent implements
|
|
30
|
+
export class BackgroundComponent implements IComponent {
|
|
31
31
|
protected viewer: Viewer;
|
|
32
32
|
protected backgroundColor: Color;
|
|
33
33
|
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { Vector3 } from "three";
|
|
25
25
|
|
|
26
|
-
import { GeometryEndEvent } from "@inweb/viewer-core";
|
|
27
|
-
import { IDisposable } from "../IDisposable";
|
|
26
|
+
import { GeometryEndEvent, IComponent } from "@inweb/viewer-core";
|
|
28
27
|
import type { Viewer } from "../Viewer";
|
|
29
28
|
|
|
30
|
-
export class DefaultPositionComponent implements
|
|
29
|
+
export class DefaultPositionComponent implements IComponent {
|
|
31
30
|
protected viewer: Viewer;
|
|
32
31
|
public defaultCameraPositions: any;
|
|
33
32
|
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { Box3, Vector3 } from "three";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
|
|
29
|
-
export class ExtentsComponent implements
|
|
29
|
+
export class ExtentsComponent implements IComponent {
|
|
30
30
|
private viewer: Viewer;
|
|
31
31
|
|
|
32
32
|
constructor(viewer: Viewer) {
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { Box3, Box3Helper, Color } from "three";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
|
|
29
|
-
export class ExtentsHelperComponent implements
|
|
29
|
+
export class ExtentsHelperComponent implements IComponent {
|
|
30
30
|
private viewer: Viewer;
|
|
31
31
|
private boxHelper: Box3Helper;
|
|
32
32
|
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { AmbientLight, DirectionalLight } from "three";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
|
|
29
|
-
export class LightComponent implements
|
|
29
|
+
export class LightComponent implements IComponent {
|
|
30
30
|
protected viewer: Viewer;
|
|
31
31
|
protected ambientLight: AmbientLight;
|
|
32
32
|
protected directionalLight: DirectionalLight;
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
25
25
|
import type { Viewer } from "../Viewer";
|
|
26
26
|
|
|
27
|
-
export class RenderLoopComponent implements
|
|
27
|
+
export class RenderLoopComponent implements IComponent {
|
|
28
28
|
protected viewer: Viewer;
|
|
29
29
|
protected requestId: number;
|
|
30
30
|
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
25
25
|
import type { Viewer } from "../Viewer";
|
|
26
26
|
|
|
27
|
-
export class ResizeCanvasComponent implements
|
|
27
|
+
export class ResizeCanvasComponent implements IComponent {
|
|
28
28
|
protected viewer: Viewer;
|
|
29
29
|
protected resizeObserver: ResizeObserver;
|
|
30
30
|
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
import { Intersection, MeshBasicMaterial, Object3D, Raycaster, Vector2 } from "three";
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
|
|
29
|
-
export class SelectionComponent implements
|
|
29
|
+
export class SelectionComponent implements IComponent {
|
|
30
30
|
protected viewer: Viewer;
|
|
31
31
|
protected raycaster: Raycaster;
|
|
32
32
|
protected downPosition: Vector2;
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { Euler, Quaternion, Object3D, Vector3 } from "three";
|
|
25
25
|
|
|
26
|
-
import { CommandEvent, RenderEvent } from "@inweb/viewer-core";
|
|
27
|
-
import { IDisposable } from "../IDisposable";
|
|
26
|
+
import { CommandEvent, IComponent, RenderEvent } from "@inweb/viewer-core";
|
|
28
27
|
import type { Viewer } from "../Viewer";
|
|
29
28
|
|
|
30
29
|
export const defaultViewPositions = {
|
|
@@ -40,7 +39,7 @@ export const defaultViewPositions = {
|
|
|
40
39
|
nw: new Vector3(-0.5, 0.5, 1.0).normalize(),
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
export class ViewPositionComponent implements
|
|
42
|
+
export class ViewPositionComponent implements IComponent {
|
|
44
43
|
private position: string;
|
|
45
44
|
private center: Vector3;
|
|
46
45
|
private targetPosition: Vector3;
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
25
25
|
import type { Viewer } from "../Viewer";
|
|
26
26
|
import { WCSHelper } from "../helpers/WCSHelper";
|
|
27
27
|
|
|
28
|
-
export class WCSHelperComponent implements
|
|
28
|
+
export class WCSHelperComponent implements IComponent {
|
|
29
29
|
private wcsHelper: WCSHelper;
|
|
30
30
|
private viewer: Viewer;
|
|
31
31
|
|
|
@@ -0,0 +1,91 @@
|
|
|
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 { IComponentsRegistry, componentsRegistry } from "@inweb/viewer-core";
|
|
25
|
+
|
|
26
|
+
// import { AxesHelperComponent } from "./AxesHelperComponent";
|
|
27
|
+
import { BackgroundComponent } from "./BackgroundComponent";
|
|
28
|
+
import { DefaultPositionComponent } from "./DefaultPositionComponent";
|
|
29
|
+
import { ExtentsComponent } from "./ExtentsComponent";
|
|
30
|
+
// import { ExtentsHelperComponent } from "./ExtentsHelperComponent";
|
|
31
|
+
import { LightComponent } from "./LightComponent";
|
|
32
|
+
import { RenderLoopComponent } from "./RenderLoopComponent";
|
|
33
|
+
import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
|
|
34
|
+
import { SelectionComponent } from "./SelectionComponent";
|
|
35
|
+
// import { ViewPositionComponent } from "./ViewPositionComponent";
|
|
36
|
+
import { WCSHelperComponent } from "./WCSHelperComponent";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Viewer components registry. Use this registry to register custom components.
|
|
40
|
+
*
|
|
41
|
+
* To implement custom component:
|
|
42
|
+
*
|
|
43
|
+
* 1. Define a component class implements {@link IComponent}.
|
|
44
|
+
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
45
|
+
* 3. Define the component logic in the event listeners. For example, listen for the `mousedown`
|
|
46
|
+
* event and select objects when the left mouse button is pressed.
|
|
47
|
+
* 4. Override {@link IComponent.dispose} and remove mouse event listeners from the viewer.
|
|
48
|
+
* 5. Register component provider in the components registry by calling the
|
|
49
|
+
* {@link components.registerComponent}.
|
|
50
|
+
*
|
|
51
|
+
* @example <caption>Implementing a custom component.</caption>
|
|
52
|
+
* import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
53
|
+
*
|
|
54
|
+
* class MyComponent implements IComponent {
|
|
55
|
+
* protected viewer: Viewer;
|
|
56
|
+
*
|
|
57
|
+
* constructor(viewer: Viewer) {
|
|
58
|
+
* this.viewer = viewer;
|
|
59
|
+
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* override dispose() {
|
|
63
|
+
* this.viewer.removeEventListener("mousedown", this.onMouseDown);
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* onMouseDown = (event: PointerEvent) => {
|
|
67
|
+
* // place custom logic here
|
|
68
|
+
* };
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* components.registerComponent(
|
|
72
|
+
* "MyComponent",
|
|
73
|
+
* (viewer): IComponent => new MyComponent(viewer)
|
|
74
|
+
* );
|
|
75
|
+
*/
|
|
76
|
+
export const components: IComponentsRegistry = componentsRegistry("threejs");
|
|
77
|
+
|
|
78
|
+
// build-in components
|
|
79
|
+
|
|
80
|
+
components.registerComponent("ExtentsComponent", (viewer) => new ExtentsComponent(viewer));
|
|
81
|
+
components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
|
|
82
|
+
components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
|
|
83
|
+
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
84
|
+
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
85
|
+
components.registerComponent("DefaultPositionComponent", (viewer) => new DefaultPositionComponent(viewer));
|
|
86
|
+
components.registerComponent("SelectionComponent", (viewer) => new SelectionComponent(viewer));
|
|
87
|
+
components.registerComponent("WCSHelperComponent", (viewer) => new WCSHelperComponent(viewer));
|
|
88
|
+
|
|
89
|
+
// components.registerComponent("AxesHelperComponent", (viewer) => new AxesHelperComponent(viewer));
|
|
90
|
+
// components.registerComponent("ExtentsHelperComponent", (viewer) => new ExtentsHelperComponent(viewer));
|
|
91
|
+
// components.registerComponent("ViewPositionComponent", (viewer) => new ViewPositionComponent(viewer));
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { MOUSE, TOUCH } from "three";
|
|
25
|
+
import { type IDragger } from "@inweb/viewer-core";
|
|
25
26
|
|
|
26
|
-
import type { IDisposable } from "../IDisposable";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
28
28
|
import { OrbitControls, STATE } from "../controls/OrbitControls.js";
|
|
29
29
|
|
|
30
|
-
export class OrbitDragger implements
|
|
30
|
+
export class OrbitDragger implements IDragger {
|
|
31
31
|
protected viewer: Viewer;
|
|
32
32
|
protected orbit: OrbitControls;
|
|
33
33
|
protected changed: boolean;
|
|
@@ -57,6 +57,7 @@ export class OrbitDragger implements IDisposable {
|
|
|
57
57
|
this.viewer.off("drawviewpoint", this.updateControls);
|
|
58
58
|
this.viewer.off("contextmenu", this.stopContextMenu);
|
|
59
59
|
|
|
60
|
+
this.orbit.removeEventListener("start", this.controlsStart);
|
|
60
61
|
this.orbit.removeEventListener("change", this.controlsChange);
|
|
61
62
|
this.orbit.dispose();
|
|
62
63
|
}
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Vector3 } from "three";
|
|
25
|
+
import { type IDragger } from "@inweb/viewer-core";
|
|
25
26
|
|
|
26
27
|
import type { Viewer } from "../Viewer";
|
|
27
28
|
import { WalkControls } from "../controls/WalkControls";
|
|
28
29
|
|
|
29
|
-
export class WalkDragger {
|
|
30
|
+
export class WalkDragger implements IDragger {
|
|
30
31
|
protected viewer: Viewer;
|
|
31
32
|
public controls: WalkControls;
|
|
32
33
|
|
|
@@ -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 { IDraggersRegistry, draggersRegistry } from "@inweb/viewer-core";
|
|
25
|
+
|
|
26
|
+
import { CuttingPlaneXAxisDragger } from "./CuttingPlaneXAxis";
|
|
27
|
+
import { CuttingPlaneYAxisDragger } from "./CuttingPlaneYAxis";
|
|
28
|
+
import { CuttingPlaneZAxisDragger } from "./CuttingPlaneZAxis";
|
|
29
|
+
import { MeasureLineDragger } from "./MeasureLineDragger";
|
|
30
|
+
import { OrbitDragger } from "./OrbitDragger";
|
|
31
|
+
import { PanDragger } from "./PanDragger";
|
|
32
|
+
import { WalkDragger } from "./WalkDragger";
|
|
33
|
+
import { ZoomDragger } from "./ZoomDragger";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Viewer draggers registry. Use this registry to register custom draggers.
|
|
37
|
+
*
|
|
38
|
+
* To implement custom dragger:
|
|
39
|
+
*
|
|
40
|
+
* 1. Define a dragger class implements {@link IDragger}.
|
|
41
|
+
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
42
|
+
* 3. Define the dragger logic in the event listeners. For example, listen for the `mousemove`
|
|
43
|
+
* event and zoom in/out when the left mouse button is pressed.
|
|
44
|
+
* 4. Override {@link IDragger.dispose} and remove mouse event listeners from the viewer.
|
|
45
|
+
* 5. Register dragger provider in the draggers registry by calling the {@link draggers.registerDragger}.
|
|
46
|
+
*
|
|
47
|
+
* @example <caption>Implementing a custom dragger.</caption>
|
|
48
|
+
* import { IDragger, draggers, Viewer } from "@inweb/viewer-three";
|
|
49
|
+
*
|
|
50
|
+
* class MyDragger implements IDragger {
|
|
51
|
+
* protected viewer: Viewer;
|
|
52
|
+
*
|
|
53
|
+
* constructor(viewer: Viewer) {
|
|
54
|
+
* this.viewer = viewer;
|
|
55
|
+
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* override dispose() {
|
|
59
|
+
* this.viewer.removeEventListener("pointermove", this.onPointerMove);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* onPointerMove = (event: PointerEvent) => {
|
|
63
|
+
* // place custom logic here
|
|
64
|
+
* };
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* draggers.registerDragger("MyDragger", (viewer): IDragger => new MyDragger(viewer));
|
|
68
|
+
*
|
|
69
|
+
* @example <caption>Activating a custom dragger.</caption>
|
|
70
|
+
* viewer.setActiveDragger("MyDragger");
|
|
71
|
+
*/
|
|
72
|
+
export const draggers: IDraggersRegistry = draggersRegistry("threejs");
|
|
73
|
+
|
|
74
|
+
// build-in draggers
|
|
75
|
+
|
|
76
|
+
draggers.registerDragger("Pan", (viewer) => new PanDragger(viewer));
|
|
77
|
+
draggers.registerDragger("Orbit", (viewer) => new OrbitDragger(viewer));
|
|
78
|
+
draggers.registerDragger("Zoom", (viewer) => new ZoomDragger(viewer));
|
|
79
|
+
draggers.registerDragger("MeasureLine", (viewer) => new MeasureLineDragger(viewer));
|
|
80
|
+
draggers.registerDragger("CuttingPlaneXAxis", (viewer) => new CuttingPlaneXAxisDragger(viewer));
|
|
81
|
+
draggers.registerDragger("CuttingPlaneYAxis", (viewer) => new CuttingPlaneYAxisDragger(viewer));
|
|
82
|
+
draggers.registerDragger("CuttingPlaneZAxis", (viewer) => new CuttingPlaneZAxisDragger(viewer));
|
|
83
|
+
draggers.registerDragger("Walk", (viewer) => new WalkDragger(viewer));
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import "./Viewer/commands";
|
|
25
|
-
|
|
26
24
|
export * from "@inweb/viewer-core";
|
|
25
|
+
export * from "@inweb/markup";
|
|
26
|
+
|
|
27
|
+
export { draggers } from "./Viewer/draggers";
|
|
28
|
+
export { commands } from "./Viewer/commands";
|
|
29
|
+
export { components } from "./Viewer/components";
|
|
27
30
|
export { Viewer } from "./Viewer/Viewer";
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
/**
|
|
25
|
-
* An object that performs a cleanup operation when `.dispose()` is called.
|
|
26
|
-
*/
|
|
27
|
-
export interface IDisposable {
|
|
28
|
-
dispose(): void;
|
|
29
|
-
}
|