@preference-sl/pref-viewer 2.6.0 → 2.7.0
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/package.json +1 -1
- package/src/index.js +20 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -37,7 +37,9 @@ import {
|
|
|
37
37
|
SceneLoader,
|
|
38
38
|
Color4,
|
|
39
39
|
HemisphericLight,
|
|
40
|
-
DirectionalLight
|
|
40
|
+
DirectionalLight,
|
|
41
|
+
PointLight,
|
|
42
|
+
ShadowGenerator
|
|
41
43
|
} from "@babylonjs/core";
|
|
42
44
|
import "@babylonjs/loaders";
|
|
43
45
|
|
|
@@ -156,11 +158,25 @@ class PrefViewer extends HTMLElement {
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
_createLights() {
|
|
161
|
+
// Ambient hemisphere for general fill
|
|
159
162
|
this.hemiLight = new HemisphericLight("hemiLight", new Vector3(0, 1, 0), this.scene);
|
|
160
|
-
this.hemiLight.intensity = 0.
|
|
163
|
+
this.hemiLight.intensity = 0.8; // stronger ambient
|
|
164
|
+
|
|
165
|
+
// Main “sun” light, but softer
|
|
161
166
|
this.dirLight = new DirectionalLight("dirLight", new Vector3(-0.5, -1, -0.5), this.scene);
|
|
162
167
|
this.dirLight.position = new Vector3(0, 5, 0);
|
|
163
|
-
this.dirLight.intensity = 0.
|
|
168
|
+
this.dirLight.intensity = 0.3; // much lower than before
|
|
169
|
+
|
|
170
|
+
// Optional: very light, blurred shadows just for form (darkness: 0 → no shadows, 1 → full)
|
|
171
|
+
const shadowGen = new ShadowGenerator(1024, this.dirLight);
|
|
172
|
+
shadowGen.useBlurExponentialShadowMap = true; // soften edges
|
|
173
|
+
shadowGen.blurKernel = 16;
|
|
174
|
+
shadowGen.darkness = 0.2; // practically “skimmed milk” shadows
|
|
175
|
+
|
|
176
|
+
// Headlight: ensure the camera always shines on what you’re looking at
|
|
177
|
+
this.cameraLight = new PointLight("cameraLight", this.camera.position, this.scene);
|
|
178
|
+
this.cameraLight.parent = this.camera;
|
|
179
|
+
this.cameraLight.intensity = 0.5;
|
|
164
180
|
}
|
|
165
181
|
|
|
166
182
|
_setupInteraction() {
|
|
@@ -211,7 +227,7 @@ class PrefViewer extends HTMLElement {
|
|
|
211
227
|
const raw = payload || base64;
|
|
212
228
|
const decoded = atob(raw);
|
|
213
229
|
let isJson = false;
|
|
214
|
-
try { JSON.parse(decoded); isJson = true; } catch {}
|
|
230
|
+
try { JSON.parse(decoded); isJson = true; } catch { }
|
|
215
231
|
const extension = isJson ? ".gltf" : ".glb";
|
|
216
232
|
const type = isJson ? "model/gltf+json" : "model/gltf-binary";
|
|
217
233
|
const array = Uint8Array.from(decoded, (c) => c.charCodeAt(0));
|