From e6de6ddae28dec5bf092b66d77ee8d522d39ff04 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 26 四月 2024 14:04:43 +0800 Subject: [PATCH] # --- src/components/box.jsx | 31 ++++++------------------------- 1 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/components/box.jsx b/src/components/box.jsx index 5ca3bba..425e6d5 100644 --- a/src/components/box.jsx +++ b/src/components/box.jsx @@ -2,37 +2,18 @@ import { useFrame } from '@react-three/fiber'; import { useFBX, useAnimations } from '@react-three/drei'; import * as THREE from 'three'; - -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); - }); - } -}; +import { MODEL_BOX_SCALE } from '@/config/setting' +import * as Common from '../utils/common'; const Box = (props) => { - const { position = [0, 300, 0] } = props; + const { position = [0, 300, 0], rotationY = 0 } = props; const boxModel = useMemo(() => { const fbx = useFBX('/models/box/box.fbx'); if (!fbx.castShadow) { - setShadow(fbx); + Common.setShadow(fbx); } + fbx.scale.set(MODEL_BOX_SCALE, MODEL_BOX_SCALE, MODEL_BOX_SCALE); return fbx.clone(); }, []) @@ -42,7 +23,7 @@ return ( <> - <group rotation={[0, 0, 0]} scale={0.5} position={position}> + <group rotation-y={rotationY} position={position}> <primitive object={boxModel} castShadow /> </group> </> -- Gitblit v1.9.1