Skip to main content
This page documents the public surface of @reactor-models/happy-oyster. For a complete application flow, see the tutorial.

Modes

Choose a mode before connecting: The mode stays fixed for the client or provider session. Construct a new client, or remount the provider, to switch modes.

Client construction

JavaScript

videoElement may be omitted at construction and supplied later with attachVideo(element).

React

Provider props:

Lifecycle

The client lifecycle is available as model.phase or useHappyOyster().phase:

connect

Open the session and synchronize the first worldState snapshot.
With a provider, use autoConnect or call the hook method:

disconnect

End any active travel and close the session. Worlds remain available for later attachment.

endTravelSession

End the active travel while keeping the session and current world.

Worlds

createWorld

Create a world for the client’s selected mode and make it current. The promise resolves with a WorldStateMessage once the world is ready. Shared parameters: Provide only one starting-image source. Adventure parameters:
Directing parameters:
Save world.encrypted_world_id to reopen the world later.

attachWorld

Make an existing world current and wait until it is ready:
The world must belong to the client’s selected mode.

Travel

startTravel

Start the current ready world and render its stream into the attached video element:
The method is single-flight: concurrent calls share one attempt. Calling it while already streaming returns the current result. StartTravelResult:

Video in React

Mount HappyOysterVideo under the provider before starting:

Adventure controls

Adventure controls are held state. Movement, look, and interaction axes compose until released.

move

Values: Front, Back, Left, Right, the four diagonal combinations, and None.

look

Values: Mouse_Up, Mouse_Down, Mouse_Left, Mouse_Right, the four diagonal combinations, and None.

interact

Built-in verbs include Jump, Attack, Crouch, and Sprint. The current world’s advertised verbs are available in travelState.character_actions and travelState.environment_actions.

hold

Set multiple axes in one call:

release

Release selected axes while leaving the others held:

stop

Release every axis:

Directing controls

instruct

Submit a text instruction:
Accepted instructions appear in travelState.user_instructions.

pause

resume

rewind

Rewind a paused travel to an absolute second. Playback resumes automatically:
Targets use 4-second boundaries; other values are rounded down.

Travel status

React:

State

worldState

The authoritative current-world snapshot: Subscribe from the class:
Or read the reactive value from useHappyOyster().

travelState

The authoritative live-travel snapshot:

React hook surface

useHappyOyster() returns:
  • model, mode, phase, worldState, travelState, and streaming
  • connect, disconnect, createWorld, attachWorld, startTravel, and endTravelSession
  • Adventure methods: move, look, interact, hold, release, stop, and control
  • Directing methods: instruct, pause, resume, and rewind
Additional hooks:
  • useHappyOysterWorldState()
  • useHappyOysterTravelState()
  • useHappyOysterPhase()
  • useHappyOysterTravelStatus(handler)
  • useHappyOysterTravelError(handler)

Errors

HappyOysterActionError exposes the rejected action and a machine-readable code.