From 8f26840c4c4d395171941d0e7345e5aabc3ab724 Mon Sep 17 00:00:00 2001 From: andrepat0 Date: Mon, 21 Oct 2024 12:47:33 +0200 Subject: [PATCH] feat: added new female animations --- .../AvatarComponent/avatarComponent.tsx | 9 ++++----- .../components/fullbodyAvatar.tsx | 16 ++++++---------- src/context/visemeContext.tsx | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx b/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx index 96a55258..c247475b 100644 --- a/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +++ b/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx @@ -16,7 +16,9 @@ interface Props { chatEmission: any; stopProcessing: () => void; resetVisemeQueue: () => void; - updateCurrentViseme: (currentTime: number) => { name: string; weight: number } | null; + updateCurrentViseme: ( + currentTime: number + ) => { name: string; weight: number } | null; } interface BaseAction { @@ -50,7 +52,6 @@ const baseActions: Record = { Loading3: { weight: 0 }, }; - export const AvatarView: React.FC = ({ stopProcessing, chatEmission, @@ -95,9 +96,7 @@ export const AvatarView: React.FC = ({ Loading: { Loading1: 1, Loading2: 1, Loading3: 1 }, }; - //remove the last character from the action - const newEmotion = action.slice(0, -1); - // setEmotion(newEmotion); + // console.log('action', action); const defaultEmotions = Object.keys(emotionMap).reduce((acc, key) => { acc[key] = 0; diff --git a/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx b/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx index 6c4335a6..2ea64947 100644 --- a/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx +++ b/src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx @@ -40,7 +40,6 @@ interface FullbodyAvatarProps { emotionMorphTargets: Record; } - const AVATAR_POSITION = new Vector3(0, -1, 0); const AVATAR_ROTATION = new Euler(0.175, 0, 0); const AVATAR_POSITION_ZOOMED = new Vector3(0, -1.45, 0); @@ -48,7 +47,7 @@ const AVATAR_POSITION_ZOOMED = new Vector3(0, -1.45, 0); const ANIMATION_URLS = { MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb', FEMALE: - 'https://assets.memori.ai/api/v2/asset/0e49aa5d-f757-4292-a170-d843c2839a41.glb', + 'https://assets.memori.ai/api/v2/asset/8d1a5853-f05a-4a34-9f99-6eff64986081.glb', }; const BLINK_CONFIG = { @@ -60,7 +59,6 @@ const BLINK_CONFIG = { const EMOTION_SMOOTHING = 0.3; const VISME_SMOOTHING = 0.5; - export default function FullbodyAvatar({ url, sex, @@ -204,7 +202,10 @@ export default function FullbodyAvatar({ const index = headMeshRef.current!.morphTargetDictionary![key]; if (typeof index === 'number') { currentEmotionRef.current[key] = 0; - if (headMeshRef.current && headMeshRef.current.morphTargetInfluences) { + if ( + headMeshRef.current && + headMeshRef.current.morphTargetInfluences + ) { headMeshRef.current.morphTargetInfluences[index] = 0; } } @@ -273,12 +274,7 @@ export default function FullbodyAvatar({ mixerRef.current?.update(0.01); }, - [ - actions, - emotionMorphTargets, - eyeBlink, - updateCurrentViseme, - ] + [actions, emotionMorphTargets, eyeBlink, updateCurrentViseme] ); useFrame(state => { diff --git a/src/context/visemeContext.tsx b/src/context/visemeContext.tsx index a2b06f72..77ede03b 100644 --- a/src/context/visemeContext.tsx +++ b/src/context/visemeContext.tsx @@ -89,7 +89,7 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({ const updateCurrentViseme = useCallback( (currentTime: number): Viseme | null => { if (!isProcessing || startTimeRef.current === null) { - console.log('StartTimeRef not set'); + //console.log('StartTimeRef not set'); return null; } @@ -106,7 +106,7 @@ export const VisemeProvider: React.FC<{ children: React.ReactNode }> = ({ ); if (currentViseme) { - console.log('CurrentViseme Found!'); + //console.log('CurrentViseme Found!'); const visemeProgress = (elapsedTime - currentViseme.startTime) / (currentViseme.endTime - currentViseme.startTime);