Skip to main content

3D Viewer and Editor Quickstart

We offer some pre-built templates for setting up a 3D Viewer or our sandbox editor with all basic plugins. Use these templates if not much customisation is required or to create proof of concept and demo applications.

WebGi Viewer setup (HTML)

Easiest way is to use the webgi-viewer web component with a src file (glb/gltf) and optionally an environment map (hdr/png)

<!--Add this script tag in the page head-->
<script src=""> </script>
<!--Add the viewer element somewhere inside the body of the page.-->
style="width: 100%; height: 100%; z-index: 1; display: block;"
Try this example on codepen here: WebGi Viewer HTML Component

The viewer can be accessed later in javascript to change the model, add plugins, make changes.

const element = document.getElementById('viewer-3d');

element.addEventListener('initialized', ()=>{
const viewer = element.viewer; // `ViewerApp`
// Use the viewer
viewer.getPlugin(DepthOfFieldPlugin).enabled = true;



Include the complete bundle js (instead of the viewer) to access all plugins and utilities.

<script src=""> </script>

WebGi Viewer setup (JS)

First, include the viewer js file in the HTML (ideally in the head portion)

<script src=""> </script>

This file is already optimised and minified, no extra processing is required.

Now, add the canvas and the javascript code in any script tag to initialise the viewer in a canvas and load a model.

<canvas style="width:100%; height: 300px;" id="webgi-canvas"></canvas>
const viewer = new CoreViewerApp({canvas: document.getElementById('mcanvas')})
caching: true,
ground: true,
bloom: true,
depthTonemap: true,
enableDrop: false,
importPopup: false,
debug: false
const model = "";

or by adding plugins manually and loading a model

<canvas style="width:100%; height: 300px;" id="webgi-canvas"></canvas>
async function setupViewer(){
const viewer = new ViewerApp({canvas: document.getElementById('mcanvas')})
// Add some plugins
await viewer.addPlugin(AssetManagerPlugin);
// Add all the important plugins at once: to see the plugins list and default settings, check:
await addBasePlugins(viewer);

// Load a 3d model.
await viewer.load("");

// Load an environment map
await viewer.setEnvironmentMap("");


The environment map must be loaded separately if not present in the `glb` model. Check the editor sample below which loads the environment map.

<iframe height="400" width="100%" scrolling="no" title="Sample WebGI Viewer" src="" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
See the Pen <a href="">
Sample WebGI Viewer</a> by Palash Bansal (<a href="">@repalash</a>)
on <a href="">CodePen</a>.
Check the codepen links below for an example.

## Sandbox editor setup
Same as for the viewer, include the webgi bundle `js` file in the HTML (ideally in the `head` portion)
<code language="html">{`<script src="${siteConfig.customFields.sdkVersion}.js"> </script>

Do not use the complete bundle in production for just a viewer, it also contains a UI library and many utils. <br />
Check the latest version in the Readme.

Now, add the below javascript code in any script tag to initialise the viewer with sandbox UI in a canvas and load a model.
{ canvas: document.getElementById("my-canvas") },
).then((viewer) => {


This loads an environment map. Now, any model can be drag and dropped.

Check the codepen links below for a complete example.

ES6 module bundles

It's recommended to use module bundles to import and add just the plugins that are required for the applications to keep the size small and get good performance.

NPM module

The SDK can be added to package.json with module bundle and type declarations like this:

"devDependecies": {
"webgi": "",
"@types/webgi": "",

JS Import

The complete SDK can also be imported as a ES6 module from a single JS file.

<script type="module">
import {ViewerApp} from "";


For more details on the ViewerAPI, check the API Getting Started page.

Note: You can see the imported JS files in CodePen by going into pen settings -> JS tab -> external files.