# `Writer.getSceneModel`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

Method of [`Writer`](Writer.md) · inherited by [`Tx`](Tx.md), [`Session`](Session.md), [`testing.FakeSession`](testing.FakeSession.md) · stable · since 2.0.0 · called as `session.getSceneModel`

```ts
getSceneModel(): DeepReadonly<SceneModel> | null;
```

Read class: intent. The scene model; null before the first model. Sync. It never contains key
material or plain-twin URLs, so never save it: merge each node's `position`, `rotation`,
`scale` and `enabled` and each GroupNode's `defaultNodeId` into your own document by `nodeId`,
and store [`assembly.connections()`](Assembly.connections.md) with a fresh [`connectionsBasis`](connectionsBasis.md). It never carries
`connections` or [`connectionsBasis`](connectionsBasis.md) either: read connections with [`assembly.connections()`](Assembly.connections.md) and
pass them back as [`SceneModel.connections`](SceneModel.connections.md) says. A save re-grafts `keyRef` by `glbUrl`, but the
plain twins only onto a node with the same `_id`, which most stored nodes lack (8.5).
Intent is not what is shown: it includes staged and queued writes. For what the viewer shows,
keep the model from the latest 'scene-model:changed', which fires after the frame that shows
its commit.
Errors: none.

## Example

Imports: values (`has`, `validate`, the `Holo*Error` classes, the pure helpers) from `@holostep-configurators/runtime-client`, types from `@holostep-configurators/runtime-client/contract`, `/math` and `/testing` names from those entries; `boot` from the runtime module the root's `loadRuntimeAtFloor` resolves to. A type your page defines is your app's: declare it there, never import it from the package.

Compiled under the contract's strict settings (`examples/declaration/05-Writer.getSceneModel.ts`):

```ts
import { connectionsBasis } from '@holostep-configurators/runtime-client';
import type { DeepReadonly, IConfigurator, SceneModel, Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
// your own document: it keeps key material
declare const saved: IConfigurator;
declare function mergePlacement(doc: IConfigurator, model: DeepReadonly<SceneModel>): IConfigurator;
declare function saveDesign(doc: IConfigurator): Promise<void>;
const model = session.getSceneModel();
if (model) {
  // position, rotation, scale, enabled and group selections, by nodeId
  const doc = mergePlacement(saved, model);
  const connections = session.assembly.connections();
  await saveDesign({ ...doc, connections, connectionsBasis: connectionsBasis(doc, connections) });
}
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `getSceneModel` names no product |
| 2. A precedent | pass: [ProseMirror history (addToHistory)](https://prosemirror.net/docs/ref/#history) (row `K62`); [Unity Undo](https://docs.unity3d.com/ScriptReference/Undo.html) (row `K62`) |
| 3. Two apps, or labs | pass: 3 apps (ledger: app-04c2774145, app-4762caacdc, app-f9a32142f1; fleet cross-check: app-04c2774145, app-4762caacdc, app-f9a32142f1) |
| 4. The cheaper fix first | decided per need in Appendix B: rows `K62` at tier stable (a member only where no rule, data, asset or app code serves the need) |
