@inweb/viewer-visualize 26.1.0 → 26.1.2
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-visualize.js +585 -553
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +77 -76
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Commands/index.d.ts +14 -8
- package/lib/Viewer/Components/index.d.ts +20 -20
- package/lib/Viewer/Draggers/index.d.ts +25 -19
- package/lib/Viewer/Viewer.d.ts +58 -55
- package/package.json +5 -5
- package/src/Viewer/Commands/GetSelected.ts +2 -2
- package/src/Viewer/Commands/index.ts +14 -8
- package/src/Viewer/Components/index.ts +20 -20
- package/src/Viewer/Draggers/index.ts +25 -19
- package/src/Viewer/Viewer.ts +60 -56
|
@@ -7,16 +7,22 @@ import { ICommandsRegistry } from "@inweb/viewer-core";
|
|
|
7
7
|
* 1. Define a command handler with a first `viewer` parameter.
|
|
8
8
|
* 2. Register command handler in the commands registry by calling the {@link commands.registerCommand}.
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
11
|
-
* import { commands, Viewer } from "@inweb/viewer-visualize";
|
|
10
|
+
* @example Implementing a custom command.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* }
|
|
12
|
+
* ```javascript
|
|
13
|
+
* import { commands, Viewer } from "@inweb/viewer-visualize";
|
|
16
14
|
*
|
|
17
|
-
*
|
|
15
|
+
* function commandHandler(viewer: Viewer, name = "world"): void {
|
|
16
|
+
* console.log(`Hello ${name}!!!`);
|
|
17
|
+
* }
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* commands.registerCommand("sayHello", commandHandler);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Calling a custom command.
|
|
23
|
+
*
|
|
24
|
+
* ```javascript
|
|
25
|
+
* viewer.executeCommand("sayHello", "user");
|
|
26
|
+
* ```
|
|
21
27
|
*/
|
|
22
28
|
export declare const commands: ICommandsRegistry;
|
|
@@ -6,35 +6,35 @@ import { IComponentsRegistry } from "@inweb/viewer-core";
|
|
|
6
6
|
*
|
|
7
7
|
* 1. Define a component class implements {@link IComponent}.
|
|
8
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
|
-
*
|
|
9
|
+
* 3. Define the component logic in the event listeners. For example, listen for the `mousedown` event and
|
|
10
|
+
* select objects when the left mouse button is pressed.
|
|
11
11
|
* 4. Override {@link IComponent.dispose} and remove mouse event listeners from the viewer.
|
|
12
12
|
* 5. Register component provider in the components registry by calling the
|
|
13
13
|
* {@link components.registerComponent}.
|
|
14
14
|
*
|
|
15
|
-
* @example
|
|
16
|
-
* import { IComponent, components, Viewer } from "@inweb/viewer-visualize";
|
|
15
|
+
* @example Implementing a custom component.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* ```javascript
|
|
18
|
+
* import { IComponent, components, Viewer } from "@inweb/viewer-visualize";
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
24
|
-
* }
|
|
20
|
+
* class MyComponent implements IComponent {
|
|
21
|
+
* protected viewer: Viewer;
|
|
25
22
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* constructor(viewer: Viewer) {
|
|
24
|
+
* this.viewer = viewer;
|
|
25
|
+
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
26
|
+
* }
|
|
29
27
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* };
|
|
28
|
+
* override dispose() {
|
|
29
|
+
* this.viewer.removeEventListener("mousedown", this.onMouseDown);
|
|
33
30
|
* }
|
|
34
31
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* onMouseDown = (event: PointerEvent) => {
|
|
33
|
+
* // place custom logic here
|
|
34
|
+
* };
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* components.registerComponent( "MyComponent", (viewer): IComponent => new MyComponent(viewer));
|
|
38
|
+
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare const components: IComponentsRegistry;
|
|
@@ -6,35 +6,41 @@ import { IDraggersRegistry } from "@inweb/viewer-core";
|
|
|
6
6
|
*
|
|
7
7
|
* 1. Define a dragger class implements {@link IDragger}.
|
|
8
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
|
-
*
|
|
9
|
+
* 3. Define the dragger logic in the event listeners. For example, listen for the `mousemove` event and
|
|
10
|
+
* zoom in/out when the left mouse button is pressed.
|
|
11
11
|
* 4. Override {@link IDragger.dispose} and remove mouse event listeners from the viewer.
|
|
12
12
|
* 5. Register dragger provider in the draggers registry by calling the {@link draggers.registerDragger}.
|
|
13
13
|
*
|
|
14
|
-
* @example
|
|
15
|
-
* import { IDragger, draggers, Viewer } from "@inweb/viewer-visualize";
|
|
14
|
+
* @example Implementing a custom dragger.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* ```javascript
|
|
17
|
+
* import { IDragger, draggers, Viewer } from "@inweb/viewer-visualize";
|
|
19
18
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
23
|
-
* }
|
|
19
|
+
* class MyDragger implements IDragger {
|
|
20
|
+
* protected viewer: Viewer;
|
|
24
21
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* constructor(viewer: Viewer) {
|
|
23
|
+
* this.viewer = viewer;
|
|
24
|
+
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
25
|
+
* }
|
|
28
26
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* };
|
|
27
|
+
* override dispose() {
|
|
28
|
+
* this.viewer.removeEventListener("pointermove", this.onPointerMove);
|
|
32
29
|
* }
|
|
33
30
|
*
|
|
34
|
-
*
|
|
31
|
+
* onPointerMove = (event: PointerEvent) => {
|
|
32
|
+
* // place custom logic here
|
|
33
|
+
* };
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* draggers.registerDragger("MyDragger", (viewer): IDragger => new MyDragger(viewer));
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example Activating a custom dragger.
|
|
35
40
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
41
|
+
* ```javascript
|
|
42
|
+
* viewer.setActiveDragger("MyDragger");
|
|
43
|
+
* ```
|
|
38
44
|
*/
|
|
39
45
|
declare const draggers: IDraggersRegistry;
|
|
40
46
|
export { draggers };
|
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { CanvasEventMap, Dragger, IComponent, IDragger, IOptions, IViewer, IView
|
|
|
4
4
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
5
5
|
import { MarkupType } from "./Markup/MarkupFactory";
|
|
6
6
|
/**
|
|
7
|
-
* 3D viewer powered by
|
|
8
|
-
*
|
|
7
|
+
* 3D viewer powered by {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS}
|
|
8
|
+
* library.
|
|
9
9
|
*/
|
|
10
10
|
export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMap & OptionsEventMap> implements IViewer, IWorldTransform {
|
|
11
11
|
private _activeDragger;
|
|
@@ -27,18 +27,18 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
27
27
|
_abortControllerForReferences: AbortController | undefined;
|
|
28
28
|
client: Client | undefined;
|
|
29
29
|
/**
|
|
30
|
-
* @param client - The `Client` instance that is used to load model reference files from the
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* @param client - The `Client` instance that is used to load model reference files from the Open Cloud
|
|
31
|
+
* Server. Do not specify `Client` if you need a standalone viewer instance to view `VSFX` files from
|
|
32
|
+
* the web or from local computer.
|
|
33
33
|
* @param params - An object containing viewer configuration parameters.
|
|
34
|
-
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @param params.markupType - The type of the markup core: `Visualize` (deprecated) or
|
|
41
|
-
*
|
|
34
|
+
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own library
|
|
35
|
+
* instance, or specify `undefined` or blank to use the default URL defined by `Viewer.visualize`
|
|
36
|
+
* library you are using.
|
|
37
|
+
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If the
|
|
38
|
+
* auto-update is disabled, you need to register an `update` event handler and update the
|
|
39
|
+
* `VisualizeJS` viewer and active dragger manually. Default is `true`.
|
|
40
|
+
* @param params.markupType - The type of the markup core: `Visualize` (deprecated) or `Konva`. Default
|
|
41
|
+
* is `Konva`.
|
|
42
42
|
*/
|
|
43
43
|
constructor(client?: Client, params?: {
|
|
44
44
|
visualizeJsUrl?: string;
|
|
@@ -65,9 +65,9 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
65
65
|
* Changes the viewer parameters.
|
|
66
66
|
*
|
|
67
67
|
* @param params - An object containing new parameters.
|
|
68
|
-
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
69
|
-
*
|
|
70
|
-
*
|
|
68
|
+
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own library
|
|
69
|
+
* instance or specify `undefined` or blank to use the default URL defined by `Viewer.visualize`
|
|
70
|
+
* library you are using.
|
|
71
71
|
*/
|
|
72
72
|
configure(params: {
|
|
73
73
|
visualizeJsUrl?: string;
|
|
@@ -82,10 +82,10 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
82
82
|
* - {@link InitializeProgressEvent | initializeprogress}
|
|
83
83
|
*
|
|
84
84
|
* @param canvas -
|
|
85
|
-
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement}
|
|
86
|
-
*
|
|
87
|
-
* @param onProgress - A callback function that handles events measuring progress of loading
|
|
88
|
-
*
|
|
85
|
+
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement} for
|
|
86
|
+
* `VisualizeJS`.
|
|
87
|
+
* @param onProgress - A callback function that handles events measuring progress of loading of the
|
|
88
|
+
* `VisualizeJS` library.
|
|
89
89
|
*/
|
|
90
90
|
initialize(canvas: HTMLCanvasElement, onProgress?: (event: ProgressEvent) => void): Promise<this>;
|
|
91
91
|
dispose(): this;
|
|
@@ -98,24 +98,24 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
98
98
|
/**
|
|
99
99
|
* Updates the viewer.
|
|
100
100
|
*
|
|
101
|
-
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
102
|
-
*
|
|
101
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register an
|
|
102
|
+
* `update` event handler and update the `Visualize` viewer and active dragger manually.
|
|
103
103
|
*
|
|
104
104
|
* Fires:
|
|
105
105
|
*
|
|
106
106
|
* - {@link UpdateEvent | update}
|
|
107
107
|
*
|
|
108
|
-
* @param force - If `true` updates the viewer immidietly. Otherwise updates on next
|
|
109
|
-
*
|
|
108
|
+
* @param force - If `true` updates the viewer immidietly. Otherwise updates on next animation frame.
|
|
109
|
+
* Default is `false`.
|
|
110
110
|
*/
|
|
111
111
|
update(force?: boolean): void;
|
|
112
112
|
private scheduleUpdateAsync;
|
|
113
113
|
/**
|
|
114
|
-
* Updates the viewer asynchronously without locking the user interface. Used to update the
|
|
115
|
-
*
|
|
114
|
+
* Updates the viewer asynchronously without locking the user interface. Used to update the viewer
|
|
115
|
+
* after changes that require a long rendering time.
|
|
116
116
|
*
|
|
117
|
-
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
118
|
-
*
|
|
117
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register an
|
|
118
|
+
* `update` event handler and update the `VisualizeJS` viewer and active dragger manually.
|
|
119
119
|
*
|
|
120
120
|
* Fires:
|
|
121
121
|
*
|
|
@@ -126,18 +126,18 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
126
126
|
*/
|
|
127
127
|
updateAsync(maxScheduleUpdateTimeInMs?: number, maxScheduleUpdateCount?: number): Promise<void>;
|
|
128
128
|
/**
|
|
129
|
-
* Returns `VisualizeJS`
|
|
130
|
-
*
|
|
129
|
+
* Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module}
|
|
130
|
+
* instance.
|
|
131
131
|
*/
|
|
132
132
|
get visualizeJs(): any;
|
|
133
133
|
/**
|
|
134
|
-
* Returns `VisualizeJS`
|
|
135
|
-
*
|
|
134
|
+
* Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module}
|
|
135
|
+
* instance.
|
|
136
136
|
*/
|
|
137
137
|
visLib(): any;
|
|
138
138
|
/**
|
|
139
|
-
* Returns `VisualizeJS`
|
|
140
|
-
*
|
|
139
|
+
* Returns `VisualizeJS` {@link https://cloud.opendesign.com/docs/index.html#/vis/Viewer | Viewer}
|
|
140
|
+
* instance.
|
|
141
141
|
*/
|
|
142
142
|
visViewer(): any;
|
|
143
143
|
syncOpenCloudVisualStyle(isInitializing: boolean): this;
|
|
@@ -194,15 +194,15 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
194
194
|
*
|
|
195
195
|
* The file geometry data on the server must be converted to `VSFX` format.
|
|
196
196
|
*
|
|
197
|
-
* To open a large file, enable {@link IOptions.enablePartialMode | partial streaming} mode
|
|
198
|
-
*
|
|
197
|
+
* To open a large file, enable {@link IOptions.enablePartialMode | partial streaming} mode before
|
|
198
|
+
* opening (see example below).
|
|
199
199
|
*
|
|
200
|
-
* This method requires a `Client` instance to be specified when creating the viewer to load
|
|
201
|
-
*
|
|
200
|
+
* This method requires a `Client` instance to be specified when creating the viewer to load model
|
|
201
|
+
* reference files from the Open Cloud Server. For a standalone viewer instance use
|
|
202
202
|
* {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
|
|
203
203
|
*
|
|
204
|
-
* If there was an active dragger before opening the file, it will be deactivated. After
|
|
205
|
-
*
|
|
204
|
+
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
205
|
+
* file, you must manually activate the required dragger.
|
|
206
206
|
*
|
|
207
207
|
* Fires:
|
|
208
208
|
*
|
|
@@ -214,14 +214,17 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
214
214
|
* - {@link GeometryEndEvent | geometryend}
|
|
215
215
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
216
216
|
*
|
|
217
|
-
* @example
|
|
218
|
-
* viewer.options.enableStreamingMode = true;
|
|
219
|
-
* viewer.options.enablePartialMode = true;
|
|
220
|
-
* await viewer.open(file);
|
|
217
|
+
* @example Using partial streaming mode to open a large file from a server.
|
|
221
218
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
219
|
+
* ```javascript
|
|
220
|
+
* viewer.options.enableStreamingMode = true;
|
|
221
|
+
* viewer.options.enablePartialMode = true;
|
|
222
|
+
* await viewer.open(file);
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @param file - File, assembly or specific model to load. If a `File` instance with multiple models is
|
|
226
|
+
* specified, the default model will be loaded. If there is no default model, first availiable model
|
|
227
|
+
* will be loaded.
|
|
225
228
|
*/
|
|
226
229
|
open(file: File | Assembly | Model): Promise<this>;
|
|
227
230
|
/**
|
|
@@ -230,8 +233,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
230
233
|
* This method does not support {@link IOptions.enableStreamingMode | streaming} or
|
|
231
234
|
* {@link IOptions.enablePartialMode | partial streaming} mode.
|
|
232
235
|
*
|
|
233
|
-
* If there was an active dragger before opening the file, it will be deactivated. After
|
|
234
|
-
*
|
|
236
|
+
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
237
|
+
* file, you must manually activate the required dragger.
|
|
235
238
|
*
|
|
236
239
|
* Fires:
|
|
237
240
|
*
|
|
@@ -251,8 +254,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
251
254
|
* This method does not support {@link IOptions.enableStreamingMode | streaming} or
|
|
252
255
|
* {@link IOptions.enablePartialMode | partial streaming} mode.
|
|
253
256
|
*
|
|
254
|
-
* If there was an active dragger before opening the file, it will be deactivated. After
|
|
255
|
-
*
|
|
257
|
+
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
258
|
+
* file, you must manually activate the required dragger.
|
|
256
259
|
*
|
|
257
260
|
* Fires:
|
|
258
261
|
*
|
|
@@ -304,8 +307,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
304
307
|
private getSelection;
|
|
305
308
|
private setSelection;
|
|
306
309
|
/**
|
|
307
|
-
* Executes the command denoted by the given command. If the command is not found, tries to
|
|
308
|
-
*
|
|
310
|
+
* Executes the command denoted by the given command. If the command is not found, tries to set active
|
|
311
|
+
* dragger with the specified name.
|
|
309
312
|
*
|
|
310
313
|
* The following commands are available by default:
|
|
311
314
|
*
|
|
@@ -337,8 +340,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
337
340
|
*
|
|
338
341
|
* @param id - Command ID or dragger name.
|
|
339
342
|
* @param args - Parameters passed to the command handler function.
|
|
340
|
-
* @returns Returns the result of the command handler function or new active dragger
|
|
341
|
-
*
|
|
343
|
+
* @returns Returns the result of the command handler function or new active dragger instance. Returns
|
|
344
|
+
* `undefined` if neither the command nor the dragger exists.
|
|
342
345
|
*/
|
|
343
346
|
executeCommand(id: string, ...args: any[]): any;
|
|
344
347
|
deviceAutoRegeneration(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "26.1.
|
|
3
|
+
"version": "26.1.2",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"docs": "typedoc"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@inweb/client": "~26.1.
|
|
33
|
-
"@inweb/eventemitter2": "~26.1.
|
|
34
|
-
"@inweb/markup": "~26.1.
|
|
35
|
-
"@inweb/viewer-core": "~26.1.
|
|
32
|
+
"@inweb/client": "~26.1.2",
|
|
33
|
+
"@inweb/eventemitter2": "~26.1.2",
|
|
34
|
+
"@inweb/markup": "~26.1.2",
|
|
35
|
+
"@inweb/viewer-core": "~26.1.2"
|
|
36
36
|
},
|
|
37
37
|
"visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
|
|
38
38
|
}
|
|
@@ -39,8 +39,8 @@ export function getSelected(viewer: Viewer): string[] {
|
|
|
39
39
|
entityId.getType() === 1
|
|
40
40
|
? entityId.openObject()
|
|
41
41
|
: entityId.getType() === 2
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
? entityId.openObjectAsInsert()
|
|
43
|
+
: null;
|
|
44
44
|
|
|
45
45
|
if (entityPtr) {
|
|
46
46
|
const handle = entityPtr.getNativeDatabaseHandle();
|
|
@@ -55,17 +55,23 @@ import { autoTransformAllModelsToCentralPoint } from "./AutoTransformAllModelsTo
|
|
|
55
55
|
* 1. Define a command handler with a first `viewer` parameter.
|
|
56
56
|
* 2. Register command handler in the commands registry by calling the {@link commands.registerCommand}.
|
|
57
57
|
*
|
|
58
|
-
* @example
|
|
59
|
-
* import { commands, Viewer } from "@inweb/viewer-visualize";
|
|
58
|
+
* @example Implementing a custom command.
|
|
60
59
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* }
|
|
60
|
+
* ```javascript
|
|
61
|
+
* import { commands, Viewer } from "@inweb/viewer-visualize";
|
|
64
62
|
*
|
|
65
|
-
*
|
|
63
|
+
* function commandHandler(viewer: Viewer, name = "world"): void {
|
|
64
|
+
* console.log(`Hello ${name}!!!`);
|
|
65
|
+
* }
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* commands.registerCommand("sayHello", commandHandler);
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Calling a custom command.
|
|
71
|
+
*
|
|
72
|
+
* ```javascript
|
|
73
|
+
* viewer.executeCommand("sayHello", "user");
|
|
74
|
+
* ```
|
|
69
75
|
*/
|
|
70
76
|
export const commands: ICommandsRegistry = commandsRegistry("visualizejs");
|
|
71
77
|
|
|
@@ -35,36 +35,36 @@ import { GestureManagerComponent } from "./GestureManagerComponent";
|
|
|
35
35
|
*
|
|
36
36
|
* 1. Define a component class implements {@link IComponent}.
|
|
37
37
|
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
38
|
-
* 3. Define the component logic in the event listeners. For example, listen for the `mousedown`
|
|
39
|
-
*
|
|
38
|
+
* 3. Define the component logic in the event listeners. For example, listen for the `mousedown` event and
|
|
39
|
+
* select objects when the left mouse button is pressed.
|
|
40
40
|
* 4. Override {@link IComponent.dispose} and remove mouse event listeners from the viewer.
|
|
41
41
|
* 5. Register component provider in the components registry by calling the
|
|
42
42
|
* {@link components.registerComponent}.
|
|
43
43
|
*
|
|
44
|
-
* @example
|
|
45
|
-
* import { IComponent, components, Viewer } from "@inweb/viewer-visualize";
|
|
44
|
+
* @example Implementing a custom component.
|
|
46
45
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* ```javascript
|
|
47
|
+
* import { IComponent, components, Viewer } from "@inweb/viewer-visualize";
|
|
49
48
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
53
|
-
* }
|
|
49
|
+
* class MyComponent implements IComponent {
|
|
50
|
+
* protected viewer: Viewer;
|
|
54
51
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
52
|
+
* constructor(viewer: Viewer) {
|
|
53
|
+
* this.viewer = viewer;
|
|
54
|
+
* this.viewer.addEventListener("mousedown", this.onMouseDown);
|
|
55
|
+
* }
|
|
58
56
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* };
|
|
57
|
+
* override dispose() {
|
|
58
|
+
* this.viewer.removeEventListener("mousedown", this.onMouseDown);
|
|
62
59
|
* }
|
|
63
60
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
61
|
+
* onMouseDown = (event: PointerEvent) => {
|
|
62
|
+
* // place custom logic here
|
|
63
|
+
* };
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* components.registerComponent( "MyComponent", (viewer): IComponent => new MyComponent(viewer));
|
|
67
|
+
* ```
|
|
68
68
|
*/
|
|
69
69
|
export const components: IComponentsRegistry = componentsRegistry("visualizejs");
|
|
70
70
|
|
|
@@ -42,35 +42,41 @@ import { OrbitAroundBuildingDragger } from "./OrbitAroundBuildingDragger";
|
|
|
42
42
|
*
|
|
43
43
|
* 1. Define a dragger class implements {@link IDragger}.
|
|
44
44
|
* 2. Define a constructor with a `viewer` parameter and add mouse event listeners for the specified viewer.
|
|
45
|
-
* 3. Define the dragger logic in the event listeners. For example, listen for the `mousemove`
|
|
46
|
-
*
|
|
45
|
+
* 3. Define the dragger logic in the event listeners. For example, listen for the `mousemove` event and
|
|
46
|
+
* zoom in/out when the left mouse button is pressed.
|
|
47
47
|
* 4. Override {@link IDragger.dispose} and remove mouse event listeners from the viewer.
|
|
48
48
|
* 5. Register dragger provider in the draggers registry by calling the {@link draggers.registerDragger}.
|
|
49
49
|
*
|
|
50
|
-
* @example
|
|
51
|
-
* import { IDragger, draggers, Viewer } from "@inweb/viewer-visualize";
|
|
50
|
+
* @example Implementing a custom dragger.
|
|
52
51
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* ```javascript
|
|
53
|
+
* import { IDragger, draggers, Viewer } from "@inweb/viewer-visualize";
|
|
55
54
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
59
|
-
* }
|
|
55
|
+
* class MyDragger implements IDragger {
|
|
56
|
+
* protected viewer: Viewer;
|
|
60
57
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
58
|
+
* constructor(viewer: Viewer) {
|
|
59
|
+
* this.viewer = viewer;
|
|
60
|
+
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
61
|
+
* }
|
|
64
62
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* };
|
|
63
|
+
* override dispose() {
|
|
64
|
+
* this.viewer.removeEventListener("pointermove", this.onPointerMove);
|
|
68
65
|
* }
|
|
69
66
|
*
|
|
70
|
-
*
|
|
67
|
+
* onPointerMove = (event: PointerEvent) => {
|
|
68
|
+
* // place custom logic here
|
|
69
|
+
* };
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* draggers.registerDragger("MyDragger", (viewer): IDragger => new MyDragger(viewer));
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example Activating a custom dragger.
|
|
71
76
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
77
|
+
* ```javascript
|
|
78
|
+
* viewer.setActiveDragger("MyDragger");
|
|
79
|
+
* ```
|
|
74
80
|
*/
|
|
75
81
|
const draggers: IDraggersRegistry = draggersRegistry("visualizejs");
|
|
76
82
|
|