webvis API Reference#

Getting Started

webvis is a web-based 3D visualization client for instant3Dhub. It streams and renders large CAD and 3D datasets in the browser and exposes a single, unified JavaScript/TypeScript API for numerous functionalities of instant3Dhub: loading models, controlling the camera, selecting and styling geometry, measuring, clipping, annotating etc.

This reference is aimed at developers who consume the webvis API in their own web apps.

webvis is served by your instant3Dhub at <hubURL>/repo/webvis/webvis.js. Load it with a regular <script> tag, no build step required, and use the global webvis object it defines. A context holds the 3D scene; a viewer renders it into a canvas.

<!DOCTYPE html>
<html>
<body>
    <canvas id="my-canvas" style="width: 100vw; height: 100vh;"></canvas>

    <!-- Load webvis straight from the hub; it defines the global `webvis` -->
    <script src="https://your-hub.example.com/repo/webvis/webvis.js?next"></script>

    <script type="module">
        // 1. Create a context (the scene + connection to the hub)
        const context = await webvis.requestContext("my-context", {
            hubURL: "https://your-hub.example.com/"
        });

        // 2. Create a viewer bound to the canvas element
        const canvas = document.getElementById("my-canvas");
        const viewer = context.createViewer("my-viewer", canvas);

        // 3. Add content - add() returns a numeric nodeID
        const nodeID = context.add({
            dataURI: "urn:x-i3d:examples:x3d:v8",
            label: "My Model",
            initialProperties: { enabled: true }   // make it visible
        });

        // 4. React to changes via the event system
        context.registerListener(
            [webvis.EventType.NODE_CHANGED],
            (event) => console.log("node changed:", event)
        );

        // 5. Frame the model in the view
        viewer.fitView();
    </script>
</body>
</html>

Everything after step 1 is reached through the context object: it is a facade that aggregates all sub-APIs (see ContextAPI).

See Development Setup for details on loading webvis and using it with TypeScript.