Loading...
Loading...
Compare original and translation side by side
Skill by ara.so — Daily 2026 Skills collection.
3dsvg<SVG3D>由ara.so提供的技能 — 属于Daily 2026 Skills合集。
3dsvg<SVG3D>npm install 3dsvgnpm install 3dsvg
**Peer dependencies** (install if not already present):
```bash
npm install three @react-three/fiber @react-three/drei
**Peer dependencies**(若尚未安装则需安装):
```bash
npm install three @react-three/fiber @react-three/dreiimport { SVG3D } from "3dsvg";
// Spin text in 3D
<SVG3D text="Hello" animate="spin" />
// 3D logo from SVG file
<SVG3D svg="/logo.svg" material="gold" />
// Pixel editor input
<SVG3D svg="<svg>...</svg>" material="chrome" animate="float" />import { SVG3D } from "3dsvg";
// 让文本以3D形式旋转
<SVG3D text="Hello" animate="spin" />
// 从SVG文件生成3D Logo
<SVG3D svg="/logo.svg" material="gold" />
// 像素编辑器输入
<SVG3D svg="<svg>...</svg>" material="chrome" animate="float" />import { SVG3D } from "3dsvg";
<SVG3D
// Input (choose one)
text="Hello World" // Text string (uses Google Fonts)
svg="/path/to/file.svg" // URL to SVG file
// svg="<svg>...</svg>" // Raw SVG markup string
// Font (when using text=)
font="Inter" // Google Font name (10 presets available)
// Material preset
material="default" // "default" | "plastic" | "metal" | "glass"
// "rubber" | "chrome" | "gold" | "clay"
// "emissive" | "holographic"
// Animation
animate="spin" // "spin" | "float" | "pulse" | "wobble"
// "swing" | "spin+float" | undefined (static)
// Geometry
depth={0.2} // Extrusion depth (default: 0.2)
bevelEnabled={true} // Enable bevel on edges
bevelThickness={0.02} // Bevel thickness
bevelSize={0.02} // Bevel size
bevelSegments={3} // Bevel smoothness
// Lighting
ambientIntensity={0.5} // Ambient light (0–1)
keyLightIntensity={1.0} // Key light brightness
keyLightX={5} // Key light X position
keyLightY={5} // Key light Y position
keyLightZ={5} // Key light Z position
shadows={true} // Enable shadow casting
// Camera
zoom={1} // Initial zoom level
autoRotate={false} // Auto-rotate camera (overrides animate)
// Texture
texture="none" // "none" or procedural preset name, or URL
/>import { SVG3D } from "3dsvg";
<SVG3D
// 输入(选择其一)
text="Hello World" // 文本字符串(使用Google Fonts)
svg="/path/to/file.svg" // SVG文件的URL
// svg="<svg>...</svg>" // 原始SVG标记字符串
// 字体(使用text属性时生效)
font="Inter" // Google Font名称(内置10种预设)
// 材质预设
material="default" // "default" | "plastic" | "metal" | "glass"
// "rubber" | "chrome" | "gold" | "clay"
// "emissive" | "holographic"
// 动画
animate="spin" // "spin" | "float" | "pulse" | "wobble"
// "swing" | "spin+float" | undefined(静态)
// 几何属性
depth={0.2} // 拉伸深度(默认值:0.2)
bevelEnabled={true} // 启用边缘斜角
bevelThickness={0.02} // 斜角厚度
bevelSize={0.02} // 斜角尺寸
bevelSegments={3} // 斜角平滑度
// 光照
ambientIntensity={0.5} // 环境光强度(0–1)
keyLightIntensity={1.0} // 主光源亮度
keyLightX={5} // 主光源X轴位置
keyLightY={5} // 主光源Y轴位置
keyLightZ={5} // 主光源Z轴位置
shadows={true} // 启用阴影投射
// 相机
zoom={1} // 初始缩放级别
autoRotate={false} // 自动旋转相机(覆盖animate属性)
// 纹理
texture="none" // "none"、程序化预设名称或URL
/>import { SVG3D } from "3dsvg";
export function LogoViewer() {
return (
<div style={{ width: 400, height: 400 }}>
<SVG3D
svg="/logo.svg"
material="metal"
animate="float"
depth={0.3}
bevelEnabled={true}
bevelThickness={0.03}
/>
</div>
);
}import { SVG3D } from "3dsvg";
export function LogoViewer() {
return (
<div style={{ width: 400, height: 400 }}>
<SVG3D
svg="/logo.svg"
material="metal"
animate="float"
depth={0.3}
bevelEnabled={true}
bevelThickness={0.03}
/>
</div>
);
}import { SVG3D } from "3dsvg";
export function HeroBadge() {
return (
<SVG3D
text="LAUNCH"
font="Inter"
material="chrome"
animate="spin"
depth={0.4}
keyLightIntensity={1.5}
ambientIntensity={0.3}
/>
);
}import { SVG3D } from "3dsvg";
export function HeroBadge() {
return (
<SVG3D
text="LAUNCH"
font="Inter"
material="chrome"
animate="spin"
depth={0.4}
keyLightIntensity={1.5}
ambientIntensity={0.3}
/>
);
}import { SVG3D } from "3dsvg";
export function ProductIcon({ svgUrl }: { svgUrl: string }) {
return (
<SVG3D
svg={svgUrl}
material="gold"
depth={0.15}
bevelEnabled={true}
shadows={true}
ambientIntensity={0.6}
keyLightX={3}
keyLightY={8}
keyLightZ={3}
/>
);
}import { SVG3D } from "3dsvg";
export function ProductIcon({ svgUrl }: { svgUrl: string }) {
return (
<SVG3D
svg={svgUrl}
material="gold"
depth={0.15}
bevelEnabled={true}
shadows={true}
ambientIntensity={0.6}
keyLightX={3}
keyLightY={8}
keyLightZ={3}
/>
);
}import { SVG3D } from "3dsvg";
export function HolographicLogo() {
return (
<SVG3D
svg="/brand.svg"
material="holographic"
animate="spin+float"
depth={0.1}
ambientIntensity={0.8}
/>
);
}import { SVG3D } from "3dsvg";
export function HolographicLogo() {
return (
<SVG3D
svg="/brand.svg"
material="holographic"
animate="spin+float"
depth={0.1}
ambientIntensity={0.8}
/>
);
}import { SVG3D } from "3dsvg";
const starSvg = `
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<polygon points="50,5 61,35 95,35 68,57 79,91 50,70 21,91 32,57 5,35 39,35"
fill="#FFD700"/>
</svg>
`;
export function Star3D() {
return (
<SVG3D
svg={starSvg}
material="gold"
animate="pulse"
depth={0.25}
/>
);
}import { SVG3D } from "3dsvg";
const starSvg = `
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<polygon points="50,5 61,35 95,35 68,57 79,91 50,70 21,91 32,57 5,35 39,35"
fill="#FFD700"/>
</svg>
`;
export function Star3D() {
return (
<SVG3D
svg={starSvg}
material="gold"
animate="pulse"
depth={0.25}
/>
);
}| Value | Description |
|---|---|
| Standard PBR material |
| Smooth, slightly shiny plastic |
| Matte metallic surface |
| Transparent glass look |
| Soft matte rubber |
| High-gloss mirror chrome |
| Warm gold PBR |
| Soft diffuse clay (great for screenshots) |
| Glowing emission effect |
| Iridescent rainbow foil |
| 值 | 描述 |
|---|---|
| 标准PBR材质 |
| 光滑、略带光泽的塑料材质 |
| 哑光金属表面 |
| 透明玻璃质感 |
| 柔软哑光橡胶 |
| 高光泽镜面铬合金 |
| 暖色调PBR黄金材质 |
| 柔软漫反射黏土(适合截图) |
| 发光效果 |
| 彩虹色虹彩箔片 |
| Value | Description |
|---|---|
| Continuous Y-axis rotation |
| Gentle up/down bob |
| Breathing scale animation |
| Side-to-side wobble |
| Pendulum swing |
| Spin combined with float |
| Static, user-draggable only |
| 值 | 描述 |
|---|---|
| 沿Y轴持续旋转 |
| 缓慢上下浮动 |
| 呼吸式缩放动画 |
| 左右摇摆 |
| 钟摆式摆动 |
| 旋转与浮动结合 |
| 静态,仅支持用户拖拽 |
git clone https://github.com/renatoworks/3dsvg.git
cd 3dsvg
npm install
npm run build:engine # Build the npm package
npm run dev:web # Start the visual editor at localhost:3000git clone https://github.com/renatoworks/3dsvg.git
cd 3dsvg
npm install
npm run build:engine # 构建npm包
npm run dev:web # 在localhost:3000启动可视化编辑器cd packages/engine
npm run build # Outputs to dist/
npm run dev # Watch modecd packages/engine
npm run build # 输出到dist/目录
npm run dev # 监听模式packages/
├── engine/src/
│ ├── index.tsx # SVG3D public component
│ ├── scene.tsx # Three.js scene, ExtrudedSVG mesh
│ ├── controls.tsx # Animation logic, orbit controls
│ ├── materials.ts # PBR material preset definitions
│ ├── types.ts # SVG3DProps TypeScript types
│ └── use-font.ts # Google Font → vector path loader
└── web/src/
├── app/ # Next.js pages
├── components/ # Editor UI panels, export bar
└── lib/ # Texture generators, FFmpeg utilspackages/
├── engine/src/
│ ├── index.tsx # SVG3D公共组件
│ ├── scene.tsx # Three.js场景、拉伸SVG网格
│ ├── controls.tsx # 动画逻辑、轨道控制器
│ ├── materials.ts # PBR材质预设定义
│ ├── types.ts # SVG3DProps TypeScript类型
│ └── use-font.ts # Google Font → 矢量路径加载器
└── web/src/
├── app/ # Next.js页面
├── components/ # 编辑器UI面板、导出栏
└── lib/ # 纹理生成器、FFmpeg工具import type { SVG3DProps } from "3dsvg";
const config: SVG3DProps = {
svg: "/logo.svg",
material: "chrome",
animate: "float",
depth: 0.3,
};
export function MyComponent() {
return <SVG3D {...config} />;
}import type { SVG3DProps } from "3dsvg";
const config: SVG3DProps = {
svg: "/logo.svg",
material: "chrome",
animate: "float",
depth: 0.3,
};
export function MyComponent() {
return <SVG3D {...config} />;
}SVG3Dssr: false// components/Logo3D.tsx
"use client";
import dynamic from "next/dynamic";
const SVG3D = dynamic(
() => import("3dsvg").then((m) => m.SVG3D),
{ ssr: false, loading: () => <div>Loading 3D...</div> }
);
export function Logo3D() {
return (
<SVG3D
svg="/logo.svg"
material="gold"
animate="spin"
/>
);
}SVG3Dssr: false// components/Logo3D.tsx
"use client";
import dynamic from "next/dynamic";
const SVG3D = dynamic(
() => import("3dsvg").then((m) => m.SVG3D),
{ ssr: false, loading: () => <div>加载3D内容中...</div> }
);
export function Logo3D() {
return (
<SVG3D
svg="/logo.svg"
material="gold"
animate="spin"
/>
);
}// No special config needed — just import and use
import { SVG3D } from "3dsvg";
function App() {
return (
<div style={{ height: "100vh" }}>
<SVG3D text="Vite + 3D" material="plastic" animate="float" />
</div>
);
}// 无需特殊配置 — 直接导入使用
import { SVG3D } from "3dsvg";
function App() {
return (
<div style={{ height: "100vh" }}>
<SVG3D text="Vite + 3D" material="plastic" animate="float" />
</div>
);
}<SVG3D><SVG3D>three@react-three/fiber@react-three/dreidynamicssr: falsewidthheightfillbevelSegmentsfontuse-font.tsbevelSegments12shadowsanimate={undefined}SharedArrayBufferCross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corpthree@react-three/fiber@react-three/dreissr: falsewidthheightfillbevelSegmentsfontuse-font.tsbevelSegments12shadowsanimate={undefined}SharedArrayBufferCross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp