Skip to content

@gameable/conversation ​

Interfaces ​

ConversationCharacter ​

Story configuration is host-owned; game code names only a character id.

Properties ​

prefabs? ​
ts
optional prefabs?: Readonly<Record<string, readonly SpeechChunk[] | undefined>>;

This character's prepared performances, selected by the service.

storyId ​
ts
storyId: string;
url ​
ts
url: string;

ConversationModule ​

Session control. Ending an interview retains its session and story revision.

Extends ​

Properties ​

id ​
ts
readonly id: string;

Unique id. Also the service id when init returns a service.

Inherited from ​

EngineModule.id

order? ​
ts
readonly optional order?: number;

Sort key. Lower runs first; equal keys keep registration order.

Rough convention: input -100, gameplay -50, physics 0, rendering helpers 200. Gameplay runs before physics so that the commands a guest tick emits are simulated by the step that follows rather than the next one.

Inherited from ​

EngineModule.order

Methods ​

ask() ​
ts
ask(text): boolean;
Parameters ​
ParameterType
textstring
Returns ​

boolean

beginFrame()? ​
ts
optional beginFrame(): void;

Run before the frame's fixed steps. Input capture lives here.

Returns ​

void

Inherited from ​

EngineModule.beginFrame

dispose() ​
ts
dispose(): void;

Release everything this module took.

Returns ​

void

Inherited from ​

EngineModule.dispose

end() ​
ts
end(): void;
Returns ​

void

endFrame()? ​
ts
optional endFrame(): void;

Run after rendering. Input's end-of-frame bookkeeping lives here.

Returns ​

void

Inherited from ​

EngineModule.endFrame

fixedUpdate()? ​
ts
optional fixedUpdate(dt): void;

Run once per fixed step.

Parameters ​
ParameterTypeDescription
dtnumberAlways ctx.config.fixedDt, whatever time.timeScale is; time scale changes how many steps a frame runs, not their length.
Returns ​

void

Inherited from ​

EngineModule.fixedUpdate

init() ​
ts
init(ctx): void | object | Promise<void | object>;

Acquire resources.

Parameters ​
ParameterTypeDescription
ctxHostContextThe host surface.
Returns ​

void | object | Promise<void | object>

Nothing, or the service to publish under id.

Inherited from ​

EngineModule.init

interrupt() ​
ts
interrupt(): void;
Returns ​

void

start() ​
ts
start(character): void;
Parameters ​
ParameterType
characterstring
Returns ​

void

update()? ​
ts
optional update(dt, alpha): void;

Run once per frame, after the fixed steps and before rendering.

Parameters ​
ParameterTypeDescription
dtnumberClamped wall-clock seconds since the previous frame, scaled by time.timeScale.
alphanumberInterpolation factor in [0, 1) for smoothing transforms.
Returns ​

void

Inherited from ​

EngineModule.update


ConversationOptions ​

Optional conversation dependencies and callbacks.

Properties ​

characters ​
ts
characters: Readonly<Record<string, ConversationCharacter | undefined>>;
player ​
ts
player: SpeechPlayer;
prefabs? ​
ts
optional prefabs?: Readonly<Record<string, readonly SpeechChunk[] | undefined>>;

Prepared performances keyed by Convorcher prefab id; no story mutations.

Methods ​

connect()? ​
ts
optional connect(url): ConversationSocket;
Parameters ​
ParameterType
urlstring
Returns ​

ConversationSocket

onError() ​
ts
onError(message): void;
Parameters ​
ParameterType
messagestring
Returns ​

void

onStatus() ​
ts
onStatus(status): void;
Parameters ​
ParameterType
statusstring
Returns ​

void

onStory() ​
ts
onStory(character, snapshot): void;
Parameters ​
ParameterType
characterstring
snapshotStorySnapshot
Returns ​

void


ConversationSocket ​

Browser connection surface; injectable for service replay tests.

Properties ​

onclose ​
ts
onclose: ((event) => void) | null;
onerror ​
ts
onerror: ((event) => void) | null;
onmessage ​
ts
onmessage: ((event) => void) | null;
onopen ​
ts
onopen: ((event) => void) | null;
readyState ​
ts
readyState: number;

Methods ​

close() ​
ts
close(): void;
Returns ​

void

send() ​
ts
send(text): void;
Parameters ​
ParameterType
textstring
Returns ​

void


FaceFrame ​

Face frames use ARKit-52 ordering, with seconds relative to their audio chunk.

Properties ​

blendshapeWeights ​
ts
blendshapeWeights: readonly number[];
timeCode ​
ts
timeCode: number;

SpeechChunk ​

One bounded speech performance, already decoded from the service wire format.

Properties ​

frames ​
ts
frames: readonly FaceFrame[];
gesture? ​
ts
optional gesture?: string;
pcm ​
ts
pcm: Uint8Array;
text ​
ts
text: string;

SpeechPlayer ​

Audio-clock speech queue; update reuses a single facial vector.

Methods ​

dispose() ​
ts
dispose(): void;
Returns ​

void

enqueue() ​
ts
enqueue(chunk): void;
Parameters ​
ParameterType
chunkSpeechChunk
Returns ​

void

stop() ​
ts
stop(): void;
Returns ​

void

update() ​
ts
update(): void;
Returns ​

void


SpeechPresentation ​

Presentation callbacks run on the audio clock.

Methods ​

expression() ​
ts
expression(weights): void;
Parameters ​
ParameterType
weightsFloat32Array
Returns ​

void

gesture() ​
ts
gesture(id): void;
Parameters ​
ParameterType
idstring
Returns ​

void

reset() ​
ts
reset(): void;
Returns ​

void

speaking() ​
ts
speaking(active): void;
Parameters ​
ParameterType
activeboolean
Returns ​

void

subtitle() ​
ts
subtitle(text): void;
Parameters ​
ParameterType
textstring
Returns ​

void


StorySnapshot ​

Stable full-state message emitted by Convorcher after analysis and on join.

Properties ​

completedObjectives ​
ts
completedObjectives: string[];
currentPhase ​
ts
currentPhase: string;
playerState ​
ts
playerState: Record<string, string>;
revision ​
ts
revision: number;
schemaVersion ​
ts
schemaVersion: 1;
sessionId ​
ts
sessionId: string;
storyId ​
ts
storyId: string;
transitionCause ​
ts
transitionCause: string;

Functions ​

acceptStorySnapshot() ​

ts
function acceptStorySnapshot(
   current, 
   next, 
   sessionId, 
   storyId
): StorySnapshot | null;

Idempotent reducer scoped to an expected session and story.

Parameters ​

ParameterTypeDescription
currentStorySnapshot | nullLast accepted snapshot.
nextStorySnapshotCandidate snapshot.
sessionIdstringExpected session.
storyIdstringExpected story.

Returns ​

StorySnapshot | null

The accepted snapshot, or the previous state.


conversation() ​

ts
function conversation(options): ConversationModule;

Build an optional session manager. Construction does not connect to any service.

Parameters ​

ParameterTypeDescription
optionsConversationOptionsExplicit character allow-list, playback and callbacks.

Returns ​

ConversationModule

An engine module. Call start only after an interview is requested.


createSpeechPlayer() ​

ts
function createSpeechPlayer(
   context, 
   presentation, 
   destination?
): SpeechPlayer;

Build a bounded PCM player. The caller creates/resumes the context in a user gesture.

Parameters ​

ParameterTypeDefault valueDescription
contextAudioContextundefinedShared or dedicated audio clock.
presentationSpeechPresentationundefinedSubtitles, gestures and facial rig.
destinationAudioNodecontext.destinationVoice bus; defaults to the context destination.

Returns ​

SpeechPlayer

A player which owns only its sources, not the context.


parseStorySnapshot() ​

ts
function parseStorySnapshot(value): StorySnapshot | null;

Validate a bounded, versioned story snapshot.

Parameters ​

ParameterTypeDescription
valueunknownUntrusted message data.

Returns ​

StorySnapshot | null

Owned snapshot, or null for invalid data.