@babylonjs-toolkit/agent 1.2.16 → 1.2.21

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.
Files changed (70) hide show
  1. package/README.md +3 -2
  2. package/package.json +1 -1
  3. package/skills/bt-blender/SKILL.md +448 -0
  4. package/skills/bt-blender/THIRD_PARTY_NOTICES.md +141 -0
  5. package/skills/bt-blender/references/art-style-and-genre.md +173 -0
  6. package/skills/bt-blender/references/characters-and-creatures.md +644 -0
  7. package/skills/bt-blender/references/environments.md +478 -0
  8. package/skills/bt-blender/references/game-engine-export.md +284 -0
  9. package/skills/bt-blender/references/geometry-nodes.md +447 -0
  10. package/skills/bt-blender/references/hard-surface.md +724 -0
  11. package/skills/bt-blender/references/procedural-generation.md +358 -0
  12. package/skills/bt-blender/references/rigging-and-animation.md +1080 -0
  13. package/skills/bt-blender/references/sculpting-and-retopology.md +544 -0
  14. package/skills/bt-blender/references/uv-and-pbr-materials.md +381 -0
  15. package/skills/bt-blender/references/vehicles.md +637 -0
  16. package/skills/bt-blender/scripts/blender/__pycache__/construction_kit.cpython-313.pyc +0 -0
  17. package/skills/bt-blender/scripts/blender/__pycache__/geometry_nodes_builders.cpython-313.pyc +0 -0
  18. package/skills/bt-blender/scripts/blender/__pycache__/image_measure.cpython-313.pyc +0 -0
  19. package/skills/bt-blender/scripts/blender/__pycache__/reference_traces.cpython-313.pyc +0 -0
  20. package/skills/bt-blender/scripts/blender/assembly_check.py +420 -0
  21. package/skills/bt-blender/scripts/blender/blueprint.py +293 -0
  22. package/skills/bt-blender/scripts/blender/character_blockout.py +462 -0
  23. package/skills/bt-blender/scripts/blender/construction_kit.py +1770 -0
  24. package/skills/bt-blender/scripts/blender/coverage_check.py +221 -0
  25. package/skills/bt-blender/scripts/blender/environment_kit.py +525 -0
  26. package/skills/bt-blender/scripts/blender/evidence_sheet.py +243 -0
  27. package/skills/bt-blender/scripts/blender/export_asset.py +623 -0
  28. package/skills/bt-blender/scripts/blender/geometry_nodes_builders.py +575 -0
  29. package/skills/bt-blender/scripts/blender/hard_surface_panels.py +374 -0
  30. package/skills/bt-blender/scripts/blender/hard_surface_trims.py +200 -0
  31. package/skills/bt-blender/scripts/blender/image_measure.py +917 -0
  32. package/skills/bt-blender/scripts/blender/materials_pbr.py +439 -0
  33. package/skills/bt-blender/scripts/blender/measure_stations.py +496 -0
  34. package/skills/bt-blender/scripts/blender/ortho_views.py +309 -0
  35. package/skills/bt-blender/scripts/blender/overlay_sheet.py +238 -0
  36. package/skills/bt-blender/scripts/blender/procedural_game_ready.py +258 -0
  37. package/skills/bt-blender/scripts/blender/procedural_generators.py +842 -0
  38. package/skills/bt-blender/scripts/blender/qa_check.py +729 -0
  39. package/skills/bt-blender/scripts/blender/reference_traces.py +344 -0
  40. package/skills/bt-blender/scripts/blender/retopology_tools.py +781 -0
  41. package/skills/bt-blender/scripts/blender/review_render.py +358 -0
  42. package/skills/bt-blender/scripts/blender/rigging_tools.py +1170 -0
  43. package/skills/bt-blender/scripts/blender/style_palette.py +190 -0
  44. package/skills/bt-blender/scripts/blender/tool_common.py +289 -0
  45. package/skills/bt-blender/scripts/blender/trace.py +283 -0
  46. package/skills/bt-blender/scripts/blender/uv_layout.py +555 -0
  47. package/skills/bt-blender/scripts/blender/vehicle_parts.py +370 -0
  48. package/skills/bt-blender/scripts/blender/view_consistency.py +133 -0
  49. package/skills/bt-blender/scripts/blender/world_gate.py +231 -0
  50. package/skills/bt-blender/scripts/bt-blender.mjs +333 -0
  51. package/skills/bt-blender/scripts/validate_gltf.mjs +204 -0
  52. package/skills/bt-execute/SKILL.md +2 -1
  53. package/skills/bt-gauntlet/SKILL.md +30 -20
  54. package/skills/bt-gauntlet/references/critic-rubrics.md +106 -7
  55. package/skills/bt-gauntlet/references/loop-templates.md +23 -3
  56. package/skills/bt-gauntlet/references/spec-composition.md +20 -1
  57. package/skills/bt-gauntlet/references/target-images.md +27 -0
  58. package/skills/bt-gauntlet/references/unity-pipeline.md +41 -4
  59. package/skills/bt-gauntlet/references/workspace.md +90 -6
  60. package/skills/bt-unwrap/scripts/blender/__pycache__/bt_unwrap.cpython-313.pyc +0 -0
  61. package/skills/bt-unwrap/scripts/blender/__pycache__/image_utils.cpython-313.pyc +0 -0
  62. package/skills/bt-unwrap/scripts/blender/__pycache__/mesh_tools.cpython-313.pyc +0 -0
  63. package/skills/bt-unwrap/scripts/blender/__pycache__/model_io.cpython-313.pyc +0 -0
  64. package/skills/bt-unwrap/scripts/blender/__pycache__/previews.cpython-313.pyc +0 -0
  65. package/skills/bt-unwrap/scripts/blender/__pycache__/rasterizer.cpython-313.pyc +0 -0
  66. package/skills/bt-unwrap/scripts/blender/__pycache__/reference_views.cpython-313.pyc +0 -0
  67. package/skills/bt-unwrap/scripts/blender/__pycache__/reference_warp.cpython-313.pyc +0 -0
  68. package/skills/bt-unwrap/scripts/blender/__pycache__/texture_bake.cpython-313.pyc +0 -0
  69. package/skills/bt-unwrap/scripts/blender/__pycache__/texture_compose.cpython-313.pyc +0 -0
  70. package/skills/bt-unwrap/scripts/blender/__pycache__/uv_layout.cpython-313.pyc +0 -0
@@ -0,0 +1,243 @@
1
+ """
2
+ Evidence sheets for bt-blender: labelled tiles of several views on one image, region shading and outline
3
+ drawing, area-averaged resizing and a small built-in bitmap font, so a tool can label its pictures without
4
+ Pillow or a GPU.
5
+
6
+ Pure numpy: no bpy import. Image arrays are float RGB(A) in 0..1, row 0 at the top.
7
+ """
8
+ import numpy as np
9
+
10
+ import image_measure
11
+
12
+ # A 5 x 7 bitmap font: '#' is ink. Lower-case text is drawn in capitals; unknown characters as a box.
13
+ GLYPH_WIDTH = 5
14
+ GLYPH_HEIGHT = 7
15
+ GLYPHS = {
16
+ "A": ".###.|#...#|#...#|#####|#...#|#...#|#...#", "B": "####.|#...#|#...#|####.|#...#|#...#|####.",
17
+ "C": ".###.|#...#|#....|#....|#....|#...#|.###.", "D": "####.|#...#|#...#|#...#|#...#|#...#|####.",
18
+ "E": "#####|#....|#....|####.|#....|#....|#####", "F": "#####|#....|#....|####.|#....|#....|#....",
19
+ "G": ".###.|#...#|#....|#.###|#...#|#...#|.####", "H": "#...#|#...#|#...#|#####|#...#|#...#|#...#",
20
+ "I": ".###.|..#..|..#..|..#..|..#..|..#..|.###.", "J": "..###|...#.|...#.|...#.|...#.|#..#.|.##..",
21
+ "K": "#...#|#..#.|#.#..|##...|#.#..|#..#.|#...#", "L": "#....|#....|#....|#....|#....|#....|#####",
22
+ "M": "#...#|##.##|#.#.#|#.#.#|#...#|#...#|#...#", "N": "#...#|##..#|#.#.#|#..##|#...#|#...#|#...#",
23
+ "O": ".###.|#...#|#...#|#...#|#...#|#...#|.###.", "P": "####.|#...#|#...#|####.|#....|#....|#....",
24
+ "Q": ".###.|#...#|#...#|#...#|#.#.#|#..#.|.##.#", "R": "####.|#...#|#...#|####.|#.#..|#..#.|#...#",
25
+ "S": ".####|#....|#....|.###.|....#|....#|####.", "T": "#####|..#..|..#..|..#..|..#..|..#..|..#..",
26
+ "U": "#...#|#...#|#...#|#...#|#...#|#...#|.###.", "V": "#...#|#...#|#...#|#...#|#...#|.#.#.|..#..",
27
+ "W": "#...#|#...#|#...#|#.#.#|#.#.#|#.#.#|.#.#.", "X": "#...#|#...#|.#.#.|..#..|.#.#.|#...#|#...#",
28
+ "Y": "#...#|#...#|.#.#.|..#..|..#..|..#..|..#..", "Z": "#####|....#|...#.|..#..|.#...|#....|#####",
29
+ "0": ".###.|#...#|#..##|#.#.#|##..#|#...#|.###.", "1": "..#..|.##..|..#..|..#..|..#..|..#..|.###.",
30
+ "2": ".###.|#...#|....#|...#.|..#..|.#...|#####", "3": "####.|....#|....#|.###.|....#|....#|####.",
31
+ "4": "...#.|..##.|.#.#.|#..#.|#####|...#.|...#.", "5": "#####|#....|####.|....#|....#|#...#|.###.",
32
+ "6": "..##.|.#...|#....|####.|#...#|#...#|.###.", "7": "#####|....#|...#.|..#..|.#...|.#...|.#...",
33
+ "8": ".###.|#...#|#...#|.###.|#...#|#...#|.###.", "9": ".###.|#...#|#...#|.####|....#|...#.|.##..",
34
+ " ": ".....|.....|.....|.....|.....|.....|.....", ".": ".....|.....|.....|.....|.....|.##..|.##..",
35
+ ",": ".....|.....|.....|.....|.##..|..#..|.#...", ":": ".....|.##..|.##..|.....|.##..|.##..|.....",
36
+ "%": "##..#|##..#|...#.|..#..|.#...|#..##|#..##", "-": ".....|.....|.....|#####|.....|.....|.....",
37
+ "_": ".....|.....|.....|.....|.....|.....|#####", "/": "....#|....#|...#.|..#..|.#...|#....|#....",
38
+ "=": ".....|.....|#####|.....|#####|.....|.....", "(": "...#.|..#..|.#...|.#...|.#...|..#..|...#.",
39
+ ")": ".#...|..#..|...#.|...#.|...#.|..#..|.#...", "+": ".....|..#..|..#..|#####|..#..|..#..|.....",
40
+ "<": "...#.|..#..|.#...|#....|.#...|..#..|...#.", ">": ".#...|..#..|...#.|....#|...#.|..#..|.#...",
41
+ "[": ".###.|.#...|.#...|.#...|.#...|.#...|.###.", "]": ".###.|...#.|...#.|...#.|...#.|...#.|.###.",
42
+ "#": ".#.#.|.#.#.|#####|.#.#.|#####|.#.#.|.#.#.", "*": ".....|#.#.#|.###.|#####|.###.|#.#.#|.....",
43
+ "?": ".###.|#...#|....#|...#.|..#..|.....|..#..", "'": "..#..|..#..|.#...|.....|.....|.....|.....",
44
+ }
45
+ UNKNOWN_GLYPH = "#####|#...#|#...#|#...#|#...#|#...#|#####"
46
+
47
+ # Ink pixels per font pixel, the gap between characters and between lines (font pixels).
48
+ DEFAULT_TEXT_SCALE = 2
49
+ CHARACTER_GAP = 1
50
+ LINE_GAP = 3
51
+
52
+ # Label strip padding (pixels) and colours.
53
+ LABEL_PADDING = 6
54
+ LABEL_BACKGROUND = (0.1, 0.1, 0.12)
55
+ LABEL_TEXT = (0.95, 0.95, 0.95)
56
+ SHEET_BACKGROUND = (0.06, 0.06, 0.07)
57
+ TILE_GAP = 8
58
+
59
+ # Pass / fail label colours.
60
+ PASS_COLOR = (0.35, 0.85, 0.45)
61
+ FAIL_COLOR = (0.95, 0.35, 0.3)
62
+
63
+ # Share of the reference image kept when it is dimmed under evidence drawing.
64
+ DIM_SHARE = 0.55
65
+
66
+
67
+ def _glyph(character: str) -> np.ndarray:
68
+ """A character's ink as a boolean (7, 5) array."""
69
+ rows = GLYPHS.get(character.upper(), UNKNOWN_GLYPH).split("|")
70
+ return np.array([[cell == "#" for cell in row] for row in rows], dtype=bool)
71
+
72
+
73
+ def text_size(text: str, scale: int = DEFAULT_TEXT_SCALE) -> tuple:
74
+ """
75
+ The pixel size a single line of text takes.
76
+
77
+ :param text: The text.
78
+ :param scale: Ink pixels per font pixel.
79
+ :returns: (width, height) in pixels.
80
+ """
81
+ return max(0, len(text) * (GLYPH_WIDTH + CHARACTER_GAP) - CHARACTER_GAP) * scale, GLYPH_HEIGHT * scale
82
+
83
+
84
+ def draw_text(image: np.ndarray, text: str, column: int, row: int, color, scale: int = DEFAULT_TEXT_SCALE) -> None:
85
+ """
86
+ Draws one line of text into an RGB(A) float image in place, clipped to the image.
87
+
88
+ :param image: (height, width, 3 or 4) float array.
89
+ :param text: The text.
90
+ :param column: Left edge of the text, pixels.
91
+ :param row: Top edge of the text, pixels.
92
+ :param color: RGB tuple 0..1.
93
+ :param scale: Ink pixels per font pixel.
94
+ """
95
+ height, width = image.shape[:2]
96
+ for index, character in enumerate(text):
97
+ ink = np.repeat(np.repeat(_glyph(character), scale, axis=0), scale, axis=1)
98
+ left = column + index * (GLYPH_WIDTH + CHARACTER_GAP) * scale
99
+ rows, columns = np.nonzero(ink)
100
+ rows, columns = rows + row, columns + left
101
+ keep = (rows >= 0) & (rows < height) & (columns >= 0) & (columns < width)
102
+ image[rows[keep], columns[keep], :3] = color
103
+
104
+
105
+ def _area_weights(source_size: int, target_size: int) -> np.ndarray:
106
+ """(target, source) matrix that averages the source cells covering each target cell."""
107
+ edges = np.linspace(0.0, source_size, target_size + 1)
108
+ cells = np.arange(source_size)
109
+ overlap = np.clip(np.minimum(edges[1:, None], cells[None, :] + 1.0) - np.maximum(edges[:-1, None], cells[None, :]), 0.0, None)
110
+ return overlap / overlap.sum(axis=1, keepdims=True)
111
+
112
+
113
+ def resize(image: np.ndarray, height: int, width: int) -> np.ndarray:
114
+ """
115
+ Resizes an image or mask by area averaging (no aliasing when shrinking).
116
+
117
+ :param image: (height, width) or (height, width, channels) array.
118
+ :param height: Target height.
119
+ :param width: Target width.
120
+ :returns: float32 array of the target size (same channel count).
121
+ """
122
+ rows = _area_weights(image.shape[0], height)
123
+ columns = _area_weights(image.shape[1], width)
124
+ values = image.astype(np.float32)
125
+ if values.ndim == 2:
126
+ return (rows @ values @ columns.T).astype(np.float32)
127
+ return np.stack([rows @ values[:, :, channel] @ columns.T for channel in range(values.shape[2])], axis=2).astype(np.float32)
128
+
129
+
130
+ def resize_mask(mask: np.ndarray, height: int, width: int) -> np.ndarray:
131
+ """A boolean mask resized by area: a target pixel is set when at least half of what it covers is."""
132
+ return resize(mask, height, width) >= 0.5
133
+
134
+
135
+ def dimmed(rgba: np.ndarray, share: float = DIM_SHARE) -> np.ndarray:
136
+ """The image as grey RGB, pulled towards black, so coloured evidence drawn over it stands out."""
137
+ gray = image_measure.luminance(rgba)[:, :, None]
138
+ return np.repeat(gray * share, 3, axis=2).astype(np.float32)
139
+
140
+
141
+ def tint(image: np.ndarray, mask: np.ndarray, color, strength: float) -> None:
142
+ """
143
+ Blends a colour over the masked pixels in place.
144
+
145
+ :param image: (height, width, 3+) float array.
146
+ :param mask: Boolean (height, width).
147
+ :param color: RGB tuple 0..1.
148
+ :param strength: 0 keeps the image, 1 paints the colour solid.
149
+ """
150
+ image[mask, :3] = image[mask, :3] * (1.0 - strength) + np.array(color, dtype=np.float32) * strength
151
+
152
+
153
+ def draw_mask_outline(image: np.ndarray, mask: np.ndarray, color, thickness: int = 1) -> None:
154
+ """
155
+ Paints the inner edge of a mask (pixels with a neighbour outside it) in place.
156
+
157
+ :param image: (height, width, 3+) float array.
158
+ :param mask: Boolean (height, width).
159
+ :param color: RGB tuple 0..1.
160
+ :param thickness: Edge width in pixels.
161
+ """
162
+ edge = mask & ~image_measure.erode(mask, thickness)
163
+ image[edge, :3] = color
164
+
165
+
166
+ def draw_box(image: np.ndarray, box, color, thickness: int = 1) -> None:
167
+ """
168
+ Draws a rectangle outline in place.
169
+
170
+ :param image: (height, width, 3+) float array.
171
+ :param box: [left, top, right, bottom] in pixels (right / bottom exclusive).
172
+ :param color: RGB tuple 0..1.
173
+ :param thickness: Line thickness in pixels.
174
+ """
175
+ left, top, right, bottom = (float(value) for value in box)
176
+ corners = np.array([[left, top], [right - 1, top], [right - 1, bottom - 1], [left, bottom - 1]])
177
+ image_measure.draw_polyline(image, corners, color, thickness)
178
+
179
+
180
+ def fit_scale(height: int, width: int, tile_size: int) -> float:
181
+ """The factor that makes an image's longer side `tile_size` pixels (never above 1)."""
182
+ return min(1.0, tile_size / float(max(height, width)))
183
+
184
+
185
+ def _label_strip(lines: list, width: int, scale: int) -> np.ndarray:
186
+ """A dark strip holding the label lines; each line is text, or (text, colour)."""
187
+ line_height = (GLYPH_HEIGHT + LINE_GAP) * scale
188
+ strip = np.empty((LABEL_PADDING * 2 + line_height * len(lines), width, 3), dtype=np.float32)
189
+ strip[:] = LABEL_BACKGROUND
190
+ for index, line in enumerate(lines):
191
+ text, color = (line, LABEL_TEXT) if isinstance(line, str) else line
192
+ draw_text(strip, text, LABEL_PADDING, LABEL_PADDING + index * line_height, color, scale)
193
+ return strip
194
+
195
+
196
+ def compose_sheet(tiles: list, columns: int = 0, scale: int = DEFAULT_TEXT_SCALE, title_lines=None) -> np.ndarray:
197
+ """
198
+ Lays labelled tiles out on one sheet, row by row.
199
+
200
+ :param tiles: [(label lines, RGB image)]; a label line is text or (text, RGB colour).
201
+ :param columns: Tiles per row; 0 picks a near-square grid.
202
+ :param scale: Label text scale.
203
+ :param title_lines: Optional lines (a legend) in a strip across the top of the sheet.
204
+ :returns: The sheet, float32 RGB.
205
+ """
206
+ if not tiles:
207
+ raise ValueError("no tiles to lay out")
208
+ columns = columns or int(np.ceil(np.sqrt(len(tiles))))
209
+ labelled = []
210
+ for lines, image in tiles:
211
+ widest = max(text_size(line if isinstance(line, str) else line[0], scale)[0] for line in lines) if lines else 0
212
+ width = max(image.shape[1], widest + 2 * LABEL_PADDING)
213
+ body = np.empty((image.shape[0], width, 3), dtype=np.float32)
214
+ body[:] = SHEET_BACKGROUND
215
+ body[:, :image.shape[1]] = image[:, :, :3]
216
+ labelled.append(np.vstack((_label_strip(lines, width, scale), body)))
217
+ grid = [labelled[start:start + columns] for start in range(0, len(labelled), columns)]
218
+ column_widths = [max(row[index].shape[1] for row in grid if index < len(row)) for index in range(columns)]
219
+ row_heights = [max(tile.shape[0] for tile in row) for row in grid]
220
+ sheet = np.empty((sum(row_heights) + TILE_GAP * (len(grid) + 1),
221
+ sum(column_widths) + TILE_GAP * (columns + 1), 3), dtype=np.float32)
222
+ sheet[:] = SHEET_BACKGROUND
223
+ top = TILE_GAP
224
+ for row, row_height in zip(grid, row_heights):
225
+ left = TILE_GAP
226
+ for index, tile in enumerate(row):
227
+ sheet[top:top + tile.shape[0], left:left + tile.shape[1]] = tile
228
+ left += column_widths[index] + TILE_GAP
229
+ top += row_height + TILE_GAP
230
+ if not title_lines:
231
+ return sheet
232
+ widest = max(text_size(line if isinstance(line, str) else line[0], scale)[0] for line in title_lines)
233
+ if widest + 2 * LABEL_PADDING > sheet.shape[1]:
234
+ widened = np.empty((sheet.shape[0], widest + 2 * LABEL_PADDING, 3), dtype=np.float32)
235
+ widened[:] = SHEET_BACKGROUND
236
+ widened[:, :sheet.shape[1]] = sheet
237
+ sheet = widened
238
+ return np.vstack((_label_strip(title_lines, sheet.shape[1], scale), sheet))
239
+
240
+
241
+ def verdict(passed: bool) -> tuple:
242
+ """A PASS / FAIL label line in its colour."""
243
+ return ("PASS", PASS_COLOR) if passed else ("FAIL", FAIL_COLOR)