@inweb/viewer-three 26.8.1 → 26.8.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/plugins/components/RoomEnvironmentComponent.js +75 -40
- package/dist/plugins/components/RoomEnvironmentComponent.js.map +1 -1
- package/dist/plugins/components/RoomEnvironmentComponent.min.js +1 -1
- package/dist/plugins/components/StatsPanelComponent.js +1 -1
- package/dist/plugins/components/StatsPanelComponent.js.map +1 -1
- package/dist/plugins/components/StatsPanelComponent.min.js +1 -1
- package/dist/plugins/components/StatsPanelComponent.module.js +1 -1
- package/dist/plugins/components/StatsPanelComponent.module.js.map +1 -1
- package/dist/plugins/loaders/GLTFCloudLoader.js +225 -94
- package/dist/plugins/loaders/GLTFCloudLoader.js.map +1 -1
- package/dist/plugins/loaders/GLTFCloudLoader.min.js +1 -1
- package/dist/plugins/loaders/IFCXLoader.js +169 -19
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.min.js +1 -1
- package/dist/viewer-three.js +31141 -5500
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +402 -295
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +17 -3
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +6 -6
- package/lib/Viewer/components/HighlighterComponent.d.ts +5 -4
- package/lib/Viewer/components/SelectionComponent.d.ts +1 -1
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +3 -1
- package/lib/Viewer/models/IModelImpl.d.ts +27 -0
- package/lib/Viewer/models/ModelImpl.d.ts +27 -0
- package/lib/Viewer/scenes/Helpers.d.ts +7 -0
- package/lib/index.d.ts +2 -1
- package/package.json +9 -9
- package/plugins/components/StatsPanelComponent.ts +1 -1
- package/src/Viewer/Viewer.ts +124 -48
- package/src/Viewer/commands/SetDefaultViewPosition.ts +8 -8
- package/src/Viewer/components/CameraComponent.ts +20 -16
- package/src/Viewer/components/ExtentsComponent.ts +1 -0
- package/src/Viewer/components/HighlighterComponent.ts +78 -80
- package/src/Viewer/components/LightComponent.ts +1 -1
- package/src/Viewer/components/ResizeCanvasComponent.ts +1 -0
- package/src/Viewer/components/SelectionComponent.ts +1 -1
- package/src/Viewer/helpers/WCSHelper.ts +8 -5
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +33 -16
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +12 -5
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +100 -20
- package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +4 -2
- package/src/Viewer/loaders/GLTFFileLoader.ts +1 -1
- package/src/Viewer/models/IModelImpl.ts +67 -0
- package/src/Viewer/models/ModelImpl.ts +214 -0
- package/src/Viewer/postprocessing/SSAARenderPass.js +245 -0
- package/src/Viewer/scenes/Helpers.ts +42 -0
- package/src/index.ts +2 -1
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Box3, Object3D, OrthographicCamera, PerspectiveCamera, Scene, Vector3, WebGLRenderer } from "three";
|
|
2
|
+
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
3
|
+
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
|
|
4
|
+
import { FXAAPass } from "three/examples/jsm/postprocessing/FXAAPass.js";
|
|
5
|
+
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass.js";
|
|
6
|
+
import { SSAARenderPass } from "./postprocessing/SSAARenderPass.js";
|
|
7
|
+
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
|
|
2
8
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
3
9
|
import { Assembly, Client, Model, File } from "@inweb/client";
|
|
4
10
|
import { CanvasEventMap, FileSource, IComponent, IDragger, ILoader, IOptions, IViewer, IViewpoint, Options, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
5
11
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
6
|
-
import { IModelImpl } from "./
|
|
12
|
+
import { IModelImpl } from "./models/IModelImpl";
|
|
13
|
+
import { Helpers } from "./scenes/Helpers";
|
|
7
14
|
/**
|
|
8
15
|
* 3D viewer powered by {@link https://threejs.org/ | Three.js}.
|
|
9
16
|
*/
|
|
@@ -14,9 +21,16 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
14
21
|
canvas: HTMLCanvasElement | undefined;
|
|
15
22
|
canvasEvents: string[];
|
|
16
23
|
scene: Scene | undefined;
|
|
17
|
-
helpers:
|
|
24
|
+
helpers: Helpers | undefined;
|
|
18
25
|
camera: PerspectiveCamera | OrthographicCamera | undefined;
|
|
19
26
|
renderer: WebGLRenderer | undefined;
|
|
27
|
+
renderPass: RenderPass | undefined;
|
|
28
|
+
helpersPass: RenderPass | undefined;
|
|
29
|
+
fxaaPass: FXAAPass | undefined;
|
|
30
|
+
smaaPass: SMAAPass | undefined;
|
|
31
|
+
ssaaRenderPass: SSAARenderPass | undefined;
|
|
32
|
+
outputPass: OutputPass | undefined;
|
|
33
|
+
composer: EffectComposer | undefined;
|
|
20
34
|
loaders: ILoader[];
|
|
21
35
|
models: IModelImpl[];
|
|
22
36
|
selected: Object3D[];
|
|
@@ -46,7 +60,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
46
60
|
dispose(): this;
|
|
47
61
|
isInitialized(): boolean;
|
|
48
62
|
update(force?: boolean): void;
|
|
49
|
-
render(time
|
|
63
|
+
render(time?: DOMHighResTimeStamp, force?: boolean): void;
|
|
50
64
|
loadReferences(model: Model | File | Assembly): Promise<this>;
|
|
51
65
|
/**
|
|
52
66
|
* Loads a file into the viewer.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
3
|
export declare const defaultViewPositions: {
|
|
4
|
-
top: Vector3;
|
|
5
|
-
bottom: Vector3;
|
|
6
|
-
left: Vector3;
|
|
7
|
-
right: Vector3;
|
|
8
4
|
front: Vector3;
|
|
9
5
|
back: Vector3;
|
|
6
|
+
left: Vector3;
|
|
7
|
+
right: Vector3;
|
|
8
|
+
bottom: Vector3;
|
|
9
|
+
top: Vector3;
|
|
10
|
+
ns: Vector3;
|
|
10
11
|
sw: Vector3;
|
|
11
|
-
se: Vector3;
|
|
12
|
-
ne: Vector3;
|
|
13
12
|
nw: Vector3;
|
|
13
|
+
se: Vector3;
|
|
14
14
|
};
|
|
15
15
|
export declare function setDefaultViewPosition(viewer: Viewer, position: string): void;
|
|
@@ -5,15 +5,16 @@ import { Viewer } from "../Viewer";
|
|
|
5
5
|
export declare class HighlighterComponent implements IComponent {
|
|
6
6
|
protected viewer: Viewer;
|
|
7
7
|
renderTarget: WebGLRenderTarget;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
facesMaterial: MeshPhongMaterial;
|
|
9
|
+
edgesMaterial: LineMaterial;
|
|
10
|
+
lineMaterial: LineBasicMaterial;
|
|
11
|
+
lineGlowMaterial: LineMaterial;
|
|
12
12
|
constructor(viewer: Viewer);
|
|
13
13
|
dispose(): void;
|
|
14
14
|
highlight(objects: Object3D | Object3D[]): void;
|
|
15
15
|
unhighlight(objects: Object3D | Object3D[]): void;
|
|
16
16
|
geometryEnd: () => void;
|
|
17
17
|
optionsChange: () => void;
|
|
18
|
+
syncHighlightColors(): void;
|
|
18
19
|
viewerResize(event: ResizeEvent): void;
|
|
19
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Intersection, Object3D, Raycaster, Vector2 } from "three";
|
|
2
2
|
import type { IComponent } from "@inweb/viewer-core";
|
|
3
3
|
import type { Viewer } from "../Viewer";
|
|
4
|
-
import type { IModelImpl } from "../
|
|
4
|
+
import type { IModelImpl } from "../models/IModelImpl";
|
|
5
5
|
import type { HighlighterComponent } from "./HighlighterComponent";
|
|
6
6
|
export declare class SelectionComponent implements IComponent {
|
|
7
7
|
protected viewer: Viewer;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Box3, Object3D } from "three";
|
|
2
|
-
import { ModelImpl } from "../../
|
|
2
|
+
import { ModelImpl } from "../../models/ModelImpl";
|
|
3
3
|
import { DynamicGltfLoader } from "./DynamicGltfLoader.js";
|
|
4
4
|
export declare class DynamicModelImpl extends ModelImpl {
|
|
5
5
|
gltfLoader: DynamicGltfLoader;
|
|
6
|
+
modelId: number;
|
|
6
7
|
getExtents(target: Box3): Box3;
|
|
7
8
|
getObjects(): Object3D[];
|
|
8
9
|
getVisibleObjects(): Object3D[];
|
|
9
10
|
hasObject(object: any): boolean;
|
|
10
11
|
getObjectsByHandles(handles: string | string[]): Object3D[];
|
|
12
|
+
getHandlesByObjects(objects: Object3D | Object3D[]): string[];
|
|
11
13
|
hideObjects(objects: Object3D | Object3D[]): this;
|
|
12
14
|
isolateObjects(objects: Object3D | Object3D[]): this;
|
|
13
15
|
showObjects(objects: Object3D | Object3D[]): this;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Box3, Object3D } from "three";
|
|
2
|
+
import { ILoader, IViewer } from "@inweb/viewer-core";
|
|
3
|
+
/**
|
|
4
|
+
* Model interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface IModelImpl {
|
|
7
|
+
handle: string;
|
|
8
|
+
scene: Object3D;
|
|
9
|
+
loader: ILoader;
|
|
10
|
+
viewer: IViewer;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
getExtents(target: Box3): Box3;
|
|
13
|
+
getObjects(): Object3D[];
|
|
14
|
+
getVisibleObjects(): Object3D[];
|
|
15
|
+
hasObject(objects: Object3D): boolean;
|
|
16
|
+
getOwnObjects(objects: Object3D | Object3D[]): Object3D[];
|
|
17
|
+
getObjectsByHandles(handles: string | string[]): Object3D[];
|
|
18
|
+
getHandlesByObjects(objects: Object3D | Object3D[]): string[];
|
|
19
|
+
hideObjects(objects: Object3D | Object3D[]): this;
|
|
20
|
+
hideAllObjects(): this;
|
|
21
|
+
isolateObjects(objects: Object3D | Object3D[]): this;
|
|
22
|
+
showObjects(objects: Object3D | Object3D[]): this;
|
|
23
|
+
showAllObjects(): this;
|
|
24
|
+
showOriginalObjects(objects: Object3D | Object3D[]): this;
|
|
25
|
+
hideOriginalObjects(objects: Object3D | Object3D[]): this;
|
|
26
|
+
explode(scale: number, coeff?: number): this;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Box3, Object3D } from "three";
|
|
2
|
+
import { ILoader } from "@inweb/viewer-core";
|
|
3
|
+
import { IModelImpl } from "./IModelImpl";
|
|
4
|
+
import { Viewer } from "../Viewer";
|
|
5
|
+
export declare class ModelImpl implements IModelImpl {
|
|
6
|
+
handle: string;
|
|
7
|
+
scene: Object3D;
|
|
8
|
+
loader: ILoader;
|
|
9
|
+
viewer: Viewer;
|
|
10
|
+
constructor(scene: Object3D);
|
|
11
|
+
dispose(): void;
|
|
12
|
+
getExtents(target: Box3): Box3;
|
|
13
|
+
getObjects(): Object3D[];
|
|
14
|
+
getVisibleObjects(): Object3D[];
|
|
15
|
+
hasObject(object: Object3D): boolean;
|
|
16
|
+
getOwnObjects(objects: Object3D | Object3D[]): Object3D[];
|
|
17
|
+
getObjectsByHandles(handles: string | string[]): Object3D[];
|
|
18
|
+
getHandlesByObjects(objects: Object3D | Object3D[]): string[];
|
|
19
|
+
hideObjects(objects: Object3D | Object3D[]): this;
|
|
20
|
+
hideAllObjects(): this;
|
|
21
|
+
isolateObjects(objects: Object3D | Object3D[]): this;
|
|
22
|
+
showObjects(objects: Object3D | Object3D[]): this;
|
|
23
|
+
showAllObjects(): this;
|
|
24
|
+
showOriginalObjects(objects: Object3D | Object3D[]): this;
|
|
25
|
+
hideOriginalObjects(objects: Object3D | Object3D[]): this;
|
|
26
|
+
explode(scale?: number, coeff?: number): this;
|
|
27
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export * from "./Viewer/commands";
|
|
|
3
3
|
export * from "./Viewer/components";
|
|
4
4
|
export * from "./Viewer/loaders";
|
|
5
5
|
export * from "./Viewer/loaders/GLTFLoadingManager";
|
|
6
|
-
export * from "./Viewer/
|
|
6
|
+
export * from "./Viewer/models/IModelImpl";
|
|
7
|
+
export * from "./Viewer/models/ModelImpl";
|
|
7
8
|
export * from "./Viewer/Viewer";
|
|
8
9
|
export * from "@inweb/viewer-core";
|
|
9
10
|
export * from "@inweb/markup";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.8.
|
|
3
|
+
"version": "26.8.2",
|
|
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,17 +35,17 @@
|
|
|
35
35
|
"docs": "typedoc"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@inweb/client": "~26.8.
|
|
39
|
-
"@inweb/eventemitter2": "~26.8.
|
|
40
|
-
"@inweb/markup": "~26.8.
|
|
41
|
-
"@inweb/viewer-core": "~26.8.
|
|
38
|
+
"@inweb/client": "~26.8.2",
|
|
39
|
+
"@inweb/eventemitter2": "~26.8.2",
|
|
40
|
+
"@inweb/markup": "~26.8.2",
|
|
41
|
+
"@inweb/viewer-core": "~26.8.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/three": "^0.
|
|
45
|
-
"three": "^0.
|
|
44
|
+
"@types/three": "^0.179.0",
|
|
45
|
+
"three": "^0.179.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@types/three": "^0.
|
|
49
|
-
"three": "^0.
|
|
48
|
+
"@types/three": "^0.179.0",
|
|
49
|
+
"three": "^0.179.1"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
25
|
Box3,
|
|
26
|
-
|
|
26
|
+
LinearSRGBColorSpace,
|
|
27
|
+
// LinearToneMapping,
|
|
27
28
|
Object3D,
|
|
28
29
|
OrthographicCamera,
|
|
29
30
|
PerspectiveCamera,
|
|
@@ -34,6 +35,12 @@ import {
|
|
|
34
35
|
Vector3,
|
|
35
36
|
WebGLRenderer,
|
|
36
37
|
} from "three";
|
|
38
|
+
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
39
|
+
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
|
|
40
|
+
import { FXAAPass } from "three/examples/jsm/postprocessing/FXAAPass.js";
|
|
41
|
+
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass.js";
|
|
42
|
+
import { SSAARenderPass } from "./postprocessing/SSAARenderPass.js";
|
|
43
|
+
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
|
|
37
44
|
|
|
38
45
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
39
46
|
import { Assembly, Client, Model, File } from "@inweb/client";
|
|
@@ -62,7 +69,8 @@ import { draggers } from "./draggers";
|
|
|
62
69
|
import { commands } from "./commands";
|
|
63
70
|
import { components } from "./components";
|
|
64
71
|
import { loaders } from "./loaders";
|
|
65
|
-
import { IModelImpl } from "./
|
|
72
|
+
import { IModelImpl } from "./models/IModelImpl";
|
|
73
|
+
import { Helpers } from "./scenes/Helpers";
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* 3D viewer powered by {@link https://threejs.org/ | Three.js}.
|
|
@@ -80,9 +88,17 @@ export class Viewer
|
|
|
80
88
|
public canvasEvents: string[];
|
|
81
89
|
|
|
82
90
|
public scene: Scene | undefined;
|
|
83
|
-
public helpers:
|
|
91
|
+
public helpers: Helpers | undefined;
|
|
84
92
|
public camera: PerspectiveCamera | OrthographicCamera | undefined;
|
|
85
93
|
public renderer: WebGLRenderer | undefined;
|
|
94
|
+
public renderPass: RenderPass | undefined;
|
|
95
|
+
public helpersPass: RenderPass | undefined;
|
|
96
|
+
public fxaaPass: FXAAPass | undefined;
|
|
97
|
+
public smaaPass: SMAAPass | undefined;
|
|
98
|
+
public ssaaRenderPass: SSAARenderPass | undefined;
|
|
99
|
+
public outputPass: OutputPass | undefined;
|
|
100
|
+
public composer: EffectComposer | undefined;
|
|
101
|
+
|
|
86
102
|
public loaders: ILoader[];
|
|
87
103
|
public models: IModelImpl[];
|
|
88
104
|
public selected: Object3D[];
|
|
@@ -153,7 +169,7 @@ export class Viewer
|
|
|
153
169
|
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
154
170
|
|
|
155
171
|
this.scene = new Scene();
|
|
156
|
-
this.helpers = new
|
|
172
|
+
this.helpers = new Helpers();
|
|
157
173
|
this.target = new Vector3();
|
|
158
174
|
|
|
159
175
|
const pixelRatio = window.devicePixelRatio;
|
|
@@ -174,11 +190,33 @@ export class Viewer
|
|
|
174
190
|
alpha: true,
|
|
175
191
|
preserveDrawingBuffer: true,
|
|
176
192
|
powerPreference: "high-performance",
|
|
177
|
-
logarithmicDepthBuffer:
|
|
193
|
+
logarithmicDepthBuffer: true,
|
|
178
194
|
});
|
|
179
195
|
this.renderer.setPixelRatio(pixelRatio);
|
|
180
196
|
this.renderer.setSize(width, height);
|
|
181
|
-
this.renderer.toneMapping = LinearToneMapping;
|
|
197
|
+
// this.renderer.toneMapping = LinearToneMapping;
|
|
198
|
+
this.renderer.outputColorSpace = LinearSRGBColorSpace;
|
|
199
|
+
|
|
200
|
+
this.renderPass = new RenderPass(this.scene, this.camera);
|
|
201
|
+
|
|
202
|
+
this.helpersPass = new RenderPass(this.helpers, this.camera);
|
|
203
|
+
this.helpersPass.clear = false;
|
|
204
|
+
|
|
205
|
+
this.fxaaPass = new FXAAPass();
|
|
206
|
+
this.smaaPass = new SMAAPass();
|
|
207
|
+
|
|
208
|
+
this.ssaaRenderPass = new SSAARenderPass([this.scene, this.helpers], this.camera);
|
|
209
|
+
this.ssaaRenderPass.unbiased = true;
|
|
210
|
+
|
|
211
|
+
this.outputPass = new OutputPass();
|
|
212
|
+
|
|
213
|
+
this.composer = new EffectComposer(this.renderer);
|
|
214
|
+
this.composer.addPass(this.renderPass);
|
|
215
|
+
this.composer.addPass(this.helpersPass);
|
|
216
|
+
this.composer.addPass(this.smaaPass);
|
|
217
|
+
this.composer.addPass(this.fxaaPass);
|
|
218
|
+
this.composer.addPass(this.ssaaRenderPass);
|
|
219
|
+
this.composer.addPass(this.outputPass);
|
|
182
220
|
|
|
183
221
|
this.canvas = canvas;
|
|
184
222
|
this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
|
|
@@ -223,12 +261,26 @@ export class Viewer
|
|
|
223
261
|
this.canvas = undefined;
|
|
224
262
|
}
|
|
225
263
|
|
|
264
|
+
if (this.composer) this.composer.dispose();
|
|
265
|
+
if (this.renderPass) this.renderPass.dispose();
|
|
266
|
+
if (this.helpersPass) this.helpersPass.dispose();
|
|
267
|
+
if (this.fxaaPass) this.fxaaPass.dispose();
|
|
268
|
+
if (this.smaaPass) this.smaaPass.dispose();
|
|
269
|
+
if (this.ssaaRenderPass) this.ssaaRenderPass.dispose();
|
|
270
|
+
if (this.outputPass) this.outputPass.dispose();
|
|
226
271
|
if (this.renderer) this.renderer.dispose();
|
|
227
272
|
|
|
228
|
-
this.helpers = undefined;
|
|
229
273
|
this.scene = undefined;
|
|
230
|
-
this.
|
|
274
|
+
this.helpers = undefined;
|
|
231
275
|
this.camera = undefined;
|
|
276
|
+
this.renderer = undefined;
|
|
277
|
+
this.renderPass = undefined;
|
|
278
|
+
this.helpersPass = undefined;
|
|
279
|
+
this.fxaaPass = undefined;
|
|
280
|
+
this.smaaPass = undefined;
|
|
281
|
+
this.ssaaRenderPass = undefined;
|
|
282
|
+
this.outputPass = undefined;
|
|
283
|
+
this.composer = undefined;
|
|
232
284
|
|
|
233
285
|
return this;
|
|
234
286
|
}
|
|
@@ -239,30 +291,29 @@ export class Viewer
|
|
|
239
291
|
|
|
240
292
|
update(force = false): void {
|
|
241
293
|
this.renderNeeded = true;
|
|
242
|
-
if (force) this.render(
|
|
294
|
+
if (force) this.render();
|
|
243
295
|
this.emitEvent({ type: "update", data: force });
|
|
244
296
|
}
|
|
245
297
|
|
|
246
|
-
render(time
|
|
247
|
-
if (!this.renderNeeded) return;
|
|
298
|
+
render(time?: DOMHighResTimeStamp, force = false): void {
|
|
248
299
|
if (!this.renderer) return;
|
|
300
|
+
if (!(this.renderNeeded || force)) return;
|
|
249
301
|
|
|
250
|
-
|
|
302
|
+
if (!time) time = performance.now();
|
|
303
|
+
const deltaTime = (time - this.renderTime) / 1000;
|
|
251
304
|
|
|
252
|
-
this.
|
|
253
|
-
this.
|
|
254
|
-
this.renderer.render(this.scene, this.camera);
|
|
305
|
+
this.renderTime = time;
|
|
306
|
+
this.renderNeeded = false;
|
|
255
307
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
308
|
+
if (this.options.antialiasing === true || this.options.antialiasing === "msaa") {
|
|
309
|
+
this.renderer.render(this.scene, this.camera);
|
|
310
|
+
this.renderer.render(this.helpers, this.camera);
|
|
311
|
+
} else {
|
|
312
|
+
this.composer.render(deltaTime);
|
|
313
|
+
}
|
|
261
314
|
|
|
262
315
|
this._activeDragger?.updatePreview?.();
|
|
263
316
|
|
|
264
|
-
const deltaTime = (time - this.renderTime) / 1000;
|
|
265
|
-
this.renderTime = time;
|
|
266
317
|
this.emitEvent({ type: "render", time, deltaTime });
|
|
267
318
|
}
|
|
268
319
|
|
|
@@ -432,6 +483,12 @@ export class Viewer
|
|
|
432
483
|
this.models.forEach((model) => model.dispose());
|
|
433
484
|
this.models = [];
|
|
434
485
|
|
|
486
|
+
this.scene.clear();
|
|
487
|
+
this.helpers.clear();
|
|
488
|
+
|
|
489
|
+
this.models.forEach((model) => model.dispose());
|
|
490
|
+
this.models = [];
|
|
491
|
+
|
|
435
492
|
this.helpers.clear();
|
|
436
493
|
this.scene.clear();
|
|
437
494
|
|
|
@@ -445,7 +502,16 @@ export class Viewer
|
|
|
445
502
|
}
|
|
446
503
|
|
|
447
504
|
syncOptions(options: IOptions = this.options): void {
|
|
448
|
-
|
|
505
|
+
if (!this.renderer) return;
|
|
506
|
+
|
|
507
|
+
this.fxaaPass.enabled = options.antialiasing === "fxaa";
|
|
508
|
+
this.smaaPass.enabled = options.antialiasing === "smaa";
|
|
509
|
+
this.ssaaRenderPass.enabled = options.antialiasing === "ssaa";
|
|
510
|
+
|
|
511
|
+
this.renderPass.enabled = !this.ssaaRenderPass.enabled;
|
|
512
|
+
this.helpersPass.enabled = !this.ssaaRenderPass.enabled;
|
|
513
|
+
|
|
514
|
+
this.update();
|
|
449
515
|
}
|
|
450
516
|
|
|
451
517
|
syncOverlay(): void {
|
|
@@ -595,20 +661,25 @@ export class Viewer
|
|
|
595
661
|
const rendererSize = this.renderer.getSize(new Vector2());
|
|
596
662
|
const aspect = rendererSize.x / rendererSize.y;
|
|
597
663
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
664
|
+
const camera = new OrthographicCamera();
|
|
665
|
+
camera.top = orthogonal_camera.field_height / 2;
|
|
666
|
+
camera.bottom = -orthogonal_camera.field_height / 2;
|
|
667
|
+
camera.left = camera.bottom * aspect;
|
|
668
|
+
camera.right = camera.top * aspect;
|
|
669
|
+
camera.near = 0;
|
|
670
|
+
camera.far = extentsSize * 100;
|
|
671
|
+
camera.zoom = orthogonal_camera.view_to_world_scale;
|
|
672
|
+
camera.updateProjectionMatrix();
|
|
673
|
+
|
|
674
|
+
camera.up.copy(getVector3FromPoint3d(orthogonal_camera.up_vector));
|
|
675
|
+
camera.position.copy(getVector3FromPoint3d(orthogonal_camera.view_point));
|
|
676
|
+
camera.lookAt(getVector3FromPoint3d(orthogonal_camera.direction).add(camera.position));
|
|
677
|
+
camera.updateMatrixWorld();
|
|
678
|
+
|
|
679
|
+
this.camera = camera;
|
|
680
|
+
this.renderPass.camera = camera;
|
|
681
|
+
this.helpersPass.camera = camera;
|
|
682
|
+
this.ssaaRenderPass.camera = camera;
|
|
612
683
|
}
|
|
613
684
|
};
|
|
614
685
|
|
|
@@ -618,17 +689,22 @@ export class Viewer
|
|
|
618
689
|
const rendererSize = this.renderer.getSize(new Vector2());
|
|
619
690
|
const aspect = rendererSize.x / rendererSize.y;
|
|
620
691
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
692
|
+
const camera = new PerspectiveCamera();
|
|
693
|
+
camera.fov = perspective_camera.field_of_view;
|
|
694
|
+
camera.aspect = aspect;
|
|
695
|
+
camera.near = extentsSize / 100;
|
|
696
|
+
camera.far = extentsSize * 100;
|
|
697
|
+
camera.updateProjectionMatrix();
|
|
698
|
+
|
|
699
|
+
camera.up.copy(getVector3FromPoint3d(perspective_camera.up_vector));
|
|
700
|
+
camera.position.copy(getVector3FromPoint3d(perspective_camera.view_point));
|
|
701
|
+
camera.lookAt(getVector3FromPoint3d(perspective_camera.direction).add(camera.position));
|
|
702
|
+
camera.updateMatrixWorld();
|
|
703
|
+
|
|
704
|
+
this.camera = camera;
|
|
705
|
+
this.renderPass.camera = camera;
|
|
706
|
+
this.helpersPass.camera = camera;
|
|
707
|
+
this.ssaaRenderPass.camera = camera;
|
|
632
708
|
}
|
|
633
709
|
};
|
|
634
710
|
|
|
@@ -26,16 +26,16 @@ import type { Viewer } from "../Viewer";
|
|
|
26
26
|
import { zoomTo } from "./ZoomTo";
|
|
27
27
|
|
|
28
28
|
export const defaultViewPositions = {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
front: new Vector3(0, 0, 1),
|
|
30
|
+
back: new Vector3(0, 0, -1),
|
|
31
31
|
left: new Vector3(-1, 0, 0),
|
|
32
32
|
right: new Vector3(1, 0, 0),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
bottom: new Vector3(0, -1, 0),
|
|
34
|
+
top: new Vector3(0, 1, 0),
|
|
35
|
+
ns: new Vector3(-0.5, 1.0, -0.5).normalize(),
|
|
36
|
+
sw: new Vector3(0.5, 1.0, -0.5).normalize(),
|
|
37
|
+
nw: new Vector3(0.5, 1.0, 0.5).normalize(),
|
|
38
|
+
se: new Vector3(-0.5, 1.0, 0.5).normalize(),
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export function setDefaultViewPosition(viewer: Viewer, position: string): void {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Sphere, Vector2
|
|
24
|
+
import { Sphere, Vector2 } from "three";
|
|
25
25
|
|
|
26
26
|
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
@@ -39,42 +39,46 @@ export class CameraComponent implements IComponent {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
geometryEnd = () => {
|
|
42
|
-
const extentsCenter = this.viewer.extents.getCenter(new Vector3());
|
|
43
42
|
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
|
|
44
43
|
const rendererSize = this.viewer.renderer.getSize(new Vector2());
|
|
45
44
|
const aspect = rendererSize.x / rendererSize.y;
|
|
46
45
|
|
|
46
|
+
let camera: any;
|
|
47
|
+
|
|
47
48
|
// TODO: do not change the camera and target after opening the second model in "append" mode
|
|
48
|
-
let sceneCamera: any;
|
|
49
49
|
this.viewer.scene.traverse((object: any) => {
|
|
50
50
|
if (object.isCamera)
|
|
51
|
-
if (!
|
|
52
|
-
else if (object.isPerspectiveCamera &&
|
|
51
|
+
if (!camera) camera = object;
|
|
52
|
+
else if (object.isPerspectiveCamera && camera.isOrthographicCamera) camera = object;
|
|
53
53
|
});
|
|
54
|
-
if (sceneCamera) {
|
|
55
|
-
this.viewer.camera = sceneCamera.clone();
|
|
56
|
-
this.viewer.camera.scale.set(1, 1, 1); // <- Visualize fix
|
|
57
|
-
}
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
if (camera) {
|
|
56
|
+
camera.isDefaultCamera = true;
|
|
57
|
+
camera.scale.set(1, 1, 1); // <- Visualize fix
|
|
58
|
+
|
|
59
|
+
this.viewer.camera = camera;
|
|
60
|
+
this.viewer.renderPass.camera = camera;
|
|
61
|
+
this.viewer.helpersPass.camera = camera;
|
|
62
|
+
this.viewer.ssaaRenderPass.camera = camera;
|
|
63
|
+
} else {
|
|
64
|
+
camera = this.viewer.camera;
|
|
65
|
+
}
|
|
60
66
|
|
|
61
67
|
if (camera.isPerspectiveCamera) {
|
|
62
68
|
camera.aspect = aspect;
|
|
63
|
-
camera.near = extentsSize /
|
|
64
|
-
camera.far = extentsSize *
|
|
69
|
+
camera.near = extentsSize / 1000;
|
|
70
|
+
camera.far = extentsSize * 1000;
|
|
65
71
|
camera.updateProjectionMatrix();
|
|
66
72
|
}
|
|
67
73
|
if (camera.isOrthographicCamera) {
|
|
68
74
|
camera.left = camera.bottom * aspect;
|
|
69
75
|
camera.right = camera.top * aspect;
|
|
70
76
|
camera.near = 0;
|
|
71
|
-
camera.far = extentsSize *
|
|
77
|
+
camera.far = extentsSize * 1000;
|
|
72
78
|
camera.updateProjectionMatrix();
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!sceneCamera) {
|
|
81
|
+
if (!camera.isDefaultCamera) {
|
|
78
82
|
this.viewer.executeCommand("setDefaultViewPosition");
|
|
79
83
|
}
|
|
80
84
|
};
|