@sage-rsc/talking-head-react 1.0.47 → 1.0.49

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.47",
3
+ "version": "1.0.49",
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",
@@ -106,7 +106,7 @@ const CurriculumLearning = forwardRef(({
106
106
  ttsApiKey: avatarConfig.ttsApiKey || null,
107
107
  bodyMovement: avatarConfig.bodyMovement || "gesturing",
108
108
  movementIntensity: avatarConfig.movementIntensity || 0.7,
109
- showFullAvatar: avatarConfig.showFullAvatar !== undefined ? avatarConfig.showFullAvatar : true,
109
+ showFullAvatar: avatarConfig.showFullAvatar !== undefined ? avatarConfig.showFullAvatar : false,
110
110
  animations: animations,
111
111
  lipsyncLang: 'en'
112
112
  });
@@ -141,7 +141,7 @@ const CurriculumLearning = forwardRef(({
141
141
  ttsApiKey: avatarConfig.ttsApiKey || null,
142
142
  bodyMovement: avatarConfig.bodyMovement || "gesturing",
143
143
  movementIntensity: avatarConfig.movementIntensity || 0.7,
144
- showFullAvatar: avatarConfig.showFullAvatar !== undefined ? avatarConfig.showFullAvatar : true,
144
+ showFullAvatar: avatarConfig.showFullAvatar !== undefined ? avatarConfig.showFullAvatar : false,
145
145
  animations: animations,
146
146
  lipsyncLang: 'en'
147
147
  };
@@ -186,7 +186,7 @@ const CurriculumLearning = forwardRef(({
186
186
  let feedbackMessage = `Congratulations! You've completed this lesson`;
187
187
  if (stateRef.current.totalQuestions > 0) {
188
188
  feedbackMessage += ` with a score of ${stateRef.current.score} out of ${stateRef.current.totalQuestions} (${percentage}%). `;
189
- } else {
189
+ } else {
190
190
  feedbackMessage += `! `;
191
191
  }
192
192
 
@@ -321,7 +321,7 @@ const CurriculumLearning = forwardRef(({
321
321
  avatarRef.current.speakText(`Now let me ask you some questions. Here's the first one: ${firstQuestion.question}`, { lipsyncLang: config.lipsyncLang });
322
322
  } else if (firstQuestion.type === 'true_false') {
323
323
  avatarRef.current.speakText(`Let's start with some true or false questions. First question: ${firstQuestion.question}`, { lipsyncLang: config.lipsyncLang });
324
- } else {
324
+ } else {
325
325
  avatarRef.current.speakText(`Now let me ask you some questions. Here's the first one: ${firstQuestion.question}`, { lipsyncLang: config.lipsyncLang });
326
326
  }
327
327
  } else if (avatarRef.current && avatarRef.current.isReady) {
@@ -358,7 +358,7 @@ const CurriculumLearning = forwardRef(({
358
358
  }
359
359
 
360
360
  if (avatarRef.current && nextQuestionObj) {
361
- avatarRef.current.setMood("happy");
361
+ avatarRef.current.setMood("happy");
362
362
  avatarRef.current.setBodyMovement("idle");
363
363
 
364
364
  // Play custom animation if available
@@ -435,9 +435,9 @@ const CurriculumLearning = forwardRef(({
435
435
  lessonIndex: stateRef.current.currentLessonIndex,
436
436
  lesson: getCurrentLesson()
437
437
  });
438
-
439
- if (avatarRef.current) {
440
- avatarRef.current.setMood("happy");
438
+
439
+ if (avatarRef.current) {
440
+ avatarRef.current.setMood("happy");
441
441
  avatarRef.current.setBodyMovement("idle");
442
442
  }
443
443
  } else {
@@ -468,11 +468,11 @@ const CurriculumLearning = forwardRef(({
468
468
  lessonIndex: stateRef.current.currentLessonIndex,
469
469
  lesson: getCurrentLesson()
470
470
  });
471
-
472
- if (avatarRef.current) {
471
+
472
+ if (avatarRef.current) {
473
473
  avatarRef.current.setMood("happy");
474
474
  avatarRef.current.setBodyMovement("idle");
475
- }
475
+ }
476
476
  } else {
477
477
  // No more modules or lessons - complete curriculum
478
478
  if (completeCurriculumRef.current) {
@@ -823,7 +823,7 @@ const CurriculumLearning = forwardRef(({
823
823
  ttsApiKey: null,
824
824
  bodyMovement: "gesturing",
825
825
  movementIntensity: 0.7,
826
- showFullAvatar: true,
826
+ showFullAvatar: false,
827
827
  animations: animations,
828
828
  lipsyncLang: 'en'
829
829
  };
@@ -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);