/ concept-collection / dulcimer
Sign in
concept-collection / dulcimer
dulcimer / src / tools.ts
27 lines · 990 BCodeBlameHistory
2 * The shared MATLAB utilities in `tools/`, as interpreter workspace files.
3 *
4 * A scene is evaluated by numbl's interpreter (see src/scene/scene.ts), which
5 * resolves a call like `sponge(...)` against the workspace files it is handed.
6 * Everything in `tools/` is handed to every such run, so any .m can call any
7 * tool by name — MATLAB's own path semantics, where the file name is the
8 * function name.
9 *
10 * These are *not* available to the models: a model's step compiles to WGSL,
11 * where none of this exists.
12 */
13const sources = import.meta.glob('../tools/*.m', {
14 query: '?raw',
15 eager: true,
16 import: 'default',
17}) as Record<string, string>;
19export interface ToolFile {
20 name: string;
21 source: string;
24/** Every tool, named as MATLAB wants it (`randnfunsphere.m`). */
25export const toolFiles: ToolFile[] = Object.entries(sources)
26 .map(([path, source]) => ({ name: path.slice(path.lastIndexOf('/') + 1), source }))
27 .sort((a, b) => a.name.localeCompare(b.name));
moveopenescclose