rayzee 9.3.1 → 9.3.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/dist/rayzee.es.js CHANGED
@@ -29095,7 +29095,7 @@ function Vv(e, t, n, r) {
29095
29095
  }
29096
29096
  //#endregion
29097
29097
  //#region src/version.js
29098
- var Hv = "9.3.1", Uv = 1e4, Wv = 15e5;
29098
+ var Hv = "9.3.2", Uv = 1e4, Wv = 15e5;
29099
29099
  function Gv(e, t, n = Uv) {
29100
29100
  return e >= n && t / Wv < e / 3;
29101
29101
  }
@@ -30178,19 +30178,28 @@ var dy = class {
30178
30178
  triRecordsPerChunk: this.triangles.recordsPerChunk
30179
30179
  });
30180
30180
  }
30181
- let i = this.instanceTable;
30181
+ let i = this.instanceTable, a = Mi.FLOATS_PER_TRIANGLE, o = [];
30182
30182
  for (let e = 0; e < i.count; e++) {
30183
30183
  if (!i.isSet[e] || !i.isOwner(e)) continue;
30184
30184
  let t = n(e);
30185
- if (t && (this._updateMeshTrianglePositions(e, t), r)) {
30185
+ if (!t) continue;
30186
+ if (this._updateMeshTrianglePositions(e, t), r) {
30186
30187
  let t = r(e);
30187
30188
  t && this._patchMeshSmoothNormals(e, t);
30188
30189
  }
30190
+ let s = i.triOffsetOf(e) * a, c = i.triCountOf(e) * a, l = o.at(-1);
30191
+ l && l.offset + l.count === s ? l.count += c : o.push({
30192
+ offset: s,
30193
+ count: c
30194
+ });
30189
30195
  }
30190
30196
  return new Promise((e, t) => {
30191
30197
  this._refitWorker.onmessage = (n) => {
30192
30198
  let r = n.data;
30193
- r.type === "refitComplete" ? e({ refitTimeMs: r.refitTimeMs }) : r.type === "error" && t(Error(r.error));
30199
+ r.type === "refitComplete" ? e({
30200
+ refitTimeMs: r.refitTimeMs,
30201
+ triRanges: o
30202
+ }) : r.type === "error" && t(Error(r.error));
30194
30203
  }, this._refitWorker.postMessage({ type: "refit" });
30195
30204
  });
30196
30205
  }
@@ -31154,8 +31163,8 @@ var vy = class {
31154
31163
  _updateStorageBuffer(e, t) {
31155
31164
  e && (e.array.set(t), e.clearUpdateRanges(), e.needsUpdate = !0);
31156
31165
  }
31157
- updateTriangleData(e) {
31158
- e?.chunks?.length > 1 ? this._triangleRecords = e : e && (this._triangleFlat = e.chunks ? e.chunks[0] : e), this._uploadTriangles(0, this._triangleRecordCount);
31166
+ updateTriangleData(e, t) {
31167
+ e?.chunks?.length > 1 ? this._triangleRecords = e : e && (this._triangleFlat = e.chunks ? e.chunks[0] : e), t ? this.updateBufferRanges(t, []) : this._uploadTriangles(0, this._triangleRecordCount);
31159
31168
  }
31160
31169
  updateBVHData(e) {
31161
31170
  if (this._bvhRecords) {
@@ -42278,7 +42287,7 @@ var yO = class extends Mn {
42278
42287
  this.camera = new yO(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Dr(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this._reportedOrthoHeight = null, this._reportOrthoHeight = this._reportOrthoHeight.bind(this), this.controls.addEventListener("change", this._reportOrthoHeight), this.walkControls = new FO(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = ji.SMOOTHING_FACTOR ? "auto" : "manual", this.afScreenPoint = {
42279
42288
  x: .5,
42280
42289
  y: .5
42281
- }, this.afSmoothingFactor = ji.SMOOTHING_FACTOR, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._afSuspended = !1, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null, this._applySettings = null;
42290
+ }, this.afSmoothingFactor = ji.SMOOTHING_FACTOR, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._afSuspended = !1, this._afPick = null, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null, this._applySettings = null;
42282
42291
  }
42283
42292
  setCameras(e) {
42284
42293
  this.cameras = e, this._userCameraCounter = 0, this.resetAutoFocus();
@@ -42571,8 +42580,8 @@ var yO = class extends Mn {
42571
42580
  this._afSuspended && (this._afSuspended = !1, this._smoothedFocusDistance = null);
42572
42581
  let l = a;
42573
42582
  if (l?.isReady && l.renderMode?.value === 1 && l.frameCount > 0 && !l.isComplete) return;
42574
- let u = this.interactionManager.pickSurface(this.afScreenPoint.x * 2 - 1, 1 - this.afScreenPoint.y * 2), d;
42575
- if (u) d = OC(u.point, this.camera), this._lastValidFocusDistance = d;
42583
+ let u = this._pickFocusPoint(l.resetCount), d;
42584
+ if (u) d = OC(u, this.camera), this._lastValidFocusDistance = d;
42576
42585
  else if (this._lastValidFocusDistance !== null) d = this._lastValidFocusDistance;
42577
42586
  else {
42578
42587
  let e = this.controls ? OC(this.controls.target, this.camera) : 0;
@@ -42593,6 +42602,22 @@ var yO = class extends Mn {
42593
42602
  f ? c?.() : n > ji.RESET_THRESHOLD && s?.();
42594
42603
  }
42595
42604
  }
42605
+ _pickFocusPoint(e) {
42606
+ let t = this.camera, { x: n, y: r } = this.afScreenPoint, i = this._afPick ??= {
42607
+ point: new ur(),
42608
+ hit: !1,
42609
+ resetCount: NaN,
42610
+ x: NaN,
42611
+ y: NaN,
42612
+ view: new yn(),
42613
+ projection: new yn()
42614
+ };
42615
+ if (this._afPointDirty || e !== i.resetCount || n !== i.x || r !== i.y || !i.view.equals(t.matrixWorld) || !i.projection.equals(t.projectionMatrix)) {
42616
+ let a = this.interactionManager.pickSurface(n * 2 - 1, 1 - r * 2);
42617
+ i.hit = !!a, a && i.point.copy(a.point), i.resetCount = e, i.x = n, i.y = r, i.view.copy(t.matrixWorld), i.projection.copy(t.projectionMatrix);
42618
+ }
42619
+ return i.hit ? i.point : null;
42620
+ }
42596
42621
  setInteractionManager(e) {
42597
42622
  this.interactionManager = e;
42598
42623
  }
@@ -45503,7 +45528,7 @@ var lA = 4096, uA = class {
45503
45528
  }
45504
45529
  }, mA = class extends en {
45505
45530
  constructor() {
45506
- super(), this.mixer = null, this.timer = new ir(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new ur(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this.wakeCallback = null, this.applyPoseCallback = null;
45531
+ super(), this.mixer = null, this.timer = new ir(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new ur(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null, this.wakeCallback = null, this.applyPoseCallback = null;
45507
45532
  }
45508
45533
  init(e, t, n, r) {
45509
45534
  if (this.dispose(), !r || r.length === 0) return;
@@ -45525,7 +45550,7 @@ var lA = 4096, uA = class {
45525
45550
  indices: r
45526
45551
  }), o += i;
45527
45552
  }
45528
- this._skinnedCache = [], this._meshPositions = [];
45553
+ this._skinnedCache = [], this._meshPositions = [], this._lastMeshWorld = this._rigid ? null : new Float64Array(n.length * 16).fill(NaN), this._lastMorphWeights = [];
45529
45554
  let s = n.filter((e) => e.isSkinnedMesh).length;
45530
45555
  console.debug(`[AnimationManager] Init: ${r.length} clips, ${n.length} meshes (${s} skinned), ${o} triangles, ${this._rigid ? "rigid" : "deforming"}`);
45531
45556
  }
@@ -45644,11 +45669,27 @@ var lA = 4096, uA = class {
45644
45669
  _poseReader() {
45645
45670
  if (this._mixerRoot.updateMatrixWorld(!0), this._rigid) return this._applyRigidPose(this._activeClip), null;
45646
45671
  let e = this._planFor(this._activeClip)?.cameras;
45647
- return e?.length && this.applyPoseCallback?.({
45672
+ e?.length && this.applyPoseCallback?.({
45648
45673
  meshIndices: [],
45649
45674
  visibilityChanged: !1,
45650
45675
  cameras: e
45651
- }), (e) => this._computeMeshPositions(e);
45676
+ });
45677
+ let t = new Int8Array(this._meshes.length);
45678
+ return (e) => (t[e] === 0 && (t[e] = this._meshes[e].isSkinnedMesh || this._poseChanged(e) ? 1 : -1), t[e] > 0 ? this._computeMeshPositions(e) : null);
45679
+ }
45680
+ _poseChanged(e) {
45681
+ let t = this._meshes[e], n = this._lastMeshWorld, r = t.matrixWorld.elements, i = e * 16, a = !1;
45682
+ for (let e = 0; e < 16; e++) if (n[i + e] !== r[e]) {
45683
+ for (let e = 0; e < 16; e++) n[i + e] = r[e];
45684
+ a = !0;
45685
+ break;
45686
+ }
45687
+ let o = t.morphTargetInfluences;
45688
+ if (o?.length) {
45689
+ let t = this._lastMorphWeights[e];
45690
+ (!t || t.length !== o.length || t.some((e, t) => e !== o[t])) && (this._lastMorphWeights[e] = Float64Array.from(o), a = !0);
45691
+ }
45692
+ return a;
45652
45693
  }
45653
45694
  _computeMeshPositions(e) {
45654
45695
  let t = this._tempVec, n = this._meshes[e], { count: r, uniqueVerts: i, indices: a } = this._meshTriRanges[e], o = this._scratch(this._skinnedCache, e, i * 3), s = this._scratch(this._meshPositions, e, r * 9), c = n.matrixWorld;
@@ -45677,7 +45718,7 @@ var lA = 4096, uA = class {
45677
45718
  }), this._clipsCache;
45678
45719
  }
45679
45720
  dispose() {
45680
- this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._skinnedCache = null, this._clipsCache = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null;
45721
+ this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._skinnedCache = null, this._clipsCache = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null;
45681
45722
  }
45682
45723
  }, hA = new ur(0, 0, -1), gA = (e) => {
45683
45724
  for (; e.parent;) e = e.parent;
@@ -46565,8 +46606,8 @@ var BA = class extends en {
46565
46606
  }
46566
46607
  async refitBVH(e, t) {
46567
46608
  await this.ensureSceneResident();
46568
- let n = await this._sdf.refitBVH(e, t);
46569
- return this.stages.pathTracer.updateTriangleData(this._sdf.triangles), this.stages.pathTracer.updateBVHData(this._sdf.bvh), this.reset(!1, { motion: !0 }), n;
46609
+ let { triRanges: n, ...r } = await this._sdf.refitBVH(e, t);
46610
+ return this.stages.pathTracer.updateTriangleData(this._sdf.triangles, n), this.stages.pathTracer.updateBVHData(this._sdf.bvh), this.reset(!1, { motion: !0 }), r;
46570
46611
  }
46571
46612
  refitBLASes(e, t, n) {
46572
46613
  if (this._sdf?.spilled) throw Error("refitBLASes: the scene is spilled to disk — await app.ensureSceneResident() first");