| | |
| | | import { useState, useMemo, useRef, useEffect } from 'react'; |
| | | import { useMemo } from 'react'; |
| | | import { useGLTF } from '@react-three/drei'; |
| | | import { MODEL_SHELF_SCALE } from '@/config/setting'; |
| | | import * as Common from '../utils/common'; |
| | | import * as THREE from 'three'; |
| | | import { MODEL_SHELF_SCALE } from '@/config/setting' |
| | | |
| | | const Shelf = (props) => { |
| | | const { position = [0, 300, 0], rotationY = 0 } = props; |
| | | |
| | | const model = useMemo(() => { |
| | | const fbx = useGLTF('/models/shelf/row.glb'); |
| | | if (!fbx.castShadow) { |
| | | Common.setShadow(fbx); |
| | | } |
| | | fbx.scale.set(MODEL_SHELF_SCALE, MODEL_SHELF_SCALE, MODEL_SHELF_SCALE); |
| | | return fbx.clone(); |
| | | }, []) |
| | | const { scene } = useGLTF('/models/shelf/row.glb'); |
| | | console.log(scene); |
| | | |
| | | useEffect(() => { |
| | | |
| | | }, []); |
| | | const model = useMemo(() => scene.clone(), [scene]); |
| | | |
| | | return ( |
| | | <> |
| | | <group rotation-y={rotationY} position={position}> |
| | | <primitive object={model} castShadow /> |
| | | </group> |
| | | <mesh position={position}> |
| | | <boxGeometry args={[50, 50, 50]} /> |
| | | <meshStandardMaterial color={'hotpink'} /> |
| | | </mesh> |
| | | {/* <group rotation-y={rotationY} position={position}> |
| | | <primitive |
| | | object={model} |
| | | castShadow |
| | | receiveShadow |
| | | scale={[MODEL_SHELF_SCALE, MODEL_SHELF_SCALE, MODEL_SHELF_SCALE]} |
| | | /> |
| | | </group> */} |
| | | </> |
| | | ) |
| | | } |