export type Vec2 = [number, number]; export type Vec3 = [number, number, number]; export type Quaternion = [number, number, number, number]; export type SceneDevicePackagePin = { packageId: string; version: string; manifestCid: string; }; /** * Authoring-only Device definition. * * `source` points at a local `device.json` (or its containing project) so the * compiler can validate port direction, kind, data type, interface and link * capacity. It is deliberately stripped from the sealed Scene; runtimes * resolve only the exact immutable Package pin. */ export type SceneDeviceDefinitionAuthoring = { id: string; package: SceneDevicePackagePin; source: string; }; export type SceneDeviceInstanceAuthoring = { id: string; definition: string; parentNode: string; transform?: { position?: Vec3; rotation?: Quaternion; scale?: Vec3; }; state?: { schema: string; values: Record; }; }; export type SceneDeviceLinkEndpointAuthoring = { instance: string; port: string; }; export type SceneDeviceLinkAuthoring = { id: string; from: SceneDeviceLinkEndpointAuthoring; to: SceneDeviceLinkEndpointAuthoring; /** Scene-authored links are always explicit; accepted only as an explicit assertion. */ binding?: 'explicit'; }; export type SceneDevicesAuthoring = { definitions: SceneDeviceDefinitionAuthoring[]; instances: SceneDeviceInstanceAuthoring[]; links?: SceneDeviceLinkAuthoring[]; }; export type InlineElementMaterial = { color?: string; roughness?: number; metalness?: number; }; export type ElementMaterial = InlineElementMaterial | { ref: string; }; /** * A named, reusable inline material a document declares once under * `materials` and references from any element via `{ ref: name }`. * * **Removed (ADR-0004 P6, home-scene-unification):** this used to be an * immutable Vault material pin (`{assetId, revision, integritySha256, ...}`), * compiled into a `vault`-sourced Scene resource so a runtime could swap it * for real PBR texture maps. The manifest's `vault` resource source no * longer exists — every compiled surface is now its exact inline color, * never a Vault-backed material. A named `ref` is purely a compile-time * alias for one inline color, saving repetition across elements; it does * not add a Scene-level material resource. */ export type ElementMaterialPalette = Record; export type SceneElementRole = 'exterior' | 'interior' | 'structure' | 'detail'; export type ElementStreamPolicy = { mode?: 'eager' | 'distance' | 'portal'; priority?: number; }; /** Properties which resolve from the nearest ancestor before Scene compilation. */ export type CascadingElementProperties = { material?: ElementMaterial; collision?: boolean; role?: SceneElementRole; stream?: ElementStreamPolicy; }; type ArchitecturalElementBase = CascadingElementProperties & { id: string; }; export type WallElement = ArchitecturalElementBase & { type: 'wall'; start: Vec2; end: Vec2; baseY?: number; height: number; thickness: number; }; export type SlabElement = ArchitecturalElementBase & { type: 'floor' | 'ceiling'; center: Vec2; elevation: number; size: Vec2; thickness: number; }; export type BoxElement = ArchitecturalElementBase & { type: 'primitive'; shape: 'box'; position: Vec3; size: Vec3; /** Full source rotation for deterministic import/conversion workflows. */ rotation?: Quaternion; rotationYDeg?: number; slot?: string; }; export type ArchitecturalElement = WallElement | SlabElement | BoxElement; type LightElementBase = { id: string; type: 'light'; position: Vec3; color: string; luminousIntensityCandela: number; rangeM: number; /** Local orientation for spot lights; points down -Z when omitted. */ rotation?: Quaternion; rotationYDeg?: number; /** Local practical lights default to unshadowed for portable performance. */ castShadow?: boolean; shadowMapSize?: 256 | 512 | 1024 | 2048; }; export type PointLightElement = LightElementBase & { kind: 'point'; }; export type SpotLightElement = LightElementBase & { kind: 'spot'; innerConeDeg: number; outerConeDeg: number; }; export type LightElement = PointLightElement | SpotLightElement; /** A non-solid, reusable swimming volume with a runtime-rendered waterline. */ export type WaterElement = { id: string; type: 'water'; /** Volume centre in the parent element's local +Y-up coordinates. */ position: Vec3; /** Full volume size in metres. */ size: Vec3; /** Local +Y offset from `position` to the visible waterline. Defaults to size[1] / 2. */ surfaceHeight?: number; rotationYDeg?: number; appearance?: { color?: string; opacity?: number; roughness?: number; rippleScaleM?: number; rippleSpeedMps?: number; }; swimming?: { entryDepthM?: number; exitDepthM?: number; floatDepthM?: number; }; }; type ContainerElementBase = CascadingElementProperties & { id: string; position?: Vec3; children: SceneElement[]; }; export type GroupElement = ContainerElementBase & { type: 'group'; }; export type LevelElement = ContainerElementBase & { type: 'level'; /** Local Y translation added to `position`, convenient for storeys. */ elevation?: number; }; export type SpaceElement = ContainerElementBase & { type: 'space'; }; /** * A terrain SOURCE FOLDER placed in the scene: `helix terrain generate|import` writes the folder, * the compiler ships its tiles as bundle resources and names the nodes the runtime streams. */ export type TerrainElement = { type: 'terrain'; id: string; /** Folder holding terrain.json, relative to the elements document. */ source: string; colliderRadiusM?: number; lod?: { strideDistancesM?: [number, number, number]; }; }; /** * A folder of pre-baked per-cell GLBs placed in the scene: `mesh-cells.json` describes them, the compiler ships each * cell as a streamed model node and, unless refused, its own distance-streamed triangle-mesh collider. */ export type MeshCellsElement = { type: 'meshCells'; id: string; /** Folder holding mesh-cells.json, relative to the elements document. */ source: string; /** Variant family to chosen name, e.g. `{ markings: 'a' }`: the choice's cells render beside the base cells. */ variants?: Record; collision?: boolean; /** Overrides the index's `lighting.giContribute` for every cell of this element. */ giContribute?: boolean; priority?: number; }; export type ContainerElement = GroupElement | LevelElement | SpaceElement; export type SceneElement = ArchitecturalElement | LightElement | WaterElement | ContainerElement; type BuildingElementBase = CascadingElementProperties & { id: string; type: 'building'; position?: Vec3; }; export type BuildingElement = BuildingElementBase & { /** Version 2 semantic tree. */ children: SceneElement[]; elements?: never; }; export type LegacyBuildingElement = BuildingElementBase & { /** Version 1 flat input, retained for immutable authoring compatibility. */ elements: ArchitecturalElement[]; children?: never; }; /** * Creator-facing semantic document. Version 2 adds semantic containment and a * bounded compile-time cascade. It remains typed data rather than a runtime * DOM: there are no selectors, specificity rules, layout, or script. */ type SceneElementsDocumentBase = { format: 'helix.scene-elements'; id: string; title: string; materials?: ElementMaterialPalette; spawn: { position: Vec3; rotationYDeg?: number; }; /** At most one, and always the world's ground: the buildings sit on it. */ terrain?: TerrainElement; /** Streamed pre-baked cell grids sitting beside the terrain, one entry per baked folder. */ meshCells?: MeshCellsElement[]; /** Folder produced by helix placements bake, relative to this document. */ placements?: { source: string; }; /** Authored total scene residency budget and native content radius; omitted values preserve existing defaults. */ runtimePolicy?: { memoryBudgetMiB?: number; streamRadiusM?: number; }; }; export type SceneElementsDocument = SceneElementsDocumentBase & ({ version: 1; buildings: LegacyBuildingElement[]; } | { version: 2; buildings: BuildingElement[]; devices?: SceneDevicesAuthoring; }); export {};