rayzee 7.22.1 → 7.22.3

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/dist/rayzee.es.js CHANGED
@@ -10920,9 +10920,9 @@ var ef = ai("wavefront"), tf = 256, nf = [
10920
10920
  this._chunkRows = Math.max(1, Math.min(Math.floor(n / e), t)), this._numChunks = Math.max(1, Math.ceil(t / this._chunkRows));
10921
10921
  }
10922
10922
  reallocateReservedStorage() {
10923
- if (!this._packedBuffers || !(this.materialData?.materialCount > 0)) return;
10923
+ if (!this.storageTextures.writeColor) return;
10924
10924
  let e = Math.min(this.storageTextures.renderWidth || 1, Y), t = Math.min(this.storageTextures.renderHeight || 1, Y);
10925
- this.storageTextures.create(e, t), this.resolution.value.set(e, t), this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels();
10925
+ this.storageTextures.create(e, t), this.resolution.value.set(e, t), !(!this._packedBuffers || !(this.materialData?.materialCount > 0)) && (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels());
10926
10926
  }
10927
10927
  _buildWavefrontKernels() {
10928
10928
  let e = this.shaderBuilder.getSceneTextureNodes();
@@ -17449,7 +17449,7 @@ var Cm = 4096, wm = class {
17449
17449
  } catch (e) {
17450
17450
  Nm.warn("prior canvas owner dispose failed", e);
17451
17451
  }
17452
- Mm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Ep(J), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = J.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 Om(), 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 Vf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
17452
+ Mm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Ep(J), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = J.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = 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 Om(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Vf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
17453
17453
  }
17454
17454
  _addTrackedListener(e, t, n) {
17455
17455
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -17467,7 +17467,7 @@ var Cm = 4096, wm = class {
17467
17467
  this._trackedListeners.length = 0;
17468
17468
  }
17469
17469
  async init() {
17470
- return await this._initRenderer(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, Nm.debug("WebGPU path tracer app initialized"), this;
17470
+ return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, Nm.debug("WebGPU path tracer app initialized"), this;
17471
17471
  }
17472
17472
  animate() {
17473
17473
  if (!this._deviceLost) {
@@ -17631,13 +17631,7 @@ var Cm = 4096, wm = class {
17631
17631
  this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), e.end("GPU data transfer"), hr({
17632
17632
  status: "Compiling shaders...",
17633
17633
  progress: 90
17634
- }), await new Promise((e) => setTimeout(e, 0)), e.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), e.end("Material setup (TSL compile)"), e.start("Pipeline precompile");
17635
- try {
17636
- await this.renderer.compileAsync(this.meshScene, this.cameraManager.camera);
17637
- } catch (e) {
17638
- Nm.warn("raster fallback precompile failed", e);
17639
- }
17640
- e.end("Pipeline precompile"), n && (hr({
17634
+ }), await new Promise((e) => setTimeout(e, 0)), e.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), e.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (e.start("Pipeline precompile"), await this.precompileRaster(), e.end("Pipeline precompile")), n && (hr({
17641
17635
  status: "Finalizing environment map...",
17642
17636
  progress: 95
17643
17637
  }), await n, this.stages.pathTracer.environment.applyCDFResults());
@@ -17751,8 +17745,13 @@ var Cm = 4096, wm = class {
17751
17745
  }), r;
17752
17746
  }
17753
17747
  setReservedRenderResolution(e, { allowLower: t = !1 } = {}) {
17754
- let n = this.renderer?.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, r = (typeof navigator < "u" && navigator.deviceMemory || 4) >= 8 && n >= 1024 * 1024 * 1024 ? Dr : 2048, i = Y, a = Or(Math.min(t ? e : Math.max(e, i), r));
17755
- if (a !== i && this.stages?.pathTracer?._packedBuffers) {
17748
+ let n = t ? e : Math.max(e, Y);
17749
+ if (!this.renderer) return this._pendingReservedRenderSize = {
17750
+ requestedPx: e,
17751
+ allowLower: t
17752
+ }, Math.max(256, Math.min(Dr, Math.floor(n) || 256));
17753
+ let r = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, i = (typeof navigator < "u" && navigator.deviceMemory || 4) >= 8 && r >= 1024 * 1024 * 1024 ? Dr : 2048, a = Or(Math.min(n, i));
17754
+ if ((this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? a) !== a) {
17756
17755
  let e = this.pauseRendering;
17757
17756
  this.pauseRendering = !0;
17758
17757
  try {
@@ -17769,11 +17768,21 @@ var Cm = 4096, wm = class {
17769
17768
  }
17770
17769
  return a;
17771
17770
  }
17771
+ _applyPendingReservedRenderSize() {
17772
+ let e = this._pendingReservedRenderSize;
17773
+ if (!e) return;
17774
+ this._pendingReservedRenderSize = null;
17775
+ let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
17776
+ t < e.requestedPx && Nm.warn(`reserved render size ${Q.n(e.requestedPx)}px was capped to ${Q.n(t)}px by this device's limits — renders above ${Q.n(t)}px will be declined.`), this.dispatchEvent({
17777
+ type: "reserved_render_size_changed",
17778
+ size: t
17779
+ });
17780
+ }
17772
17781
  getReservedRenderResolution() {
17773
17782
  return Y;
17774
17783
  }
17775
17784
  _isRenderSizeSupported(e, t) {
17776
- return e > Y || t > Y ? (Nm.warn(`render resolution ${e}×${t} exceeds the ${Y}px limit (compute storage textures are pre-allocated at ${Y}px). Ignoring resize — use a resolution ≤ ${Y}.`), !1) : !0;
17785
+ return e > Y || t > Y ? (Nm.warn(`render resolution ${e}×${t} exceeds the ${Y}px reserve (compute storage textures are pre-allocated at ${Y}px). Ignoring resize — raise the reserve with setReservedRenderResolution( ${Math.max(e, t)} ) first, or use a resolution ≤ ${Y}.`), !1) : !0;
17777
17786
  }
17778
17787
  onResize() {
17779
17788
  let e = this.canvas.clientWidth, t = this.canvas.clientHeight;
@@ -17792,7 +17801,10 @@ var Cm = 4096, wm = class {
17792
17801
  }));
17793
17802
  }
17794
17803
  setCanvasSize(e, t) {
17795
- e === 0 || t === 0 || this._isRenderSizeSupported(e, t) && (this.renderer.setPixelRatio(1), this.renderer.setSize(e, t, !1), this.cameraManager.camera.aspect = e / t, this.cameraManager.camera.updateProjectionMatrix(), clearTimeout(this._resizeDebounceTimer), this._applyRenderResize(e, t));
17804
+ return e === 0 || t === 0 || !this._isRenderSizeSupported(e, t) ? null : (this.renderer.setPixelRatio(1), this.renderer.setSize(e, t, !1), this.cameraManager.camera.aspect = e / t, this.cameraManager.camera.updateProjectionMatrix(), clearTimeout(this._resizeDebounceTimer), this._applyRenderResize(e, t), {
17805
+ width: e,
17806
+ height: t
17807
+ });
17796
17808
  }
17797
17809
  configureForMode(e, t = {}) {
17798
17810
  let n = e === "production", r = n ? Vr : Hr;
@@ -17934,6 +17946,15 @@ var Cm = 4096, wm = class {
17934
17946
  return null;
17935
17947
  }
17936
17948
  }
17949
+ get pathTracerEnabled() {
17950
+ return this._pathTracerEnabled;
17951
+ }
17952
+ set pathTracerEnabled(e) {
17953
+ this._pathTracerEnabled = e, e || this.precompileRaster();
17954
+ }
17955
+ precompileRaster() {
17956
+ return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => Nm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
17957
+ }
17937
17958
  get isLoading() {
17938
17959
  return this._loadingInProgress;
17939
17960
  }
@@ -18316,4 +18337,4 @@ var Cm = 4096, wm = class {
18316
18337
  }
18317
18338
  };
18318
18339
  //#endregion
18319
- export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, Om as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Dp as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, vm as DenoisingManager, J as ENGINE_DEFAULTS, dr as EngineEvents, kp as GoboManager, Bp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Hf as InteractionManager, Wr as LOG_LEVELS, Op as LightManager, ii as Logger, Ur as MEMORY_CONSTANTS, Dm as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Pm as PathTracerApp, Of as PipelineContext, Bf as RenderPipeline, Ep as RenderSettings, lr as RenderStage, jr as SKY_PRESETS, cr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, Am as TransformManager, uu as VRAMTracker, Fm as VideoRenderManager, cu as bufferBytes, Ff as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Pf as getBindingAuditFindings, Nf as setBindingAudit, lu as textureBytes };
18340
+ export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, Om as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Dp as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, vm as DenoisingManager, J as ENGINE_DEFAULTS, dr as EngineEvents, kp as GoboManager, Bp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Hf as InteractionManager, Wr as LOG_LEVELS, Op as LightManager, ii as Logger, Dr as MAX_RESERVABLE_RENDER_SIZE, Ur as MEMORY_CONSTANTS, Dm as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Pm as PathTracerApp, Of as PipelineContext, Bf as RenderPipeline, Ep as RenderSettings, lr as RenderStage, jr as SKY_PRESETS, cr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, Am as TransformManager, uu as VRAMTracker, Fm as VideoRenderManager, cu as bufferBytes, Ff as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Pf as getBindingAuditFindings, Nf as setBindingAudit, lu as textureBytes };