@inweb/viewer-three 26.6.7 → 26.7.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/plugins/loaders/IFCXLoader.js +2 -2
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.min.js +1 -1
- package/dist/plugins/loaders/IFCXLoader.module.js +2 -2
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/viewer-three.js +45 -45
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +3 -1
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +28 -30
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +0 -3
- package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +2 -2
- package/lib/Viewer/loaders/index.d.ts +14 -10
- package/lib/Viewer/model/ModelImpl.d.ts +0 -3
- package/package.json +5 -5
- package/plugins/loaders/IFCXCloudLoader.ts +1 -1
- package/plugins/loaders/IFCXFileLoader.ts +1 -1
- package/src/Viewer/Viewer.ts +36 -30
- package/src/Viewer/components/CameraComponent.ts +1 -1
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +2 -3
- package/src/Viewer/loaders/GLTFFileLoader.ts +1 -1
- package/src/Viewer/loaders/GLTFLoadingManager.ts +2 -2
- package/src/Viewer/loaders/index.ts +14 -10
- package/src/Viewer/model/ModelImpl.ts +2 -3
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -55,29 +55,20 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
55
55
|
* nothing.
|
|
56
56
|
*
|
|
57
57
|
* This method requires a `Client` instance to be specified to load file from the Open Cloud Server.
|
|
58
|
-
* The file geometry data on the Open Cloud Server must be converted into a format
|
|
59
|
-
*
|
|
58
|
+
* The file geometry data on the Open Cloud Server must be converted into a `gltf` format, otherwise an
|
|
59
|
+
* exception will be thrown.
|
|
60
60
|
*
|
|
61
61
|
* For files from Open Cloud Server, the default model will be loaded. If there is no default model,
|
|
62
62
|
* first availiable model will be loaded. If no models are found in the file, an exception will be
|
|
63
63
|
* thrown.
|
|
64
64
|
*
|
|
65
|
-
*
|
|
66
|
-
* a file format must be specified using `params.format` parameter (see below). If no appropriate
|
|
65
|
+
* For URLs, the file extension is used to determine the file format. For a `ArrayBuffer` and `Data
|
|
66
|
+
* URL`, a file format must be specified using `params.format` parameter (see below). If no appropriate
|
|
67
67
|
* loader is found for the specified format, an exception will be thrown.
|
|
68
68
|
*
|
|
69
69
|
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
70
70
|
* file, you must manually activate the required dragger.
|
|
71
71
|
*
|
|
72
|
-
* To open a large files, enable {@link IOptions.enablePartialMode | partial streaming} mode before
|
|
73
|
-
* opening. For example:
|
|
74
|
-
*
|
|
75
|
-
* ```javascript
|
|
76
|
-
* viewer.options.enableStreamingMode = true;
|
|
77
|
-
* viewer.options.enablePartialMode = true;
|
|
78
|
-
* await viewer.open(file);
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
72
|
* Fires:
|
|
82
73
|
*
|
|
83
74
|
* - {@link OpenEvent | open}
|
|
@@ -88,40 +79,47 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
88
79
|
* - {@link GeometryEndEvent | geometryend}
|
|
89
80
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
90
81
|
*
|
|
91
|
-
* @param file - File to load.
|
|
82
|
+
* @param file - File to load. Can be one of:
|
|
83
|
+
*
|
|
84
|
+
* - `File`, `Assembly` or `Model` instance from the Open Cloud Server
|
|
85
|
+
* - File `URL` string
|
|
86
|
+
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
87
|
+
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
88
|
+
* - {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
|
89
|
+
* object
|
|
90
|
+
*
|
|
92
91
|
* @param params - Loading parameters.
|
|
93
|
-
* @param params.format - File format string. Required when loading a file as `ArrayBuffer
|
|
94
|
-
*
|
|
92
|
+
* @param params.format - File format string. Required when loading a file as `ArrayBuffer` or `Data
|
|
93
|
+
* URL`.
|
|
95
94
|
* @param params.mode - File opening mode. Can be one of:
|
|
96
95
|
*
|
|
97
96
|
* - `open` - Unloads an open file and opens a new one. This is default mode.
|
|
98
97
|
* - `append` - Appends a file to an already open file.
|
|
99
98
|
*
|
|
100
|
-
* @param params.externalFiles - External resource map such as binary data buffers or textures. Each
|
|
101
|
-
* resource should be represented by a `uri` and a corresponding resource URL, or
|
|
102
|
-
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
103
|
-
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
104
|
-
* or {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, or
|
|
105
|
-
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string,
|
|
106
|
-
* @param params.path - The base path from which additional resources will be loaded. If not defined,
|
|
107
|
-
* the base path of the file URL will be used.
|
|
108
99
|
* @param params.requestHeader - The
|
|
109
100
|
* {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
|
|
110
101
|
* request.
|
|
111
|
-
* @param params.
|
|
112
|
-
* different domain that allows CORS. Default is `anonymous`.
|
|
113
|
-
* @param params.withCredentials - Whether the XMLHttpRequest uses credentials such as cookies,
|
|
102
|
+
* @param params.withCredentials - Whether the HTTP request uses credentials such as cookies,
|
|
114
103
|
* authorization headers or TLS client certificates. See
|
|
115
104
|
* {@link https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/withCredentials | XMLHttpRequest.withCredentials}.
|
|
105
|
+
* @param params.path - The base path from which external resources such as binary data buffers, images
|
|
106
|
+
* or textures will be loaded. If not defined, the base path of the file URL will be used.
|
|
107
|
+
* @param params.externalFiles - External resource map. Each resource should be represented by a `uri`
|
|
108
|
+
* and a corresponding resource URL, or
|
|
109
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string, or
|
|
110
|
+
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
111
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}.
|
|
112
|
+
* @param params.crossOrigin - The crossOrigin string to implement CORS for loading the external
|
|
113
|
+
* resources from a different domain that allows CORS. Default is `anonymous`.
|
|
116
114
|
*/
|
|
117
115
|
open(file: FileSource, params?: {
|
|
118
116
|
format?: string;
|
|
119
117
|
mode?: string;
|
|
120
|
-
path?: string;
|
|
121
|
-
externalFiles?: Map<string, string | globalThis.File | ArrayBuffer | Blob>;
|
|
122
118
|
requestHeader?: HeadersInit;
|
|
123
|
-
crossOrigin?: string;
|
|
124
119
|
withCredentials?: boolean;
|
|
120
|
+
path?: string;
|
|
121
|
+
externalFiles?: Map<string, string | globalThis.File | ArrayBuffer>;
|
|
122
|
+
crossOrigin?: string;
|
|
125
123
|
}): Promise<this>;
|
|
126
124
|
/**
|
|
127
125
|
* Deprecated since `26.4`. Use {@link open | open()} instead.
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Box3, Object3D } from "three";
|
|
2
2
|
import { ModelImpl } from "../../model";
|
|
3
3
|
import { DynamicGltfLoader } from "./DynamicGltfLoader.js";
|
|
4
|
-
/**
|
|
5
|
-
* Dynamic model implementation.
|
|
6
|
-
*/
|
|
7
4
|
export declare class DynamicModelImpl extends ModelImpl {
|
|
8
5
|
gltfLoader: DynamicGltfLoader;
|
|
9
6
|
getExtents(target: Box3): Box3;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LoadingManager } from "three";
|
|
2
|
-
export type GLTFFileSource = string | globalThis.File | ArrayBuffer
|
|
2
|
+
export type GLTFFileSource = string | globalThis.File | ArrayBuffer;
|
|
3
3
|
export type GLTFLoadParams = {
|
|
4
4
|
path?: string;
|
|
5
5
|
externalFiles?: Map<string, GLTFFileSource>;
|
|
6
|
-
requestHeader?: HeadersInit;
|
|
7
6
|
crossOrigin?: string;
|
|
7
|
+
requestHeader?: HeadersInit;
|
|
8
8
|
withCredentials?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare class GLTFLoadingManager extends LoadingManager {
|
|
@@ -7,12 +7,13 @@ import { ILoadersRegistry } from "@inweb/viewer-core";
|
|
|
7
7
|
* 1. Define a loader class implements {@link ILoader}.
|
|
8
8
|
* 2. Define a constructor with a `viewer` parameter.
|
|
9
9
|
* 3. Override {@link ILoader.isSupport} and сheck if the loader can load the specified file.
|
|
10
|
-
* 4. Override {@link ILoader.load} and define the logic for loading the
|
|
10
|
+
* 4. Override {@link ILoader.load} and define the logic for loading the scene from the file.
|
|
11
11
|
*
|
|
12
12
|
* The loader should do:
|
|
13
13
|
*
|
|
14
|
-
* - Load
|
|
15
|
-
* - Add
|
|
14
|
+
* - Load scene from file. The scene must be a Three.js object of type `Object3D` or a descendant of it.
|
|
15
|
+
* - Add scene to the viewer `scene`.
|
|
16
|
+
* - Create `ModelImpl` for the scene and to the viewer `models` list.
|
|
16
17
|
* - Synchronize viewer options and overlay.
|
|
17
18
|
* - Update the viewer.
|
|
18
19
|
*
|
|
@@ -20,15 +21,14 @@ import { ILoadersRegistry } from "@inweb/viewer-core";
|
|
|
20
21
|
*
|
|
21
22
|
* - `geometryprogress` - during loading. If progress is not supported, emit it once with a value of 100%
|
|
22
23
|
* after the load is complete.
|
|
23
|
-
* - `databasechunk` - when
|
|
24
|
+
* - `databasechunk` - when scene is loaded and ready to render.
|
|
24
25
|
* 5. Override {@link ILoader.dispose} and release loader resources, if required.
|
|
25
26
|
* 6. Register loader provider in the loaders registry by calling the {@link loaders.registerLoader}.
|
|
26
27
|
*
|
|
27
28
|
* @example Implementing a custom loader.
|
|
28
29
|
*
|
|
29
30
|
* ```javascript
|
|
30
|
-
* import { Loader } from "@inweb/viewer-
|
|
31
|
-
* import { loaders, Viewer } from "@inweb/viewer-three";
|
|
31
|
+
* import { loaders, Loader, ModelImpl, Viewer } from "@inweb/viewer-three";
|
|
32
32
|
*
|
|
33
33
|
* class MyLoader extends Loader {
|
|
34
34
|
* public viewer: Viewer;
|
|
@@ -46,16 +46,20 @@ import { ILoadersRegistry } from "@inweb/viewer-core";
|
|
|
46
46
|
* override load(file, format, params): Promise<this> {
|
|
47
47
|
*
|
|
48
48
|
* // place custom loading logic here
|
|
49
|
-
* const
|
|
49
|
+
* const scene = ...;
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
* this
|
|
51
|
+
* const modelImpl = new ModelImpl(scene);
|
|
52
|
+
* modelImpl.loader = this;
|
|
53
|
+
* modelImpl.viewer = this.viewer;
|
|
54
|
+
*
|
|
55
|
+
* this.viewer.scene.add(scene);
|
|
56
|
+
* this.viewer.models.push(modelImpl);
|
|
53
57
|
*
|
|
54
58
|
* this.viewer.syncOptions();
|
|
55
59
|
* this.viewer.syncOverlay();
|
|
56
60
|
* this.viewer.update();
|
|
57
61
|
*
|
|
58
|
-
* this.viewer.emitEvent({ type: "databasechunk", data:
|
|
62
|
+
* this.viewer.emitEvent({ type: "databasechunk", data: scene, file });
|
|
59
63
|
*
|
|
60
64
|
* return Promise.resove(this);
|
|
61
65
|
* };
|
|
@@ -2,9 +2,6 @@ import { Box3, Object3D } from "three";
|
|
|
2
2
|
import { ILoader } from "@inweb/viewer-core";
|
|
3
3
|
import { IModelImpl } from "./IModelImpl";
|
|
4
4
|
import { Viewer } from "../Viewer";
|
|
5
|
-
/**
|
|
6
|
-
* Basic model implementation.
|
|
7
|
-
*/
|
|
8
5
|
export declare class ModelImpl implements IModelImpl {
|
|
9
6
|
handle: string;
|
|
10
7
|
scene: Object3D;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.7.1",
|
|
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",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"docs": "typedoc"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@inweb/client": "~26.
|
|
39
|
-
"@inweb/eventemitter2": "~26.
|
|
40
|
-
"@inweb/markup": "~26.
|
|
41
|
-
"@inweb/viewer-core": "~26.
|
|
38
|
+
"@inweb/client": "~26.7.1",
|
|
39
|
+
"@inweb/eventemitter2": "~26.7.1",
|
|
40
|
+
"@inweb/markup": "~26.7.1",
|
|
41
|
+
"@inweb/viewer-core": "~26.7.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/three": "^0.173.0",
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -273,29 +273,20 @@ export class Viewer
|
|
|
273
273
|
* nothing.
|
|
274
274
|
*
|
|
275
275
|
* This method requires a `Client` instance to be specified to load file from the Open Cloud Server.
|
|
276
|
-
* The file geometry data on the Open Cloud Server must be converted into a format
|
|
277
|
-
*
|
|
276
|
+
* The file geometry data on the Open Cloud Server must be converted into a `gltf` format, otherwise an
|
|
277
|
+
* exception will be thrown.
|
|
278
278
|
*
|
|
279
279
|
* For files from Open Cloud Server, the default model will be loaded. If there is no default model,
|
|
280
280
|
* first availiable model will be loaded. If no models are found in the file, an exception will be
|
|
281
281
|
* thrown.
|
|
282
282
|
*
|
|
283
|
-
*
|
|
284
|
-
* a file format must be specified using `params.format` parameter (see below). If no appropriate
|
|
283
|
+
* For URLs, the file extension is used to determine the file format. For a `ArrayBuffer` and `Data
|
|
284
|
+
* URL`, a file format must be specified using `params.format` parameter (see below). If no appropriate
|
|
285
285
|
* loader is found for the specified format, an exception will be thrown.
|
|
286
286
|
*
|
|
287
287
|
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
288
288
|
* file, you must manually activate the required dragger.
|
|
289
289
|
*
|
|
290
|
-
* To open a large files, enable {@link IOptions.enablePartialMode | partial streaming} mode before
|
|
291
|
-
* opening. For example:
|
|
292
|
-
*
|
|
293
|
-
* ```javascript
|
|
294
|
-
* viewer.options.enableStreamingMode = true;
|
|
295
|
-
* viewer.options.enablePartialMode = true;
|
|
296
|
-
* await viewer.open(file);
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
290
|
* Fires:
|
|
300
291
|
*
|
|
301
292
|
* - {@link OpenEvent | open}
|
|
@@ -306,42 +297,49 @@ export class Viewer
|
|
|
306
297
|
* - {@link GeometryEndEvent | geometryend}
|
|
307
298
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
308
299
|
*
|
|
309
|
-
* @param file - File to load.
|
|
300
|
+
* @param file - File to load. Can be one of:
|
|
301
|
+
*
|
|
302
|
+
* - `File`, `Assembly` or `Model` instance from the Open Cloud Server
|
|
303
|
+
* - File `URL` string
|
|
304
|
+
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
305
|
+
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
306
|
+
* - {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
|
307
|
+
* object
|
|
308
|
+
*
|
|
310
309
|
* @param params - Loading parameters.
|
|
311
|
-
* @param params.format - File format string. Required when loading a file as `ArrayBuffer
|
|
312
|
-
*
|
|
310
|
+
* @param params.format - File format string. Required when loading a file as `ArrayBuffer` or `Data
|
|
311
|
+
* URL`.
|
|
313
312
|
* @param params.mode - File opening mode. Can be one of:
|
|
314
313
|
*
|
|
315
314
|
* - `open` - Unloads an open file and opens a new one. This is default mode.
|
|
316
315
|
* - `append` - Appends a file to an already open file.
|
|
317
316
|
*
|
|
318
|
-
* @param params.externalFiles - External resource map such as binary data buffers or textures. Each
|
|
319
|
-
* resource should be represented by a `uri` and a corresponding resource URL, or
|
|
320
|
-
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
321
|
-
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
322
|
-
* or {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, or
|
|
323
|
-
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string,
|
|
324
|
-
* @param params.path - The base path from which additional resources will be loaded. If not defined,
|
|
325
|
-
* the base path of the file URL will be used.
|
|
326
317
|
* @param params.requestHeader - The
|
|
327
318
|
* {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
|
|
328
319
|
* request.
|
|
329
|
-
* @param params.
|
|
330
|
-
* different domain that allows CORS. Default is `anonymous`.
|
|
331
|
-
* @param params.withCredentials - Whether the XMLHttpRequest uses credentials such as cookies,
|
|
320
|
+
* @param params.withCredentials - Whether the HTTP request uses credentials such as cookies,
|
|
332
321
|
* authorization headers or TLS client certificates. See
|
|
333
322
|
* {@link https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/withCredentials | XMLHttpRequest.withCredentials}.
|
|
323
|
+
* @param params.path - The base path from which external resources such as binary data buffers, images
|
|
324
|
+
* or textures will be loaded. If not defined, the base path of the file URL will be used.
|
|
325
|
+
* @param params.externalFiles - External resource map. Each resource should be represented by a `uri`
|
|
326
|
+
* and a corresponding resource URL, or
|
|
327
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string, or
|
|
328
|
+
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
329
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}.
|
|
330
|
+
* @param params.crossOrigin - The crossOrigin string to implement CORS for loading the external
|
|
331
|
+
* resources from a different domain that allows CORS. Default is `anonymous`.
|
|
334
332
|
*/
|
|
335
333
|
async open(
|
|
336
334
|
file: FileSource,
|
|
337
335
|
params: {
|
|
338
336
|
format?: string;
|
|
339
337
|
mode?: string;
|
|
340
|
-
path?: string;
|
|
341
|
-
externalFiles?: Map<string, string | globalThis.File | ArrayBuffer | Blob>;
|
|
342
338
|
requestHeader?: HeadersInit;
|
|
343
|
-
crossOrigin?: string;
|
|
344
339
|
withCredentials?: boolean;
|
|
340
|
+
path?: string;
|
|
341
|
+
externalFiles?: Map<string, string | globalThis.File | ArrayBuffer>;
|
|
342
|
+
crossOrigin?: string;
|
|
345
343
|
} = {}
|
|
346
344
|
): Promise<this> {
|
|
347
345
|
if (!this.renderer) return this;
|
|
@@ -388,6 +386,10 @@ export class Viewer
|
|
|
388
386
|
* @deprecated
|
|
389
387
|
*/
|
|
390
388
|
openGltfFile(file, externalFiles, params: any = {}): Promise<this> {
|
|
389
|
+
console.warn(
|
|
390
|
+
"Viewer.openGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."
|
|
391
|
+
);
|
|
392
|
+
|
|
391
393
|
return this.open(file, { ...params, format: "gltf", externalFiles });
|
|
392
394
|
}
|
|
393
395
|
|
|
@@ -397,6 +399,10 @@ export class Viewer
|
|
|
397
399
|
* @deprecated
|
|
398
400
|
*/
|
|
399
401
|
loadGltfFile(file, externalFiles, params: any = {}): Promise<this> {
|
|
402
|
+
console.warn(
|
|
403
|
+
"Viewer.loadGltfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead."
|
|
404
|
+
);
|
|
405
|
+
|
|
400
406
|
return this.open(file, { ...params, format: "gltf", externalFiles, mode: "append" });
|
|
401
407
|
}
|
|
402
408
|
|
|
@@ -54,7 +54,7 @@ export class CameraComponent implements IComponent {
|
|
|
54
54
|
if (sceneCamera) {
|
|
55
55
|
this.viewer.camera = sceneCamera.clone();
|
|
56
56
|
this.viewer.camera.up.set(0, 0, 1);
|
|
57
|
-
this.viewer.camera.scale.set(1, 1, 1); // <-
|
|
57
|
+
this.viewer.camera.scale.set(1, 1, 1); // <- Visualize fix
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const camera = this.viewer.camera as any;
|
|
@@ -26,9 +26,8 @@ import { Box3, Object3D } from "three";
|
|
|
26
26
|
import { ModelImpl } from "../../model";
|
|
27
27
|
import { DynamicGltfLoader } from "./DynamicGltfLoader.js";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
29
|
+
// Dynamic model implementation.
|
|
30
|
+
|
|
32
31
|
export class DynamicModelImpl extends ModelImpl {
|
|
33
32
|
public gltfLoader: DynamicGltfLoader;
|
|
34
33
|
|
|
@@ -64,7 +64,7 @@ export class GLTFFileLoader extends Loader {
|
|
|
64
64
|
modelImpl.loader = this;
|
|
65
65
|
modelImpl.viewer = this.viewer;
|
|
66
66
|
|
|
67
|
-
this.viewer.scene.add(
|
|
67
|
+
this.viewer.scene.add(gltf.scene);
|
|
68
68
|
this.viewer.models.push(modelImpl);
|
|
69
69
|
|
|
70
70
|
this.viewer.syncOptions();
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
|
|
24
24
|
import { LoadingManager, LoaderUtils } from "three";
|
|
25
25
|
|
|
26
|
-
export type GLTFFileSource = string | globalThis.File | ArrayBuffer
|
|
26
|
+
export type GLTFFileSource = string | globalThis.File | ArrayBuffer;
|
|
27
27
|
|
|
28
28
|
export type GLTFLoadParams = {
|
|
29
29
|
path?: string;
|
|
30
30
|
externalFiles?: Map<string, GLTFFileSource>;
|
|
31
|
-
requestHeader?: HeadersInit;
|
|
32
31
|
crossOrigin?: string;
|
|
32
|
+
requestHeader?: HeadersInit;
|
|
33
33
|
withCredentials?: boolean;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -34,12 +34,13 @@ import { GLTFCloudDynamicLoader } from "./GLTFCloudDynamicLoader";
|
|
|
34
34
|
* 1. Define a loader class implements {@link ILoader}.
|
|
35
35
|
* 2. Define a constructor with a `viewer` parameter.
|
|
36
36
|
* 3. Override {@link ILoader.isSupport} and сheck if the loader can load the specified file.
|
|
37
|
-
* 4. Override {@link ILoader.load} and define the logic for loading the
|
|
37
|
+
* 4. Override {@link ILoader.load} and define the logic for loading the scene from the file.
|
|
38
38
|
*
|
|
39
39
|
* The loader should do:
|
|
40
40
|
*
|
|
41
|
-
* - Load
|
|
42
|
-
* - Add
|
|
41
|
+
* - Load scene from file. The scene must be a Three.js object of type `Object3D` or a descendant of it.
|
|
42
|
+
* - Add scene to the viewer `scene`.
|
|
43
|
+
* - Create `ModelImpl` for the scene and to the viewer `models` list.
|
|
43
44
|
* - Synchronize viewer options and overlay.
|
|
44
45
|
* - Update the viewer.
|
|
45
46
|
*
|
|
@@ -47,15 +48,14 @@ import { GLTFCloudDynamicLoader } from "./GLTFCloudDynamicLoader";
|
|
|
47
48
|
*
|
|
48
49
|
* - `geometryprogress` - during loading. If progress is not supported, emit it once with a value of 100%
|
|
49
50
|
* after the load is complete.
|
|
50
|
-
* - `databasechunk` - when
|
|
51
|
+
* - `databasechunk` - when scene is loaded and ready to render.
|
|
51
52
|
* 5. Override {@link ILoader.dispose} and release loader resources, if required.
|
|
52
53
|
* 6. Register loader provider in the loaders registry by calling the {@link loaders.registerLoader}.
|
|
53
54
|
*
|
|
54
55
|
* @example Implementing a custom loader.
|
|
55
56
|
*
|
|
56
57
|
* ```javascript
|
|
57
|
-
* import { Loader } from "@inweb/viewer-
|
|
58
|
-
* import { loaders, Viewer } from "@inweb/viewer-three";
|
|
58
|
+
* import { loaders, Loader, ModelImpl, Viewer } from "@inweb/viewer-three";
|
|
59
59
|
*
|
|
60
60
|
* class MyLoader extends Loader {
|
|
61
61
|
* public viewer: Viewer;
|
|
@@ -73,16 +73,20 @@ import { GLTFCloudDynamicLoader } from "./GLTFCloudDynamicLoader";
|
|
|
73
73
|
* override load(file, format, params): Promise<this> {
|
|
74
74
|
*
|
|
75
75
|
* // place custom loading logic here
|
|
76
|
-
* const
|
|
76
|
+
* const scene = ...;
|
|
77
77
|
*
|
|
78
|
-
*
|
|
79
|
-
* this
|
|
78
|
+
* const modelImpl = new ModelImpl(scene);
|
|
79
|
+
* modelImpl.loader = this;
|
|
80
|
+
* modelImpl.viewer = this.viewer;
|
|
81
|
+
*
|
|
82
|
+
* this.viewer.scene.add(scene);
|
|
83
|
+
* this.viewer.models.push(modelImpl);
|
|
80
84
|
*
|
|
81
85
|
* this.viewer.syncOptions();
|
|
82
86
|
* this.viewer.syncOverlay();
|
|
83
87
|
* this.viewer.update();
|
|
84
88
|
*
|
|
85
|
-
* this.viewer.emitEvent({ type: "databasechunk", data:
|
|
89
|
+
* this.viewer.emitEvent({ type: "databasechunk", data: scene, file });
|
|
86
90
|
*
|
|
87
91
|
* return Promise.resove(this);
|
|
88
92
|
* };
|
|
@@ -27,9 +27,8 @@ import { ILoader } from "@inweb/viewer-core";
|
|
|
27
27
|
import { IModelImpl } from "./IModelImpl";
|
|
28
28
|
import { Viewer } from "../Viewer";
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
30
|
+
// Basic model implementation.
|
|
31
|
+
|
|
33
32
|
export class ModelImpl implements IModelImpl {
|
|
34
33
|
public handle: string;
|
|
35
34
|
public scene: Object3D;
|