# Wall

> One straight wall in a wall network. Change its thickness and height, in the plan and in 3D.

- Live example: https://floorkit-examples.ploterr.com/floorkit/api/wall
- Docs page: https://docs.ploterr.com/floorkit/api/architecture/wall
- Category: Walls
- API: `Wall`, `WallNetwork`
- Tags: wall, network
- Package: `@opengeometry/floorkit`
- Source: `examples/src/api/wall.example.ts`

Each example is one module exporting `meta` and `setup(ctx)`. The examples shell renders it in 3D and as a 2D plan (or on a sheet surface for drawing examples) and builds its controls from the element schema.

## Source

### examples/src/api/wall.example.ts

```ts
import { Wall, WallNetwork } from '@opengeometry/floorkit';
import type { ExampleContext, ExampleMeta, ExampleResult } from '../app/lib/example';

export const meta: ExampleMeta = {
  title: 'Wall',
  description:
    'One straight wall in a wall network. Change its thickness and height, in the plan and in 3D.',
  tags: ['wall', 'network'],
  api: ['Wall', 'WallNetwork'],
  camera: { position: [7, 6, 8], target: [2.5, 1.5, 0] },
};

export function setup({ scene }: ExampleContext): ExampleResult {
  const network = new WallNetwork();
  const wall = network.add(
    new Wall({
      labelName: 'Wall',
      axis: { kind: 'line', start: [0, 0, 0], end: [5, 0, 0] },
      thickness: 0.2,
      height: 3,
      baseElevation: 0,
      locationLine: 'centre',
      locationOffset: 0,
      material: 'CONCRETE',
      color: 0xcccccc,
      priority: 0,
      joins: { start: { allow: true }, end: { allow: true } },
    }),
  );
  network.resolve();
  wall.outline = true;
  scene.add(wall);

  return { edit: wall, plan: network, expose: { wall, network } };
}
```

### examples/src/app/lib/example.ts

```ts
import type * as THREE from 'three';
import type { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import type { createModelRenderer, EditorChange, OPControl, VectorDrawing, WallNetwork } from '@opengeometry/floorkit';

export type EditTarget = THREE.Object3D & { ogType: string };

export type PlanRenderer = Awaited<ReturnType<typeof createModelRenderer>>;

export interface ExampleMeta {
  title: string;
  description: string;
  tags?: readonly string[];
  api?: readonly string[];
  camera?: { position: [number, number, number]; target: [number, number, number] };
  view?: '3d' | '2d';
  surface?: 'dom';
  grid?: false | { size: number; y?: number };
  notes?: readonly string[];
}

export interface SurfaceContext {
  container: HTMLElement;
  refresh: () => void;
}

export interface ExampleContext extends SurfaceContext {
  scene: THREE.Scene;
  camera: THREE.PerspectiveCamera;
  controls: OrbitControls;
  renderer: THREE.WebGLRenderer;
  onFrame: (callback: () => void) => void;
}

export interface PlanSource {
  getDrawing: () => VectorDrawing;
  getElementById?: (ogid: string) => unknown;
  getChangedDrawing?: (ogids: readonly string[]) => VectorDrawing;
  subscribeInvalidation?: (callback: (ogids: readonly string[]) => void) => () => void;
}

export interface PlanElement {
  ogid: string;
}

export type InputControl =
  | { kind: 'text'; input: 'date' | 'password' }
  | { kind: 'file'; accept: string };

export interface ValueControl {
  key: string;
  label: string;
  group?: string;
  control: OPControl | InputControl;
  get: () => unknown;
  set?: (value: unknown) => void;
  commit?: (value: unknown) => void;
}

export type ActionIcon = 'undo' | 'redo';

export interface ActionControl {
  key: string;
  label: string;
  group?: string;
  icon?: ActionIcon;
  run: () => unknown;
}

export type ControlOverride = ValueControl | ActionControl;

export type Verdict = 'pass' | 'fail';

export interface ReportSection {
  title: string;
  verdict?: Verdict;
  columns?: readonly string[];
  rows?: ReadonlyArray<{ cells: ReadonlyArray<string | number>; verdict?: Verdict }>;
  note?: string;
}

export interface EditChoice {
  label: string;
  target: EditTarget;
}

export interface ExampleResult {
  edit?: EditTarget | (() => EditTarget | undefined);
  targets?: readonly EditChoice[] | (() => readonly EditChoice[]);
  pick?: boolean;
  plan?: WallNetwork | readonly PlanElement[] | PlanSource;
  controls?: false | readonly ControlOverride[] | ((target: EditTarget | undefined) => readonly ControlOverride[]);
  report?: () => readonly ReportSection[];
  onEdit?: (change: EditorChange) => void;
  onChange?: () => void;
  onPlan?: (renderer: PlanRenderer) => void;
  expose?: Record<string, unknown>;
  dispose?: () => void;
}

export interface ExampleModule {
  meta: ExampleMeta;
  setup: (context: ExampleContext) => Promise<ExampleResult> | ExampleResult;
}
```
