@preference-sl/pref-viewer 2.9.0-beta.0 → 2.9.0-beta.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +6 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preference-sl/pref-viewer",
3
- "version": "2.9.0-beta.0",
3
+ "version": "2.9.0-beta.1",
4
4
  "description": "Web Component to preview GLTF models with Babylon.js",
5
5
  "author": "Alex Moreno Palacio <amoreno@preference.es>",
6
6
  "scripts": {
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() {
@@ -185,7 +182,7 @@ class PrefViewer extends HTMLElement {
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.2;
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
- // custom wheel zoom: zoom toward the point under mouse
202
- this.scene.onPointerObservable.add((pointerInfo) => {
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
- if (!pick.hit) return;
207
- const zoomPoint = pick.pickedPoint;
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
  }