| | |
| | | import { useFBX, useAnimations } from '@react-three/drei'; |
| | | import * as THREE from 'three'; |
| | | import Box from './box'; |
| | | import * as Common from '../utils/common' |
| | | |
| | | const setShadow = (obj) => { |
| | | obj.castShadow = true; |
| | | obj.receiveShadow = true; |
| | | |
| | | if (obj.children) { |
| | | obj.children.forEach((child) => { |
| | | setShadow(child); |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const setColor = (obj) => { |
| | | if (obj.material) { |
| | | obj.material.color.set(0x4680BF); |
| | | } |
| | | if (obj.children) { |
| | | obj.children.forEach((child) => { |
| | | setColor(child); |
| | | }); |
| | | } |
| | | }; |
| | | let lastData = {}; |
| | | |
| | | const Agv = (props) => { |
| | | const { } = props; |
| | | const { position, theta } = props; |
| | | |
| | | useEffect(() => { |
| | | console.log(position); |
| | | console.log(theta); |
| | | |
| | | }, [props]); |
| | | |
| | | const bodyModel = useMemo(() => { |
| | | const fbx = useFBX('/models/agv/body.fbx'); |
| | | if (!fbx.castShadow) { |
| | | setShadow(fbx); |
| | | Common.setShadow(fbx); |
| | | } |
| | | return fbx.clone(); |
| | | }, []) |
| | |
| | | const loaderModel = useMemo(() => { |
| | | const fbx = useFBX('/models/agv/loader.fbx'); |
| | | if (!fbx.castShadow) { |
| | | setShadow(fbx); |
| | | Common.setShadow(fbx); |
| | | } |
| | | return fbx.clone(); |
| | | }, []) |
| | |
| | | const forkModel = useMemo(() => { |
| | | const fbx = useFBX('/models/agv/fork.fbx'); |
| | | if (!fbx.castShadow) { |
| | | setShadow(fbx); |
| | | Common.setShadow(fbx); |
| | | } |
| | | return fbx.clone(); |
| | | }, []) |
| | | |
| | | useEffect(() => { |
| | | |
| | | }, []); |
| | | |
| | | return ( |
| | | <> |
| | | <group rotation={[0, 0, 0]} scale={0.5} position={[0, 0, 0]}> |
| | | <group rotation-y={Common.rotationParseNum(theta)} scale={0.5} position={position}> |
| | | <primitive object={bodyModel} castShadow /> |
| | | <primitive object={loaderModel} castShadow position={[0, 100, 0]} /> |
| | | <primitive object={forkModel} castShadow position={[0, 120, 0]} /> |