#
luxiaotao1123
2024-04-23 1c367ba22bb5ba35b3a2de45f23af675d50eeff4
#
2个文件已删除
2个文件已修改
42 ■■■■ 已修改文件
public/models/shelf/Horse.glb 补丁 | 查看 | 原始文档 | blame | 历史
public/models/shelf/row.fbx 补丁 | 查看 | 原始文档 | blame | 历史
src/components/shelf.jsx 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/base.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/models/shelf/Horse.glb
Binary files differ
public/models/shelf/row.fbx
Binary files differ
src/components/shelf.jsx
@@ -1,58 +1,27 @@
import { useMemo } from 'react';
import { useMemo, useState, useEffect } from 'react';
import { useGLTF } from '@react-three/drei';
import * as THREE from 'three';
import { MODEL_SHELF_SCALE } from '@/config/setting'
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
const generateScene = async () => {
    const loader = new GLTFLoader();
    const dracoLoader = new DRACOLoader();
    dracoLoader.setDecoderPath('/draco/');
    loader.setDRACOLoader(dracoLoader);
    return await new Promise((resolve, reject) => {
        loader.load('/models/shelf/row.glb', function (mesh) {
            console.log(mesh);
            resolve(mesh.scene)
        })
    })
}
const Shelf = (props) => {
    const { position = [0, 300, 0], rotationY = 0 } = props;
    const dracoLoader = new DRACOLoader();
    dracoLoader.setDecoderPath('draco/');
    useGLTF.setDecoderPath('/draco/');
    // const { scene } = useGLTF('/models/shelf/row.glb', '/draco/');
    const { nodes, materials } = useGLTF('/models/shelf/row.glb');
    console.log(nodes);
    const { nodes: nodes1, materials1, animations } = useGLTF('/models/shelf/Horse.glb');
    return (
        <>
            <group rotation-y={rotationY} position={position}>
                <primitive object={generateScene()} />
                <mesh
                <primitive
                    castShadow
                    receiveShadow
                    geometry={nodes.物件_1001.geometry}
                    object={nodes.物件_1001}
                    material={materials['材质_1.002']}
                    position={[0, 2, 0.3]}
                    rotation={[Math.PI / 2, 0, Math.PI / 2]}
                    scale={70}
                />
                <mesh
                    castShadow
                    receiveShadow
                    geometry={nodes1.mesh_0.geometry}
                    material={nodes1.mesh_0.material}
                    morphTargetDictionary={nodes1.mesh_0.morphTargetDictionary}
                    morphTargetInfluences={nodes1.mesh_0.morphTargetInfluences}
                    position={[0, 0, 0]}
                    scale={10000}
                />
            </group>
        </>
src/pages/base.jsx
@@ -26,7 +26,6 @@
                <TreeGroup />
                <House />
                <Warehouse />
                <Demo position={[0, 0, 0]} />
                <OrbitControls />
                <Environment background preset="night" />
                <Help />