@leejungkiin/awkit 1.7.6 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/awk.js +213 -92
- package/bin/codex-generators.js +32 -3
- package/core/GEMINI.md +18 -5
- package/core/GEMINI.md.bak +20 -7
- package/core/skill-runtime-manifest.json +1 -0
- package/package.json +1 -1
- package/scripts/exec-progress.js +116 -0
- package/scripts/exec-rtk.js +105 -10
- package/skills/CATALOG.md +1 -1
- package/skills/awf-caveman/SKILL.md +13 -1
- package/skills/code-review/SKILL.md +40 -68
- package/skills/generate-gui-assets/SKILL.md +5 -5
- package/skills/hatch-pet/SKILL.md +2 -2
- package/skills/review/SKILL.md +40 -68
- package/skills/threejs-animation/SKILL.md +86 -0
- package/skills/threejs-animation/examples/workflow-mixer-action.md +20 -0
- package/skills/threejs-animation/references/official-sections.md +19 -0
- package/skills/threejs-audio/SKILL.md +112 -0
- package/skills/threejs-audio/examples/workflow-positional-audio.md +15 -0
- package/skills/threejs-audio/references/official-sections.md +16 -0
- package/skills/threejs-camera/SKILL.md +96 -0
- package/skills/threejs-camera/examples/workflow-perspective-resize.md +13 -0
- package/skills/threejs-controls/SKILL.md +101 -0
- package/skills/threejs-controls/examples/workflow-orbit-damping.md +15 -0
- package/skills/threejs-dev-setup/SKILL.md +102 -0
- package/skills/threejs-dev-setup/examples/workflow-scaffold.md +24 -0
- package/skills/threejs-geometries/SKILL.md +108 -0
- package/skills/threejs-geometries/examples/workflow-extrude-shape.md +13 -0
- package/skills/threejs-helpers/SKILL.md +103 -0
- package/skills/threejs-helpers/examples/workflow-light-camera-helpers.md +13 -0
- package/skills/threejs-lights/SKILL.md +103 -0
- package/skills/threejs-lights/examples/workflow-directional-shadow.md +17 -0
- package/skills/threejs-loaders/SKILL.md +89 -0
- package/skills/threejs-loaders/examples/workflow-gltf-draco.md +22 -0
- package/skills/threejs-loaders/references/official-sections.md +27 -0
- package/skills/threejs-materials/SKILL.md +102 -0
- package/skills/threejs-materials/examples/workflow-pbr-transparent.md +15 -0
- package/skills/threejs-math/SKILL.md +102 -0
- package/skills/threejs-math/examples/workflow-ray-aabb.md +11 -0
- package/skills/threejs-node-tsl/SKILL.md +83 -0
- package/skills/threejs-node-tsl/examples/workflow-tsl-entry.md +13 -0
- package/skills/threejs-node-tsl/references/official-links.md +8 -0
- package/skills/threejs-node-tsl/references/tsl-vs-classic.md +23 -0
- package/skills/threejs-objects/SKILL.md +111 -0
- package/skills/threejs-objects/examples/workflow-raycaster-pick.md +17 -0
- package/skills/threejs-postprocessing/SKILL.md +116 -0
- package/skills/threejs-postprocessing/examples/workflow-composer-bloom.md +15 -0
- package/skills/threejs-renderers/SKILL.md +91 -0
- package/skills/threejs-renderers/examples/workflow-renderer-resize.md +21 -0
- package/skills/threejs-renderers/references/official-sections.md +14 -0
- package/skills/threejs-scenes/SKILL.md +90 -0
- package/skills/threejs-scenes/examples/workflow-fog-background.md +13 -0
- package/skills/threejs-textures/SKILL.md +83 -0
- package/skills/threejs-textures/examples/workflow-pmrem-env.md +19 -0
- package/skills/threejs-webxr/SKILL.md +104 -0
- package/skills/threejs-webxr/examples/workflow-xr-button.md +15 -0
- package/workflows/_uncategorized/generate-gui-assets.md +111 -0
- package/workflows/_uncategorized/goal.md +86 -0
- package/workflows/_uncategorized/hatch-pet.md +116 -0
- package/workflows/_uncategorized/office-hours.md +38 -0
- package/workflows/_uncategorized/plan-ceo-review.md +34 -0
- package/workflows/_uncategorized/plan-design-review.md +38 -0
- package/workflows/_uncategorized/plan-eng-review.md +43 -0
- package/workflows/quality/plan-ceo-review.md +34 -0
- package/workflows/quality/plan-design-review.md +38 -0
- package/workflows/quality/plan-eng-review.md +43 -0
- package/workflows/roles/office-hours.md +38 -0
- package/workflows/ui/generate-gui-assets.md +111 -0
- package/workflows/ui/hatch-pet.md +116 -0
package/skills/review/SKILL.md
CHANGED
|
@@ -1,87 +1,59 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review
|
|
3
|
-
description: Use when completing tasks, implementing features, or before merging. Dispatch structured code review with severity classification
|
|
3
|
+
description: Use when completing tasks, implementing features, or before merging. Dispatch structured code review with severity classification.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Smart Code Review
|
|
6
|
+
# Smart Code Review v2.0 (GStack-Powered)
|
|
9
7
|
|
|
10
8
|
## Overview
|
|
9
|
+
Perform structured code reviews on modified files (using git diff against origin/main or staged changes) to catch issues before they are committed or merged.
|
|
10
|
+
Antigravity uses the `codex` CLI (or active LLM runner) to perform deep, multi-file code reviews across specific safety and quality domains.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Antigravity uses `codex` CLI to perform deep, multi-file code reviews across specific domains (Security, Localization, Compliance, Quality).
|
|
14
|
-
|
|
15
|
-
**Core principle:** Actionable, domain-specific feedback via Multi-Agent Flow.
|
|
16
|
-
|
|
17
|
-
## The Review Modules (Execution via Codex CLI)
|
|
12
|
+
## 📋 The Two-Pass Review Rubric
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
Dưới đây là 5 Module Review Tự Động. Antigravity tự động map intent của User để chọn Module phù hợp:
|
|
14
|
+
Reviews are divided into two distinct passes depending on severity:
|
|
21
15
|
|
|
22
|
-
### 1
|
|
23
|
-
**
|
|
16
|
+
### Pass 1 — CRITICAL (Highest Severity)
|
|
17
|
+
* **SQL & Data Safety:** String interpolation in SQL (require parameterized queries/prepared statements), TOCTOU race conditions (require atomic `WHERE` checks), and bypassing model validations for direct DB writes.
|
|
18
|
+
* **Race Conditions & Concurrency:** Read-check-write patterns without uniqueness constraints, find-or-create without unique DB indices, and status transitions that are not atomic.
|
|
19
|
+
* **LLM Output Trust Boundaries:** Ensure LLM-generated values are type/shape/format checked before saving to database, and external URLs generated by LLM are allowlisted.
|
|
20
|
+
* **Shell Injection:** Variable interpolation in shell execution commands (e.g. `subprocess` with `shell=True` or `exec`/`eval` without sandboxing). Use argument arrays instead.
|
|
21
|
+
* **Enum & Value Completeness:** When a new enum, status string, tier, or type constant is added, trace it through every switch, filter, or conditional block across the entire project. Ensure all consumers handle the new value.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Trả về báo cáo phân loại Critical/High/Low." --approval-mode auto
|
|
33
|
-
```
|
|
23
|
+
### Pass 2 — INFORMATIONAL (Lower Severity)
|
|
24
|
+
* **Async/Sync Mixing:** Running synchronous calls (blocking calls, file I/O, sync requests) inside async event loops.
|
|
25
|
+
* **Column/Field Name Safety:** Verify ORM query columns match actual database schemas.
|
|
26
|
+
* **LLM Prompt Issues:** 0-indexed lists in prompts (LLMs expect 1-indexed) or listing tools/capabilities that don't match the wired array.
|
|
27
|
+
* **Completeness Gaps:** Shortcut implementations where complete versions are achievable within 30 minutes, or missing test paths (negative paths, edge cases).
|
|
28
|
+
* **Time Window Safety:** Date-key lookups assuming 24h coverage without timezone normalization.
|
|
29
|
+
* **Type Coercion:** Values crossing language/JSON boundaries where types change (e.g. numeric vs string).
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
**Dùng khi User yêu cầu:** *"review đa ngôn ngữ", "check hardcode string", "kiểm tra UI"*
|
|
31
|
+
---
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
codex -p "Thực hiện Localization Review. Quét các file UI (Views, Components):
|
|
40
|
-
1. Tìm tất cả các string hiển thị cho người dùng bị hardcode mà chưa bọc qua hàm dịch (i18n, LocalizedStringKey, R.string).
|
|
41
|
-
2. Đối chiếu xem các key được gọi trong UI đã tồn tại trong file từ điển (en/vi) chưa.
|
|
42
|
-
Liệt kê chi tiết tên file và số dòng vi phạm." --approval-mode auto
|
|
43
|
-
```
|
|
33
|
+
## ⚡ The Fix-First Heuristic
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
**Dùng khi User yêu cầu:** *"review appstore", "check compliance", "chuẩn bị submit"*
|
|
35
|
+
When reviewing, classify findings into AUTO-FIX (applied automatically without prompting) or ASK (require user confirmation):
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
| AUTO-FIX (Apply without asking) | ASK (Needs user confirmation) |
|
|
38
|
+
| :--- | :--- |
|
|
39
|
+
| Dead code & unused variables | Security issues (auth, XSS, injection) |
|
|
40
|
+
| Missing eager loading (N+1 queries) | Race conditions & concurrency |
|
|
41
|
+
| Stale comments contradicting code | Design decisions |
|
|
42
|
+
| Magic numbers → named constants | Large fixes (>20 lines of code) |
|
|
43
|
+
| Missing basic input/regex validation | Enum & value completeness changes |
|
|
44
|
+
| Version/dependency mismatches | Anything changing user-visible behavior |
|
|
55
45
|
|
|
56
|
-
|
|
57
|
-
**Dùng khi User yêu cầu:** *"review kiến trúc", "review logic", "code smell"*
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
codex -p "Thực hiện Architecture & Logic Review. Đánh giá:
|
|
61
|
-
1. Vi phạm nguyên tắc SOLID và Clean Architecture (VD: View xử lý Business Logic).
|
|
62
|
-
2. Code duplication (Lặp code) hoặc Hàm quá dài (>50 lines).
|
|
63
|
-
3. Thiếu Error Handling trong các async function / API calls.
|
|
64
|
-
4. Memory Leaks (Retain cycles, forgot to unsubscribe)." --approval-mode auto
|
|
65
|
-
```
|
|
46
|
+
---
|
|
66
47
|
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
## 🚫 Harmless Noise Suppressions (DO NOT flag)
|
|
49
|
+
* Harmless redundancies that aid readability (e.g., `present?` vs `length > 0`).
|
|
50
|
+
* Harmless no-ops (e.g., `.reject` on an element never present in the array).
|
|
51
|
+
* Requests to add comments explaining "why" a threshold was chosen.
|
|
52
|
+
* Suggestions to write tighter assertions in test cases that are already covering the behavior.
|
|
53
|
+
* Anything already addressed in the active diff.
|
|
69
54
|
|
|
55
|
+
## 🛠️ Execution via Codex CLI
|
|
56
|
+
Invoke the review module using the non-interactive Codex CLI or active model runner:
|
|
70
57
|
```bash
|
|
71
|
-
codex -p "
|
|
58
|
+
codex -p "Perform a GStack-style pre-landing review. Highlight Pass 1 (Critical) and Pass 2 (Informational) issues, then apply the Fix-First heuristic." --approval-mode auto
|
|
72
59
|
```
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Cách Xử Lý Output Từ Codex
|
|
77
|
-
1. Fix 🔴 **Critical** issues NGAY LẬP TỨC. (VD: Lộ Key, API chưa chặn rate limit).
|
|
78
|
-
2. Fix 🟡 **Important** issues trước khi kết thúc task hoặc chuyển sang Phase mới. (VD: Quên localize string).
|
|
79
|
-
3. Log 🟢 **Minor** issues để cấu trúc lại sau.
|
|
80
|
-
4. Proceed nếu Subagent Codex báo "LGTM" hoặc không có issue nào nghiêm trọng.
|
|
81
|
-
|
|
82
|
-
## Integration
|
|
83
|
-
|
|
84
|
-
**Used by:**
|
|
85
|
-
- `single-flow-task-execution` — Review sau mỗi task
|
|
86
|
-
- `symphony-enforcer` — Review trước khi `symphony_complete_task`
|
|
87
|
-
- Thay thế hoàn toàn quy trình thủ công của `/audit` workflow.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threejs-animation
|
|
3
|
+
description: "three.js keyframe animation system: AnimationMixer, AnimationClip, AnimationAction, KeyframeTrack variants, PropertyBinding, PropertyMixer, AnimationObjectGroup, AnimationUtils; mixing and crossfading clips, loop modes, timeScale, weight; addon AnimationClipCreator and CCDIKSolver for procedural rigs. Use when playing glTF clips, blending actions, or authoring procedural tracks; for skin deformation rigging on meshes see threejs-objects; for math interpolants without clips see threejs-math only when not tied to AnimationMixer."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## When to use this skill
|
|
7
|
+
|
|
8
|
+
**ALWAYS use this skill when the user mentions:**
|
|
9
|
+
|
|
10
|
+
- `AnimationMixer.update`, `AnimationAction` play/pause/stop, crossfade, synchronized clips
|
|
11
|
+
- `AnimationClip` from glTF or `AnimationClipCreator`, retargeting caveats at API level
|
|
12
|
+
- Keyframe tracks: position/rotation/scale/color tracks, boolean/string tracks where applicable
|
|
13
|
+
- IK: `CCDIKSolver` / `CCDIKHelper` from addons
|
|
14
|
+
|
|
15
|
+
**IMPORTANT: animation vs objects**
|
|
16
|
+
|
|
17
|
+
- **threejs-animation** = time evaluation and tracks.
|
|
18
|
+
- **threejs-objects** = `SkinnedMesh`/`Skeleton` attachment, bind pose—mesh side.
|
|
19
|
+
|
|
20
|
+
**Trigger phrases include:**
|
|
21
|
+
|
|
22
|
+
- "AnimationMixer", "AnimationAction", "AnimationClip", "crossFade", "KeyframeTrack"
|
|
23
|
+
- "动画混合", "骨骼动画", "剪辑", "淡入淡出"
|
|
24
|
+
|
|
25
|
+
## How to use this skill
|
|
26
|
+
|
|
27
|
+
1. **Collect clips** from `gltf.animations` or create with utilities / `AnimationClipCreator`.
|
|
28
|
+
2. **Create mixer** bound to root object (often `scene` or rig root).
|
|
29
|
+
3. **Create actions** per clip via `mixer.clipAction(clip)`; configure loop mode (`LoopOnce`, `LoopRepeat`, `LoopPingPong`).
|
|
30
|
+
4. **Per frame**: compute delta seconds (use `Clock` from core—documented under Core in docs index), call `mixer.update(delta)`.
|
|
31
|
+
5. **Blending**: adjust `weight`, `crossFadeTo`, `enabled` flags; watch for additive vs full replacement semantics per docs.
|
|
32
|
+
6. **PropertyBinding**: understand path strings targeting bones/morphs—errors often from wrong object names.
|
|
33
|
+
7. **IK addon**: attach solver after base animation if using CCD IK from examples.
|
|
34
|
+
|
|
35
|
+
See [examples/workflow-mixer-action.md](examples/workflow-mixer-action.md).
|
|
36
|
+
|
|
37
|
+
## Doc map (official)
|
|
38
|
+
|
|
39
|
+
| Docs section | Representative links |
|
|
40
|
+
|--------------|----------------------|
|
|
41
|
+
| Animation (index) | https://threejs.org/docs/#Animation |
|
|
42
|
+
| Action | https://threejs.org/docs/AnimationAction.html |
|
|
43
|
+
| Mixer | https://threejs.org/docs/AnimationMixer.html |
|
|
44
|
+
| Clip | https://threejs.org/docs/AnimationClip.html |
|
|
45
|
+
| Tracks | https://threejs.org/docs/KeyframeTrack.html |
|
|
46
|
+
|
|
47
|
+
More: [references/official-sections.md](references/official-sections.md).
|
|
48
|
+
|
|
49
|
+
## Scope
|
|
50
|
+
|
|
51
|
+
- **In scope:** Core Animation module, keyframe pipeline, listed addons for clip creation and IK.
|
|
52
|
+
- **Out of scope:** DCC export best practices; physics ragdoll; audio sync (link conceptually only).
|
|
53
|
+
|
|
54
|
+
## Common pitfalls and best practices
|
|
55
|
+
|
|
56
|
+
- Forgetting `mixer.update` freezes animation; double `update` per frame speeds up.
|
|
57
|
+
- Mixing clips with incompatible hierarchies causes violent pops—validate bind pose.
|
|
58
|
+
- Root motion must be handled in game logic if not baked—document explicitly.
|
|
59
|
+
- Large track counts cost CPU—strip unused tracks in preprocessing when possible.
|
|
60
|
+
|
|
61
|
+
## Documentation and version
|
|
62
|
+
|
|
63
|
+
Behavior of `AnimationMixer`, tracks, and glTF animation import can change between three.js majors. Treat the [Animation](https://threejs.org/docs/#Animation) section of the [docs index](https://threejs.org/docs/) as authoritative for the user’s installed version; when upgrading, check the three.js repository release notes and migration notes for renamed properties or loader output.
|
|
64
|
+
|
|
65
|
+
## Agent response checklist
|
|
66
|
+
|
|
67
|
+
When answering under this skill, prefer responses that:
|
|
68
|
+
|
|
69
|
+
1. Cite the exact class (`AnimationMixer`, `AnimationAction`, etc.) or addon (`CCDIKSolver`) from the official docs.
|
|
70
|
+
2. Include at least one `https://threejs.org/docs/...` link (e.g. [AnimationAction](https://threejs.org/docs/AnimationAction.html)).
|
|
71
|
+
3. Relate clips to `SkinnedMesh` / skeleton via **threejs-objects** when deformation is involved.
|
|
72
|
+
4. Mention `mixer.update(delta)` and a stable time source (`Clock`) explicitly.
|
|
73
|
+
5. Reference official **examples** by name only (no full file paste).
|
|
74
|
+
|
|
75
|
+
## References
|
|
76
|
+
|
|
77
|
+
- https://threejs.org/docs/#Animation
|
|
78
|
+
- https://threejs.org/docs/AnimationMixer.html
|
|
79
|
+
- https://threejs.org/docs/AnimationAction.html
|
|
80
|
+
- https://threejs.org/docs/PropertyBinding.html
|
|
81
|
+
|
|
82
|
+
## Keywords
|
|
83
|
+
|
|
84
|
+
**English:** animationmixer, animationaction, animationclip, keyframetrack, crossfade, skinning, propertybinding, three.js
|
|
85
|
+
|
|
86
|
+
**中文:** 动画混合、AnimationMixer、AnimationAction、关键帧、骨骼动画、剪辑、淡入淡出、three.js
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Workflow: play one glTF clip
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. After **threejs-loaders** provides `gltf` with `animations` array non-empty.
|
|
6
|
+
|
|
7
|
+
2. `const mixer = new THREE.AnimationMixer(gltf.scene);`
|
|
8
|
+
|
|
9
|
+
3. `const clip = gltf.animations[0]; const action = mixer.clipAction(clip); action.play();`
|
|
10
|
+
|
|
11
|
+
4. In the render loop: `const delta = clock.getDelta(); mixer.update(delta);` then render (**threejs-renderers**).
|
|
12
|
+
|
|
13
|
+
5. To switch clips, prepare second `clipAction`, then `action.crossFadeTo(nextAction, duration, false)` per docs.
|
|
14
|
+
|
|
15
|
+
6. Dispose mixer when discarding the rig if your app hot-swaps characters.
|
|
16
|
+
|
|
17
|
+
## Anchor
|
|
18
|
+
|
|
19
|
+
- https://threejs.org/docs/AnimationMixer.html
|
|
20
|
+
- https://threejs.org/docs/AnimationAction.html
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Animation module (core)
|
|
2
|
+
|
|
3
|
+
- https://threejs.org/docs/AnimationAction.html
|
|
4
|
+
- https://threejs.org/docs/AnimationClip.html
|
|
5
|
+
- https://threejs.org/docs/AnimationMixer.html
|
|
6
|
+
- https://threejs.org/docs/AnimationObjectGroup.html
|
|
7
|
+
- https://threejs.org/docs/AnimationUtils.html
|
|
8
|
+
- https://threejs.org/docs/KeyframeTrack.html
|
|
9
|
+
- https://threejs.org/docs/VectorKeyframeTrack.html
|
|
10
|
+
- https://threejs.org/docs/QuaternionKeyframeTrack.html
|
|
11
|
+
- https://threejs.org/docs/PropertyBinding.html
|
|
12
|
+
- https://threejs.org/docs/PropertyMixer.html
|
|
13
|
+
|
|
14
|
+
**Addons**
|
|
15
|
+
|
|
16
|
+
- https://threejs.org/docs/AnimationClipCreator.html
|
|
17
|
+
- https://threejs.org/docs/CCDIKSolver.html
|
|
18
|
+
|
|
19
|
+
See https://threejs.org/docs/#Animation
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threejs-audio
|
|
3
|
+
description: "three.js audio spatialization: AudioListener attached to camera rig, Audio and PositionalAudio sources, AudioAnalyser for FFT/time-domain data, and integration with Web Audio API contexts; AudioLoader is referenced from threejs-loaders for file decoding. Use when placing 3D sound, configuring panner parameters, or building audio visualization; not a replacement for full game audio middleware."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## When to use this skill
|
|
7
|
+
|
|
8
|
+
**ALWAYS use this skill when the user mentions:**
|
|
9
|
+
|
|
10
|
+
- `AudioListener` on `Camera`, `Audio` vs `PositionalAudio`, distance models, refDistance/maxDistance/rolloff
|
|
11
|
+
- `AudioAnalyser` for visualization bars/spectrum
|
|
12
|
+
- Browser autoplay policies blocking audio start
|
|
13
|
+
|
|
14
|
+
**IMPORTANT: audio vs loaders**
|
|
15
|
+
|
|
16
|
+
| Step | Skill |
|
|
17
|
+
|------|--------|
|
|
18
|
+
| Decode mp3/ogg buffer | **threejs-loaders** (`AudioLoader`) |
|
|
19
|
+
| Spatial playback API | **threejs-audio** |
|
|
20
|
+
|
|
21
|
+
**Trigger phrases include:**
|
|
22
|
+
|
|
23
|
+
- "PositionalAudio", "AudioListener", "AudioAnalyser", "panner"
|
|
24
|
+
- "空间音频", "音量衰减", "频谱"
|
|
25
|
+
|
|
26
|
+
## How to use this skill
|
|
27
|
+
|
|
28
|
+
1. **Attach listener** to camera object so head-related audio follows view.
|
|
29
|
+
2. **Validate AudioContext state** — check `listener.context.state` before playback; resume if suspended.
|
|
30
|
+
3. **Create context** compatible with user gesture unlock patterns in browsers.
|
|
31
|
+
4. **PositionalAudio** — set `refDistance`, `maxDistance`, `rolloffFactor`, `distanceModel` per docs.
|
|
32
|
+
5. **Load buffer** via `AudioLoader` (**threejs-loaders**), then `positionalAudio.setBuffer`.
|
|
33
|
+
6. **Analyser** — connect graph `listener.context.createAnalyser()` pathways per examples; watch performance.
|
|
34
|
+
7. **Update** — audio nodes usually need no per-frame update unless following moving sources manually.
|
|
35
|
+
|
|
36
|
+
### Example: PositionalAudio with context validation
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import * as THREE from 'three';
|
|
40
|
+
|
|
41
|
+
const listener = new THREE.AudioListener();
|
|
42
|
+
camera.add(listener);
|
|
43
|
+
|
|
44
|
+
// Validate AudioContext state before attempting playback
|
|
45
|
+
function ensureAudioContext() {
|
|
46
|
+
if (listener.context.state === 'suspended') {
|
|
47
|
+
listener.context.resume();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Resume on user gesture (required by browser autoplay policy)
|
|
52
|
+
document.addEventListener('click', ensureAudioContext, { once: true });
|
|
53
|
+
|
|
54
|
+
const sound = new THREE.PositionalAudio(listener);
|
|
55
|
+
const loader = new THREE.AudioLoader();
|
|
56
|
+
loader.load('sound.mp3', (buffer) => {
|
|
57
|
+
sound.setBuffer(buffer);
|
|
58
|
+
sound.setRefDistance(20);
|
|
59
|
+
sound.setRolloffFactor(1);
|
|
60
|
+
});
|
|
61
|
+
mesh.add(sound); // Attach to a scene object for spatial positioning
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
See [examples/workflow-positional-audio.md](examples/workflow-positional-audio.md).
|
|
65
|
+
|
|
66
|
+
## Doc map (official)
|
|
67
|
+
|
|
68
|
+
| Docs section | Representative links |
|
|
69
|
+
|--------------|----------------------|
|
|
70
|
+
| Audio | https://threejs.org/docs/AudioListener.html |
|
|
71
|
+
| Audio | https://threejs.org/docs/Audio.html |
|
|
72
|
+
| Audio | https://threejs.org/docs/PositionalAudio.html |
|
|
73
|
+
| Audio | https://threejs.org/docs/AudioAnalyser.html |
|
|
74
|
+
|
|
75
|
+
Extended list: [references/official-sections.md](references/official-sections.md).
|
|
76
|
+
|
|
77
|
+
## Scope
|
|
78
|
+
|
|
79
|
+
- **In scope:** Core Audio classes, spatialization parameters, analyser usage overview.
|
|
80
|
+
- **Out of scope:** FMOD/Wwise-style authoring tools.
|
|
81
|
+
|
|
82
|
+
## Common pitfalls and best practices
|
|
83
|
+
|
|
84
|
+
- Autoplay restrictions require user interaction to resume AudioContext.
|
|
85
|
+
- Too many positional sources hurt CPU—pool or LOD audio.
|
|
86
|
+
- Ensure world units match distance model expectations.
|
|
87
|
+
|
|
88
|
+
## Documentation and version
|
|
89
|
+
|
|
90
|
+
Audio classes are under [Audio](https://threejs.org/docs/#Audio) in [three.js docs](https://threejs.org/docs/). Decoding buffers uses `AudioLoader`—see **threejs-loaders**. Browser Web Audio policies are external but must be mentioned when `AudioContext` is suspended.
|
|
91
|
+
|
|
92
|
+
## Agent response checklist
|
|
93
|
+
|
|
94
|
+
When answering under this skill, prefer responses that:
|
|
95
|
+
|
|
96
|
+
1. Link `AudioListener`, `PositionalAudio`, or `AudioAnalyser` as relevant.
|
|
97
|
+
2. Delegate file loading of sound buffers to **threejs-loaders** (`AudioLoader`).
|
|
98
|
+
3. Note autoplay / user-gesture requirements for resuming context.
|
|
99
|
+
4. Relate distance attenuation to world units and **threejs-objects** placement.
|
|
100
|
+
5. Avoid promising DAW-level mixing—stay within three.js audio scope.
|
|
101
|
+
|
|
102
|
+
## References
|
|
103
|
+
|
|
104
|
+
- https://threejs.org/docs/#Audio
|
|
105
|
+
- https://threejs.org/docs/AudioListener.html
|
|
106
|
+
- https://threejs.org/docs/PositionalAudio.html
|
|
107
|
+
|
|
108
|
+
## Keywords
|
|
109
|
+
|
|
110
|
+
**English:** audio, positional audio, listener, analyser, spatial sound, web audio, three.js
|
|
111
|
+
|
|
112
|
+
**中文:** 音频、空间音频、AudioListener、PositionalAudio、Web Audio、three.js
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Workflow: positional loop with loader
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Create `AudioListener`, `camera.add(listener)`.
|
|
6
|
+
|
|
7
|
+
2. `const sound = new THREE.PositionalAudio(listener);`
|
|
8
|
+
|
|
9
|
+
3. `const loader = new THREE.AudioLoader();` (**threejs-loaders**) `loader.load('file.ogg', buffer => { sound.setBuffer(buffer); sound.setRefDistance(1); sound.play(); });`
|
|
10
|
+
|
|
11
|
+
4. Add `sound` as child of moving mesh or update position each frame.
|
|
12
|
+
|
|
13
|
+
5. Connect `AudioAnalyser` only if visualization required—extra CPU.
|
|
14
|
+
|
|
15
|
+
Browser autoplay: resume context on first click if needed.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Audio module (core)
|
|
2
|
+
|
|
3
|
+
Index: https://threejs.org/docs/#Audio
|
|
4
|
+
|
|
5
|
+
- https://threejs.org/docs/AudioListener.html
|
|
6
|
+
- https://threejs.org/docs/Audio.html
|
|
7
|
+
- https://threejs.org/docs/PositionalAudio.html
|
|
8
|
+
- https://threejs.org/docs/AudioAnalyser.html
|
|
9
|
+
|
|
10
|
+
**Loaders (decode buffers — see skill `threejs-loaders`)**
|
|
11
|
+
|
|
12
|
+
- https://threejs.org/docs/AudioLoader.html
|
|
13
|
+
|
|
14
|
+
**Addons (positional helper)**
|
|
15
|
+
|
|
16
|
+
- https://threejs.org/docs/PositionalAudioHelper.html
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threejs-camera
|
|
3
|
+
description: "three.js cameras: Camera base, PerspectiveCamera, OrthographicCamera, CubeCamera, ArrayCamera, StereoCamera; projection matrices, aspect, FOV, orthographic frustum sizes, near/far planes, and dynamic environment maps with CubeCamera. Use when placing views, rendering reflections, or multi-view splits; for XR projections and eye matrices use threejs-webxr; for post pass camera tricks use threejs-postprocessing alongside threejs-renderers."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## When to use this skill
|
|
7
|
+
|
|
8
|
+
**ALWAYS use this skill when the user mentions:**
|
|
9
|
+
|
|
10
|
+
- Switching perspective vs orthographic, `fov`, `aspect`, `zoom`, `near`, `far`
|
|
11
|
+
- `CubeCamera` for real-time environment maps or reflections (update rate caveats)
|
|
12
|
+
- `ArrayCamera`/`StereoCamera` for multi-view or stereo off-axis projection (non-XR)
|
|
13
|
+
|
|
14
|
+
**IMPORTANT: camera vs webxr vs post**
|
|
15
|
+
|
|
16
|
+
| Topic | Skill |
|
|
17
|
+
|-------|--------|
|
|
18
|
+
| Standard desktop projection | **threejs-camera** |
|
|
19
|
+
| XR reference spaces, IPD | **threejs-webxr** |
|
|
20
|
+
| Offscreen pass cameras inside composer | **threejs-postprocessing** |
|
|
21
|
+
|
|
22
|
+
**Trigger phrases include:**
|
|
23
|
+
|
|
24
|
+
- "PerspectiveCamera", "OrthographicCamera", "CubeCamera", "aspect", "near", "far"
|
|
25
|
+
- "透视相机", "正交", "立方体相机"
|
|
26
|
+
|
|
27
|
+
## How to use this skill
|
|
28
|
+
|
|
29
|
+
1. **Perspective**: set `aspect` = width/height; update on resize (**threejs-renderers** example workflow).
|
|
30
|
+
2. **Orthographic**: define `left/right/top/bottom` in world units for CAD/2.5D views.
|
|
31
|
+
3. **Near/far**: balance depth precision vs containing scene bounds; relate to fog (**threejs-scenes**).
|
|
32
|
+
4. **CubeCamera**: position at reflection probe; call `update` when scene static enough; use render target outputs per docs.
|
|
33
|
+
5. **Stereo/Array**: advanced; cite docs for eye parameters; defer XR to **threejs-webxr**.
|
|
34
|
+
6. **Projection matrix**: call `updateProjectionMatrix()` after parameter edits.
|
|
35
|
+
7. **Helpers**: `CameraHelper` lives in **threejs-helpers**.
|
|
36
|
+
|
|
37
|
+
### Example: Resize handler with updateProjectionMatrix
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
window.addEventListener('resize', () => {
|
|
41
|
+
camera.aspect = window.innerWidth / window.innerHeight;
|
|
42
|
+
camera.updateProjectionMatrix();
|
|
43
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See [examples/workflow-perspective-resize.md](examples/workflow-perspective-resize.md).
|
|
48
|
+
|
|
49
|
+
## Doc map (official)
|
|
50
|
+
|
|
51
|
+
| Docs section | Representative links |
|
|
52
|
+
|--------------|----------------------|
|
|
53
|
+
| Cameras (index) | https://threejs.org/docs/#Cameras |
|
|
54
|
+
| Cameras | https://threejs.org/docs/Camera.html |
|
|
55
|
+
| Perspective | https://threejs.org/docs/PerspectiveCamera.html |
|
|
56
|
+
| Orthographic | https://threejs.org/docs/OrthographicCamera.html |
|
|
57
|
+
| Cube | https://threejs.org/docs/CubeCamera.html |
|
|
58
|
+
| Multi-view | https://threejs.org/docs/ArrayCamera.html |
|
|
59
|
+
| Stereo (non-XR) | https://threejs.org/docs/StereoCamera.html |
|
|
60
|
+
|
|
61
|
+
## Scope
|
|
62
|
+
|
|
63
|
+
- **In scope:** Core camera classes and parameters; cube/array/stereo overview.
|
|
64
|
+
- **Out of scope:** WebXR reference spaces, eye matrices, session lifecycle (**threejs-webxr**); shadow map camera tuning (**threejs-lights**); pass-internal cameras in composer (**threejs-postprocessing**).
|
|
65
|
+
|
|
66
|
+
## Common pitfalls and best practices
|
|
67
|
+
|
|
68
|
+
- Wrong `aspect` after resize stretches image—always sync with canvas.
|
|
69
|
+
- Too small `near` hurts depth precision in large worlds.
|
|
70
|
+
- `CubeCamera` every frame is expensive—throttle for performance.
|
|
71
|
+
|
|
72
|
+
## Documentation and version
|
|
73
|
+
|
|
74
|
+
Camera parameters and `CubeCamera` update behavior follow the [Cameras](https://threejs.org/docs/#Cameras) section of [three.js docs](https://threejs.org/docs/). WebXR uses different projection paths—hand off to **threejs-webxr** when the user mentions headsets or reference spaces.
|
|
75
|
+
|
|
76
|
+
## Agent response checklist
|
|
77
|
+
|
|
78
|
+
When answering under this skill, prefer responses that:
|
|
79
|
+
|
|
80
|
+
1. Link `PerspectiveCamera`, `OrthographicCamera`, or `CubeCamera` as relevant.
|
|
81
|
+
2. Pair resize with **threejs-renderers** `setSize` / DPR patterns when relevant.
|
|
82
|
+
3. Route `XR`/`WebXRManager` questions to **threejs-webxr** after one-line renderer mention.
|
|
83
|
+
4. Mention `updateProjectionMatrix()` after intrinsic changes.
|
|
84
|
+
5. Use **threejs-helpers** `CameraHelper` for shadow frustum debug when discussing lights.
|
|
85
|
+
|
|
86
|
+
## References
|
|
87
|
+
|
|
88
|
+
- https://threejs.org/docs/#Cameras
|
|
89
|
+
- https://threejs.org/docs/PerspectiveCamera.html
|
|
90
|
+
- https://threejs.org/docs/CubeCamera.html
|
|
91
|
+
|
|
92
|
+
## Keywords
|
|
93
|
+
|
|
94
|
+
**English:** perspectivecamera, orthographiccamera, cubecamera, projection, aspect, near, far, three.js
|
|
95
|
+
|
|
96
|
+
**中文:** 相机、透视、正交、投影、近裁剪、远裁剪、CubeCamera、three.js
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Workflow: perspective camera on window resize
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Store `PerspectiveCamera` reference.
|
|
6
|
+
|
|
7
|
+
2. On resize: `camera.aspect = width / height; camera.updateProjectionMatrix();`
|
|
8
|
+
|
|
9
|
+
3. Pair with renderer `setSize` from **threejs-renderers** examples.
|
|
10
|
+
|
|
11
|
+
4. For orthographic cameras, recompute `left/right/top/bottom` if using fit-to-view logic.
|
|
12
|
+
|
|
13
|
+
This is the standard pattern used across three.js examples.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threejs-controls
|
|
3
|
+
description: "Addon camera and object manipulation controls: OrbitControls, MapControls, FlyControls, FirstPersonControls, TrackballControls, ArcballControls, DragControls, PointerLockControls, TransformControls; damping, target focal point, and integration with the animation loop. Use for editor-style navigation and gizmos—not a full game character controller stack; pair with Raycaster selection patterns in threejs-objects when transforming selections."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## When to use this skill
|
|
7
|
+
|
|
8
|
+
**ALWAYS use this skill when the user mentions:**
|
|
9
|
+
|
|
10
|
+
- Orbiting/panning/dolly around a target, inertia/damping, min/max distance/polar angles
|
|
11
|
+
- Map-like pan (MapControls) or flying (FlyControls)
|
|
12
|
+
- Transform gizmo translate/rotate/scale with `TransformControls`
|
|
13
|
+
- Dragging objects in plane (DragControls), pointer lock FPS (PointerLockControls)
|
|
14
|
+
|
|
15
|
+
**IMPORTANT: controls vs webxr**
|
|
16
|
+
|
|
17
|
+
| Context | Skill |
|
|
18
|
+
|---------|--------|
|
|
19
|
+
| Desktop/browser camera nav | **threejs-controls** |
|
|
20
|
+
| XR controller poses | **threejs-webxr** |
|
|
21
|
+
|
|
22
|
+
**Trigger phrases include:**
|
|
23
|
+
|
|
24
|
+
- "OrbitControls", "TransformControls", "MapControls", "PointerLockControls"
|
|
25
|
+
- "轨道", "变换控制器", "漫游"
|
|
26
|
+
|
|
27
|
+
## How to use this skill
|
|
28
|
+
|
|
29
|
+
1. **Import** from addons path (**threejs-dev-setup**).
|
|
30
|
+
2. **Construct** with `(camera, domElement)`; for `TransformControls` also attach to renderer events.
|
|
31
|
+
3. **Animation loop**: when `enableDamping`, call `controls.update()` each frame.
|
|
32
|
+
4. **TransformControls**: wire `dragging-changed` to disable Orbit temporarily; sync with selection from **threejs-objects**.
|
|
33
|
+
5. **Constraints**: set min/max distance/angles to avoid flipping or underground views.
|
|
34
|
+
6. **Dispose**: `controls.dispose()` when tearing down.
|
|
35
|
+
|
|
36
|
+
### Example: OrbitControls with damping
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
40
|
+
|
|
41
|
+
const controls = new OrbitControls(camera, renderer.domElement);
|
|
42
|
+
controls.enableDamping = true;
|
|
43
|
+
controls.dampingFactor = 0.05;
|
|
44
|
+
controls.minDistance = 2;
|
|
45
|
+
controls.maxDistance = 50;
|
|
46
|
+
|
|
47
|
+
// Must call update() each frame when damping is enabled
|
|
48
|
+
function animate() {
|
|
49
|
+
controls.update();
|
|
50
|
+
renderer.render(scene, camera);
|
|
51
|
+
}
|
|
52
|
+
renderer.setAnimationLoop(animate);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See [examples/workflow-orbit-damping.md](examples/workflow-orbit-damping.md).
|
|
56
|
+
|
|
57
|
+
## Doc map (official)
|
|
58
|
+
|
|
59
|
+
| Docs section | Representative links |
|
|
60
|
+
|--------------|----------------------|
|
|
61
|
+
| Controls | https://threejs.org/docs/OrbitControls.html |
|
|
62
|
+
| Controls | https://threejs.org/docs/TransformControls.html |
|
|
63
|
+
| Controls | https://threejs.org/docs/MapControls.html |
|
|
64
|
+
| Controls (index) | https://threejs.org/docs/#Controls |
|
|
65
|
+
|
|
66
|
+
## Scope
|
|
67
|
+
|
|
68
|
+
- **In scope:** Official addons controls usage patterns.
|
|
69
|
+
- **Out of scope:** Full physics character motor; mobile gesture frameworks.
|
|
70
|
+
|
|
71
|
+
## Common pitfalls and best practices
|
|
72
|
+
|
|
73
|
+
- Forgetting `update()` with damping enabled causes drift never settling.
|
|
74
|
+
- TransformControls fighting with Orbit—pause one while using the other.
|
|
75
|
+
- Pointer lock requires user gesture and exit handling.
|
|
76
|
+
|
|
77
|
+
## Documentation and version
|
|
78
|
+
|
|
79
|
+
Controls are under [Controls](https://threejs.org/docs/#Controls) (Addons) in [three.js docs](https://threejs.org/docs/). API details (`enableDamping`, events) evolve—link `OrbitControls` / `TransformControls` pages for the user’s three.js version.
|
|
80
|
+
|
|
81
|
+
## Agent response checklist
|
|
82
|
+
|
|
83
|
+
When answering under this skill, prefer responses that:
|
|
84
|
+
|
|
85
|
+
1. Link the specific controls class from the docs.
|
|
86
|
+
2. State `controls.update()` when damping is on, every frame.
|
|
87
|
+
3. Coordinate `TransformControls` with selection / **threejs-objects** raycasting.
|
|
88
|
+
4. Separate desktop navigation from **threejs-webxr** locomotion.
|
|
89
|
+
5. Call `dispose()` on controls when unmounting canvas.
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- https://threejs.org/docs/#Controls
|
|
94
|
+
- https://threejs.org/docs/OrbitControls.html
|
|
95
|
+
- https://threejs.org/docs/TransformControls.html
|
|
96
|
+
|
|
97
|
+
## Keywords
|
|
98
|
+
|
|
99
|
+
**English:** orbitcontrols, transformcontrols, mapcontrols, damping, camera controls, three.js
|
|
100
|
+
|
|
101
|
+
**中文:** OrbitControls、轨道、TransformControls、变换控制器、阻尼、three.js
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Workflow: OrbitControls with damping
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. `const controls = new OrbitControls(camera, renderer.domElement);`
|
|
6
|
+
|
|
7
|
+
2. `controls.enableDamping = true; controls.dampingFactor = 0.05;`
|
|
8
|
+
|
|
9
|
+
3. Each frame before render: `controls.update();`
|
|
10
|
+
|
|
11
|
+
4. Listen to `controls.addEventListener('change', render)` only if using lazy rendering; continuous apps already render in rAF.
|
|
12
|
+
|
|
13
|
+
5. On destroy: `controls.dispose()`.
|
|
14
|
+
|
|
15
|
+
API: https://threejs.org/docs/OrbitControls.html
|