@sage-rsc/talking-head-react 1.0.48 → 1.0.50

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.0.48",
3
+ "version": "1.0.50",
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",
@@ -49,9 +49,15 @@ const TalkingHeadAvatar = forwardRef(({
49
49
  }, ref) => {
50
50
  const containerRef = useRef(null);
51
51
  const talkingHeadRef = useRef(null);
52
+ const showFullAvatarRef = useRef(showFullAvatar);
52
53
  const [isLoading, setIsLoading] = useState(true);
53
54
  const [error, setError] = useState(null);
54
55
  const [isReady, setIsReady] = useState(false);
56
+
57
+ // Update ref when prop changes
58
+ useEffect(() => {
59
+ showFullAvatarRef.current = showFullAvatar;
60
+ }, [showFullAvatar]);
55
61
 
56
62
  // Get TTS configuration
57
63
  const ttsConfig = getActiveTTSConfig();
@@ -450,9 +456,10 @@ const TalkingHeadAvatar = forwardRef(({
450
456
  animationName = animations[animationName];
451
457
  }
452
458
 
459
+ // Respect the showFullAvatar prop value instead of forcing true
453
460
  if (talkingHeadRef.current.setShowFullAvatar) {
454
461
  try {
455
- talkingHeadRef.current.setShowFullAvatar(true);
462
+ talkingHeadRef.current.setShowFullAvatar(showFullAvatarRef.current);
456
463
  } catch (error) {
457
464
  console.warn('Error setting full body mode:', error);
458
465
  }
@@ -517,7 +524,8 @@ const TalkingHeadAvatar = forwardRef(({
517
524
  setBodyMovement: (movement) => {
518
525
  if (talkingHeadRef.current && talkingHeadRef.current.setShowFullAvatar && talkingHeadRef.current.setBodyMovement) {
519
526
  try {
520
- talkingHeadRef.current.setShowFullAvatar(true);
527
+ // Respect the showFullAvatar prop value instead of forcing true
528
+ talkingHeadRef.current.setShowFullAvatar(showFullAvatarRef.current);
521
529
  talkingHeadRef.current.setBodyMovement(movement);
522
530
  } catch (error) {
523
531
  console.warn('Error setting body movement:', error);
@@ -528,7 +536,8 @@ const TalkingHeadAvatar = forwardRef(({
528
536
  playRandomDance: () => {
529
537
  if (talkingHeadRef.current && talkingHeadRef.current.setShowFullAvatar && talkingHeadRef.current.playRandomDance) {
530
538
  try {
531
- talkingHeadRef.current.setShowFullAvatar(true);
539
+ // Respect the showFullAvatar prop value instead of forcing true
540
+ talkingHeadRef.current.setShowFullAvatar(showFullAvatarRef.current);
532
541
  talkingHeadRef.current.playRandomDance();
533
542
  } catch (error) {
534
543
  console.warn('Error playing random dance:', error);
@@ -538,7 +547,8 @@ const TalkingHeadAvatar = forwardRef(({
538
547
  playReaction: (reactionType) => {
539
548
  if (talkingHeadRef.current && talkingHeadRef.current.setShowFullAvatar && talkingHeadRef.current.playReaction) {
540
549
  try {
541
- talkingHeadRef.current.setShowFullAvatar(true);
550
+ // Respect the showFullAvatar prop value instead of forcing true
551
+ talkingHeadRef.current.setShowFullAvatar(showFullAvatarRef.current);
542
552
  talkingHeadRef.current.playReaction(reactionType);
543
553
  } catch (error) {
544
554
  console.warn('Error playing reaction:', error);
@@ -548,7 +558,8 @@ const TalkingHeadAvatar = forwardRef(({
548
558
  playCelebration: () => {
549
559
  if (talkingHeadRef.current && talkingHeadRef.current.setShowFullAvatar && talkingHeadRef.current.playCelebration) {
550
560
  try {
551
- talkingHeadRef.current.setShowFullAvatar(true);
561
+ // Respect the showFullAvatar prop value instead of forcing true
562
+ talkingHeadRef.current.setShowFullAvatar(showFullAvatarRef.current);
552
563
  talkingHeadRef.current.playCelebration();
553
564
  } catch (error) {
554
565
  console.warn('Error playing celebration:', error);
@@ -558,6 +569,8 @@ const TalkingHeadAvatar = forwardRef(({
558
569
  setShowFullAvatar: (show) => {
559
570
  if (talkingHeadRef.current && talkingHeadRef.current.setShowFullAvatar) {
560
571
  try {
572
+ // Update ref so other methods use the new value
573
+ showFullAvatarRef.current = show;
561
574
  talkingHeadRef.current.setShowFullAvatar(show);
562
575
  } catch (error) {
563
576
  console.warn('Error setting showFullAvatar:', error);
@@ -2100,14 +2100,14 @@ class TalkingHead {
2100
2100
 
2101
2101
  console.log('Body movement set to:', movement);
2102
2102
 
2103
- // Ensure avatar is in full body mode for body movements
2104
- if (movement !== 'idle') {
2105
- this.setShowFullAvatar(true);
2106
- // Don't lock position for code-based animations - they should be stable by design
2107
- } else {
2103
+ // Respect the current showFullAvatar setting instead of forcing it to true
2104
+ // Only unlock position when returning to idle
2105
+ if (movement === 'idle') {
2108
2106
  // Unlock position when returning to idle
2109
2107
  this.unlockAvatarPosition();
2110
2108
  }
2109
+ // Note: We no longer force showFullAvatar to true for body movements
2110
+ // The avatar will use whatever showFullAvatar value was set by the user
2111
2111
 
2112
2112
  // Apply body movement animation
2113
2113
  this.applyBodyMovementAnimation();