Add scene context and animation handling to AssetProperties and Model components

- Enhanced animation handling in Model component with animation state management.
- Updated useAssetStore to support multiple animations for assets.
This commit is contained in:
2025-06-26 15:11:52 +05:30
parent e5e92d2b9f
commit d926809dec
4 changed files with 117 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ interface AssetsStore {
setOpacity: (modelUuid: string, opacity: number) => void;
// Animation controls
setAnimation: (modelUuid: string, animation: string) => void;
setAnimations: (modelUuid: string, animations: string[]) => void;
setCurrentAnimation: (modelUuid: string, current: string, isPlaying: boolean) => void;
addAnimation: (modelUuid: string, animation: string) => void;
removeAnimation: (modelUuid: string, animation: string) => void;
@@ -143,14 +143,13 @@ export const createAssetStore = () => {
},
// Animation controls
setAnimation: (modelUuid, animation) => {
setAnimations: (modelUuid, animations) => {
set((state) => {
const asset = state.assets.find(a => a.modelUuid === modelUuid);
if (asset) {
asset.animations = animations;
if (!asset.animationState) {
asset.animationState = { current: animation, playing: false };
} else {
asset.animationState.current = animation;
asset.animationState = { current: '', playing: false };
}
}
});