← All Components
<mth-model-viewer>
Wrap-first Three.js <mth-model-viewer> component featuring lazy WebGL/WebGPU renderer attachment, keyboard orbit/zoom/reset controls, MotionController reduced-motion gating on autoRotate, URL sanitization, and poster/fallback slots.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
3D Stage Ready (WebGL with automatic headless fallback)
Ready · interact with <mth-model-viewer>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/3d/model-viewer"></script>
<mth-model-viewer renderer-backend="auto" auto-rotate-speed="2"></mth-model-viewer>import '@methane-ui/3d/model-viewer';
import '@methane-ui/react';
export function Example() {
return <mth-model-viewer renderer-backend="auto" auto-rotate-speed="2"></mth-model-viewer>;
}<script setup lang="ts">
import '@methane-ui/3d/model-viewer';
</script>
<template>
<mth-model-viewer renderer-backend="auto" auto-rotate-speed="2"></mth-model-viewer>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/3d/model-viewer';
import { MthModelViewerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthModelViewerDirective],
template: `<mth-model-viewer renderer-backend="auto" auto-rotate-speed="2"></mth-model-viewer>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/3d/model-viewer';
import MthModelViewer from '@methane-ui/svelte/MthModelViewer.svelte';
</script>
<MthModelViewer renderer-backend="auto" auto-rotate-speed="2"></MthModelViewer>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
src | src | string | "" | glTF/GLB model URL (validated with @methane-ui/sanitize isSafeUrl). |
poster | poster | string | "" | Optional preview poster image URL shown until the 3D scene loads. |
alt | alt | string | "" | Accessible description of the 3D model. |
rendererBackend | renderer-backend | 'auto' | 'webgl' | 'webgpu' | "auto" | Preferred Three.js rendering backend (auto, webgl, or webgpu). |
autoRotate | auto-rotate | boolean | false | Enables continuous camera turntable rotation (disabled automatically under prefers-reduced-motion: reduce). |
autoRotateSpeed | auto-rotate-speed | number | 2 | Turntable rotation speed multiplier. |
cameraOrbitTheta | camera-orbit-theta | number | 0 | Horizontal camera azimuth angle in degrees. |
cameraOrbitPhi | camera-orbit-phi | number | 75 | Vertical camera polar angle in degrees. |
cameraDistance | camera-distance | number | 4 | Camera orbit distance from origin. |
exposure | exposure | number | 1 | Tone-mapping exposure multiplier. |
showControls | show-controls | boolean | true | Shows interactive accessible camera toolbar controls. |
loading | loading | boolean | false | Indicates active model/renderer loading. |
error | error | string | "" | Error message when model load or URL validation fails. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-model-load | { src: string; backend: 'webgpu' | 'webgl' | 'headless' } | Emitted when the Three.js model finishes loading. |
mth-camera-change | { theta: number; phi: number; distance: number } | Emitted when camera orbit or zoom updates. |
mth-model-error | { message: string } | Emitted when model URL validation or glTF load fails. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowLeft | ltr | 3D viewport is focused | orbits camera left |
| ArrowRight | ltr | 3D viewport is focused | orbits camera right |
| ArrowUp | both | 3D viewport is focused | tilts camera upward |
| ArrowDown | both | 3D viewport is focused | tilts camera downward |
| + | both | 3D viewport is focused | zooms camera closer |
| - | both | 3D viewport is focused | zooms camera farther |
| Home | both | 3D viewport is focused | resets camera orbit and distance |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 7 APG keyboard transitions across LTR/RTL. | mth-model-viewer.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(loading), :state(error), :state(loaded), :state(auto-rotating), :state(reduced-motion). | Conformance suite |
| i18n | Routes 8 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |