fix how it work loading issue
This commit is contained in:
@@ -32,6 +32,7 @@ import React, { useLayoutEffect } from 'react'
|
||||
import { useGLTF } from '@react-three/drei'
|
||||
|
||||
const GLB = '/models/3d_scene_final.glb'
|
||||
const DRACO_PATH = '/draco/' // self-hosted decoder (public/draco/)
|
||||
|
||||
// Tyre meshes in the exact order the rig expects: [FR, FL, RL, RR]. Order is
|
||||
// load-bearing — animateWheels() flips spin direction by index parity.
|
||||
@@ -61,7 +62,10 @@ const BG_TREE_MAT_RX = /background_tree_atlas/i
|
||||
const matName = (o) => (Array.isArray(o.material) ? o.material[0]?.name : o.material?.name) || ''
|
||||
|
||||
export function Model({ truckRef, wheelRefs, tier = 'desktop', /* dashboardRefs (unused) */ ...props }) {
|
||||
const { scene } = useGLTF(GLB)
|
||||
// String arg = self-hosted Draco decoder path: the GLB is Draco-compressed
|
||||
// geometry + WebP textures (31 MB → 3.7 MB). Self-hosting (vs the gstatic CDN)
|
||||
// keeps this static-export site free of an external runtime dependency.
|
||||
const { scene } = useGLTF(GLB, DRACO_PATH)
|
||||
|
||||
// useLayoutEffect: wire refs + prune before first paint so TruckAnimation /
|
||||
// CameraRig (which run in useFrame) see a fully-configured graph on frame 1.
|
||||
@@ -125,4 +129,4 @@ export function Model({ truckRef, wheelRefs, tier = 'desktop', /* dashboardRefs
|
||||
return <primitive object={scene} {...props} dispose={null} />
|
||||
}
|
||||
|
||||
useGLTF.preload(GLB)
|
||||
useGLTF.preload(GLB, DRACO_PATH)
|
||||
|
||||
Reference in New Issue
Block a user