Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Fix avatar animations not playing on cyberbots #8045

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const LoopAnimationComponent = defineComponent({

const animComponent = useOptionalComponent(entity, AnimationComponent)

const loopAnimationComponent = useOptionalComponent(entity, LoopAnimationComponent)
/**
* Callback functions
*/
Expand Down Expand Up @@ -85,12 +86,18 @@ export const LoopAnimationComponent = defineComponent({
const scene = modelComponent.scene.value

if (!hasComponent(entity, AnimationComponent)) {
addComponent(entity, AnimationComponent, {
setComponent(entity, AnimationComponent, {
mixer: new AnimationMixer(scene),
animationSpeed: 1,
animations: []
})
}
}, [modelComponent?.scene])

useEffect(() => {
if (!modelComponent?.scene?.value) return

const scene = modelComponent.scene.value

const loopComponent = getComponent(entity, LoopAnimationComponent)
const animationComponent = getComponent(entity, AnimationComponent)
Expand Down Expand Up @@ -126,7 +133,7 @@ export const LoopAnimationComponent = defineComponent({
}

if (!loopComponent.action?.paused) playAnimationClip(animationComponent, loopComponent)
}, [animComponent?.animations])
}, [animComponent?.animations, loopAnimationComponent?.hasAvatarAnimations])

return null
}
Expand Down