threejs-math
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen to use this skill
何时使用此 skill
ALWAYS use this skill when the user mentions:
- Vector/matrix math order, ,
applyQuaternion, world vs local transformslookAt - Bounding volumes /
Box3, containment/intersection testsSphere - vs
RayvsPlanetests (without full picking pipeline)Frustum
IMPORTANT: math vs objects vs animation
| Need | Skill |
|---|---|
| Raw math types | threejs-math |
| threejs-objects |
| QuaternionKeyframeTrack playback | threejs-animation |
Trigger phrases include:
- "Vector3", "Matrix4", "Quaternion", "Box3", "Ray", "Frustum"
- "向量", "矩阵", "四元数", "包围盒"
当用户提到以下内容时,始终使用此 skill:
- 向量/矩阵运算顺序、、
applyQuaternion、世界变换与局部变换lookAt - 包围体 /
Box3,包含/相交测试Sphere - 、
Ray与Plane测试(不涉及完整的拾取流程)Frustum
重要:数学、对象与动画的区分
| 需求 | Skill |
|---|---|
| 原始数学类型 | threejs-math |
| threejs-objects |
| QuaternionKeyframeTrack 播放 | threejs-animation |
触发短语包括:
- "Vector3"、"Matrix4"、"Quaternion"、"Box3"、"Ray"、"Frustum"
- "向量"、"矩阵"、"四元数"、"包围盒"
How to use this skill
如何使用此 skill
- Conventions: multiply vectors by matrices on the left as three.js examples show; call before world-space queries (threejs-objects).
updateMatrixWorld - Bounding: for rough bounds; refine per need.
Box3().setFromObject(object) - Collision-ish checks: ,
ray.intersectBox, etc., per docs.sphere.containsPoint - Addon structures: /
Octreefor games—cite addon pages, avoid copying full API tables here.OBB - Color: conversions relate to materials/textures—cross-link.
Color - Random sampling: for distributing points on meshes.
MeshSurfaceSampler
See examples/workflow-ray-aabb.md.
- 约定:按照 three.js 示例所示,将矩阵放在左侧与向量相乘;执行世界空间查询前调用 (threejs-objects)。
updateMatrixWorld - 包围体:使用 获取粗略边界;根据需求进一步细化。
Box3().setFromObject(object) - 类碰撞检查:按照文档使用 、
ray.intersectBox等方法。sphere.containsPoint - 附加数据结构:游戏开发可使用 /
Octree——引用附加组件页面,避免在此复制完整的 API 表。OBB - 颜色:转换与材质/纹理相关——建立交叉引用。
Color - 随机采样:使用 在网格表面上分布点。
MeshSurfaceSampler
请参阅 examples/workflow-ray-aabb.md。
Doc map (official)
文档地图(官方)
| Docs section | Representative links |
|---|---|
| Math | https://threejs.org/docs/Vector3.html |
| Math | https://threejs.org/docs/Matrix4.html |
| Math | https://threejs.org/docs/Quaternion.html |
| Math | https://threejs.org/docs/Ray.html |
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 (, , …) appear under Addons → Math in three.js docs. Global also lists constants (e.g. wrapping, blending) sometimes needed alongside materials.
OctreeOBB核心数学类型列于 Math;附加工具(、 等)位于 three.js 文档的 Addons → Math 下。Global 中也列出了有时需与材质一起使用的常量(例如 、)。
OctreeOBBwrappingblendingAgent response checklist
Agent 响应检查清单
When answering under this skill, prefer responses that:
- Link the concrete type (,
Vector3,Matrix4, …) from the docs.Quaternion - Send / track math to threejs-animation when time-sampled.
AnimationMixer - Send picking flows to threejs-objects when interaction is the goal.
Raycaster - Mention numeric stability (epsilon) where comparisons matter.
- Point to Addons → Math for game-oriented structures when users need spatial acceleration.
使用此 skill 回答问题时,优先采用以下方式:
- 从文档中链接具体类型(、
Vector3、Matrix4等)。Quaternion - 当涉及按时间采样时,将 /轨道数学问题转至 threejs-animation。
AnimationMixer - 当目标是实现交互时,将 拾取流程转至 threejs-objects。
Raycaster - 当比较运算很重要时,提及数值稳定性(epsilon)。
- 当用户需要空间加速时,指向 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