Skip to content

ES module viewer

Open the example · JavaScript source

ES module viewer example

This example uses the module build, which is ideal for Vite, webpack, Rollup, and modern browser projects. It does not create window.WebexViewer or any WASM protocol globals.

import { WebexViewer } from './components/viewer/webex-viewer.mjs';

const viewer = await WebexViewer.mount({
  canvas: '#canvas-viewer',
  apiKey: window.WEBEX_API_KEY,
  scene: './scenes/scene.webex'
});

The example disables controls during await viewer.load(...), calls viewer.setMaterial(...), and calls viewer.close() before loading a different scene. In a single-page application, call viewer.destroy() when the component unmounts.