Model Viewer
A 3D model (glTF or GLB) in a stage that turns with drag, wheel, pinch and keys, with views, zoom, reset, animation clips, morph weights (a Float32Array aligned with the target names, or by name) and ARKit expressions eased in the render loop, and an optional floor (a grid, a contact shadow) in the theme's colours. A new model fades in over the old one, keeping its weights. controls="gestures" keeps drag and keys without the bar, for controls of your own through handleRef and useModelViewerControls. The three.js scene (react-three-fiber) is a separate chunk, loaded when the stage nears the viewport and only with WebGL; a poster stands in until then and without WebGL. Agents get rotate, zoom, reset, setView, play, pause and selectClip.
Example
A standing character with dark skin and a red fringed bob, in a blue T-shirt, dark trousers and white socks. Clips: idle, wave.
Installation
lucide-reactthree@0.185.1@react-three/fiber@9.8.0Usage
Reach for it to show a glTF or GLB model people can turn: a product, an avatar, a scan. It costs a small shell up front; three.js loads only when a stage nears the viewport, and only with WebGL.
API reference
ModelViewerScene
| Prop | Type | Default |
|---|---|---|
handlerequired | ModelViewerHandle | – |
modelrequired | ModelViewerSource | undefined | – |
framingrequired | ModelViewerFraming | – |
weightsrequired | ModelViewerWeights | undefined | – |
targetNamesrequired | readonly string[] | undefined | – |
expressionsrequired | ModelViewerExpressions | undefined | – |
scaledWeightsrequired | boolean | – |
materialrequired | ModelViewerMaterial | – |
looprequired | boolean | – |
speedrequired | number | – |
autoRotaterequired | number | – |
floorrequired | boolean | – |
onLoad | (info: ModelViewerLoadInfo) => void | – |
onError | (error: Error) => void | – |
onModelLoad | ModelViewerModelLoad | – |
children | ReactNode | – |
ModelViewer
Takes Omit<PartProps<"div">, "children" | "onLoad" | "onError"> &.
Other exports
clampNumberclampPitchclampZoomdampdampIntoexpressionPrefixfieldOfViewfitBoxDistancefitSizefitSphereDistanceframingMarginRatiomodelViewerViewsnearestAngleorbitPositionpitchRangeviewAnglesviewSizeAtwrapDegreeswriteTargetszoomRangemodelViewerLabelsmodelViewerisMeshisMorphMeshsignatureOftargetNamesOftargetScalesOftoonGradienttoonOfcreateModelRigModelViewerSceneContextcreateFloorisDarkonThemeChangetokenColorloadModeluseModelFlooruseModelFrameuseModelRiguseSceneFrameloopuseModelViewerControlspreloadModelViewertype ModelViewerBoundstype ModelViewerExpressionstype ModelViewerFramingtype ModelViewerOrbittype ModelViewerViewtype ModelViewerWeightstype Vec3type WeightMaptype ModelViewerLabelstype ModelViewerHandletype ModelViewerStatetype ModelViewerChangeReasontype ModelViewerControlsStatetype ModelViewerMotiontype ModelViewerOptionstype ModelViewerStatustype MorphMeshtype LoadedModeltype ModelRigtype ModelViewerMaterialtype ModelViewerSceneStatetype RigInputtype CameraStatetype Channelstype RigFrametype RigSnapshottype ModelViewerFloortype ModelViewerLoadInfotype ModelViewerModelLoadtype ModelViewerSourcetype ModelViewerScenePropstype ModelViewerPropsAccessibility
- The stage is an image named by alt and described by the keyboard hint and the visible summary; with focus, arrows turn, + and - zoom, Home resets.
- Views, zoom, reset, play and the clip picker are named buttons, a segmented control and a native select under the stage; with controls="gestures" your own controls take their place and the stage keeps its keys.
- Under reduced motion clips start paused, auto-rotation stays off and camera moves jump instead of easing.
- Without WebGL, or when loading fails, the poster stays with a message; a failure is announced at once.
Agent actions
Agents see the viewer by its alt with the clips as items, and call rotate, zoom, reset, setView, play, pause and selectClip.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.