@preference-sl/pref-viewer 2.9.0-beta.0 → 2.9.0-beta.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/package.json +1 -1
- package/src/index.js +10 -32
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -39,8 +39,7 @@ import {
|
|
|
39
39
|
HemisphericLight,
|
|
40
40
|
DirectionalLight,
|
|
41
41
|
PointLight,
|
|
42
|
-
ShadowGenerator
|
|
43
|
-
PointerEventTypes
|
|
42
|
+
ShadowGenerator
|
|
44
43
|
} from "@babylonjs/core";
|
|
45
44
|
import "@babylonjs/loaders";
|
|
46
45
|
|
|
@@ -159,8 +158,6 @@ class PrefViewer extends HTMLElement {
|
|
|
159
158
|
this.scene
|
|
160
159
|
);
|
|
161
160
|
this.camera.attachControl(this.canvas, true);
|
|
162
|
-
// remove default wheel behavior
|
|
163
|
-
this.camera.inputs.removeByType("ArcRotateCameraMouseWheelInput");
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
_createLights() {
|
|
@@ -170,22 +167,22 @@ class PrefViewer extends HTMLElement {
|
|
|
170
167
|
new Vector3(0, 1, 0),
|
|
171
168
|
this.scene
|
|
172
169
|
);
|
|
173
|
-
this.hemiLight.intensity = 0.
|
|
170
|
+
this.hemiLight.intensity = 0.5;
|
|
174
171
|
|
|
175
172
|
// 2) Soft directional “sun” for form
|
|
176
173
|
this.dirLight = new DirectionalLight(
|
|
177
174
|
"dirLight",
|
|
178
|
-
new Vector3(-
|
|
175
|
+
new Vector3(-1, -0.3, -0.5), // more horizontal light
|
|
179
176
|
this.scene
|
|
180
177
|
);
|
|
181
|
-
this.dirLight.position = new Vector3(
|
|
182
|
-
this.dirLight.intensity = 0.
|
|
178
|
+
this.dirLight.position = new Vector3(5, 3, 5); // coming from above + front/right
|
|
179
|
+
this.dirLight.intensity = 0.4;
|
|
183
180
|
|
|
184
181
|
// 3) Soft blurred shadows
|
|
185
182
|
this.shadowGen = new ShadowGenerator(1024, this.dirLight);
|
|
186
183
|
this.shadowGen.useBlurExponentialShadowMap = true;
|
|
187
184
|
this.shadowGen.blurKernel = 16;
|
|
188
|
-
this.shadowGen.darkness = 0.
|
|
185
|
+
this.shadowGen.darkness = 0.5;
|
|
189
186
|
|
|
190
187
|
// 4) Camera‐attached headlight
|
|
191
188
|
this.cameraLight = new PointLight(
|
|
@@ -198,30 +195,11 @@ class PrefViewer extends HTMLElement {
|
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
_setupInteraction() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (pointerInfo.type !== PointerEventTypes.POINTERWHEEL) return;
|
|
204
|
-
const evt = pointerInfo.event;
|
|
198
|
+
this.canvas.addEventListener("wheel", (evt) => {
|
|
199
|
+
if (!this.scene || !this.camera) return;
|
|
205
200
|
const pick = this.scene.pick(this.scene.pointerX, this.scene.pointerY);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// compute new radius
|
|
210
|
-
const delta = evt.deltaY * this.camera.wheelDeltaPercentage;
|
|
211
|
-
let newRadius = this.camera.radius + delta;
|
|
212
|
-
if (this.camera.lowerRadiusLimit) newRadius = Math.max(newRadius, this.camera.lowerRadiusLimit);
|
|
213
|
-
if (this.camera.upperRadiusLimit) newRadius = Math.min(newRadius, this.camera.upperRadiusLimit);
|
|
214
|
-
|
|
215
|
-
// compute direction from target to camera
|
|
216
|
-
const fromTarget = this.camera.position.subtract(this.camera.target);
|
|
217
|
-
const ratio = newRadius / this.camera.radius;
|
|
218
|
-
const newFromTarget = fromTarget.scale(ratio);
|
|
219
|
-
|
|
220
|
-
// update camera
|
|
221
|
-
this.camera.target = zoomPoint;
|
|
222
|
-
this.camera.radius = newRadius;
|
|
223
|
-
this.camera.position = zoomPoint.add(newFromTarget);
|
|
224
|
-
|
|
201
|
+
this.camera.target = pick.hit ? pick.pickedPoint.clone() : this.camera.target;
|
|
202
|
+
this.camera.inertialRadiusOffset += evt.deltaY * this.camera.wheelPrecision * 0.01;
|
|
225
203
|
evt.preventDefault();
|
|
226
204
|
});
|
|
227
205
|
}
|