This page covers useMotionGPU() for runtime context access, usePointer() for normalized pointer input, the CurrentWritable pattern for synchronous reads, and recommended integration patterns.
For advanced user-defined context, see User Context (Advanced).
useMotionGPU()
useMotionGPU() returns the MotionGPUContext — the primary API for reading runtime state and controlling rendering from within FragCanvas children.
Must be called inside a <FragCanvas> component tree. Calling it outside throws.
usePointer()
usePointer() provides adapter-managed pointer tracking (mouse, touch, pen) with shader-friendly coordinates:
state.current.uvin0..1with Y-up orientationstate.current.ndcin-1..1- optional synthesized click snapshots via
lastClick.current - optional automatic frame wakeups (
requestFrame: 'auto')
Use it to remove canvas event-listener boilerplate in runtime components.
MotionGPUContext shape
Reactive stores
Direct values
Control methods
Scheduler access
For higher-level scheduler configuration and debug snapshots, use the advanced helper exports:
The CurrentWritable / CurrentReadable pattern
Store-like subscriptions require setup/teardown to read values reactively. In useFrame callbacks (which run 60 times per second), subscribing and unsubscribing per read is wasteful.
CurrentWritable<T> and CurrentReadable<T> extend reactive store contracts with a synchronous .current getter: