3D Model Viewer Embed Tool

Live Sample

Single 3D Model Viewer (chair0):

1. Include tool.js

Host tool.js on any HTML page:

<!-- Include tool.js --> <script src="https://usdc-testing.s3.us-east-1.amazonaws.com/tool.js"></script>

2. Add a Container

Create a simple container div where the 3D viewer will be rendered:

<div id="my-model-viewer" style="width: 100%; height: 600px;"></div>

3. Initialize the Viewer

Call initModelViewer once the page has loaded:

<script> document.addEventListener('DOMContentLoaded', () => { initModelViewer({ containerId: 'my-model-viewer', modelId: 'chair0', // required envMap: 'studio_small_09', // optional (uses model-viewer default HDRI if not specified) theme: 'theme3', // optional enableAR: true, // optional (default: true) arPlacement: 'floor', // optional (default: 'floor', options: 'floor' or 'wall') exposure: '0.85', // optional (default: '0.85') enableFullscreen: true, // optional (default: true) postProcessing: { // optional brightness: 100, // 0–200 (default 100) contrast: 100, // 0–200 (default 100) saturation: 100, // 0–200 (default 100) gamma: 100, // 50–200 (default 100) hue: 0, // -180–180 (default 0) temperature: 6500, // 2000–10000 (default 6500) red: 100, // 0–200 (default 100) green: 100, // 0–200 (default 100) blue: 100 // 0–200 (default 100) } }); }); </script>

API Reference: initModelViewer(options)

URL Parameters

You can override the model ID and automatically trigger fullscreen using URL parameters. This is useful for deep linking to specific models or creating shareable links.

Note: URL parameters will override the modelId specified in your initModelViewer call, but all other settings (containerId, theme, etc.) remain unchanged.

Available Parameters:

Examples:

// Load chair1 model (overrides modelId in initModelViewer) https://yoursite.com/page.html?arboost-id=chair1 // Load chair1 and automatically enter fullscreen https://yoursite.com/page.html?arboost-id=chair1&arboost-fullscreen=true // Your code remains the same - URL parameters are handled automatically initModelViewer({ containerId: 'my-viewer', modelId: 'chair0', // This will be overridden by ?arboost-id=chair1 enableAR: true, enableFullscreen: true });
How it works: When initModelViewer is called, the wrapper function automatically checks for URL parameters. If arboost-id is present, it replaces the modelId in your config. If arboost-fullscreen=true is present, it automatically triggers the fullscreen button after the viewer initializes. No changes to your code are required!