pixelkiln 0.53.2 → 0.53.4

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/dist/index.cjs CHANGED
@@ -6407,7 +6407,14 @@ async function resolveSpecs(loaded, filter) {
6407
6407
  noBackground: style.noBackground,
6408
6408
  tileSize: generator === "tiles" ? tileSize : void 0,
6409
6409
  tileHeight: generator === "tiles" ? style.tileHeight : void 0,
6410
- tileType: generator === "tiles" ? style.tileType : void 0,
6410
+ // `/create-tileset` places tiles on a rectangular vertex grid (its own
6411
+ // docs: "a map of W×H cells has (W+1)×(H+1) vertices"), the same
6412
+ // square Wang-tiling math as `square_topdown` tiles-pro, regardless of
6413
+ // `terrainView`'s camera-angle setting. `tileType` otherwise defaults
6414
+ // to undefined and falls through to the exporter's own "isometric"
6415
+ // fallback, which is `tiles`' own real API default, not terrain's —
6416
+ // this is set explicitly so that fallback is never reached for terrain.
6417
+ tileType: generator === "tiles" ? style.tileType : generator === "terrain" ? "square_topdown" : void 0,
6411
6418
  tileView: generator === "tiles" ? style.tileView : void 0,
6412
6419
  tileViewAngle: generator === "tiles" ? style.tileViewAngle : void 0,
6413
6420
  tileDepthRatio: generator === "tiles" ? style.tileDepthRatio : void 0,
@@ -10563,6 +10570,11 @@ function exportTileset(entry, spec, options) {
10563
10570
  `${options.format} export cannot infer adjacency from outline/stamp-only rules; use --format generic`
10564
10571
  );
10565
10572
  }
10573
+ if (options.format === "godot" && rules?.ruleType === "edge" && godotTileShape(spec.tileType ?? "isometric") !== 0) {
10574
+ throw new Error(
10575
+ "godot export does not yet map edge/side adjacency onto an isometric or oblique tile's diagonal peering bits safely; use --format generic or --format tiled"
10576
+ );
10577
+ }
10566
10578
  if (options.format === "tiled") {
10567
10579
  return {
10568
10580
  png: packed.png,
@@ -10651,6 +10663,7 @@ function tiledWangId(rules, mask) {
10651
10663
  }
10652
10664
  function buildGodot(generic, spec) {
10653
10665
  const rules = generic.rules;
10666
+ const shape = godotTileShape(spec.tileType ?? "isometric");
10654
10667
  const lines = [
10655
10668
  `[gd_resource type="TileSet" load_steps=3 format=3]`,
10656
10669
  "",
@@ -10665,7 +10678,7 @@ function buildGodot(generic, spec) {
10665
10678
  const y = Math.floor(tile.id / generic.sheet.columns);
10666
10679
  lines.push(`${x}:${y}/0 = 0`);
10667
10680
  if (!rules || tile.bitmask === void 0 || rules.ruleType === "outline") continue;
10668
- const values = godotTerrainBits(rules, tile.bitmask);
10681
+ const values = godotTerrainBits(rules, tile.bitmask, shape);
10669
10682
  lines.push(`${x}:${y}/0/terrain_set = 0`);
10670
10683
  lines.push(`${x}:${y}/0/terrain = ${dominantTerrain(values)}`);
10671
10684
  for (const [side, value] of Object.entries(values)) {
@@ -10674,7 +10687,6 @@ function buildGodot(generic, spec) {
10674
10687
  }
10675
10688
  lines.push("", "[resource]");
10676
10689
  lines.push(`tile_size = Vector2i(${generic.tile.width}, ${generic.tile.height})`);
10677
- const shape = godotTileShape(spec.tileType ?? "isometric");
10678
10690
  if (shape !== 0) lines.push(`tile_shape = ${shape}`);
10679
10691
  if (rules && rules.ruleType !== "outline") {
10680
10692
  lines.push(`terrain_set_0/mode = ${rules.ruleType === "corner" ? 1 : 2}`);
@@ -10688,9 +10700,17 @@ function buildGodot(generic, spec) {
10688
10700
  lines.push(`sources/0 = SubResource("TileSetAtlasSource_pixelkiln")`, "");
10689
10701
  return lines.join("\n");
10690
10702
  }
10691
- function godotTerrainBits(rules, mask) {
10703
+ function godotTerrainBits(rules, mask, shape) {
10692
10704
  const terrain = (bit) => (mask & 1 << bit) !== 0 ? 0 : 1;
10693
10705
  if (rules.ruleType === "corner") {
10706
+ if (shape === 1) {
10707
+ return {
10708
+ top_corner: terrain(3),
10709
+ right_corner: terrain(2),
10710
+ left_corner: terrain(1),
10711
+ bottom_corner: terrain(0)
10712
+ };
10713
+ }
10694
10714
  return {
10695
10715
  top_left_corner: terrain(3),
10696
10716
  top_right_corner: terrain(2),