Skip to content

Commit

Permalink
feat: added new female animations
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepat0 committed Oct 21, 2024
1 parent 639ae4e commit 8f26840
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -50,7 +52,6 @@ const baseActions: Record<string, BaseAction> = {
Loading3: { weight: 0 },
};


export const AvatarView: React.FC<Props & { halfBody: boolean }> = ({
stopProcessing,
chatEmission,
Expand Down Expand Up @@ -95,9 +96,7 @@ export const AvatarView: React.FC<Props & { halfBody: boolean }> = ({
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ interface FullbodyAvatarProps {
emotionMorphTargets: Record<string, number>;
}


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);

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 = {
Expand All @@ -60,7 +59,6 @@ const BLINK_CONFIG = {
const EMOTION_SMOOTHING = 0.3;
const VISME_SMOOTHING = 0.5;


export default function FullbodyAvatar({
url,
sex,
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -273,12 +274,7 @@ export default function FullbodyAvatar({

mixerRef.current?.update(0.01);
},
[
actions,
emotionMorphTargets,
eyeBlink,
updateCurrentViseme,
]
[actions, emotionMorphTargets, eyeBlink, updateCurrentViseme]
);

useFrame(state => {
Expand Down
4 changes: 2 additions & 2 deletions src/context/visemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit 8f26840

Please sign in to comment.