@lovelace_lol/loom3 1.0.1 → 1.0.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/index.cjs CHANGED
@@ -25,6 +25,20 @@ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
25
25
  var __defProp = Object.defineProperty;
26
26
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
27
27
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
28
+
29
+ // src/engines/three/balanceUtils.ts
30
+ function clampBalance(value) {
31
+ if (!Number.isFinite(value)) return 0;
32
+ return Math.max(-1, Math.min(1, value));
33
+ }
34
+ function resolveCurveBalance(curveId, globalBalance, balanceMap) {
35
+ if (balanceMap && Object.prototype.hasOwnProperty.call(balanceMap, curveId)) {
36
+ return clampBalance(Number(balanceMap[curveId]));
37
+ }
38
+ return clampBalance(globalBalance);
39
+ }
40
+
41
+ // src/engines/three/AnimationThree.ts
28
42
  var easeInOutQuad = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
29
43
  var AnimationThree = class {
30
44
  constructor() {
@@ -384,7 +398,8 @@ var BakedAnimationController = class {
384
398
  }
385
399
  const tracks = [];
386
400
  const intensityScale = options?.intensityScale ?? 1;
387
- const balance = options?.balance ?? 0;
401
+ const globalBalance = options?.balance ?? 0;
402
+ const balanceMap = options?.balanceMap;
388
403
  const meshNames = options?.meshNames;
389
404
  let maxTime = 0;
390
405
  const isNumericAU = (id) => /^\d+$/.test(id);
@@ -440,9 +455,10 @@ var BakedAnimationController = class {
440
455
  const leftKeys = morphsBySide?.left ?? [];
441
456
  const rightKeys = morphsBySide?.right ?? [];
442
457
  const centerKeys = morphsBySide?.center ?? [];
458
+ const curveBalance = resolveCurveBalance(curveId, globalBalance, balanceMap);
443
459
  for (const morphKey of leftKeys) {
444
460
  let effectiveScale = intensityScale * mixWeight;
445
- if (balance > 0) effectiveScale *= 1 - balance;
461
+ if (curveBalance > 0) effectiveScale *= 1 - curveBalance;
446
462
  if (typeof morphKey === "number") {
447
463
  this.addMorphIndexTracks(tracks, morphKey, keyframes, effectiveScale, meshNames);
448
464
  } else {
@@ -451,7 +467,7 @@ var BakedAnimationController = class {
451
467
  }
452
468
  for (const morphKey of rightKeys) {
453
469
  let effectiveScale = intensityScale * mixWeight;
454
- if (balance < 0) effectiveScale *= 1 + balance;
470
+ if (curveBalance < 0) effectiveScale *= 1 + curveBalance;
455
471
  if (typeof morphKey === "number") {
456
472
  this.addMorphIndexTracks(tracks, morphKey, keyframes, effectiveScale, meshNames);
457
473
  } else {