# Frame

class in `closed-chain-ik/core`

```js
import { Frame } from 'closed-chain-ik/core';
```

Base class for `Link`, `Joint`, and `Goal` representing a frame defined by a position and
rotation in space.

## Properties

### .name: string

Name of the frame.

### .quaternion: Float32Array

Orientation of the frame relative to its parent. If modified directly
`setMatrixNeedsUpdate` must be called.

### .position: Float32Array

Position of the frame relative to its parent. If modified directly
`setMatrixNeedsUpdate` must be called.

### .matrix: Float32Array

readonly

Local transform matrix composed from the position and quaternion.

### .matrixWorld: Float32Array

readonly

World transform matrix computed from the parent world matrix and the local matrix.

### .parent: Frame | null

readonly

The frame this frame is a child of.

### .children: Array<Frame>

readonly

The frames this frame is a parent of.

## Methods

### .setPosition

```js
.setPosition( x: number, y: number, z: number )
```

Sets the position of the frame relative to its parent.

- `x`, `number`
- `y`, `number`
- `z`, `number`

### .setEuler

```js
.setEuler( x: number, y: number, z: number )
```

Sets the orientation of the frame relative to its parent from Euler angles in radians.

- `x`, `number`
- `y`, `number`
- `z`, `number`

### .setQuaternion

```js
.setQuaternion( x: number, y: number, z: number, w: number )
```

Sets the orientation of the frame relative to its parent.

- `x`, `number`
- `y`, `number`
- `z`, `number`
- `w`, `number`

### .setWorldPosition

```js
.setWorldPosition( x: number, y: number, z: number )
```

Sets the position of the frame in world space. The local position relative to the parent
is computed automatically.

- `x`, `number`
- `y`, `number`
- `z`, `number`

### .setWorldEuler

```js
.setWorldEuler( x: number, y: number, z: number )
```

Sets the orientation of the frame in world space from Euler angles in radians. The local
orientation relative to the parent is computed automatically.

- `x`, `number`
- `y`, `number`
- `z`, `number`

### .setWorldQuaternion

```js
.setWorldQuaternion( x: number, y: number, z: number, w: number )
```

Sets the orientation of the frame in world space. The local orientation relative to the
parent is computed automatically.

- `x`, `number`
- `y`, `number`
- `z`, `number`
- `w`, `number`

### .getWorldPosition

```js
.getWorldPosition( target: Array<number> | Float32Array )
```

Writes the position of the frame in world space into `target`.

- `target`, `Array<number> | Float32Array`

### .getWorldQuaternion

```js
.getWorldQuaternion( target: Array<number> | Float32Array )
```

Writes the orientation of the frame in world space into `target`.

- `target`, `Array<number> | Float32Array`

### .traverseParents

```js
.traverseParents( callback: FrameCallback )
```

Calls `callback` for every ancestor starting with the parent. Returning `true` from the
callback stops the traversal.

- `callback`, `FrameCallback`

### .traverse

```js
.traverse( callback: FrameCallback )
```

Calls `callback` for this frame and every descendant in breadth first order. Returning
`true` from the callback stops traversal below that frame.

- `callback`, `FrameCallback`

### .find

```js
.find( callback: FrameCallback ): Frame | null
```

Returns the first frame in the tree, including this one, for which `callback` returns
`true`, or `null` if none does.

- `callback`, `FrameCallback`

### .addChild

```js
.addChild( child: Frame )
```

Adds a child to this frame and sets its parent to this frame. Throws if the child already
has a parent.

- `child`, `Frame`

### .removeChild

```js
.removeChild( child: Frame )
```

Removes the given child from this frame. Throws if the frame is not a child of this frame.

- `child`, `Frame`

### .attachChild

```js
.attachChild( child: Frame )
```

Adds the given frame as a child while preserving its world transform.

- `child`, `Frame`

### .detachChild

```js
.detachChild( child: Frame )
```

Removes the given child while preserving its world transform.

- `child`, `Frame`

### .setMatrixNeedsUpdate

```js
.setMatrixNeedsUpdate(  )
```

Flags this frame as needing its local and world matrices updated.

### .setMatrixWorldNeedsUpdate

```js
.setMatrixWorldNeedsUpdate(  )
```

Flags this frame and all its descendants as needing their world matrices updated.

### .updateMatrix

```js
.updateMatrix(  )
```

Updates the local matrix if it has been flagged as needing an update.

### .updateMatrixWorld

```js
.updateMatrixWorld( updateChildren?: boolean )
```

Updates the local and world matrices if they have been flagged as needing an update,
updating parent matrices first as needed.

- `updateChildren`, `boolean`, optional, default `false`: Also update the world matrices of all descendants.
