@inweb/viewer-three 27.1.3 → 27.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewer-three.js +74 -36
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +4 -4
- package/dist/viewer-three.module.js +59 -22
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +1 -0
- package/lib/Viewer/commands/GetSnapshot.d.ts +2 -0
- package/lib/Viewer/components/CanvasRemoveComponent.d.ts +9 -0
- package/lib/Viewer/components/{ResizeCanvasComponent.d.ts → CanvasResizeComponent.d.ts} +1 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +8 -1
- package/src/Viewer/commands/{CreatePreview.ts → GetSnapshot.ts} +10 -2
- package/src/Viewer/commands/index.ts +3 -2
- package/src/Viewer/components/CameraComponent.ts +1 -1
- package/src/Viewer/components/CanvasRemoveComponent.ts +55 -0
- package/src/Viewer/components/{ResizeCanvasComponent.ts → CanvasResizeComponent.ts} +1 -1
- package/src/Viewer/components/index.ts +4 -2
- package/lib/Viewer/commands/CreatePreview.d.ts +0 -2
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
178
178
|
getComponent(name: string): IComponent;
|
|
179
179
|
drawViewpoint(viewpoint: IViewpoint): void;
|
|
180
180
|
createViewpoint(): IViewpoint;
|
|
181
|
+
getSnapshot(type?: string, quality?: number): string;
|
|
181
182
|
screenToWorld(position: {
|
|
182
183
|
x: number;
|
|
183
184
|
y: number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
|
+
import type { Viewer } from "../Viewer";
|
|
3
|
+
export declare class CanvasRemoveComponent implements IComponent {
|
|
4
|
+
protected viewer: Viewer;
|
|
5
|
+
protected mutationObserver: MutationObserver;
|
|
6
|
+
constructor(viewer: Viewer);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
cleanupViewer: (mutations: MutationRecord[]) => void;
|
|
9
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IComponent } from "@inweb/viewer-core";
|
|
2
2
|
import type { Viewer } from "../Viewer";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class CanvasResizeComponent implements IComponent {
|
|
4
4
|
protected viewer: Viewer;
|
|
5
5
|
protected resizeObserver: ResizeObserver;
|
|
6
6
|
constructor(viewer: Viewer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.5",
|
|
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": "~27.1.
|
|
39
|
-
"@inweb/eventemitter2": "~27.1.
|
|
40
|
-
"@inweb/markup": "~27.1.
|
|
41
|
-
"@inweb/viewer-core": "~27.1.
|
|
38
|
+
"@inweb/client": "~27.1.5",
|
|
39
|
+
"@inweb/eventemitter2": "~27.1.5",
|
|
40
|
+
"@inweb/markup": "~27.1.5",
|
|
41
|
+
"@inweb/viewer-core": "~27.1.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@streamparser/json": "^0.0.22",
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -681,7 +681,7 @@ export class Viewer
|
|
|
681
681
|
camera.bottom = -orthogonal_camera.field_height / 2;
|
|
682
682
|
camera.left = camera.bottom * aspectRatio;
|
|
683
683
|
camera.right = camera.top * aspectRatio;
|
|
684
|
-
camera.near =
|
|
684
|
+
camera.near = -extentsSize * 1000;
|
|
685
685
|
camera.far = extentsSize * 1000;
|
|
686
686
|
camera.zoom = orthogonal_camera.view_to_world_scale;
|
|
687
687
|
camera.updateProjectionMatrix();
|
|
@@ -761,6 +761,7 @@ export class Viewer
|
|
|
761
761
|
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
762
762
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
763
763
|
setSelection(viewpoint.custom_fields?.selection2 || viewpoint.selection);
|
|
764
|
+
|
|
764
765
|
this._markup.setViewpoint(viewpoint);
|
|
765
766
|
|
|
766
767
|
this.target.copy(getVector3FromPoint3d(viewpoint.custom_fields?.camera_target ?? this.target));
|
|
@@ -828,6 +829,8 @@ export class Viewer
|
|
|
828
829
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
829
830
|
viewpoint.selection = getSelection();
|
|
830
831
|
viewpoint.description = new Date().toDateString();
|
|
832
|
+
viewpoint.snapshot = { data: this.getSnapshot() };
|
|
833
|
+
|
|
831
834
|
this._markup.getViewpoint(viewpoint);
|
|
832
835
|
|
|
833
836
|
viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
|
|
@@ -838,6 +841,10 @@ export class Viewer
|
|
|
838
841
|
return viewpoint;
|
|
839
842
|
}
|
|
840
843
|
|
|
844
|
+
getSnapshot(type?: string, quality?: number): string {
|
|
845
|
+
return this.executeCommand("getSnapshot", type, quality);
|
|
846
|
+
}
|
|
847
|
+
|
|
841
848
|
// IWorldTransform
|
|
842
849
|
|
|
843
850
|
screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
|
|
@@ -23,7 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|
import type { Viewer } from "../Viewer";
|
|
25
25
|
|
|
26
|
-
export function
|
|
26
|
+
export function getSnapshot(viewer: Viewer, type?: string, quality?: number): string {
|
|
27
27
|
viewer.update(true);
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
const mimeType = type ?? viewer.options.snapshotMimeType ?? "image/jpeg";
|
|
30
|
+
const imageQuality = quality ?? viewer.options.snapshotQuality ?? 0.25;
|
|
31
|
+
|
|
32
|
+
if (viewer.markup) {
|
|
33
|
+
return viewer.markup.getSnapshot(mimeType, imageQuality);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return viewer.canvas.toDataURL(mimeType, imageQuality);
|
|
29
37
|
}
|
|
@@ -27,7 +27,7 @@ import { applyModelTransform } from "./ApplyModelTransform";
|
|
|
27
27
|
import { clearMarkup } from "./ClearMarkup";
|
|
28
28
|
import { clearSelected } from "./ClearSelected";
|
|
29
29
|
import { clearSlices } from "./ClearSlices";
|
|
30
|
-
import {
|
|
30
|
+
import { getSnapshot } from "./GetSnapshot";
|
|
31
31
|
import { explode, collect } from "./Explode";
|
|
32
32
|
import { getDefaultViewPositions } from "./GetDefaultViewPositions";
|
|
33
33
|
import { getModels } from "./GetModels";
|
|
@@ -83,7 +83,7 @@ commands.registerCommand("clearMarkup", clearMarkup);
|
|
|
83
83
|
commands.registerCommand("clearSelected", clearSelected);
|
|
84
84
|
commands.registerCommand("clearSlices", clearSlices);
|
|
85
85
|
commands.registerCommand("collect", collect);
|
|
86
|
-
commands.registerCommand("
|
|
86
|
+
commands.registerCommand("getSnapshot", getSnapshot);
|
|
87
87
|
commands.registerCommand("explode", explode);
|
|
88
88
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
89
89
|
commands.registerCommand("getModels", getModels);
|
|
@@ -117,6 +117,7 @@ commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"))
|
|
|
117
117
|
|
|
118
118
|
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
119
119
|
commands.registerCommandAlias("clearSelected", "unselect");
|
|
120
|
+
commands.registerCommandAlias("getSnapshot", "createPreview");
|
|
120
121
|
commands.registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
121
122
|
|
|
122
123
|
commands.registerCommandAlias("top", "k3DViewTop");
|
|
@@ -59,7 +59,7 @@ export class CameraComponent implements IComponent {
|
|
|
59
59
|
if (camera.isOrthographicCamera) {
|
|
60
60
|
camera.left = camera.bottom * aspectRatio;
|
|
61
61
|
camera.right = camera.top * aspectRatio;
|
|
62
|
-
camera.near =
|
|
62
|
+
camera.near = -extentsSize * 1000;
|
|
63
63
|
camera.far = extentsSize * 1000;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
25
|
+
import type { Viewer } from "../Viewer";
|
|
26
|
+
|
|
27
|
+
export class CanvasRemoveComponent implements IComponent {
|
|
28
|
+
protected viewer: Viewer;
|
|
29
|
+
protected mutationObserver: MutationObserver;
|
|
30
|
+
|
|
31
|
+
constructor(viewer: Viewer) {
|
|
32
|
+
this.viewer = viewer;
|
|
33
|
+
this.mutationObserver = new MutationObserver(this.cleanupViewer);
|
|
34
|
+
this.mutationObserver.observe(document, { childList: true, subtree: true });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
dispose() {
|
|
38
|
+
this.mutationObserver.disconnect();
|
|
39
|
+
this.mutationObserver = undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
cleanupViewer = (mutations: MutationRecord[]) => {
|
|
43
|
+
for (const mutation of mutations) {
|
|
44
|
+
if (mutation.type === "childList" && mutation.removedNodes.length > 0) {
|
|
45
|
+
for (const node of mutation.removedNodes) {
|
|
46
|
+
if (node === this.viewer.canvas || node.contains(this.viewer.canvas)) {
|
|
47
|
+
this.viewer.emitEvent({ type: "canvasremoved" });
|
|
48
|
+
this.viewer.dispose();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import { IComponent } from "@inweb/viewer-core";
|
|
25
25
|
import type { Viewer } from "../Viewer";
|
|
26
26
|
|
|
27
|
-
export class
|
|
27
|
+
export class CanvasResizeComponent implements IComponent {
|
|
28
28
|
protected viewer: Viewer;
|
|
29
29
|
protected resizeObserver: ResizeObserver;
|
|
30
30
|
|
|
@@ -28,8 +28,9 @@ import { CameraComponent } from "./CameraComponent";
|
|
|
28
28
|
import { ExtentsComponent } from "./ExtentsComponent";
|
|
29
29
|
import { LightComponent } from "./LightComponent";
|
|
30
30
|
import { InfoComponent } from "./InfoComponent";
|
|
31
|
+
import { CanvasResizeComponent } from "./CanvasResizeComponent";
|
|
32
|
+
import { CanvasRemoveComponent } from "./CanvasRemoveComponent";
|
|
31
33
|
import { RenderLoopComponent } from "./RenderLoopComponent";
|
|
32
|
-
import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
|
|
33
34
|
import { HighlighterComponent } from "./HighlighterComponent";
|
|
34
35
|
import { SelectionComponent } from "./SelectionComponent";
|
|
35
36
|
import { WCSHelperComponent } from "./WCSHelperComponent";
|
|
@@ -82,7 +83,8 @@ components.registerComponent("CameraComponent", (viewer) => new CameraComponent(
|
|
|
82
83
|
components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
|
|
83
84
|
components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
|
|
84
85
|
components.registerComponent("InfoComponent", (viewer) => new InfoComponent(viewer));
|
|
85
|
-
components.registerComponent("
|
|
86
|
+
components.registerComponent("CanvasResizeComponent", (viewer) => new CanvasResizeComponent(viewer));
|
|
87
|
+
components.registerComponent("CanvasRemoveComponent", (viewer) => new CanvasRemoveComponent(viewer));
|
|
86
88
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
87
89
|
components.registerComponent("HighlighterComponent", (viewer) => new HighlighterComponent(viewer));
|
|
88
90
|
components.registerComponent("SelectionComponent", (viewer) => new SelectionComponent(viewer));
|