rayzee 7.14.0 → 7.15.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/README.md CHANGED
@@ -1,19 +1,53 @@
1
1
  # Rayzee Engine
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/rayzee?label=npm)](https://www.npmjs.com/package/rayzee)
4
- [![minzipped size](https://img.shields.io/badge/minzipped-169.1%20KB-blue)](https://www.npmjs.com/package/rayzee)
4
+ [![minzipped size](https://img.shields.io/badge/minzipped-169.6%20KB-blue)](https://www.npmjs.com/package/rayzee)
5
5
  [![downloads](https://img.shields.io/npm/dw/rayzee?label=downloads)](https://www.npmjs.com/package/rayzee)
6
6
  [![jsDelivr](https://img.shields.io/jsdelivr/npm/hm/rayzee?label=jsDelivr)](https://www.jsdelivr.com/package/npm/rayzee)
7
7
 
8
8
  A real-time WebGPU path tracing engine built on Three.js. Framework-agnostic — use it with React, Vue, vanilla JS, or any other setup.
9
9
 
10
+ 🌐 **[Live Demo](https://atul-mourya.github.io/RayTracing/)** — the same demo app linked from the root monorepo README, built on this engine.
11
+
12
+ ## Table of Contents
13
+
14
+ - [Installation](#installation)
15
+ - [Getting Started](#getting-started)
16
+ - [Vanilla JS with Vite](#vanilla-js-with-vite)
17
+ - [Vanilla JS (no bundler)](#vanilla-js-no-bundler)
18
+ - [React](#react)
19
+ - [Integrating Alongside an Existing Three.js App](#integrating-alongside-an-existing-threejs-app)
20
+ - [Vite tip](#vite-tip)
21
+ - [API Reference](#api-reference)
22
+ - [Configuring Assets (CDN URLs & cache namespace)](#configuring-assets-cdn-urls--cache-namespace)
23
+ - [PathTracerApp](#pathtracerapp)
24
+ - [engine.cameraManager](#enginecameramanager)
25
+ - [engine.lightManager](#enginelightmanager)
26
+ - [engine.animationManager](#engineanimationmanager)
27
+ - [Materials](#materials)
28
+ - [engine.environmentManager](#engineenvironmentmanager)
29
+ - [engine.denoisingManager](#enginedenoisingmanager)
30
+ - [engine.interactionManager](#engineinteractionmanager)
31
+ - [engine.transformManager](#enginetransformmanager)
32
+ - [Output Methods](#output-methods)
33
+ - [Memory Monitoring](#memory-monitoring)
34
+ - [Events](#events)
35
+ - [Advanced: Custom Pipeline Stages](#advanced-custom-pipeline-stages)
36
+ - [All Exports](#all-exports)
37
+ - [Browser Requirements](#browser-requirements)
38
+ - [Optional Dependencies](#optional-dependencies)
39
+ - [Enabling OIDN (Intel Open Image Denoise)](#enabling-oidn-intel-open-image-denoise)
40
+ - [Enabling the AI Upscaler](#enabling-the-ai-upscaler)
41
+ - [Troubleshooting](#troubleshooting)
42
+ - [License](#license)
43
+
10
44
  ## Installation
11
45
 
12
46
  ```bash
13
47
  npm install rayzee three
14
48
  ```
15
49
 
16
- `three` (>=0.183.0) is a required peer dependency.
50
+ `three` (>=0.185.0) is a required peer dependency.
17
51
 
18
52
  ## Getting Started
19
53
 
@@ -65,7 +99,7 @@ npm install rayzee three
65
99
  });
66
100
 
67
101
  // Tweak settings
68
- engine.settings.set('bounces', 8);
102
+ engine.settings.set('maxBounces', 8);
69
103
  engine.settings.set('exposure', 1.2);
70
104
 
71
105
  // Use namespaced APIs and direct methods
@@ -95,10 +129,10 @@ A single HTML file — no Node.js, no build step. Uses [ES module import maps](h
95
129
  <script type="importmap">
96
130
  {
97
131
  "imports": {
98
- "three": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.webgpu.js",
99
- "three/tsl": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.tsl.js",
100
- "three/webgpu": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.webgpu.js",
101
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/",
132
+ "three": "https://cdn.jsdelivr.net/npm/three@0.185.0/build/three.webgpu.js",
133
+ "three/tsl": "https://cdn.jsdelivr.net/npm/three@0.185.0/build/three.tsl.js",
134
+ "three/webgpu": "https://cdn.jsdelivr.net/npm/three@0.185.0/build/three.webgpu.js",
135
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.185.0/examples/jsm/",
102
136
  "oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.5/dist/oidn.js",
103
137
  "rayzee": "https://cdn.jsdelivr.net/npm/rayzee/dist/rayzee.es.js"
104
138
  }
@@ -291,21 +325,33 @@ Constructing a new `PathTracerApp` on a canvas that already has an active instan
291
325
  #### Loading Assets
292
326
 
293
327
  ```js
294
- await engine.loadModel(url) // Load GLB/GLTF/FBX/OBJ/STL/PLY/DAE/3MF/USDZ/ZIP
295
- await engine.loadObject3D(object3d) // Load a Three.js Object3D directly
296
- await engine.loadEnvironment(url) // Load HDR/EXR environment map
328
+ await engine.loadModel(url) // Load GLB/GLTF/FBX/OBJ/STL/PLY/DAE/3MF/USDZ/ZIP
329
+ await engine.loadObject3D(object3d, name?) // Load a Three.js Object3D directly (name is optional, defaults to 'object3d')
330
+ await engine.loadEnvironment(url) // Load HDR/EXR environment map
331
+ engine.cancelLoad() // Abort an in-flight download (network phase only; no-op once processing starts)
332
+ ```
333
+
334
+ `loadModel` / `loadObject3D` **replace** the current scene. To add or remove objects from a live scene without a full reload (and without reframing the camera):
335
+
336
+ ```js
337
+ const id = await engine.addModel(url, { name }) // Append a model, rebuild in place
338
+ const id = await engine.addModelFromObject3D(object3d, { name }) // Append a caller-owned Object3D (caller retains ownership)
339
+ await engine.removeSceneObject(id) // Remove by id — returns false if not found
340
+ engine.setSceneObjectVisibility(id, visible) // Toggle visibility with an O(1) BVH-leaf patch, no rebuild
297
341
  ```
298
342
 
343
+ `id` is the appended root's `Object3D.uuid`, returned by `addModel`/`addModelFromObject3D`. The built-in ground plane is permanent and can't be removed.
344
+
299
345
  #### Settings
300
346
 
301
347
  ```js
302
- engine.settings.set('bounces', 8) // Set a single parameter
348
+ engine.settings.set('maxBounces', 8) // Set a single parameter
303
349
  engine.settings.setMany({ // Set multiple parameters at once
304
- bounces: 8,
350
+ maxBounces: 8,
305
351
  maxSamples: 60,
306
352
  exposure: 1.0
307
353
  })
308
- engine.settings.get('bounces') // Read a parameter
354
+ engine.settings.get('maxBounces') // Read a parameter
309
355
  engine.settings.getAll() // Get all current settings
310
356
  ```
311
357
 
@@ -313,30 +359,43 @@ Key settings:
313
359
 
314
360
  | Setting | Type | Default | Description |
315
361
  |---|---|---|---|
316
- | `bounces` | `number` | 3 | Max ray bounce depth |
362
+ | `maxBounces` | `number` | 3 | Max ray bounce depth |
317
363
  | `maxSamples` | `number` | 60 | Max accumulated samples before stopping |
318
364
  | `exposure` | `number` | 1.0 | Exposure value |
319
365
  | `saturation` | `number` | 1.2 | Color saturation |
320
366
  | `enableEnvironment` | `boolean` | true | Use environment lighting |
321
367
  | `environmentIntensity` | `number` | 1.0 | Environment light strength |
322
368
  | `environmentRotation` | `number` | 270 | Environment Y-rotation (degrees) |
369
+ | `showBackground` | `boolean` | true | Show the environment as a visible backdrop for camera-miss rays (vs. a solid/transparent background) |
370
+ | `samplingTechnique` | `number` | 3 | Light-sampling / MIS technique selector |
323
371
  | `fireflyThreshold` | `number` | 3.0 | Firefly clamping threshold |
324
372
  | `transmissiveBounces` | `number` | 5 | Max bounces for transmissive materials |
373
+ | `maxSubsurfaceSteps` | `number` | 8 | Max random-walk steps for subsurface scattering (raised to 64 by `configureForMode('production')`) |
374
+ | `enableAlphaShadows` | `boolean` | false | Alpha-tested shadow rays (enabled by `configureForMode('production')`) |
325
375
  | `enableDOF` | `boolean` | false | Enable depth of field |
326
376
  | `focusDistance` | `number` | 0.8 | DOF focus distance |
327
377
  | `aperture` | `number` | 5.6 | DOF aperture (f-stop) |
328
378
  | `focalLength` | `number` | 50 | DOF focal length (mm) |
329
379
  | `transparentBackground` | `boolean` | false | Transparent canvas background |
330
380
  | `interactionModeEnabled` | `boolean` | true | Lower quality during camera movement for smoother navigation |
331
- | `debugMode` | `number` | 0 | Debug visualization mode (0 = off) |
332
- | `environmentMode` | `string` | 'hdri' | Sky mode: `'hdri'` \| `'procedural'` \| `'gradient'` \| `'color'` |
381
+ | `renderMode` | `number` | 0 | Internal preview(0)/production(1) flag driving accumulation & ASVGF behavior — normally set via `configureForMode()`, not written directly |
382
+ | `visMode` | `number` | 0 | Debug visualization mode (0 = off) |
383
+ | `environmentMode` | `string` | 'hdri' | Sky mode: `'hdri'` \| `'procedural'` \| `'gradient'` \| `'color'` — not routed through `engine.settings`; use `engine.environmentManager.setMode()` instead |
384
+ | `useAdaptiveSampling` | `boolean` | true | Whole-frame early-stop once convergence reaches `adaptiveStopFraction` |
385
+ | `noiseThreshold` | `number` | 0.02 | Relative-error threshold below which a pixel is considered converged |
386
+ | `darkNoiseFloor` | `number` | 0.003 | Absolute-error floor so dim pixels don't stall convergence |
387
+ | `adaptiveMinSamples` | `number` | 8 | Minimum samples before adaptive sampling can trigger |
388
+ | `adaptiveStopFraction` | `number` | 0.95 | Fraction of pixels that must converge before the frame retires |
389
+ | `usePixelFreeze` | `boolean` | false | Per-pixel freeze (Tier-2): skip individually-converged pixels via active-list compaction |
390
+ | `pixelFreezeThreshold` | `number` | 0.02 | Relative-error threshold for a pixel to become a freeze candidate |
391
+ | `pixelFreezeStability` | `number` | 8 | Consecutive candidate frames required before a pixel freezes |
333
392
 
334
393
  See `ENGINE_DEFAULTS` for the full list with default values.
335
394
 
336
395
  #### Rendering Modes
337
396
 
338
397
  ```js
339
- engine.configureForMode('production') // High quality (tiled, 20 bounces, OIDN, controls disabled)
398
+ engine.configureForMode('production') // High quality (full-frame, 20 bounces, OIDN, controls disabled)
340
399
  engine.configureForMode('interactive') // Real-time navigation (3 bounces, controls enabled)
341
400
  ```
342
401
 
@@ -396,6 +455,11 @@ engine.reset() // Re-upload all material data to GPU
396
455
  engine.stages.pathTracer.materialData.updateMaterial(index, mat) // Replace a material
397
456
  await engine.rebuildMaterials(scene) // Full rebuild (after texture changes)
398
457
 
458
+ // Cap the longest edge of processed material textures (clamped to the hardware max).
459
+ // Larger = sharper textures, ~quadratic VRAM. Reprocesses the current scene by default.
460
+ await engine.setMaxTextureSize(2048)
461
+ await engine.setMaxTextureSize(4096, { reprocess: false })
462
+
399
463
  // Per-mesh visibility — recommended UUID-based API (handles lookup + sync internally)
400
464
  engine.setMeshVisibilityByUuid(uuid, true) // explicit set
401
465
  engine.setMeshVisibilityByUuid(uuid, prev => !prev) // toggle via updater fn
@@ -550,6 +614,7 @@ engine.addEventListener(EngineEvents.RENDER_COMPLETE, (e) => {
550
614
  | `AF_POINT_PLACED` | Focus point placed on screen |
551
615
  | `ANIMATION_STARTED` / `ANIMATION_PAUSED` / `ANIMATION_STOPPED` / `ANIMATION_FINISHED` | Animation lifecycle |
552
616
  | `VIDEO_RENDER_PROGRESS` / `VIDEO_RENDER_COMPLETE` | Video export progress |
617
+ | `DEVICE_LOST` | The GPU device was lost (driver crash/reset) — rendering halts instead of throwing into a dead device |
553
618
  | `DISPOSE` | Engine is being disposed (fires before teardown begins, so listeners can release their own references) |
554
619
 
555
620
  ### Advanced: Custom Pipeline Stages
@@ -604,6 +669,8 @@ import {
604
669
  RenderSettings,
605
670
  CameraManager,
606
671
  LightManager,
672
+ GoboManager,
673
+ IESManager,
607
674
  DenoisingManager,
608
675
  OverlayManager,
609
676
  AnimationManager,
@@ -632,6 +699,8 @@ import { VRAMTracker, bufferBytes, textureBytes } from 'rayzee';
632
699
  | `oidn-web` | Intel Open Image Denoise for high-quality final renders | Yes — `npm install oidn-web` |
633
700
  | `onnxruntime-web` | AI-powered upscaling | No — loaded from CDN at runtime |
634
701
 
702
+ > **Note:** `onnxruntime-web` is also listed in `package.json` under `optionalDependencies` for bundler compatibility, but the engine's own runtime path always fetches it from a CDN (see `ortRuntimeUrl` / `ortWasmPaths` in [Configuring Assets](#configuring-assets-cdn-urls--cache-namespace)) rather than importing the installed package — installing it locally has no effect unless you also override those URLs to point at your own copy.
703
+
635
704
  ### Enabling OIDN (Intel Open Image Denoise)
636
705
 
637
706
  OIDN provides high-quality AI denoising for final renders. It runs automatically after the render converges (reaches `maxSamples`).
package/dist/rayzee.es.js CHANGED
@@ -11650,10 +11650,10 @@ var Yu = class extends lc {
11650
11650
  }
11651
11651
  }, Cd = class extends st {
11652
11652
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
11653
- super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null;
11653
+ super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null, this._helperScene = null;
11654
11654
  }
11655
- setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r }) {
11656
- this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null;
11655
+ setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r, helperScene: i }) {
11656
+ this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null, this._helperScene = i || null;
11657
11657
  }
11658
11658
  select(e) {
11659
11659
  let t = this._overlayManager?.getHelper("outline");
@@ -11753,17 +11753,17 @@ var Yu = class extends lc {
11753
11753
  this.clickTimeout = null;
11754
11754
  let t = this.getMouseCoordinates(e);
11755
11755
  this.raycaster.setFromCamera(t, this.camera);
11756
- let n = this.raycaster.intersectObjects(this.scene.children, !0), r = this.filterValidIntersects(n);
11757
- if (r.length > 0) {
11758
- let e = r[0].object, t = this.selectedObject;
11759
- t && t.uuid === e.uuid ? this.dispatchEvent({
11756
+ let n = this.raycaster.intersectObjects(this.scene.children, !0), r = this.filterValidIntersects(n), i = this._pickLightHelper(), a = null;
11757
+ if (r.length > 0 && i ? a = r[0].distance <= i.distance ? r[0].object : i.light : r.length > 0 ? a = r[0].object : i && (a = i.light), a) {
11758
+ let e = this.selectedObject;
11759
+ e && e.uuid === a.uuid ? this.dispatchEvent({
11760
11760
  type: "objectDeselected",
11761
- object: e,
11762
- uuid: e.uuid
11761
+ object: a,
11762
+ uuid: a.uuid
11763
11763
  }) : this.dispatchEvent({
11764
11764
  type: "objectSelected",
11765
- object: e,
11766
- uuid: e.uuid
11765
+ object: a,
11766
+ uuid: a.uuid
11767
11767
  });
11768
11768
  } else this.dispatchEvent({ type: "objectDeselected" });
11769
11769
  }, 250);
@@ -11827,6 +11827,21 @@ var Yu = class extends lc {
11827
11827
  return t !== this.focusPointIndicator && t !== this.floorPlane && !t.name.includes("Helper") && t.type === "Mesh";
11828
11828
  });
11829
11829
  }
11830
+ _pickLightHelper() {
11831
+ if (!this._helperScene || this._helperScene.children.length === 0) return null;
11832
+ let e = this.raycaster.intersectObjects(this._helperScene.children, !0);
11833
+ for (let t of e) {
11834
+ let e = t.object;
11835
+ for (; e;) {
11836
+ if (e.light) return {
11837
+ distance: t.distance,
11838
+ light: e.light
11839
+ };
11840
+ e = e.parent;
11841
+ }
11842
+ }
11843
+ return null;
11844
+ }
11830
11845
  updateDependencies({ scene: e, camera: t, floorPlane: n }) {
11831
11846
  e && (this.scene = e), t && (this.camera = t), n && (this.floorPlane = n);
11832
11847
  }
@@ -16024,9 +16039,9 @@ var Yf = {
16024
16039
  dispose() {
16025
16040
  this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
16026
16041
  }
16027
- }, np = class {
16042
+ }, np = new rn(0, 0, -1), rp = class {
16028
16043
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
16029
- this._app = r, this._orbitControls = n, this._camera = e, this._controls = new vn(e, t), this._gizmoScene = new Gt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new rn(), this._normalMatrix = new yt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
16044
+ this._app = r, this._orbitControls = n, this._camera = e, this._controls = new vn(e, t), this._gizmoScene = new Gt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new rn(), this._normalMatrix = new yt(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new rn(), this._lightTargetDistance = null, this._lastLightPosition = null, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
16030
16045
  }
16031
16046
  setMeshData(e) {
16032
16047
  this._meshes = e, this._meshTriRanges = [], this._skinnedCache = [], this._normalCache = [];
@@ -16043,19 +16058,22 @@ var Yf = {
16043
16058
  this._posBuffer = new Float32Array(t * 9), this._normalBuffer = new Float32Array(t * 9), this._baselineComputed = !1;
16044
16059
  }
16045
16060
  attach(e) {
16046
- this._attached !== e && (this._controls.attach(e), this._attached = e);
16061
+ if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
16062
+ let t = e.target.position.clone().sub(e.position), n = t.length();
16063
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(np, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
16064
+ }
16047
16065
  }
16048
16066
  detach() {
16049
- this._attached &&= (this._controls.detach(), null);
16067
+ this._attached && (this._controls.detach(), this._attached = null, this._lightTargetDistance = null, this._lastLightPosition = null);
16050
16068
  }
16051
16069
  setMode(e) {
16052
16070
  this._controls.setMode(e), this._app?.dispatchEvent({
16053
16071
  type: Y.TRANSFORM_MODE_CHANGED,
16054
16072
  mode: e
16055
- });
16073
+ }), this._app?.refreshFrame();
16056
16074
  }
16057
16075
  setSpace(e) {
16058
- this._controls.setSpace(e);
16076
+ this._controls.setSpace(e), this._app?.refreshFrame();
16059
16077
  }
16060
16078
  get isDragging() {
16061
16079
  return this._isDragging;
@@ -16072,10 +16090,29 @@ var Yf = {
16072
16090
  e.autoClear = !1, e.clearDepth(), e.setRenderTarget(null), e.render(this._gizmoScene, this._camera), e.autoClear = t;
16073
16091
  }
16074
16092
  _onDraggingChanged(e) {
16075
- this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_START }) : (this._recomputeAndRefit(), this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_END }));
16093
+ this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: Y.OBJECT_TRANSFORM_END }));
16076
16094
  }
16077
16095
  _onObjectChange() {
16078
- this._app.needsReset = !0, this._app.wake();
16096
+ this._app.needsReset = !0, this._app.wake(), this._attached?.isLight && this._syncLightDuringDrag();
16097
+ }
16098
+ _syncLightDuringDrag() {
16099
+ let e = this._attached;
16100
+ if (e.target) {
16101
+ let t = this._controls.mode;
16102
+ if (t === "translate" && this._lastLightPosition) {
16103
+ let t = this._tempForward.copy(e.position).sub(this._lastLightPosition);
16104
+ e.target.position.add(t), e.target.updateMatrixWorld(!0);
16105
+ } else if (t === "rotate" && this._lightTargetDistance != null) {
16106
+ let t = this._tempForward.set(0, 0, -1).applyQuaternion(e.quaternion);
16107
+ e.target.position.copy(e.position).addScaledVector(t, this._lightTargetDistance), e.target.updateMatrixWorld(!0);
16108
+ }
16109
+ this._lastLightPosition.copy(e.position);
16110
+ }
16111
+ this._app.lightManager?.updateLights();
16112
+ }
16113
+ _finalizeLightTransform() {
16114
+ let e = this._attached;
16115
+ e.isRectAreaLight && (e.scale.x !== 1 || e.scale.y !== 1) && (e.width *= e.scale.x, e.height *= e.scale.y, e.scale.set(1, 1, 1)), this._app.lightManager?.updateLights();
16079
16116
  }
16080
16117
  _recomputeAndRefit() {
16081
16118
  if (!this._meshes || !this._posBuffer || this._refitInFlight || !this._attached) return;
@@ -16133,17 +16170,17 @@ var Yf = {
16133
16170
  }
16134
16171
  }
16135
16172
  dispose() {
16136
- this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
16173
+ this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
16137
16174
  }
16138
- }, rp = /* @__PURE__ */ new WeakMap(), ip = class extends st {
16175
+ }, ip = /* @__PURE__ */ new WeakMap(), ap = class extends st {
16139
16176
  constructor(e, t = {}) {
16140
16177
  super();
16141
16178
  try {
16142
- rp.get(e)?.dispose();
16179
+ ip.get(e)?.dispose();
16143
16180
  } catch (e) {
16144
16181
  console.warn("PathTracerApp: prior canvas owner dispose failed", e);
16145
16182
  }
16146
- rp.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new cf(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new tp(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Sd(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1;
16183
+ ip.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new cf(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new tp(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Sd(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1;
16147
16184
  }
16148
16185
  _addTrackedListener(e, t, n) {
16149
16186
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -16596,7 +16633,7 @@ var Yf = {
16596
16633
  assetLoader: this.assetLoader,
16597
16634
  pathTracer: null,
16598
16635
  floorPlane: this.assetLoader.floorPlane
16599
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new uf(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new df(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Sf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new np({
16636
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new uf(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new df(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Sf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new rp({
16600
16637
  camera: this.cameraManager.camera,
16601
16638
  canvas: this.canvas,
16602
16639
  orbitControls: this.cameraManager.controls,
@@ -16605,7 +16642,8 @@ var Yf = {
16605
16642
  overlayManager: this.overlayManager,
16606
16643
  transformManager: this.transformManager,
16607
16644
  appDispatch: (e) => this.dispatchEvent(e),
16608
- orbitControls: this.cameraManager.controls
16645
+ orbitControls: this.cameraManager.controls,
16646
+ helperScene: this._sceneHelpers.scene
16609
16647
  }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
16610
16648
  }
16611
16649
  _wireEvents() {
@@ -16740,7 +16778,7 @@ var Yf = {
16740
16778
  _forwardEvents(e, t) {
16741
16779
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
16742
16780
  }
16743
- }, ap = class {
16781
+ }, op = class {
16744
16782
  constructor(e) {
16745
16783
  this._app = e, this._cancelled = !1, this._rendering = !1;
16746
16784
  }
@@ -16838,6 +16876,6 @@ var Yf = {
16838
16876
  }
16839
16877
  };
16840
16878
  //#endregion
16841
- export { xr as AF_DEFAULTS, gr as ASVGF_QUALITY_PRESETS, br as AUTO_FOCUS_MODES, tp as AnimationManager, Sr as BVH_LEAF_MARKERS, yr as CAMERA_PRESETS, _r as CAMERA_RANGES, lf as CameraManager, Dr as DEFAULT_TEXTURE_MATRIX, Zf as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, df as GoboManager, Sf as IESManager, kr as INTERACTIVE_RENDER_CONFIG, Cd as InteractionManager, uf as LightManager, Ar as MEMORY_CONSTANTS, ep as OverlayManager, Or as PRODUCTION_RENDER_CONFIG, ip as PathTracerApp, yd as PipelineContext, xd as RenderPipeline, cf as RenderSettings, $n as RenderStage, vr as SKY_PRESETS, Qn as StageExecutionMode, Cr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, np as TransformManager, $c as VRAMTracker, ap as VideoRenderManager, Zc as bufferBytes, oc as configureAssets, sc as getAssetConfig, Qc as textureBytes };
16879
+ export { xr as AF_DEFAULTS, gr as ASVGF_QUALITY_PRESETS, br as AUTO_FOCUS_MODES, tp as AnimationManager, Sr as BVH_LEAF_MARKERS, yr as CAMERA_PRESETS, _r as CAMERA_RANGES, lf as CameraManager, Dr as DEFAULT_TEXTURE_MATRIX, Zf as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, df as GoboManager, Sf as IESManager, kr as INTERACTIVE_RENDER_CONFIG, Cd as InteractionManager, uf as LightManager, Ar as MEMORY_CONSTANTS, ep as OverlayManager, Or as PRODUCTION_RENDER_CONFIG, ap as PathTracerApp, yd as PipelineContext, xd as RenderPipeline, cf as RenderSettings, $n as RenderStage, vr as SKY_PRESETS, Qn as StageExecutionMode, Cr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, rp as TransformManager, $c as VRAMTracker, op as VideoRenderManager, Zc as bufferBytes, oc as configureAssets, sc as getAssetConfig, Qc as textureBytes };
16842
16880
 
16843
16881
  //# sourceMappingURL=rayzee.es.js.map