fix: add disposal on unmount in SkyModel and SimpleModel

This commit is contained in:
Tom Boullay
2026-05-14 00:15:52 +02:00
parent b3a3f3557c
commit 260bfea716
2 changed files with 17 additions and 3 deletions
+8 -1
View File
@@ -1,6 +1,7 @@
import { useMemo } from "react";
import { useEffect, useMemo } from "react";
import { useLoggedGLTF } from "@/hooks/three/useLoggedGLTF";
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
import { disposeObject3D } from "@/utils/three/dispose";
export interface SimpleModelConfig extends ModelTransformProps {
modelPath: string;
@@ -29,6 +30,12 @@ export function SimpleModel({
});
const model = useMemo(() => scene.clone(true), [scene]);
useEffect(() => {
return () => {
disposeObject3D(model);
};
}, [model]);
const parsedScale =
typeof scale === "number" ? ([scale, scale, scale] as Vector3Tuple) : scale;