added wall asset visiblity toggle and code optimization

This commit is contained in:
2025-08-23 12:26:45 +05:30
parent 8b01372d08
commit 21cd12b518
15 changed files with 172 additions and 89 deletions

View File

@@ -1,8 +1,14 @@
import { Object3D } from 'three';
import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';
interface AssetsStore {
assets: Assets;
movedObjects: Object3D[];
rotatedObjects: Object3D[];
copiedObjects: Object3D[];
pastedObjects: Object3D[];
duplicatedObjects: Object3D[];
// Asset CRUD operations
addAsset: (asset: Asset) => void;
@@ -12,6 +18,12 @@ interface AssetsStore {
resetAsset: (modelUuid: string) => void;
setAssets: (assets: Assets) => void;
setMovedObjects: (objects: Object3D[]) => Object3D[];
setRotatedObjects: (objects: Object3D[]) => Object3D[];
setCopiedObjects: (objects: Object3D[]) => Object3D[];
setPastedObjects: (objects: Object3D[]) => Object3D[];
setDuplicatedObjects: (objects: Object3D[]) => Object3D[];
// Asset properties
setName: (modelUuid: string, newName: string) => void;
setPosition: (modelUuid: string, position: [number, number, number]) => void;
@@ -44,6 +56,11 @@ export const createAssetStore = () => {
return create<AssetsStore>()(
immer((set, get) => ({
assets: [],
movedObjects: [],
rotatedObjects: [],
copiedObjects: [],
pastedObjects: [],
duplicatedObjects: [],
// Asset CRUD operations
addAsset: (asset) => {
@@ -94,6 +111,41 @@ export const createAssetStore = () => {
});
},
setMovedObjects: (objects) => {
set((state) => {
state.movedObjects = objects;
});
return objects;
},
setRotatedObjects: (objects) => {
set((state) => {
state.rotatedObjects = objects;
});
return objects;
},
setCopiedObjects: (objects) => {
set((state) => {
state.copiedObjects = objects;
});
return objects;
},
setPastedObjects: (objects) => {
set((state) => {
state.pastedObjects = objects;
});
return objects;
},
setDuplicatedObjects: (objects) => {
set((state) => {
state.duplicatedObjects = objects;
});
return objects;
},
// Asset properties
setName: (modelUuid, newName) => {
set((state) => {

View File

@@ -15,7 +15,7 @@ interface WallAssetStore {
setOpacity: (uuid: string, opacity: number) => void;
getWallAssetById: (uuid: string) => WallAsset | undefined;
getAssetsByWall: (wallUuid: string) => WallAsset[];
getWallAssetsByWall: (wallUuid: string) => WallAsset[];
}
export const createWallAssetStore = () => {
@@ -93,7 +93,7 @@ export const createWallAssetStore = () => {
return get().wallAssets.find(a => a.modelUuid === uuid);
},
getAssetsByWall: (wallUuid) => {
getWallAssetsByWall: (wallUuid) => {
return get().wallAssets.filter(a => a.wallUuid === wallUuid);
},
}))