How to display a GLB model on your website
Put an AI-generated GLB on a website with model-viewer or Three.js, preserve materials, and test loading and rotation on mobile.
To display an image-generated 3D model on a website, export GLB, host the model as a public asset and load it in a compatible viewer. Use Google's model-viewer component for a simple rotatable object. Use Three.js when you need a custom scene, interactions or rendering behavior.
Keep the original GLB as your master file. An STL export is useful for printing, but it will not retain the model's textures or materials. If your goal is a colored product view, start with the textured asset rather than converting it through STL.
Check that the GLB contains the asset you need
The GLB extension tells you the container format, not whether the file has useful textures. A geometry-only model can be a valid GLB. A textured model may also rely on extensions or resources that your viewer needs to support.
Before embedding, open the exported file in the target viewer and check:
- The object appears with its expected colors and materials.
- The back and underside are suitable for visitors to inspect.
- The origin and orientation produce a sensible camera view.
- Transparent surfaces render as expected.
- The file loads from the actual hosting URL, including any required resources.
If you are still choosing a generator, use the free GLB download checklist. For the format differences, read GLB vs STL.
A simple model-viewer embed
model-viewer is a web component for displaying interactive 3D models. Its official site provides documentation, examples and an editor. The following is a starter HTML example for a model and poster you own; replace the asset paths with your files.
<script
type="module"
src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"
></script>
<style>
.product-3d {
display: block;
width: 100%;
height: 420px;
background: #f4f5f7;
}
</style>
<model-viewer
class="product-3d"
src="/models/ceramic-vase.glb"
poster="/images/ceramic-vase-poster.webp"
alt="Three-dimensional view of a ceramic vase"
camera-controls
touch-action="pan-y"
loading="lazy"
reveal="interaction"
>
</model-viewer>
<p>
<a href="/images/ceramic-vase-poster.webp">View a still image</a>
</p>
This example pins a component version so that behavior does not silently change with an unversioned CDN release. Review the current official release and examples before choosing a production version. You can also install or host the component through your own build pipeline.
The poster gives visitors a useful still image before the model is revealed. camera-controls allows rotation and zoom. touch-action="pan-y" keeps vertical page scrolling available on touch devices. Reserve the viewer's height so that loading does not move surrounding content.
The snippet displays a model; it does not generate one or add checkout, AR or product configuration. Add those capabilities deliberately if your product needs them.
Host the model as a stable public asset
A local path such as /models/ceramic-vase.glb must resolve on your deployed website. A temporary download URL from a generation provider is often unsuitable as a permanent storefront asset. Store the file on infrastructure you control, subject to the provider's retention and license terms.
Serve GLB with the model/gltf-binary content type. If the asset is on a different origin, configure CORS to allow the website to fetch it. Test the exact deployed URL in an unauthenticated browser. A link that works only in your logged-in generation session will not work for ordinary visitors.
If the model contains external image or buffer references, host those resources too and preserve their paths. For simpler deployment, export a self-contained asset where your tool supports it. A missing texture is often an asset-path problem rather than a geometry problem.
When Three.js is the better fit
Choose Three.js when the 3D object is part of a larger experience: a game, a scene with several interactive objects, a custom lighting setup or a configurator with application-specific behavior.
The Three.js GLTFLoader documentation describes loading glTF and GLB. Compressed geometry or textures may require matching decoders and loader configuration. A successful uncompressed test does not establish that a compressed export will work with the same setup.
A custom scene also makes you responsible for camera controls, loading and error states, resizing, resource cleanup and accessible alternatives. A small product viewer is often easier to maintain with a dedicated component; a custom application can justify the extra control.
Optimize the file and test the result
Start by measuring the original. Note the GLB's transfer size, triangle count, texture dimensions, loading time and responsiveness on a representative phone. There is no universal file-size or polygon threshold that fits every scene and device.
The official glTF Transform CLI supports inspection and optimization. For example:
gltf-transform inspect original.glb
gltf-transform optimize original.glb web.glb --compress draco --texture-compress webp
Run these commands on copies with the CLI installed. The optimization command may change geometry and texture representation; check decoder and texture support in your viewer. Inspect both visual quality and actual loading after the transformation. The smaller output is useful only if it remains compatible and preserves the details that matter.
Possible adjustments include reducing unnecessary geometry, resizing oversized textures, removing unused data and selecting suitable geometry or texture compression. A high-resolution texture on a tiny prop may add transfer and memory cost without useful visible detail. Draco and Meshopt affect geometry delivery; KTX2/Basis workflows address texture delivery and GPU usage. They solve different parts of the problem.
A mobile launch checklist
- Open the production page on a phone with a fresh browser session. Confirm the poster is useful before interacting.
- Reveal the model, rotate a full turn and zoom. Check that scrolling the page still feels natural.
- Try a slower connection. Confirm there is a useful loading state and a still-image fallback if the asset fails.
- Navigate away and back. Check that the page remains responsive and that a custom viewer releases resources when removed.
- Compare the optimized asset with the original from the same views and lighting.
For ecommerce, also compare the model against the actual product. Our image-to-3D ecommerce guide covers dimensions, variants and product accuracy.
Where Image to STL fits
Use the image workbench to explore image-generated geometry and prepare a print. Use a textured GLB workflow when the website must reproduce colors and materials. If you later need a print of that web model, export a separate STL copy locally.
Website display and printing can share a source model while requiring different deliverables. Keeping the GLB avoids throwing away material information that you may want for the next version.
Sources
Technical references checked November 18, 2026: model-viewer, Three.js GLTFLoader, Khronos glTF and glTF Transform CLI. The code is an integration example, not a measured performance claim.