pixelkiln 0.97.0 → 0.99.0
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 +1 -1
- package/dist/cli.js +312 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +281 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1094 -50
- package/dist/index.d.ts +1094 -50
- package/dist/index.js +277 -11
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +27 -4
- package/docs/ENDPOINTS.md +82 -3
- package/docs/GENERATORS.md +2 -2
- package/docs/MANIFEST.md +7 -0
- package/docs/PIXELLAB.md +2 -2
- package/docs/REVISIONS.md +9 -1
- package/docs/TILES.md +29 -0
- package/package.json +1 -1
- package/schema/manifest.schema.json +119 -0
- package/schema/recipe.schema.json +29 -0
- package/skills/pixelkiln/references/pixellab.md +1 -1
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ function terrainTileCount(transitionSize, mode2, orientation) {
|
|
|
98
98
|
return transitionSize === 1 ? 25 : 16;
|
|
99
99
|
}
|
|
100
100
|
function terrainCost(mode2, tileSize, orientation) {
|
|
101
|
-
if (orientation === "sidescroller") return
|
|
101
|
+
if (orientation === "sidescroller") return mode2 === "pro" ? 15 : 1;
|
|
102
102
|
if (mode2 === "pro") return tileSize <= 32 ? 15 : 25;
|
|
103
103
|
return 4;
|
|
104
104
|
}
|
|
@@ -524,6 +524,24 @@ var RevisionSchema = z.object({
|
|
|
524
524
|
removalTask: z.enum(["simple", "complex"]).optional(),
|
|
525
525
|
/** `normal-map` only: `opengl` (green up; PixelLab's default) or `directx` (green down, for Unreal). */
|
|
526
526
|
convention: NormalMapConventionSchema.optional(),
|
|
527
|
+
/**
|
|
528
|
+
* `normal-map` only: `lite` (PixelLab's default, 0.1 generation) makes the
|
|
529
|
+
* map from the art alone; `pro` (0.5) plans each part's shape, what is in
|
|
530
|
+
* front and what is sunk.
|
|
531
|
+
*/
|
|
532
|
+
normalMapMode: z.enum(["lite", "pro"]).optional(),
|
|
533
|
+
/** `normal-map` only: what the picture is. Left out, PixelLab reads it from the picture; set it for sidescroller, isometric and UI art. */
|
|
534
|
+
normalMapKind: z.enum(["character", "object", "topdown", "side", "iso", "ui"]).optional(),
|
|
535
|
+
/** `normal-map` only: how far every pixel tilts away from facing the viewer, 0 to 2 (the API refuses more). */
|
|
536
|
+
normalMapStrength: z.number().min(0).max(2).optional(),
|
|
537
|
+
/** `normal-map` only: how much the outline rounds off, 0 to 3; 0 keeps it flat to the edge. */
|
|
538
|
+
outlineRounding: z.number().min(0).max(3).optional(),
|
|
539
|
+
/** `normal-map` only: how much the sprite's 3D parts (a round head, an arm) add, 0 to 2. */
|
|
540
|
+
partShapes: z.number().min(0).max(2).optional(),
|
|
541
|
+
/** `normal-map` only: the art's own light and dark as bumps, 0 to 2; 0 for a smooth surface. */
|
|
542
|
+
surfaceDetail: z.number().min(0).max(2).optional(),
|
|
543
|
+
/** `normal-map` only: how far that detail is blurred, 0.6 to 3 px. */
|
|
544
|
+
detailSoftness: z.number().min(0.6).max(3).optional(),
|
|
527
545
|
/**
|
|
528
546
|
* `animate-skeleton`: what the character *looks like*, a noun
|
|
529
547
|
* phrase (colours, clothing, held items) — distinct from the asset's
|
|
@@ -684,6 +702,15 @@ var RevisionSchema = z.object({
|
|
|
684
702
|
path: ["convention"]
|
|
685
703
|
});
|
|
686
704
|
}
|
|
705
|
+
for (const field of ["normalMapMode", "normalMapKind", "normalMapStrength", "outlineRounding", "partShapes", "surfaceDetail", "detailSoftness"]) {
|
|
706
|
+
if (revision[field] !== void 0 && revision.mode !== "normal-map") {
|
|
707
|
+
context.addIssue({
|
|
708
|
+
code: z.ZodIssueCode.custom,
|
|
709
|
+
message: `${field} applies to normal-map revisions only`,
|
|
710
|
+
path: [field]
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
687
714
|
if (revision.description !== void 0 && revision.mode !== "animate-skeleton" && revision.mode !== "remove-background") {
|
|
688
715
|
context.addIssue({
|
|
689
716
|
code: z.ZodIssueCode.custom,
|
|
@@ -886,6 +913,48 @@ var StyleObjectSchema = z.object({
|
|
|
886
913
|
* lower terrain between them.
|
|
887
914
|
*/
|
|
888
915
|
terrainConnectDiagonals: z.boolean().optional(),
|
|
916
|
+
/**
|
|
917
|
+
* `terrain` generator only, standard mode, top-down. Which ragged border
|
|
918
|
+
* `terrainRaggedness` draws, 0 to 99 (the website's Reshuffle): another
|
|
919
|
+
* number gives a different boundary at the same raggedness. API default 0.
|
|
920
|
+
*/
|
|
921
|
+
terrainShapeSeed: z.number().int().min(0).max(99).optional(),
|
|
922
|
+
/**
|
|
923
|
+
* `terrain` generator only, standard mode, top-down, with
|
|
924
|
+
* `terrainTransitionSize` above 0. How thick the wall reads on the top
|
|
925
|
+
* rim and down both sides of the front face, 0 to 1. The website starts
|
|
926
|
+
* at 0.1.
|
|
927
|
+
*/
|
|
928
|
+
terrainSideWallThickness: z.number().min(0).max(1).optional(),
|
|
929
|
+
/**
|
|
930
|
+
* `terrain` generator only, standard mode, top-down, with
|
|
931
|
+
* `terrainTransitionSize` above 0. Which side of the border the wall sits
|
|
932
|
+
* on: 0 sticks out past the terrain (the API default), 1 is carved into
|
|
933
|
+
* it so the shape stays put. The website starts at 0.5.
|
|
934
|
+
*/
|
|
935
|
+
terrainSideWallPlacement: z.number().min(0).max(1).optional(),
|
|
936
|
+
/**
|
|
937
|
+
* `terrain` generator only, standard mode. PixelLab rewrites the terrain
|
|
938
|
+
* descriptions and picks base colors before drawing unless this is
|
|
939
|
+
* false. On by default upstream; set false to have your wording used as
|
|
940
|
+
* written.
|
|
941
|
+
*/
|
|
942
|
+
terrainEnhance: z.boolean().optional(),
|
|
943
|
+
/**
|
|
944
|
+
* `terrain` generator only, a standard sidescroller set. How thick the
|
|
945
|
+
* platform body is, 0 thin to 1 thick. Left out, PixelLab fits it to
|
|
946
|
+
* `terrainTransitionSize`.
|
|
947
|
+
*/
|
|
948
|
+
terrainPlatformThickness: z.number().min(0).max(1).optional(),
|
|
949
|
+
/**
|
|
950
|
+
* `terrain` generator only, top-down. Whether each terrain can be walked
|
|
951
|
+
* on, stored with the set for PixelLab's maps and engine exports (left
|
|
952
|
+
* out, those guess from the terrain's name). They change no pixel, so
|
|
953
|
+
* they are sent when the set is generated and are not part of its
|
|
954
|
+
* identity: changing one later does not make the set stale.
|
|
955
|
+
*/
|
|
956
|
+
terrainLowerWalkable: z.boolean().optional(),
|
|
957
|
+
terrainUpperWalkable: z.boolean().optional(),
|
|
889
958
|
/**
|
|
890
959
|
* `terrain` generator only. Visual height of the step between lower and
|
|
891
960
|
* upper terrain. Without `terrainShapeStyle`, only 0, 0.25, 0.5, or 1 are
|
|
@@ -1278,6 +1347,18 @@ var AssetSchema = z.object({
|
|
|
1278
1347
|
* (a sword hand, a parted fringe) comes out the other way round.
|
|
1279
1348
|
*/
|
|
1280
1349
|
mirror: z.string().min(1).optional(),
|
|
1350
|
+
/**
|
|
1351
|
+
* `terrain` styles only: a PNG per terrain for PixelLab to take that
|
|
1352
|
+
* terrain's look from, paths relative to the manifest. Top-down sets
|
|
1353
|
+
* take `lower`, `upper` and `transition`. A sidescroller set takes
|
|
1354
|
+
* `lower` (the platform body, pro mode) or `transition` (the surface
|
|
1355
|
+
* layer, standard mode), each a square PNG of the tile size.
|
|
1356
|
+
*/
|
|
1357
|
+
terrainReferences: z.object({
|
|
1358
|
+
lower: z.string().min(1).optional(),
|
|
1359
|
+
upper: z.string().min(1).optional(),
|
|
1360
|
+
transition: z.string().min(1).optional()
|
|
1361
|
+
}).strict().optional(),
|
|
1281
1362
|
/** Made from existing pixels by a local transform; see AssetDeriveSchema. Free; the provider is never called. */
|
|
1282
1363
|
derive: AssetDeriveSchema.optional(),
|
|
1283
1364
|
/** Built by a tool outside pixelkiln; see AssetExternalSchema. Never generated. */
|
|
@@ -2301,7 +2382,12 @@ function refusalReason(status, body) {
|
|
|
2301
2382
|
if (status < 400 || status >= 500 || !body.startsWith("{")) return "";
|
|
2302
2383
|
try {
|
|
2303
2384
|
const detail = JSON.parse(body).detail;
|
|
2304
|
-
|
|
2385
|
+
if (typeof detail === "string" && detail) return `: ${detail.slice(0, 400)}`;
|
|
2386
|
+
if (Array.isArray(detail)) {
|
|
2387
|
+
const messages = detail.map((item) => item && typeof item === "object" && typeof item.msg === "string" ? item.msg : "").filter(Boolean).map((msg) => msg.replace(/^Value error, /, ""));
|
|
2388
|
+
if (messages.length) return `: ${messages.join("; ").slice(0, 400)}`;
|
|
2389
|
+
}
|
|
2390
|
+
return "";
|
|
2305
2391
|
} catch {
|
|
2306
2392
|
return "";
|
|
2307
2393
|
}
|
|
@@ -2335,6 +2421,14 @@ function targetPaletteBody(palette) {
|
|
|
2335
2421
|
}
|
|
2336
2422
|
};
|
|
2337
2423
|
}
|
|
2424
|
+
var NORMAL_MAP_MODES = ["lite", "pro"];
|
|
2425
|
+
var NORMAL_MAP_KINDS = ["character", "object", "topdown", "side", "iso", "ui"];
|
|
2426
|
+
var NORMAL_MAP_SHAPE_RANGES = {
|
|
2427
|
+
outlineRounding: [0, 3],
|
|
2428
|
+
partShapes: [0, 2],
|
|
2429
|
+
surfaceDetail: [0, 2],
|
|
2430
|
+
detailSoftness: [0.6, 3]
|
|
2431
|
+
};
|
|
2338
2432
|
var PixelLabClient = class {
|
|
2339
2433
|
constructor(apiKey, timeoutMs = 12e4) {
|
|
2340
2434
|
this.apiKey = apiKey;
|
|
@@ -2503,6 +2597,16 @@ var PixelLabClient = class {
|
|
|
2503
2597
|
lower_description: args.lowerDescription,
|
|
2504
2598
|
upper_description: args.upperDescription
|
|
2505
2599
|
};
|
|
2600
|
+
const image = (value) => ({ type: "base64", base64: value.base64, format: value.format });
|
|
2601
|
+
if (args.shapeSeed != null) body.shape_seed = args.shapeSeed;
|
|
2602
|
+
if (args.sideWallThickness != null) body.side_wall_thickness = args.sideWallThickness;
|
|
2603
|
+
if (args.sideWallPlacement != null) body.side_wall_placement = args.sideWallPlacement;
|
|
2604
|
+
if (args.enhance != null) body.enhance = args.enhance;
|
|
2605
|
+
if (args.lowerWalkable != null) body.lower_walkable = args.lowerWalkable;
|
|
2606
|
+
if (args.upperWalkable != null) body.upper_walkable = args.upperWalkable;
|
|
2607
|
+
if (args.lowerReferenceImage) body.lower_reference_image = image(args.lowerReferenceImage);
|
|
2608
|
+
if (args.upperReferenceImage) body.upper_reference_image = image(args.upperReferenceImage);
|
|
2609
|
+
if (args.transitionReferenceImage) body.transition_reference_image = image(args.transitionReferenceImage);
|
|
2506
2610
|
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
2507
2611
|
if (args.lowerBaseTileId) body.lower_base_tile_id = args.lowerBaseTileId;
|
|
2508
2612
|
if (args.upperBaseTileId) body.upper_base_tile_id = args.upperBaseTileId;
|
|
@@ -2540,6 +2644,12 @@ var PixelLabClient = class {
|
|
|
2540
2644
|
*/
|
|
2541
2645
|
async createTilesetSidescroller(args) {
|
|
2542
2646
|
const body = { lower_description: args.lowerDescription };
|
|
2647
|
+
const image = (value) => ({ type: "base64", base64: value.base64, format: value.format });
|
|
2648
|
+
if (args.mode) body.mode = args.mode;
|
|
2649
|
+
if (args.enhance != null) body.enhance = args.enhance;
|
|
2650
|
+
if (args.platformThickness != null) body.platform_thickness = args.platformThickness;
|
|
2651
|
+
if (args.transitionReferenceImage) body.transition_reference_image = image(args.transitionReferenceImage);
|
|
2652
|
+
if (args.lowerReferenceImage) body.lower_reference_image = image(args.lowerReferenceImage);
|
|
2543
2653
|
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
2544
2654
|
if (args.lowerBaseTileId) body.lower_base_tile_id = args.lowerBaseTileId;
|
|
2545
2655
|
if (args.tileSize != null) body.tile_size = { width: args.tileSize, height: args.tileSize };
|
|
@@ -3397,8 +3507,15 @@ var PixelLabClient = class {
|
|
|
3397
3507
|
*/
|
|
3398
3508
|
async normalMap(args) {
|
|
3399
3509
|
const body = { image: args.image };
|
|
3510
|
+
if (args.mode) body.mode = args.mode;
|
|
3511
|
+
if (args.kind) body.kind = args.kind;
|
|
3512
|
+
if (args.shape?.strength != null) body.strength = args.shape.strength;
|
|
3400
3513
|
if (args.frames != null && args.frames !== 1) body.frames = args.frames;
|
|
3401
3514
|
if (args.convention) body.convention = args.convention;
|
|
3515
|
+
if (args.shape?.outlineRounding != null) body.outline_rounding = args.shape.outlineRounding;
|
|
3516
|
+
if (args.shape?.partShapes != null) body.part_shapes = args.shape.partShapes;
|
|
3517
|
+
if (args.shape?.surfaceDetail != null) body.surface_detail = args.shape.surfaceDetail;
|
|
3518
|
+
if (args.shape?.detailSoftness != null) body.detail_softness = args.shape.detailSoftness;
|
|
3402
3519
|
return validateResponse(
|
|
3403
3520
|
RevisionJobSubmitSchema,
|
|
3404
3521
|
await this.request("/normal-map", { method: "POST", body: JSON.stringify(body) }),
|
|
@@ -4515,6 +4632,21 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4515
4632
|
terrainBoundarySeed: spec.terrainBoundarySeed,
|
|
4516
4633
|
terrainStepSlope: spec.terrainStepSlope,
|
|
4517
4634
|
terrainConnectDiagonals: spec.terrainConnectDiagonals,
|
|
4635
|
+
// Added after the fields above, each only when set, so no terrain entry
|
|
4636
|
+
// written before them changes hash. The walkable flags change no pixel
|
|
4637
|
+
// and are deliberately not here.
|
|
4638
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
4639
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
4640
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
4641
|
+
terrainEnhance: spec.terrainEnhance,
|
|
4642
|
+
terrainPlatformThickness: spec.terrainPlatformThickness,
|
|
4643
|
+
// Reference images enter as their bytes' hashes, never their paths.
|
|
4644
|
+
terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
|
|
4645
|
+
["lower", "upper", "transition"].flatMap((side) => {
|
|
4646
|
+
const reference = spec.terrainReferences[side];
|
|
4647
|
+
return reference ? [[side, reference.sha256]] : [];
|
|
4648
|
+
})
|
|
4649
|
+
) : void 0,
|
|
4518
4650
|
// "top-down" is the default and draws the same set as leaving it out.
|
|
4519
4651
|
terrainOrientation: spec.terrainOrientation === "sidescroller" ? spec.terrainOrientation : void 0,
|
|
4520
4652
|
// Which set and which of its terrains, not that terrain's id: the id
|
|
@@ -4647,6 +4779,14 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4647
4779
|
description: spec.revision.description,
|
|
4648
4780
|
removalTask: spec.revision.removalTask,
|
|
4649
4781
|
convention: spec.revision.convention,
|
|
4782
|
+
// Each only when set, so normal-map revisions made before them keep their hash.
|
|
4783
|
+
normalMapMode: spec.revision.normalMapMode,
|
|
4784
|
+
normalMapKind: spec.revision.normalMapKind,
|
|
4785
|
+
normalMapStrength: spec.revision.normalMapStrength,
|
|
4786
|
+
outlineRounding: spec.revision.outlineRounding,
|
|
4787
|
+
partShapes: spec.revision.partShapes,
|
|
4788
|
+
surfaceDetail: spec.revision.surfaceDetail,
|
|
4789
|
+
detailSoftness: spec.revision.detailSoftness,
|
|
4650
4790
|
driftThreshold: spec.revision.driftThreshold,
|
|
4651
4791
|
subjectDescription: spec.revision.subjectDescription,
|
|
4652
4792
|
initialPose: spec.revision.initialPose,
|
|
@@ -5423,6 +5563,9 @@ async function pixelateFile(client2, input, opts = {}) {
|
|
|
5423
5563
|
await sleep3(interval);
|
|
5424
5564
|
}
|
|
5425
5565
|
}
|
|
5566
|
+
function normalMapCost(mode2) {
|
|
5567
|
+
return mode2 === "pro" ? 0.5 : 0.1;
|
|
5568
|
+
}
|
|
5426
5569
|
var NORMAL_MAP_COST_GENERATIONS = 0.5;
|
|
5427
5570
|
var NORMAL_MAP_MIN_SIDE = 8;
|
|
5428
5571
|
var NORMAL_MAP_MAX_SIDE = 512;
|
|
@@ -5467,7 +5610,10 @@ async function normalMapFile(client2, input, opts = {}) {
|
|
|
5467
5610
|
const submitted = await client2.normalMap({
|
|
5468
5611
|
image: { base64: bytes.toString("base64"), format: "png" },
|
|
5469
5612
|
frames,
|
|
5470
|
-
convention: opts.convention
|
|
5613
|
+
convention: opts.convention,
|
|
5614
|
+
shape: opts.shape,
|
|
5615
|
+
mode: opts.mode,
|
|
5616
|
+
kind: opts.kind
|
|
5471
5617
|
});
|
|
5472
5618
|
const jobId = submitted.background_job_id;
|
|
5473
5619
|
const started = Date.now();
|
|
@@ -5732,7 +5878,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
5732
5878
|
return { unit: "generations", amount: 1, candidates: 1 };
|
|
5733
5879
|
}
|
|
5734
5880
|
if (spec.revision?.mode === "normal-map") {
|
|
5735
|
-
return { unit: "generations", amount:
|
|
5881
|
+
return { unit: "generations", amount: normalMapCost(spec.revision.normalMapMode), candidates: 1 };
|
|
5736
5882
|
}
|
|
5737
5883
|
if (spec.revision?.mode === "reduce-colors" || spec.revision?.mode === "correct-pixelart") {
|
|
5738
5884
|
return { unit: "generations", amount: 0.1, candidates: 1 };
|
|
@@ -6100,6 +6246,23 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6100
6246
|
if (spec.terrainTileSize === 64 && spec.terrainMode !== "pro") {
|
|
6101
6247
|
throw new Error('PixelLab terrain: a 64px tile needs terrainMode: "pro"');
|
|
6102
6248
|
}
|
|
6249
|
+
const standardOnly = {
|
|
6250
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
6251
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
6252
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
6253
|
+
terrainEnhance: spec.terrainEnhance
|
|
6254
|
+
};
|
|
6255
|
+
const proSet = Object.entries(standardOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
6256
|
+
if (pro && proSet.length) {
|
|
6257
|
+
throw new Error(`PixelLab terrain: ${proSet.join(", ")} shape a standard set; terrainMode: "pro" ignores them`);
|
|
6258
|
+
}
|
|
6259
|
+
if ((spec.terrainSideWallThickness != null || spec.terrainSideWallPlacement != null) && !(spec.terrainTransitionSize != null && spec.terrainTransitionSize > 0)) {
|
|
6260
|
+
throw new Error("PixelLab terrain: terrainSideWallThickness and terrainSideWallPlacement shape the wall, which needs a terrainTransitionSize above 0");
|
|
6261
|
+
}
|
|
6262
|
+
if (spec.terrainPlatformThickness != null) {
|
|
6263
|
+
throw new Error("PixelLab terrain: terrainPlatformThickness is a sidescroller control");
|
|
6264
|
+
}
|
|
6265
|
+
this.requireTerrainReferences(spec);
|
|
6103
6266
|
if (spec.terrainShapeStyle && spec.terrainTransitionSize != null && spec.terrainTransitionSize > 0.5) {
|
|
6104
6267
|
throw new Error(
|
|
6105
6268
|
"PixelLab terrain: terrainShapeStyle with terrainTransitionSize above 0.5 uses an extended 32-tile layout pixelkiln does not model; use 0, 0.25, or 0.5"
|
|
@@ -6118,7 +6281,6 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6118
6281
|
*/
|
|
6119
6282
|
validateSidescrollerTerrain(spec) {
|
|
6120
6283
|
const topDownOnly = {
|
|
6121
|
-
terrainMode: spec.terrainMode,
|
|
6122
6284
|
terrainShapeStyle: spec.terrainShapeStyle,
|
|
6123
6285
|
terrainView: spec.terrainView,
|
|
6124
6286
|
terrainSpreadX: spec.terrainSpreadX,
|
|
@@ -6128,7 +6290,12 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6128
6290
|
terrainBoundaryAmplitude: spec.terrainBoundaryAmplitude,
|
|
6129
6291
|
terrainBoundarySeed: spec.terrainBoundarySeed,
|
|
6130
6292
|
terrainStepSlope: spec.terrainStepSlope,
|
|
6131
|
-
terrainConnectDiagonals: spec.terrainConnectDiagonals
|
|
6293
|
+
terrainConnectDiagonals: spec.terrainConnectDiagonals,
|
|
6294
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
6295
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
6296
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
6297
|
+
terrainLowerWalkable: spec.terrainLowerWalkable,
|
|
6298
|
+
terrainUpperWalkable: spec.terrainUpperWalkable
|
|
6132
6299
|
};
|
|
6133
6300
|
const set = Object.entries(topDownOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
6134
6301
|
if (set.length) {
|
|
@@ -6137,9 +6304,26 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6137
6304
|
if (spec.terrainTileSize !== 16 && spec.terrainTileSize !== 32) {
|
|
6138
6305
|
throw new Error(`PixelLab terrain: a sidescroller set's tiles are 16 or 32px, got ${spec.terrainTileSize}`);
|
|
6139
6306
|
}
|
|
6140
|
-
if (spec.terrainTransitionSize != null && ![0, 0.25, 0.5
|
|
6141
|
-
throw new Error("PixelLab terrain: a sidescroller set's terrainTransitionSize must be 0, 0.25, 0.5
|
|
6307
|
+
if (spec.terrainTransitionSize != null && ![0, 0.25, 0.5].includes(spec.terrainTransitionSize)) {
|
|
6308
|
+
throw new Error("PixelLab terrain: a sidescroller set's terrainTransitionSize must be 0, 0.25, or 0.5 (the top layer stops at half a tile)");
|
|
6309
|
+
}
|
|
6310
|
+
const pro = spec.terrainMode === "pro";
|
|
6311
|
+
if (pro && (spec.terrainEnhance != null || spec.terrainPlatformThickness != null)) {
|
|
6312
|
+
throw new Error('PixelLab terrain: terrainEnhance and terrainPlatformThickness shape a standard sidescroller set; terrainMode: "pro" ignores them');
|
|
6142
6313
|
}
|
|
6314
|
+
if (spec.terrainConnect?.lower && !pro) {
|
|
6315
|
+
throw new Error(`PixelLab terrain: a sidescroller set connects to another set's platform only with terrainMode: "pro"`);
|
|
6316
|
+
}
|
|
6317
|
+
if (spec.terrainReferences?.upper) {
|
|
6318
|
+
throw new Error("PixelLab terrain: a sidescroller set's upper terrain is empty air; it takes no upper reference");
|
|
6319
|
+
}
|
|
6320
|
+
if (spec.terrainReferences?.lower && !pro) {
|
|
6321
|
+
throw new Error('PixelLab terrain: a sidescroller set keeps a lower (platform body) reference only with terrainMode: "pro"');
|
|
6322
|
+
}
|
|
6323
|
+
if (spec.terrainReferences?.transition && pro) {
|
|
6324
|
+
throw new Error('PixelLab terrain: a sidescroller set textures its top layer from a transition reference only on standard mode; drop it or terrainMode: "pro"');
|
|
6325
|
+
}
|
|
6326
|
+
this.requireTerrainReferences(spec, spec.terrainTileSize);
|
|
6143
6327
|
if (spec.terrainConnect?.upper) {
|
|
6144
6328
|
throw new Error(
|
|
6145
6329
|
"PixelLab terrain: a sidescroller set's upper terrain is empty air; only its lower (platform) terrain can connect"
|
|
@@ -6152,6 +6336,19 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6152
6336
|
);
|
|
6153
6337
|
}
|
|
6154
6338
|
}
|
|
6339
|
+
/** Reference files must exist; a sidescroller's must be a square PNG of the tile size. */
|
|
6340
|
+
requireTerrainReferences(spec, tileSize) {
|
|
6341
|
+
for (const [side, reference] of Object.entries(spec.terrainReferences ?? {})) {
|
|
6342
|
+
if (!reference?.sha256) {
|
|
6343
|
+
throw new Error(`PixelLab terrain: the ${side} reference is missing or not a PNG: ${reference?.file}`);
|
|
6344
|
+
}
|
|
6345
|
+
if (tileSize != null && (reference.width !== tileSize || reference.height !== tileSize)) {
|
|
6346
|
+
throw new Error(
|
|
6347
|
+
`PixelLab terrain: a sidescroller set's ${side} reference must be a ${tileSize}x${tileSize} PNG; ${reference.file} is ${reference.width}x${reference.height}`
|
|
6348
|
+
);
|
|
6349
|
+
}
|
|
6350
|
+
}
|
|
6351
|
+
}
|
|
6155
6352
|
validateCharacter(spec, styleImages = []) {
|
|
6156
6353
|
const character = spec.character;
|
|
6157
6354
|
if (!character) throw new Error(`${spec.styleId}/${spec.assetId} has no character shape`);
|
|
@@ -6929,7 +7126,12 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6929
7126
|
outline: spec.outline,
|
|
6930
7127
|
shading: spec.shading,
|
|
6931
7128
|
detail: spec.detail,
|
|
6932
|
-
seed: spec.seed
|
|
7129
|
+
seed: spec.seed,
|
|
7130
|
+
mode: spec.terrainMode,
|
|
7131
|
+
enhance: spec.terrainEnhance,
|
|
7132
|
+
platformThickness: spec.terrainPlatformThickness,
|
|
7133
|
+
lowerReferenceImage: await terrainReferenceImage(spec, "lower"),
|
|
7134
|
+
transitionReferenceImage: await terrainReferenceImage(spec, "transition")
|
|
6933
7135
|
});
|
|
6934
7136
|
return {
|
|
6935
7137
|
jobId: res2.tileset_id,
|
|
@@ -6964,7 +7166,16 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6964
7166
|
shading: spec.shading,
|
|
6965
7167
|
detail: spec.detail,
|
|
6966
7168
|
seed: spec.seed,
|
|
6967
|
-
targetPalette: targetPaletteFor(spec)
|
|
7169
|
+
targetPalette: targetPaletteFor(spec),
|
|
7170
|
+
shapeSeed: spec.terrainShapeSeed,
|
|
7171
|
+
sideWallThickness: spec.terrainSideWallThickness,
|
|
7172
|
+
sideWallPlacement: spec.terrainSideWallPlacement,
|
|
7173
|
+
enhance: spec.terrainEnhance,
|
|
7174
|
+
lowerWalkable: spec.terrainLowerWalkable,
|
|
7175
|
+
upperWalkable: spec.terrainUpperWalkable,
|
|
7176
|
+
lowerReferenceImage: await terrainReferenceImage(spec, "lower"),
|
|
7177
|
+
upperReferenceImage: await terrainReferenceImage(spec, "upper"),
|
|
7178
|
+
transitionReferenceImage: await terrainReferenceImage(spec, "transition")
|
|
6968
7179
|
});
|
|
6969
7180
|
return {
|
|
6970
7181
|
jobId: res2.tileset_id,
|
|
@@ -7141,7 +7352,20 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7141
7352
|
}
|
|
7142
7353
|
if (revision.mode === "normal-map") {
|
|
7143
7354
|
const strip = roles ? { base64: joinStripPng(images.map((member) => Buffer.from(member.base64, "base64"))).toString("base64"), format: "png" } : image;
|
|
7144
|
-
const res2 = await this.client.normalMap({
|
|
7355
|
+
const res2 = await this.client.normalMap({
|
|
7356
|
+
image: strip,
|
|
7357
|
+
frames: roles?.length ?? 1,
|
|
7358
|
+
convention: revision.convention,
|
|
7359
|
+
mode: revision.normalMapMode,
|
|
7360
|
+
kind: revision.normalMapKind,
|
|
7361
|
+
shape: {
|
|
7362
|
+
strength: revision.normalMapStrength,
|
|
7363
|
+
outlineRounding: revision.outlineRounding,
|
|
7364
|
+
partShapes: revision.partShapes,
|
|
7365
|
+
surfaceDetail: revision.surfaceDetail,
|
|
7366
|
+
detailSoftness: revision.detailSoftness
|
|
7367
|
+
}
|
|
7368
|
+
});
|
|
7145
7369
|
return {
|
|
7146
7370
|
jobId: res2.background_job_id,
|
|
7147
7371
|
metadata: roles ? { revisionMembers: roles, ...revision.sourceFps != null ? { revisionFps: revision.sourceFps } : {} } : {}
|
|
@@ -8143,6 +8367,16 @@ function sendsTargetPalette(spec) {
|
|
|
8143
8367
|
return false;
|
|
8144
8368
|
}
|
|
8145
8369
|
}
|
|
8370
|
+
async function terrainReferenceImage(spec, side) {
|
|
8371
|
+
const reference = spec.terrainReferences?.[side];
|
|
8372
|
+
if (!reference) return void 0;
|
|
8373
|
+
if (!existsSync3(reference.file)) throw new Error(`terrain ${side} reference is missing: ${reference.file}`);
|
|
8374
|
+
const bytes = readFileSync(reference.file);
|
|
8375
|
+
if (sha256(bytes) !== reference.sha256) {
|
|
8376
|
+
throw new Error(`terrain ${side} reference changed after the manifest was resolved: ${reference.file}; run the command again`);
|
|
8377
|
+
}
|
|
8378
|
+
return { base64: bytes.toString("base64"), format: "png" };
|
|
8379
|
+
}
|
|
8146
8380
|
function targetPaletteFor(spec) {
|
|
8147
8381
|
if (!sendsTargetPalette(spec)) return void 0;
|
|
8148
8382
|
if (!spec.palette.length && spec.maxColors == null) return void 0;
|
|
@@ -11425,6 +11659,13 @@ async function resolveSpecs(loaded, filter) {
|
|
|
11425
11659
|
terrainBoundarySeed: generator === "terrain" ? style.terrainBoundarySeed : void 0,
|
|
11426
11660
|
terrainStepSlope: generator === "terrain" ? style.terrainStepSlope : void 0,
|
|
11427
11661
|
terrainConnectDiagonals: generator === "terrain" ? style.terrainConnectDiagonals : void 0,
|
|
11662
|
+
terrainShapeSeed: generator === "terrain" ? style.terrainShapeSeed : void 0,
|
|
11663
|
+
terrainSideWallThickness: generator === "terrain" ? style.terrainSideWallThickness : void 0,
|
|
11664
|
+
terrainSideWallPlacement: generator === "terrain" ? style.terrainSideWallPlacement : void 0,
|
|
11665
|
+
terrainEnhance: generator === "terrain" ? style.terrainEnhance : void 0,
|
|
11666
|
+
terrainPlatformThickness: generator === "terrain" ? style.terrainPlatformThickness : void 0,
|
|
11667
|
+
terrainLowerWalkable: generator === "terrain" ? style.terrainLowerWalkable : void 0,
|
|
11668
|
+
terrainUpperWalkable: generator === "terrain" ? style.terrainUpperWalkable : void 0,
|
|
11428
11669
|
terrainTransitionSize: generator === "terrain" ? style.terrainTransitionSize : void 0,
|
|
11429
11670
|
terrainView: generator === "terrain" ? style.terrainView : void 0,
|
|
11430
11671
|
terrainOrientation: generator === "terrain" ? style.terrainOrientation : void 0,
|
|
@@ -11783,6 +12024,13 @@ async function resolveSpecs(loaded, filter) {
|
|
|
11783
12024
|
...asset.revision.description ? { description: asset.revision.description } : {},
|
|
11784
12025
|
...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
|
|
11785
12026
|
...asset.revision.convention ? { convention: asset.revision.convention } : {},
|
|
12027
|
+
...asset.revision.normalMapMode ? { normalMapMode: asset.revision.normalMapMode } : {},
|
|
12028
|
+
...asset.revision.normalMapKind ? { normalMapKind: asset.revision.normalMapKind } : {},
|
|
12029
|
+
...asset.revision.normalMapStrength == null ? {} : { normalMapStrength: asset.revision.normalMapStrength },
|
|
12030
|
+
...asset.revision.outlineRounding == null ? {} : { outlineRounding: asset.revision.outlineRounding },
|
|
12031
|
+
...asset.revision.partShapes == null ? {} : { partShapes: asset.revision.partShapes },
|
|
12032
|
+
...asset.revision.surfaceDetail == null ? {} : { surfaceDetail: asset.revision.surfaceDetail },
|
|
12033
|
+
...asset.revision.detailSoftness == null ? {} : { detailSoftness: asset.revision.detailSoftness },
|
|
11786
12034
|
...asset.revision.driftThreshold == null ? {} : { driftThreshold: asset.revision.driftThreshold },
|
|
11787
12035
|
...asset.revision.subjectDescription ? { subjectDescription: asset.revision.subjectDescription } : {},
|
|
11788
12036
|
...asset.revision.initialPose ? { initialPose: asset.revision.initialPose } : {},
|
|
@@ -11857,6 +12105,20 @@ async function resolveSpecs(loaded, filter) {
|
|
|
11857
12105
|
}
|
|
11858
12106
|
resolved.terrainConnect = links;
|
|
11859
12107
|
}
|
|
12108
|
+
if (asset.terrainReferences) {
|
|
12109
|
+
if (resolved.generator !== "terrain") {
|
|
12110
|
+
throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);
|
|
12111
|
+
}
|
|
12112
|
+
const references = {};
|
|
12113
|
+
for (const side of ["lower", "upper", "transition"]) {
|
|
12114
|
+
const relative = asset.terrainReferences[side];
|
|
12115
|
+
if (!relative) continue;
|
|
12116
|
+
const file = path8.resolve(root, relative);
|
|
12117
|
+
const image = await optionalRevisionImage(file, `terrain ${side} reference`, "png");
|
|
12118
|
+
references[side] = { file, sha256: image?.hash ?? null, width: image?.width ?? null, height: image?.height ?? null };
|
|
12119
|
+
}
|
|
12120
|
+
if (Object.keys(references).length) resolved.terrainReferences = references;
|
|
12121
|
+
}
|
|
11860
12122
|
if (asset.scene) resolved.scene = await resolveMapScene(root, styleId, assetId, resolved.generator, asset.scene, activeProvider);
|
|
11861
12123
|
resolved.specHash = specHash(
|
|
11862
12124
|
resolved,
|
|
@@ -22855,9 +23117,12 @@ export {
|
|
|
22855
23117
|
MediaType,
|
|
22856
23118
|
NORMAL_MAP_CONVENTIONS,
|
|
22857
23119
|
NORMAL_MAP_COST_GENERATIONS,
|
|
23120
|
+
NORMAL_MAP_KINDS,
|
|
22858
23121
|
NORMAL_MAP_MAX_FRAMES,
|
|
22859
23122
|
NORMAL_MAP_MAX_SIDE,
|
|
22860
23123
|
NORMAL_MAP_MIN_SIDE,
|
|
23124
|
+
NORMAL_MAP_MODES,
|
|
23125
|
+
NORMAL_MAP_SHAPE_RANGES,
|
|
22861
23126
|
NormalMapConventionSchema,
|
|
22862
23127
|
OverwriteRefusedError,
|
|
22863
23128
|
PIXELATE_COST_GENERATIONS,
|
|
@@ -23025,6 +23290,7 @@ export {
|
|
|
23025
23290
|
mountStyle,
|
|
23026
23291
|
musicCost,
|
|
23027
23292
|
musicOutputPaths,
|
|
23293
|
+
normalMapCost,
|
|
23028
23294
|
normalMapFile,
|
|
23029
23295
|
normalMapResultPng,
|
|
23030
23296
|
normalMapSizeProblem,
|