Implement asset management and loading functionality with Zustand; refactor error handling and update asset types

This commit is contained in:
2025-05-15 09:34:55 +05:30
parent 0134b64ca0
commit 6c4b298072
11 changed files with 489 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ async function loadInitialWallItems(
const loadedWallItems = await Promise.all(items.map(async (item: Types.WallItem) => {
// Check THREE.js cache first
const cachedModel = THREE.Cache.get(item.modelName!);
const cachedModel = THREE.Cache.get(item.modelfileID!);
if (cachedModel) {
return processModel(cachedModel, item);
}
@@ -45,7 +45,7 @@ async function loadInitialWallItems(
return new Promise<Types.WallItem>((resolve) => {
loader.load(blobUrl, (gltf) => {
URL.revokeObjectURL(blobUrl);
THREE.Cache.add(item.modelName!, gltf);
THREE.Cache.add(item.modelfileID!, gltf);
resolve(processModel(gltf, item));
});
});
@@ -58,8 +58,8 @@ async function loadInitialWallItems(
try {
// Cache the model
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
await storeGLTF(item.modelName!, modelBlob);
THREE.Cache.add(item.modelName!, gltf);
await storeGLTF(item.modelfileID!, modelBlob);
THREE.Cache.add(item.modelfileID!, gltf);
resolve(processModel(gltf, item));
} catch (error) {
console.error('Failed to cache model:', error);