@lovelace_lol/loom3 1.0.0 → 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/README.md +18 -18
- package/dist/index.cjs +19 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -519,6 +519,12 @@ interface ClipOptions {
|
|
|
519
519
|
mixerWeight?: number;
|
|
520
520
|
/** Left/right balance for bilateral AUs (-1 to 1, default: 0) */
|
|
521
521
|
balance?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Per-curve left/right balance overrides keyed by curve id (typically AU ids as strings).
|
|
524
|
+
* Example: { "43": 1, "12": 0.7 }.
|
|
525
|
+
* Falls back to `balance` when a curve id is not present.
|
|
526
|
+
*/
|
|
527
|
+
balanceMap?: Record<string, number>;
|
|
522
528
|
/** Jaw scale for viseme playback (default: 1.0) */
|
|
523
529
|
jawScale?: number;
|
|
524
530
|
/** Intensity scale multiplier (default: 1.0) */
|
package/dist/index.d.ts
CHANGED
|
@@ -519,6 +519,12 @@ interface ClipOptions {
|
|
|
519
519
|
mixerWeight?: number;
|
|
520
520
|
/** Left/right balance for bilateral AUs (-1 to 1, default: 0) */
|
|
521
521
|
balance?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Per-curve left/right balance overrides keyed by curve id (typically AU ids as strings).
|
|
524
|
+
* Example: { "43": 1, "12": 0.7 }.
|
|
525
|
+
* Falls back to `balance` when a curve id is not present.
|
|
526
|
+
*/
|
|
527
|
+
balanceMap?: Record<string, number>;
|
|
522
528
|
/** Jaw scale for viseme playback (default: 1.0) */
|
|
523
529
|
jawScale?: number;
|
|
524
530
|
/** Intensity scale multiplier (default: 1.0) */
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,20 @@ import { Vector3, Clock, Box3, Quaternion, LoopOnce, LoopPingPong, LoopRepeat, Q
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
|
|
8
|
+
// src/engines/three/balanceUtils.ts
|
|
9
|
+
function clampBalance(value) {
|
|
10
|
+
if (!Number.isFinite(value)) return 0;
|
|
11
|
+
return Math.max(-1, Math.min(1, value));
|
|
12
|
+
}
|
|
13
|
+
function resolveCurveBalance(curveId, globalBalance, balanceMap) {
|
|
14
|
+
if (balanceMap && Object.prototype.hasOwnProperty.call(balanceMap, curveId)) {
|
|
15
|
+
return clampBalance(Number(balanceMap[curveId]));
|
|
16
|
+
}
|
|
17
|
+
return clampBalance(globalBalance);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/engines/three/AnimationThree.ts
|
|
7
21
|
var easeInOutQuad = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
8
22
|
var AnimationThree = class {
|
|
9
23
|
constructor() {
|
|
@@ -363,7 +377,8 @@ var BakedAnimationController = class {
|
|
|
363
377
|
}
|
|
364
378
|
const tracks = [];
|
|
365
379
|
const intensityScale = options?.intensityScale ?? 1;
|
|
366
|
-
const
|
|
380
|
+
const globalBalance = options?.balance ?? 0;
|
|
381
|
+
const balanceMap = options?.balanceMap;
|
|
367
382
|
const meshNames = options?.meshNames;
|
|
368
383
|
let maxTime = 0;
|
|
369
384
|
const isNumericAU = (id) => /^\d+$/.test(id);
|
|
@@ -419,9 +434,10 @@ var BakedAnimationController = class {
|
|
|
419
434
|
const leftKeys = morphsBySide?.left ?? [];
|
|
420
435
|
const rightKeys = morphsBySide?.right ?? [];
|
|
421
436
|
const centerKeys = morphsBySide?.center ?? [];
|
|
437
|
+
const curveBalance = resolveCurveBalance(curveId, globalBalance, balanceMap);
|
|
422
438
|
for (const morphKey of leftKeys) {
|
|
423
439
|
let effectiveScale = intensityScale * mixWeight;
|
|
424
|
-
if (
|
|
440
|
+
if (curveBalance > 0) effectiveScale *= 1 - curveBalance;
|
|
425
441
|
if (typeof morphKey === "number") {
|
|
426
442
|
this.addMorphIndexTracks(tracks, morphKey, keyframes, effectiveScale, meshNames);
|
|
427
443
|
} else {
|
|
@@ -430,7 +446,7 @@ var BakedAnimationController = class {
|
|
|
430
446
|
}
|
|
431
447
|
for (const morphKey of rightKeys) {
|
|
432
448
|
let effectiveScale = intensityScale * mixWeight;
|
|
433
|
-
if (
|
|
449
|
+
if (curveBalance < 0) effectiveScale *= 1 + curveBalance;
|
|
434
450
|
if (typeof morphKey === "number") {
|
|
435
451
|
this.addMorphIndexTracks(tracks, morphKey, keyframes, effectiveScale, meshNames);
|
|
436
452
|
} else {
|