rayzee 7.22.0 → 7.22.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "7.22.0",
3
+ "version": "7.22.2",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -146,7 +146,8 @@ export class PathTracerApp extends EventDispatcher {
146
146
  // ── State ──
147
147
  this.isInitialized = false;
148
148
  this.pauseRendering = false;
149
- this.pathTracerEnabled = true;
149
+ this._pathTracerEnabled = true;
150
+ this._rasterPrecompile = null;
150
151
  this.animationManagerId = null;
151
152
  this.needsReset = false;
152
153
  this._loadingInProgress = false;
@@ -841,21 +842,16 @@ export class PathTracerApp extends EventDispatcher {
841
842
  this.stages.pathTracer.setupMaterial();
842
843
  timer.end( 'Material setup (TSL compile)' );
843
844
 
844
- // Front-load raster pipeline creation (compileAsync yields to main thread, r184+) so the first
845
- // animate frame is snappy. Wavefront compute kernels compile lazily on their first dispatch.
846
- timer.start( 'Pipeline precompile' );
847
- try {
848
-
849
- await this.renderer.compileAsync( this.meshScene, this.cameraManager.camera );
845
+ this._rasterPrecompile = null;
850
846
 
851
- } catch ( err ) {
847
+ if ( ! this._pathTracerEnabled ) {
852
848
 
853
- log.warn( 'raster fallback precompile failed', err );
849
+ timer.start( 'Pipeline precompile' );
850
+ await this.precompileRaster();
851
+ timer.end( 'Pipeline precompile' );
854
852
 
855
853
  }
856
854
 
857
- timer.end( 'Pipeline precompile' );
858
-
859
855
  // Wait for CDF
860
856
  if ( cdfPromise ) {
861
857
 
@@ -1864,6 +1860,42 @@ export class PathTracerApp extends EventDispatcher {
1864
1860
 
1865
1861
  }
1866
1862
 
1863
+ /**
1864
+ * When false, `animate()` rasters `meshScene` instead of path tracing. Those raster pipelines
1865
+ * are compiled on the switch rather than at load — `compileAsync` costs seconds on a
1866
+ * many-material model, and path tracing, the default, never uses them.
1867
+ * @returns {boolean}
1868
+ */
1869
+ get pathTracerEnabled() {
1870
+
1871
+ return this._pathTracerEnabled;
1872
+
1873
+ }
1874
+
1875
+ set pathTracerEnabled( value ) {
1876
+
1877
+ this._pathTracerEnabled = value;
1878
+ if ( ! value ) this.precompileRaster();
1879
+
1880
+ }
1881
+
1882
+ /**
1883
+ * Warms the raster fallback's pipelines. Once per loaded model; concurrent callers await the
1884
+ * same compile rather than racing past a flag set before it finishes.
1885
+ * @returns {Promise<void>}
1886
+ */
1887
+ precompileRaster() {
1888
+
1889
+ if ( ! this.renderer || ! this.meshScene ) return Promise.resolve();
1890
+
1891
+ this._rasterPrecompile ??= this.renderer
1892
+ .compileAsync( this.meshScene, this.cameraManager.camera )
1893
+ .catch( err => log.warn( 'raster fallback precompile failed', err ) );
1894
+
1895
+ return this._rasterPrecompile;
1896
+
1897
+ }
1898
+
1867
1899
  /**
1868
1900
  * Whether a model/environment load is currently in progress.
1869
1901
  * @returns {boolean}
@@ -96,8 +96,9 @@ export class BVHBuilder {
96
96
  reinsertionIterations: 0
97
97
  };
98
98
 
99
- // Treelet optimization configuration
100
- this.enableTreeletOptimization = true;
99
+ // Off: repairs LBVH trees, so on this binned-SAH build it buys 0.005% tree SAH for 72%
100
+ // of build time.
101
+ this.enableTreeletOptimization = false;
101
102
  this.treeletSize = 5;
102
103
  this.treeletOptimizationPasses = 1;
103
104
  this.treeletMinImprovement = 0.02;
@@ -48,6 +48,8 @@ export class SceneProcessor {
48
48
  enableTextureCache: true,
49
49
  maxConcurrentTextureTasks: Math.min( navigator.hardwareConcurrency || 4, 6 ),
50
50
  // Treelet optimization configuration
51
+ // Keep: `_buildBVH` sends `enabled: value !== false`, so undefined re-enables treelets.
52
+ enableTreeletOptimization: false,
51
53
  treeletSize: 7, // 7 nodes gives 315 topologies for optimal enumeration
52
54
  treeletOptimizationPasses: 1,
53
55
  treeletMinImprovement: 0.01, // Minimum SAH improvement threshold