@inweb/viewer-three 27.1.2 → 27.1.4
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/extensions/components/RoomEnvironmentComponent.js +1 -0
- package/dist/extensions/components/RoomEnvironmentComponent.js.map +1 -1
- package/dist/extensions/components/RoomEnvironmentComponent.min.js +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
- package/dist/viewer-three.js +1315 -690
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +4 -4
- package/dist/viewer-three.module.js +59 -13
- 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/package.json +9 -9
- package/src/Viewer/Viewer.ts +7 -0
- package/src/Viewer/commands/{CreatePreview.ts → GetSnapshot.ts} +10 -2
- package/src/Viewer/commands/index.ts +3 -2
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +63 -10
- 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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.4",
|
|
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,20 +35,20 @@
|
|
|
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.4",
|
|
39
|
+
"@inweb/eventemitter2": "~27.1.4",
|
|
40
|
+
"@inweb/markup": "~27.1.4",
|
|
41
|
+
"@inweb/viewer-core": "~27.1.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@streamparser/json": "^0.0.22",
|
|
45
|
-
"@types/three": "^0.
|
|
45
|
+
"@types/three": "^0.182.0",
|
|
46
46
|
"potree-core": "^2.0.11",
|
|
47
|
-
"three": "^0.
|
|
47
|
+
"three": "^0.182.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@streamparser/json": "^0.0.22",
|
|
51
|
-
"@types/three": "^0.
|
|
52
|
-
"three": "^0.
|
|
51
|
+
"@types/three": "^0.182.0",
|
|
52
|
+
"three": "^0.182.0"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -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");
|
|
@@ -1004,19 +1004,19 @@ export class DynamicGltfLoader {
|
|
|
1004
1004
|
const transformedBox = node.geometryExtents.clone();
|
|
1005
1005
|
const structureRoot = node.structure ? this.structureRoots.get(node.structure.id) : null;
|
|
1006
1006
|
|
|
1007
|
+
// Calculate relative transformation from node.group to structureRoot
|
|
1008
|
+
// This matches the logic used in merge methods
|
|
1007
1009
|
if (node.group) {
|
|
1008
|
-
const
|
|
1009
|
-
let
|
|
1010
|
+
const relativeMatrix = new Matrix4();
|
|
1011
|
+
let currentObject = node.group;
|
|
1010
1012
|
|
|
1011
|
-
while (
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
currentGroup = currentGroup.parent;
|
|
1013
|
+
while (currentObject && currentObject !== structureRoot) {
|
|
1014
|
+
relativeMatrix.premultiply(currentObject.matrix);
|
|
1015
|
+
currentObject = currentObject.parent;
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
|
-
|
|
1019
|
-
transformedBox.applyMatrix4(
|
|
1018
|
+
if (!relativeMatrix.equals(new Matrix4())) {
|
|
1019
|
+
transformedBox.applyMatrix4(relativeMatrix);
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
@@ -1548,6 +1548,18 @@ export class DynamicGltfLoader {
|
|
|
1548
1548
|
for (const mesh of group.objects) {
|
|
1549
1549
|
const geometry = mesh.geometry.clone();
|
|
1550
1550
|
|
|
1551
|
+
const relativeMatrix = new Matrix4();
|
|
1552
|
+
let currentObject = mesh;
|
|
1553
|
+
|
|
1554
|
+
while (currentObject && currentObject !== rootGroup) {
|
|
1555
|
+
relativeMatrix.premultiply(currentObject.matrix);
|
|
1556
|
+
currentObject = currentObject.parent;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
if (!relativeMatrix.equals(new Matrix4())) {
|
|
1560
|
+
geometry.applyMatrix4(relativeMatrix);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1551
1563
|
const handle = mesh.userData.handle;
|
|
1552
1564
|
if (!this.objectIdToIndex.has(handle)) {
|
|
1553
1565
|
this.objectIdToIndex.set(handle, this.maxObjectId++);
|
|
@@ -1673,7 +1685,20 @@ export class DynamicGltfLoader {
|
|
|
1673
1685
|
let isEdge = false;
|
|
1674
1686
|
group.objects.forEach((line) => {
|
|
1675
1687
|
isEdge = line.userData.isEdge;
|
|
1676
|
-
const geometry = line.geometry;
|
|
1688
|
+
const geometry = line.geometry.clone();
|
|
1689
|
+
|
|
1690
|
+
const relativeMatrix = new Matrix4();
|
|
1691
|
+
let currentObject = line;
|
|
1692
|
+
|
|
1693
|
+
while (currentObject && currentObject !== rootGroup) {
|
|
1694
|
+
relativeMatrix.premultiply(currentObject.matrix);
|
|
1695
|
+
currentObject = currentObject.parent;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
if (!relativeMatrix.equals(new Matrix4())) {
|
|
1699
|
+
geometry.applyMatrix4(relativeMatrix);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1677
1702
|
const positionAttr = geometry.attributes.position;
|
|
1678
1703
|
const vertexCount = positionAttr.count;
|
|
1679
1704
|
|
|
@@ -1701,6 +1726,7 @@ export class DynamicGltfLoader {
|
|
|
1701
1726
|
}
|
|
1702
1727
|
|
|
1703
1728
|
vertexOffset += vertexCount;
|
|
1729
|
+
geometry.dispose();
|
|
1704
1730
|
});
|
|
1705
1731
|
|
|
1706
1732
|
const geometry = new BufferGeometry();
|
|
@@ -1787,6 +1813,20 @@ export class DynamicGltfLoader {
|
|
|
1787
1813
|
isEdge = line.userData.isEdge;
|
|
1788
1814
|
const geometry = line.geometry.clone();
|
|
1789
1815
|
|
|
1816
|
+
// Calculate transformation matrix relative to rootGroup
|
|
1817
|
+
const relativeMatrix = new Matrix4();
|
|
1818
|
+
let currentObject = line;
|
|
1819
|
+
|
|
1820
|
+
while (currentObject && currentObject !== rootGroup) {
|
|
1821
|
+
relativeMatrix.premultiply(currentObject.matrix);
|
|
1822
|
+
currentObject = currentObject.parent;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
// Apply the relative transformation
|
|
1826
|
+
if (!relativeMatrix.equals(new Matrix4())) {
|
|
1827
|
+
geometry.applyMatrix4(relativeMatrix);
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1790
1830
|
const handle = line.userData.handle;
|
|
1791
1831
|
if (!this.objectIdToIndex.has(handle)) {
|
|
1792
1832
|
this.objectIdToIndex.set(handle, this.maxObjectId++);
|
|
@@ -1892,6 +1932,19 @@ export class DynamicGltfLoader {
|
|
|
1892
1932
|
|
|
1893
1933
|
for (const points of group.objects) {
|
|
1894
1934
|
const geometry = points.geometry.clone();
|
|
1935
|
+
|
|
1936
|
+
const relativeMatrix = new Matrix4();
|
|
1937
|
+
let currentObject = points;
|
|
1938
|
+
|
|
1939
|
+
while (currentObject && currentObject !== rootGroup) {
|
|
1940
|
+
relativeMatrix.premultiply(currentObject.matrix);
|
|
1941
|
+
currentObject = currentObject.parent;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
if (!relativeMatrix.equals(new Matrix4())) {
|
|
1945
|
+
geometry.applyMatrix4(relativeMatrix);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1895
1948
|
geometries.push(geometry);
|
|
1896
1949
|
optimizedObjects.push(points);
|
|
1897
1950
|
handles.add(points.userData.handle);
|