@inweb/viewer-three 26.5.0 → 26.5.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/components/AxesHelperComponent.js +65 -0
- package/dist/plugins/components/AxesHelperComponent.js.map +1 -0
- package/dist/plugins/components/AxesHelperComponent.min.js +1 -0
- package/dist/plugins/components/AxesHelperComponent.module.js +39 -0
- package/dist/plugins/components/AxesHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/ExtentsHelperComponent.js +55 -0
- package/dist/plugins/components/ExtentsHelperComponent.js.map +1 -0
- package/dist/plugins/components/ExtentsHelperComponent.min.js +1 -0
- package/dist/plugins/components/ExtentsHelperComponent.module.js +29 -0
- package/dist/plugins/components/ExtentsHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/LightHelperComponent.js +65 -0
- package/dist/plugins/components/LightHelperComponent.js.map +1 -0
- package/dist/plugins/components/LightHelperComponent.min.js +1 -0
- package/dist/plugins/components/LightHelperComponent.module.js +40 -0
- package/dist/plugins/components/LightHelperComponent.module.js.map +1 -0
- package/dist/plugins/loaders/IFCXLoader.js +887 -0
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -0
- package/dist/plugins/loaders/IFCXLoader.min.js +1 -0
- package/dist/plugins/loaders/IFCXLoader.module.js +726 -0
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -0
- package/dist/viewer-three.js +49075 -32407
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -7
- package/dist/viewer-three.module.js +192 -86
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +51 -68
- package/lib/Viewer/loaders/GLTFFileLoader.d.ts +9 -0
- package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +9 -3
- package/lib/Viewer/loaders/GLTFModelLoader.d.ts +8 -0
- package/lib/Viewer/loaders/index.d.ts +67 -0
- package/lib/index-umd.d.ts +1 -0
- package/lib/index.d.ts +6 -4
- package/package.json +10 -7
- package/{src/Viewer → plugins}/components/AxesHelperComponent.ts +4 -4
- package/{src/Viewer → plugins}/components/ExtentsHelperComponent.ts +4 -4
- package/{src/Viewer → plugins}/components/LightHelperComponent.ts +4 -4
- package/plugins/loaders/IFCX/IFCXLoader.ts +71 -0
- package/plugins/loaders/IFCX/render.js +701 -0
- package/plugins/loaders/IFCXFileLoader.ts +76 -0
- package/plugins/loaders/IFCXLoader.ts +30 -0
- package/plugins/loaders/IFCXModelLoader.ts +75 -0
- package/src/Viewer/Viewer.ts +101 -148
- package/src/Viewer/commands/Explode.ts +2 -2
- package/src/Viewer/components/index.ts +2 -8
- package/src/Viewer/loaders/GLTFFileLoader.ts +73 -0
- package/src/Viewer/loaders/GLTFLoadingManager.ts +16 -8
- package/src/Viewer/loaders/GLTFModelLoader.ts +74 -0
- package/src/Viewer/loaders/index.ts +99 -0
- package/src/index-umd.ts +30 -0
- package/src/index.ts +9 -5
- package/lib/Viewer/components/AxesHelperComponent.d.ts +0 -10
- package/lib/Viewer/components/ExtentsHelperComponent.d.ts +0 -9
- package/lib/Viewer/components/LightHelperComponent.d.ts +0 -9
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Box3, Object3D, OrthographicCamera, PerspectiveCamera, Scene, Vector3, WebGLRenderer } from "three";
|
|
2
|
-
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
3
2
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
4
3
|
import { Assembly, Client, Model, File } from "@inweb/client";
|
|
5
|
-
import { CanvasEventMap, IComponent, IDragger, IOptions, IViewer, IViewpoint, Options, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
4
|
+
import { CanvasEventMap, FileSource, IComponent, IDragger, ILoader, IOptions, IViewer, IViewpoint, Options, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
6
5
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
7
6
|
/**
|
|
8
7
|
* 3D viewer powered by {@link https://threejs.org/ | Three.js}.
|
|
@@ -17,7 +16,8 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
17
16
|
helpers: Scene | undefined;
|
|
18
17
|
camera: PerspectiveCamera | OrthographicCamera | undefined;
|
|
19
18
|
renderer: WebGLRenderer | undefined;
|
|
20
|
-
models: Array<
|
|
19
|
+
models: Array<Object3D>;
|
|
20
|
+
loaders: Array<ILoader>;
|
|
21
21
|
selected: Array<Object3D>;
|
|
22
22
|
extents: Box3;
|
|
23
23
|
target: Vector3;
|
|
@@ -49,17 +49,35 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
49
49
|
syncOptions(options?: IOptions): void;
|
|
50
50
|
loadReferences(model: Model | File | Assembly): Promise<this>;
|
|
51
51
|
/**
|
|
52
|
-
* Loads a file
|
|
52
|
+
* Loads a file into the viewer.
|
|
53
53
|
*
|
|
54
|
-
* The
|
|
54
|
+
* The viewer must be {@link initialize | initialized} before opening the file. Otherwise, `open()` does
|
|
55
|
+
* nothing.
|
|
55
56
|
*
|
|
56
|
-
* This method requires a `Client` instance to be specified
|
|
57
|
-
*
|
|
58
|
-
*
|
|
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 siutable for the
|
|
59
|
+
* viewer, otherwise an exception will be thrown.
|
|
60
|
+
*
|
|
61
|
+
* For files from Open Cloud Server, the default model will be loaded. If there is no default model,
|
|
62
|
+
* first availiable model will be loaded. If no models are found in the file, an exception will be
|
|
63
|
+
* thrown.
|
|
64
|
+
*
|
|
65
|
+
* The file extension is used to determine the file format. For a `ArrayBuffer`, `Blob` and `Data URL`,
|
|
66
|
+
* a file format must be specified using `params.format` parameter (see below). If no appropriate
|
|
67
|
+
* loader is found for the specified format, an exception will be thrown.
|
|
59
68
|
*
|
|
60
69
|
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
61
70
|
* file, you must manually activate the required dragger.
|
|
62
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
|
+
*
|
|
63
81
|
* Fires:
|
|
64
82
|
*
|
|
65
83
|
* - {@link OpenEvent | open}
|
|
@@ -70,37 +88,23 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
70
88
|
* - {@link GeometryEndEvent | geometryend}
|
|
71
89
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
72
90
|
*
|
|
73
|
-
* @param file - File
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
cancel(): this;
|
|
79
|
-
/**
|
|
80
|
-
* Loads a `glTF` file into the viewer.
|
|
81
|
-
*
|
|
82
|
-
* If there was an active dragger before opening the file, it will be deactivated. After opening the
|
|
83
|
-
* file, you must manually activate the required dragger.
|
|
91
|
+
* @param file - File to load.
|
|
92
|
+
* @param params - Loading parameters.
|
|
93
|
+
* @param params.format - File format string. Required when loading a file as `ArrayBuffer`, `Blob` or
|
|
94
|
+
* `Data URL`.
|
|
95
|
+
* @param params.mode - File opening mode. Can be one of:
|
|
84
96
|
*
|
|
85
|
-
*
|
|
97
|
+
* - `open` - Unloads an open file and opens a new one. This is default mode.
|
|
98
|
+
* - `append` - Appends a file to an already open file.
|
|
86
99
|
*
|
|
87
|
-
* -
|
|
88
|
-
*
|
|
89
|
-
* - {@link GeometryProgressEvent | geometryprogress}
|
|
90
|
-
* - {@link DatabaseChunkEvent | databasechunk}
|
|
91
|
-
* - {@link GeometryEndEvent | geometryend}
|
|
92
|
-
* - {@link GeometryErrorEvent | geometryerror}
|
|
93
|
-
*
|
|
94
|
-
* @param file - File URL or binary data buffer to load.
|
|
95
|
-
* @param externalData - External resource map such as binary data buffers or images. Each resource
|
|
96
|
-
* should be represented by a `uri` and a corresponding resource URL, or
|
|
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
|
|
97
102
|
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
98
|
-
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
|
103
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
99
104
|
* or {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, or
|
|
100
105
|
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string,
|
|
101
|
-
* @param params -
|
|
102
|
-
*
|
|
103
|
-
* .bin data files. If not defined, the base path of the file URL will be used.
|
|
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.
|
|
104
108
|
* @param params.requestHeader - The
|
|
105
109
|
* {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
|
|
106
110
|
* request.
|
|
@@ -110,49 +114,28 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
110
114
|
* authorization headers or TLS client certificates. See
|
|
111
115
|
* {@link https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/withCredentials | XMLHttpRequest.withCredentials}.
|
|
112
116
|
*/
|
|
113
|
-
|
|
117
|
+
open(file: FileSource, params?: {
|
|
118
|
+
format?: string;
|
|
119
|
+
mode?: string;
|
|
114
120
|
path?: string;
|
|
121
|
+
externalFiles?: Map<string, string | globalThis.File | ArrayBuffer | Blob>;
|
|
115
122
|
requestHeader?: HeadersInit;
|
|
116
123
|
crossOrigin?: string;
|
|
117
124
|
withCredentials?: boolean;
|
|
118
125
|
}): Promise<this>;
|
|
119
126
|
/**
|
|
120
|
-
*
|
|
127
|
+
* Deprecated since `26.4`. Use {@link open | open()} instead.
|
|
121
128
|
*
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
* - {@link DatabaseChunkEvent | databasechunk}
|
|
128
|
-
* - {@link GeometryEndEvent | geometryend}
|
|
129
|
-
* - {@link GeometryErrorEvent | geometryerror}
|
|
129
|
+
* @deprecated
|
|
130
|
+
*/
|
|
131
|
+
openGltfFile(file: any, externalFiles: any, params?: any): Promise<this>;
|
|
132
|
+
/**
|
|
133
|
+
* Deprecated since `26.4`. Use {@link open | open()} instead.
|
|
130
134
|
*
|
|
131
|
-
* @
|
|
132
|
-
* @param externalData - External resource map such as binary data buffers or images. Each resource
|
|
133
|
-
* should be represented by a `uri` and a corresponding resource URL, or
|
|
134
|
-
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object, or
|
|
135
|
-
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer}
|
|
136
|
-
* or {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, or
|
|
137
|
-
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string,
|
|
138
|
-
* @param params - Loader parameters.
|
|
139
|
-
* @param params.path - The base path from which to find subsequent glTF resources such as textures and
|
|
140
|
-
* .bin data files.
|
|
141
|
-
* @param params.requestHeader - The
|
|
142
|
-
* {@link https://developer.mozilla.org/docs/Glossary/Request_header | request header} used in HTTP
|
|
143
|
-
* request.
|
|
144
|
-
* @param params.crossOrigin - The crossOrigin string to implement CORS for loading the url from a
|
|
145
|
-
* different domain that allows CORS. Default is `anonymous`.
|
|
146
|
-
* @param params.withCredentials - Whether the XMLHttpRequest uses credentials such as cookies,
|
|
147
|
-
* authorization headers or TLS client certificates. See
|
|
148
|
-
* {@link https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/withCredentials | XMLHttpRequest.withCredentials}.
|
|
135
|
+
* @deprecated
|
|
149
136
|
*/
|
|
150
|
-
loadGltfFile(file:
|
|
151
|
-
|
|
152
|
-
requestHeader?: HeadersInit;
|
|
153
|
-
crossOrigin?: string;
|
|
154
|
-
withCredentials?: boolean;
|
|
155
|
-
}): Promise<this>;
|
|
137
|
+
loadGltfFile(file: any, externalFiles: any, params?: any): Promise<this>;
|
|
138
|
+
cancel(): this;
|
|
156
139
|
clear(): this;
|
|
157
140
|
syncOverlay(): void;
|
|
158
141
|
clearOverlay(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Loader } from "@inweb/viewer-core";
|
|
2
|
+
import { Viewer } from "../Viewer";
|
|
3
|
+
import { GLTFLoadParams } from "./GLTFLoadingManager";
|
|
4
|
+
export declare class GLTFFileLoader extends Loader {
|
|
5
|
+
viewer: Viewer;
|
|
6
|
+
constructor(viewer: Viewer);
|
|
7
|
+
isSupport(file: any, format?: string): boolean;
|
|
8
|
+
load(buffer: any, format?: string, params?: GLTFLoadParams): Promise<this>;
|
|
9
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { LoadingManager } from "three";
|
|
2
|
+
export type GLTFFileSource = string | globalThis.File | ArrayBuffer | Blob;
|
|
3
|
+
export type GLTFLoadParams = {
|
|
4
|
+
path?: string;
|
|
5
|
+
externalFiles?: Map<string, GLTFFileSource>;
|
|
6
|
+
requestHeader?: HeadersInit;
|
|
7
|
+
crossOrigin?: string;
|
|
8
|
+
withCredentials?: boolean;
|
|
9
|
+
};
|
|
2
10
|
export declare class GLTFLoadingManager extends LoadingManager {
|
|
3
11
|
path: string;
|
|
4
12
|
resourcePath: string;
|
|
5
13
|
fileURL: string;
|
|
6
14
|
dataURLs: Map<any, any>;
|
|
7
|
-
constructor(file:
|
|
8
|
-
path?: string;
|
|
9
|
-
});
|
|
15
|
+
constructor(file: GLTFFileSource, params?: GLTFLoadParams);
|
|
10
16
|
dispose(): void;
|
|
11
17
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ILoadersRegistry } from "@inweb/viewer-core";
|
|
2
|
+
/**
|
|
3
|
+
* Viewer loaders registry. Use this registry to register custom loaders.
|
|
4
|
+
*
|
|
5
|
+
* To implement custom loader:
|
|
6
|
+
*
|
|
7
|
+
* 1. Define a loader class implements {@link ILoader}.
|
|
8
|
+
* 2. Define a constructor with a `viewer` parameter.
|
|
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 model from the file.
|
|
11
|
+
*
|
|
12
|
+
* The loader should do:
|
|
13
|
+
*
|
|
14
|
+
* - Load model from file. The model must be a Three.js object of type `Object3D` or a descendant of it.
|
|
15
|
+
* - Add model to the viewer `scene` and `models` list.
|
|
16
|
+
* - Synchronize viewer options and overlay.
|
|
17
|
+
* - Update the viewer.
|
|
18
|
+
*
|
|
19
|
+
* The loader must emit events:
|
|
20
|
+
*
|
|
21
|
+
* - `geometryprogress` - during loading. If progress is not supported, emit it once with a value of 100%
|
|
22
|
+
* after the load is complete.
|
|
23
|
+
* - `databasechunk` - when model is loaded and ready to render.
|
|
24
|
+
* 5. Override {@link ILoader.dispose} and release loader resources, if required.
|
|
25
|
+
* 6. Register loader provider in the loaders registry by calling the {@link loaders.registerLoader}.
|
|
26
|
+
*
|
|
27
|
+
* @example Implementing a custom loader.
|
|
28
|
+
*
|
|
29
|
+
* ```javascript
|
|
30
|
+
* import { Loader } from "@inweb/viewer-core";
|
|
31
|
+
* import { loaders, Viewer } from "@inweb/viewer-three";
|
|
32
|
+
*
|
|
33
|
+
* class MyLoader extends Loader {
|
|
34
|
+
* public viewer: Viewer;
|
|
35
|
+
*
|
|
36
|
+
* constructor(viewer: Viewer) {
|
|
37
|
+
* super();
|
|
38
|
+
* this.viewer = viewer;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* override isSupport(file, format): Boolean {
|
|
42
|
+
* // place custom logic here
|
|
43
|
+
* return ...;
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* override load(file, format, params): Promise<this> {
|
|
47
|
+
*
|
|
48
|
+
* // place custom loading logic here
|
|
49
|
+
* const model = ...;
|
|
50
|
+
*
|
|
51
|
+
* this.viewer.scene.add(model);
|
|
52
|
+
* this.viewer.models.push(model);
|
|
53
|
+
*
|
|
54
|
+
* this.viewer.syncOptions();
|
|
55
|
+
* this.viewer.syncOverlay();
|
|
56
|
+
* this.viewer.update();
|
|
57
|
+
*
|
|
58
|
+
* this.viewer.emitEvent({ type: "databasechunk", data: model, file });
|
|
59
|
+
*
|
|
60
|
+
* return Promise.resove(this);
|
|
61
|
+
* };
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* loaders.registerLoader("MyLoader", (viewer) => new MyLoader(viewer));
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const loaders: ILoadersRegistry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from "./Viewer/draggers";
|
|
2
|
+
export * from "./Viewer/commands";
|
|
3
|
+
export * from "./Viewer/components";
|
|
4
|
+
export * from "./Viewer/loaders";
|
|
5
|
+
export * from "./Viewer/loaders/GLTFLoadingManager";
|
|
6
|
+
export * from "./Viewer/Viewer";
|
|
1
7
|
export * from "@inweb/viewer-core";
|
|
2
8
|
export * from "@inweb/markup";
|
|
3
|
-
export { draggers } from "./Viewer/draggers";
|
|
4
|
-
export { commands } from "./Viewer/commands";
|
|
5
|
-
export { components } from "./Viewer/components";
|
|
6
|
-
export { Viewer } from "./Viewer/Viewer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.5.
|
|
3
|
+
"version": "26.5.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",
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
"three",
|
|
14
14
|
"three.js"
|
|
15
15
|
],
|
|
16
|
-
"sideEffects":
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"dist/plugins/**/*"
|
|
18
|
+
],
|
|
17
19
|
"main": "dist/viewer-three.js",
|
|
18
20
|
"module": "dist/viewer-three.module.js",
|
|
19
21
|
"types": "lib/index.d.ts",
|
|
20
22
|
"files": [
|
|
21
23
|
"dist",
|
|
22
24
|
"lib/**/*.d.ts",
|
|
23
|
-
"src"
|
|
25
|
+
"src",
|
|
26
|
+
"plugins"
|
|
24
27
|
],
|
|
25
28
|
"scripts": {
|
|
26
29
|
"build": "rollup -c rollup.config.js",
|
|
@@ -28,10 +31,10 @@
|
|
|
28
31
|
"docs": "typedoc"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@inweb/client": "~26.5.
|
|
32
|
-
"@inweb/eventemitter2": "~26.5.
|
|
33
|
-
"@inweb/markup": "~26.5.
|
|
34
|
-
"@inweb/viewer-core": "~26.5.
|
|
34
|
+
"@inweb/client": "~26.5.1",
|
|
35
|
+
"@inweb/eventemitter2": "~26.5.1",
|
|
36
|
+
"@inweb/markup": "~26.5.1",
|
|
37
|
+
"@inweb/viewer-core": "~26.5.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"@types/three": "^0.173.0",
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { AxesHelper, Vector3 } from "three";
|
|
25
|
+
import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
import type { Viewer } from "../Viewer";
|
|
28
|
-
|
|
29
|
-
export class AxesHelperComponent implements IComponent {
|
|
27
|
+
class AxesHelperComponent implements IComponent {
|
|
30
28
|
private viewer: Viewer;
|
|
31
29
|
private axesHelper1: AxesHelper;
|
|
32
30
|
private axesHelper2: AxesHelper;
|
|
@@ -71,3 +69,5 @@ export class AxesHelperComponent implements IComponent {
|
|
|
71
69
|
this.viewer.helpers.add(this.axesHelper2);
|
|
72
70
|
};
|
|
73
71
|
}
|
|
72
|
+
|
|
73
|
+
components.registerComponent("AxesHelperComponent", (viewer) => new AxesHelperComponent(viewer));
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Box3, Box3Helper } from "three";
|
|
25
|
+
import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
import type { Viewer } from "../Viewer";
|
|
28
|
-
|
|
29
|
-
export class ExtentsHelperComponent implements IComponent {
|
|
27
|
+
class ExtentsHelperComponent implements IComponent {
|
|
30
28
|
private viewer: Viewer;
|
|
31
29
|
private boxHelper: Box3Helper;
|
|
32
30
|
|
|
@@ -56,3 +54,5 @@ export class ExtentsHelperComponent implements IComponent {
|
|
|
56
54
|
this.viewer.helpers.add(this.boxHelper);
|
|
57
55
|
};
|
|
58
56
|
}
|
|
57
|
+
|
|
58
|
+
components.registerComponent("ExtentsHelperComponent", (viewer) => new ExtentsHelperComponent(viewer));
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { DirectionalLightHelper, Sphere } from "three";
|
|
25
|
+
import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
import type { Viewer } from "../Viewer";
|
|
28
|
-
|
|
29
|
-
export class LightHelperComponent implements IComponent {
|
|
27
|
+
class LightHelperComponent implements IComponent {
|
|
30
28
|
private viewer: Viewer;
|
|
31
29
|
private lightHelpers: DirectionalLightHelper[];
|
|
32
30
|
|
|
@@ -67,3 +65,5 @@ export class LightHelperComponent implements IComponent {
|
|
|
67
65
|
});
|
|
68
66
|
};
|
|
69
67
|
}
|
|
68
|
+
|
|
69
|
+
components.registerComponent("LightHelperComponent", (viewer) => new LightHelperComponent(viewer));
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { FileLoader, Loader, Scene } from "three";
|
|
25
|
+
import { parse, clear } from "./render.js";
|
|
26
|
+
|
|
27
|
+
class IFCXLoader extends Loader<Scene> {
|
|
28
|
+
override load(
|
|
29
|
+
url: string,
|
|
30
|
+
onLoad: (data: Scene) => void,
|
|
31
|
+
onProgress?: (event: ProgressEvent) => void,
|
|
32
|
+
onError?: (err: unknown) => void
|
|
33
|
+
) {
|
|
34
|
+
const manager = this.manager;
|
|
35
|
+
|
|
36
|
+
manager.itemStart(url);
|
|
37
|
+
|
|
38
|
+
const _onLoad = (scene: Scene) => {
|
|
39
|
+
onLoad(scene);
|
|
40
|
+
manager.itemEnd(url);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const _onError = (e: unknown) => {
|
|
44
|
+
if (onError) onError(e);
|
|
45
|
+
else console.error(e);
|
|
46
|
+
manager.itemError(url);
|
|
47
|
+
manager.itemEnd(url);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const loader = new FileLoader(this.manager);
|
|
51
|
+
|
|
52
|
+
loader.setPath(this.path);
|
|
53
|
+
loader.setResponseType("json");
|
|
54
|
+
loader.setRequestHeader(this.requestHeader);
|
|
55
|
+
loader.setWithCredentials(this.withCredentials);
|
|
56
|
+
|
|
57
|
+
loader.load(url, (json) => this.parse(json, _onLoad, _onError), onProgress, onError);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
parse(json: any, onLoad: (scene: Scene) => void, onError: (err: unknown) => void) {
|
|
61
|
+
try {
|
|
62
|
+
onLoad(parse(json));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
onError(e);
|
|
65
|
+
} finally {
|
|
66
|
+
clear();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { IFCXLoader };
|