cesartevisual/threejs-skills

threejs-interaction

Implement Three.js pointer picking, orbit controls, object dragging, selection, and synchronized HTML controls.

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/cesartevisual/threejs-skills --skill threejs-interaction

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Picking and Controls

Use the project's installed versions and existing architecture. These instructions supplement the user's task; they do not authorize unrelated changes or external actions.

Choose controls based on the task and preserve ordinary page scrolling outside the interactive area. Define pointer, touch, keyboard, and HTML equivalents for important actions. Keep selection in application state keyed by stable IDs rather than temporary mesh indices alone.

Convert client coordinates using the actual event viewport rectangle: x = 2 (clientX - left) / width - 1; y = 1 - 2 (clientY - top) / height. For scissored views use that view's rectangle. Ignore zero-sized views. Raycast only relevant roots/layers and account for descendants, instance IDs, and front/back-face behavior.

Distinguish a click from a drag using travel thresholds. Use pointer capture when dragging beyond the canvas; handle pointercancel and lost capture. Temporarily suspend orbit controls while object manipulation owns the gesture, then restore them on every exit path.

For drag planes and transform gizmos, convert world results into the object's parent space. Scale constraints and hit tolerances to the use case. Visible shader deformation may not match CPU raycasting; use proxy geometry or another picking method when needed.

Throttle expensive hover work to rendered frames, reuse allocations, and dispose controls/listeners. Verify an offset canvas, touch cancellation, nested transforms, occlusion, keyboard selection, and selecting an instance after list updates.

API reference

Consult the official documentation for exact signatures and revision-specific behavior. If documentation access is unavailable, inspect installed types/source and state any remaining uncertainty.

来自同一仓库

更多 Skills

全部 Skills