Skip to content

Embeddable Session Replay API reference

The Embeddable Session Replay SDK exposes one object, window.EmbeddableSessionReplay, with methods to load sessions, change the display, drive the camera and playback, and listen for events. Use this reference when you write or adjust embed code. For setup, credentials, and the backend route, see Embeddable Session Replay.

Methods

Method What it does
initializeApp(options) Starts the viewer, or switches it to another session. Returns the app. See initializeApp options.
updateConfig(object) Applies a config change object: the shape getConfig() returns, plus playback and a camera move under camera.
updateConfig.<chain> Starts a chain. Every chain method is available and returns the chain.
getConfig() Returns the viewer's current config, with credentials removed.
getConfig(object) / getConfig.<chain> Returns the change object a call stands for. It is validated but not sent.
updateKey(key) Gives the viewer a new credential, as a string or a function.
destroy() Removes the viewer and its listeners. An element the SDK created is removed; an element on your page is emptied.
on(event, listener) Subscribes to an event. Returns an unsubscribe function.
off(event, listener) Unsubscribes.
getPlaybackState() Returns { isPlaying, buffering, currentTimeMs, durationMs, speed, loop }.
getCameraState() Returns { mode, pose: { position, target, fovDeg \| orthoHeight }, autoZoom, bounds, sceneBounds }. bounds is the box the camera is held in (null when free or in First Person). sceneBounds is the box of the scene on screen.
getApp() Returns the running app, or null.
version The SDK version, the same as in the script file name.
elementName "c3d-session-replay".

initializeApp options

Option Type Description
key string or function The credential, or a function that returns it (sync or async). A function is called whenever the viewer asks for a credential. Required on the first call.
projectId number The project ID. Required.
sceneId string The scene ID. Use with sceneVersion for a scene session.
sceneVersion number The scene version number (not its ID).
sessionId / sessionIds string or string[] One or more session IDs.
lobbyId string A multiplayer lobby ID. Alone, it loads the whole lobby; with sessionId, only those sessions.
config object The opening config. See Config fields.
container element or selector Where the viewer goes. A <c3d-session-replay> element is used as is; any other element gets one created inside it. Without it, the SDK uses the first <c3d-session-replay> on the page.
viewerOrigin string The viewer's origin. Needed only when you host the script yourself: "https://replay.cognitive3d.com".

The element also accepts the IDs as attributes: project-id, scene-id, scene-version, session-id, session-ids, lobby-id, and viewer-origin. Options passed to initializeApp() override them.

Chain methods: config

Start a chain with updateConfig. to send it, or with getConfig. to preview the change object without sending it. Each method returns the chain.

Method Sets
updateElevationClip(amount) verticalSliceAmount, from 0 to 1.
setCameraMode(controlType) controlType: orbit, fly, firstPerson, followCamera, or topDown.
setCameraSensitivity(metresPerSecond) camera.cameraSensitivity, from 0.1 to 20.
setInitialCamera({ position, target, fovDeg?, orthoHeight? }) camera.cameraInitialization.
setCameraBounds() Keeps the camera inside the box of the scene on screen.
setCameraBounds({ min, max }) Keeps the camera inside a custom box, in viewer world space.
clearCameraBounds() Lets the camera go anywhere.
focusObject(sdkId) lookAtObject: frames the Dynamic Object with this ID once.
setLightIntensity(percent) renderConfig.lightIntensity.
setPathType('head' \| 'floor') renderConfig.pathType.
setPathSize(size) renderConfig.pathSize.
setCloudPointsSize(size) renderConfig.cloudPointsSize.
setMaxFPS(fps) renderConfig.maxFPS.
setResolutionFactor(factor) renderConfig.resolutionFactor.
setHeatmapConfig(object) heatmapConfig.
setPointCloudConfig(object) pointCloudConfig.
setRender(field, value) Any renderConfig field.
merge(object) Merges a config object into the chain.
toObject() Returns the chain as a plain object.

Chain methods: show, hide, enable, disable

Each pair sets one renderConfig field to true or false.

Methods renderConfig field
showUI() / hideUI() ui
showGrid() / hideGrid() gridEnabled
showLegend() / hideLegend() legendEnabled
showBoundingBox() / hideBoundingBox() boundingBoxEnabled
showAxesHelper() / hideAxesHelper() axesHelperEnabled
showBoundary() / hideBoundary() boundaryEnabled
showAvatarHead() / hideAvatarHead() avatarHeadEnabled
showNamePlates() / hideNamePlates() namePlatesEnabled
showPath() / hidePath() pathVisible
showEventToast() / hideEventToast() eventToastEnabled
showControllerModal() / hideControllerModal() controllerModalEnabled
showFullscreenButton() / hideFullscreenButton() fullscreenButtonEnabled
showSpaces() / hideSpaces() spacesEnabled
showScene() / hideScene() sceneVisible
showSensorHud() / hideSensorHud() sensorHudEnabled
showHeatmap() / hideHeatmap() heatmapEnabled
showCloudPoints() / hideCloudPoints() cloudPointsEnabled
enableAutoplay() / disableAutoplay() autoplay
enableLoop() / disableLoop() loopSession
enableDarkMode() / disableDarkMode() darkMode
enableDarkModeForWidgets() / disableDarkModeForWidgets() darkModeForWidgets
enableAmbientOcclusion() / disableAmbientOcclusion() ssaoEnabled
enablePointsAlwaysOnTop() / disablePointsAlwaysOnTop() pointsAlwaysOnTop

Chain methods: playback and camera

Method What it does
playPlayback() / pausePlayback() Plays or pauses. The last one in a chain wins.
togglePlayback() Toggles play and pause. Two toggles cancel out.
seekPlayback(timeMs) Jumps to a time, in milliseconds from the session start.
setPlaybackSpeed(speed) Sets the speed to 1, 2, or 4. Any other value is rejected.
setCameraPose({ position, target, fovDeg?, orthoHeight? }, durationMs?) Moves the camera to a pose.
resetCamera() Returns the camera to the mode's opening view.
frameObject(sdkId, durationMs?) Frames a Dynamic Object.
frameScene(durationMs?) Frames the whole scene.
frameParticipant(durationMs?) Frames the participant's headset.

A chain carries one camera move; the last one wins. Playback requests wait until the session has loaded its duration.

Example

EmbeddableSessionReplay.updateConfig
  .hideUI()
  .setCameraMode("orbit")
  .setCameraBounds()
  .frameScene(500)
  .setPlaybackSpeed(2)
  .playPlayback();

Events

Subscribe with on(event, listener). The listener receives the detail object.

Event Detail
ready { kind: 'scene' \| 'project' \| 'lobby', sessionIds }, when the viewer has loaded.
error { message, detail }, for bad options, unknown config keys, a refused credential, viewer, camera, or playback errors, and a viewer that doesn't start within 60 seconds.
keyExpired { status }, when a string credential is refused. Call updateKey() with a new one.
config The config after each change, without credentials.
playback The playback state, at most every 250 ms.
camera The camera state, at most every 250 ms.
message Every message from the viewer, without credentials.

Config fields

A config can be passed to initializeApp({ config }) or updateConfig({ ... }). Any other key is logged, emitted as an error event, and dropped.

Top level

Field Type Default Description
controlType string followCamera Camera mode: orbit, fly, firstPerson, followCamera, or topDown.
camera object Camera settings. See camera.
renderConfig object Display settings. See renderConfig.
verticalSliceAmount number, 0 to 1 1 Elevation clip. 0 hides everything above the floor; 1 shows the whole scene.
lookAtObject string Frames the Dynamic Object with this ID once.
heatmapConfig object Heatmap colors and normalization, such as { colorMap: 'default', normalizationMethod: 'minmax', gammaCorrection: 0.55 }.
pointCloudConfig object Aggregation point colors, size, and normalization. Same shape as heatmapConfig.
captureScreen { enabled, fileName? } { enabled: false } Takes one screenshot.
hmdModelUrl string Replaces the headset model with a glTF file.

Don't pass apiKey or projectToken in a config. The SDK rejects them; use key in initializeApp() or updateKey() instead.

camera

Field Type Default Description
cameraSensitivity number, 0.1 to 20 m/s 10 How far keyboard moves, pans, and zooms go.
cameraInitialization { position, target, fovDeg?, orthoHeight? } The opening view, in viewer world space. Orbit and Fly use position, target, and fovDeg. Top Down uses orthoHeight. First Person and Follow Camera ignore it.
cameraBounds { enabled, min?, max? } { enabled: false } Keeps the camera inside a box. Without min and max, the box is the scene's own. First Person is exempt.
cameraControls { orbit?, fly?, topdown?, followCamera? } per mode Per-mode tuning. orbit: rotationSpeed, zoomSpeed, panSpeedMultiplier, minRadius, maxRadius. fly: moveSpeed, lookSpeed. topdown: moveSpeed, zoomSpeed, dragSpeed.

renderConfig

Field Type Default Description
ui boolean true The viewer's own UI.
autoplay boolean false Plays once loaded.
loopSession boolean true Restarts at the end.
darkMode boolean false Dark scene background.
darkModeForWidgets boolean false Dark UI.
sceneVisible boolean true Scene geometry.
gridEnabled boolean Floor grid.
legendEnabled boolean true Heatmap legend.
heatmapEnabled boolean false Aggregated heatmap.
cloudPointsEnabled boolean true Aggregation points.
cloudPointsSize number per mode Aggregation point size, in pixels.
pointsAlwaysOnTop boolean Draws points over geometry.
pathVisible boolean Participant path.
pathType 'head' or 'floor' Path height.
pathSize number, 0 to 1 Path width.
boundaryEnabled boolean Play-area boundary.
spacesEnabled boolean false Saved spaces overlay.
avatarHeadEnabled boolean true Headset model.
namePlatesEnabled boolean true Participant name plates.
eventToastEnabled boolean false Event pop-ups.
controllerModalEnabled boolean true Controller-button overlay.
sensorHudEnabled boolean false Sensor readouts.
fullscreenButtonEnabled boolean false Fullscreen button.
lightIntensity number (percent) Scene lighting.
ssaoEnabled boolean true Ambient occlusion.
ssaoRadius number 0.1 Ambient occlusion radius.
ssaoStrength number, 0 to 1 0.5 Ambient occlusion strength.
sobelEnabled boolean false Edge darkening.
sobelIntensity number 1 Edge darkening strength.
terrainLayer string Map layer for geo sessions.
buildingsMode string 3D buildings for geo sessions: none, osm, or photoreal.
maxFPS number 120 Frame rate cap.
resolutionFactor number 1 Render resolution multiplier. Lower values are faster.
distanceCulling { enabled, maxDistance } { enabled: true, maxDistance: 300 } Hides objects beyond a distance.

Renamed fields

If your config uses an older field, move it as shown. The old names are now logged as unknown keys and dropped.

Old field Now
cameraSensitivity (top level) camera.cameraSensitivity
initialCamera (top level) camera.cameraInitialization
controlSettings (top level) camera.cameraControls
controlSettings.fps camera.cameraControls.fly
cameraSpeed Removed.

See also

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.