@babylonjs/loaders 9.33.2 → 9.34.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.
@@ -293,7 +293,8 @@ export declare class FBXFileLoader implements ISceneLoaderPluginAsync, ISceneLoa
293
293
  /**
294
294
  * Baked keys are interpolated linearly by Babylon. Between two frames an FBX cubic segment can deviate from that
295
295
  * line, so sample times are refined (midpoints inserted, up to two levels) wherever the interpolated transform
296
- * differs noticeably from the curve. Flat and linear segments stay at frame resolution.
296
+ * differs noticeably from the curve. Rotations are normalized so quaternion length error cannot trigger subdivision.
297
+ * Flat and linear segments stay at frame resolution.
297
298
  */
298
299
  private static _refineSampleTimes;
299
300
  /**
@@ -2452,6 +2452,7 @@ export class FBXFileLoader {
2452
2452
  if (!sampledModelIds.has(boneData.modelId) || !md || cn.length === 0) {
2453
2453
  continue;
2454
2454
  }
2455
+ // Refine the original intervals for every bone so the depth limit applies to the whole rig.
2455
2456
  for (const time of FBXFileLoader._refineSampleTimes(baseTimes, (time) => this._sampleModelLocalMatrix(md, cn, time))) {
2456
2457
  refinedTimes.add(time);
2457
2458
  }
@@ -2648,7 +2649,8 @@ export class FBXFileLoader {
2648
2649
  /**
2649
2650
  * Baked keys are interpolated linearly by Babylon. Between two frames an FBX cubic segment can deviate from that
2650
2651
  * line, so sample times are refined (midpoints inserted, up to two levels) wherever the interpolated transform
2651
- * differs noticeably from the curve. Flat and linear segments stay at frame resolution.
2652
+ * differs noticeably from the curve. Rotations are normalized so quaternion length error cannot trigger subdivision.
2653
+ * Flat and linear segments stay at frame resolution.
2652
2654
  */
2653
2655
  static _refineSampleTimes(times, sample, maxDepth = 2) {
2654
2656
  const decompose = (time) => {
@@ -2656,6 +2658,7 @@ export class FBXFileLoader {
2656
2658
  const r = new Quaternion();
2657
2659
  const t = new Vector3();
2658
2660
  sample(time).decompose(s, r, t);
2661
+ r.normalize();
2659
2662
  return { s, r, t };
2660
2663
  };
2661
2664
  const out = [];
@@ -2670,7 +2673,7 @@ export class FBXFileLoader {
2670
2673
  const dm = decompose(tm);
2671
2674
  const lerpT = Vector3.Lerp(d0.t, d1.t, 0.5);
2672
2675
  const lerpS = Vector3.Lerp(d0.s, d1.s, 0.5);
2673
- const slerpR = Quaternion.Slerp(d0.r, d1.r, 0.5);
2676
+ const slerpR = Quaternion.Slerp(d0.r, d1.r, 0.5).normalize();
2674
2677
  const posErr = Vector3.Distance(lerpT, dm.t);
2675
2678
  const sclErr = Vector3.Distance(lerpS, dm.s);
2676
2679
  const dot = Math.min(1, Math.abs(Quaternion.Dot(slerpR, dm.r)));