Blueprint Models

Embed the models

Every model in the gallery is a single HTML element you can put in your own site or app: one script tag from a CDN, or one npm package.

npm install blueprintspace

Playground

Pick a model and its options; the code underneath is what you'd paste into your page.

Model
Theme
Render
Options
Angle
45°
Elevation
model's own
HTML

Quick start

From a CDN

Add the script once, then use the element anywhere on the page.

HTML
<script type="module" src="https://cdn.jsdelivr.net/npm/blueprintspace@{v}/index.js"></script>

<blueprint-model model="gameboy" theme="amber" render="photo"></blueprint-model>

From npm

Terminal
npm install blueprintspace
JavaScript
import "blueprintspace";                        // registers <blueprint-model>
import { models, thumbnail, BlueprintModel } from "blueprintspace";

The models load from the jsDelivr CDN by default, matching the installed version, so nothing else needs copying. To serve them yourself, see self-hosting.

Frameworks

It's a standard custom element, so it works in any framework, or none.

React

JSX
import "blueprintspace";
import { useRef } from "react";

export function Hero() {
  const ref = useRef(null);
  return (
    <>
      <blueprint-model ref={ref} model="ps5" render="shaded" autorotate="15" style={{ width: "100%" }} />
      <button onClick={() => ref.current.explode()}>Take it apart</button>
    </>
  );
}

React 19 sets the element's properties directly. In React 18, give boolean options as strings (animation="true", xray="false") or set them through the ref (ref.current.animation = true).

Vue

Vue
<script setup>
import "blueprintspace";
</script>

<template>
  <blueprint-model model="v8" render="photo" :animation="true" :transparent="true" />
</template>

Tell Vue it's a custom element: compilerOptions.isCustomElement = tag => tag === "blueprint-model" in the Vue plugin's options.

Svelte

Svelte
<script>
  import "blueprintspace";
  let el;
</script>

<blueprint-model bind:this={el} model="walkman" theme="navy" render="shaded" />
<button on:click={() => (el.exploded = !el.exploded)}>Explode</button>

Attributes and properties

A model opens at a 45° view from its right side and holds it: people can zoom in and take it apart, but not turn it. Change the view with angle and elevation, or set locked="false" to let them turn it.

Every option is both an HTML attribute and a JavaScript property on the element. Boolean attributes are on when present (or "true") and off with "false". All of them change live except model, base and motion, which reload the model.

Attribute / propertyValuesDefaultWhat it does
modela model id—Which model to show. See the list.
themedark light amber navy lime, each with :invdarkThe colours. :inv swaps background and lines. In the Photo render it sets the backdrop.
renderlines shaded photolinesLine drawing, flat-shaded, or a photoshoot-style render with materials, textures and shadows.
animationbooleanoffPlays the model's own animation: a screen, a game, an LED pattern. Models without one ignore it.
transparentbooleanoffShows your page behind the model, in every render style.
xraybooleanonHidden edges faintly visible through the parts.
explodedtrue false, or absenthovertrue takes it apart, false holds it assembled; without the attribute it comes apart while hovered.
labelsbooleanoffCallout labels on the parts.
controlsbooleanoffThe model page's own buttons, title and hints.
angledegrees45The view's angle round the model, from the front towards its right side: 0 straight on, 90 the right side, -45 from the left.
elevationdegreesthe model's ownHow high the view is, above the model.
lockedbooleanonHolds the view at its angle so the pointer can't turn it; zoom and taking it apart still work. locked="false" lets people turn it.
autorotateboolean, or degrees a secondoffA slow turn: autorotate at 12°/s, or autorotate="30". It turns even while locked.
interactivebooleanonTurn, zoom and take it apart with the pointer. Off makes it a still picture that ignores the pointer.
motionbooleanonMoving parts (fans, reels, cranks) and camera easing. Off keeps everything still.
basea URLthe CDNWhere models/ and thumbs/ are served from.
HTML
<blueprint-model model="playdate" render="photo" theme="amber"
  animation transparent xray="false" autorotate="20"></blueprint-model>
JavaScript
const el = document.querySelector("blueprint-model");
el.animation = true;      // start its animation
el.transparent = true;    // let the page show through
el.xray = false;          // no hidden edges
el.exploded = true;       // take it apart (false: together, null: on hover)
el.autorotate = 20;       // degrees a second (0 stops)
el.interactive = false;   // a still picture
el.angle = 90;            // see it from the right side
el.locked = false;        // let people turn it
el.theme = "navy:inv";
el.render = "shaded";

Methods and events

MethodWhat it does
explode()Takes it apart, or puts it back together.
toggleAnimation()Starts or stops its animation.
tour()Plays the "how it works" tour.
reset()Back to the starting view.
setTheme(t), setRender(r)The same as setting theme or render.
EventWhen
readyThe model has loaded and will take commands. event.detail holds { model, title }.
JavaScript
el.addEventListener("ready", e => console.log("loaded", e.detail.title));
el.info;                  // { id, label, kind, category, tags }
BlueprintModel.models;    // every model in the package

Sizing

The element behaves like an image: it fills the width it's given at a 4:3 ratio. Give it a height, or an aspect-ratio, to change that. It's an ordinary block element, so CSS layout, borders, rounded corners and shadows all apply.

CSS
blueprint-model { width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; }
blueprint-model::part(frame) { /* the iframe inside, if you need it */ }

Each model runs in its own sandboxed iframe, so its scripts and styles never touch your page and yours never touch it.

Self-hosting

By default the models load from jsDelivr. To serve them from your own domain, copy the package's models/ and thumbs/ folders into your public folder, then point the element at them, once for every element or on one.

Terminal
cp -r node_modules/blueprintspace/models node_modules/blueprintspace/thumbs public/blueprintspace/
JavaScript
import { BlueprintModel } from "blueprintspace";
BlueprintModel.base = "/blueprintspace/";        // the folder holding models/ and thumbs/
HTML
<blueprint-model base="/blueprintspace/" model="v8"></blueprint-model>

The model pages load three.js from cdnjs and their fonts from Google Fonts.

Thumbnails

Every model also comes as a still line drawing, white on transparent. thumbnail(id) gives its URL. Use it as an <img>, or as a CSS mask to colour it with any colour.

JavaScript
import { thumbnail } from "blueprintspace";
img.src = thumbnail("gameboy");
CSS
.icon {
  background: currentColor;
  mask: url(https://cdn.jsdelivr.net/npm/blueprintspace@{v}/thumbs/v8.webp) center / contain no-repeat;
}

Models

Click one to load it into the playground. Its model id is under its name.