@inweb/viewer-three 26.5.5 → 26.6.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/plugins/components/LightHelperComponent.js +9 -3
- package/dist/plugins/components/LightHelperComponent.js.map +1 -1
- package/dist/plugins/components/LightHelperComponent.min.js +1 -1
- package/dist/plugins/components/LightHelperComponent.module.js +5 -4
- package/dist/plugins/components/LightHelperComponent.module.js.map +1 -1
- package/dist/plugins/components/RoomEnvironmentComponent.js +178 -0
- package/dist/plugins/components/RoomEnvironmentComponent.js.map +1 -0
- package/dist/plugins/components/RoomEnvironmentComponent.min.js +1 -0
- package/dist/plugins/components/RoomEnvironmentComponent.module.js +21 -0
- package/dist/plugins/components/RoomEnvironmentComponent.module.js.map +1 -0
- package/dist/plugins/loaders/IFCXLoader.js +21 -27
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.min.js +1 -1
- package/dist/plugins/loaders/IFCXLoader.module.js +7 -18
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/viewer-three.js +25 -173
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -2
- package/dist/viewer-three.module.js +21 -21
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/components/LightComponent.d.ts +3 -1
- package/package.json +5 -5
- package/plugins/components/LightHelperComponent.ts +10 -5
- package/{src/Viewer → plugins}/components/RoomEnvironmentComponent.ts +4 -4
- package/plugins/loaders/IFCX/render.js +26 -21
- package/src/Viewer/components/LightComponent.ts +33 -4
- package/src/Viewer/components/index.ts +0 -2
- package/lib/Viewer/components/RoomEnvironmentComponent.d.ts +0 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { AmbientLight, DirectionalLight } from "three";
|
|
1
|
+
import { AmbientLight, DirectionalLight, HemisphereLight } from "three";
|
|
2
2
|
import { IComponent } from "@inweb/viewer-core";
|
|
3
3
|
import type { Viewer } from "../Viewer";
|
|
4
4
|
export declare class LightComponent implements IComponent {
|
|
5
5
|
protected viewer: Viewer;
|
|
6
6
|
protected ambientLight: AmbientLight;
|
|
7
7
|
protected directionalLight: DirectionalLight;
|
|
8
|
+
protected frontLight: DirectionalLight;
|
|
9
|
+
protected hemisphereLight: HemisphereLight;
|
|
8
10
|
constructor(viewer: Viewer);
|
|
9
11
|
dispose(): void;
|
|
10
12
|
geometryEnd: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.6.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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"docs": "typedoc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@inweb/client": "~26.
|
|
35
|
-
"@inweb/eventemitter2": "~26.
|
|
36
|
-
"@inweb/markup": "~26.
|
|
37
|
-
"@inweb/viewer-core": "~26.
|
|
34
|
+
"@inweb/client": "~26.6.1",
|
|
35
|
+
"@inweb/eventemitter2": "~26.6.1",
|
|
36
|
+
"@inweb/markup": "~26.6.1",
|
|
37
|
+
"@inweb/viewer-core": "~26.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/three": "^0.173.0",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { DirectionalLightHelper, Sphere } from "three";
|
|
24
|
+
import { DirectionalLightHelper, HemisphereLightHelper, PointLightHelper, Sphere } from "three";
|
|
25
25
|
import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
26
26
|
|
|
27
27
|
class LightHelperComponent implements IComponent {
|
|
28
28
|
private viewer: Viewer;
|
|
29
|
-
private lightHelpers: DirectionalLightHelper[];
|
|
29
|
+
private lightHelpers: (DirectionalLightHelper | HemisphereLightHelper | PointLightHelper)[];
|
|
30
30
|
|
|
31
31
|
constructor(viewer: Viewer) {
|
|
32
32
|
this.lightHelpers = [];
|
|
@@ -54,11 +54,16 @@ class LightHelperComponent implements IComponent {
|
|
|
54
54
|
this.lightHelpers.length = 0;
|
|
55
55
|
|
|
56
56
|
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
|
|
57
|
-
const size = extentsSize /
|
|
57
|
+
const size = extentsSize / 20;
|
|
58
58
|
|
|
59
59
|
this.viewer.scene.traverse((object: any) => {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
let helper: DirectionalLightHelper | HemisphereLightHelper | PointLightHelper;
|
|
61
|
+
|
|
62
|
+
if (object.isDirectionalLight) helper = new DirectionalLightHelper(object, size, "#aa0000");
|
|
63
|
+
else if (object.isHemisphereLight) helper = new HemisphereLightHelper(object, size, "#ff9800");
|
|
64
|
+
else if (object.isPointLight) helper = new PointLightHelper(object, size, "#ff9800");
|
|
65
|
+
|
|
66
|
+
if (helper) {
|
|
62
67
|
this.lightHelpers.push(helper);
|
|
63
68
|
this.viewer.helpers.add(helper);
|
|
64
69
|
}
|
|
@@ -23,11 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
import { PMREMGenerator } from "three";
|
|
25
25
|
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
|
|
26
|
+
import { IComponent, components, Viewer } from "@inweb/viewer-three";
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
import type { Viewer } from "../Viewer";
|
|
29
|
-
|
|
30
|
-
export class RoomEnvironmentComponent implements IComponent {
|
|
28
|
+
class RoomEnvironmentComponent implements IComponent {
|
|
31
29
|
protected viewer: Viewer;
|
|
32
30
|
|
|
33
31
|
constructor(viewer: Viewer) {
|
|
@@ -45,3 +43,5 @@ export class RoomEnvironmentComponent implements IComponent {
|
|
|
45
43
|
this.viewer.scene.environment = undefined;
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
|
|
47
|
+
components.registerComponent("LightComponent", (viewer) => new RoomEnvironmentComponent(viewer));
|
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
// https://github.com/buildingSMART/IFC5-development
|
|
25
|
-
//
|
|
26
|
-
// Commit SHA-1:
|
|
24
|
+
// Repository: https://github.com/buildingSMART/IFC5-development
|
|
25
|
+
// Original File: docs/viewer/render.mjs
|
|
26
|
+
// Commit SHA-1: 83a7ae862232c90065d1bd03fcd538315e7d2563
|
|
27
|
+
// Commit Date: 20.05.2025 21:00:52
|
|
27
28
|
|
|
28
29
|
// (C) buildingSMART International
|
|
29
30
|
// published under MIT license
|
|
30
31
|
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
31
33
|
/* eslint-disable prefer-const */
|
|
32
34
|
/* eslint-disable no-useless-catch */
|
|
33
35
|
|
|
@@ -175,7 +177,7 @@ function FindRootsOrCycles(nodes) {
|
|
|
175
177
|
}
|
|
176
178
|
visit(path);
|
|
177
179
|
});
|
|
178
|
-
} catch {
|
|
180
|
+
} catch (e) {
|
|
179
181
|
return null;
|
|
180
182
|
}
|
|
181
183
|
return roots;
|
|
@@ -262,7 +264,7 @@ function ToInputNodes(data) {
|
|
|
262
264
|
let inputNodes = /* @__PURE__ */ new Map();
|
|
263
265
|
data.forEach((ifcxNode) => {
|
|
264
266
|
let node = {
|
|
265
|
-
path: ifcxNode.
|
|
267
|
+
path: ifcxNode.path,
|
|
266
268
|
children: ifcxNode.children ? ifcxNode.children : {},
|
|
267
269
|
inherits: ifcxNode.inherits ? ifcxNode.inherits : {},
|
|
268
270
|
attributes: ifcxNode.attributes ? ifcxNode.attributes : {},
|
|
@@ -431,7 +433,7 @@ function Prune(file, deleteEmpty = false) {
|
|
|
431
433
|
let collapsed = Collapse(nodes, deleteEmpty);
|
|
432
434
|
if (collapsed)
|
|
433
435
|
result.data.push({
|
|
434
|
-
|
|
436
|
+
path: collapsed.path,
|
|
435
437
|
children: collapsed.children,
|
|
436
438
|
inherits: collapsed.inherits,
|
|
437
439
|
attributes: collapsed.attributes,
|
|
@@ -496,8 +498,8 @@ function init() {
|
|
|
496
498
|
camera.lookAt(0, 0, 0);
|
|
497
499
|
// const nd = document.querySelector(".viewport");
|
|
498
500
|
// renderer = new THREE.WebGLRenderer({
|
|
499
|
-
//
|
|
500
|
-
//
|
|
501
|
+
// alpha: true,
|
|
502
|
+
// logarithmicDepthBuffer: true,
|
|
501
503
|
// });
|
|
502
504
|
// renderer.setSize(nd.offsetWidth, nd.offsetHeight);
|
|
503
505
|
// controls = new THREE.OrbitControls(camera, renderer.domElement);
|
|
@@ -529,13 +531,12 @@ function createMaterialFromParent(parent, root) {
|
|
|
529
531
|
};
|
|
530
532
|
if (reference) {
|
|
531
533
|
const materialNode = getChildByName(root, reference.ref);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
let color = shader?.attributes["usd::materials::inputs::diffuseColor"];
|
|
534
|
+
if (materialNode) {
|
|
535
|
+
let color = materialNode?.attributes["bsi::presentation::diffuseColor"];
|
|
535
536
|
material.color = new THREE.Color(...color);
|
|
536
|
-
if (
|
|
537
|
+
if (materialNode?.attributes["bsi::presentation::opacity"]) {
|
|
537
538
|
material.transparent = true;
|
|
538
|
-
material.opacity =
|
|
539
|
+
material.opacity = materialNode.attributes["bsi::presentation::opacity"];
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
542
|
}
|
|
@@ -596,17 +597,23 @@ function traverseTree(node, parent, root, parentNode = void 0) {
|
|
|
596
597
|
// var icons = {
|
|
597
598
|
// "usd::usdgeom::mesh::points": "deployed_code",
|
|
598
599
|
// "usd::usdgeom::basiscurves::points": "line_curve",
|
|
599
|
-
// "usd::usdshade::material::outputs::surface.connect": "line_style"
|
|
600
|
+
// "usd::usdshade::material::outputs::surface.connect": "line_style",
|
|
600
601
|
// };
|
|
601
602
|
// function buildDomTree(prim, node) {
|
|
602
603
|
// const elem = document.createElement("div");
|
|
603
604
|
// let span;
|
|
604
605
|
// elem.appendChild(document.createTextNode(prim.name ? prim.name.split("/").reverse()[0] : "root"));
|
|
605
|
-
// elem.appendChild(span = document.createElement("span"));
|
|
606
|
-
// Object.entries(icons).forEach(([k, v]) => span.innerText += (prim.attributes || {})[k] ? v : " ");
|
|
606
|
+
// elem.appendChild((span = document.createElement("span")));
|
|
607
|
+
// Object.entries(icons).forEach(([k, v]) => (span.innerText += (prim.attributes || {})[k] ? v : " "));
|
|
607
608
|
// span.className = "material-symbols-outlined";
|
|
608
609
|
// elem.onclick = (evt) => {
|
|
609
|
-
// let rows = [["name", prim.name]]
|
|
610
|
+
// let rows = [["name", prim.name]]
|
|
611
|
+
// .concat(Object.entries(prim.attributes))
|
|
612
|
+
// .map(
|
|
613
|
+
// ([k, v]) =>
|
|
614
|
+
// `<tr><td>${encodeHtmlEntities(k)}</td><td>${encodeHtmlEntities(typeof v === "object" ? JSON.stringify(v) : v)}</td>`
|
|
615
|
+
// )
|
|
616
|
+
// .join("");
|
|
610
617
|
// document.querySelector(".attributes .table").innerHTML = `<table border="0">${rows}</table>`;
|
|
611
618
|
// evt.stopPropagation();
|
|
612
619
|
// };
|
|
@@ -685,10 +692,8 @@ function composeAndRender() {
|
|
|
685
692
|
// controls.update();
|
|
686
693
|
// renderer.render(scene, camera);
|
|
687
694
|
// }
|
|
688
|
-
// export {
|
|
689
|
-
|
|
690
|
-
// addModel as default
|
|
691
|
-
// };
|
|
695
|
+
// export { composeAndRender, addModel as default };
|
|
696
|
+
|
|
692
697
|
export function parse(m, name) {
|
|
693
698
|
datas.push([name, m]);
|
|
694
699
|
composeAndRender();
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { AmbientLight, DirectionalLight, Sphere, Vector3 } from "three";
|
|
24
|
+
import { AmbientLight, DirectionalLight, HemisphereLight, Sphere, Vector3 } from "three";
|
|
25
25
|
|
|
26
26
|
import { IComponent } from "@inweb/viewer-core";
|
|
27
27
|
import type { Viewer } from "../Viewer";
|
|
@@ -30,17 +30,27 @@ export class LightComponent implements IComponent {
|
|
|
30
30
|
protected viewer: Viewer;
|
|
31
31
|
protected ambientLight: AmbientLight;
|
|
32
32
|
protected directionalLight: DirectionalLight;
|
|
33
|
+
protected frontLight: DirectionalLight;
|
|
34
|
+
protected hemisphereLight: HemisphereLight;
|
|
33
35
|
|
|
34
36
|
constructor(viewer: Viewer) {
|
|
35
37
|
this.viewer = viewer;
|
|
36
38
|
|
|
37
|
-
this.ambientLight = new AmbientLight(0xffffff,
|
|
39
|
+
this.ambientLight = new AmbientLight(0xffffff, 1);
|
|
38
40
|
this.viewer.scene.add(this.ambientLight);
|
|
39
41
|
|
|
40
42
|
this.directionalLight = new DirectionalLight(0xffffff, 1);
|
|
41
43
|
this.directionalLight.position.set(0.5, 0, 0.866); // ~60º
|
|
42
44
|
this.viewer.scene.add(this.directionalLight);
|
|
43
45
|
|
|
46
|
+
this.frontLight = new DirectionalLight(0xffffff, 1.25);
|
|
47
|
+
this.frontLight.position.set(0, 1, 0);
|
|
48
|
+
this.viewer.scene.add(this.frontLight);
|
|
49
|
+
|
|
50
|
+
this.hemisphereLight = new HemisphereLight(0xffffff, 0x444444, 1.25);
|
|
51
|
+
this.hemisphereLight.position.set(0, 0, 1);
|
|
52
|
+
this.viewer.scene.add(this.hemisphereLight);
|
|
53
|
+
|
|
44
54
|
this.viewer.addEventListener("databasechunk", this.geometryEnd);
|
|
45
55
|
this.viewer.addEventListener("clear", this.geometryEnd);
|
|
46
56
|
}
|
|
@@ -52,6 +62,12 @@ export class LightComponent implements IComponent {
|
|
|
52
62
|
this.directionalLight.removeFromParent();
|
|
53
63
|
this.directionalLight.dispose();
|
|
54
64
|
|
|
65
|
+
this.frontLight.removeFromParent();
|
|
66
|
+
this.frontLight.dispose();
|
|
67
|
+
|
|
68
|
+
this.hemisphereLight.removeFromParent();
|
|
69
|
+
this.hemisphereLight.dispose();
|
|
70
|
+
|
|
55
71
|
this.viewer.removeEventListener("databasechunk", this.geometryEnd);
|
|
56
72
|
this.viewer.removeEventListener("clear", this.geometryEnd);
|
|
57
73
|
}
|
|
@@ -59,15 +75,28 @@ export class LightComponent implements IComponent {
|
|
|
59
75
|
geometryEnd = () => {
|
|
60
76
|
this.ambientLight.removeFromParent();
|
|
61
77
|
this.directionalLight.removeFromParent();
|
|
78
|
+
this.frontLight.removeFromParent();
|
|
79
|
+
this.hemisphereLight.removeFromParent();
|
|
62
80
|
|
|
63
81
|
if (this.viewer.extents.isEmpty()) return;
|
|
64
82
|
|
|
65
83
|
const extentsCenter = this.viewer.extents.getCenter(new Vector3());
|
|
66
|
-
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius
|
|
67
|
-
|
|
84
|
+
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius;
|
|
85
|
+
|
|
86
|
+
this.directionalLight.position
|
|
87
|
+
.set(0.5, 0, 0.866)
|
|
88
|
+
.multiplyScalar(extentsSize * 2)
|
|
89
|
+
.add(extentsCenter);
|
|
68
90
|
this.directionalLight.target.position.copy(extentsCenter);
|
|
69
91
|
|
|
92
|
+
this.frontLight.position.set(0, extentsSize * 2, 0).add(extentsCenter);
|
|
93
|
+
this.frontLight.target.position.copy(extentsCenter);
|
|
94
|
+
|
|
95
|
+
this.hemisphereLight.position.set(0, extentsSize * 3, 0).add(extentsCenter);
|
|
96
|
+
|
|
70
97
|
this.viewer.scene.add(this.ambientLight);
|
|
71
98
|
this.viewer.scene.add(this.directionalLight);
|
|
99
|
+
this.viewer.scene.add(this.frontLight);
|
|
100
|
+
this.viewer.scene.add(this.hemisphereLight);
|
|
72
101
|
};
|
|
73
102
|
}
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
import { IComponentsRegistry, componentsRegistry } from "@inweb/viewer-core";
|
|
25
25
|
|
|
26
26
|
import { BackgroundComponent } from "./BackgroundComponent";
|
|
27
|
-
import { RoomEnvironmentComponent } from "./RoomEnvironmentComponent";
|
|
28
27
|
import { CameraComponent } from "./CameraComponent";
|
|
29
28
|
import { ExtentsComponent } from "./ExtentsComponent";
|
|
30
29
|
import { LightComponent } from "./LightComponent";
|
|
@@ -78,7 +77,6 @@ export const components: IComponentsRegistry = componentsRegistry("threejs");
|
|
|
78
77
|
components.registerComponent("ExtentsComponent", (viewer) => new ExtentsComponent(viewer));
|
|
79
78
|
components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
|
|
80
79
|
components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
|
|
81
|
-
components.registerComponent("RoomEnvironmentComponent", (viewer) => new RoomEnvironmentComponent(viewer));
|
|
82
80
|
components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
|
|
83
81
|
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
84
82
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|