@inweb/viewer-three 26.8.1 → 26.9.0
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 +31138 -5501
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +399 -296
- 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/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 +119 -49
- 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/postprocessing/SSAARenderPass.js +245 -0
- package/src/Viewer/{model/index.ts → scenes/Helpers.ts} +19 -2
- package/src/index.ts +2 -1
- package/lib/Viewer/model/index.d.ts +0 -2
- /package/lib/Viewer/{model → models}/IModelImpl.d.ts +0 -0
- /package/lib/Viewer/{model → models}/ModelImpl.d.ts +0 -0
- /package/src/Viewer/{model → models}/IModelImpl.ts +0 -0
- /package/src/Viewer/{model → models}/ModelImpl.ts +0 -0
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;
|
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.
|
|
3
|
+
"version": "26.9.0",
|
|
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.
|
|
39
|
-
"@inweb/eventemitter2": "~26.
|
|
40
|
-
"@inweb/markup": "~26.
|
|
41
|
-
"@inweb/viewer-core": "~26.
|
|
38
|
+
"@inweb/client": "~26.9.0",
|
|
39
|
+
"@inweb/eventemitter2": "~26.9.0",
|
|
40
|
+
"@inweb/markup": "~26.9.0",
|
|
41
|
+
"@inweb/viewer-core": "~26.9.0"
|
|
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,8 +483,8 @@ export class Viewer
|
|
|
432
483
|
this.models.forEach((model) => model.dispose());
|
|
433
484
|
this.models = [];
|
|
434
485
|
|
|
435
|
-
this.helpers.clear();
|
|
436
486
|
this.scene.clear();
|
|
487
|
+
this.helpers.clear();
|
|
437
488
|
|
|
438
489
|
this.syncOptions();
|
|
439
490
|
this.syncOverlay();
|
|
@@ -445,7 +496,16 @@ export class Viewer
|
|
|
445
496
|
}
|
|
446
497
|
|
|
447
498
|
syncOptions(options: IOptions = this.options): void {
|
|
448
|
-
|
|
499
|
+
if (!this.renderer) return;
|
|
500
|
+
|
|
501
|
+
this.fxaaPass.enabled = options.antialiasing === "fxaa";
|
|
502
|
+
this.smaaPass.enabled = options.antialiasing === "smaa";
|
|
503
|
+
this.ssaaRenderPass.enabled = options.antialiasing === "ssaa";
|
|
504
|
+
|
|
505
|
+
this.renderPass.enabled = !this.ssaaRenderPass.enabled;
|
|
506
|
+
this.helpersPass.enabled = !this.ssaaRenderPass.enabled;
|
|
507
|
+
|
|
508
|
+
this.update();
|
|
449
509
|
}
|
|
450
510
|
|
|
451
511
|
syncOverlay(): void {
|
|
@@ -595,20 +655,25 @@ export class Viewer
|
|
|
595
655
|
const rendererSize = this.renderer.getSize(new Vector2());
|
|
596
656
|
const aspect = rendererSize.x / rendererSize.y;
|
|
597
657
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
658
|
+
const camera = new OrthographicCamera();
|
|
659
|
+
camera.top = orthogonal_camera.field_height / 2;
|
|
660
|
+
camera.bottom = -orthogonal_camera.field_height / 2;
|
|
661
|
+
camera.left = camera.bottom * aspect;
|
|
662
|
+
camera.right = camera.top * aspect;
|
|
663
|
+
camera.near = 0;
|
|
664
|
+
camera.far = extentsSize * 100;
|
|
665
|
+
camera.zoom = orthogonal_camera.view_to_world_scale;
|
|
666
|
+
camera.updateProjectionMatrix();
|
|
667
|
+
|
|
668
|
+
camera.up.copy(getVector3FromPoint3d(orthogonal_camera.up_vector));
|
|
669
|
+
camera.position.copy(getVector3FromPoint3d(orthogonal_camera.view_point));
|
|
670
|
+
camera.lookAt(getVector3FromPoint3d(orthogonal_camera.direction).add(camera.position));
|
|
671
|
+
camera.updateMatrixWorld();
|
|
672
|
+
|
|
673
|
+
this.camera = camera;
|
|
674
|
+
this.renderPass.camera = camera;
|
|
675
|
+
this.helpersPass.camera = camera;
|
|
676
|
+
this.ssaaRenderPass.camera = camera;
|
|
612
677
|
}
|
|
613
678
|
};
|
|
614
679
|
|
|
@@ -618,17 +683,22 @@ export class Viewer
|
|
|
618
683
|
const rendererSize = this.renderer.getSize(new Vector2());
|
|
619
684
|
const aspect = rendererSize.x / rendererSize.y;
|
|
620
685
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
686
|
+
const camera = new PerspectiveCamera();
|
|
687
|
+
camera.fov = perspective_camera.field_of_view;
|
|
688
|
+
camera.aspect = aspect;
|
|
689
|
+
camera.near = extentsSize / 100;
|
|
690
|
+
camera.far = extentsSize * 100;
|
|
691
|
+
camera.updateProjectionMatrix();
|
|
692
|
+
|
|
693
|
+
camera.up.copy(getVector3FromPoint3d(perspective_camera.up_vector));
|
|
694
|
+
camera.position.copy(getVector3FromPoint3d(perspective_camera.view_point));
|
|
695
|
+
camera.lookAt(getVector3FromPoint3d(perspective_camera.direction).add(camera.position));
|
|
696
|
+
camera.updateMatrixWorld();
|
|
697
|
+
|
|
698
|
+
this.camera = camera;
|
|
699
|
+
this.renderPass.camera = camera;
|
|
700
|
+
this.helpersPass.camera = camera;
|
|
701
|
+
this.ssaaRenderPass.camera = camera;
|
|
632
702
|
}
|
|
633
703
|
};
|
|
634
704
|
|
|
@@ -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
|
};
|