ParaShape

Scene

TypeScript contract for Model.toScene() — the JSON-safe render packet sent to host renderers (Three.js / SketchUp).

Source: packages/parametric/src/schema/scene.ts

SceneJSON — top-level contract

//
// The render packet from Model.toScene(). Pure geometry tree — NO asset bodies.
// Materials, layers and fonts are referenced by string name only; their full
// definitions live in the Store (looked up by name at render time).

import type { Point3D } from "./graph.js"

export type SceneJSON = {
    nodes: SceneNode[]
}

Scene node (mirrors a top-level body node)

export type SceneNode = {
    id: string
    key: string
    entities: SceneEntity[]
    children: SceneNode[]
    material?: string
    layer?: string
    label?: string
    visible?: false
}

Geometry union

export type SceneEntity = Curve | Mesh | Point

// material + layer resolve nearest-ancestor (SketchUp-like): an entity uses its
// OWN material/layer if set, else inherits the parent SceneNode's, else the
// nearest ancestor up the tree. The engine lifts a value shared by all of a
// node's entities up to the node, so per-entity fields appear only as overrides.

Curve geometry

export type Curve = {
    type: "curve"
    points: Point3D[]
    material?: string
    layer?: string
}

Face / solid geometry

export type MeshGroup = {
    start: number
    count: number
    material?: string
}

export type Mesh = {
    type: "mesh"
    positions: number[]
    indices: number[]
    normals: number[]
    uvs: number[]
    groups: MeshGroup[]
    material?: string
    layer?: string
}

Point geometry

export type Point = {
    type: "point"
    position: Point3D
}