@sage-rsc/talking-head-react 1.1.0 → 1.1.1
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 +2 -2
- package/dist/index.js +261 -273
- package/package.json +1 -1
- package/src/lib/talkinghead.mjs +24 -45
package/package.json
CHANGED
package/src/lib/talkinghead.mjs
CHANGED
|
@@ -2214,38 +2214,35 @@ class TalkingHead {
|
|
|
2214
2214
|
console.log('Original position stored:', this.originalPosition);
|
|
2215
2215
|
}
|
|
2216
2216
|
|
|
2217
|
-
//
|
|
2218
|
-
// Set a higher base position so FBX animations land in the center
|
|
2219
|
-
const upwardOffset = 2.0; // Even more upward movement
|
|
2220
|
-
|
|
2217
|
+
// Lock the avatar at its CURRENT position (don't move it)
|
|
2221
2218
|
this.lockedPosition = {
|
|
2222
|
-
x:
|
|
2223
|
-
y:
|
|
2224
|
-
z:
|
|
2219
|
+
x: this.armature.position.x,
|
|
2220
|
+
y: this.armature.position.y,
|
|
2221
|
+
z: this.armature.position.z
|
|
2225
2222
|
};
|
|
2226
2223
|
|
|
2227
|
-
|
|
2228
|
-
this.armature.position.set(
|
|
2229
|
-
this.lockedPosition.x,
|
|
2230
|
-
this.lockedPosition.y,
|
|
2231
|
-
this.lockedPosition.z
|
|
2232
|
-
);
|
|
2233
|
-
|
|
2234
|
-
console.log('BEFORE: Avatar position was:', this.armature.position.x, this.armature.position.y, this.armature.position.z);
|
|
2235
|
-
console.log('AFTER: Avatar position moved up and locked at:', this.lockedPosition);
|
|
2236
|
-
console.log('Current view:', this.viewName);
|
|
2224
|
+
console.log('Avatar position locked at current position:', this.lockedPosition);
|
|
2237
2225
|
}
|
|
2238
2226
|
|
|
2239
2227
|
/**
|
|
2240
|
-
* Unlock avatar position and
|
|
2228
|
+
* Unlock avatar position and restore original position.
|
|
2241
2229
|
*/
|
|
2242
2230
|
unlockAvatarPosition() {
|
|
2243
|
-
if (this.armature) {
|
|
2244
|
-
//
|
|
2231
|
+
if (this.armature && this.originalPosition) {
|
|
2232
|
+
// Restore avatar to its original position before locking
|
|
2233
|
+
this.armature.position.set(
|
|
2234
|
+
this.originalPosition.x,
|
|
2235
|
+
this.originalPosition.y,
|
|
2236
|
+
this.originalPosition.z
|
|
2237
|
+
);
|
|
2238
|
+
console.log('Avatar position restored to original:', this.originalPosition);
|
|
2239
|
+
} else if (this.armature) {
|
|
2240
|
+
// Fallback: reset to center if no original position was stored
|
|
2245
2241
|
this.armature.position.set(0, 0, 0);
|
|
2246
2242
|
console.log('Avatar position reset to center (0,0,0)');
|
|
2247
2243
|
}
|
|
2248
2244
|
this.lockedPosition = null;
|
|
2245
|
+
this.originalPosition = null; // Clear original position after unlock
|
|
2249
2246
|
console.log('Avatar position unlocked');
|
|
2250
2247
|
}
|
|
2251
2248
|
|
|
@@ -2254,31 +2251,13 @@ class TalkingHead {
|
|
|
2254
2251
|
*/
|
|
2255
2252
|
maintainLockedPosition() {
|
|
2256
2253
|
if (this.lockedPosition && this.armature) {
|
|
2257
|
-
//
|
|
2258
|
-
// This
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
// If moved too far down, bring it back up
|
|
2265
|
-
this.armature.position.set(
|
|
2266
|
-
this.lockedPosition.x,
|
|
2267
|
-
minY,
|
|
2268
|
-
this.lockedPosition.z
|
|
2269
|
-
);
|
|
2270
|
-
} else if (currentY > maxY) {
|
|
2271
|
-
// If moved too far up, bring it back down
|
|
2272
|
-
this.armature.position.set(
|
|
2273
|
-
this.lockedPosition.x,
|
|
2274
|
-
maxY,
|
|
2275
|
-
this.lockedPosition.z
|
|
2276
|
-
);
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
// Always maintain X and Z position
|
|
2280
|
-
this.armature.position.x = this.lockedPosition.x;
|
|
2281
|
-
this.armature.position.z = this.lockedPosition.z;
|
|
2254
|
+
// Enforce the locked position - keep avatar exactly where it was locked
|
|
2255
|
+
// This prevents FBX animations from moving the avatar
|
|
2256
|
+
this.armature.position.set(
|
|
2257
|
+
this.lockedPosition.x,
|
|
2258
|
+
this.lockedPosition.y,
|
|
2259
|
+
this.lockedPosition.z
|
|
2260
|
+
);
|
|
2282
2261
|
}
|
|
2283
2262
|
}
|
|
2284
2263
|
|