WebberUI

Model Viewer

three.js 3D 模型軌道檢視器

低多邊形 3D 模型軌道檢視器:拖曳自由旋轉、放開帶慣性、自動旋轉與方向光即時打光。純 canvas 2D 投影模擬,無 WebGL、無外部相依。

載入預覽⋯

Playground

即時調整 props、程式碼片段同步更新——直接試出你要的樣子再複製。

26
<ModelViewer />

安裝

npx shadcn@latest add https://webberui.com/r/model-viewer.json

或在 components.json 設定 registries 後,改用 @webberui/model-viewer 安裝。

安裝依賴後,從 registry JSON(/r/model-viewer.jsonfiles[0].content)複製 model-viewer.tsx 原始碼到你的 components/ui/ 目錄:

npm install motion clsx tailwind-merge

使用

import { ModelViewer } from "@/components/ui/model-viewer";

<ModelViewer model="icosahedron" color="#818cf8" className="h-[320px] w-full" />

model 可選 icosahedroncubeoctahedrontorus。容器需自備明確高度(例如 h-[320px])。

Props

Prop型別預設值說明
model"icosahedron" | "cube" | "octahedron" | "torus""icosahedron"內建幾何
colorstring"#818cf8"模型主色(十六進位),面光影由此色明暗調變
wireframebooleanfalse線框模式,只描邊不填色
autoRotatebooleantrue是否自動繞 Y 軸旋轉
autoRotateSpeednumber26自動旋轉速度(度/秒)
interactivebooleantrue允許拖曳軌道旋轉,放開後帶慣性
ambientnumber0.32環境光比例(0~1),越高整體越亮、對比越弱
floorbooleantrue在模型下方畫柔和接觸陰影

可及性

  • 使用者系統開啟「減少動態效果」時,停用自動旋轉與拖曳,僅以預設角度渲染一幀靜態畫面
  • canvas 標記 aria-hidden,屬純裝飾層,不干擾輔助科技

On this page