iobroker.mywebui 1.42.32 → 1.42.33
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/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -79,15 +79,9 @@ export class IobrokerWebui3DScreenViewer extends BaseCustomWebComponentConstruct
|
|
|
79
79
|
} else {
|
|
80
80
|
// Old format backward compatibility
|
|
81
81
|
scene = new THREE.Scene();
|
|
82
|
-
scene.background = new THREE.Color(0x333333);
|
|
83
82
|
camera = new THREE.PerspectiveCamera(75, w / h, 0.1, 1000);
|
|
84
83
|
camera.position.set(10, 10, 10);
|
|
85
84
|
|
|
86
|
-
scene.add(new THREE.AmbientLight(0xffffff, 0.6));
|
|
87
|
-
const dir = new THREE.DirectionalLight(0xffffff, 0.8);
|
|
88
|
-
dir.position.set(10, 10, 10);
|
|
89
|
-
scene.add(dir);
|
|
90
|
-
|
|
91
85
|
if (sceneData.assets) {
|
|
92
86
|
const { GLTFLoader } = await import('three/addons/loaders/GLTFLoader.js');
|
|
93
87
|
const loader = new GLTFLoader();
|
|
@@ -104,12 +98,47 @@ export class IobrokerWebui3DScreenViewer extends BaseCustomWebComponentConstruct
|
|
|
104
98
|
}
|
|
105
99
|
}
|
|
106
100
|
|
|
101
|
+
// Ensure scene has a visible background
|
|
102
|
+
if (!scene.background) scene.background = new THREE.Color(0x222222);
|
|
103
|
+
|
|
104
|
+
// Ensure scene has at least one light source
|
|
105
|
+
const existingLights = [];
|
|
106
|
+
scene.traverse(o => { if (o.isLight) existingLights.push(o); });
|
|
107
|
+
if (existingLights.length === 0) {
|
|
108
|
+
scene.add(new THREE.AmbientLight(0xffffff, 0.6));
|
|
109
|
+
const dl = new THREE.DirectionalLight(0xffffff, 1.0);
|
|
110
|
+
dl.position.set(5, 10, 7.5);
|
|
111
|
+
scene.add(dl);
|
|
112
|
+
}
|
|
113
|
+
|
|
107
114
|
camera.aspect = w / h;
|
|
108
115
|
camera.updateProjectionMatrix();
|
|
109
116
|
|
|
110
117
|
const controls = new OrbitControls(camera, renderer.domElement);
|
|
111
118
|
controls.enableDamping = true;
|
|
112
119
|
|
|
120
|
+
// Auto-fit camera to scene content after scene/controls are ready
|
|
121
|
+
{
|
|
122
|
+
const box = new THREE.Box3();
|
|
123
|
+
scene.traverse(o => {
|
|
124
|
+
if (o.isMesh || o.isPoints || o.isLine) box.expandByObject(o);
|
|
125
|
+
});
|
|
126
|
+
if (!box.isEmpty()) {
|
|
127
|
+
const center = new THREE.Vector3();
|
|
128
|
+
const size = new THREE.Vector3();
|
|
129
|
+
box.getCenter(center);
|
|
130
|
+
box.getSize(size);
|
|
131
|
+
const maxDim = Math.max(size.x, size.y, size.z);
|
|
132
|
+
const dist = maxDim / (2 * Math.tan((camera.fov * Math.PI / 180) / 2)) * 1.5;
|
|
133
|
+
camera.position.set(center.x + dist * 0.6, center.y + dist * 0.4, center.z + dist);
|
|
134
|
+
camera.near = dist / 100;
|
|
135
|
+
camera.far = dist * 100;
|
|
136
|
+
camera.updateProjectionMatrix();
|
|
137
|
+
controls.target.copy(center);
|
|
138
|
+
controls.update();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
// Script context helpers
|
|
114
143
|
const frameCallbacks = [];
|
|
115
144
|
const selectCallbacks = [];
|