# `PartActions.follow`

> 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 [`PartActions`](PartActions.md) · inherited by [`Query`](Query.md), [`Parts`](Parts.md), [`Part`](Part.md) · stable · since 2.0.0 · called as `session.node(nodeId).follow`

```ts
follow(target: Query, options?: FollowOptions): () => void;
```

Rides `target` (one part: a part or bone) every frame, after animations, until disposed.
Re-binds after reloads. A lifecycle call: immediate. Transient: never stored or undone. Through
[`Parts`](Parts.md), every match follows; use `node(nodeId).follow(…)` to move a model as a whole. Returns
the stop function. A target that matches several parts applies nothing ('target-ambiguous').
Errors: none thrown; a `target` matching several parts records 'target-ambiguous' and applies
nothing.

## Options

Through [`Session`](Session.md):

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `offset` | `'rest' \| 'current' \| 'none'` | 'rest' | 'rest': keep the offset the two parts have in their rest poses (safe to call any time). |
| `signal` | `AbortSignal` | undefined | Aborting stops following; already aborted, none starts ([`SignalOption`](SignalOption.md)). |

Through [`Tx`](Tx.md):

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `offset` | `'rest' \| 'current' \| 'none'` | 'rest' | 'rest': keep the offset the two parts have in their rest poses (safe to call any time). |
| `signal` | `AbortSignal` | undefined | Aborting stops following; already aborted, none starts ([`SignalOption`](SignalOption.md)). |

## Abort (`signal`)

This call is a creator (`SignalOption.signal`, [the kinds of call](../read-this-first.md#conventions)).

> A creator (`collection` for a new name, `materials.create`, `on`, `onFrame`, `beforeCommit`, `follow`, `input.drag`, `labs.lightLinking`) given a signal already aborted returns at once, already ended: a `Collection` or `Material` reading `disposed: true` that holds no content and no live name, or a registration that never runs and whose disposer does nothing.
>
> It records no Problem for the abort and throws only what it would throw anyway, as the DOM's `addEventListener` with an aborted signal adds nothing (spec section 6.5).

## 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/06-PartActions.follow.ts`):

```ts
import type { Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const pocketId: string;
declare const frameId: string;
// from the base's attributes
declare const pocketFollow: ReadonlyArray<{ source: string; bone: string }>;
for (const { source, bone } of pocketFollow) {
  session.find({ node: pocketId, name: source })               // each pocket half…
    .follow({ node: frameId, name: bone }, { offset: 'rest', signal });   // …rides its own lid bone
}
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `follow` names no product |
| 2. A precedent | pass: [DOM Document.getElementById](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById) (row `G31`); [Unity Animations.ParentConstraint (offsets)](https://docs.unity3d.com/ScriptReference/Animations.ParentConstraint.html) (row `G6`); [Unity Animations.ParentConstraint](https://docs.unity3d.com/ScriptReference/Animations.ParentConstraint.html) (row `K56`); [Babylon.js TransformNode.attachToBone](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Meshes/transformNode.ts) (row `K56`) |
| 3. Two apps, or labs | pass: 5 apps (ledger: app-04c2774145, app-b362a81c85, app-c1384707fc, app-f9a32142f1, app-fc306ec3dc) |
| 4. The cheaper fix first | decided per need in Appendix B: rows `G31`, `G6`, `K56` at tier stable (a member only where no rule, data, asset or app code serves the need) |
