feat: Enhance asset and human event handling with animation and loop capabilities
This commit is contained in:
@@ -22,7 +22,8 @@ interface AssetsStore {
|
||||
|
||||
// Animation controls
|
||||
setAnimations: (modelUuid: string, animations: string[]) => void;
|
||||
setCurrentAnimation: (modelUuid: string, current: string, isPlaying: boolean) => void;
|
||||
setCurrentAnimation: (modelUuid: string, current: string, isisPlaying: boolean, loopAnimation: boolean) => void;
|
||||
resetAnimation: (modelUuid: string) => void;
|
||||
addAnimation: (modelUuid: string, animation: string) => void;
|
||||
removeAnimation: (modelUuid: string, animation: string) => void;
|
||||
|
||||
@@ -149,18 +150,28 @@ export const createAssetStore = () => {
|
||||
if (asset) {
|
||||
asset.animations = animations;
|
||||
if (!asset.animationState) {
|
||||
asset.animationState = { current: '', playing: false };
|
||||
asset.animationState = { current: '', isPlaying: false, loopAnimation: true };
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setCurrentAnimation: (modelUuid, current, isPlaying) => {
|
||||
setCurrentAnimation: (modelUuid, current, isisPlaying, loopAnimation) => {
|
||||
set((state) => {
|
||||
const asset = state.assets.find(a => a.modelUuid === modelUuid);
|
||||
if (asset?.animationState) {
|
||||
asset.animationState.current = current;
|
||||
asset.animationState.playing = isPlaying;
|
||||
asset.animationState.isPlaying = isisPlaying;
|
||||
asset.animationState.loopAnimation = loopAnimation;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
resetAnimation: (modelUuid) => {
|
||||
set((state) => {
|
||||
const asset = state.assets.find(a => a.modelUuid === modelUuid);
|
||||
if (asset?.animationState) {
|
||||
asset.animationState = { current: '', isPlaying: false, loopAnimation: true };
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -184,7 +195,7 @@ export const createAssetStore = () => {
|
||||
if (asset?.animations) {
|
||||
asset.animations = asset.animations.filter(a => a !== animation);
|
||||
if (asset.animationState?.current === animation) {
|
||||
asset.animationState.playing = false;
|
||||
asset.animationState.isPlaying = false;
|
||||
asset.animationState.current = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ interface BuilderState {
|
||||
|
||||
// Floor Asset
|
||||
selectedFloorAsset: Object3D | null;
|
||||
loopAnimation: boolean;
|
||||
|
||||
// Wall Settings
|
||||
selectedWall: Object3D | null;
|
||||
@@ -64,6 +65,7 @@ interface BuilderState {
|
||||
|
||||
// Setters - Floor Asset
|
||||
setSelectedFloorAsset: (asset: Object3D | null) => void;
|
||||
setLoopAnimation: (loop: boolean) => void;
|
||||
|
||||
// Setters - Wall
|
||||
setSelectedWall: (wall: Object3D | null) => void;
|
||||
@@ -118,6 +120,7 @@ export const useBuilderStore = create<BuilderState>()(
|
||||
deletableWallAsset: null,
|
||||
|
||||
selectedFloorAsset: null,
|
||||
loopAnimation: true,
|
||||
|
||||
selectedWall: null,
|
||||
wallThickness: 0.5,
|
||||
@@ -197,6 +200,12 @@ export const useBuilderStore = create<BuilderState>()(
|
||||
});
|
||||
},
|
||||
|
||||
setLoopAnimation(loopAnimation: boolean) {
|
||||
set((state) => {
|
||||
state.loopAnimation = loopAnimation;
|
||||
});
|
||||
},
|
||||
|
||||
// === Setters: Wall ===
|
||||
|
||||
setSelectedWall: (wall: Object3D | null) => {
|
||||
|
||||
Reference in New Issue
Block a user