Skip to content
Snippets Groups Projects
Commit 0a0612ba authored by David Sehnal's avatar David Sehnal
Browse files

wip, params

parent 8d7ae26d
Branches
Tags
No related merge requests found
......@@ -18,6 +18,8 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) {
ctx.canvas3d.add(e.obj.data);
ctx.canvas3d.requestDraw(true);
console.log(e.obj.data);
// TODO: update visiblity
});
events.object.updated.subscribe(e => {
......
// TODO: state reducers
// The idea is to have "reduced"/computed objects from a state
// basicaly something like this Reduce(selection: StateSelection) => Value
// the reducer would be automatically called each time a state update is finished and any object of the selection is updated.
\ No newline at end of file
......@@ -90,7 +90,17 @@ export namespace ParamDefinition {
return { type: 'interval', label, description, defaultValue }
}
export type Any = /* GenericValue<any> | */ Select<any> | MultiSelect<any> | Boolean | Range | Text | Color | Numeric | Interval
export interface Obj<P extends Params> extends Base<{ [K in keyof P]: P[K]['defaultValue']}> {
type: 'obj',
pivot?: keyof P,
params: P
}
export function Obj<P extends Params>(label: string, description: string, params: P, pivot?: keyof P): Obj<P> {
return { type: 'obj', label, description, defaultValue: getDefaultValues(params), params, pivot };
}
export type Any = Select<any> | MultiSelect<any> | Boolean | Range | Text | Color | Numeric | Interval | Obj<any>
export type Params = { [k: string]: Any }
export type DefaultValues<T extends Params> = { [k in keyof T]: T[k]['defaultValue'] }
......@@ -117,7 +127,7 @@ export namespace ParamDefinition {
definition?(a: A, globalCtx: Ctx): { [K in keyof P]?: Any },
/** Check the parameters and return a list of errors if the are not valid. */
validate?(params: P, a: A, globalCtx: unknown): ParamErrors | undefined,
/** Optional custom parameter equality. Use deep structural equal by default. */
/** Optional custom parameter equality. Use shallow structural equal by default. */
areEqual?(oldParams: P, newParams: P): boolean
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment