@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
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Box3, Object3D, PerspectiveCamera, Scene, Vector3, WebGLRenderer } from
|
|
|
2
2
|
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
3
3
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
4
4
|
import { Assembly, Client, Model, File } from "@inweb/client";
|
|
5
|
-
import { CanvasEventMap, IDragger, IOptions, IViewer, IViewpoint, Options, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
5
|
+
import { CanvasEventMap, IComponent, IDragger, IOptions, IViewer, IViewpoint, Options, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
6
6
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
7
7
|
/**
|
|
8
8
|
* 3D viewer powered by {@link https://threejs.org/ | Three.js}.
|
|
@@ -21,9 +21,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
21
21
|
selected: Array<Object3D>;
|
|
22
22
|
extents: Box3;
|
|
23
23
|
target: Vector3;
|
|
24
|
-
private draggerFactory;
|
|
25
24
|
private _activeDragger;
|
|
26
|
-
private
|
|
25
|
+
private _components;
|
|
27
26
|
private renderNeeded;
|
|
28
27
|
private renderTime;
|
|
29
28
|
private _markup;
|
|
@@ -35,6 +34,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
35
34
|
constructor(client?: Client);
|
|
36
35
|
get options(): IOptions;
|
|
37
36
|
get draggers(): string[];
|
|
37
|
+
get components(): string[];
|
|
38
38
|
/**
|
|
39
39
|
* 2D markup core instance used to create markups.
|
|
40
40
|
*
|
|
@@ -191,7 +191,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
191
191
|
z: number;
|
|
192
192
|
};
|
|
193
193
|
executeCommand(id: string, ...args: any[]): any;
|
|
194
|
-
getComponent(
|
|
194
|
+
getComponent(name: string): IComponent;
|
|
195
195
|
drawViewpoint(viewpoint: IViewpoint): void;
|
|
196
196
|
createViewpoint(): IViewpoint;
|
|
197
197
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function clearMarkup(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function clearSelected(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function clearSlices(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function createPreview(viewer: Viewer, type?: string, encoderOptions?: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function getDefaultViewPositions(): string[];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function getModels(viewer: Viewer): string[];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function getSelected(viewer: Viewer): string[];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function hideSelected(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function isolateSelected(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function regenerateAll(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function resetView(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function selectModel(viewer: Viewer, handle: string): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function setActiveDragger(viewer: Viewer, dragger?: string): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
+
import type { Viewer } from "../Viewer";
|
|
2
3
|
export declare const defaultViewPositions: {
|
|
3
4
|
top: Vector3;
|
|
4
5
|
bottom: Vector3;
|
|
@@ -11,3 +12,4 @@ export declare const defaultViewPositions: {
|
|
|
11
12
|
ne: Vector3;
|
|
12
13
|
nw: Vector3;
|
|
13
14
|
};
|
|
15
|
+
export declare function setDefaultViewPosition(viewer: Viewer, position: string): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function setMarkupColor(viewer: Viewer, r?: number, g?: number, b?: number): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function setSelected(viewer: Viewer, handles?: string[]): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function showAll(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function zoomToExtents(viewer: Viewer): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function zoomToObjects(viewer: Viewer, handles?: string[]): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Viewer } from "../Viewer";
|
|
2
|
+
export declare function zoomToSelected(viewer: Viewer): void;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import "
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { ICommandsRegistry } from "@inweb/viewer-core";
|
|
2
|
+
/**
|
|
3
|
+
* A commands registry. Use this registry to register custom commands.
|
|
4
|
+
*
|
|
5
|
+
* To implement custom command:
|
|
6
|
+
*
|
|
7
|
+
* 1. Define a command handler with a first `viewer` parameter.
|
|
8
|
+
* 2. Register command handler in the commands registry by calling the {@link commands.registerCommand}.
|
|
9
|
+
*
|
|
10
|
+
* @example <caption>Implementing a custom command.</caption>
|
|
11
|
+
* import { commands, Viewer } from "@inweb/viewer-three";
|
|
12
|
+
*
|
|
13
|
+
* function commandHandler(viewer: Viewer, name = "world"): void {
|
|
14
|
+
* console.log(`Hello ${name}!!!`);
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* commands.registerCommand("sayHello", commandHandler);
|
|
18
|
+
*
|
|
19
|
+
* @example <caption>Calling a custom command.</caption>
|
|
20
|
+
* viewer.executeCommand("sayHello", "user");
|
|
21
|
+
*/
|
|
22
|
+
export declare const commands: ICommandsRegistry;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class AxesHelperComponent implements
|
|
3
|
+
export declare class AxesHelperComponent implements IComponent {
|
|
4
4
|
private viewer;
|
|
5
5
|
private axesHelper1;
|
|
6
6
|
private axesHelper2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Color } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
3
3
|
import type { Viewer } from "../Viewer";
|
|
4
|
-
export declare class BackgroundComponent implements
|
|
4
|
+
export declare class BackgroundComponent implements IComponent {
|
|
5
5
|
protected viewer: Viewer;
|
|
6
6
|
protected backgroundColor: Color;
|
|
7
7
|
constructor(viewer: Viewer);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GeometryEndEvent } from "@inweb/viewer-core";
|
|
2
|
-
import { IDisposable } from "../IDisposable";
|
|
1
|
+
import { GeometryEndEvent, IComponent } from "@inweb/viewer-core";
|
|
3
2
|
import type { Viewer } from "../Viewer";
|
|
4
|
-
export declare class DefaultPositionComponent implements
|
|
3
|
+
export declare class DefaultPositionComponent implements IComponent {
|
|
5
4
|
protected viewer: Viewer;
|
|
6
5
|
defaultCameraPositions: any;
|
|
7
6
|
constructor(viewer: Viewer);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class ExtentsComponent implements
|
|
3
|
+
export declare class ExtentsComponent implements IComponent {
|
|
4
4
|
private viewer;
|
|
5
5
|
constructor(viewer: Viewer);
|
|
6
6
|
dispose(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class ExtentsHelperComponent implements
|
|
3
|
+
export declare class ExtentsHelperComponent implements IComponent {
|
|
4
4
|
private viewer;
|
|
5
5
|
private boxHelper;
|
|
6
6
|
constructor(viewer: Viewer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AmbientLight, DirectionalLight } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
3
3
|
import type { Viewer } from "../Viewer";
|
|
4
|
-
export declare class LightComponent implements
|
|
4
|
+
export declare class LightComponent implements IComponent {
|
|
5
5
|
protected viewer: Viewer;
|
|
6
6
|
protected ambientLight: AmbientLight;
|
|
7
7
|
protected directionalLight: DirectionalLight;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class RenderLoopComponent implements
|
|
3
|
+
export declare class RenderLoopComponent implements IComponent {
|
|
4
4
|
protected viewer: Viewer;
|
|
5
5
|
protected requestId: number;
|
|
6
6
|
constructor(viewer: Viewer);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class ResizeCanvasComponent implements
|
|
3
|
+
export declare class ResizeCanvasComponent implements IComponent {
|
|
4
4
|
protected viewer: Viewer;
|
|
5
5
|
protected resizeObserver: ResizeObserver;
|
|
6
6
|
constructor(viewer: Viewer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Intersection, MeshBasicMaterial, Object3D, Raycaster, Vector2 } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
3
3
|
import type { Viewer } from "../Viewer";
|
|
4
|
-
export declare class SelectionComponent implements
|
|
4
|
+
export declare class SelectionComponent implements IComponent {
|
|
5
5
|
protected viewer: Viewer;
|
|
6
6
|
protected raycaster: Raycaster;
|
|
7
7
|
protected downPosition: Vector2;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
-
import { CommandEvent, RenderEvent } from "@inweb/viewer-core";
|
|
3
|
-
import { IDisposable } from "../IDisposable";
|
|
2
|
+
import { CommandEvent, IComponent, RenderEvent } from "@inweb/viewer-core";
|
|
4
3
|
import type { Viewer } from "../Viewer";
|
|
5
4
|
export declare const defaultViewPositions: {
|
|
6
5
|
top: Vector3;
|
|
@@ -14,7 +13,7 @@ export declare const defaultViewPositions: {
|
|
|
14
13
|
ne: Vector3;
|
|
15
14
|
nw: Vector3;
|
|
16
15
|
};
|
|
17
|
-
export declare class ViewPositionComponent implements
|
|
16
|
+
export declare class ViewPositionComponent implements IComponent {
|
|
18
17
|
private position;
|
|
19
18
|
private center;
|
|
20
19
|
private targetPosition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class WCSHelperComponent implements
|
|
3
|
+
export declare class WCSHelperComponent implements IComponent {
|
|
4
4
|
private wcsHelper;
|
|
5
5
|
private viewer;
|
|
6
6
|
constructor(viewer: Viewer);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IComponentsRegistry } from "@inweb/viewer-core";
|
|
2
|
+
/**
|
|
3
|
+
* Viewer components registry. Use this registry to register custom components.
|
|
4
|
+
*
|
|
5
|
+
* To implement custom component:
|
|
6
|
+
*
|
|
7
|
+
* 1. Define a component class implements {@link IComponent}.
|
|
8
|
+
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
9
|
+
* 3. Define the component logic in the event listeners. For example, listen for the `mousedown`
|
|
10
|
+
* event and select objects when the left mouse button is pressed.
|
|
11
|
+
* 4. Override {@link IComponent.dispose} and remove mouse event listeners from the viewer.
|
|
12
|
+
* 5. Register component provider in the components registry by calling the
|
|
13
|
+
* {@link components.registerComponent}.
|
|
14
|
+
*
|
|
15
|
+
* @example <caption>Implementing a custom component.</caption>
|
|
16
|
+
* import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
17
|
+
*
|
|
18
|
+
* class MyComponent implements IComponent {
|
|
19
|
+
* protected viewer: Viewer;
|
|
20
|
+
*
|
|
21
|
+
* constructor(viewer: Viewer) {
|
|
22
|
+
* this.viewer = viewer;
|
|
23
|
+
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* override dispose() {
|
|
27
|
+
* this.viewer.removeEventListener("mousedown", this.onMouseDown);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* onMouseDown = (event: PointerEvent) => {
|
|
31
|
+
* // place custom logic here
|
|
32
|
+
* };
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* components.registerComponent(
|
|
36
|
+
* "MyComponent",
|
|
37
|
+
* (viewer): IComponent => new MyComponent(viewer)
|
|
38
|
+
* );
|
|
39
|
+
*/
|
|
40
|
+
export declare const components: IComponentsRegistry;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IDragger } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
3
|
import { OrbitControls } from "../controls/OrbitControls.js";
|
|
4
|
-
export declare class OrbitDragger implements
|
|
4
|
+
export declare class OrbitDragger implements IDragger {
|
|
5
5
|
protected viewer: Viewer;
|
|
6
6
|
protected orbit: OrbitControls;
|
|
7
7
|
protected changed: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type IDragger } from "@inweb/viewer-core";
|
|
1
2
|
import type { Viewer } from "../Viewer";
|
|
2
3
|
import { WalkControls } from "../controls/WalkControls";
|
|
3
|
-
export declare class WalkDragger {
|
|
4
|
+
export declare class WalkDragger implements IDragger {
|
|
4
5
|
protected viewer: Viewer;
|
|
5
6
|
controls: WalkControls;
|
|
6
7
|
constructor(viewer: Viewer);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IDraggersRegistry } from "@inweb/viewer-core";
|
|
2
|
+
/**
|
|
3
|
+
* Viewer draggers registry. Use this registry to register custom draggers.
|
|
4
|
+
*
|
|
5
|
+
* To implement custom dragger:
|
|
6
|
+
*
|
|
7
|
+
* 1. Define a dragger class implements {@link IDragger}.
|
|
8
|
+
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
9
|
+
* 3. Define the dragger logic in the event listeners. For example, listen for the `mousemove`
|
|
10
|
+
* event and zoom in/out when the left mouse button is pressed.
|
|
11
|
+
* 4. Override {@link IDragger.dispose} and remove mouse event listeners from the viewer.
|
|
12
|
+
* 5. Register dragger provider in the draggers registry by calling the {@link draggers.registerDragger}.
|
|
13
|
+
*
|
|
14
|
+
* @example <caption>Implementing a custom dragger.</caption>
|
|
15
|
+
* import { IDragger, draggers, Viewer } from "@inweb/viewer-three";
|
|
16
|
+
*
|
|
17
|
+
* class MyDragger implements IDragger {
|
|
18
|
+
* protected viewer: Viewer;
|
|
19
|
+
*
|
|
20
|
+
* constructor(viewer: Viewer) {
|
|
21
|
+
* this.viewer = viewer;
|
|
22
|
+
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* override dispose() {
|
|
26
|
+
* this.viewer.removeEventListener("pointermove", this.onPointerMove);
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* onPointerMove = (event: PointerEvent) => {
|
|
30
|
+
* // place custom logic here
|
|
31
|
+
* };
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* draggers.registerDragger("MyDragger", (viewer): IDragger => new MyDragger(viewer));
|
|
35
|
+
*
|
|
36
|
+
* @example <caption>Activating a custom dragger.</caption>
|
|
37
|
+
* viewer.setActiveDragger("MyDragger");
|
|
38
|
+
*/
|
|
39
|
+
export declare const draggers: IDraggersRegistry;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import "./Viewer/commands";
|
|
2
1
|
export * from "@inweb/viewer-core";
|
|
2
|
+
export * from "@inweb/markup";
|
|
3
|
+
export { draggers } from "./Viewer/draggers";
|
|
4
|
+
export { commands } from "./Viewer/commands";
|
|
5
|
+
export { components } from "./Viewer/components";
|
|
3
6
|
export { Viewer } from "./Viewer/Viewer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.1.0",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using Three.js",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"docs": "typedoc"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@inweb/client": "~
|
|
32
|
-
"@inweb/eventemitter2": "~
|
|
33
|
-
"@inweb/markup": "~
|
|
34
|
-
"@inweb/viewer-core": "~
|
|
31
|
+
"@inweb/client": "~26.1.0",
|
|
32
|
+
"@inweb/eventemitter2": "~26.1.0",
|
|
33
|
+
"@inweb/markup": "~26.1.0",
|
|
34
|
+
"@inweb/viewer-core": "~26.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/three": "^0.169.0",
|