@inweb/viewer-core 26.10.6 → 26.11.1
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-core.js +8 -0
- package/dist/viewer-core.js.map +1 -1
- package/dist/viewer-core.module.js +8 -0
- package/dist/viewer-core.module.js.map +1 -1
- package/lib/commands/ICommands.d.ts +5 -4
- package/lib/index.d.ts +1 -0
- package/lib/loaders/ILoader.d.ts +1 -1
- package/lib/loaders/Loader.d.ts +1 -0
- package/lib/models/IModel.d.ts +20 -0
- package/lib/viewer/IViewer.d.ts +51 -12
- package/lib/viewer/ViewerEvents.d.ts +40 -16
- package/package.json +3 -3
- package/src/commands/ICommands.ts +5 -4
- package/src/index.ts +1 -0
- package/src/loaders/ILoader.ts +1 -1
- package/src/loaders/Loader.ts +9 -0
- package/src/models/IModel.ts +44 -0
- package/src/viewer/IViewer.ts +55 -12
- package/src/viewer/ViewerEvents.ts +44 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-core",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.11.1",
|
|
4
4
|
"description": "3D CAD and BIM data Viewer core",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "karma start karma.conf.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/client": "~26.
|
|
30
|
-
"@inweb/eventemitter2": "~26.
|
|
29
|
+
"@inweb/client": "~26.11.1",
|
|
30
|
+
"@inweb/eventemitter2": "~26.11.1"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -28,12 +28,13 @@ import { IViewer } from "../viewer/IViewer";
|
|
|
28
28
|
*/
|
|
29
29
|
export interface ICommandService {
|
|
30
30
|
/**
|
|
31
|
-
* Executes the command denoted by the given command ID.
|
|
31
|
+
* Executes the command denoted by the given command ID. If the command is not found, tries to set
|
|
32
|
+
* active dragger with the specified name.
|
|
32
33
|
*
|
|
33
|
-
* @param id - ID
|
|
34
|
+
* @param id - Command ID or dragger name.
|
|
34
35
|
* @param args - Parameters passed to the command handler function.
|
|
35
|
-
* @returns Returns the result of the command handler function
|
|
36
|
-
*
|
|
36
|
+
* @returns Returns the result of the command handler function or new active dragger instance. Returns
|
|
37
|
+
* `undefined` if neither the command nor the dragger exists.
|
|
37
38
|
*/
|
|
38
39
|
executeCommand(id: string, ...args: any[]): any;
|
|
39
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./components/IComponents";
|
|
|
32
32
|
export * from "./loaders/ILoader";
|
|
33
33
|
export * from "./loaders/Loader";
|
|
34
34
|
export * from "./loaders/Loaders";
|
|
35
|
+
export * from "./models/IModel";
|
|
35
36
|
export * from "./options/IOptions";
|
|
36
37
|
export * from "./options/Options";
|
|
37
38
|
export * from "./options/OptionsEvents";
|
package/src/loaders/ILoader.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { IViewer } from "../viewer/IViewer";
|
|
|
28
28
|
* Defines the file source to load into the viewer:
|
|
29
29
|
*
|
|
30
30
|
* - `File`, `Assembly` or `Model` instance from the Open Cloud Server
|
|
31
|
-
* -
|
|
31
|
+
* - `URL` string
|
|
32
32
|
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
33
33
|
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
34
34
|
* - {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
package/src/loaders/Loader.ts
CHANGED
|
@@ -43,4 +43,13 @@ export class Loader implements ILoader {
|
|
|
43
43
|
cancel(): void {
|
|
44
44
|
this.abortController.abort();
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
extractFileName(file: FileSource): string {
|
|
48
|
+
const regex = /[^/\\?#:]+(?=\?|#|$)/;
|
|
49
|
+
|
|
50
|
+
if (typeof file === "string") return (file.match(regex) || [])[0];
|
|
51
|
+
else if (file instanceof globalThis.File) return (file.name.match(regex) || [])[0];
|
|
52
|
+
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
46
55
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, 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-2025 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
|
+
* Model interface.
|
|
26
|
+
*/
|
|
27
|
+
export interface IModel {
|
|
28
|
+
/**
|
|
29
|
+
* Unique model ID, used as a model prefix when selecting objects in assemblies (multi-model scenes).
|
|
30
|
+
* Can be:
|
|
31
|
+
*
|
|
32
|
+
* - `file ID` - when loading a file from Open Cloud Server.
|
|
33
|
+
* - `assembly ID` - when loading an assembly from Open Cloud Server.
|
|
34
|
+
* - `model ID` - when loading a model of the file/assembly from Open Cloud Server.
|
|
35
|
+
* - `file name` - when loading from local File or URL.
|
|
36
|
+
* - `user defined` - when loading from ArrayBuffer or Data URL.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Disposes the model and releases allocated resources.
|
|
42
|
+
*/
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
package/src/viewer/IViewer.ts
CHANGED
|
@@ -27,7 +27,8 @@ import { ICommandService } from "../commands/ICommands";
|
|
|
27
27
|
import { IOptions } from "../options/IOptions";
|
|
28
28
|
import { IDragger } from "../draggers/IDraggers";
|
|
29
29
|
import { IComponent } from "../components/IComponents";
|
|
30
|
-
import { FileSource } from "../loaders/ILoader";
|
|
30
|
+
import { FileSource, ILoader } from "../loaders/ILoader";
|
|
31
|
+
import { IModel } from "../models/IModel";
|
|
31
32
|
import { IViewpoint } from "./IViewpoint";
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -78,6 +79,16 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
78
79
|
*/
|
|
79
80
|
canvasEvents: string[];
|
|
80
81
|
|
|
82
|
+
/**
|
|
83
|
+
* List of active loaders used to load models into the viewer.
|
|
84
|
+
*/
|
|
85
|
+
loaders: ILoader[];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* List of models loaded into the viewer.
|
|
89
|
+
*/
|
|
90
|
+
models: IModel[];
|
|
91
|
+
|
|
81
92
|
/**
|
|
82
93
|
* List of names of available draggers.
|
|
83
94
|
*
|
|
@@ -169,14 +180,16 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
169
180
|
* thrown.
|
|
170
181
|
*
|
|
171
182
|
* For URLs, the file extension is used to determine the file format. For a `ArrayBuffer` and `Data
|
|
172
|
-
* URL`, a file format must be specified using `params.format` parameter
|
|
173
|
-
*
|
|
183
|
+
* URL`, a file format must be specified using `params.format` parameter. If no appropriate loader is
|
|
184
|
+
* found for the specified format, an exception will be thrown.
|
|
174
185
|
*
|
|
175
186
|
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
176
187
|
* file, you must manually activate the required dragger.
|
|
177
188
|
*
|
|
178
189
|
* Fires:
|
|
179
190
|
*
|
|
191
|
+
* - {@link CancelEvent | cancel}
|
|
192
|
+
* - {@link ClearEvent | clear}
|
|
180
193
|
* - {@link OpenEvent | open}
|
|
181
194
|
* - {@link GeometryStartEvent | geometrystart}
|
|
182
195
|
* - {@link GeometryProgressEvent | geometryprogress}
|
|
@@ -185,23 +198,26 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
185
198
|
* - {@link GeometryEndEvent | geometryend}
|
|
186
199
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
187
200
|
*
|
|
188
|
-
* @param file - File to load. Can be
|
|
201
|
+
* @param file - File to load. Can be:
|
|
189
202
|
*
|
|
190
203
|
* - `File`, `Assembly` or `Model` instance from the Open Cloud Server
|
|
191
|
-
* -
|
|
204
|
+
* - `URL` string
|
|
192
205
|
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
193
206
|
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
194
207
|
* - {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
|
195
208
|
* object
|
|
196
209
|
*
|
|
197
210
|
* @param params - Loading parameters.
|
|
198
|
-
* @param params.format - File format
|
|
199
|
-
*
|
|
200
|
-
* @param params.mode - File opening mode. Viewer specific. Can be one of:
|
|
211
|
+
* @param params.format - File format. Required when loading a file as `ArrayBuffer` or `Data URL`.
|
|
212
|
+
* @param params.mode - File opening mode. Can be one of:
|
|
201
213
|
*
|
|
202
|
-
* - `
|
|
203
|
-
* - `
|
|
214
|
+
* - `file` - Single file mode. Unloads an open file and opens a new one. This is default mode.
|
|
215
|
+
* - `assembly` - Assembly mode. Appends a file to an already open file (). This mode is not supported
|
|
216
|
+
* for all viewers.
|
|
204
217
|
*
|
|
218
|
+
* @param params.modelId - Unique model ID in the assembly (multi-model scene). Used as a model prefix
|
|
219
|
+
* when selecting objects (see {@link getSelected2}). Must not contain the ":" (colon). Required when
|
|
220
|
+
* loading a file as `ArrayBuffer` or `Data URL`.
|
|
205
221
|
* @param params.requestHeader - The
|
|
206
222
|
* {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
|
|
207
223
|
* request.
|
|
@@ -215,6 +231,7 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
215
231
|
params: {
|
|
216
232
|
format?: string;
|
|
217
233
|
mode?: string;
|
|
234
|
+
modelId?: string;
|
|
218
235
|
requestHeader?: HeadersInit;
|
|
219
236
|
withCredentials?: boolean;
|
|
220
237
|
}
|
|
@@ -259,21 +276,45 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
259
276
|
clearSlices(): void;
|
|
260
277
|
|
|
261
278
|
/**
|
|
262
|
-
* Returns a list of original handles for the selected objects.
|
|
279
|
+
* Returns a list of original handles for the selected objects. To avoid handle collisions in
|
|
280
|
+
* assemblies (multi-model scenes), use {@link getSelected2} instead.
|
|
281
|
+
*
|
|
282
|
+
* @returns The list of original object handles.
|
|
263
283
|
*/
|
|
264
284
|
getSelected(): string[];
|
|
265
285
|
|
|
266
286
|
/**
|
|
267
|
-
*
|
|
287
|
+
* Returns a list of original handles for the selected objects in assemblies (multi-model scenes).
|
|
288
|
+
*
|
|
289
|
+
* @returns The list of original object handles with model prefix in format "model:handle".
|
|
290
|
+
*/
|
|
291
|
+
getSelected2(): string[];
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Selects the objects by original handles. To avoid handle collisions in assemblies (multi-model
|
|
295
|
+
* scenes), use {@link setSelected2} instead.
|
|
268
296
|
*
|
|
269
297
|
* Fires:
|
|
270
298
|
*
|
|
271
299
|
* - {@link SelectEvent | select}
|
|
300
|
+
* - {@link Select2Event | select2}
|
|
272
301
|
*
|
|
273
302
|
* @param handles - The list of original handles.
|
|
274
303
|
*/
|
|
275
304
|
setSelected(handles?: string[]): void;
|
|
276
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Selects the objects by original handles in assemblies (multi-model scenes).
|
|
308
|
+
*
|
|
309
|
+
* Fires:
|
|
310
|
+
*
|
|
311
|
+
* - {@link SelectEvent | select}
|
|
312
|
+
* - {@link Select2Event | select2}
|
|
313
|
+
*
|
|
314
|
+
* @param handles - The list of original handles with model prefix in format "model:handle".
|
|
315
|
+
*/
|
|
316
|
+
setSelected2(handles?: string[]): void;
|
|
317
|
+
|
|
277
318
|
/**
|
|
278
319
|
* Unselects all objects.
|
|
279
320
|
*
|
|
@@ -358,6 +399,8 @@ export interface IViewer extends IEventEmitter, ICommandService {
|
|
|
358
399
|
|
|
359
400
|
/**
|
|
360
401
|
* Returns the component reference, or `null` if there is no component with the specified name.
|
|
402
|
+
*
|
|
403
|
+
* @param name - Component name. Can be one of the {@link components} list.
|
|
361
404
|
*/
|
|
362
405
|
getComponent(name: string): IComponent | null;
|
|
363
406
|
|
|
@@ -45,7 +45,7 @@ export interface AnimateEvent {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Event that fires when
|
|
48
|
+
* Event that fires when file loading has been canceled.
|
|
49
49
|
*
|
|
50
50
|
* @event
|
|
51
51
|
*/
|
|
@@ -254,7 +254,7 @@ export interface GeometryChunkEvent {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
* Event that fires after
|
|
257
|
+
* Event that fires after file has been successfully loaded.
|
|
258
258
|
*
|
|
259
259
|
* @event
|
|
260
260
|
*/
|
|
@@ -317,7 +317,7 @@ export interface GeometryErrorEvent {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
|
-
* Event that measures the progress of the
|
|
320
|
+
* Event that measures the progress of the file loading.
|
|
321
321
|
*
|
|
322
322
|
* @event
|
|
323
323
|
*/
|
|
@@ -351,7 +351,7 @@ export interface GeometryProgressEvent {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
|
-
* Event that fires before the
|
|
354
|
+
* Event that fires before the file loads.
|
|
355
355
|
*
|
|
356
356
|
* @event
|
|
357
357
|
*/
|
|
@@ -445,7 +445,7 @@ export interface IsolateEvent {
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
/**
|
|
448
|
-
* Event that fires before
|
|
448
|
+
* Event that fires before file open.
|
|
449
449
|
*
|
|
450
450
|
* @event
|
|
451
451
|
*/
|
|
@@ -456,14 +456,14 @@ export interface OpenEvent {
|
|
|
456
456
|
type: "open";
|
|
457
457
|
|
|
458
458
|
/**
|
|
459
|
-
* File
|
|
459
|
+
* File opening mode.
|
|
460
460
|
*/
|
|
461
|
-
|
|
461
|
+
mode: string;
|
|
462
462
|
|
|
463
463
|
/**
|
|
464
|
-
*
|
|
464
|
+
* File to load.
|
|
465
465
|
*/
|
|
466
|
-
|
|
466
|
+
file: File | Assembly | Model | string | globalThis.File | ArrayBuffer;
|
|
467
467
|
|
|
468
468
|
/**
|
|
469
469
|
* Deprecated since `26.4`. Use {@link file} instead.
|
|
@@ -576,10 +576,33 @@ export interface SelectEvent {
|
|
|
576
576
|
/**
|
|
577
577
|
* Selection set (viewer dependent).
|
|
578
578
|
*/
|
|
579
|
-
data
|
|
579
|
+
data?: any;
|
|
580
580
|
|
|
581
581
|
/**
|
|
582
|
-
* Handles of selected
|
|
582
|
+
* Handles of selected objects.
|
|
583
|
+
*/
|
|
584
|
+
handles: string[];
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Event that fires after viewer selection changes. Uses model prefix to avoid handle collisions in
|
|
589
|
+
* assemblies (multi-model scenes).
|
|
590
|
+
*
|
|
591
|
+
* @event
|
|
592
|
+
*/
|
|
593
|
+
export interface Select2Event {
|
|
594
|
+
/**
|
|
595
|
+
* Event type.
|
|
596
|
+
*/
|
|
597
|
+
type: "select2";
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Selection set (viewer dependent).
|
|
601
|
+
*/
|
|
602
|
+
data?: any;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Handles of selected objects with model prefix in format "model:handle".
|
|
583
606
|
*/
|
|
584
607
|
handles: string[];
|
|
585
608
|
}
|
|
@@ -798,7 +821,7 @@ export interface ViewerEventMap {
|
|
|
798
821
|
animate: AnimateEvent;
|
|
799
822
|
|
|
800
823
|
/**
|
|
801
|
-
* Event that fires when
|
|
824
|
+
* Event that fires when file loading has been canceled.
|
|
802
825
|
*/
|
|
803
826
|
cancel: CancelEvent;
|
|
804
827
|
|
|
@@ -863,7 +886,7 @@ export interface ViewerEventMap {
|
|
|
863
886
|
geometrychunk: GeometryChunkEvent;
|
|
864
887
|
|
|
865
888
|
/**
|
|
866
|
-
* Event that fires after
|
|
889
|
+
* Event that fires after file has been successfully loaded.
|
|
867
890
|
*/
|
|
868
891
|
geometryend: GeometryEndEvent;
|
|
869
892
|
|
|
@@ -873,12 +896,12 @@ export interface ViewerEventMap {
|
|
|
873
896
|
geometryerror: GeometryErrorEvent;
|
|
874
897
|
|
|
875
898
|
/**
|
|
876
|
-
* Event that measures the progress of the
|
|
899
|
+
* Event that measures the progress of the file loading.
|
|
877
900
|
*/
|
|
878
901
|
geometryprogress: GeometryProgressEvent;
|
|
879
902
|
|
|
880
903
|
/**
|
|
881
|
-
* Event that fires before the
|
|
904
|
+
* Event that fires before the file opens.
|
|
882
905
|
*/
|
|
883
906
|
geometrystart: GeometryStartEvent;
|
|
884
907
|
|
|
@@ -903,7 +926,7 @@ export interface ViewerEventMap {
|
|
|
903
926
|
isolate: IsolateEvent;
|
|
904
927
|
|
|
905
928
|
/**
|
|
906
|
-
* Event that fires before
|
|
929
|
+
* Event that fires before file opens.
|
|
907
930
|
*/
|
|
908
931
|
open: OpenEvent;
|
|
909
932
|
|
|
@@ -932,6 +955,11 @@ export interface ViewerEventMap {
|
|
|
932
955
|
*/
|
|
933
956
|
select: SelectEvent;
|
|
934
957
|
|
|
958
|
+
/**
|
|
959
|
+
* Event that fires when the selection changes.
|
|
960
|
+
*/
|
|
961
|
+
select2: Select2Event;
|
|
962
|
+
|
|
935
963
|
/**
|
|
936
964
|
* Event that fires after selected objects becomes visible.
|
|
937
965
|
*/
|