1实现原理 · 为什么它能做到
SKILL.md 本身只有 93 行 / 3.2KB,是一张路由表:正文用『Skill Contents』把 7 篇 docs、5 个 examples、2 个 templates、1 个 cheatsheet 逐条列名,agent 按当前任务再加载对应文件(渐进披露),而不是把 50KB+ 文档一次性灌进上下文。
- `docs/compute-shaders.md` - GPU compute with instanced arrays
Cursor 侧把同一套披露策略写成显式话术:.mdc 正文只留三五行摘要,然后用 @file 引用指向 skills/ 下的原始文档(5 个 .mdc 合计仅 5.9KB,却挂了 10 条 @ 引用)。
The source-of-truth documentation lives under `skills/webgpu-threejs-tsl/`. Reference these files directly when deeper guidance is needed:
『能写对代码』的真正支点是文档反复钉死的一条 TSL 语义陷阱:TSL 只能拦截节点属性赋值,拦不住 JS 变量重赋值——所以在 If() 里写 value = value.add(1.0) 会静默失效(返回旧节点、不报错)。
**TSL can intercept property assignments on nodes, but NOT JavaScript variable reassignment.**
不只给规则,还给失败机理,避免模型换个写法重犯同一个错:文档解释了 JS 变量重赋值会新建节点、而 TSL 看不到这次赋值,且标量没有 .x/.y 属性因此无法绕道属性赋值。
**Why it fails:** `value = value.add(1.0)` creates a new TSL node and reassigns the JavaScript variable to point to it.
版本断层以文档条目形式固化,而非运行时探测:skill 不去读用户项目的 three 版本,而是把 r17x–r18x 的破坏性改动写成对照条目,交由模型自行比对。
> **Note:** `PostProcessing` was renamed to `RenderPipeline` in r183. `PostProcessing` still works as a compatibility wrapper but is deprecated.
模板是可直接落地的整文件骨架而非伪代码:分段骨架(CONFIG/GLOBALS/INITIALIZATION/SCENE/ANIMATION/EVENT)、插入点标记、结尾把内部对象 export 出去供外部调试。
// Export for external access if needed
WGSL 逃生口:TSL 表达不了或需要移植现成 WGSL 时,用 wgslFn() 把整段 WGSL 函数体嵌进 TSL 节点图;文档同时附 WGSL 类型/语法/内建函数速查,使模型脱离 TSL 也能写对 WGSL。
TSL allows embedding raw WGSL (WebGPU Shading Language) code when you need direct GPU control.
把 WebGPU 特有的运行期故障面(设备丢失、limits/features)也纳入编码指导,使生成的代码不只是能跑,还考虑 GPU 崩溃与缓冲区上限。
Three.js accepts `requiredLimits` as a renderer constructor option, which gets passed through to `requestDevice()`:
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| package | three(npm 包,生成项目需自装) |
| package | three/addons 子路径(OrbitControls、BloomNode 等 addons 模块) |
| network | 文档引用链接(仅 markdown 里的参考资料链接,仓库内无任何抓取/请求代码,不被 skill 调用) |
4风险提醒 风险提醒:绿色 · 放心使用
- 知识时效风险(版本漂移即失效) — 结论绑定 Three.js r171–r183 世代;若用户项目使用更早/更新的 three,文档中的 API(RenderPipeline、DOF 新签名、blur sigma 标定、compute 同步派发)可能直接不适用,而 skill 不做任何项目版本探测,模型可能照抄。
- 双份维护的实际漂移(已实证两处) — README 宣称 Cursor rules 是自动同步的 thin shims,但 .cursor/rules/post-processing.mdc 仍教 PostProcessing 类、compute-shaders.mdc 仍教 renderer.computeAsync(),与 docs 的 r183/r181 结论相悖;Cursor 用户按 rule 摘要写代码会写出过时/已弃用写法。
- 许可声明缺仓内 LICENSE 文件 — README 与 plugin.json 均声明 MIT,但仓库内没有 LICENSE 文件,GitHub API 检测为 null。多数场景无碍(示例注明源自 three.js MIT),但对需要法务留痕的使用方是程序性缺口。
- 文档自称与自身目录结构不一致(README 漏列 limits-and-features.md) — README 的 Skill Structure 图只列 6 篇 docs,实际 7 篇;对按 README 手动拷贝/裁剪目录的用户会造成漏文件。
- 语言与生态绑定 — 全部面向 JavaScript/TSL 与 three/webgpu 生态;若目标是原生 WebGPU/WGSL 工程或 WebGL/GLSL 项目,文档结构(节点材质、import 模式)帮助有限,仅 wgsl-integration.md 部分可迁移。
5第二遍独立确认
- [ok] pin commit 与工作副本一致 — git rev-parse HEAD 输出 af2319bd01bb7cc881267a9ef42cafdaf5e9029d,与 .git/shallow 首行相同,等于任务 pin commit;结论只对该 commit 有效。
- [ok] skill 目录定位 — skills/webgpu-threejs-tsl/SKILL.md 存在且 frontmatter name: webgpu-threejs-tsl 与 slug 对应;同目录含 REFERENCE.md、docs/×7、examples/×5、templates/×2,路径写入 skill.path。
- [discrepancy] license 声明与仓库实际文件 — README.md 有『## License』段声明 MIT License,.claude-plugin/plugin.json 也写 "license": "MIT";但 git ls-tree -r 全量清单里没有 LICENSE / LICENSE.md 文件,全仓 grep -il license 只命中 plugin.json、README.md 与 5 个 examples 的注释,与 GitHub API license=null 一致。即:许可为『源码内声明』而非仓内标准许可文件。
- [discrepancy] README 自述的 skill 结构图 vs 实际文件 — README『## Skill Structure』的 docs/ 分支只列 core-concepts / materials / compute-shaders / post-processing / wgsl-integration / device-loss 六篇(以 `└── device-loss.md` 收尾),而 docs/ 实有 7 篇——漏列 limits-and-features.md;SKILL.md 的 Skill Contents 则完整列出七篇。属 README 文档漂移。
- [discrepancy] Cursor 摘要与 docs 的 API 世代是否一致(后处理) — .cursor/rules/post-processing.mdc 仍教 `import { PostProcessing } from 'three/webgpu';` 并说 postProcessing.renderAsync(),而 docs/post-processing.md 开篇即注明 r183 已改名 RenderPipeline、旧名仅为兼容包装,examples/post-processing.js 实际用的是 `new THREE.RenderPipeline(renderer)`。README 自称 shim 会『edits flow through automatically』——该说法对手写摘要句不成立。
- [discrepancy] Cursor 摘要与 docs 的 API 世代是否一致(compute 派发) — .cursor/rules/compute-shaders.mdc 写『dispatched via `renderer.computeAsync()`』与『- `renderer.computeAsync(kernel)` to dispatch』,而 docs/compute-shaders.md『Execution Methods』明确『// Note: computeAsync() is deprecated since r181.』并给出『await renderer.init() at startup, then renderer.compute() synchronously』;templates/compute-shader.js 与 examples/particle-system.js 用的都是 renderer.compute(...)。同一漂移问题的第二例。
- [ok] 外部依赖反查:是否存在 CDN/网络调用 — 全仓 grep -riE 'unpkg|jsdelivr|cdn\.|importmap|import-map' 零命中;templates/examples 的 import 全部是裸包名(three、three/webgpu、three/tsl、three/addons/...),无 URL 形式的模块来源。故 external_deps 只列 npm 包,security.network_calls 为空。
- [ok] 脚本/凭证面反查 — git ls-tree 全清单只有 .md/.mdc/.json/.js;无 package.json(因此无 npm scripts、无依赖安装钩子)、无 scripts/、无 .sh/.py;危险 token 扫描对 child_process/eval/new Function/process.env/.env/token/secret/document.cookie/credentials 均无命中。scripts_executed 与 credential_reads 为空有据。
6结论
afb594cdc14fec2b…af2319bd01