yjkj-fec-canvas-threejs

Sub-skill to use when building or reviewing Canvas 2D, Three.js/WebGL, React Three Fiber, GLSL shaders, ShaderToy-to-WebGL adaptations, 2D/3D visualization, game rendering, animation loops, GPU resource cleanup, or rendering performance. Not to be used for standard DOM UIs, charts already covered by a chart library, or non-graphical performance work. Chinese triggers include: Canvas, Three.js, WebGL, GLSL, Shader, 3D, data visualization, game.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "yjkj-fec-canvas-threejs" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ac1db509717f09f7ec99556bc6097e7b650d4856d0045488122e35aa1ff6c426. Verify the upstream source and version against https://skillhub.cn/skills/user_15292d5a/yjkj-fec-canvas-threejs before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Sub-skill to use when building or reviewing Canvas 2D, Three.js/WebGL, React Three Fiber, GLSL shaders, ShaderToy-to-WebGL adaptations, 2D/3D visualization, game rendering, animation loops, GPU resource cleanup, or rendering performance. Not to be used for standard DOM UIs, charts already covered by a chart library, or non-graphical performance work. Chinese triggers include: Canvas, Three.js, WebGL, GLSL, Shader, 3D, data visualization, game.

0 Downloads

Introduction source: third_party · user_15292d5a · 2.5.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: fec-canvas-threejs
description: Use when building or reviewing Canvas 2D, Three.js/WebGL, React Three Fiber, GLSL shaders, ShaderToy-to-WebGL adaptation, 2D/3D visualization, game rendering, animation loops, GPU resource cleanup, or rendering performance. Do not use for standard DOM UI, charts already covered by a chart library, or non-graphical performance work; Chinese triggers include Canvas, Three.js, WebGL, GLSL, Shader, 3D, 数据可视化, 游戏.

Canvas 与 Three.js

Purpose

在浏览器中实现高性能 2D/3D 图形渲染。

Procedure

  1. 先选渲染层:标准 UI 用 DOM;简单 2D 图形/签名/粒子用 Canvas 2D;3D 模型、空间交互和复杂粒子用 Three.js/WebGL;React 项目中的声明式 3D 用 React Three Fiber。
  2. 为渲染容器定义稳定尺寸、DPI 适配和 resize 行为;Canvas 不会自动随 CSS 清晰缩放。
  3. 动画循环使用 requestAnimationFrame,不可见或无变化时暂停,卸载时取消。
  4. Three.js 必须释放 geometry/material/texture/renderer,并移除事件监听和 observer。
  5. Shader/WebGL 任务先识别是 SDF、ray marching、noise、particle、post-processing、multipass 还是调试问题,再决定是否需要原生 WebGL2、Three.js ShaderMaterial 或 R3F。
  6. WebGL2 适配时检查 GLSL 版本、入口函数、varying/in-out、texture API、uniform 使用和函数声明顺序,避免白屏只留控制台错误。
  7. 对不可访问的图形内容提供 aria-label、替代文本或 DOM 版摘要;交互式图形要有键盘兜底。

Core Patterns

const dpr = Math.min(window.devicePixelRatio || 1, 2);
canvas.width = width * dpr;
canvas.height = height * dpr;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
ctx.scale(dpr, dpr);
let animationId = 0;
function animate() {
  animationId = requestAnimationFrame(animate);
  renderer.render(scene, camera);
}

return () => {
  cancelAnimationFrame(animationId);
  geometry.dispose();
  material.dispose();
  renderer.dispose();
};

Detailed References

涉及 Canvas 2D 绘图、动画循环、Three.js 场景搭建、React Three Fiber、InstancedMesh 和性能清理时,加载 references/rendering-patterns.md。

涉及着色器路由、WebGL2 适配、GLSL 调试、多 pass 预算和视觉验证时,加载 references/shader-webgl-patterns.md。

Constraints

  • Canvas/WebGL 内容对屏幕阅读器不可见,必须提供替代语义。
  • WebGL 消耗 GPU,低端设备需限制像素比、面数和纹理大小。
  • Three.js 资源不会自动释放,遗漏 dispose() 会造成 GPU 内存泄漏。
  • Canvas 响应式必须同步 CSS 尺寸、绘图尺寸和相机/viewport。
  • 复杂布局/路径规划可联用后台线程 workflow,但渲染本身仍在主线程/渲染线程协调。
  • Shader 主循环、采样层数和多 pass 数量必须有预算;低端设备上要降低 DPR、步数、粒子数或禁用重后处理。
  • 交付前必须确认 canvas 非空、尺寸正确、resize 后不拉伸、控制台无 shader compile/link 错误。

Expected Output

2D/3D 场景清晰、响应式、可清理,关键设备上接近 60fps;用户能通过替代文本或键盘路径理解/操作核心内容。

Current listing version

2.5.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value88/100

Highlights

  • 覆盖 Canvas 2D、Three.js/WebGL、React Three Fiber、GLSL 着色器、ShaderToy 适配、2D/3D 可视化、游戏渲染等高频刚需场景
  • 提供 GPU 资源清理、动画循环、性能优化等核心实践,解决前端图形渲染的关键痛点
Trigger Precision95/100

Highlights

  • 触发词详尽且边界清晰,涵盖中英文场景,无歧义或重叠风险
Structure and Standards92/100

Areas to improve

  • 缺少 When to Use 显式章节 Reported severity: Minor

    文档结构完整,但未设置显式的 When to Use 章节,虽 description 已涵盖,但规范建议单独列出

    Recommendation: 建议在 Procedure 前增加 When to Use 章节,明确使用时机与边界

Highlights

  • Phase/步骤清晰,含端到端代码示例,frontmatter 完整,单文件长度合理
Execution Reliability90/100

Highlights

  • 工具来源明确,参数正确,覆盖主要异常(资源释放、resize、DPI 适配、低端设备限制),不可逆操作有确认机制
Evidence Verifiability (mean of the first four)91/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.