rayzee 9.4.0 → 9.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "9.4.0",
3
+ "version": "9.4.1",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -312,40 +312,7 @@ export class CameraManager extends EventDispatcher {
312
312
 
313
313
  } else {
314
314
 
315
- const sourceCamera = this.cameras[ index ];
316
-
317
- this.camera.position.copy( sourceCamera.position );
318
- this.camera.quaternion.copy( sourceCamera.quaternion );
319
- // An imported camera can carry a mirror (a negative axis scale) that no
320
- // quaternion can express — a pbrt scene's `Scale -1 1 1`, for one. Copying
321
- // pose alone would silently un-mirror the view.
322
- this.camera.scale.copy( sourceCamera.scale );
323
- if ( sourceCamera.isPerspectiveCamera ) this.camera.fov = sourceCamera.fov;
324
- this.camera.near = sourceCamera.near;
325
- this.camera.far = sourceCamera.far;
326
- this.camera.updateProjectionMatrix();
327
- this.camera.updateMatrixWorld( true );
328
-
329
- // Restore the saved orbit target for user cameras; otherwise place it
330
- // along the forward direction at the focus distance.
331
- if ( this.controls ) {
332
-
333
- const savedTarget = sourceCamera.userData?.__rayzeeOrbitTarget;
334
- if ( savedTarget ) {
335
-
336
- this.controls.target.copy( savedTarget );
337
-
338
- } else {
339
-
340
- const forward = new Vector3( 0, 0, - 1 ).applyQuaternion( sourceCamera.quaternion );
341
- const focusDist = focusDistance || 5.0;
342
- this.controls.target.copy( this.camera.position ).addScaledVector( forward, focusDist );
343
-
344
- }
345
-
346
- this.controls.update();
347
-
348
- }
315
+ this._placeAt( this.cameras[ index ], focusDistance );
349
316
 
350
317
  }
351
318
 
@@ -370,6 +337,60 @@ export class CameraManager extends EventDispatcher {
370
337
 
371
338
  }
372
339
 
340
+ /**
341
+ * Puts the active camera back at the view it starts from: the default camera at the framing the
342
+ * model loaded with, any other at its own pose and lens. Its effects and projection stay.
343
+ */
344
+ resetView() {
345
+
346
+ const source = this.currentCameraIndex > 0 ? this.cameras[ this.currentCameraIndex ] : null;
347
+ if ( ! source ) {
348
+
349
+ this.controls.reset();
350
+ return;
351
+
352
+ }
353
+
354
+ this._placeAt( source, this._getSettings?.( 'focusDistance' ) );
355
+ const height = orthoHeightOf( source );
356
+ if ( this.camera.orthographic ) this._setView( true, height ? height / 2 : this.camera.orthoHalfHeight );
357
+ this._onReset?.();
358
+
359
+ }
360
+
361
+ // The view takes a camera's pose and lens, orbiting its saved target or a point ahead at the focus distance.
362
+ _placeAt( source, focusDistance ) {
363
+
364
+ this.camera.position.copy( source.position );
365
+ this.camera.quaternion.copy( source.quaternion );
366
+ // An imported camera can carry a mirror (a negative axis scale) that no
367
+ // quaternion can express — a pbrt scene's `Scale -1 1 1`, for one. Copying
368
+ // pose alone would silently un-mirror the view.
369
+ this.camera.scale.copy( source.scale );
370
+ if ( source.isPerspectiveCamera ) this.camera.fov = source.fov;
371
+ this.camera.near = source.near;
372
+ this.camera.far = source.far;
373
+ this.camera.updateProjectionMatrix();
374
+ this.camera.updateMatrixWorld( true );
375
+
376
+ if ( ! this.controls ) return;
377
+
378
+ const savedTarget = source.userData?.__rayzeeOrbitTarget;
379
+ if ( savedTarget ) {
380
+
381
+ this.controls.target.copy( savedTarget );
382
+
383
+ } else {
384
+
385
+ const forward = new Vector3( 0, 0, - 1 ).applyQuaternion( source.quaternion );
386
+ this.controls.target.copy( this.camera.position ).addScaledVector( forward, focusDistance || 5.0 );
387
+
388
+ }
389
+
390
+ this.controls.update();
391
+
392
+ }
393
+
373
394
  /**
374
395
  * Makes the camera orthographic at `height`, or perspective for null, then hands the `cameraProjection`
375
396
  * setting the outcome — after, so its handler finds the camera already there. A 360° panorama stays on