@nodecraft/rendermite 1.4.1 → 1.5.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 -0
- package/dist/blocks/cli.js +1 -1
- package/dist/blocks/export.d.ts +1 -1
- package/dist/blocks/export.js +1 -1
- package/dist/blocks/item-sprites.d.ts +34 -0
- package/dist/blocks/item-sprites.js +2 -0
- package/dist/blocks/obj-mesh.js +1 -1
- package/dist/blocks/pack-format.d.ts +2 -2
- package/dist/blocks/sprite-sheet.d.ts +59 -0
- package/dist/blocks/sprite-sheet.js +2 -0
- package/dist/{cli-DqJtT-Ms.js → cli-DMTaIbDI.js} +9 -2
- package/dist/cli.js +3 -3
- package/dist/{discovery-CsZu08re.js → discovery-CD0QqxSF.js} +1 -1
- package/dist/{discovery-C5ZR4aoG.d.ts → discovery-Cmir3QfC.d.ts} +8 -1
- package/dist/{entity-fallback-BTkM8j0V.js → entity-fallback-DutR9Hdz.js} +1 -1
- package/dist/{export-kMoMes_a.js → export-sadR0pWp.js} +90 -160
- package/dist/{export-Bllg8Fw7.d.ts → export-wvt0Fryo.d.ts} +9 -1
- package/dist/{geo-BguldlU-.js → geo-BC8jtG5Q.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/item-sprites-G-yikdfV.js +126 -0
- package/dist/items/discovery.d.ts +2 -2
- package/dist/items/discovery.js +2 -2
- package/dist/mods/prepare.js +1 -1
- package/dist/mods/tints.js +1 -1
- package/dist/{obj-bvs3gwex.js → obj-BaGvPUbb.js} +3 -3
- package/dist/{obj-mesh-rnYbSbpv.js → obj-mesh-CazmV8ya.js} +1 -1
- package/dist/{pack-format-BVC_B-ZW.d.ts → pack-format-oRExIeD3.d.ts} +42 -1
- package/dist/pack.d.ts +1 -1
- package/dist/{pipeline-B8e6x8Hh.js → pipeline-AAfohoHU.js} +7 -7
- package/dist/{prepare-C9gjqQTt.js → prepare-B_tRy9lB.js} +1 -1
- package/dist/render/entity-fallback.js +1 -1
- package/dist/render/face.js +1 -1
- package/dist/render/geo.js +1 -1
- package/dist/render/obj.js +1 -1
- package/dist/render/pipeline.js +1 -1
- package/dist/render/renderer.js +1 -1
- package/dist/{run-B_JAUbXe.js → run-UKgVb-kW.js} +2 -2
- package/dist/run.js +1 -1
- package/dist/sprite-sheet-LQAEtGkp.js +185 -0
- package/dist/workers/render-worker.js +1 -1
- package/package.json +1 -1
- package/dist/{face-CKHboPfh.js → face-CMJ3b3Ae.js} +1 -1
- package/dist/{tints-C1tT6pKk.js → tints-BspVCz2G.js} +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { t as packAtlas } from "./atlas-pack-CoOih7By.js";
|
|
2
1
|
import { i as parseBiomeClimate, n as VANILLA_BIOME_CLIMATES, r as buildBiomeClimates, t as DEFAULT_WATER_COLOR } from "./biomes-5ZwYxMYe.js";
|
|
3
2
|
import { n as ResourceLocator, t as InvalidResourceLocatorError } from "./locator-COMEtEn9.js";
|
|
4
3
|
import { a as parseBlockState, i as matchesCondition, n as collectModels, o as weightedVariantIndex, r as evaluateBlockState, t as BlockStateError } from "./blockstate-eval-BRQ3NWY2.js";
|
|
4
|
+
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-ColsvWrH.js";
|
|
5
|
+
import { i as resolveItem, n as discoverItems, t as ItemResolutionError } from "./discovery-CD0QqxSF.js";
|
|
6
|
+
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-C-NuJaEi.js";
|
|
7
|
+
import { a as resolveTints, i as resolveTint, n as InvalidTinterDefinitionError, r as parseTintValue, t as DYE_COLORS } from "./tints-B3WQcPtx.js";
|
|
5
8
|
import { c as toByteTexture, l as toFloatTexture } from "./blend-KXMclcHk.js";
|
|
6
9
|
import { c as lightsForProfile, r as LightingProfile } from "./lighting--5myudVu.js";
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { a as ItemRenderError, c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "./obj-BaGvPUbb.js";
|
|
11
|
+
import { n as buildObjMesh, t as ObjMeshError } from "./obj-mesh-CazmV8ya.js";
|
|
12
|
+
import { t as packAtlas } from "./atlas-pack-CoOih7By.js";
|
|
10
13
|
import { n as buildBlockTints, t as UNREGISTERED_TINTS } from "./tints-Cl0r-Ol3.js";
|
|
11
14
|
import { o as createAtlasResolver, s as parseAtlasSources, t as AtlasSourceError } from "./sources-BlUriDCs.js";
|
|
12
15
|
import { n as LayeredResourceManager, r as ResourceKind, t as FolderResourceManager } from "./manager-BNibYkmI.js";
|
|
13
16
|
import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-C18GpurU.js";
|
|
14
|
-
import { t as exportBlockPack } from "./export-
|
|
15
|
-
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-ColsvWrH.js";
|
|
17
|
+
import { t as exportBlockPack } from "./export-sadR0pWp.js";
|
|
16
18
|
import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager } from "./jar-W2cV2ZVO.js";
|
|
17
|
-
import { n as prepareModResources } from "./prepare-
|
|
19
|
+
import { n as prepareModResources } from "./prepare-B_tRy9lB.js";
|
|
18
20
|
import { a as prepareVersionResources, i as eraForVersion, r as compareVersions } from "./prepare-8LswFoS-.js";
|
|
19
|
-
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "./discovery-CsZu08re.js";
|
|
20
21
|
import { n as encodeIcon, t as encodeAnimatedIcon } from "./encode-LR9wxigC.js";
|
|
21
22
|
import { a as builtinDynamicResources } from "./generators-BCZVlWig.js";
|
|
22
23
|
import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
|
|
23
24
|
import { n as itemClass, t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
|
|
24
|
-
import {
|
|
25
|
-
import { t as run } from "./run-B_JAUbXe.js";
|
|
25
|
+
import { t as run } from "./run-UKgVb-kW.js";
|
|
26
26
|
export { AnimatedTexture, AtlasSourceError, BlockStateError, DEFAULT_WATER_COLOR, DYE_COLORS, FolderResourceManager, InvalidItemDefinitionError, InvalidResourceLocatorError, InvalidTinterDefinitionError, ItemRenderError, ItemResolutionError, JarResourceManager, LayeredResourceManager, LightingProfile, ModelLoader, ModelResolutionError, ObjMeshError, ResourceKind, ResourceLocator, TextureLoader, TextureResolutionError, UNKNOWN_MODEL, UNREGISTERED_TINTS, UnsafeJarError, VANILLA_BIOME_CLIMATES, boxDownscale, buildBiomeClimates, buildBlockTints, buildObjMesh, builtinDynamicResources, collectModels, compareVersions, createAtlasResolver, defaultProperties, discoverItems, encodeAnimatedIcon, encodeIcon, eraForVersion, evaluateBlockState, evaluateItemModel, exportBlockPack, generateStylesheet, isUnsafeEntryPath, itemClass, lightsForProfile, matchesCondition, minifyStylesheet, packAtlas, parseAtlasSources, parseBiomeClimate, parseBlockState, parseTintValue, pointResize, prepareModResources, prepareVersionResources, renderModel, renderModelFrames, resolveItem, resolveTexture, resolveTint, resolveTints, run, salvageJson, toByteTexture, toFloatTexture, weightedVariantIndex };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { i as resolveItem, r as langRegistry } from "./discovery-CD0QqxSF.js";
|
|
2
|
+
import { i as resolveTexture } from "./loader-C-NuJaEi.js";
|
|
3
|
+
import { a as resolveTints } from "./tints-B3WQcPtx.js";
|
|
4
|
+
//#region src/blocks/item-sprites.ts
|
|
5
|
+
/**
|
|
6
|
+
* Flat item sprites, for the items a world holds that are not blocks.
|
|
7
|
+
*
|
|
8
|
+
* A dropped stack is the commonest entity in a played-in world, and the game
|
|
9
|
+
* draws it from the *item* model rather than the block one. Most of the time that
|
|
10
|
+
* item model is a block's, and a consumer with the block pack already has what it
|
|
11
|
+
* needs. The rest — a lead, a handful of charcoal, an arrow, a mod's seed — are
|
|
12
|
+
* `item/generated`: a stack of flat sprites the client extrudes into a thin slab,
|
|
13
|
+
* with no geometry stated anywhere because `ItemModelGenerator` builds it in code.
|
|
14
|
+
*
|
|
15
|
+
* So this exports the only thing there is to export: the ordered layer sprites,
|
|
16
|
+
* and which of them the item tints. The consumer does the extruding.
|
|
17
|
+
*
|
|
18
|
+
* Deliberately *not* filtered to non-block ids. Whether an item is flat is decided
|
|
19
|
+
* by asking what its own model resolves to, which is also what the game asks —
|
|
20
|
+
* and it gets `minecraft:wheat` right, where the item is a flat sheaf and the
|
|
21
|
+
* block of the same id is a crop cross.
|
|
22
|
+
*/
|
|
23
|
+
/** The builtin parent whose geometry the client generates from flat layers. */
|
|
24
|
+
const GENERATED = "builtin/generated";
|
|
25
|
+
/** `layer0`, `layer1`, … in the order the client stacks them. */
|
|
26
|
+
const LAYER_NAME = /^layer(\d+)$/;
|
|
27
|
+
/** `{ r, g, b }` in 0–1 as `#rrggbb`, matching how the tint pack writes a colour. */
|
|
28
|
+
function hex(color) {
|
|
29
|
+
return `#${[
|
|
30
|
+
color.r,
|
|
31
|
+
color.g,
|
|
32
|
+
color.b
|
|
33
|
+
].map((channel) => Math.round(Math.max(0, Math.min(1, channel)) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The layers of one generated model, in draw order.
|
|
37
|
+
*
|
|
38
|
+
* Sorted by the number in the name rather than by key order: a mod that writes
|
|
39
|
+
* `layer1` before `layer0` still stacks the way the client stacks it, and a chain
|
|
40
|
+
* that merged its parent's textures has no reliable order at all.
|
|
41
|
+
*/
|
|
42
|
+
function layersOf(textures) {
|
|
43
|
+
const layers = [];
|
|
44
|
+
for (const name of Object.keys(textures)) {
|
|
45
|
+
const match = LAYER_NAME.exec(name);
|
|
46
|
+
if (match) layers.push({
|
|
47
|
+
index: Number(match[1]),
|
|
48
|
+
reference: `#${name}`
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return layers.toSorted((left, right) => left.index - right.index);
|
|
52
|
+
}
|
|
53
|
+
async function collectItemSprites(options) {
|
|
54
|
+
const { resources, models, textures, blocks, itemIds } = options;
|
|
55
|
+
const items = {};
|
|
56
|
+
const spriteIds = /* @__PURE__ */ new Set();
|
|
57
|
+
const failures = [];
|
|
58
|
+
let done = 0;
|
|
59
|
+
const translated = /* @__PURE__ */ new Map();
|
|
60
|
+
for (const namespace of options.namespaces) translated.set(namespace, await langRegistry(resources, namespace));
|
|
61
|
+
const report = (id, reason) => {
|
|
62
|
+
const divider = id.indexOf(":");
|
|
63
|
+
const gate = translated.get(id.slice(0, divider));
|
|
64
|
+
if (gate === void 0 || gate === null || gate.has(id.slice(divider + 1).replaceAll("/", "."))) failures.push({
|
|
65
|
+
id,
|
|
66
|
+
reason
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
for (const id of [...itemIds].toSorted((left, right) => left.localeCompare(right))) {
|
|
70
|
+
options.onProgress?.(++done, itemIds.length);
|
|
71
|
+
let instructions;
|
|
72
|
+
try {
|
|
73
|
+
instructions = await resolveItem(resources, id);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (!blocks.has(id)) report(id, err.message);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const layers = [];
|
|
79
|
+
let flat = true;
|
|
80
|
+
for (const instruction of instructions) {
|
|
81
|
+
let model;
|
|
82
|
+
try {
|
|
83
|
+
model = await models.load(instruction.model);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
flat = false;
|
|
86
|
+
if (!blocks.has(id)) report(id, `model ${instruction.model} did not load: ${err.message}`);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (model.builtinParent !== GENERATED) {
|
|
90
|
+
flat = false;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
const tints = await resolveTints(instruction.tints, { textures });
|
|
94
|
+
for (const layer of layersOf(model.textures)) {
|
|
95
|
+
const sprite = resolveTexture(model, layer.reference);
|
|
96
|
+
if (!sprite) {
|
|
97
|
+
report(id, `${layer.reference} resolves to no texture; layer dropped`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const tint = tints[layer.index];
|
|
101
|
+
layers.push({
|
|
102
|
+
sprite: sprite.toString(),
|
|
103
|
+
...instruction.tints[layer.index] !== void 0 && { tintindex: layer.index },
|
|
104
|
+
...tint && { tint: hex(tint) }
|
|
105
|
+
});
|
|
106
|
+
spriteIds.add(sprite.toString());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!flat) {
|
|
110
|
+
if (!blocks.has(id)) report(id, "item model is not a flat sprite stack and the pack describes no block of this id");
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (layers.length === 0) {
|
|
114
|
+
report(id, "generated item model states no layers");
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
items[id] = { layers };
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
items,
|
|
121
|
+
spriteIds,
|
|
122
|
+
failures
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { collectItemSprites as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { DiscoveredItem, ItemDiscoveryOptions, ItemResolutionError, discoverItems, resolveItem };
|
|
1
|
+
import { a as langRegistry, i as discoverItems, n as ItemDiscoveryOptions, o as resolveItem, r as ItemResolutionError, t as DiscoveredItem } from "../discovery-Cmir3QfC.js";
|
|
2
|
+
export { DiscoveredItem, ItemDiscoveryOptions, ItemResolutionError, discoverItems, langRegistry, resolveItem };
|
package/dist/items/discovery.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as discoverItems, r as
|
|
2
|
-
export { ItemResolutionError, discoverItems, resolveItem };
|
|
1
|
+
import { i as resolveItem, n as discoverItems, r as langRegistry, t as ItemResolutionError } from "../discovery-CD0QqxSF.js";
|
|
2
|
+
export { ItemResolutionError, discoverItems, langRegistry, resolveItem };
|
package/dist/mods/prepare.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as prepareModResources, t as LOADER_NAMESPACES } from "../prepare-
|
|
1
|
+
import { n as prepareModResources, t as LOADER_NAMESPACES } from "../prepare-B_tRy9lB.js";
|
|
2
2
|
export { LOADER_NAMESPACES, prepareModResources };
|
package/dist/mods/tints.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as harvestTintOverrides, t as curatedTintOverrides } from "../tints-
|
|
1
|
+
import { n as harvestTintOverrides, t as curatedTintOverrides } from "../tints-BspVCz2G.js";
|
|
2
2
|
export { curatedTintOverrides, harvestTintOverrides };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
2
|
-
import { l as toFloatTexture, n as cloneFloatTexture, r as darkenTexture, s as tintTexture, t as blendPixel } from "./blend-KXMclcHk.js";
|
|
3
2
|
import { c as normalize, g as transformVector, m as sub, n as displayMatrix, o as identity, r as dot, s as multiply, t as cross } from "./vector-CCxLae_T.js";
|
|
3
|
+
import { i as resolveTexture } from "./loader-C-NuJaEi.js";
|
|
4
|
+
import { l as toFloatTexture, n as cloneFloatTexture, r as darkenTexture, s as tintTexture, t as blendPixel } from "./blend-KXMclcHk.js";
|
|
4
5
|
import { c as lightsForProfile } from "./lighting--5myudVu.js";
|
|
5
6
|
import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, t as RowCursor } from "./rasterizer-DcVJzkxz.js";
|
|
6
7
|
import { t as combineFaceBuffers } from "./compose-BGsNFR12.js";
|
|
7
|
-
import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-
|
|
8
|
+
import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-CMJ3b3Ae.js";
|
|
8
9
|
import { t as paintBucketFluid } from "./fluid-bucket-B-I4ZYHl.js";
|
|
9
10
|
import { r as buildElementFaces } from "./geometry-Bi-Bf5rb.js";
|
|
10
|
-
import { i as resolveTexture } from "./loader-C-NuJaEi.js";
|
|
11
11
|
//#region src/render/renderer.ts
|
|
12
12
|
/**
|
|
13
13
|
* Item rendering entry: flat generated items (2D layer compositing) and 3D
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
2
|
-
import { n as parseMtl, r as parseObj, t as materialTexture } from "./obj-
|
|
2
|
+
import { n as parseMtl, r as parseObj, t as materialTexture } from "./obj-BaGvPUbb.js";
|
|
3
3
|
//#region src/blocks/obj-mesh.ts
|
|
4
4
|
/**
|
|
5
5
|
* OBJ geometry as pack data.
|
|
@@ -119,6 +119,45 @@ type BlockPackTintsFile = BlockTintPack;
|
|
|
119
119
|
* consumer with no file falls back to tinting at `tints.json`'s flat climate.
|
|
120
120
|
*/
|
|
121
121
|
type BlockPackBiomesFile = BiomeClimatePack;
|
|
122
|
+
/** One flat sprite of an item's layer stack, in the order the client draws them. */
|
|
123
|
+
interface ItemPackLayer {
|
|
124
|
+
sprite: string;
|
|
125
|
+
/**
|
|
126
|
+
* Present when the item declares a tint at this layer, which is the client's own
|
|
127
|
+
* rule: `ItemModelGenerator` passes each layer its own index as the tint index.
|
|
128
|
+
*/
|
|
129
|
+
tintindex?: number;
|
|
130
|
+
/**
|
|
131
|
+
* The colour that tint resolves to in an item's default state, `#rrggbb`.
|
|
132
|
+
*
|
|
133
|
+
* Absent where it cannot be known from assets — a dyed leather boot or a potion
|
|
134
|
+
* takes its colour from the stack's components, which no pack can carry. A
|
|
135
|
+
* consumer drawing an absent tint untinted gets the mod's own artwork, which is
|
|
136
|
+
* the same thing the icon renderer settles for.
|
|
137
|
+
*/
|
|
138
|
+
tint?: string;
|
|
139
|
+
}
|
|
140
|
+
/** One flat item: everything there is to say about how the game draws it. */
|
|
141
|
+
interface ItemPackEntry {
|
|
142
|
+
layers: ItemPackLayer[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* `items.json`. Self-contained rather than sharing `atlas.json`'s pages, so a
|
|
146
|
+
* consumer that only draws blocks never fetches the item sheet at all — a world
|
|
147
|
+
* viewer needs it only once it finds a dropped stack of something that is not a
|
|
148
|
+
* block.
|
|
149
|
+
*
|
|
150
|
+
* Holds *only* items whose model is a flat sprite stack. An item absent from
|
|
151
|
+
* `items` either draws from `blockstates.json` under the same id, or is in
|
|
152
|
+
* `failures.json` saying why nothing can draw it.
|
|
153
|
+
*/
|
|
154
|
+
interface BlockPackItemsFile {
|
|
155
|
+
/** Edge-extended border per sprite, in pixels. */
|
|
156
|
+
padding: number;
|
|
157
|
+
pages: BlockPackAtlasPage[];
|
|
158
|
+
sprites: Record<string, BlockPackSprite>;
|
|
159
|
+
items: Record<string, ItemPackEntry>;
|
|
160
|
+
}
|
|
122
161
|
/** `meta.json`, written last because it hashes every other file. */
|
|
123
162
|
interface BlockPackMetaFile {
|
|
124
163
|
generator: string;
|
|
@@ -131,10 +170,12 @@ interface BlockPackMetaFile {
|
|
|
131
170
|
pages: number;
|
|
132
171
|
/** Biomes in `biomes.json`; `0` means the pack has none and the file is absent. */
|
|
133
172
|
biomes: number;
|
|
173
|
+
/** Flat items in `items.json`; `0` means the pack has none and the file is absent. */
|
|
174
|
+
items: number;
|
|
134
175
|
failures: number;
|
|
135
176
|
};
|
|
136
177
|
/** sha256 per file, enough to verify a cached copy without refetching it. */
|
|
137
178
|
hashes: Record<string, string>;
|
|
138
179
|
}
|
|
139
180
|
//#endregion
|
|
140
|
-
export { BlockPackBlockStatesFile as a,
|
|
181
|
+
export { ItemPackEntry as _, BlockPackBlockStatesFile as a, BlockPackItemsFile as c, BlockPackModelsFile as d, BlockPackRenderLayer as f, BlockPackVariant as g, BlockPackTintsFile as h, BlockPackBlockState as i, BlockPackMetaFile as l, BlockPackSpriteFrame as m, BlockPackAtlasPage as n, BlockPackElement as o, BlockPackSprite as p, BlockPackBiomesFile as r, BlockPackFace as s, BlockPackAtlasFile as t, BlockPackModel as u, ItemPackLayer as v };
|
package/dist/pack.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { n as BiomeClimatePack, t as BiomeClimate } from "./biomes-CJDJQqJb.js";
|
|
|
2
2
|
import { a as BlockStateMultipartCase, d as matchesCondition, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "./blockstate-eval-BzznRcVY.js";
|
|
3
3
|
import { n as ObjMesh, t as MeshGroup } from "./obj-mesh-ydhVfLKs.js";
|
|
4
4
|
import { n as BlockTintPack, t as BlockTint } from "./tints-DoBv5S9v.js";
|
|
5
|
-
import { a as BlockPackBlockStatesFile,
|
|
5
|
+
import { a as BlockPackBlockStatesFile, d as BlockPackModelsFile, f as BlockPackRenderLayer, g as BlockPackVariant, h as BlockPackTintsFile, i as BlockPackBlockState, l as BlockPackMetaFile, m as BlockPackSpriteFrame, n as BlockPackAtlasPage, o as BlockPackElement, p as BlockPackSprite, r as BlockPackBiomesFile, s as BlockPackFace, t as BlockPackAtlasFile, u as BlockPackModel } from "./pack-format-oRExIeD3.js";
|
|
6
6
|
export { type BiomeClimate, type BiomeClimatePack, type BlockModelVariant, type BlockPackAtlasFile, type BlockPackAtlasPage, type BlockPackBiomesFile, type BlockPackBlockState, type BlockPackBlockStatesFile, type BlockPackElement, type BlockPackFace, type BlockPackMetaFile, type BlockPackModel, type BlockPackModelsFile, type BlockPackRenderLayer, type BlockPackSprite, type BlockPackSpriteFrame, type BlockPackTintsFile, type BlockPackVariant, type BlockProperties, type BlockStateDefinition, type BlockStateMultipartCase, type BlockStateVariantCase, type BlockTint, type BlockTintPack, type MeshGroup, type MultipartCondition, type ObjMesh, evaluateBlockState, matchesCondition, weightedVariantIndex };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as defaultProperties } from "./definition-ColsvWrH.js";
|
|
3
|
+
import { i as resolveItem } from "./discovery-CD0QqxSF.js";
|
|
3
4
|
import { t as ModelLoader } from "./loader-C-NuJaEi.js";
|
|
4
|
-
import {
|
|
5
|
+
import { a as resolveTints } from "./tints-B3WQcPtx.js";
|
|
6
|
+
import { l as toFloatTexture, t as blendPixel } from "./blend-KXMclcHk.js";
|
|
7
|
+
import { c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "./obj-BaGvPUbb.js";
|
|
5
8
|
import { t as loadAtlasResolver } from "./registry-DlduyjtM.js";
|
|
6
9
|
import { n as LayeredResourceManager, t as FolderResourceManager } from "./manager-BNibYkmI.js";
|
|
7
10
|
import { n as TextureLoader } from "./loader-C18GpurU.js";
|
|
8
|
-
import { a as defaultProperties } from "./definition-ColsvWrH.js";
|
|
9
|
-
import { r as resolveItem } from "./discovery-CsZu08re.js";
|
|
10
11
|
import { t as encodeAnimatedIcon } from "./encode-LR9wxigC.js";
|
|
11
12
|
import { a as builtinDynamicResources } from "./generators-BCZVlWig.js";
|
|
12
|
-
import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-
|
|
13
|
-
import { i as renderGeo, t as findGeoForItem } from "./geo-
|
|
13
|
+
import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-DutR9Hdz.js";
|
|
14
|
+
import { i as renderGeo, t as findGeoForItem } from "./geo-BC8jtG5Q.js";
|
|
14
15
|
import { t as legacyTintsForChain } from "./legacy-tints-l-541wgI.js";
|
|
15
|
-
import { a as resolveTints } from "./tints-B3WQcPtx.js";
|
|
16
16
|
import { n as defaultBlockStateModel, t as blockStateTransform } from "./blockstate-DVb8Mhxc.js";
|
|
17
17
|
import path from "node:path";
|
|
18
18
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as LayeredResourceManager } from "./manager-BNibYkmI.js";
|
|
2
2
|
import { t as curatedModelOverrides } from "./models-CZjCOjs4.js";
|
|
3
3
|
import { t as synthesizeItemModels } from "./synthesize-jTjVjPAt.js";
|
|
4
|
-
import { n as harvestTintOverrides, t as curatedTintOverrides } from "./tints-
|
|
4
|
+
import { n as harvestTintOverrides, t as curatedTintOverrides } from "./tints-BspVCz2G.js";
|
|
5
5
|
import { n as UnsafeJarError, t as JarResourceManager } from "./jar-W2cV2ZVO.js";
|
|
6
6
|
//#region src/mods/prepare.ts
|
|
7
7
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-
|
|
1
|
+
import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-DutR9Hdz.js";
|
|
2
2
|
export { dyeVariantName, dyedVariantTint, renderDyedVariantFallback, renderEntityFallback, spawnEggTints };
|
package/dist/render/face.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "../face-
|
|
1
|
+
import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "../face-CMJ3b3Ae.js";
|
|
2
2
|
export { createShadeCache, faceMaxZ, renderFace };
|
package/dist/render/geo.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as renderGeo, n as geoToFaces, r as parseGeo, t as findGeoForItem } from "../geo-
|
|
1
|
+
import { i as renderGeo, n as geoToFaces, r as parseGeo, t as findGeoForItem } from "../geo-BC8jtG5Q.js";
|
|
2
2
|
export { findGeoForItem, geoToFaces, parseGeo, renderGeo };
|
package/dist/render/obj.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as renderObjModel, n as parseMtl, r as parseObj, t as materialTexture } from "../obj-
|
|
1
|
+
import { i as renderObjModel, n as parseMtl, r as parseObj, t as materialTexture } from "../obj-BaGvPUbb.js";
|
|
2
2
|
export { materialTexture, parseMtl, parseObj, renderObjModel };
|
package/dist/render/pipeline.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ItemPipeline } from "../pipeline-
|
|
1
|
+
import { t as ItemPipeline } from "../pipeline-AAfohoHU.js";
|
|
2
2
|
export { ItemPipeline };
|
package/dist/render/renderer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ItemRenderError, c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "../obj-
|
|
1
|
+
import { a as ItemRenderError, c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "../obj-BaGvPUbb.js";
|
|
2
2
|
export { ItemRenderError, boxDownscale, pointResize, renderModel, renderModelFrames };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
2
|
+
import { n as discoverItems } from "./discovery-CD0QqxSF.js";
|
|
2
3
|
import { n as LayeredResourceManager } from "./manager-BNibYkmI.js";
|
|
3
4
|
import { t as curatedModelOverrides } from "./models-CZjCOjs4.js";
|
|
4
|
-
import { n as discoverItems } from "./discovery-CsZu08re.js";
|
|
5
5
|
import { r as encodeRasterAsset } from "./encode-LR9wxigC.js";
|
|
6
6
|
import { t as classifyItemStyle } from "./item-styles-DjYRdyHi.js";
|
|
7
7
|
import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
|
|
8
8
|
import { t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
|
|
9
|
-
import { t as ItemPipeline } from "./pipeline-
|
|
9
|
+
import { t as ItemPipeline } from "./pipeline-AAfohoHU.js";
|
|
10
10
|
import { t as describeResources } from "./descriptor-D7VKgeGT.js";
|
|
11
11
|
import { t as WorkerRenderPool } from "./pool-CKGp1qup.js";
|
|
12
12
|
import path from "node:path";
|
package/dist/run.js
CHANGED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
2
|
+
import { t as packAtlas } from "./atlas-pack-CoOih7By.js";
|
|
3
|
+
//#region src/blocks/sprite-sheet.ts
|
|
4
|
+
/**
|
|
5
|
+
* Turning a set of texture ids into a stitched atlas plus the JSON that
|
|
6
|
+
* addresses it, which is the same problem whether the sprites came from block
|
|
7
|
+
* models or from item models.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from `export.ts` when the item sprites arrived, unchanged: the
|
|
10
|
+
* fiddly parts — an animation strip becoming one rect per physical frame, a
|
|
11
|
+
* `.mcmeta` claiming more frames than an atlas can hold, a sprite too large for
|
|
12
|
+
* a page, alpha deciding the render layer — are all things it would be a mistake
|
|
13
|
+
* to write twice and let drift.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here knows what names the sprites. Callers that need a guaranteed
|
|
16
|
+
* fallback sprite pass `includeMissing`; callers that do not (an item sheet, where
|
|
17
|
+
* a missing sprite means the consumer draws a box instead) leave it off.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Vanilla's own id for the missing-texture sprite. A face whose texture does
|
|
21
|
+
* not resolve is drawn by the game in black and magenta rather than skipped —
|
|
22
|
+
* Blockbench leaves `"texture": "#missing"` on unassigned faces and mods ship
|
|
23
|
+
* models naming textures they forgot to include. Dropping those faces would
|
|
24
|
+
* put holes in geometry the player can see, and would read as our bug rather
|
|
25
|
+
* than the mod's.
|
|
26
|
+
*/
|
|
27
|
+
const MISSING_SPRITE = "minecraft:missingno";
|
|
28
|
+
/**
|
|
29
|
+
* A sprite whose strip is longer than this exports as its first frame only.
|
|
30
|
+
* A broken `.mcmeta` can claim thousands of frames, and packing them would
|
|
31
|
+
* blow the atlas out for one texture.
|
|
32
|
+
*/
|
|
33
|
+
const MAX_FRAMES_PER_SPRITE = 256;
|
|
34
|
+
/** `MissingTextureAtlasSprite`: 16x16, black and magenta in 8px quarters. */
|
|
35
|
+
function missingTexture() {
|
|
36
|
+
const size = 16;
|
|
37
|
+
const data = /* @__PURE__ */ new Uint8ClampedArray(1024);
|
|
38
|
+
for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
|
|
39
|
+
const magenta = x < 8 !== y < 8;
|
|
40
|
+
const offset = (y * size + x) * 4;
|
|
41
|
+
data[offset] = magenta ? 248 : 0;
|
|
42
|
+
data[offset + 1] = 0;
|
|
43
|
+
data[offset + 2] = magenta ? 248 : 0;
|
|
44
|
+
data[offset + 3] = 255;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
width: size,
|
|
48
|
+
height: size,
|
|
49
|
+
data
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Alpha decides the render layer: vanilla assets do not state cutout versus
|
|
54
|
+
* translucent (`render_type` is a loader extension adopted only recently), and
|
|
55
|
+
* inferring it covers mods for free.
|
|
56
|
+
*/
|
|
57
|
+
function inferRenderLayer(frames) {
|
|
58
|
+
let sawHole = false;
|
|
59
|
+
for (const frame of frames) for (let offset = 3; offset < frame.data.length; offset += 4) {
|
|
60
|
+
const alpha = frame.data[offset];
|
|
61
|
+
if (alpha === 0) sawHole = true;
|
|
62
|
+
else if (alpha !== 255) return "translucent";
|
|
63
|
+
}
|
|
64
|
+
return sawHole ? "cutout" : "solid";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Loads every id, packs the frames, and returns the sheet plus everything that
|
|
68
|
+
* did not make it. Ids are packed in sorted order so an unchanged input produces
|
|
69
|
+
* a byte-identical atlas.
|
|
70
|
+
*/
|
|
71
|
+
async function buildSpriteSheet(ids, textures, options = {}) {
|
|
72
|
+
const wanted = new Set(ids);
|
|
73
|
+
if (options.includeMissing) wanted.delete(MISSING_SPRITE);
|
|
74
|
+
const failures = [];
|
|
75
|
+
const missing = /* @__PURE__ */ new Set();
|
|
76
|
+
const loaded = [];
|
|
77
|
+
let done = 0;
|
|
78
|
+
for (const id of [...wanted].toSorted((left, right) => left.localeCompare(right))) {
|
|
79
|
+
options.onProgress?.(++done, wanted.size);
|
|
80
|
+
let animated;
|
|
81
|
+
try {
|
|
82
|
+
animated = await textures.loadAnimated(ResourceLocator.parse(id));
|
|
83
|
+
} catch (err) {
|
|
84
|
+
failures.push({
|
|
85
|
+
id,
|
|
86
|
+
reason: err.message
|
|
87
|
+
});
|
|
88
|
+
missing.add(id);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (!animated) {
|
|
92
|
+
failures.push({
|
|
93
|
+
id,
|
|
94
|
+
reason: "texture not found"
|
|
95
|
+
});
|
|
96
|
+
missing.add(id);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const overlong = animated.frameCount > MAX_FRAMES_PER_SPRITE;
|
|
100
|
+
if (overlong) failures.push({
|
|
101
|
+
id,
|
|
102
|
+
reason: `${animated.frameCount} frames exceeds the ${MAX_FRAMES_PER_SPRITE} cap; exported static`
|
|
103
|
+
});
|
|
104
|
+
const starts = overlong ? [0] : animated.frameStartTicks();
|
|
105
|
+
const total = overlong ? 1 : animated.tickLength;
|
|
106
|
+
const sequence = starts.map((start, index) => {
|
|
107
|
+
return {
|
|
108
|
+
frame: animated.resolveFrame(start).frame,
|
|
109
|
+
time: (index + 1 < starts.length ? starts[index + 1] : total) - start
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
const frames = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const entry of sequence) if (!frames.has(entry.frame)) frames.set(entry.frame, animated.frame(entry.frame));
|
|
114
|
+
loaded.push({
|
|
115
|
+
id,
|
|
116
|
+
frames,
|
|
117
|
+
sequence,
|
|
118
|
+
interpolate: animated.interpolated
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (options.includeMissing) loaded.push({
|
|
122
|
+
id: MISSING_SPRITE,
|
|
123
|
+
frames: /* @__PURE__ */ new Map([[0, missingTexture()]]),
|
|
124
|
+
sequence: [{
|
|
125
|
+
frame: 0,
|
|
126
|
+
time: 1
|
|
127
|
+
}],
|
|
128
|
+
interpolate: false
|
|
129
|
+
});
|
|
130
|
+
const packed = packAtlas(loaded.flatMap((sprite) => [...sprite.frames].map(([index, texture]) => {
|
|
131
|
+
return {
|
|
132
|
+
key: `${sprite.id}#${index}`,
|
|
133
|
+
texture
|
|
134
|
+
};
|
|
135
|
+
})), {
|
|
136
|
+
padding: options.padding,
|
|
137
|
+
maxPageSize: options.maxPageSize
|
|
138
|
+
});
|
|
139
|
+
for (const key of packed.oversized) {
|
|
140
|
+
const id = key.split("#", 1)[0];
|
|
141
|
+
if (!missing.has(id)) {
|
|
142
|
+
failures.push({
|
|
143
|
+
id,
|
|
144
|
+
reason: "sprite is larger than one atlas page; drawn as the missing texture"
|
|
145
|
+
});
|
|
146
|
+
missing.add(id);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (options.includeMissing && missing.has("minecraft:missingno")) throw new Error("the missing-texture sprite does not fit an atlas page; maxPageSize is too small");
|
|
150
|
+
const rects = new Map(packed.rects.map((rect) => [rect.key, rect]));
|
|
151
|
+
const sprites = {};
|
|
152
|
+
for (const sprite of loaded) {
|
|
153
|
+
const first = rects.get(`${sprite.id}#${sprite.sequence[0].frame}`);
|
|
154
|
+
if (!first) continue;
|
|
155
|
+
const frames = [];
|
|
156
|
+
for (const entry of sprite.sequence) {
|
|
157
|
+
const rect = rects.get(`${sprite.id}#${entry.frame}`);
|
|
158
|
+
if (rect) frames.push({
|
|
159
|
+
page: rect.page,
|
|
160
|
+
x: rect.x,
|
|
161
|
+
y: rect.y,
|
|
162
|
+
time: entry.time
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
sprites[sprite.id] = {
|
|
166
|
+
page: first.page,
|
|
167
|
+
x: first.x,
|
|
168
|
+
y: first.y,
|
|
169
|
+
w: first.width,
|
|
170
|
+
h: first.height,
|
|
171
|
+
layer: inferRenderLayer(sprite.frames.values().toArray()),
|
|
172
|
+
...frames.length === sprite.sequence.length && frames.length > 1 && { frames },
|
|
173
|
+
...sprite.interpolate && { interpolate: true }
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
pages: packed.pages,
|
|
178
|
+
sprites,
|
|
179
|
+
missing,
|
|
180
|
+
failures,
|
|
181
|
+
padding: packed.padding
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
export { missingTexture as i, buildSpriteSheet as n, inferRenderLayer as r, MISSING_SPRITE as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ItemPipeline } from "../pipeline-
|
|
1
|
+
import { t as ItemPipeline } from "../pipeline-AAfohoHU.js";
|
|
2
2
|
import { n as restoreResources } from "../descriptor-D7VKgeGT.js";
|
|
3
3
|
import sharp from "sharp";
|
|
4
4
|
import { parentPort, workerData } from "node:worker_threads";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodecraft/rendermite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Minecraft item icon renderer: renders inventory-identical item icons from vanilla and modded assets across game versions, outputting optimized PNG/WebP/AVIF plus CSS and a JSON item library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as scaleTextureAlpha, n as cloneFloatTexture, r as darkenTexture, s as tintTexture, u as uvWindow } from "./blend-KXMclcHk.js";
|
|
2
1
|
import { c as normalize, g as transformVector, h as transformDirection, m as sub, r as dot, t as cross } from "./vector-CCxLae_T.js";
|
|
2
|
+
import { a as scaleTextureAlpha, n as cloneFloatTexture, r as darkenTexture, s as tintTexture, u as uvWindow } from "./blend-KXMclcHk.js";
|
|
3
3
|
import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, r as compactFaceBuffer, t as RowCursor } from "./rasterizer-DcVJzkxz.js";
|
|
4
4
|
//#region src/render/face.ts
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as modTintPackPath } from "./builtin-WkWjATeh.js";
|
|
2
2
|
import { n as ResourceLocator } from "./locator-COMEtEn9.js";
|
|
3
|
+
import { a as defaultProperties, o as evaluateItemModel } from "./definition-ColsvWrH.js";
|
|
3
4
|
import { t as FolderResourceManager } from "./manager-BNibYkmI.js";
|
|
4
5
|
import { n as MapResourceManager } from "./synthetic-rc9BPT4P.js";
|
|
5
|
-
import { a as defaultProperties, o as evaluateItemModel } from "./definition-ColsvWrH.js";
|
|
6
6
|
//#region src/mods/tints.ts
|
|
7
7
|
/**
|
|
8
8
|
* Tints for mod items whose colors live in client code rather than asset JSON.
|