@babylonjs-toolkit/agent 1.1.51 → 1.1.54
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/README.md +6 -4
- package/package.json +1 -1
- package/skills/bt-combine/SKILL.md +262 -0
- package/skills/bt-combine/scripts/BtCombine.cs +1618 -0
- package/skills/bt-combine/scripts/qa/compare-browser.mjs +164 -0
- package/skills/bt-combine/scripts/qa/gltf-stats.mjs +57 -0
- package/skills/bt-combine/scripts/qa/package.json +9 -0
- package/skills/bt-copycat/SKILL.md +2 -0
- package/skills/bt-design/SKILL.md +4 -0
- package/skills/bt-execute/SKILL.md +6 -1
- package/skills/bt-landing/SKILL.md +6 -1
- package/skills/bt-plan/SKILL.md +21 -14
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Babylon Toolkit Desktop Agent (1.1.
|
|
1
|
+
# Babylon Toolkit Desktop Agent (1.1.54)
|
|
2
2
|
|
|
3
3
|
The desktop agent owns the entire pipeline end to end — frontend and UI design, gameplay code, shaders, generated art and audio, 3D models in headless Blender, whole game levels and prefabs in a terminal-driven Unity Editor, the interactive glTF export, the web build, the dev server, and visual QA by screenshotting both Unity and the running browser.
|
|
4
4
|
|
|
@@ -251,6 +251,7 @@ pair or schedule the bridge.
|
|
|
251
251
|
| [`bt-design`](skills/bt-design/SKILL.md) | `/bt-design` | Implement high quality frontend and in-game designs. |
|
|
252
252
|
| [`bt-hero`](skills/bt-hero/SKILL.md) | `/bt-hero` | Create smooth cinematic 3D scrolling hero sections. |
|
|
253
253
|
| [`bt-atlas`](skills/bt-atlas/SKILL.md) | `/bt-atlas` | Generate texture atlas skin variations. |
|
|
254
|
+
| [`bt-combine`](skills/bt-combine/SKILL.md) | `/bt-combine` | Analyse a Unity scene and merge the static meshes and LOD groups that can safely be merged (packed lightmap UVs, LOD clusters with corrected switch distances), on a copy of the scene — then re-bake, export and verify against the original in Unity and the browser. |
|
|
254
255
|
|
|
255
256
|
Every tool derives the slash-command from the **folder name** (`bt-spec/` → `/bt-spec`) and reads
|
|
256
257
|
the frontmatter `name` + `description` to decide when the skill applies. The `allowed-tools`
|
|
@@ -326,8 +327,9 @@ attempts, 5 under `--strict`), is then marked `⏭️ DEFERRED (auto-pilot): <re
|
|
|
326
327
|
on; deferred tasks get one more pass at the end. Each verified task is committed as a checkpoint
|
|
327
328
|
on the current branch (an `autopilot/<plan>` branch is created if you are on `main`; nothing is
|
|
328
329
|
ever pushed), and a `<plan>_autopilot.md` run log next to the plan records every task outcome,
|
|
329
|
-
decision and deferral for you to read in the morning
|
|
330
|
-
|
|
330
|
+
decision and deferral for you to read in the morning, plus clock times per phase and per task
|
|
331
|
+
(interactive runs log the clock times too) so bt-plan's time estimates can be recalibrated from
|
|
332
|
+
real runs. Re-running the same command resumes and re-attempts anything deferred.
|
|
331
333
|
|
|
332
334
|
One thing the skill cannot do is answer the host's tool-permission prompts — start the session
|
|
333
335
|
in a non-prompting permission mode (Claude Code auto / bypass-permissions) and leave Unity,
|
|
@@ -361,7 +363,7 @@ Where each tool looks for PROJECT-LOCAL skills (only when the user explicitly re
|
|
|
361
363
|
> for everything else (Codex, Copilot, Gemini CLI, Antigravity). By default use the
|
|
362
364
|
> GLOBAL (per-user home) locations; use the project-local locations only when the user
|
|
363
365
|
> explicitly asks for a project install. Copy **whole folders** into each — the
|
|
364
|
-
> `bt-atlas/scripts/` assets must be present in every location.
|
|
366
|
+
> `bt-atlas/scripts/` and `bt-combine/scripts/` assets must be present in every location.
|
|
365
367
|
|
|
366
368
|
|
|
367
369
|
# Babylon Toolkit Loop Engineering (Gauntlet Loop)
|
package/package.json
CHANGED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bt-combine
|
|
3
|
+
description: "The Babylon Toolkit Combine Skill analyses a Unity scene and merges the static meshes and LOD groups that can safely be merged — fewer meshes, fewer draw calls, faster export and load — without changing how the scene looks in Unity or in BabylonJS. It works on a copy of the scene, explains every keep/merge decision in a report, merges with the Babylon Toolkit MeshCombiner (packed source lightmap UVs, no vertex bloat), clusters LOD groups level by level with corrected switch distances, re-bakes, exports, and verifies the result against the original in Unity and in the browser. Use when the user wants to combine, merge, batch or optimize static meshes or LOD groups in a scene (e.g. `/bt-combine Assets/Scenes/Garden/GardenScene.unity`)."
|
|
4
|
+
allowed-tools: Read, Grep, Glob, Edit, Write, Bash, WebFetch(domain:raw.githubusercontent.com)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an EXPERT Babylon Toolkit and Unity technical artist. Always adhere to any rules or requirements set out in the project's agent instructions (AGENTS.md / CLAUDE.md / .github/copilot-instructions.md).
|
|
8
|
+
|
|
9
|
+
Use the user's message after the skill name as the `arguments`.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Invocation
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/bt-combine [<scene asset path>] [--out:<asset path>] [--analyze] [--reset] [--cell:15] [--spread:3] [--atlas-share:0.45]
|
|
17
|
+
[--include-shadergraphs] [--no-lods] [--exclude:Name1,Prefix*] [--only:Path/A,Path/B] [--shaders:Name1,Name2]
|
|
18
|
+
[--no-bake] [--no-export] [--no-browser] [--times:10,15,20,30]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- **`<scene asset path>`** — the scene to optimize. Default: the Editor's active scene.
|
|
22
|
+
- **`--out:`** — the working copy. Default: `<scene folder>/<SceneName>_Combined.unity`. **The source scene is never edited.**
|
|
23
|
+
- **`--analyze`** — report only: analyse the source scene, write the report, change nothing, stop.
|
|
24
|
+
- **`--reset`** — start again from the source (re-copies it over the working copy and deletes the previous merged meshes).
|
|
25
|
+
- **`--cell:`** — area "patch" size in meters that merged meshes must stay inside (default 15).
|
|
26
|
+
- **`--spread:`** — meters a merge may extend past its largest piece (default 3). Keeps merges to pieces that touch.
|
|
27
|
+
- **`--atlas-share:`** — largest share of one lightmap atlas a merged lightmapped mesh may use (default 0.45).
|
|
28
|
+
- **`--include-shadergraphs`** — also merge Shader Graph materials that pass the object-space / vertex-animation scan.
|
|
29
|
+
- **`--no-lods`** — leave every LOD group alone.
|
|
30
|
+
- **`--exclude:`** — object names (or prefixes ending in `*`) whose subtrees are never merged.
|
|
31
|
+
- **`--only:`** — limit merging to these hierarchy paths.
|
|
32
|
+
- **`--shaders:`** — extra shader names to treat as safe (custom shaders that do not use the pivot or object space).
|
|
33
|
+
- **`--no-bake` / `--no-export` / `--no-browser`** — skip those phases (each skip is stated in the final report as unverified).
|
|
34
|
+
- **`--times:`** — seconds after page load at which the browser comparison captures frames.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# What this skill guarantees
|
|
39
|
+
|
|
40
|
+
1. **The source scene — and any scene the user has open — is untouched.** All work happens in the working copy, which only `PrepareCopy` can create (it leaves a `working-copy.txt` marker; `Apply` and `RemoveCopy` refuse any scene without it). Nothing switches scenes while an open scene has unsaved changes. A bad result is undone with `--reset`.
|
|
41
|
+
2. **Every decision has a written reason.** `_combine/<Scene>_Combined/analysis.md` lists every merge (pieces, vertices, draw calls before → after, reflection probe, lights, lightmap share, spread) and every object kept separate, grouped by reason.
|
|
42
|
+
3. **No vertex bloat.** Merges use the toolkit's `UnityMeshSimplifier.MeshCombiner` in *Pack Source Lightmap UVs* mode: each source keeps its own lightmap UVs, packed side by side at its original texel density. Apply refuses to run on a toolkit build without that mode.
|
|
43
|
+
4. **It looks the same.** The result is re-baked and compared with the original — numerically (lightmap slots, UV range, texel density, LOD transitions) and visually (Unity captures and browser frames at the same moments).
|
|
44
|
+
|
|
45
|
+
# Talk to the user while you work
|
|
46
|
+
|
|
47
|
+
Long runs lose people. At every phase change, post one short plain-language update: **Done** (what changed, with numbers) · **Doing now** · **Next**. Say plainly that the merging itself is done by their toolkit's MeshCombiner. If you change the plan (exclude a group, reset, re-bake), say why in one line.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
# The merge rules — and why each exists
|
|
52
|
+
|
|
53
|
+
These rules are enforced by `scripts/BtCombine.cs`; know them so you can explain the report. Each one comes from a real regression.
|
|
54
|
+
|
|
55
|
+
**A piece can merge only if it is:**
|
|
56
|
+
|
|
57
|
+
| Rule | Why |
|
|
58
|
+
|---|---|
|
|
59
|
+
| Marked static (Contribute GI or Batching Static) | Anything else may move at runtime |
|
|
60
|
+
| Not scripted, animated, a particle system, a Rigidbody, or under one | Merged geometry cannot move or toggle on its own |
|
|
61
|
+
| Not referenced by any component (scripts, timeline bindings, cameras, signals…) | A script that toggles or moves it would lose its target |
|
|
62
|
+
| Opaque or alpha-tested (not transparent) | Transparent meshes are sorted per mesh; merging breaks draw order |
|
|
63
|
+
| A safe shader: URP/HDRP/Built-in Lit/Simple Lit/Unlit/Standard, `--shaders`, or a Shader Graph that passes the scan (`--include-shadergraphs`) | Graphs that read object space, use the Object node / model matrix, or move vertices (wind) change look when many objects share one pivot |
|
|
64
|
+
| Not mirrored (negative scale), not vertex-painted, not on toolkit layers 28–31 | The combiner does not flip winding; vertex streams and reserved layers are lost |
|
|
65
|
+
| **Lightmapped** (Contribute GI + Receive GI: Lightmaps) when the scene has light probes | A merged light-probe-lit mesh gets **one** probe sample at its centre — metal rails merged across a room turned black |
|
|
66
|
+
|
|
67
|
+
**A group of pieces merges only if they:**
|
|
68
|
+
|
|
69
|
+
| Rule | Why |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Share a container (highest ancestor with no scripts, animation or references) | Toggling or moving anything above still applies to the merged mesh |
|
|
72
|
+
| Share every renderer setting (shadows, GI, probes, Scale In Lightmap, lightmap parameters, layer, tag, static flags) | One mesh has one set |
|
|
73
|
+
| Share their dominant **reflection probe**, and the merged centre stays inside that probe's box | Probes are chosen from a mesh's bounds centre; merging two corridors moved the centre into a different probe zone and darkened both |
|
|
74
|
+
| Stay inside one area cell, and extend at most `--spread` past their largest piece | Keeps merges physically adjacent: culling, probes and light choice stay local |
|
|
75
|
+
| Fit the lightmap atlas budget, and stay under 200k vertices | One mesh must fit one lightmap; huge meshes cull badly |
|
|
76
|
+
| Are not reached by more runtime lights than BabylonJS applies per mesh (scene `maximumLights`, default 4), beyond what their most-lit piece already had | Merging must never cost a piece one of its lights |
|
|
77
|
+
|
|
78
|
+
**LOD groups** are merged as **LOD clusters**: nearby groups with the same level count, the same transition heights (typically instances of one prefab), the same fade mode and the same per-level settings. Level *i* of every member becomes one merged mesh, held by a new LOD group with exactly one renderer per level (BabylonJS's fast native LOD path). Because a bigger group switches later, the new transition heights are the old ones × (cluster size ÷ member size), and a cluster is split when a member would sit more than 20% of its LOD0→LOD1 switch distance from the cluster centre, or when the rescaled LOD0 height would reach 0.95. LOD levels above 0 may be probe-lit (seen only at distance).
|
|
79
|
+
|
|
80
|
+
**Lower LODs borrow LOD0's lightmap.** In Unity, a LOD1/LOD2 renderer that receives lightmaps but does not Contribute GI gets **LOD0's lightmap region** (same index and scale/offset), so its UV2 is authored to line up with LOD0's. The engine therefore records where each member's LOD0 UV2 was packed and applies that exact scale and offset to the member's lower levels; packing them independently turned merged rocks black at LOD1. Such clusters need exactly one LOD0 renderer per member and UV2 on every sharing level, otherwise the group is kept separate. Billboard / SpeedTree / skinned LODs, empty levels, and renderers shared between levels are left alone too.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
# Pipeline
|
|
85
|
+
|
|
86
|
+
Read the Babylon Toolkit Agent Reference router and its `unity-exporter-cli.md`, `unity-editor-commands.md` and `unity-authoring-recipes.md` (§4 lightmaps, §5–6 probes, §17 LOD, §19 static flags, §21 verification) before the first run in a session — unless your prompt already carries those excerpts.
|
|
87
|
+
|
|
88
|
+
Set these once:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
PROJ=<absolute Unity project path> # folder holding Assets/
|
|
92
|
+
SKILL_DIR=<absolute path of this skill's folder>
|
|
93
|
+
SOURCE=Assets/.../Scene.unity # from the arguments, or the active scene (bt_status → scene)
|
|
94
|
+
OUT=Assets/.../Scene_Combined.unity # --out, or <source folder>/<SceneName>_Combined.unity
|
|
95
|
+
NAME=$(basename "$OUT" .unity) # reports live in $PROJ/_combine/$NAME/
|
|
96
|
+
OPTIONS='{"cellSize":15,"maxSpread":3,"maxAtlasShare":0.45,"includeShaderGraphs":false,"combineLods":true,"exclude":[],"only":[],"extraShaders":[]}'
|
|
97
|
+
|
|
98
|
+
bt_run() { # bt_run <Method> '<json args array>'
|
|
99
|
+
unity command run_script --file AgentScripts/bt-combine/BtCombine.cs --entry "BtCombine.$1" --args "$2" \
|
|
100
|
+
--timeout_ms 1800000 --timeout 1900 --project-path "$PROJ" --format json \
|
|
101
|
+
| python3 -c "import json,sys; d=json.load(sys.stdin); r=d['data']['result']; print(r.get('result') if r.get('success') else 'FAILED: '+json.dumps(r.get('diagnostics') or r.get('errorDetails') or r)[:4000])"
|
|
102
|
+
}
|
|
103
|
+
OPTS_ARG=$(python3 -c "import json,sys; print(json.dumps([sys.argv[1]]))" "$OPTIONS") # options JSON wrapped as a one-string args array
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Map flags into `OPTIONS` (`--exclude:A,B*` → `"exclude":["A","B*"]`, `--include-shadergraphs` → `true`, `--no-lods` → `"combineLods":false`, …).
|
|
107
|
+
|
|
108
|
+
## Phase 0 — Preflight
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
unity pipeline list # Editor running, Pipeline reachable, not in Safe Mode
|
|
112
|
+
unity command editor_status --project-path "$PROJ" # ready, not in Play mode (editor_stop if it is)
|
|
113
|
+
mkdir -p "$PROJ/AgentScripts/bt-combine" && cp "$SKILL_DIR/scripts/BtCombine.cs" "$PROJ/AgentScripts/bt-combine/"
|
|
114
|
+
bt_run Preflight "[\"$SOURCE\"]"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Stop and report if: no Editor is reachable (say how to start one — `unity-exporter-cli.md` §6), the source does not exist, **any open scene has unsaved changes** (`activeScene=… dirty=True`, or a `PrepareCopy` error naming the scene — ask the user to save or discard; never save or discard their scene for them, and never open another scene over it), or `packSourceLightmapUVs=False` (their `CanvasTools.dll` predates the packing combiner — merging would split vertices; tell them to update the toolkit, or proceed only if they explicitly accept with `allowUnityUnwrap`).
|
|
118
|
+
|
|
119
|
+
## Phase 1 — Analyse
|
|
120
|
+
|
|
121
|
+
- `--analyze`: `unity command open_scene --path "$SOURCE"`, then `bt_run Analyze "$OPTS_ARG"`, summarise `_combine/<SourceName>/analysis.md`, stop.
|
|
122
|
+
- Otherwise: `bt_run PrepareCopy "[\"$SOURCE\",\"$OUT\",<true if --reset else false>]"`, then `bt_run Analyze "$OPTS_ARG"`.
|
|
123
|
+
|
|
124
|
+
If the working copy already holds merges (Apply refuses: "already combined"), either continue from Phase 3 with the existing result or rerun with `--reset` — ask only if the user's intent is unclear.
|
|
125
|
+
|
|
126
|
+
Tell the user, in a few lines: meshes and estimated draw calls before → after, number of static merges and LOD clusters, the top three "kept separate" reasons, and anything they could change to merge more (for example: "142 rocks are skipped only because they are not marked Static"). Then continue — do not wait for approval; the source is safe.
|
|
127
|
+
|
|
128
|
+
## Phase 2 — Apply
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
bt_run Apply "$OPTS_ARG"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Read the output: every group's `verts a -> b` must be equal (a mismatch or a `WARNING … re-unwrapped` line means bloat — stop and report). `needsBake=True` means Phase 3 is required.
|
|
135
|
+
|
|
136
|
+
## Phase 3 — Bake (skip only with --no-bake)
|
|
137
|
+
|
|
138
|
+
The working copy needs its own lightmaps: merged meshes have new lightmap UVs, and a copied scene still points at the source's LightingData.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
unity command bake_lighting --dry_run true --project-path "$PROJ"
|
|
142
|
+
unity command bake_lighting --confirm true --project-path "$PROJ"
|
|
143
|
+
deadline=$((SECONDS+5400)); seen=""
|
|
144
|
+
while :; do
|
|
145
|
+
s=$(unity command lighting_bake_status --project-path "$PROJ" --result-only 2>/dev/null)
|
|
146
|
+
case "$s" in
|
|
147
|
+
*completed*) break;;
|
|
148
|
+
*failed*) echo "bake failed: $s"; break;;
|
|
149
|
+
*baking*|*running*|*in_progress*) seen=1;;
|
|
150
|
+
*idle*) [ -n "$seen" ] && { echo "bake stopped without completing"; break; };;
|
|
151
|
+
esac
|
|
152
|
+
[ $SECONDS -ge $deadline ] && { echo "bake timed out"; break; }
|
|
153
|
+
sleep 15
|
|
154
|
+
done
|
|
155
|
+
unity command save_all --project-path "$PROJ" # the bake assigns new LightingData; exports refuse a dirty scene
|
|
156
|
+
bt_run CorrectDensity '[]'
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Density correction (one extra bake).** Unity sizes a merged mesh in the lightmap slightly smaller than the sum of its parts — measured on a 900-piece garden: median 84–89% of the sources' texel density, down to 73% for clusters of many small pieces. `CorrectDensity` measures every merged lightmapped mesh against its sources and raises its Scale In Lightmap by exactly the shortfall (target 95%, at most ×2). When it reports `corrected=N` with N > 0, run the bake loop above **once more**, `save_all`, then:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
bt_run Verify '[]'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`Verify` must end with `problems=0` (it flags density below 80% of the sources, missing lightmap slots, UV2 outside 0..1, malformed LOD clusters, and LightingData that is not this scene's). Typical fixes: no lightmap slot → bake again; density still low → lower `--atlas-share` and `--reset`; LightingData not this scene's → the bake did not finish or was not saved.
|
|
166
|
+
|
|
167
|
+
## Phase 4 — Unity side-by-side (LOD0 **and** LOD1)
|
|
168
|
+
|
|
169
|
+
The spawn view alone is not enough: a merge can look right up close and wrong at distance (lower LOD levels), or right in the open and wrong in a corridor. Capture the spawn view, then the three largest merges at LOD0 and forced LOD1, in both scenes (GPU Resident Drawer must be off in batch Editors — `unity-editor-commands.md` §8.1):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
CAPS="$PROJ/_combine/$NAME/captures"; mkdir -p "$CAPS"
|
|
173
|
+
CAM=$(unity command eval 'return UnityEngine.Camera.main != null ? UnityEngine.Camera.main.name : "";' --project-path "$PROJ" --result-only | python3 -c "import json,sys; print(json.load(sys.stdin)['result'])")
|
|
174
|
+
cap() { unity command capture_game_view --camera "$CAM" --width 1280 --height 720 --project-path "$PROJ" --result-only --timeout 300 \
|
|
175
|
+
| python3 -c "import json,sys,base64; d=json.load(sys.stdin); d=json.loads(d) if isinstance(d,str) else d; open(sys.argv[1],'wb').write(base64.b64decode(d['base64']))" "$1"; }
|
|
176
|
+
|
|
177
|
+
cap "$CAPS/unity_spawn_combined.png"
|
|
178
|
+
unity command open_scene --path "$SOURCE" --project-path "$PROJ"; cap "$CAPS/unity_spawn_source.png"
|
|
179
|
+
unity command open_scene --path "$OUT" --project-path "$PROJ"
|
|
180
|
+
|
|
181
|
+
bt_run QaPoints '[3]' > "$CAPS/points.txt" # name|x|y|z|size of the largest merges (LOD clusters first)
|
|
182
|
+
while IFS='|' read -r name x y z size; do
|
|
183
|
+
[ -z "$name" ] && continue
|
|
184
|
+
dist=$(python3 -c "print(max(4.0, float('$size') * 1.5))")
|
|
185
|
+
for lod in 0 1; do
|
|
186
|
+
for which in source combined; do
|
|
187
|
+
scene=$([ "$which" = source ] && echo "$SOURCE" || echo "$OUT")
|
|
188
|
+
bt_run QaView "[\"$scene\",$x,$y,$z,$dist,$lod]" >/dev/null && cap "$CAPS/unity_${name}_lod${lod}_${which}.png"
|
|
189
|
+
done
|
|
190
|
+
done
|
|
191
|
+
done < "$CAPS/points.txt"
|
|
192
|
+
unity command open_scene --path "$OUT" --project-path "$PROJ" # QaView never saves; reopening discards the QA camera
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Open every source/combined pair and compare: material, moss/detail, baked shadows and brightness must match. A merged object that is darker, black or blotchy **only at LOD1** is a lower-LOD lightmap problem; one that is wrong at LOD0 is a probe or lightmap problem — exclude that merge (Phase 6 loop) and report it.
|
|
196
|
+
|
|
197
|
+
## Phase 5 — Export and numbers (skip only with --no-export)
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
unity command bt_export_level --scene "$OUT" --project-path "$PROJ" --timeout 3600
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The source's export must exist for comparison: find `<exportRoot>/scenes/<source name>.gltf` (`bt_status` → `exportRoot`; the project may lower-case file names). If it is missing or older than the source scene file, export the source too (`bt_export_level --scene "$SOURCE"`). Record both export durations.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
mkdir -p "$PROJ/_combine/.qa-tools" && cp "$SKILL_DIR"/scripts/qa/* "$PROJ/_combine/.qa-tools/"
|
|
207
|
+
(cd "$PROJ/_combine/.qa-tools" && npm install --silent) # puppeteer-core, kept out of the Unity project's package.json
|
|
208
|
+
node "$PROJ/_combine/.qa-tools/gltf-stats.mjs" <source.gltf> <combined.gltf>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Phase 6 — Browser comparison (skip only with --no-browser)
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
unity command bt_devserver_start --project-path "$PROJ" # rerun after any domain reload — it stops the server
|
|
215
|
+
node "$PROJ/_combine/.qa-tools/compare-browser.mjs" --base http://localhost:<port> \
|
|
216
|
+
--scenes <source>.gltf,<combined>.gltf --times 10,15,20,30 --out "$PROJ/_combine/$NAME/captures"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Use the harness's own browser tool instead when it has one and it works. The script prints `{ sheet, results }`: open **`sheet.png`** first — one row per moment, one column per scene — then the full-size frames you need. Load time and console errors are in `results` (both scenes must be error-free).
|
|
220
|
+
|
|
221
|
+
Flythroughs start when the scene is ready, so **the two runs are usually offset by a few seconds** (on a 900-piece garden the combined scene ran 5–10 s ahead of the original — it finished loading sooner). Pair frames by matching view, not by timestamp: find the same view in both columns, note the offset, and compare those pairs at full size. Report the offset as a load-time observation (headless, single run). Capture enough moments (`--times 20,25,…,90`) to cover the offset.
|
|
222
|
+
|
|
223
|
+
**Regression loop (at most 3 rounds).** If a region looks different (darker, flatter, wrong reflections, LOD popping):
|
|
224
|
+
|
|
225
|
+
1. Identify the merge: match the region against `manifest.json` (`combinedPaths`, `sources`, `containers`, probe names).
|
|
226
|
+
2. Add its sources' container or names to `exclude`, say why in one line, then `PrepareCopy … true` (reset), Analyze, Apply, Bake, Verify, export, compare again.
|
|
227
|
+
3. If it is still different without that merge, the cause is not merging — compare against a re-baked **uncombined** copy (PrepareCopy to `<Scene>_Control.unity`, bake, export, capture; delete it afterwards with `RemoveCopy`). A difference that the control also shows is the re-bake (often a stale source bake), not this skill — report it as such.
|
|
228
|
+
|
|
229
|
+
## Phase 7 — Report
|
|
230
|
+
|
|
231
|
+
Reply in plain language, with images. Put this structure in the reply and in `_combine/$NAME/report.md`:
|
|
232
|
+
|
|
233
|
+
- **Result:** working copy path; meshes, drawn mesh nodes, primitives, drawn vertices and export size before → after (`gltf-stats`); export time before → after; draw calls estimated before → after.
|
|
234
|
+
- **What merged:** static merges and LOD clusters, the biggest ones by name.
|
|
235
|
+
- **What stayed separate and why:** the top reasons with counts, and which ones the user can unlock (mark static, opt into Shader Graphs, fix mirrored prefabs…).
|
|
236
|
+
- **Checks:** Verify result, Unity captures, browser frames with load time and console errors; anything skipped or unverified, stated as such.
|
|
237
|
+
- **How to undo or redo:** `--reset`, or delete the working copy and `<SceneName>_CombinedMeshes/`.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
# Files this skill writes
|
|
242
|
+
|
|
243
|
+
| Path | What |
|
|
244
|
+
|---|---|
|
|
245
|
+
| `<out scene>` | the working copy (combined) |
|
|
246
|
+
| `<out scene folder>/<OutName>_CombinedMeshes/*.asset` | merged meshes |
|
|
247
|
+
| `<out scene folder>/<OutName>/` | the copy's baked lighting |
|
|
248
|
+
| `_combine/<OutName>/analysis.md`, `analysis.json` | the plan and every reason |
|
|
249
|
+
| `_combine/<OutName>/manifest.json`, `verify.md`, `report.md`, `captures/` | what was done and how it was checked |
|
|
250
|
+
| `AgentScripts/bt-combine/BtCombine.cs`, `_combine/.qa-tools/` | the engine and the QA tools (outside `Assets/`, no recompiles) |
|
|
251
|
+
|
|
252
|
+
# Troubleshooting
|
|
253
|
+
|
|
254
|
+
| Symptom | Fix |
|
|
255
|
+
|---|---|
|
|
256
|
+
| `FAILED: … Compilation Failed` from `bt_run` | Read the diagnostics; the toolkit DLL may be older than this skill (`UnityMeshSimplifier.MeshCombiner`, `UnityTools.GetMaxSimultaneousLights` must exist) |
|
|
257
|
+
| Apply: "no Pack Source Lightmap UVs mode" | Update the Babylon Toolkit (`CanvasTools.dll`); never accept bloat silently |
|
|
258
|
+
| Apply: "already combined" | `--reset`, or continue from Phase 3 |
|
|
259
|
+
| Bake never completes | Check `console --level error`; GPU lightmapper may fall back to CPU and take much longer — raise the deadline |
|
|
260
|
+
| Export refuses: unsaved changes | `unity command save_all` after the bake |
|
|
261
|
+
| Browser: connection refused | The dev server stops on every domain reload — `bt_devserver_start` again |
|
|
262
|
+
| Merged area darker in the browser only | Probe or light choice: lower `--spread` / `--cell`, or `--exclude` that container; then the control test above |
|