@babylonjs/viewer
TypeScript icon, indicating that this package has built-in type declarations

8.6.1 • Public • Published

BabylonJS Viewer

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

Using with a Bundler

Install the package using npm:

npm install @babylonjs/viewer

To use the HTML3DElement you can import the @babylonjs/viewer module and then reference the <babylon-viewer> custom element in your HTML like this:

<html lang="en">
    <body>
        <!-- Note: If @babylonjs/viewer is already being imported somewhere in your JavaScript, you don't need this script import. -->
        <script type="module">
            import "@babylonjs/viewer";
        </script>
        <babylon-viewer source="https://playground.babylonjs.com/scenes/BoomBox.glb"></babylon-viewer>
    </body>
</html>

Using Directly in a Browser

If you want to use the viewer directly in a browser without any build tools, you can use the self-contained ESM bundle (which includes all dependencies) through a CDN such as jsDelivr, UNPKG, or your own CDN like this:

<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>

See the codepen.io example for a live demo.

/@babylonjs/viewer/

    Package Sidebar

    Install

    npm i @babylonjs/viewer

    Weekly Downloads

    1,701

    Version

    8.6.1

    License

    Apache-2.0

    Unpacked Size

    32.9 MB

    Total Files

    761

    Last publish

    Collaborators

    • babylonjs