GLb animation Issue With useAnimation Hooks in R3F

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ธ.ค. 2024

ความคิดเห็น • 1

  • @paradise_hope
    @paradise_hope  6 หลายเดือนก่อน

    //mode1.jsx --------> here i m usinf useAnimation hook to play animation
    // Scene.js
    import React, { useRef } from 'react';
    import { useLoader, useFrame } from '@react-three/fiber';
    import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
    import * as THREE from 'three'
    import { Canvas } from '@react-three/fiber';
    import { OrbitControls, useAnimations } from '@react-three/drei';
    const Scene = () => {
    const modelRef=useRef()
    const { scene, animations } = useLoader(GLTFLoader, '/SM.glb');
    const { actions } = useAnimations(animations, modelRef);
    console.log("actions animation",actions)
    useFrame((state, delta) => {
    //console.log("useFram runing....")
    actions.Running.play()
    //actions.walking.play()
    });


    return (

    );
    };
    export default Scene