#
luxiaotao1123
2024-04-24 ef1c6cacf5aa4b2bcce35eb3b7bae2db95692edd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { useState, useMemo, useRef, useEffect } from 'react';
import { useFrame } from '@react-three/fiber';
import { useFBX, useAnimations } from '@react-three/drei';
import * as THREE from 'three';
import { MODEL_BOX_SCALE } from '@/config/setting'
import * as Common from '../utils/common';
 
const Box = (props) => {
    const { position = [0, 300, 0], rotationY = 0 } = props;
 
    const boxModel = useMemo(() => {
        const fbx = useFBX('/models/box/box.fbx');
        if (!fbx.castShadow) {
            Common.setShadow(fbx);
        }
        fbx.scale.set(MODEL_BOX_SCALE, MODEL_BOX_SCALE, MODEL_BOX_SCALE);
        return fbx.clone();
    }, [])
 
    useEffect(() => {
 
    }, []);
 
    return (
        <>
            <group rotation-y={rotationY} position={position}>
                <primitive object={boxModel} castShadow />
            </group>
        </>
    )
}
 
export default Box;