ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
// src/ModelViewer.jsimport React,{ useRef} from 'react';import { Canvas } from '@react-three/fiber';import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';import { Suspense } from 'react';import { Html, useGLTF, useProgress } from '@react-three/drei';import { useFrame } from '@react-three/fiber'; // please correct your modal path/* const Model = () => { const gltf = useGLTF('/Soldier.glb'); return }; */const Model = () => { const gltf = useGLTF('/Soldier.glb'); const modelRef = useRef(); // Animate the model useFrame(() => { // Example rotation animation (rotates around Y-axis) modelRef.current.rotation.y += 0.01; }); return ; };const Loading = () => { const { progress } = useProgress(); return Loading {progress} %;};const ModelViewer = () => { return ( ); }; export default ModelViewer;
// src/ModelViewer.js
import React,{ useRef} from 'react';
import { Canvas } from '@react-three/fiber';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { Suspense } from 'react';
import { Html, useGLTF, useProgress } from '@react-three/drei';
import { useFrame } from '@react-three/fiber';
// please correct your modal path
/* const Model = () => {
const gltf = useGLTF('/Soldier.glb');
return
}; */
const Model = () => {
const gltf = useGLTF('/Soldier.glb');
const modelRef = useRef();
// Animate the model
useFrame(() => {
// Example rotation animation (rotates around Y-axis)
modelRef.current.rotation.y += 0.01;
});
return ;
};
const Loading = () => {
const { progress } = useProgress();
return Loading {progress} %;
};
const ModelViewer = () => {
return (
);
};
export default ModelViewer;