From 07e8e33114cf97a8f10b871d6e4c5d3addd28c7a Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 26 四月 2024 14:39:59 +0800 Subject: [PATCH] # --- src/store/index.js | 2 +- src/components/box.jsx | 8 +++++--- src/components/shelf.jsx | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/box.jsx b/src/components/box.jsx index 425e6d5..42ab356 100644 --- a/src/components/box.jsx +++ b/src/components/box.jsx @@ -4,10 +4,12 @@ import * as THREE from 'three'; import { MODEL_BOX_SCALE } from '@/config/setting' import * as Common from '../utils/common'; +import { useStore } from '@/store'; const Box = (props) => { const { position = [0, 300, 0], rotationY = 0 } = props; - + const state = useStore(); + const boxModel = useMemo(() => { const fbx = useFBX('/models/box/box.fbx'); if (!fbx.castShadow) { @@ -18,8 +20,8 @@ }, []) useEffect(() => { - - }, []); + console.log(state.shelfList['1-1-1']); + }, [props]); return ( <> diff --git a/src/components/shelf.jsx b/src/components/shelf.jsx index 065358c..5347d8a 100644 --- a/src/components/shelf.jsx +++ b/src/components/shelf.jsx @@ -2,7 +2,6 @@ import { useGLTF, useFBX } from '@react-three/drei'; import * as THREE from 'three'; import { MODEL_SHELF_SCALE } from '@/config/setting' -import { snapshot } from 'valtio'; import { useStore } from '@/store'; import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; @@ -18,7 +17,7 @@ }, []) useEffect(() => { - snapshot(state).models[no] = position; + state.shelfList[no] = position; }, [props]); return ( diff --git a/src/store/index.js b/src/store/index.js index adcceb6..b8505d2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,7 +4,7 @@ const store = proxy( { text: 'Hello World', - shelf: {}, + shelfList: {}, } ); -- Gitblit v1.9.1