Viewer SDK API¶
The Viewer SDK exposes a semantic JavaScript API. Engine operations, transport names, the WebAssembly module, and engine messages are private implementation details.
Scene and lifecycle¶
| Method | Result | Purpose |
|---|---|---|
WebexViewer.mount(options) | Promise<WebexViewer> | Create an isolated viewer runtime. |
load(url) | Promise<this> | Load a .webex scene and resolve when it is interactive. |
close() | void | Close the current scene. |
destroy() | void | Stop the runtime, reject pending work, and release resources. |
resize() | this | Notify the runtime after an application-controlled layout change. |
Presentation and camera¶
| Method | Purpose |
|---|---|
setQuality(quality) | Select medium, high, or ultra rendering quality. |
setBackground(color) | Set the viewer background color. |
setAutospin(enabled) | Start or stop automatic rotation. |
setInfotag(enabled) | Show or hide the information overlay. |
zoom(direction) | Zoom with '+1' or '-1'. |
centerView() | Re-center the camera on the product. |
capture(timeout?) | Resolve with a JPEG data URL for the current view. |
Scene content and properties¶
| Method | Result | Purpose |
|---|---|---|
setMaterial(layer, material) | void | Apply a library material to a layer. |
setProperty(node, property, value) | void | Set a documented scene property. |
getProperty(node, property, timeout?) | Promise<string> | Read a documented scene property. |
getSceneObjects(timeout?) | Promise<WebexSceneObjects> | Read the structured scene-object description. |
Layer visibility is a property:
viewer.setProperty('Heart Head', 'obj_visible', 'false');
Authored product choices¶
| Method | Result | Purpose |
|---|---|---|
readMaterialChoices(timeout?) | Promise<WebexChoiceCatalog> | Read authored material choices. |
applyMaterialChoice(choice, option, timeout?) | Promise<this> | Apply one material choice option. |
applyDefaultMaterialChoices(timeout?) | Promise<this> | Apply all authored material defaults. |
readObjectChoices(timeout?) | Promise<WebexChoiceCatalog> | Read authored object choices. |
applyObjectChoice(choice, option, timeout?) | Promise<this> | Apply one object choice option. |
applyDefaultObjectChoices(timeout?) | Promise<this> | Apply all authored object defaults. |
Choice and option identifiers are numeric slots stored in the scene. Read the catalog and use its slot values; do not infer identifiers from array positions.
const { choices } = await viewer.readMaterialChoices();
const choice = choices[0];
const option = choice.options[0];
await viewer.applyMaterialChoice(choice.slot, option.slot);
Multipart products and virtual try-on¶
| Method | Result | Purpose |
|---|---|---|
mergePart(id, source, options?) | Promise<this> | Add or atomically replace a keyed URL or binary part. |
removePart(id, timeout?) | Promise<this> | Remove one keyed part. |
clearParts(timeout?) | Promise<this> | Remove every keyed part. |
pushTrackingPose(packet) | boolean | Submit one validated high-frequency virtual try-on pose. |
Promise resolution is the authoritative completion signal. Rejections are WebexViewerError instances with a stable code.
Events¶
on(), once(), and off() accept only the documented semantic lifecycle events. See Events for their payloads. The SDK intentionally provides no raw message subscription, generic send function, command table, or WebAssembly module access.