When to use this skill
ALWAYS use this skill when the user mentions:
- Creating or configuring a new three.js project, Vite/Webpack/Rollup entry, or browser
importmap
- Installing the
three package, aligning version with documentation, or TypeScript setup (@types/three where applicable)
- Import errors for
three/addons/..., examples/jsm, ESM vs CJS interop, or bare specifier resolution
IMPORTANT: this skill vs runtime topics
- threejs-dev-setup = install paths, bundler, module graph, and where to import addons from.
- threejs-renderers =
WebGLRenderer / WebGPURenderer, canvas, pixel ratio, render loop—after the project loads.
- threejs-loaders =
GLTFLoader, DRACOLoader, progress callbacks—after imports resolve.
Trigger phrases include:
- "vite three.js", "webpack three", "import map", "three/addons", "cannot find module", "jsm"
- "新建项目", "安装 three", "找不到模块", "ESM", "TypeScript three"
How to use this skill
- Confirm delivery model: SPA bundler (Vite/Webpack), Node tooling, or static HTML with
importmap—each affects how three/addons/ resolves.
- Pin
three version to a release compatible with the docs the user cites; note that addon paths follow the published package layout.
- Show canonical imports: core from
three; controls/loaders/effects from three/addons/... (mapped to examples/jsm in source tree). See examples/workflow-scaffold.md.
- Minimal loop: create renderer + scene + camera + one mesh;
requestAnimationFrame—enough to verify toolchain without duplicating threejs-renderers depth.
- TypeScript: enable
moduleResolution appropriate for bundler; reference types from three package typings; avoid duplicating global script tag patterns unless user targets no-bundler HTML.
- On failure: distinguish missing dependency vs wrong path vs SSR context (no
window/document).
- Deepening: link user to three.js manual first chapter after scaffold works.
Doc map (official)
Scope
- In scope: npm/install, bundlers, import maps, TypeScript basics for three, addon import paths, minimal verification snippet.
- Out of scope: WebGL theory, full render target or post stack (threejs-renderers, threejs-postprocessing), physics, deployment beyond "build runs".
Common pitfalls and best practices
- Mixing multiple
three copies in one page breaks singletons; dedupe with bundler aliases.
- Importing addons from deep
node_modules/.../examples/jsm paths is fragile; prefer package exports three/addons/... when available.
- Always match r152+ style color management docs when giving snippet defaults (output color space)—point to threejs-renderers/textures for details.
- SSR frameworks need dynamic import or client-only components for WebGL context.
Documentation and version
Toolchain and import paths follow the three npm package version the user installs. The Manual and docs are updated with the library; addon paths (three/addons/...) must match the package layout for that release—when in doubt, cite the version number and the exact import line from the current docs.
Agent response checklist
When answering under this skill, prefer responses that:
- Name the bundler or runtime (Vite, Webpack, bare ESM,
importmap) and the intended three version.
- Link https://threejs.org/manual/ and/or https://threejs.org/docs/ for authoritative setup context.
- Distinguish threejs-dev-setup (resolution) from threejs-renderers (runtime API) failures.
- Never assume global script tags unless the user explicitly uses CDN/no-bundler HTML.
- Recommend deduplicating
three in package.json / lockfile when duplicate singleton issues appear.
References
Keywords
English: three.js, vite, webpack, rollup, import map, typescript, npm, three/addons, examples jsm, module resolution, scaffold
中文: three.js 安装、构建、importmap、模块解析、three/addons、脚手架、Vite、Webpack
能力边界
✅ 适用场景
- 当你需要使用此技能对应的技术栈时
- 当项目需要遵循最佳实践时
- 当需要快速上手或深入理解核心概念时
⚠️ 需要注意
- 复杂业务逻辑需要结合具体场景调整
- 性能优化需要根据实际数据量评估
❌ 不适用场景
常见陷阱 (Gotchas)
- 版本兼容性:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异
- 配置文件格式:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查
- 环境变量:确保所有必要的环境变量已正确设置,敏感信息不要硬编码
- 依赖冲突:多版本共存时注意依赖冲突,使用 lock 文件锁定版本
- 性能陷阱:大数据量场景下注意性能优化,避免 N+1 查询等常见问题
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
1---2name: threejs-dev-setup3description: Bootstrap and toolchain guidance for three.js applications using npm, Vite/Webpack/Rollup, bare ESM import maps, and TypeScript. Covers canonical import paths for `three` core versus `three/addons/` (examples/jsm re-exports), version alignment with https://threejs.org/docs/, and fixing "module not found" for loaders and controls. Use when scaffolding a new 3D project, migrating bundler, or debugging resolution of addons—do not use for rendering API details (see threejs-renderers) or asset loading logic (see threejs-loaders).4---56## When to use this skill78**ALWAYS use this skill when the user mentions:**910- Creating or configuring a new three.js project, Vite/Webpack/Rollup entry, or browser `importmap`11- Installing the `three` package, aligning version with documentation, or TypeScript setup (`@types/three` where applicable)12- Import errors for `three/addons/...`, `examples/jsm`, ESM vs CJS interop, or bare specifier resolution1314**IMPORTANT: this skill vs runtime topics**1516- **threejs-dev-setup** = install paths, bundler, module graph, and where to import addons from.17- **threejs-renderers** = `WebGLRenderer` / `WebGPURenderer`, canvas, pixel ratio, render loop—after the project loads.18- **threejs-loaders** = `GLTFLoader`, `DRACOLoader`, progress callbacks—after imports resolve.1920**Trigger phrases include:**2122- "vite three.js", "webpack three", "import map", "three/addons", "cannot find module", "jsm"23- "新建项目", "安装 three", "找不到模块", "ESM", "TypeScript three"2425## How to use this skill26271. **Confirm delivery model**: SPA bundler (Vite/Webpack), Node tooling, or static HTML with `importmap`—each affects how `three/addons/` resolves.282. **Pin `three` version** to a release compatible with the docs the user cites; note that addon paths follow the published package layout.293. **Show canonical imports**: core from `three`; controls/loaders/effects from `three/addons/...` (mapped to `examples/jsm` in source tree). See [examples/workflow-scaffold.md](examples/workflow-scaffold.md).304. **Minimal loop**: create renderer + scene + camera + one mesh; `requestAnimationFrame`—enough to verify toolchain without duplicating threejs-renderers depth.315. **TypeScript**: enable `moduleResolution` appropriate for bundler; reference types from `three` package typings; avoid duplicating global script tag patterns unless user targets no-bundler HTML.326. **On failure**: distinguish missing dependency vs wrong path vs SSR context (no `window`/`document`).337. **Deepening**: link user to [three.js manual](https://threejs.org/manual/) first chapter after scaffold works.3435## Doc map (official)3637| Docs section | Representative links |38|--------------|----------------------|39| Manual (getting started) | https://threejs.org/manual/ |40| Docs index | https://threejs.org/docs/ |41| Package / install context | https://www.npmjs.com/package/three |4243## Scope4445- **In scope:** npm/install, bundlers, import maps, TypeScript basics for three, addon import paths, minimal verification snippet.46- **Out of scope:** WebGL theory, full render target or post stack (threejs-renderers, threejs-postprocessing), physics, deployment beyond "build runs".4748## Common pitfalls and best practices4950- Mixing multiple `three` copies in one page breaks singletons; dedupe with bundler aliases.51- Importing addons from deep `node_modules/.../examples/jsm` paths is fragile; prefer package exports `three/addons/...` when available.52- Always match **r152+** style color management docs when giving snippet defaults (output color space)—point to threejs-renderers/textures for details.53- SSR frameworks need dynamic import or client-only components for WebGL context.5455## Documentation and version5657Toolchain and import paths follow the **three** npm package version the user installs. The [Manual](https://threejs.org/manual/) and [docs](https://threejs.org/docs/) are updated with the library; addon paths (`three/addons/...`) must match the package layout for that release—when in doubt, cite the version number and the exact import line from the current docs.5859## Agent response checklist6061When answering under this skill, prefer responses that:62631. Name the bundler or runtime (Vite, Webpack, bare ESM, `importmap`) and the intended `three` version.642. Link https://threejs.org/manual/ and/or https://threejs.org/docs/ for authoritative setup context.653. Distinguish **threejs-dev-setup** (resolution) from **threejs-renderers** (runtime API) failures.664. Never assume global script tags unless the user explicitly uses CDN/no-bundler HTML.675. Recommend deduplicating `three` in `package.json` / lockfile when duplicate singleton issues appear.6869## References7071- https://threejs.org/manual/72- https://threejs.org/docs/73- https://www.npmjs.com/package/three7475## Keywords7677**English:** three.js, vite, webpack, rollup, import map, typescript, npm, three/addons, examples jsm, module resolution, scaffold7879**中文:** three.js 安装、构建、importmap、模块解析、three/addons、脚手架、Vite、Webpack8081## 能力边界8283### ✅ 适用场景84- 当你需要使用此技能对应的技术栈时85- 当项目需要遵循最佳实践时86- 当需要快速上手或深入理解核心概念时8788### ⚠️ 需要注意89- 复杂业务逻辑需要结合具体场景调整90- 性能优化需要根据实际数据量评估9192### ❌ 不适用场景93- 不相关的技术栈或框架94- 需要完全自定义的特殊场景9596## 常见陷阱 (Gotchas)97981. **版本兼容性**:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异992. **配置文件格式**:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查1003. **环境变量**:确保所有必要的环境变量已正确设置,敏感信息不要硬编码1014. **依赖冲突**:多版本共存时注意依赖冲突,使用 lock 文件锁定版本1025. **性能陷阱**:大数据量场景下注意性能优化,避免 N+1 查询等常见问题103104## 使用流程105106### Step 1: 环境准备107确保开发环境已安装必要的依赖和工具。108109### Step 2: 配置初始化110根据项目需求进行基础配置。111112### Step 3: 核心功能使用113按照示例代码实现核心功能。114115### Step 4: 测试验证116运行测试确保功能正常。117118### Step 5: 部署上线119完成开发后进行部署和监控。