feat add model loading diagnostics

This commit is contained in:
Tom Boullay
2026-05-02 00:14:47 +02:00
parent 4d7d2efdcc
commit 1d64582383
13 changed files with 218 additions and 29 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useEffect, useRef } from "react";
import { useGLTF } from "@react-three/drei";
import {
logModelLoadSuccess,
type ModelLoadLogContext,
} from "@/utils/three/modelLoadLogger";
export function useLoggedGLTF(
modelPath: string,
context: Omit<ModelLoadLogContext, "modelPath">,
) {
const gltf = useGLTF(modelPath);
const hasLoggedRef = useRef(false);
const { position, rotation, scale, scope } = context;
useEffect(() => {
if (hasLoggedRef.current) return;
hasLoggedRef.current = true;
logModelLoadSuccess({ modelPath, position, rotation, scale, scope }, gltf);
}, [gltf, modelPath, position, rotation, scale, scope]);
return gltf;
}