#Dynamic animations
29 messages · Page 1 of 1 (latest)
this is the structure of the external animation that I want to insert in the scene. (I removed the tracks for the print)
and I got these errors
it shouldn't matter where the animations come from but that code executes in the render function and that's not good. animation is a side effect. the view the mixer wants to animate doesn't exist at that point. it needs to run inside useeffect
btw, useAnimation already creates clips for you, no need to do that yourself
here's an animation example, the important part is that it's all running in Models useEffect https://codesandbox.io/s/pecl6
however using useAnimation I only get static animations, if I want to add more animations to the same model I would have to do a new upload, it is not desired to use another .glb for another pack of new animations
ah ok, still, executing this in the function body isn't possible, needs to be in a useEffect
and works?
i got theses errors
it's like not finding the model to make the animation
I found this difference in "_localRoot" using the actions of the animations imported from the model and the action imported externally
yes, animations are super specific, the tree has to exist exactly the same with all the groups and names present
how do you render the model?
can you show me a snap of that?
I used the useGLTF hook
const { nodes, materials, scene, animations } = useGLTF(pathLisa)
i think that's the problem, "scene" is empty
in threejs an object can only ever be added to a parent once. if you do this
parent1.add(foo)
parent2.add(foo)
foo will be child of parent2
you need to give it a reference to the actual scene:
const ref = useRef()
<Controller scene={ref}
...
useEffect(() => {
scene.current
and make sure the ref points to the first object, not the outer group, group name=scene should be the one
if this is too hard to figure out you can put it online as a codesandbox. i've never used foreign animation on a foreign scene before but i imagine it will work if it targets the correct scene
I changed "lisaRef" to "lisaRef.current" on line 58 and it didn't give an error, but the animation still didn't happen
should the uuid be the same in _localRoot?