API

Getting Started - Chapter 1 - Enhancing Your Website

First Model on a Web Page

Provided the file type is one recognized by Babylon.js, you can use the Babylon Viewer to display your scene or model on a web page using the <babylon-viewer> custom element. Examples of suitable file types are .gltf and .glb. See the importer docs for more details. It makes no difference whether the scene was built with Babylon.js or created with your favorite design software. The <babylon-viewer> element will be sized to fit its container.

The easiest way to try the Babylon Viewer is to reference the distribution script in an HTML page from a free public CDN. For example:

<html lang="en">
<body>
<script type="module" src="https://cdn.jsdelivr.net/npm/@babylonjs/viewer/dist/babylon-viewer.esm.min.js"></script>
<babylon-viewer source="https://playground.babylonjs.com/scenes/BoomBox.glb"></babylon-viewer>
</body>
</html>

For more details, see the main Viewer documentation page and the NPM page.