@inweb/viewer-three 26.11.0 → 26.12.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/extensions/components/AxesHelperComponent.js +1 -1
- package/dist/extensions/components/AxesHelperComponent.js.map +1 -1
- package/dist/extensions/components/AxesHelperComponent.min.js +1 -1
- package/dist/extensions/components/AxesHelperComponent.module.js +1 -1
- package/dist/extensions/components/AxesHelperComponent.module.js.map +1 -1
- package/dist/extensions/components/InfoPanelComponent.js +170 -0
- package/dist/extensions/components/InfoPanelComponent.js.map +1 -0
- package/dist/extensions/components/InfoPanelComponent.min.js +24 -0
- package/dist/extensions/components/InfoPanelComponent.module.js +164 -0
- package/dist/extensions/components/InfoPanelComponent.module.js.map +1 -0
- package/dist/extensions/components/StatsPanelComponent.js +9 -3
- package/dist/extensions/components/StatsPanelComponent.js.map +1 -1
- package/dist/extensions/components/StatsPanelComponent.min.js +1 -1
- package/dist/extensions/components/StatsPanelComponent.module.js +9 -3
- package/dist/extensions/components/StatsPanelComponent.module.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.js +55 -4
- package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
- package/dist/extensions/loaders/PotreeLoader.module.js +52 -0
- package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -1
- package/dist/viewer-three.js +435 -14
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +8 -3
- package/dist/viewer-three.module.js +379 -10
- package/dist/viewer-three.module.js.map +1 -1
- package/extensions/components/AxesHelperComponent.ts +1 -1
- package/extensions/components/InfoPanelComponent.ts +197 -0
- package/extensions/components/StatsPanelComponent.ts +10 -3
- package/extensions/loaders/Potree/PotreeModelImpl.ts +72 -0
- package/lib/Viewer/Viewer.d.ts +2 -1
- package/lib/Viewer/components/InfoComponent.d.ts +22 -0
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +2 -0
- package/lib/Viewer/models/IModelImpl.d.ts +2 -1
- package/lib/Viewer/models/ModelImpl.d.ts +2 -0
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +41 -5
- package/src/Viewer/components/InfoComponent.ts +187 -0
- package/src/Viewer/components/index.ts +2 -0
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +16 -8
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +25 -0
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +67 -1
- package/src/Viewer/loaders/RangesLoader.ts +11 -1
- package/src/Viewer/models/IModelImpl.ts +3 -1
- package/src/Viewer/models/ModelImpl.ts +158 -0
|
@@ -35,7 +35,7 @@ class AxesHelperComponent implements IComponent {
|
|
|
35
35
|
this.axesHelper2 = new AxesHelper(1);
|
|
36
36
|
this.modelHelpers = [];
|
|
37
37
|
|
|
38
|
-
this.axesHelper1.setColors("#ccc", "#ccc", "#
|
|
38
|
+
this.axesHelper1.setColors("#ccc", "#ccc", "#ccc");
|
|
39
39
|
|
|
40
40
|
this.viewer = viewer;
|
|
41
41
|
this.viewer.addEventListener("initialize", this.syncHelper);
|
|
@@ -0,0 +1,197 @@
|
|
|
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, components, Viewer } from "@inweb/viewer-three";
|
|
25
|
+
|
|
26
|
+
const map = {
|
|
27
|
+
B: 1,
|
|
28
|
+
KB: 1 << 10,
|
|
29
|
+
MB: 1 << 20,
|
|
30
|
+
GB: 1 << 30,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function formatBytes(bytes: number): string {
|
|
34
|
+
if (!bytes) return "-";
|
|
35
|
+
|
|
36
|
+
let unit: string;
|
|
37
|
+
if (bytes >= map.GB) unit = "GB";
|
|
38
|
+
else if (bytes >= map.MB) unit = "MB";
|
|
39
|
+
else if (bytes >= map.KB) unit = "KB";
|
|
40
|
+
else unit = "B";
|
|
41
|
+
|
|
42
|
+
const value = bytes / map[unit];
|
|
43
|
+
return value.toFixed() + " " + unit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class Panel {
|
|
47
|
+
public dom: HTMLElement;
|
|
48
|
+
private label: HTMLElement;
|
|
49
|
+
private text: HTMLElement;
|
|
50
|
+
|
|
51
|
+
constructor(label: string) {
|
|
52
|
+
this.dom = document.createElement("div");
|
|
53
|
+
|
|
54
|
+
this.label = document.createElement("div");
|
|
55
|
+
this.label.style.padding = "0.25rem 0";
|
|
56
|
+
this.label.style.fontWeight = "600";
|
|
57
|
+
this.label.innerText = label;
|
|
58
|
+
this.dom.appendChild(this.label);
|
|
59
|
+
|
|
60
|
+
this.text = document.createElement("small");
|
|
61
|
+
this.text.style.display = "block";
|
|
62
|
+
this.text.style.padding = "0 0.5rem";
|
|
63
|
+
this.dom.appendChild(this.text);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
update(text: string) {
|
|
67
|
+
if (this.text.innerText !== text) this.text.innerText = text;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class InfoPanelComponent implements IComponent {
|
|
72
|
+
private viewer: Viewer;
|
|
73
|
+
private container: HTMLElement;
|
|
74
|
+
private performancePanel: Panel;
|
|
75
|
+
private renderPanel: Panel;
|
|
76
|
+
private optimizedPanel: Panel;
|
|
77
|
+
private scenePanel: Panel;
|
|
78
|
+
private memoryPanel: Panel;
|
|
79
|
+
|
|
80
|
+
constructor(viewer: Viewer) {
|
|
81
|
+
this.container = document.createElement("div");
|
|
82
|
+
this.container.id = "info-container";
|
|
83
|
+
this.container.style.position = "absolute";
|
|
84
|
+
this.container.style.left = "0px";
|
|
85
|
+
this.container.style.top = "0px";
|
|
86
|
+
this.container.style.maxHeight = "100%";
|
|
87
|
+
this.container.style.overflow = "auto";
|
|
88
|
+
this.container.style.padding = "1rem";
|
|
89
|
+
|
|
90
|
+
this.setTheme("dark");
|
|
91
|
+
|
|
92
|
+
this.performancePanel = new Panel("Performance");
|
|
93
|
+
this.renderPanel = new Panel("Render");
|
|
94
|
+
this.optimizedPanel = new Panel("Optimized Scene");
|
|
95
|
+
this.scenePanel = new Panel("Scene");
|
|
96
|
+
this.memoryPanel = new Panel("Memory");
|
|
97
|
+
|
|
98
|
+
this.container.appendChild(this.performancePanel.dom);
|
|
99
|
+
this.container.appendChild(this.renderPanel.dom);
|
|
100
|
+
this.container.appendChild(this.optimizedPanel.dom);
|
|
101
|
+
this.container.appendChild(this.scenePanel.dom);
|
|
102
|
+
this.container.appendChild(this.memoryPanel.dom);
|
|
103
|
+
|
|
104
|
+
viewer.canvas.parentElement.appendChild(this.container);
|
|
105
|
+
|
|
106
|
+
this.viewer = viewer;
|
|
107
|
+
this.viewer.addEventListener("clear", this.updateSceneInfo);
|
|
108
|
+
this.viewer.addEventListener("geometryend", this.updateSceneInfo);
|
|
109
|
+
this.viewer.addEventListener("render", this.updateRenderInfo);
|
|
110
|
+
this.viewer.addEventListener("animate", this.updatePreformanceInfo);
|
|
111
|
+
|
|
112
|
+
this.updatePreformanceInfo();
|
|
113
|
+
this.updateRenderInfo();
|
|
114
|
+
this.updateSceneInfo();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dispose() {
|
|
118
|
+
this.viewer.removeEventListener("clear", this.updateSceneInfo);
|
|
119
|
+
this.viewer.removeEventListener("geometryend", this.updateSceneInfo);
|
|
120
|
+
this.viewer.removeEventListener("render", this.updateRenderInfo);
|
|
121
|
+
this.viewer.removeEventListener("animate", this.updatePreformanceInfo);
|
|
122
|
+
|
|
123
|
+
this.performancePanel = undefined;
|
|
124
|
+
this.renderPanel = undefined;
|
|
125
|
+
this.optimizedPanel = undefined;
|
|
126
|
+
this.scenePanel = undefined;
|
|
127
|
+
this.memoryPanel = undefined;
|
|
128
|
+
|
|
129
|
+
this.container.remove();
|
|
130
|
+
this.container = undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
setTheme(value: string) {
|
|
134
|
+
if (value === "light") {
|
|
135
|
+
this.container.style.background = "rgba(0, 0, 0, 0.025)";
|
|
136
|
+
this.container.style.color = "#3d3d3d";
|
|
137
|
+
}
|
|
138
|
+
if (value === "dark") {
|
|
139
|
+
this.container.style.background = "rgba(0, 0, 0, 0.88)";
|
|
140
|
+
this.container.style.color = "#ebebeb";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
updatePreformanceInfo = () => {
|
|
145
|
+
const info = this.viewer.info;
|
|
146
|
+
|
|
147
|
+
const text = [];
|
|
148
|
+
text.push(`FPS: ${info.performance.fps}`);
|
|
149
|
+
text.push(`Frame Time: ${info.performance.frameTime} ms`);
|
|
150
|
+
this.performancePanel.update(text.join("\n"));
|
|
151
|
+
|
|
152
|
+
this.viewer.update();
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
updateRenderInfo = () => {
|
|
156
|
+
const info = this.viewer.info;
|
|
157
|
+
|
|
158
|
+
const text = [];
|
|
159
|
+
text.push(`Viewport: ${info.render.viewport.width} x ${info.render.viewport.height}`);
|
|
160
|
+
text.push(`Antialiasing: ${info.render.antialiasing}`);
|
|
161
|
+
text.push(`Draw Calls: ${info.render.drawCalls}`);
|
|
162
|
+
text.push(`Triangles: ${info.render.triangles}`);
|
|
163
|
+
text.push(`Points: ${info.render.points}`);
|
|
164
|
+
text.push(`Lines: ${info.render.lines}`);
|
|
165
|
+
this.renderPanel.update(text.join("\n"));
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
updateSceneInfo = () => {
|
|
169
|
+
const info = this.viewer.info;
|
|
170
|
+
|
|
171
|
+
const text = [];
|
|
172
|
+
text.push(`Objects: ${info.optimizedScene.objects}`);
|
|
173
|
+
text.push(`Triangles: ${info.optimizedScene.triangles}`);
|
|
174
|
+
text.push(`Points: ${info.optimizedScene.points}`);
|
|
175
|
+
text.push(`Lines: ${info.optimizedScene.lines}`);
|
|
176
|
+
text.push(`Edges: ${info.optimizedScene.edges}`);
|
|
177
|
+
this.optimizedPanel.update(text.join("\n"));
|
|
178
|
+
|
|
179
|
+
text.length = 0;
|
|
180
|
+
text.push(`Objects: ${info.scene.objects}`);
|
|
181
|
+
text.push(`Triangles: ${info.scene.triangles}`);
|
|
182
|
+
text.push(`Points: ${info.scene.points}`);
|
|
183
|
+
text.push(`Lines: ${info.scene.lines}`);
|
|
184
|
+
text.push(`Edges: ${info.scene.edges}`);
|
|
185
|
+
this.scenePanel.update(text.join("\n"));
|
|
186
|
+
|
|
187
|
+
text.length = 0;
|
|
188
|
+
text.push(`Geometries: ${info.memory.geometries}`);
|
|
189
|
+
text.push(`Textures: ${info.memory.textures}`);
|
|
190
|
+
text.push(`Materials: ${info.memory.materials}`);
|
|
191
|
+
text.push(`GPU Used: ${formatBytes(info.memory.totalEstimatedGpuBytes)}`);
|
|
192
|
+
text.push(`JS Heap Used: ${formatBytes(info.memory.usedJSHeapSize)}`);
|
|
193
|
+
this.memoryPanel.update(text.join("\n"));
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
components.registerComponent("InfoPanelComponent", (viewer) => new InfoPanelComponent(viewer));
|
|
@@ -31,23 +31,30 @@ class StatsPanelComponent implements IComponent {
|
|
|
31
31
|
constructor(viewer: Viewer) {
|
|
32
32
|
this.stats = new Stats();
|
|
33
33
|
this.stats.dom.style.position = "absolute";
|
|
34
|
+
this.stats.dom.style.left = "0px";
|
|
35
|
+
this.stats.dom.style.top = "0px";
|
|
34
36
|
viewer.canvas.parentElement.appendChild(this.stats.dom);
|
|
35
37
|
|
|
36
38
|
this.viewer = viewer;
|
|
37
|
-
this.viewer.
|
|
39
|
+
this.viewer.addEventListener("render", this.updateStats);
|
|
40
|
+
this.viewer.addEventListener("animate", this.updateViewer);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
dispose() {
|
|
41
|
-
this.viewer.
|
|
44
|
+
this.viewer.removeEventListener("render", this.updateStats);
|
|
45
|
+
this.viewer.removeEventListener("animate", this.updateViewer);
|
|
42
46
|
|
|
43
47
|
this.stats.dom.remove();
|
|
44
48
|
this.stats = undefined;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
updateStats = () => {
|
|
48
|
-
this.viewer.render(null, true);
|
|
49
52
|
this.stats.update();
|
|
50
53
|
};
|
|
54
|
+
|
|
55
|
+
updateViewer = () => {
|
|
56
|
+
this.viewer.update();
|
|
57
|
+
};
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
components.registerComponent("StatsPanelComponent", (viewer) => new StatsPanelComponent(viewer));
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { Box3 } from "three";
|
|
25
25
|
import { PointCloudOctree } from "potree-core";
|
|
26
|
+
import { IInfo, Info } from "@inweb/viewer-core";
|
|
26
27
|
import { ModelImpl } from "@inweb/viewer-three";
|
|
27
28
|
|
|
28
29
|
// Potree model implementation.
|
|
@@ -30,6 +31,77 @@ import { ModelImpl } from "@inweb/viewer-three";
|
|
|
30
31
|
export class PotreeModelImpl extends ModelImpl {
|
|
31
32
|
public pco: PointCloudOctree;
|
|
32
33
|
|
|
34
|
+
override getInfo(): IInfo {
|
|
35
|
+
// ===================== AI-CODE-START ======================
|
|
36
|
+
// Source: Claude Sonnet 4.5
|
|
37
|
+
// Date: 2025-10-02
|
|
38
|
+
// Reviewer: roman.mochalov@opendesign.com
|
|
39
|
+
// Issue: CLOUD-5738
|
|
40
|
+
|
|
41
|
+
let totalPoints = 0;
|
|
42
|
+
let totalNodes = 0;
|
|
43
|
+
let loadedGeometryBytes = 0;
|
|
44
|
+
let estimatedTotalGeometryBytes = 0;
|
|
45
|
+
let geometryBytes = 0;
|
|
46
|
+
|
|
47
|
+
const bytesPerPoint = this.pco.pcoGeometry?.pointAttributes?.byteSize || 0;
|
|
48
|
+
|
|
49
|
+
if (this.pco.pcoGeometry && this.pco.pcoGeometry.root) {
|
|
50
|
+
this.pco.pcoGeometry.root.traverse((node: any) => {
|
|
51
|
+
totalNodes++;
|
|
52
|
+
|
|
53
|
+
const numPoints = node.numPoints || 0;
|
|
54
|
+
totalPoints += numPoints;
|
|
55
|
+
|
|
56
|
+
if (node.loaded && node.geometry) {
|
|
57
|
+
if (node.geometry.attributes) {
|
|
58
|
+
for (const name in node.geometry.attributes) {
|
|
59
|
+
const attribute = node.geometry.attributes[name];
|
|
60
|
+
if (attribute && attribute.array) {
|
|
61
|
+
loadedGeometryBytes += attribute.array.byteLength;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (node.geometry.index && node.geometry.index.array) {
|
|
67
|
+
loadedGeometryBytes += node.geometry.index.array.byteLength;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (bytesPerPoint > 0 && numPoints > 0) {
|
|
72
|
+
estimatedTotalGeometryBytes += numPoints * (bytesPerPoint * 2 - 1);
|
|
73
|
+
}
|
|
74
|
+
}, true);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
geometryBytes = Math.max(loadedGeometryBytes, estimatedTotalGeometryBytes);
|
|
78
|
+
|
|
79
|
+
// ===================== AI-CODE-END ======================
|
|
80
|
+
|
|
81
|
+
const info = new Info();
|
|
82
|
+
|
|
83
|
+
info.scene.objects = totalNodes;
|
|
84
|
+
info.scene.points = totalPoints;
|
|
85
|
+
info.scene.triangles = 0;
|
|
86
|
+
info.scene.lines = 0;
|
|
87
|
+
info.scene.edges = 0;
|
|
88
|
+
|
|
89
|
+
info.memory.geometries = totalNodes;
|
|
90
|
+
info.memory.geometryBytes = Math.floor(geometryBytes);
|
|
91
|
+
info.memory.textures = 0;
|
|
92
|
+
info.memory.textureBytes = 0;
|
|
93
|
+
info.memory.materials = 1;
|
|
94
|
+
info.memory.totalEstimatedGpuBytes = Math.floor(geometryBytes);
|
|
95
|
+
|
|
96
|
+
info.optimizedScene.objects = info.scene.objects;
|
|
97
|
+
info.optimizedScene.triangles = info.scene.triangles;
|
|
98
|
+
info.optimizedScene.points = info.scene.points;
|
|
99
|
+
info.optimizedScene.lines = info.scene.lines;
|
|
100
|
+
info.optimizedScene.edges = info.scene.edges;
|
|
101
|
+
|
|
102
|
+
return info;
|
|
103
|
+
}
|
|
104
|
+
|
|
33
105
|
override getExtents(target: Box3): Box3 {
|
|
34
106
|
return target.union(this.pco.pcoGeometry.boundingBox);
|
|
35
107
|
}
|
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { SSAARenderPass } from "./postprocessing/SSAARenderPass.js";
|
|
|
7
7
|
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
|
|
8
8
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
9
9
|
import { Assembly, Client, Model, File } from "@inweb/client";
|
|
10
|
-
import { CanvasEventMap, FileSource, IComponent, IDragger, ILoader, IOptions, IViewer, IViewpoint, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
10
|
+
import { CanvasEventMap, FileSource, IComponent, IDragger, IInfo, ILoader, IOptions, IViewer, IViewpoint, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
|
|
11
11
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
12
12
|
import { IModelImpl } from "./models/IModelImpl";
|
|
13
13
|
import { Helpers } from "./scenes/Helpers";
|
|
@@ -21,6 +21,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
21
21
|
canvasEvents: string[];
|
|
22
22
|
loaders: ILoader[];
|
|
23
23
|
models: IModelImpl[];
|
|
24
|
+
info: IInfo;
|
|
24
25
|
private canvaseventlistener;
|
|
25
26
|
scene: Scene | undefined;
|
|
26
27
|
helpers: Helpers | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
|
+
import type { Viewer } from "../Viewer";
|
|
3
|
+
export declare class InfoComponent implements IComponent {
|
|
4
|
+
protected viewer: Viewer;
|
|
5
|
+
private startTime;
|
|
6
|
+
private beginTime;
|
|
7
|
+
private prevTime;
|
|
8
|
+
private frames;
|
|
9
|
+
constructor(viewer: Viewer);
|
|
10
|
+
dispose(): void;
|
|
11
|
+
initialize: () => void;
|
|
12
|
+
clear: () => void;
|
|
13
|
+
optionsChange: ({ data: options }: {
|
|
14
|
+
data: any;
|
|
15
|
+
}) => void;
|
|
16
|
+
geometryStart: () => void;
|
|
17
|
+
databaseChunk: () => void;
|
|
18
|
+
geometryEnd: () => void;
|
|
19
|
+
resize: () => void;
|
|
20
|
+
render: () => void;
|
|
21
|
+
animate: () => void;
|
|
22
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Box3, Object3D } from "three";
|
|
2
|
+
import { IInfo } from "@inweb/viewer-core";
|
|
2
3
|
import { ModelImpl } from "../../models/ModelImpl";
|
|
3
4
|
import { DynamicGltfLoader } from "./DynamicGltfLoader.js";
|
|
4
5
|
export declare class DynamicModelImpl extends ModelImpl {
|
|
5
6
|
gltfLoader: DynamicGltfLoader;
|
|
7
|
+
getInfo(): IInfo;
|
|
6
8
|
getExtents(target: Box3): Box3;
|
|
7
9
|
getObjects(): Object3D[];
|
|
8
10
|
getVisibleObjects(): Object3D[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Box3, Object3D } from "three";
|
|
2
|
-
import { IModel } from "@inweb/viewer-core";
|
|
2
|
+
import { IInfo, IModel } from "@inweb/viewer-core";
|
|
3
3
|
/**
|
|
4
4
|
* Basic model implementation.
|
|
5
5
|
*/
|
|
@@ -9,6 +9,7 @@ export interface IModelImpl extends IModel {
|
|
|
9
9
|
getUnitScale(): number;
|
|
10
10
|
getUnitString(): string;
|
|
11
11
|
getPrecision(): number;
|
|
12
|
+
getInfo(): IInfo;
|
|
12
13
|
getExtents(target: Box3): Box3;
|
|
13
14
|
getObjects(): Object3D[];
|
|
14
15
|
getVisibleObjects(): Object3D[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Box3, Object3D } from "three";
|
|
2
|
+
import { IInfo } from "@inweb/viewer-core";
|
|
2
3
|
import { IModelImpl } from "./IModelImpl";
|
|
3
4
|
export declare class ModelImpl implements IModelImpl {
|
|
4
5
|
id: string;
|
|
@@ -9,6 +10,7 @@ export declare class ModelImpl implements IModelImpl {
|
|
|
9
10
|
getUnitScale(): number;
|
|
10
11
|
getUnitString(): string;
|
|
11
12
|
getPrecision(): number;
|
|
13
|
+
getInfo(): IInfo;
|
|
12
14
|
getExtents(target: Box3): Box3;
|
|
13
15
|
getObjects(): Object3D[];
|
|
14
16
|
getVisibleObjects(): Object3D[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.12.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",
|
|
@@ -35,10 +35,10 @@
|
|
|
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.12.1",
|
|
39
|
+
"@inweb/eventemitter2": "~26.12.1",
|
|
40
|
+
"@inweb/markup": "~26.12.1",
|
|
41
|
+
"@inweb/viewer-core": "~26.12.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/three": "^0.180.0",
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
import {
|
|
25
25
|
Box3,
|
|
26
26
|
LinearSRGBColorSpace,
|
|
27
|
-
// LinearToneMapping,
|
|
28
27
|
Object3D,
|
|
29
28
|
OrthographicCamera,
|
|
30
29
|
PerspectiveCamera,
|
|
31
30
|
Plane,
|
|
31
|
+
Raycaster,
|
|
32
32
|
Scene,
|
|
33
33
|
Sphere,
|
|
34
34
|
Vector2,
|
|
@@ -52,7 +52,9 @@ import {
|
|
|
52
52
|
IComponent,
|
|
53
53
|
IDragger,
|
|
54
54
|
IEntity,
|
|
55
|
+
IInfo,
|
|
55
56
|
ILoader,
|
|
57
|
+
Info,
|
|
56
58
|
IOptions,
|
|
57
59
|
IOrthogonalCamera,
|
|
58
60
|
IPerspectiveCamera,
|
|
@@ -85,6 +87,7 @@ export class Viewer
|
|
|
85
87
|
public canvasEvents: string[];
|
|
86
88
|
public loaders: ILoader[];
|
|
87
89
|
public models: IModelImpl[];
|
|
90
|
+
public info: IInfo;
|
|
88
91
|
|
|
89
92
|
private canvaseventlistener: (event: any) => void;
|
|
90
93
|
|
|
@@ -122,6 +125,7 @@ export class Viewer
|
|
|
122
125
|
this.options = new Options(this);
|
|
123
126
|
this.loaders = [];
|
|
124
127
|
this.models = [];
|
|
128
|
+
this.info = new Info();
|
|
125
129
|
|
|
126
130
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
127
131
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
@@ -326,6 +330,9 @@ export class Viewer
|
|
|
326
330
|
this._renderTime = time;
|
|
327
331
|
this._renderNeeded = false;
|
|
328
332
|
|
|
333
|
+
this.renderer.info.autoReset = false;
|
|
334
|
+
this.renderer.info.reset();
|
|
335
|
+
|
|
329
336
|
if (this.options.antialiasing === true || this.options.antialiasing === "msaa") {
|
|
330
337
|
this.renderer.render(this.scene, this.camera);
|
|
331
338
|
this.renderer.render(this.helpers, this.camera);
|
|
@@ -825,7 +832,11 @@ export class Viewer
|
|
|
825
832
|
}
|
|
826
833
|
|
|
827
834
|
// IWorldTransform
|
|
828
|
-
|
|
835
|
+
// ===================== AI-CODE-START ======================
|
|
836
|
+
// Source: Claude Sonnet 4.5
|
|
837
|
+
// Date: 2025-11-25
|
|
838
|
+
// Reviewer: vitaly.ivanov@opendesign.com
|
|
839
|
+
// Issue: CLOUD-5990
|
|
829
840
|
screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
|
|
830
841
|
if (!this.renderer) return { x: position.x, y: position.y, z: 0 };
|
|
831
842
|
|
|
@@ -833,11 +844,36 @@ export class Viewer
|
|
|
833
844
|
const x = position.x / (rect.width / 2) - 1;
|
|
834
845
|
const y = -position.y / (rect.height / 2) + 1;
|
|
835
846
|
|
|
836
|
-
|
|
837
|
-
|
|
847
|
+
if (this.camera["isPerspectiveCamera"]) {
|
|
848
|
+
// Create a raycaster from the screen position
|
|
849
|
+
const raycaster = new Raycaster();
|
|
850
|
+
const mouse = new Vector2(x, y);
|
|
851
|
+
raycaster.setFromCamera(mouse, this.camera);
|
|
852
|
+
|
|
853
|
+
// Create a plane perpendicular to the camera direction at the target point
|
|
854
|
+
const cameraDirection = new Vector3();
|
|
855
|
+
this.camera.getWorldDirection(cameraDirection);
|
|
856
|
+
const targetPlane = new Plane().setFromNormalAndCoplanarPoint(cameraDirection, this.target);
|
|
857
|
+
|
|
858
|
+
// Intersect the ray with the target plane
|
|
859
|
+
const intersectionPoint = new Vector3();
|
|
860
|
+
raycaster.ray.intersectPlane(targetPlane, intersectionPoint);
|
|
861
|
+
|
|
862
|
+
// If intersection fails (ray parallel to plane), fallback to near plane unprojection
|
|
863
|
+
if (!intersectionPoint) {
|
|
864
|
+
const point = new Vector3(x, y, -1);
|
|
865
|
+
point.unproject(this.camera);
|
|
866
|
+
return { x: point.x, y: point.y, z: point.z };
|
|
867
|
+
}
|
|
868
|
+
return { x: intersectionPoint.x, y: intersectionPoint.y, z: intersectionPoint.z };
|
|
869
|
+
} else {
|
|
870
|
+
const point = new Vector3(x, y, -1);
|
|
871
|
+
point.unproject(this.camera);
|
|
838
872
|
|
|
839
|
-
|
|
873
|
+
return { x: point.x, y: point.y, z: point.z };
|
|
874
|
+
}
|
|
840
875
|
}
|
|
876
|
+
// ===================== AI-CODE-END ======================
|
|
841
877
|
|
|
842
878
|
worldToScreen(position: { x: number; y: number; z: number }): { x: number; y: number } {
|
|
843
879
|
if (!this.renderer) return { x: position.x, y: position.y };
|