🧭 TypeScript Binding — Core API Map

This page explains how the TypeScript API maps to the core command protocol. You do not need to manually build command batches — the binding does that for you.


The Execution Flow

  1. You call a TS function (e.g. createModel, updateTransform)
  2. The engine stores an intent in the world
  3. Systems turn intents into core commands during tick()
  4. Commands are MessagePack-encoded and sent in a single batch

Engine Lifecycle

TypeScript API Core Behavior
initEngine({ transport }) Calls vulframInit() in the transport
disposeEngine() Calls vulframDispose() and clears world state
tick(timeMs, deltaMs) Polls events + responses, runs systems, sends command batch

World & Window

TypeScript API Core Command(s)
createWorld(worldId) Creates a host world (no core call yet)
createWindow(worldId, props) cmd-window-create
closeWindow(worldId) cmd-window-close
updateWindow(worldId, props) cmd-window-* variants (title/size/pos/state/etc)
requestAttention(worldId) cmd-window-request-attention
focusWindow(worldId) cmd-window-focus

Entities & Components

TypeScript API Core Command(s)
createEntity(worldId) Host-side entity allocation + intent
removeEntity(worldId, entityId) Disposes camera/light/model if needed
createCamera(...) cmd-camera-create (+ update on transform changes)
createLight(...) cmd-light-create (+ update on transform changes)
createModel(...) cmd-model-create (+ update on transform changes)
updateTransform(...) cmd-*-update for attached components

Resources

TypeScript API Core Command(s)
createGeometry(worldId, props) cmd-geometry-create or cmd-primitive-geometry-create
createMaterial(worldId, props) cmd-material-create
createTexture(worldId, props) cmd-texture-create-*
uploadBuffer(bufferId, type, data) vulframUploadBuffer(...) (out-of-band)
disposeGeometry/Material/Texture cmd-*-dispose

Events & Responses

  • Events (keyboard, pointer, window) are polled on every tick() and mirrored into the InputState and WindowState components.
  • Responses for commands are routed back to the world that created them.

Input Helpers

These read from the InputState component created by the input system:

  • isKeyPressed, isKeyJustPressed, isKeyJustReleased
  • isMouseButtonPressed, isMouseButtonJustPressed
  • getMousePosition, getMouseDelta, getScrollDelta
  • getWindowSize, getWindowPosition, isWindowFocused

Important Constraints

  • The core expects to be driven from one thread.
  • You must call tick() every frame — this is how commands and events flow.
  • World ID must match the window ID used by the core.
Documentation Vulfram Core