---
title: "createMotionAxis"
description: "A unit direction that follows where the pointer has been travelling, smoothed frame to frame."
group: "simulation"
groupTitle: "Simulation"
categoryId: "sim.agentFrame"
categorySlug: "sim-agentframe"
categoryTitle: "Agent frame"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/sim/agentFrame.ts#L147"
---

# createMotionAxis

A unit direction that follows where the pointer has been travelling, smoothed frame to frame.

```ts
createMotionAxis(opts?: {smoothing?: number; teleport?: number}): { update(x: number, y: number): { x: number; y: number; }; }
```

Import `sim` from `shaders/std` and use `sim.agentFrame.createMotionAxis`.

Feed `update(x, y)` the pointer each frame and write the result into an axis value.

`smoothing` (0–1, default 0.1) is how fast the axis turns. A jump longer than `teleport` (default 0.25, in the same units as the pointer) is the cursor re-entering the canvas, not a stroke, and leaves the axis alone.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `opts` | `{smoothing?: number; teleport?: number}` | Optional. |

## Example

```ts
const motionAxis = agentFrame.createMotionAxis({smoothing: 0.1, teleport: 0.25})
const axis = motionAxis.update(cursorX, cursorY)
```

## See also

- [`field`](/docs/primitives/sim-agentforces/field) — What a turning agent samples at its position: the magnetic field at the cursor, and its resting place on a jittered grid.