HOSTING

Share a 3D model as a link people can rotate

Put a .glb model inside one HTML file with the model-viewer web component, upload it and send a link. The reader can rotate and zoom the model in the browser with no 3D software.

4 min read·

Sending a .glb or .gltf file as an attachment means the reader needs a 3D viewer installed, and most phones and work laptops do not open those files on a tap.

model-viewer is an open-source web component from Google that draws a glTF model in the page with WebGL. Put it and the model in one HTML file, host the file at a link, and the reader drags to rotate and pinches or scrolls to zoom.

Step 1: get a .glb file

model-viewer reads glTF. A .glb file is glTF packed into one binary file, which is what this recipe needs.

  • ✓Blender: File, Export, glTF 2.0, and pick the glTF Binary (.glb) format.
  • ✓A .gltf file with a separate .bin and texture images: pack it into one .glb with the glTF Transform command line tool, npx @gltf-transform/cli copy model.gltf model.glb.
  • ✓Other formats such as STL, OBJ or FBX: import them into Blender and export as .glb.

Step 2: build the HTML file

Create model.html with these parts:

  • ✓<!doctype html>, <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> in the head.
  • ✓In the head: <script type="module" src="https://cdn.jsdelivr.net/npm/@google/model-viewer@4.4.0/dist/model-viewer.min.js"></script>
  • ✓In the body: <model-viewer src="data:model/gltf-binary;base64,..." alt="Describe the model" camera-controls auto-rotate></model-viewer>, with style="width:100%;height:80vh" so it has a size.
  • ✓For the src, base64-encode the .glb. On macOS or Linux, base64 -i model.glb | tr -d '\n' prints it on one line; paste it after the comma.
  • ✓Tested with model-viewer 4.4.0 in Chrome: a .glb inlined this way loaded, fired the load event and drew the model.

File size

Base64 makes the model about a third larger than the .glb. A model of a few megabytes loads quickly; a 50 MB scan makes the reader wait.

To shrink a model, glTF Transform can compress meshes and textures, for example npx @gltf-transform/cli optimize model.glb small.glb. Check the result in the page before you send it.

Upload it and send the link

Drag model.html onto the FileShare Pro dashboard and copy the link. Viewers need no account and no 3D software.

Turn on comments and reviewers can leave a note on the page after typing a name. When the model changes, upload the new file over the old one; the link stays the same: updating a shared link without changing it.

Related: a p5.js or three.js sketch as a link, an SVG file as a link and making an HTML file self-contained.

Frequently asked

How do I share a 3D model as a link?

Embed the .glb in one HTML file with the model-viewer web component, upload the file and send the link. It opens in the browser.

Do viewers need 3D software?

No. model-viewer draws the model with WebGL in a current browser on desktop or phone.

Can I share STL or OBJ files this way?

Convert them to .glb first, for example by importing into Blender and exporting glTF Binary.

Is it free?

Yes. The free plan hosts up to 50 files of up to 100 MB each, with view counts and comments included. Password-protected links are on Pro.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free