@lovelace_lol/loom3 1.0.11 → 1.0.12

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
@@ -4055,6 +4055,28 @@ var _Loom3 = class _Loom3 {
4055
4055
  * Resolve morph key to direct targets for ultra-fast repeated access.
4056
4056
  * Use this when you need to set the same morph many times (e.g., in animation loops).
4057
4057
  */
4058
+ resolveMorphTargetIndex(dict, key) {
4059
+ if (!dict) return void 0;
4060
+ const prefix = this.config.morphPrefix || "";
4061
+ const suffix = this.config.morphSuffix || "";
4062
+ const fullName = prefix + key + suffix;
4063
+ const exactIndex = dict[fullName];
4064
+ if (exactIndex !== void 0) {
4065
+ return exactIndex;
4066
+ }
4067
+ const suffixRegex = this.config.suffixPattern ? new RegExp(this.config.suffixPattern) : null;
4068
+ if (!suffixRegex) {
4069
+ return void 0;
4070
+ }
4071
+ for (const [candidate, index] of Object.entries(dict)) {
4072
+ if (!candidate.startsWith(fullName)) continue;
4073
+ const candidateSuffix = candidate.slice(fullName.length);
4074
+ if (candidateSuffix === "" || suffixRegex.test(candidateSuffix)) {
4075
+ return index;
4076
+ }
4077
+ }
4078
+ return void 0;
4079
+ }
4058
4080
  resolveMorphTargets(key, meshNames) {
4059
4081
  const targetMeshes = meshNames || this.config.morphToMesh?.face || [];
4060
4082
  const cacheKey = this.getMorphKeyCacheKey(key, meshNames);
@@ -4067,7 +4089,7 @@ var _Loom3 = class _Loom3 {
4067
4089
  const dict = mesh.morphTargetDictionary;
4068
4090
  const infl = mesh.morphTargetInfluences;
4069
4091
  if (!dict || !infl) continue;
4070
- const idx = dict[key];
4092
+ const idx = this.resolveMorphTargetIndex(dict, key);
4071
4093
  if (idx !== void 0) {
4072
4094
  targets.push({ infl, idx });
4073
4095
  }
@@ -4558,7 +4580,7 @@ var _Loom3 = class _Loom3 {
4558
4580
  const dict = this.faceMesh.morphTargetDictionary;
4559
4581
  const infl = this.faceMesh.morphTargetInfluences;
4560
4582
  if (dict && infl) {
4561
- const idx = dict[key];
4583
+ const idx = this.resolveMorphTargetIndex(dict, key);
4562
4584
  if (idx !== void 0) return infl[idx] ?? 0;
4563
4585
  }
4564
4586
  return 0;
@@ -4567,7 +4589,7 @@ var _Loom3 = class _Loom3 {
4567
4589
  const dict = mesh.morphTargetDictionary;
4568
4590
  const infl = mesh.morphTargetInfluences;
4569
4591
  if (!dict || !infl) continue;
4570
- const idx = dict[key];
4592
+ const idx = this.resolveMorphTargetIndex(dict, key);
4571
4593
  if (idx !== void 0) return infl[idx] ?? 0;
4572
4594
  }
4573
4595
  return 0;