@@ -3,7 +3,6 @@ import { useAnimations } from '@react-three/drei'
33import { useFrame } from '@react-three/fiber'
44import { useEffect } from 'react'
55
6- import idleUrl from '~/assets/motions/converted/idle.vrma?url'
76import walkUrl from '~/assets/motions/converted/walk.vrma?url'
87
98const vrmUrl = import . meta. env . DEV
@@ -15,33 +14,17 @@ useVRM.preload(vrmUrl)
1514
1615export const HikariMixamoVrma = ( ) => {
1716 const vrm = useVRM ( vrmUrl )
18- const idle = useVRMAnimation ( idleUrl , vrm , 'idle' )
1917 const walk = useVRMAnimation ( walkUrl , vrm , 'walk' )
2018
21- const { actions, names } = useAnimations ( [ idle , walk ] , vrm . scene )
19+ const { actions } = useAnimations ( [ walk ] , vrm . scene )
2220
2321 useEffect ( ( ) => {
24- let index : 0 | 1 = 0
25-
26- // eslint-disable-next-line @masknet/no-timer
27- const loop = setInterval ( ( ) => {
28- Object . values ( actions ) [ index ] ?. stop ( )
29- console . warn ( 'Stopped:' , names [ index ] )
30-
31- if ( index === 1 )
32- index = 0
33- else
34- index = 1
35-
36- Object . values ( actions ) [ index ] ?. reset ( ) . play ( )
37- console . warn ( 'Playing:' , names [ index ] )
38- } , 5000 )
22+ actions . walk ?. reset ( ) . play ( )
3923
4024 return ( ) => {
41- // eslint-disable-next-line @masknet/no-timer
42- clearInterval ( loop )
25+ actions . walk ?. stop ( )
4326 }
44- } , [ actions , names ] )
27+ } , [ actions ] )
4528
4629 useFrame ( ( _ , delta ) => vrm . update ( delta ) )
4730
0 commit comments