Skip to content

Commit

Permalink
fix: reintroduced head movement for half body avatar and removed unus…
Browse files Browse the repository at this point in the history
…ed speaking prop
  • Loading branch information
andrepat0 committed Nov 12, 2024
1 parent 6b599e4 commit df4eb7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const AvatarView: React.FC<Props & { halfBody: boolean }> = ({
sex,
eyeBlink,
headMovement,
speaking,
// speaking,
halfBody,
loading,
isZoomed,
Expand Down Expand Up @@ -219,6 +219,7 @@ export const AvatarView: React.FC<Props & { halfBody: boolean }> = ({
updateCurrentViseme={updateCurrentViseme}
avatarHeight={avatarHeight || 50}
avatarDepth={avatarDepth || -50}
headMovement={headMovement}
/>
) : (
<FullbodyAvatar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useRef } from 'react';
import { MathUtils, Object3D, SkinnedMesh, Vector3 } from 'three';
import { useEffect, useMemo, useRef } from 'react';
import { Object3D, SkinnedMesh } from 'three';
import { useGLTF } from '@react-three/drei';
import { useGraph, useFrame, useThree } from '@react-three/fiber';
import { correctMaterials, isSkinnedMesh } from '../../../../../helpers/utils';
Expand All @@ -11,20 +11,20 @@ import {
AVATAR_POSITION_ZOOMED,
} from './constants';
import { hideHands } from '../../utils/utils';
import useHeadMovement from '../../utils/useHeadMovement';

interface HalfBodyAvatarProps {
url: string;
setMorphTargetInfluences: (morphTargetInfluences: any) => void;
setMorphTargetDictionary: (morphTargetDictionary: any) => void;
updateCurrentViseme: (currentTime: number) => any;
eyeBlink?: boolean;
isZoomed?: boolean;
heightValue?: number; // 0-100 slider value
avatarHeight: number;
avatarDepth: number;
morphTargetSmoothing?: number;
onLoaded?: () => void;
onCameraZChange: (value: number) => void;
headMovement?: boolean;
}

export default function HalfBodyAvatar({
Expand All @@ -33,10 +33,9 @@ export default function HalfBodyAvatar({
setMorphTargetDictionary,
updateCurrentViseme,
eyeBlink = false,
isZoomed = false,
avatarHeight = 50,
avatarDepth = 0,
morphTargetSmoothing = 0.5,
headMovement = false,
onLoaded,
onCameraZChange,
}: HalfBodyAvatarProps) {
Expand All @@ -47,6 +46,9 @@ export default function HalfBodyAvatar({
const morphTargetControllerRef = useRef<MorphTargetController>();
const positionControllerRef = useRef<AvatarPositionController>();
const targetCameraZRef = useRef(camera.position.z);


useHeadMovement(headMovement, nodes);

const blinkStateRef = useRef({
isBlinking: false,
Expand Down

0 comments on commit df4eb7e

Please sign in to comment.