webgl
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "webgl":https://skillpi.com/zh/skills/deepskill-067819063a3e43dc61a0df6b979698afd62e044f4dac6919468f2687df0e3631。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
在浏览器中使用 WebGL 渲染 3D 图形:设置渲染管线,使用 GLSL 编写顶点与片段着色器,管理缓冲区与纹理,处理相机变换,并构建交互式 3D 场景。适用于 3D 可视化、GPU 加速渲染、自定义着色器或图形密集型 Web 应用的任务。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: webgl
description: >-
Render 3D graphics in the browser with WebGL — set up rendering pipelines,
write vertex and fragment shaders in GLSL, manage buffers and textures,
handle camera transformations, and build interactive 3D scenes. Use when tasks
involve 3D visualization, GPU-accelerated rendering, custom shaders, or
building graphics-intensive web applications.
license: Apache-2.0
compatibility: "Modern browsers with WebGL 2.0 support"
metadata:
author: terminal-skills
version: "1.0.0"
category: design
tags: ["webgl", "3d", "shaders", "glsl", "gpu", "graphics"]WebGL
Low-level 3D graphics API for the browser. Direct GPU access through shaders, buffers, and textures.
Initializing a WebGL Context
// src/webgl/init.ts — Get a WebGL2 rendering context and configure it.
// Falls back to WebGL1 if WebGL2 is unavailable.
export function initWebGL(canvas: HTMLCanvasElement): WebGL2RenderingContext {
const gl = canvas.getContext("webgl2");
if (!gl) throw new Error("WebGL2 not supported");
gl.viewport(0, 0, canvas.width, canvas.height);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.enable(gl.DEPTH_TEST);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
return gl;
}
Compiling Shaders
// src/webgl/shaders.ts — Compile vertex and fragment shaders, link into a program.
// Shaders run on the GPU and control how vertices and pixels are processed.
export function createShaderProgram(
gl: WebGL2RenderingContext,
vertexSrc: string,
fragmentSrc: string
): WebGLProgram {
const vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc);
const fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc);
const program = gl.createProgram()!;
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
throw new Error(`Link error: ${gl.getProgramInfoLog(program)}`);
}
return program;
}
function compileShader(
gl: WebGL2RenderingContext,
type: number,
source: string
): WebGLShader {
const shader = gl.createShader(type)!;
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const info = gl.getShaderInfoLog(shader);
gl.deleteShader(shader);
throw new Error(`Shader compile error: ${info}`);
}
return shader;
}
GLSL Shaders
// shaders/vertex.glsl — Transform vertex positions and pass data to fragment shader.
#version 300 es
layout(location = 0) in vec3 aPosition;
layout(location = 1) in vec3 aNormal;
layout(location = 2) in vec2 aTexCoord;
uniform mat4 uModelView;
uniform mat4 uProjection;
out vec3 vNormal;
out vec2 vTexCoord;
void main() {
vNormal = mat3(uModelView) * aNormal;
vTexCoord = aTexCoord;
gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);
}
// shaders/fragment.glsl — Calculate pixel color using lighting and texture.
#version 300 es
precision highp float;
in vec3 vNormal;
in vec2 vTexCoord;
uniform sampler2D uTexture;
uniform vec3 uLightDir;
out vec4 fragColor;
void main() {
vec3 normal = normalize(vNormal);
float diffuse = max(dot(normal, normalize(uLightDir)), 0.0);
vec4 texColor = texture(uTexture, vTexCoord);
fragColor = vec4(texColor.rgb * (0.3 + 0.7 * diffuse), texColor.a);
}
Buffers and VAOs
// src/webgl/geometry.ts — Create vertex buffer objects and vertex array objects
// to upload geometry data to the GPU.
export function createTriangle(gl: WebGL2RenderingContext) {
const vertices = new Float32Array([
// x, y, z
0.0, 0.5, 0.0,
-0.5, -0.5, 0.0,
0.5, -0.5, 0.0,
]);
const vao = gl.createVertexArray()!;
gl.bindVertexArray(vao);
const vbo = gl.createBuffer()!;
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.bindVertexArray(null);
return { vao, vertexCount: 3 };
}
Render Loop
// src/webgl/render.ts — Animation loop that clears the screen and draws geometry
// each frame, updating uniforms for animation.
export function startRenderLoop(
gl: WebGL2RenderingContext,
program: WebGLProgram,
draw: (time: number) => void
) {
gl.useProgram(program);
function frame(time: number) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
draw(time);
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
}当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 WebGL 3D 图形渲染能力,包括上下文初始化、着色器编译、缓冲区管理等核心功能
- 适用于 3D 可视化、GPU 加速渲染等明确场景,具有较高的实用价值
亮点
- description 明确描述了使用场景和适用任务,触发词覆盖合理,边界清晰
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档未明确说明何时使用此 Skill
改进建议:建议添加 When to Use 章节,帮助用户更好地理解适用场景
-
缺少端到端完整示例 原报告严重程度:轻微
虽然提供了多个代码片段,但缺少一个完整的端到端示例
改进建议:建议添加一个完整的端到端示例,展示如何从零开始创建一个 WebGL 场景
亮点
- 文档结构清晰,分模块展示代码,包含完整示例和代码片段
- frontmatter 完整,包含必要的元数据信息
亮点
- 代码示例完整,包含错误处理机制
- 工具来源明确,参数使用正确,覆盖主要异常情况
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。