rayzee 7.15.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
@@ -7,13 +7,47 @@
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`).