360 Secure SkillHub
360 安全技能中心

reuse-scripts

该 Skill 指导在编写 PlayCanvas 行为前,先枚举并复用已安装 playcanvas 包 scripts/esm 下的现成脚本(如相机控制、第一人称控制、水面、网格等)及核心导出,并按其官方示例补齐资源与渲染设置,最后以控制台、着色器与资源错误作为验收;同时按直接引擎、React 或 Web Components 三种场景阅读对应参考文档。

分类:开发
playcanvas
热度 0.00
最近更新 2026-11-11 05:19:30

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add playcanvas/skills/reuse-scripts
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
reuse-scripts
description
Use before writing PlayCanvas behaviour from scratch, to reuse the scripts and helpers the installed Engine already ships.

Reuse shipped Engine code

Before writing behaviour, check what the installed playcanvas package already provides.

Scripts live under scripts/esm/**; import only from there. List them:

rg 'static scriptName =' node_modules/playcanvas/scripts/esm \
  | sed "s|.*/scripts/esm/||; s|:.*static scriptName = ['\"]|  ->  |; s|['\"].*||" \
  | sort

Common ones are CameraControls, FirstPersonController, ThirdPersonController, ShadowCatcher, ProceduralSky, Water, and Grid, plus XR and splat scripts. Modules under scripts/esm/parsers are resource-handler classes, not scripts.

Core exports that are not scripts include CameraFrame for post-processing, Picker (getSelectionAsync), TransformGizmo, OutlineRenderer, MiniStats, GltfExporter, and UsdzExporter.

Integrate

  1. Read the source for exports, @attribute properties, defaults, and required components.
  2. Find its official example with find-examples, and copy the assets, layers, scene settings, and render setup it depends on.
  3. Adapt configuration and extension points. If nothing fits, implement only the missing part and say what was missing.
  4. After a rendered frame, fail on console, shader, or missing-asset errors.

Keep a shipped script's input mapping and damping unless asked otherwise, and verify input directions with real input rather than deriving signs from memory.

Grouped property updates differ by surface; preserve defaults you do not change. Read only the reference matching the code: direct Engine, React, or Web Components.