Skip to content

feat(parametric): add design tree viewer for annotated models #139

@techfowl

Description

@techfowl

Proposal

Add a lightweight design tree for parametric OpenSCAD artifacts so users can inspect model structure and filter parameter controls by part, operation, or parameter group.

This is related to #62, but deliberately scopes the first pass to a source/metadata-driven design tree rather than mesh face or viewport selection.

Motivation

CADAM already exposes parametric controls, but generated models can become hard to understand once they include multiple modules, assemblies, operations, or groups of related dimensions. A design tree would make generated models easier to inspect and would create a foundation for more source-aware editing later.

First-pass behavior

  • Parse structured OpenSCAD comments such as:

    // @cadam-node {"id":"base","kind":"part","name":"Base","params":["width","height"]}
    module base() { ... }
  • Store parsed nodes on the parametric artifact when available.

  • Show a collapsible design-tree drawer inside the model viewer.

  • Reuse the same tree in the parameter panel.

  • Selecting a node filters linked parameter controls on desktop and mobile.

  • Show an empty state for artifacts without annotations.

  • Fall back to parsing annotated code when older artifacts have designTree: [] or no stored tree.

Proposed node shape

type DesignNodeKind =
  | 'assembly'
  | 'part'
  | 'operation'
  | 'sketch'
  | 'parameter-group'
  | 'import';

type DesignNode = {
  id: string;
  kind: DesignNodeKind;
  name: string;
  parentId?: string;
  children?: string[];
  parameterNames?: string[];
  codeRange?: { start: number; end: number };
  visible?: boolean;
  locked?: boolean;
  color?: string;
};

Out of scope for this first pass

  • Clicking viewport geometry to select a node.
  • Mapping compiled mesh triangles/faces back to source nodes.
  • Editing, reordering, suppressing, or regenerating individual operations.
  • Reconstructing a full CAD feature history from arbitrary OpenSCAD.

Follow-up possibilities

  • Prompt/model updates so generated code emits @cadam-node annotations consistently.
  • Node-aware editing/regeneration.
  • Visibility toggles once node-to-geometry mapping exists.
  • Geometry picking for models compiled with source-node metadata.

Validation plan for an implementation PR

  • npm run typecheck
  • npm run lint
  • npm run build

Manual checks:

  • Annotated artifact shows a tree button with a node count in the viewer.
  • Opening the drawer shows nested tree rows.
  • Selecting a node filters the parameter panel.
  • Clearing selection restores all parameters.
  • Unannotated artifact shows an empty state.
  • Mobile preview drawer opens and node selection filters mobile controls.
  • Existing rendering, orbit controls, download controls, and compile loading overlay continue to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions