Bake stub atlas-sets for demo_tilemap and walls_tilemap
Replaces the legacy color-only *.tilemap.json fixtures with baked
2-tile atlas-sets in the new atlases/<id>/{diffuse,height,atlas-json,
lock-json} layout. Stub PNGs are 32x32 solid colors matching the
previous color values; height channel is synthesized L8=0 by the baker.
A scripts/bake.sh re-bake helper drives the atlas-baker tool against
assets/_sources/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
21
assets/_sources/_gen.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const { PNG } = require('pngjs');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
function writeSolidRGBA(p, w, h, rgba) {
|
||||||
|
const png = new PNG({ width: w, height: h });
|
||||||
|
for (let i = 0; i < png.data.length; i += 4) {
|
||||||
|
png.data[i + 0] = rgba[0];
|
||||||
|
png.data[i + 1] = rgba[1];
|
||||||
|
png.data[i + 2] = rgba[2];
|
||||||
|
png.data[i + 3] = rgba[3];
|
||||||
|
}
|
||||||
|
fs.writeFileSync(p, PNG.sync.write(png));
|
||||||
|
}
|
||||||
|
|
||||||
|
const SOURCES = path.resolve(__dirname);
|
||||||
|
writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'grass_diffuse.png'), 32, 32, [110, 170, 80, 255]);
|
||||||
|
writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'stone_diffuse.png'), 32, 32, [120, 120, 120, 255]);
|
||||||
|
writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_brick_diffuse.png'), 32, 32, [180, 100, 80, 255]);
|
||||||
|
writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_wood_diffuse.png'), 32, 32, [140, 90, 50, 255]);
|
||||||
|
console.log('test-stub sources generated');
|
||||||
BIN
assets/_sources/demo_tilemap/grass_diffuse.png
Normal file
|
After Width: | Height: | Size: 128 B |
BIN
assets/_sources/demo_tilemap/stone_diffuse.png
Normal file
|
After Width: | Height: | Size: 125 B |
BIN
assets/_sources/walls_tilemap/wall_brick_diffuse.png
Normal file
|
After Width: | Height: | Size: 128 B |
BIN
assets/_sources/walls_tilemap/wall_wood_diffuse.png
Normal file
|
After Width: | Height: | Size: 128 B |
31
assets/atlases/demo_tilemap/tiles.atlas.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"atlas_id": "demo_tilemap",
|
||||||
|
"atlas_version": 1,
|
||||||
|
"atlas_size_px": [
|
||||||
|
64,
|
||||||
|
64
|
||||||
|
],
|
||||||
|
"tile_size_px": 32,
|
||||||
|
"tiles": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "grass",
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
32,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "stone",
|
||||||
|
"uv": [
|
||||||
|
32,
|
||||||
|
0,
|
||||||
|
32,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
9
assets/atlases/demo_tilemap/tiles.atlas.lock.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"atlas_id": "demo_tilemap",
|
||||||
|
"bindings": {
|
||||||
|
"grass": 1,
|
||||||
|
"stone": 2
|
||||||
|
},
|
||||||
|
"deleted": [],
|
||||||
|
"next_id": 3
|
||||||
|
}
|
||||||
BIN
assets/atlases/demo_tilemap/tiles.diffuse.atlas.png
Normal file
|
After Width: | Height: | Size: 162 B |
BIN
assets/atlases/demo_tilemap/tiles.height.atlas.png
Normal file
|
After Width: | Height: | Size: 176 B |
33
assets/atlases/walls_tilemap/tiles.atlas.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"atlas_id": "walls_tilemap",
|
||||||
|
"atlas_version": 1,
|
||||||
|
"atlas_size_px": [
|
||||||
|
64,
|
||||||
|
64
|
||||||
|
],
|
||||||
|
"tile_size_px": 32,
|
||||||
|
"tiles": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "wall_brick",
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
32,
|
||||||
|
32
|
||||||
|
],
|
||||||
|
"blocks_sight": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "wall_wood",
|
||||||
|
"uv": [
|
||||||
|
32,
|
||||||
|
0,
|
||||||
|
32,
|
||||||
|
32
|
||||||
|
],
|
||||||
|
"blocks_sight": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
9
assets/atlases/walls_tilemap/tiles.atlas.lock.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"atlas_id": "walls_tilemap",
|
||||||
|
"bindings": {
|
||||||
|
"wall_brick": 1,
|
||||||
|
"wall_wood": 2
|
||||||
|
},
|
||||||
|
"deleted": [],
|
||||||
|
"next_id": 3
|
||||||
|
}
|
||||||
BIN
assets/atlases/walls_tilemap/tiles.diffuse.atlas.png
Normal file
|
After Width: | Height: | Size: 161 B |
BIN
assets/atlases/walls_tilemap/tiles.height.atlas.png
Normal file
|
After Width: | Height: | Size: 176 B |
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "demo_tilemap",
|
|
||||||
"tile_size": 32,
|
|
||||||
"tiles": [
|
|
||||||
{"id": "grass", "walkable": true, "color": [110, 170, 80]},
|
|
||||||
{"id": "stone", "walkable": false, "color": [120, 120, 120]}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "walls_tilemap",
|
|
||||||
"tile_size": 32,
|
|
||||||
"tiles": [
|
|
||||||
{"id": "wall_brick", "walkable": false, "color": [180, 100, 80]},
|
|
||||||
{"id": "wall_wood", "walkable": false, "color": [140, 90, 50]}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
19
scripts/bake.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Re-bake the stub atlases used by maps-test fixtures.
|
||||||
|
set -euo pipefail
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
LIB_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
BAKER=~/Projects/Sporel/sporel-tool-atlas-baker/bin/atlas-baker.js
|
||||||
|
|
||||||
|
node "$BAKER" \
|
||||||
|
--in "$LIB_DIR/assets/_sources/demo_tilemap" \
|
||||||
|
--out "$LIB_DIR/assets/atlases/demo_tilemap" \
|
||||||
|
--atlas-id demo_tilemap \
|
||||||
|
--tile-size 32
|
||||||
|
|
||||||
|
node "$BAKER" \
|
||||||
|
--in "$LIB_DIR/assets/_sources/walls_tilemap" \
|
||||||
|
--out "$LIB_DIR/assets/atlases/walls_tilemap" \
|
||||||
|
--atlas-id walls_tilemap \
|
||||||
|
--tile-size 32 \
|
||||||
|
--blocks-sight-pattern '^wall_'
|
||||||