@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +10 -32
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.2",
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() {
@@ -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.8;
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(-0.5, -1, -0.5),
175
+ new Vector3(-1, -0.3, -0.5), // more horizontal light
179
176
  this.scene
180
177
  );
181
- this.dirLight.position = new Vector3(0, 5, 0);
182
- this.dirLight.intensity = 0.3;
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.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
  }