@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
Lifecycle
The client lifecycle is available asmodel.phase or useHappyOyster().phase:
connect
Open the session and synchronize the first worldState snapshot.
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:
world.encrypted_world_id to reopen the world later.
attachWorld
Make an existing world current and wait until it is ready:
Travel
startTravel
Start the current ready world and render its stream into the attached video element:
StartTravelResult:
Video in React
MountHappyOysterVideo under the provider before starting:
Adventure controls
Adventure controls are held state. Movement, look, and interaction axes compose until released.move
Front, Back, Left, Right, the four diagonal combinations, and None.
look
Mouse_Up, Mouse_Down, Mouse_Left, Mouse_Right, the four diagonal combinations, and
None.
interact
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:
travelState.user_instructions.
pause
resume
rewind
Rewind a paused travel to an absolute second. Playback resumes automatically:
Travel status
State
worldState
The authoritative current-world snapshot:
Subscribe from the class:
useHappyOyster().
travelState
The authoritative live-travel snapshot:
React hook surface
useHappyOyster() returns:
model,mode,phase,worldState,travelState, andstreamingconnect,disconnect,createWorld,attachWorld,startTravel, andendTravelSession- Adventure methods:
move,look,interact,hold,release,stop, andcontrol - Directing methods:
instruct,pause,resume, andrewind
useHappyOysterWorldState()useHappyOysterTravelState()useHappyOysterPhase()useHappyOysterTravelStatus(handler)useHappyOysterTravelError(handler)
Errors
HappyOysterActionError exposes the rejected action and a machine-readable code.