@inweb/viewer-three 26.4.1 → 26.4.2
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 +55 -28
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +17 -6
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/commands/index.d.ts +1 -1
- package/lib/Viewer/components/RoomEnvironmentComponent.d.ts +7 -0
- package/package.json +5 -5
- package/src/Viewer/commands/index.ts +1 -1
- package/src/Viewer/components/BackgroundComponent.ts +1 -9
- package/src/Viewer/components/CameraComponent.ts +5 -1
- package/src/Viewer/components/ExtentsComponent.ts +1 -2
- package/src/Viewer/components/LightComponent.ts +6 -4
- package/src/Viewer/components/RoomEnvironmentComponent.ts +47 -0
- package/src/Viewer/components/index.ts +2 -0
package/dist/viewer-three.js
CHANGED
|
@@ -68,25 +68,22 @@
|
|
|
68
68
|
|
|
69
69
|
class DraggersRegistry {
|
|
70
70
|
constructor() {
|
|
71
|
-
this.
|
|
71
|
+
this._providers = new Map;
|
|
72
72
|
}
|
|
73
73
|
registerDragger(name, provider) {
|
|
74
|
-
this.
|
|
74
|
+
this._providers.set(name, provider);
|
|
75
75
|
}
|
|
76
76
|
registerDraggerAlias(name, alias) {
|
|
77
|
-
const provider = this.
|
|
77
|
+
const provider = this._providers.get(name);
|
|
78
78
|
if (provider) this.registerDragger(alias, (viewer => provider(viewer)));
|
|
79
79
|
}
|
|
80
|
-
getDragger(name) {
|
|
81
|
-
return this._draggers.get(name);
|
|
82
|
-
}
|
|
83
80
|
getDraggers() {
|
|
84
81
|
const map = new Map;
|
|
85
|
-
this.
|
|
82
|
+
this._providers.forEach(((value, key) => map.set(key, value)));
|
|
86
83
|
return map;
|
|
87
84
|
}
|
|
88
85
|
createDragger(name, viewer) {
|
|
89
|
-
const provider = this.
|
|
86
|
+
const provider = this._providers.get(name);
|
|
90
87
|
if (!provider) return null;
|
|
91
88
|
const dragger = provider(viewer);
|
|
92
89
|
dragger.name = name;
|
|
@@ -114,25 +111,22 @@
|
|
|
114
111
|
|
|
115
112
|
class Components {
|
|
116
113
|
constructor() {
|
|
117
|
-
this.
|
|
114
|
+
this._providers = new Map;
|
|
118
115
|
}
|
|
119
116
|
registerComponent(name, provider) {
|
|
120
|
-
this.
|
|
117
|
+
this._providers.set(name, provider);
|
|
121
118
|
}
|
|
122
119
|
registerComponentAlias(name, alias) {
|
|
123
|
-
const provider = this.
|
|
120
|
+
const provider = this._providers.get(name);
|
|
124
121
|
if (provider) this.registerComponent(alias, (viewer => provider(viewer)));
|
|
125
122
|
}
|
|
126
|
-
getComponent(name) {
|
|
127
|
-
return this._components.get(name);
|
|
128
|
-
}
|
|
129
123
|
getComponents() {
|
|
130
124
|
const map = new Map;
|
|
131
|
-
this.
|
|
125
|
+
this._providers.forEach(((value, key) => map.set(key, value)));
|
|
132
126
|
return map;
|
|
133
127
|
}
|
|
134
128
|
createComponent(name, viewer) {
|
|
135
|
-
const provider = this.
|
|
129
|
+
const provider = this._providers.get(name);
|
|
136
130
|
if (!provider) return null;
|
|
137
131
|
const component = provider(viewer);
|
|
138
132
|
component.name = name;
|
|
@@ -58048,7 +58042,7 @@ void main() {
|
|
|
58048
58042
|
// acknowledge and accept the above terms.
|
|
58049
58043
|
///////////////////////////////////////////////////////////////////////////////
|
|
58050
58044
|
/**
|
|
58051
|
-
*
|
|
58045
|
+
* Viewer commands registry. Use this registry to register custom commands.
|
|
58052
58046
|
*
|
|
58053
58047
|
* To implement custom command:
|
|
58054
58048
|
*
|
|
@@ -58122,6 +58116,45 @@ void main() {
|
|
|
58122
58116
|
commands.registerCommandAlias("ne", "k3DViewNE");
|
|
58123
58117
|
commands.registerCommandAlias("nw", "k3DViewNW");
|
|
58124
58118
|
|
|
58119
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
58120
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
58121
|
+
// All rights reserved.
|
|
58122
|
+
//
|
|
58123
|
+
// This software and its documentation and related materials are owned by
|
|
58124
|
+
// the Alliance. The software may only be incorporated into application
|
|
58125
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
58126
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
58127
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
58128
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
58129
|
+
// protected by copyright law and international treaty provisions. Application
|
|
58130
|
+
// programs incorporating this software must include the following statement
|
|
58131
|
+
// with their copyright notices:
|
|
58132
|
+
//
|
|
58133
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
58134
|
+
// license agreement with Open Design Alliance.
|
|
58135
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
58136
|
+
// All rights reserved.
|
|
58137
|
+
//
|
|
58138
|
+
// By use of this software, its documentation or related materials, you
|
|
58139
|
+
// acknowledge and accept the above terms.
|
|
58140
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
58141
|
+
class BackgroundComponent {
|
|
58142
|
+
constructor(viewer) {
|
|
58143
|
+
this.syncOptions = () => {
|
|
58144
|
+
this.backgroundColor.setHex(0xffffff);
|
|
58145
|
+
};
|
|
58146
|
+
this.viewer = viewer;
|
|
58147
|
+
this.backgroundColor = new Color(0xffffff);
|
|
58148
|
+
this.viewer.renderer.setClearColor(this.backgroundColor);
|
|
58149
|
+
this.viewer.scene.background = this.backgroundColor;
|
|
58150
|
+
this.viewer.addEventListener("optionschange", this.syncOptions);
|
|
58151
|
+
}
|
|
58152
|
+
dispose() {
|
|
58153
|
+
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
58154
|
+
this.viewer.scene.background = undefined;
|
|
58155
|
+
}
|
|
58156
|
+
}
|
|
58157
|
+
|
|
58125
58158
|
/**
|
|
58126
58159
|
* https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts
|
|
58127
58160
|
*/
|
|
@@ -58278,25 +58311,16 @@ void main() {
|
|
|
58278
58311
|
// By use of this software, its documentation or related materials, you
|
|
58279
58312
|
// acknowledge and accept the above terms.
|
|
58280
58313
|
///////////////////////////////////////////////////////////////////////////////
|
|
58281
|
-
class
|
|
58314
|
+
class RoomEnvironmentComponent {
|
|
58282
58315
|
constructor(viewer) {
|
|
58283
|
-
this.syncOptions = () => {
|
|
58284
|
-
this.backgroundColor.setHex(0xffffff);
|
|
58285
|
-
};
|
|
58286
58316
|
this.viewer = viewer;
|
|
58287
|
-
this.backgroundColor = new Color(0xffffff);
|
|
58288
58317
|
const environment = new RoomEnvironment();
|
|
58289
58318
|
const pmremGenerator = new PMREMGenerator(this.viewer.renderer);
|
|
58290
|
-
this.viewer.renderer.setClearColor(this.backgroundColor);
|
|
58291
|
-
this.viewer.scene.background = this.backgroundColor;
|
|
58292
58319
|
this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;
|
|
58293
|
-
this.viewer.addEventListener("optionschange", this.syncOptions);
|
|
58294
58320
|
environment.dispose();
|
|
58295
58321
|
}
|
|
58296
58322
|
dispose() {
|
|
58297
|
-
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
58298
58323
|
this.viewer.scene.environment = undefined;
|
|
58299
|
-
this.viewer.scene.background = undefined;
|
|
58300
58324
|
}
|
|
58301
58325
|
}
|
|
58302
58326
|
|
|
@@ -58325,9 +58349,11 @@ void main() {
|
|
|
58325
58349
|
class CameraComponent {
|
|
58326
58350
|
constructor(viewer) {
|
|
58327
58351
|
this.geometryEnd = () => {
|
|
58352
|
+
const extentsCenter = this.viewer.extents.getCenter(new Vector3());
|
|
58328
58353
|
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
|
|
58329
58354
|
const rendererSize = this.viewer.renderer.getSize(new Vector2());
|
|
58330
58355
|
const aspect = rendererSize.x / rendererSize.y;
|
|
58356
|
+
// TODO: do not change the camera and target after opening the second model in "append" mode
|
|
58331
58357
|
let sceneCamera;
|
|
58332
58358
|
this.viewer.scene.traverse((object) => {
|
|
58333
58359
|
if (object.isCamera)
|
|
@@ -58355,6 +58381,7 @@ void main() {
|
|
|
58355
58381
|
camera.far = extentsSize * 100;
|
|
58356
58382
|
camera.updateProjectionMatrix();
|
|
58357
58383
|
}
|
|
58384
|
+
this.viewer.target.copy(extentsCenter);
|
|
58358
58385
|
if (!sceneCamera) {
|
|
58359
58386
|
this.viewer.executeCommand("setDefaultViewPosition");
|
|
58360
58387
|
}
|
|
@@ -58395,7 +58422,6 @@ void main() {
|
|
|
58395
58422
|
const extents = new Box3();
|
|
58396
58423
|
this.viewer.scene.traverseVisible((object) => !object.children.length && extents.expandByObject(object));
|
|
58397
58424
|
this.viewer.extents.copy(extents);
|
|
58398
|
-
this.viewer.target.copy(extents.getCenter(new Vector3()));
|
|
58399
58425
|
};
|
|
58400
58426
|
this.viewer = viewer;
|
|
58401
58427
|
this.viewer.addEventListener("databasechunk", this.syncExtents);
|
|
@@ -58700,6 +58726,7 @@ void main() {
|
|
|
58700
58726
|
components.registerComponent("ExtentsComponent", (viewer) => new ExtentsComponent(viewer));
|
|
58701
58727
|
components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
|
|
58702
58728
|
components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
|
|
58729
|
+
components.registerComponent("RoomEnvironmentComponent", (viewer) => new RoomEnvironmentComponent(viewer));
|
|
58703
58730
|
// components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
|
|
58704
58731
|
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
58705
58732
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|