switching
This commit is contained in:
33
src/stores/shader.ts
Normal file
33
src/stores/shader.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { atom } from 'nanostores';
|
||||
|
||||
export interface ShaderState {
|
||||
code: string;
|
||||
isCompiled: boolean;
|
||||
isAnimating: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export const defaultShaderState: ShaderState = {
|
||||
code: 'x^y',
|
||||
isCompiled: false,
|
||||
isAnimating: false,
|
||||
error: null,
|
||||
};
|
||||
|
||||
export const $shader = atom<ShaderState>(defaultShaderState);
|
||||
|
||||
export function setShaderCode(code: string) {
|
||||
$shader.set({ ...$shader.get(), code, isCompiled: false, error: null });
|
||||
}
|
||||
|
||||
export function setShaderCompiled(isCompiled: boolean, error?: string) {
|
||||
$shader.set({
|
||||
...$shader.get(),
|
||||
isCompiled,
|
||||
error: error || null,
|
||||
});
|
||||
}
|
||||
|
||||
export function setShaderAnimating(isAnimating: boolean) {
|
||||
$shader.set({ ...$shader.get(), isAnimating });
|
||||
}
|
||||
Reference in New Issue
Block a user