rayzee 4.8.12 → 4.8.14

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
@@ -178,6 +178,7 @@ const engine = new PathTracerApp(canvas, options?)
178
178
  |---|---|---|
179
179
  | `canvas` | `HTMLCanvasElement` | Rendering target |
180
180
  | `options.autoResize` | `boolean` | Auto-resize on window resize (default: `true`) |
181
+ | `options.showStats` | `boolean` | Show the performance stats panel (default: `true`) |
181
182
  | `options.statsContainer` | `HTMLElement` | DOM element to append the stats panel to (defaults to `document.body`) |
182
183
 
183
184
  #### Lifecycle
@@ -233,6 +234,7 @@ Key settings:
233
234
  | `focalLength` | `number` | 50 | DOF focal length (mm) |
234
235
  | `adaptiveSampling` | `boolean` | false | Variance-guided sample distribution |
235
236
  | `transparentBackground` | `boolean` | false | Transparent canvas background |
237
+ | `interactionModeEnabled` | `boolean` | true | Lower quality during camera movement for smoother navigation |
236
238
  | `debugMode` | `number` | 0 | Debug visualization mode (0 = off) |
237
239
  | `environmentMode` | `string` | 'hdri' | Sky mode: `'hdri'` \| `'procedural'` \| `'gradient'` \| `'color'` |
238
240
 
@@ -540,6 +542,30 @@ OIDN provides high-quality AI denoising for final renders. It runs automatically
540
542
 
541
543
  ## Troubleshooting
542
544
 
545
+ **OIDN: `Cannot find module './tza'` (webpack)**
546
+ The `oidn-web` package uses dynamic imports that webpack cannot resolve. This does not affect Vite or other ESM-native bundlers. Add `oidn-web` to your webpack externals:
547
+
548
+ ```js
549
+ // webpack.config.js
550
+ module.exports = {
551
+ externals: {
552
+ 'oidn-web': 'oidn-web'
553
+ }
554
+ };
555
+ ```
556
+
557
+ Then load it via a script tag or import map instead:
558
+
559
+ ```html
560
+ <script type="importmap">
561
+ {
562
+ "imports": {
563
+ "oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.0/+esm"
564
+ }
565
+ }
566
+ </script>
567
+ ```
568
+
543
569
  **Black screen / "WebGPU not supported"**
544
570
  Your browser may not support WebGPU. Use Chrome 113+, Edge 113+, Safari 18+, or Firefox 141+. Ensure you're on HTTPS or localhost.
545
571
 
package/dist/rayzee.es.js CHANGED
@@ -2181,10 +2181,10 @@ var Xr = X("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3
2181
2181
  let t = z(1).sub(o).sub(s), r = $(n, a, B(6), B(ui)), c = $(n, a, B(7), B(ui));
2182
2182
  i.uv.assign(r.xy.mul(t).add(r.zw.mul(o)).add(c.xy.mul(s))), i.triangleIndex.assign(a);
2183
2183
  }), i;
2184
- }), bi = M(([e, t, n, r]) => {
2185
- let i = Tr({
2184
+ }), bi = M(([e, t, n, r, i]) => {
2185
+ let a = Tr({
2186
2186
  didHit: !1,
2187
- dst: z(0x56bc75e2d63100000),
2187
+ dst: i,
2188
2188
  hitPoint: J(0),
2189
2189
  normal: J(0),
2190
2190
  uv: q(0),
@@ -2192,62 +2192,62 @@ var Xr = X("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3
2192
2192
  meshIndex: B(-1),
2193
2193
  boxTests: B(0),
2194
2194
  triTests: B(0)
2195
- }).toVar(), a = fi(), o = B(1).toVar();
2196
- a.element(B(0)).assign(B(0));
2197
- let s = H(J(1), pt(e.direction), ct(e.direction, J(0))), c = H(J(1).div(e.direction), J(di).mul(s), nt(F(e.direction), J(1e-8))).toVar(), l = B(0).toVar();
2198
- return P(o.greaterThan(B(0)).and(i.didHit.not()).and(l.lessThan(B(ci))), () => {
2199
- l.addAssign(1), o.subAssign(1);
2200
- let s = a.element(o).toVar(), u = $(t, s, B(0), B(li));
2201
- N(u.w.lessThan(0), () => {
2202
- N(u.w.greaterThan(z(-1.5)), () => {
2203
- let t = B(u.x).toVar(), a = B(u.y).toVar();
2195
+ }).toVar(), o = fi(), s = B(1).toVar();
2196
+ o.element(B(0)).assign(B(0));
2197
+ let c = H(J(1), pt(e.direction), ct(e.direction, J(0))), l = H(J(1).div(e.direction), J(di).mul(c), nt(F(e.direction), J(1e-8))).toVar(), u = B(0).toVar();
2198
+ return P(s.greaterThan(B(0)).and(a.didHit.not()).and(u.lessThan(B(ci))), () => {
2199
+ u.addAssign(1), s.subAssign(1);
2200
+ let i = o.element(s).toVar(), c = $(t, i, B(0), B(li));
2201
+ N(c.w.lessThan(0), () => {
2202
+ N(c.w.greaterThan(z(-1.5)), () => {
2203
+ let t = B(c.x).toVar(), i = B(c.y).toVar();
2204
2204
  P({
2205
2205
  start: B(0),
2206
- end: a
2207
- }, ({ i: a }) => {
2208
- let o = t.add(a).toVar(), s = $(n, o, B(0), B(ui)).xyz, c = $(n, o, B(1), B(ui)).xyz, l = $(n, o, B(2), B(ui)).xyz, u = pi({
2206
+ end: i
2207
+ }, ({ i }) => {
2208
+ let o = t.add(i).toVar(), s = $(n, o, B(0), B(ui)).xyz, c = $(n, o, B(1), B(ui)).xyz, l = $(n, o, B(2), B(ui)).xyz, u = pi({
2209
2209
  rayOrigin: e.origin,
2210
2210
  rayDir: e.direction,
2211
2211
  pA: s,
2212
2212
  pB: c,
2213
2213
  pC: l,
2214
- closestHitDst: i.dst
2214
+ closestHitDst: a.dst
2215
2215
  });
2216
2216
  N(u.w.greaterThan(.5), () => {
2217
- let t = $(n, o, B(7), B(ui)), a = B(t.z);
2218
- N(gi(a, r), () => {
2219
- i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(a), i.meshIndex.assign(B(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.normal.assign(U(Xe(c.sub(s), l.sub(s)))), He();
2217
+ let t = $(n, o, B(7), B(ui)), i = B(t.z);
2218
+ N(gi(i, r), () => {
2219
+ a.didHit.assign(!0), a.dst.assign(u.x), a.materialIndex.assign(i), a.meshIndex.assign(B(t.w)), a.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), a.normal.assign(U(Xe(c.sub(s), l.sub(s)))), He();
2220
2220
  });
2221
2221
  });
2222
2222
  });
2223
2223
  }).Else(() => {
2224
- let e = B(u.x).toVar();
2225
- N(o.lessThan(B(si)), () => {
2226
- a.element(o).assign(e), o.addAssign(1);
2224
+ let e = B(c.x).toVar();
2225
+ N(s.lessThan(B(si)), () => {
2226
+ o.element(s).assign(e), s.addAssign(1);
2227
2227
  });
2228
2228
  });
2229
2229
  }).Else(() => {
2230
- let n = $(t, s, B(1), B(li)), r = $(t, s, B(2), B(li)), l = $(t, s, B(3), B(li)), d = B(u.w).toVar(), f = B(n.w).toVar(), p = mi({
2230
+ let n = $(t, i, B(1), B(li)), r = $(t, i, B(2), B(li)), u = $(t, i, B(3), B(li)), d = B(c.w).toVar(), f = B(n.w).toVar(), p = mi({
2231
2231
  rayOrigin: e.origin,
2232
- invDir: c,
2233
- boxMin: u.xyz,
2232
+ invDir: l,
2233
+ boxMin: c.xyz,
2234
2234
  boxMax: n.xyz
2235
2235
  }).toVar(), m = mi({
2236
2236
  rayOrigin: e.origin,
2237
- invDir: c,
2237
+ invDir: l,
2238
2238
  boxMin: r.xyz,
2239
- boxMax: l.xyz
2239
+ boxMax: u.xyz
2240
2240
  }).toVar();
2241
- N(ot(p, m).lessThan(i.dst), () => {
2241
+ N(ot(p, m).lessThan(a.dst), () => {
2242
2242
  let e = p.lessThan(m), t = W(e, d, f).toVar(), n = W(e, f, d).toVar();
2243
- N(W(e, m, p).toVar().lessThan(i.dst).and(o.lessThan(B(si))), () => {
2244
- a.element(o).assign(n), o.addAssign(1);
2245
- }), N(o.lessThan(B(si)), () => {
2246
- a.element(o).assign(t), o.addAssign(1);
2243
+ N(W(e, m, p).toVar().lessThan(a.dst).and(s.lessThan(B(si))), () => {
2244
+ o.element(s).assign(n), s.addAssign(1);
2245
+ }), N(s.lessThan(B(si)), () => {
2246
+ o.element(s).assign(t), s.addAssign(1);
2247
2247
  });
2248
2248
  });
2249
2249
  });
2250
- }), i;
2250
+ }), a;
2251
2251
  }), xi = M(([e, t, n, r, i, a, o, s, c, l, u]) => {
2252
2252
  let d = J(e.xy, 1), f = r.mul(Y(d, 1)), p = U(at(n[0].xyz, n[1].xyz, n[2].xyz).mul(f.xyz.div(f.w))).toVar(), m = J(n[3]).toVar(), h = m.toVar(), g = p.toVar();
2253
2253
  return N(i.and(a.greaterThan(0)).and(o.lessThan(64)).and(s.greaterThan(.001)), () => {
@@ -3228,7 +3228,7 @@ M(([e, t, n]) => {
3228
3228
  }), r;
3229
3229
  });
3230
3230
  var qa = M(([e, t, n, r, i, a, o, s]) => {
3231
- let c = z(1).toVar(), l = e.toVar();
3231
+ let c = z(1).toVar(), l = e.toVar(), u = z(n).toVar();
3232
3232
  return P({
3233
3233
  start: B(0),
3234
3234
  end: B(8)
@@ -3236,25 +3236,25 @@ var qa = M(([e, t, n, r, i, a, o, s]) => {
3236
3236
  let e = Cr({
3237
3237
  origin: l,
3238
3238
  direction: t
3239
- }), r = Tr.wrap(i(e, a, o, s));
3240
- N(r.didHit.not().or(r.dst.greaterThan(n)), () => {
3239
+ }), n = Tr.wrap(i(e, a, o, s, u));
3240
+ N(n.didHit.not(), () => {
3241
3241
  He();
3242
3242
  });
3243
- let u = wr.wrap(ii(r.materialIndex, s));
3244
- N(u.transmission.greaterThan(0), () => {
3245
- let e = R(t, r.normal).lessThan(0), n = W(e, r.normal, r.normal.negate());
3246
- N(e.not().and(u.attenuationDistance.greaterThan(0)), () => {
3247
- let e = tt(r.hitPoint.sub(l)), t = Ca(u.attenuationColor, u.attenuationDistance, e);
3243
+ let r = wr.wrap(ii(n.materialIndex, s));
3244
+ N(r.transmission.greaterThan(0), () => {
3245
+ let e = R(t, n.normal).lessThan(0), i = W(e, n.normal, n.normal.negate());
3246
+ N(e.not().and(r.attenuationDistance.greaterThan(0)), () => {
3247
+ let e = tt(n.hitPoint.sub(l)), t = Ca(r.attenuationColor, r.attenuationDistance, e);
3248
3248
  c.mulAssign(t.x.add(t.y).add(t.z).div(3));
3249
3249
  });
3250
- let i = qi(F(R(t, n)), Zi(u.ior, z(1))), a = z(1).sub(i).mul(u.transmission);
3251
- c.mulAssign(a), N(c.lessThan(.005), () => {
3250
+ let a = qi(F(R(t, i)), Zi(r.ior, z(1))), o = z(1).sub(a).mul(r.transmission);
3251
+ c.mulAssign(o), N(c.lessThan(.005), () => {
3252
3252
  c.assign(0), He();
3253
- }), l.assign(r.hitPoint.add(t.mul(.001)));
3254
- }).ElseIf(u.transparent, () => {
3255
- c.mulAssign(z(1).sub(u.opacity)), N(c.lessThan(.005), () => {
3253
+ }), l.assign(n.hitPoint.add(t.mul(.001))), u.subAssign(n.dst.add(.001));
3254
+ }).ElseIf(r.transparent, () => {
3255
+ c.mulAssign(z(1).sub(r.opacity)), N(c.lessThan(.005), () => {
3256
3256
  c.assign(0), He();
3257
- }), l.assign(r.hitPoint.add(t.mul(.001)));
3257
+ }), l.assign(n.hitPoint.add(t.mul(.001))), u.subAssign(n.dst.add(.001));
3258
3258
  }).Else(() => {
3259
3259
  c.assign(0), He();
3260
3260
  });
@@ -11011,7 +11011,7 @@ var oc = class extends fn {
11011
11011
  e.traverse((e) => {
11012
11012
  let n = e.userData;
11013
11013
  if (e.isRectAreaLight && !t.includes(e.uuid) && t.push(e.uuid), e.name.startsWith("RectAreaLightPlaceholder") && n.name && n.type === "RectAreaLight") {
11014
- let r = new we(new v(...n.color), n.intensity, n.width, n.height);
11014
+ let r = new we(new v(...n.color), n.intensity / Math.PI, n.width, n.height);
11015
11015
  r.position.z = -2, r.name = n.name, e.add(r), t.push(r.uuid);
11016
11016
  }
11017
11017
  if (e.isMesh && Array.isArray(e.material)) {
@@ -11398,6 +11398,10 @@ var oc = class extends fn {
11398
11398
  uniform: "adaptiveSamplingMax",
11399
11399
  reset: !0
11400
11400
  },
11401
+ interactionModeEnabled: {
11402
+ handler: "handleInteractionModeEnabled",
11403
+ reset: !1
11404
+ },
11401
11405
  maxSamples: {
11402
11406
  handler: "handleMaxSamples",
11403
11407
  reset: !1
@@ -12842,7 +12846,7 @@ var Wc = new Float32Array(3), Gc = {
12842
12846
  }
12843
12847
  }, nl = class extends E {
12844
12848
  constructor(e, t = {}) {
12845
- super(), this.canvas = e, this.denoiserCanvas = null, this._autoResize = t.autoResize !== !1, this._statsContainer = t.statsContainer || null, this.settings = new Tc(Z), this.renderer = null, this._camera = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this._controls = null, this.assetLoader = null, this._sdf = null, this.animationManager = new Qc(), this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationId = null, this.needsReset = !1, this._renderCompleteDispatched = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.lastResetTime = performance.now(), this.timeElapsed = 0, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._resizeDebounceTimer = null, this._outputAPI = null, this._lightsAPI = null, this._animationAPI = null, this._selectionAPI = null, this._transformAPI = null, this._cameraAPI = null, this._environmentAPI = null, this._materialsAPI = null, this._denoisingAPI = null;
12849
+ super(), this.canvas = e, this.denoiserCanvas = null, this._autoResize = t.autoResize !== !1, this._showStats = t.showStats !== !1, this._statsContainer = t.statsContainer || null, this.settings = new Tc(Z), this.renderer = null, this._camera = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this._controls = null, this.assetLoader = null, this._sdf = null, this.animationManager = new Qc(), this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationId = null, this.needsReset = !1, this._renderCompleteDispatched = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.lastResetTime = performance.now(), this.timeElapsed = 0, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._resizeDebounceTimer = null, this._outputAPI = null, this._lightsAPI = null, this._animationAPI = null, this._selectionAPI = null, this._transformAPI = null, this._cameraAPI = null, this._environmentAPI = null, this._materialsAPI = null, this._denoisingAPI = null;
12846
12850
  }
12847
12851
  set(e, t, n) {
12848
12852
  this.settings.set(e, t, n);
@@ -12954,7 +12958,7 @@ var Wc = new Float32Array(3), Gc = {
12954
12958
  }, this.assetLoader.addEventListener("load", this._onAssetLoaded), this.assetLoader.addEventListener("modelProcessed", (e) => {
12955
12959
  let t = [this._camera, ...e.cameras || []];
12956
12960
  this.cameraManager.setCameras(t), this._floorPlane = this.assetLoader.floorPlane, this._interactionManager && (this._interactionManager.floorPlane = this._floorPlane);
12957
- }), 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._initStats(), this.isInitialized = !0, console.log("WebGPU Path Tracer App initialized"), this;
12961
+ }), 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._showStats && this._initStats(), this.isInitialized = !0, console.log("WebGPU Path Tracer App initialized"), this;
12958
12962
  }
12959
12963
  animate() {
12960
12964
  if (this.animationId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
@@ -13498,6 +13502,9 @@ var Wc = new Float32Array(3), Gc = {
13498
13502
  },
13499
13503
  handleEnvironmentRotation: (e) => {
13500
13504
  this.stages.pathTracer?.environment.setEnvironmentRotation(e);
13505
+ },
13506
+ handleInteractionModeEnabled: (e) => {
13507
+ this.setInteractionModeEnabled(e);
13501
13508
  }
13502
13509
  };
13503
13510
  }