Embedding in Your Website
Overview
Section titled “Overview”Use <rv-embed> to place a prepared GLB twin inside your page. The lightweight
viewer renders the model and runs its supported simulation in the visitor’s
browser. Your page controls the surrounding text and link to the full application.
Quick start
Section titled “Quick start”Build the Community library with npm run build:embed and serve the complete
dist-embed/ directory at /embed/. Add your model and poster, then include:
<script type="module" src="/embed/rv-embed.js"></script><rv-embed src="/models/machine.glb" poster="/images/machine.webp" look="studio" interactive="drag" hide="#frame-node-id,#table-node-id" background="transparent" aria-label="Interactive machine model" style="width: 100%; height: 420px"></rv-embed>Replace the paths with your files. Replace hide with authored NodeIds from your
model, or remove it. Give the element a height so its canvas has room to render.
Attributes
Section titled “Attributes”| Attribute | Values and behavior |
|---|---|
src | GLB URL; changing it loads a new model |
poster | Image shown until the rendered model is ready |
look | studio adds room reflections, soft shadows and a shadow ground; omit for default lighting |
interactive | orbit-on-click (default), none, full, or drag |
hide | Comma-separated authored NodeIds such as #frame-id,#table-id |
background | CSS color; default #1a1d21; transparent blends into your page |
run | when-visible (default) or manual; automatic loading waits for visibility and respects reduced motion |
dpr-cap | Positive pixel-ratio cap; default 1.5 |
director | Name of a director script authored in the model |
none disables navigation, full enables it immediately, and orbit-on-click
waits for a click or tap. hide uses IDs stored in the GLB, rather than names or
paths. It hides parts before model preparation while preserving their hierarchy.
Missing IDs produce a browser console warning.
Live PLC and mechanisms
Section titled “Live PLC and mechanisms”To run a model’s virtual PLC programs and mechanism motion inside the embed, use rv-embed-pro: see Live PLC and mechanisms in embeds.
Performance & SEO
Section titled “Performance & SEO”For a prominent hero, put a normal poster image in the initial HTML with explicit
dimensions, eager loading and fetchpriority="high". Let that image be the
Largest Contentful Paint (LCP) while the live view starts later. Keep the live
view in the same fixed-size box to avoid layout shifts.
Load the live module after the page’s load event and an idle opportunity. On
mobile devices, with Save-Data enabled or reduced motion requested, keep only
the poster and a link to the full application. Implement these rules in your
website: the embed handles visibility and reduced motion, but does not itself
provide mobile or Save-Data poster-only gating.
For SEO, treat Googlebot as unable to render the WebGL scene as indexable page content. Put machine descriptions, benefits and links in ordinary HTML; the poster and canvas enhance that text.
Opening the full application
Section titled “Opening the full application”Link to the same published document in the full viewer. Replace the example document ID with one in your deployment:
<a href="https://web.realvirtual.io/demo/?doc=YOUR_DOCUMENT_ID&mode=commissioning&entry=usecase#cam=4,3,4,0,0,0" target="_blank" rel="noopener">Open full application</a>#cam=px,py,pz,tx,ty,tz passes the camera position and target in scene coordinates.
The full viewer applies the six finite numbers after its scene and start view
are ready. Invalid values are ignored.
To pass the current view, retain the underlying viewer from the rv-ready
event’s detail.viewer, then update the link when it opens:
const values = [ ...viewer.controls.object.position.toArray(), ...viewer.controls.target.toArray(),];link.hash = `cam=${values.join(',')}`;This opens the same model and camera view; it does not transfer simulation state.
Self-hosting
Section titled “Self-hosting”Upload the complete build directory with its layout intact, including chunks, Draco decoders, WASM assets and third-party notices. Copying just the entry JavaScript file breaks dependency loading. Serve it over HTTP(S).
Serve JavaScript with a JavaScript MIME type and WASM as application/wasm.
For modules, models or dependencies on another host, configure CORS there to
allow your website’s origin. Check final URLs in the browser network panel.
Your model’s referenced assets must also be reachable. Community licence
obligations still apply when you self-host.
Host the embed build on the same origin as your page where you can. Browsers do not start web workers from another origin; the embed then prepares models on the main thread, which works but takes longer for large models.