pixelkiln 0.53.0 → 0.53.1

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/cli.js CHANGED
@@ -15596,6 +15596,25 @@ function normalizeTileRules(raw) {
15596
15596
  raw
15597
15597
  };
15598
15598
  }
15599
+ function normalizeTerrainTiles(metadata) {
15600
+ if (!isRecord2(metadata) || !Array.isArray(metadata.terrainTiles)) return null;
15601
+ const terrains = Array.isArray(metadata.terrainTypes) ? metadata.terrainTypes.filter((item) => typeof item === "string") : [];
15602
+ if (terrains.length < 2) return null;
15603
+ const masks = {};
15604
+ metadata.terrainTiles.forEach((tile, index) => {
15605
+ if (!isRecord2(tile) || !isRecord2(tile.corners)) return;
15606
+ const corners = tile.corners;
15607
+ const bit = (corner) => corners[corner] === terrains[0] ? 1 : 0;
15608
+ masks[index] = bit("NW") << 3 | bit("NE") << 2 | bit("SW") << 1 | bit("SE");
15609
+ });
15610
+ return {
15611
+ ruleType: "corner",
15612
+ arity: 4,
15613
+ terrains,
15614
+ masks,
15615
+ raw: metadata
15616
+ };
15617
+ }
15599
15618
  function exportTileset(entry, spec, options) {
15600
15619
  let outputs = resolveSpecEntryOutputs(entry, spec);
15601
15620
  if (!outputs.length) throw new Error(`${spec.styleId}/${spec.assetId} has no downloaded outputs`);
@@ -15616,14 +15635,16 @@ function exportTileset(entry, spec, options) {
15616
15635
  }
15617
15636
  const metadata = entry.providerMetadata?.[entry.provider];
15618
15637
  const rawRules = isRecord2(metadata) ? metadata.tileRules : void 0;
15619
- const rules = normalizeTileRules(rawRules);
15638
+ const terrainRules = normalizeTerrainTiles(metadata);
15639
+ const rules = normalizeTileRules(rawRules) ?? terrainRules;
15640
+ const providerRules = isRecord2(rawRules) ? rawRules : terrainRules ? metadata : null;
15620
15641
  const frames = packed.atlas.frames;
15621
15642
  const generic = buildGeneric(
15622
15643
  spec,
15623
15644
  options.imageName,
15624
15645
  packed.atlas,
15625
15646
  frames,
15626
- isRecord2(rawRules) ? rawRules : null,
15647
+ providerRules,
15627
15648
  rules
15628
15649
  );
15629
15650
  if (options.format === "generic") {
@@ -15636,7 +15657,7 @@ function exportTileset(entry, spec, options) {
15636
15657
  };
15637
15658
  }
15638
15659
  assertUniformTiles(generic);
15639
- if ((rawRules !== void 0 || entry.tileFeature) && !rules) {
15660
+ if ((rawRules !== void 0 || entry.tileFeature || entry.generator === "terrain") && !rules) {
15640
15661
  throw new Error(
15641
15662
  `${options.format} export needs recognized adjacency rules; use --format generic to retain this provider rule object without guessing`
15642
15663
  );