rayzee 5.3.7 → 5.4.0

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/src/README.md DELETED
@@ -1,284 +0,0 @@
1
- # Rayzee Engine
2
-
3
- WebGPU path tracing engine. Framework-agnostic — works with React, Vue, Svelte, or vanilla JS.
4
-
5
- ## Quick Start
6
-
7
- ```html
8
- <canvas id="c" width="512" height="512"></canvas>
9
- <script type="module">
10
- import { PathTracerApp } from 'rayzee';
11
-
12
- const engine = new PathTracerApp(document.getElementById('c'));
13
- await engine.init();
14
- await engine.loadEnvironment('studio.hdr');
15
- await engine.loadModel('scene.glb');
16
- engine.animate();
17
- </script>
18
- ```
19
-
20
- ## Constructor
21
-
22
- ```js
23
- new PathTracerApp(canvas, options?)
24
- ```
25
-
26
- | Param | Type | Description |
27
- |-------|------|-------------|
28
- | `canvas` | `HTMLCanvasElement` | Render target |
29
- | `options.autoResize` | `boolean` | Auto-listen for window resize (default `true`) |
30
-
31
- ## API Reference
32
-
33
- ### Settings — Unified Parameter Access
34
-
35
- All render parameters go through a single API. No individual setter methods.
36
-
37
- ```js
38
- engine.set('maxBounces', 8);
39
- engine.set('exposure', 1.5);
40
- engine.get('maxBounces'); // 8
41
- engine.setMany({ maxBounces: 8, exposure: 1.5 }); // batch, single reset
42
- engine.getAll(); // snapshot of all settings
43
- ```
44
-
45
- **Available setting keys:**
46
-
47
- | Key | Type | Default | Description |
48
- |-----|------|---------|-------------|
49
- | `maxBounces` | `number` | 3 | Ray bounce limit |
50
- | `samplesPerPixel` | `number` | 1 | SPP multiplier |
51
- | `maxSamples` | `number` | 60 | Max accumulated samples |
52
- | `transmissiveBounces` | `number` | 5 | Bounces through transparent materials |
53
- | `fireflyThreshold` | `number` | 1.8 | Clamp bright outliers |
54
- | `exposure` | `number` | 1.0 | Manual exposure |
55
- | `enableDOF` | `boolean` | false | Depth of field |
56
- | `focusDistance` | `number` | 0.8 | Focus distance |
57
- | `aperture` | `number` | 5.6 | F-stop |
58
- | `focalLength` | `number` | 50 | Focal length in mm |
59
- | `apertureScale` | `number` | 1.0 | Aperture multiplier |
60
- | `samplingTechnique` | `number` | 3 | Sampling strategy |
61
- | `environmentIntensity` | `number` | 1.0 | Environment brightness |
62
- | `backgroundIntensity` | `number` | 1.0 | Background brightness |
63
- | `showBackground` | `boolean` | true | Show environment background |
64
- | `transparentBackground` | `boolean` | false | Alpha transparency |
65
- | `enableEnvironment` | `boolean` | true | Enable environment lighting |
66
- | `globalIlluminationIntensity` | `number` | 1.0 | GI multiplier |
67
- | `enableEmissiveTriangleSampling` | `boolean` | false | Direct emissive sampling |
68
- | `emissiveBoost` | `number` | 1.0 | Emissive multiplier |
69
- | `useAdaptiveSampling` | `boolean` | false | Variance-guided sampling |
70
- | `adaptiveSamplingMax` | `number` | 8 | Max samples for high-variance pixels |
71
- | `visMode` | `number` | 0 | Debug visualization mode |
72
- | `debugVisScale` | `number` | 100 | Debug vis scale factor |
73
- | `renderLimitMode` | `string` | 'frames' | `'frames'` or `'time'` |
74
- | `renderTimeLimit` | `number` | 30 | Time limit in seconds |
75
- | `environmentRotation` | `number` | 0.0 | Env rotation in radians |
76
-
77
- ### Lifecycle
78
-
79
- | Method | Description |
80
- |--------|-------------|
81
- | `await init()` | Initialize WebGPU renderer and pipeline |
82
- | `animate()` | Start render loop |
83
- | `pause()` / `resume()` | Pause/resume animation |
84
- | `reset(soft?)` | Reset accumulation (`soft=true` preserves temporal history) |
85
- | `dispose()` | Release all GPU resources |
86
-
87
- ### Scene Loading
88
-
89
- | Method | Description |
90
- |--------|-------------|
91
- | `await loadModel(url)` | Load GLB/GLTF, build BVH, upload to GPU |
92
- | `await loadEnvironment(url)` | Load HDR environment map |
93
- | `await loadExampleModels(index, modelFiles)` | Load from a model catalog array |
94
-
95
- ### Rendering Mode
96
-
97
- | Method | Description |
98
- |--------|-------------|
99
- | `configureForMode(mode, opts?)` | Batch-configure for `'preview'`, `'final-render'`, or `'results'` |
100
- | `setRenderMode(0\|1)` | 0=progressive, 1=tiled |
101
- | `setTileCount(n)` | Tiles per axis (e.g. 3 = 3x3 grid) |
102
- | `isComplete()` | Whether render converged |
103
- | `getFrameCount()` | Current accumulated frame count |
104
- | `getOutputCanvas()` | Returns the correct canvas for reading pixels |
105
- | `takeScreenshot()` | Download current render as PNG |
106
-
107
- ### Managers
108
-
109
- Access camera, lights, and denoising through focused manager objects:
110
-
111
- #### `engine.cameraManager`
112
-
113
- | Property / Method | Description |
114
- |-------------------|-------------|
115
- | `.camera` | Active `PerspectiveCamera` |
116
- | `.controls` | `OrbitControls` instance |
117
- | `.switchCamera(index)` | Switch to loaded camera (0=default) |
118
- | `.getCameraNames()` | Array of camera display names |
119
- | `.setAutoFocusMode('manual'\|'auto')` | Auto-focus mode |
120
- | `.setAFScreenPoint(x, y)` | Focus point in screen-space (0-1) |
121
- | `.enterAFPointPlacementMode()` | Click-to-place AF point |
122
- | `.exitAFPointPlacementMode()` | Exit AF placement |
123
-
124
- #### `engine.lightManager`
125
-
126
- | Method | Description |
127
- |--------|-------------|
128
- | `.addLight(type)` | `'DirectionalLight'` \| `'PointLight'` \| `'SpotLight'` \| `'RectAreaLight'` |
129
- | `.removeLight(uuid)` | Remove by UUID |
130
- | `.getLights()` | Get all light descriptors |
131
- | `.clearLights()` | Remove all lights |
132
- | `.updateLights()` | Sync lights to GPU |
133
- | `.setShowLightHelper(bool)` | Toggle light visualizations |
134
-
135
- #### `engine.denoiseManager`
136
-
137
- | Method | Description |
138
- |--------|-------------|
139
- | `.setDenoiserStrategy(s, preset?)` | `'none'` \| `'asvgf'` \| `'ssrc'` \| `'edgeaware'` |
140
- | `.setASVGFEnabled(bool, preset?)` | Toggle ASVGF with optional quality preset |
141
- | `.applyASVGFPreset(name)` | `'low'` \| `'medium'` \| `'high'` |
142
- | `.setAutoExposureEnabled(bool)` | Toggle auto-exposure |
143
- | `.setAdaptiveSamplingEnabled(bool)` | Toggle adaptive sampling |
144
-
145
- ### Stage Parameter Updates
146
-
147
- For fine-grained control over individual pipeline stages:
148
-
149
- | Method | Description |
150
- |--------|-------------|
151
- | `updateASVGFParameters(params)` | Update ASVGF params (temporalAlpha, phiColor, etc.) |
152
- | `updateSSRCParameters(params)` | Update SSRC params |
153
- | `updateEdgeAwareUniforms(params)` | Update edge-aware filter uniforms |
154
- | `updateAutoExposureParameters(params)` | Update auto-exposure params |
155
- | `updateAdaptiveSamplingParameters(params)` | Update adaptive sampling params |
156
- | `setTileHelperEnabled(bool)` | Toggle tile highlight overlay (2D canvas, never baked into renders) |
157
-
158
- ### OIDN & AI Upscaler
159
-
160
- | Method | Description |
161
- |--------|-------------|
162
- | `setOIDNEnabled(bool)` | Enable/disable OIDN denoiser |
163
- | `updateOIDNQuality(quality)` | `'fast'` \| `'balance'` \| `'high'` |
164
- | `setUpscalerEnabled(bool)` | Enable/disable AI upscaler |
165
- | `setUpscalerScaleFactor(n)` | Upscale factor (2, 4) |
166
- | `setUpscalerQuality(quality)` | `'fast'` \| `'balance'` |
167
-
168
- ### Environment Modes
169
-
170
- | Method | Description |
171
- |--------|-------------|
172
- | `setEnvironmentMode(m)` | `'hdri'` \| `'procedural'` \| `'gradient'` \| `'color'` |
173
- | `await setEnvironmentMap(texture)` | Set custom env texture |
174
- | `generateProceduralSkyTexture()` | Regenerate procedural sky |
175
- | `generateGradientTexture()` | Regenerate gradient sky |
176
- | `generateSolidColorTexture()` | Regenerate solid color sky |
177
- | `markEnvironmentNeedsUpdate()` | Flag env texture for GPU re-upload |
178
-
179
- ### Materials
180
-
181
- | Method | Description |
182
- |--------|-------------|
183
- | `updateMaterialProperty(idx, prop, val)` | Update single material property |
184
- | `updateTextureTransform(idx, name, matrix)` | Update UV transform |
185
- | `rebuildMaterials(scene)` | Full material rebuild and GPU upload |
186
-
187
- ### Interaction
188
-
189
- | Method | Description |
190
- |--------|-------------|
191
- | `selectObject(obj)` | Select for outline highlight |
192
- | `toggleSelectMode()` | Toggle click-to-select |
193
- | `toggleFocusMode()` | Toggle click-to-focus |
194
- | `focusOnPoint(vec3)` | Move orbit target to world point |
195
- | `dispatchInteractionEvent(event)` | Forward events to interaction manager |
196
- | `onInteractionEvent(type, handler)` | Subscribe to interaction events (returns unsubscribe fn) |
197
-
198
- ### Direct Stage Access
199
-
200
- For advanced consumers, all pipeline stages are accessible via `engine.stages`:
201
-
202
- ```js
203
- engine.stages.pathTracer // PathTracer
204
- engine.stages.normalDepth // NormalDepth
205
- engine.stages.motionVector // MotionVector
206
- engine.stages.asvgf // ASVGF
207
- engine.stages.variance
208
- engine.stages.bilateralFilter
209
- engine.stages.adaptiveSampling
210
- engine.stages.edgeFilter
211
- engine.stages.autoExposure
212
- engine.stages.ssrc
213
- engine.stages.display // Display
214
- engine.overlayManager // OverlayManager (tile helper, scene helpers)
215
- ```
216
-
217
- ## Events
218
-
219
- Subscribe via `engine.addEventListener(EngineEvents.X, handler)`.
220
-
221
- | Event | Extra Fields | When |
222
- |-------|-------------|------|
223
- | `RENDER_COMPLETE` | | Accumulation finished |
224
- | `RENDER_RESET` | | Accumulation restarted |
225
- | `DENOISING_START` | | OIDN denoiser begins |
226
- | `DENOISING_END` | | OIDN denoiser finishes |
227
- | `UPSCALING_START` | | AI upscaler begins |
228
- | `UPSCALING_PROGRESS` | `progress` | Upscaler progress (0-1) |
229
- | `UPSCALING_END` | | AI upscaler finishes |
230
- | `LOADING_UPDATE` | `status`, `progress`, ... | Asset loading progress |
231
- | `LOADING_RESET` | | Loading state cleared |
232
- | `STATS_UPDATE` | `timeElapsed`, `samples` | Per-frame render stats |
233
- | `OBJECT_SELECTED` | `object` | Object selected |
234
- | `OBJECT_DESELECTED` | `object` | Object deselected |
235
- | `OBJECT_DOUBLE_CLICKED` | `object`, `uuid` | Object double-clicked |
236
- | `SELECT_MODE_CHANGED` | `enabled` | Select mode toggled |
237
- | `AUTO_FOCUS_UPDATED` | `distance` | Auto-focus distance changed |
238
- | `AUTO_EXPOSURE_UPDATED` | `exposure`, `luminance` | Auto-exposure computed |
239
- | `AF_POINT_PLACED` | `point` | Focus point placed via click |
240
- | `SETTING_CHANGED` | `key`, `value`, `prev` | Any render setting changed |
241
-
242
- ## Exports
243
-
244
- ```js
245
- import {
246
- PathTracerApp, // Main engine class
247
- EngineEvents, // Event type constants
248
-
249
- // Settings & managers
250
- RenderSettings, // Unified parameter store
251
- CameraManager, // Camera switching, auto-focus, DOF
252
- LightManager, // Light CRUD and GPU transfer
253
- DenoisingManager, // Denoiser strategy, OIDN, upscaler
254
-
255
- // Configuration
256
- ENGINE_DEFAULTS, // Default config values
257
- ASVGF_QUALITY_PRESETS,// { low, medium, high }
258
- CAMERA_PRESETS, // { portrait, landscape, macro, product, architectural, cinematic }
259
- CAMERA_RANGES, // { fov, focusDistance, aperture, focalLength } with min/max
260
- SKY_PRESETS, // { clearMorning, clearNoon, overcast, goldenHour, sunset, dusk }
261
- AF_DEFAULTS, // Auto-focus constants
262
- FINAL_RENDER_CONFIG, // High-quality render preset
263
- PREVIEW_RENDER_CONFIG,// Interactive preview preset
264
-
265
- // Pipeline (for building custom stages)
266
- RenderPipeline,
267
- RenderStage,
268
- StageExecutionMode,
269
- PipelineContext,
270
- } from 'rayzee';
271
- ```
272
-
273
- ## React Integration
274
-
275
- Use the provided adapter to bridge engine events to Zustand stores:
276
-
277
- ```js
278
- import { connectEngineToStore } from './src/lib/EngineAdapter.js';
279
-
280
- const cleanup = connectEngineToStore(engine, { useStore, useCameraStore, usePathTracerStore });
281
- // cleanup() to unsubscribe
282
- ```
283
-
284
- For other frameworks, subscribe to `EngineEvents` directly and update your state layer.
@@ -1,31 +0,0 @@
1
- /**
2
- * Monkey-patch for Three.js StorageTexture.setSize() bind group staleness.
3
- *
4
- * Bug: StorageTexture.setSize() calls dispose() but never sets needsUpdate = true.
5
- * The Bindings system tracks texture.version (incremented by needsUpdate setter)
6
- * to detect when bind groups need recreation. Without the version bump, the bind
7
- * group keeps referencing the destroyed GPUTextureView → writes silently fail.
8
- *
9
- * Three.js issue: https://github.com/mrdoob/three.js/issues/32969
10
- * Targeted fix: r184+ (2026-03-25)
11
- *
12
- * Import this module once at app startup (side-effect only).
13
- */
14
-
15
- import { StorageTexture } from 'three/webgpu';
16
-
17
- const _origSetSize = StorageTexture.prototype.setSize;
18
-
19
- StorageTexture.prototype.setSize = function ( width, height ) {
20
-
21
- const wasChanged = this.image.width !== width || this.image.height !== height;
22
-
23
- _origSetSize.call( this, width, height );
24
-
25
- if ( wasChanged ) {
26
-
27
- this.needsUpdate = true;
28
-
29
- }
30
-
31
- };