threejs-math

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to use this skill

何时使用此 skill

ALWAYS use this skill when the user mentions:
  • Vector/matrix math order,
    applyQuaternion
    ,
    lookAt
    , world vs local transforms
  • Bounding volumes
    Box3
    /
    Sphere
    , containment/intersection tests
  • Ray
    vs
    Plane
    vs
    Frustum
    tests (without full picking pipeline)
IMPORTANT: math vs objects vs animation
NeedSkill
Raw math typesthreejs-math
Raycaster
+ layers picking
threejs-objects
QuaternionKeyframeTrack playbackthreejs-animation
Trigger phrases include:
  • "Vector3", "Matrix4", "Quaternion", "Box3", "Ray", "Frustum"
  • "向量", "矩阵", "四元数", "包围盒"
当用户提到以下内容时,始终使用此 skill:
  • 向量/矩阵运算顺序、
    applyQuaternion
    、
    lookAt
    、世界变换与局部变换
  • 包围体
    Box3
    /
    Sphere
    ,包含/相交测试
  • Ray
    、
    Plane
    与
    Frustum
    测试(不涉及完整的拾取流程)
重要:数学、对象与动画的区分
需求Skill
原始数学类型threejs-math
Raycaster
+ layers 拾取
threejs-objects
QuaternionKeyframeTrack 播放threejs-animation
触发短语包括:
  • "Vector3"、"Matrix4"、"Quaternion"、"Box3"、"Ray"、"Frustum"
  • "向量"、"矩阵"、"四元数"、"包围盒"

How to use this skill

如何使用此 skill

  1. Conventions: multiply vectors by matrices on the left as three.js examples show; call
    updateMatrixWorld
    before world-space queries (threejs-objects).
  2. Bounding:
    Box3().setFromObject(object)
    for rough bounds; refine per need.
  3. Collision-ish checks:
    ray.intersectBox
    ,
    sphere.containsPoint
    , etc., per docs.
  4. Addon structures:
    Octree
    /
    OBB
    for games—cite addon pages, avoid copying full API tables here.
  5. Color:
    Color
    conversions relate to materials/textures—cross-link.
  6. Random sampling:
    MeshSurfaceSampler
    for distributing points on meshes.
See examples/workflow-ray-aabb.md.
  1. 约定:按照 three.js 示例所示,将矩阵放在左侧与向量相乘;执行世界空间查询前调用
    updateMatrixWorld
    (threejs-objects)。
  2. 包围体:使用
    Box3().setFromObject(object)
    获取粗略边界;根据需求进一步细化。
  3. 类碰撞检查:按照文档使用
    ray.intersectBox
    、
    sphere.containsPoint
    等方法。
  4. 附加数据结构:游戏开发可使用
    Octree
    /
    OBB
    ——引用附加组件页面,避免在此复制完整的 API 表。
  5. 颜色:
    Color
    转换与材质/纹理相关——建立交叉引用。
  6. 随机采样:使用
    MeshSurfaceSampler
    在网格表面上分布点。
请参阅 examples/workflow-ray-aabb.md。

Doc map (official)

文档地图(官方)

Scope

适用范围

  • In scope: Core Math types; addon math entries as pointers.
  • Out of scope: Keyframe track evaluation beyond type references (animation skill).
  • **范围内:**核心 Math 类型;附加数学条目仅作为指引。
  • **范围外:**除类型引用之外的关键帧轨道求值(animation skill)。

Common pitfalls and best practices

常见陷阱与最佳实践

  • Euler gimbal lock—prefer quaternions for arbitrary rotations.
  • Reusing temporary vectors reduces GC thrash in hot loops.
  • Frustum culling helpers vary—verify against your three version.
  • Euler 万向节死锁——任意旋转优先使用四元数。
  • 在热循环中复用临时向量可减少 GC 压力。
  • Frustum 剔除辅助工具可能有所不同——请根据你的 three 版本进行验证。

Documentation and version

文档与版本

Core math types are listed under Math; addon utilities (
Octree
,
OBB
, …) appear under Addons → Math in three.js docs. Global also lists constants (e.g. wrapping, blending) sometimes needed alongside materials.
核心数学类型列于 Math;附加工具(
Octree
、
OBB
等)位于 three.js 文档的 Addons → Math 下。Global 中也列出了有时需与材质一起使用的常量(例如
wrapping
、
blending
)。

Agent response checklist

Agent 响应检查清单

When answering under this skill, prefer responses that:
  1. Link the concrete type (
    Vector3
    ,
    Matrix4
    ,
    Quaternion
    , …) from the docs.
  2. Send
    AnimationMixer
    / track math to threejs-animation when time-sampled.
  3. Send
    Raycaster
    picking flows to threejs-objects when interaction is the goal.
  4. Mention numeric stability (epsilon) where comparisons matter.
  5. Point to Addons → Math for game-oriented structures when users need spatial acceleration.
使用此 skill 回答问题时,优先采用以下方式:
  1. 从文档中链接具体类型(
    Vector3
    、
    Matrix4
    、
    Quaternion
    等)。
  2. 当涉及按时间采样时,将
    AnimationMixer
    /轨道数学问题转至 threejs-animation。
  3. 当目标是实现交互时,将
    Raycaster
    拾取流程转至 threejs-objects。
  4. 当比较运算很重要时,提及数值稳定性(epsilon)。
  5. 当用户需要空间加速时,指向 Addons → Math,以获取面向游戏的数据结构。

References

参考资料

Keywords

关键词

English: vector, matrix, quaternion, euler, box3, sphere, ray, frustum, three.js
中文: 向量、矩阵、四元数、欧拉角、包围盒、射线、three.js
English: vector, matrix, quaternion, euler, box3, sphere, ray, frustum, three.js
中文: 向量、矩阵、四元数、欧拉角、包围盒、射线、three.js