diff --git a/packages/core/src/material-library.ts b/packages/core/src/material-library.ts index ca1ab1b93..074b07e5f 100644 --- a/packages/core/src/material-library.ts +++ b/packages/core/src/material-library.ts @@ -4187,13 +4187,14 @@ export function toSceneMaterialRef(id: string) { } export function getLibraryMaterialIdFromRef(materialRef?: string | null) { - if (!materialRef) return null + if (typeof materialRef !== 'string') return null if (!materialRef.startsWith(LIBRARY_MATERIAL_REF_PREFIX)) return null return materialRef.slice(LIBRARY_MATERIAL_REF_PREFIX.length) } export function getSceneMaterialIdFromRef(materialRef?: string | null): string | null { - if (!materialRef?.startsWith(SCENE_MATERIAL_REF_PREFIX)) return null + if (typeof materialRef !== 'string') return null + if (!materialRef.startsWith(SCENE_MATERIAL_REF_PREFIX)) return null return materialRef.slice(SCENE_MATERIAL_REF_PREFIX.length) }