@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A reusable React component for 3D talking avatars with lip-sync and text-to-speech",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -2214,38 +2214,35 @@ class TalkingHead {
2214
2214
  console.log('Original position stored:', this.originalPosition);
2215
2215
  }
2216
2216
 
2217
- // Move avatar UP initially to compensate for FBX animation downward movement
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: 0, // Keep centered horizontally
2223
- y: upwardOffset, // Set to the upward offset directly
2224
- z: 0 // Keep centered horizontally
2219
+ x: this.armature.position.x,
2220
+ y: this.armature.position.y,
2221
+ z: this.armature.position.z
2225
2222
  };
2226
2223
 
2227
- // Set the avatar to the higher position
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 reset to center.
2228
+ * Unlock avatar position and restore original position.
2241
2229
  */
2242
2230
  unlockAvatarPosition() {
2243
- if (this.armature) {
2244
- // Reset avatar to center (0,0,0) when animation finishes
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
- // Allow some downward movement but prevent excessive movement
2258
- // This lets FBX animations move the avatar down to the correct position
2259
- const currentY = this.armature.position.y;
2260
- const minY = this.lockedPosition.y - 2.0; // Allow up to 2.0 units down from locked position
2261
- const maxY = this.lockedPosition.y + 0.1; // Prevent moving up too much
2262
-
2263
- if (currentY < minY) {
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