rayzee 5.10.2 → 5.11.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/README.md CHANGED
@@ -230,7 +230,10 @@ const engine = new PathTracerApp(canvas, options?)
230
230
  | `canvas` | `HTMLCanvasElement` | Rendering target |
231
231
  | `options.autoResize` | `boolean` | Auto-resize on window resize (default: `true`) |
232
232
  | `options.showStats` | `boolean` | Show the performance stats panel (default: `true`) |
233
- | `options.statsContainer` | `HTMLElement` | DOM element to append the stats panel to (defaults to `document.body`) |
233
+ | `options.container` | `HTMLElement` | Single DOM parent the engine mounts auxiliary elements into — HUD overlay (tile borders, helpers), denoiser canvas, and stats panel. Defaults to `canvas.parentNode`. |
234
+ | `options.statsContainer` | `HTMLElement` | Override mount target for the stats panel only. Defaults to `options.container`. |
235
+
236
+ The engine creates and mounts everything it needs (denoiser canvas, tile/HUD overlay, stats) into a single parent on `init()`
234
237
 
235
238
  #### Lifecycle
236
239
 
package/dist/rayzee.es.js CHANGED
@@ -6618,8 +6618,8 @@ var Xs = 16, Zs = class {
6618
6618
  generateHash(e) {
6619
6619
  let t = "";
6620
6620
  for (let n of e) if (n?.image) {
6621
- let e = n.image.width || 0, r = n.image.height || 0, i = n.image.src || n.uuid || "";
6622
- t += `${e}x${r}_${i.slice(-8)}_`;
6621
+ let e = n.image.width || 0, r = n.image.height || 0, i = n.image.src || n.uuid || "", a = n.flipY === !1 ? "n" : "f";
6622
+ t += `${e}x${r}_${i.slice(-8)}_${a}_`;
6623
6623
  }
6624
6624
  return t + e.length;
6625
6625
  }
@@ -6735,28 +6735,32 @@ var Xs = 16, Zs = class {
6735
6735
  }
6736
6736
  async prepareTexturesForWorkerDirect(e) {
6737
6737
  let t = [];
6738
- for (let n of e) if (n?.image) try {
6739
- if (typeof createImageBitmap < "u" && n.image instanceof HTMLImageElement) {
6740
- let e = await createImageBitmap(n.image);
6741
- t.push({
6742
- bitmap: e,
6743
- width: n.image.width,
6744
- height: n.image.height,
6745
- isDirect: !0
6746
- });
6747
- } else {
6748
- let e = this.canvasPool.getCanvasWithContext(n.image.width, n.image.height);
6749
- e.context.drawImage(n.image, 0, 0);
6750
- let r = e.context.getImageData(0, 0, n.image.width, n.image.height);
6751
- t.push({
6752
- data: r.data.buffer,
6753
- width: n.image.width,
6754
- height: n.image.height,
6755
- isImageData: !0
6756
- }), this.canvasPool.releaseCanvasWithContext(e);
6738
+ for (let n of e) {
6739
+ if (!n?.image) continue;
6740
+ let e = n.flipY !== !1;
6741
+ try {
6742
+ if (typeof createImageBitmap < "u" && n.image instanceof HTMLImageElement) {
6743
+ let r = await createImageBitmap(n.image, { imageOrientation: e ? "flipY" : "none" });
6744
+ t.push({
6745
+ bitmap: r,
6746
+ width: n.image.width,
6747
+ height: n.image.height,
6748
+ isDirect: !0
6749
+ });
6750
+ } else {
6751
+ let r = n.image.width, i = n.image.height, a = await createImageBitmap(n.image, { imageOrientation: e ? "flipY" : "none" }), o = this.canvasPool.getCanvasWithContext(r, i);
6752
+ o.context.drawImage(a, 0, 0), a.close();
6753
+ let s = o.context.getImageData(0, 0, r, i);
6754
+ t.push({
6755
+ data: s.data.buffer,
6756
+ width: r,
6757
+ height: i,
6758
+ isImageData: !0
6759
+ }), this.canvasPool.releaseCanvasWithContext(o);
6760
+ }
6761
+ } catch (e) {
6762
+ console.warn("Failed to prepare texture for worker:", e);
6757
6763
  }
6758
- } catch (e) {
6759
- console.warn("Failed to prepare texture for worker:", e);
6760
6764
  }
6761
6765
  return t;
6762
6766
  }
@@ -6775,12 +6779,13 @@ var Xs = 16, Zs = class {
6775
6779
  for (let e = 0; e < n.length; e += t) {
6776
6780
  let a = Math.min(e + t, n.length), s = [];
6777
6781
  for (let t = e; t < a; t++) {
6778
- let e = n[t], a = createImageBitmap(e.image, {
6782
+ let e = n[t], a = e.flipY !== !1, o = createImageBitmap(e.image, {
6779
6783
  resizeWidth: r,
6780
6784
  resizeHeight: i,
6781
- resizeQuality: "high"
6785
+ resizeQuality: "high",
6786
+ imageOrientation: a ? "flipY" : "none"
6782
6787
  });
6783
- s.push(a.then((e) => ({
6788
+ s.push(o.then((e) => ({
6784
6789
  bitmap: e,
6785
6790
  index: t
6786
6791
  })));
@@ -6802,10 +6807,15 @@ var Xs = 16, Zs = class {
6802
6807
  let { maxWidth: n, maxHeight: r } = this.calculateOptimalDimensions(t), i = t.length, a = this.bufferPool.getBuffer(n * r * i * 4, Uint8Array), o = this.canvasPool.getCanvasWithContext(n, r);
6803
6808
  o.context.imageSmoothingEnabled = !0, o.context.imageSmoothingQuality = "high";
6804
6809
  for (let e = 0; e < t.length; e++) {
6805
- let i = t[e];
6806
- o.context.clearRect(0, 0, n, r), o.context.drawImage(i.image, 0, 0, n, r);
6807
- let s = o.context.getImageData(0, 0, n, r), c = n * r * 4 * e;
6808
- a.set(s.data, c), e % $n.STREAM_BATCH_SIZE === 0 && await new Promise((e) => setTimeout(e, 0));
6810
+ let i = t[e], s = await createImageBitmap(i.image, {
6811
+ resizeWidth: n,
6812
+ resizeHeight: r,
6813
+ resizeQuality: "high",
6814
+ imageOrientation: i.flipY === !1 ? "none" : "flipY"
6815
+ });
6816
+ o.context.clearRect(0, 0, n, r), o.context.drawImage(s, 0, 0), s.close();
6817
+ let c = o.context.getImageData(0, 0, n, r), l = n * r * 4 * e;
6818
+ a.set(c.data, l), e % $n.STREAM_BATCH_SIZE === 0 && await new Promise((e) => setTimeout(e, 0));
6809
6819
  }
6810
6820
  return this.canvasPool.releaseCanvasWithContext(o), this.createDataArrayTextureFromBuffer(a, n, r, i);
6811
6821
  }
@@ -6815,10 +6825,15 @@ var Xs = 16, Zs = class {
6815
6825
  let { maxWidth: n, maxHeight: r } = this.calculateOptimalDimensions(t), i = t.length, a = this.bufferPool.getBuffer(n * r * i * 4, Uint8Array), o = this.canvasPool.getCanvasWithContext(n, r);
6816
6826
  o.context.imageSmoothingEnabled = !0, o.context.imageSmoothingQuality = "high";
6817
6827
  for (let e = 0; e < t.length; e++) {
6818
- let i = t[e];
6819
- o.context.clearRect(0, 0, n, r), o.context.drawImage(i.image, 0, 0, n, r);
6820
- let s = o.context.getImageData(0, 0, n, r), c = n * r * 4 * e;
6821
- a.set(s.data, c);
6828
+ let i = t[e], s = await createImageBitmap(i.image, {
6829
+ resizeWidth: n,
6830
+ resizeHeight: r,
6831
+ resizeQuality: "high",
6832
+ imageOrientation: i.flipY === !1 ? "none" : "flipY"
6833
+ });
6834
+ o.context.clearRect(0, 0, n, r), o.context.drawImage(s, 0, 0), s.close();
6835
+ let c = o.context.getImageData(0, 0, n, r), l = n * r * 4 * e;
6836
+ a.set(c.data, l);
6822
6837
  }
6823
6838
  return this.canvasPool.releaseCanvasWithContext(o), this.createDataArrayTextureFromBuffer(a, n, r, i);
6824
6839
  }
@@ -7076,6 +7091,7 @@ var Xs = 16, Zs = class {
7076
7091
  let e = n.mipmaps[0], i = t.length;
7077
7092
  t.push(null), r.push({
7078
7093
  index: i,
7094
+ flipY: n.flipY,
7079
7095
  promise: ac(e.data, e.width, e.height)
7080
7096
  });
7081
7097
  continue;
@@ -7088,6 +7104,7 @@ var Xs = 16, Zs = class {
7088
7104
  let e = t.length;
7089
7105
  t.push(null), r.push({
7090
7106
  index: e,
7107
+ flipY: n.flipY,
7091
7108
  promise: ac(n.image.data, n.image.width, n.image.height)
7092
7109
  });
7093
7110
  continue;
@@ -7097,11 +7114,14 @@ var Xs = 16, Zs = class {
7097
7114
  if (r.length > 0) {
7098
7115
  let e = await Promise.allSettled(r.map((e) => e.promise));
7099
7116
  for (let i = 0; i < r.length; i++) {
7100
- let { index: a } = r[i], o = e[i];
7101
- if (o.status === "fulfilled") {
7102
- let e = o.value;
7103
- n.push(e), t[a] = { image: e };
7104
- } else console.warn("[TextureCreator] Failed to create ImageBitmap:", o.reason);
7117
+ let { index: a, flipY: o } = r[i], s = e[i];
7118
+ if (s.status === "fulfilled") {
7119
+ let e = s.value;
7120
+ n.push(e), t[a] = {
7121
+ image: e,
7122
+ flipY: o
7123
+ };
7124
+ } else console.warn("[TextureCreator] Failed to create ImageBitmap:", s.reason);
7105
7125
  }
7106
7126
  }
7107
7127
  for (let e = 0; e < t.length; e++) if (t[e] === null) {
@@ -7111,7 +7131,10 @@ var Xs = 16, Zs = class {
7111
7131
  255,
7112
7132
  255
7113
7133
  ]), i = await createImageBitmap(new ImageData(r, 1, 1));
7114
- n.push(i), t[e] = { image: i };
7134
+ n.push(i), t[e] = {
7135
+ image: i,
7136
+ flipY: !1
7137
+ };
7115
7138
  }
7116
7139
  return {
7117
7140
  normalized: t,
@@ -12900,6 +12923,9 @@ var _l = new Float32Array(3), vl = {
12900
12923
  getHUDCanvas() {
12901
12924
  return this._hudCanvas;
12902
12925
  }
12926
+ mount(e) {
12927
+ !e || this._hudCanvas.parentElement === e || e.appendChild(this._hudCanvas);
12928
+ }
12903
12929
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
12904
12930
  this.setHelperScene(e);
12905
12931
  let s = new Tl();
@@ -13194,7 +13220,7 @@ var _l = new Float32Array(3), vl = {
13194
13220
  } catch (e) {
13195
13221
  console.warn("PathTracerApp: prior canvas owner dispose failed", e);
13196
13222
  }
13197
- Al.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._showStats = t.showStats !== !1, this._statsContainer = t.statsContainer || null, this.settings = new Yc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Ol(), 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.completion = new Uc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
13223
+ Al.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._showStats = t.showStats !== !1, this._container = t.container || null, this._statsContainer = t.statsContainer || null, this.settings = new Yc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Ol(), 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.completion = new Uc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
13198
13224
  }
13199
13225
  _addTrackedListener(e, t, n) {
13200
13226
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -13613,7 +13639,7 @@ var _l = new Float32Array(3), vl = {
13613
13639
  }
13614
13640
  }
13615
13641
  _initStats() {
13616
- let e = this._statsContainer || this.canvas.parentElement || document.body;
13642
+ let e = this._statsContainer || this._container || this.canvas.parentElement || document.body;
13617
13643
  this._stats = en(this.renderer, e);
13618
13644
  }
13619
13645
  _setupAutoExposureListener() {
@@ -13637,7 +13663,7 @@ var _l = new Float32Array(3), vl = {
13637
13663
  app: this,
13638
13664
  renderWidth: this.denoisingManager?._lastRenderWidth || this.canvas.clientWidth || 1,
13639
13665
  renderHeight: this.denoisingManager?._lastRenderHeight || this.canvas.clientHeight || 1
13640
- });
13666
+ }), this._container = this._container || this.canvas.parentNode || null, this.overlayManager.mount(this._container);
13641
13667
  }
13642
13668
  _syncControlsAfterLoad() {
13643
13669
  this.cameraManager.controls.saveState(), this.cameraManager.controls.update();