@nodecraft/rendermite 1.2.1 → 1.3.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 +8 -0
- package/dist/blocks/pack-format.d.ts +2 -0
- package/dist/blocks/pack-format.js +1 -0
- package/dist/pack-format-BO2FsorN.d.ts +121 -0
- package/dist/pack.d.ts +5 -0
- package/dist/pack.js +2 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -91,6 +91,14 @@ Everything the CLI does is exported, from the high-level `run()` and `exportBloc
|
|
|
91
91
|
import { run, exportBlockPack, prepareModResources, builtinPackPath } from '@nodecraft/rendermite';
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
Reading a published block pack needs none of that toolchain, so it has its own entry — no `sharp`,
|
|
95
|
+
no `node:` builtin, 13 KB bundled:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { evaluateBlockState } from '@nodecraft/rendermite/pack';
|
|
99
|
+
import type { BlockPackModel } from '@nodecraft/rendermite/pack';
|
|
100
|
+
```
|
|
101
|
+
|
|
94
102
|
## Performance
|
|
95
103
|
|
|
96
104
|
Benchmarked against PHP renderchest v5.1.0 on the same machine, rendering the same extracted 1.21.8 assets at 64px (PNG + WebP):
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "../pack-format-BO2FsorN.js";
|
|
2
|
+
export { BlockPackAtlasFile, BlockPackAtlasPage, BlockPackBlockState, BlockPackBlockStatesFile, BlockPackElement, BlockPackFace, BlockPackMetaFile, BlockPackModel, BlockPackModelsFile, BlockPackRenderLayer, BlockPackSprite, BlockPackSpriteFrame, BlockPackTintsFile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { a as FaceDirectionName, l as Vec3, o as ModelElementJson, u as Vec4 } from "./types-qlp3I8_-.js";
|
|
2
|
+
import { r as BlockStateDefinition } from "./blockstate-eval-CObtPWzJ.js";
|
|
3
|
+
import { t as MeshGroup } from "./obj-mesh-C6Sp4Ysc.js";
|
|
4
|
+
import { n as BlockTintPack } from "./tints-2k3ZhkY3.js";
|
|
5
|
+
//#region src/blocks/pack-format.d.ts
|
|
6
|
+
/** How a sprite's alpha classifies it, inferred because assets rarely say. */
|
|
7
|
+
type BlockPackRenderLayer = 'solid' | 'cutout' | 'translucent';
|
|
8
|
+
interface BlockPackFace {
|
|
9
|
+
sprite: string;
|
|
10
|
+
/** [u1, v1, u2, v2] in 0–16 sprite space, derived when the model omits it. */
|
|
11
|
+
uv: Vec4;
|
|
12
|
+
rotation?: number;
|
|
13
|
+
tintindex?: number;
|
|
14
|
+
cullface?: FaceDirectionName;
|
|
15
|
+
}
|
|
16
|
+
interface BlockPackElement {
|
|
17
|
+
from: Vec3;
|
|
18
|
+
to: Vec3;
|
|
19
|
+
rotation?: ModelElementJson['rotation'];
|
|
20
|
+
shade?: false;
|
|
21
|
+
faces: Partial<Record<FaceDirectionName, BlockPackFace>>;
|
|
22
|
+
}
|
|
23
|
+
interface BlockPackModel {
|
|
24
|
+
ao: boolean;
|
|
25
|
+
elements: BlockPackElement[];
|
|
26
|
+
/**
|
|
27
|
+
* The model's `particle` texture. What the game throws when the block breaks
|
|
28
|
+
* or is walked on, and the only colour a consumer has to work with for a
|
|
29
|
+
* block that draws nothing — a placeholder cube for a chest comes out oak
|
|
30
|
+
* rather than magenta.
|
|
31
|
+
*/
|
|
32
|
+
particle?: string;
|
|
33
|
+
/** Triangle geometry from an OBJ loader, when the model uses one. */
|
|
34
|
+
mesh?: MeshGroup[];
|
|
35
|
+
/**
|
|
36
|
+
* The layer the model states it draws on. Authoritative where present, and
|
|
37
|
+
* it beats the per-sprite alpha inference — the same sprite can be solid in
|
|
38
|
+
* one model and translucent in another.
|
|
39
|
+
*/
|
|
40
|
+
renderType?: BlockPackRenderLayer;
|
|
41
|
+
/** Block offsets a split-multiblock mesh spans. */
|
|
42
|
+
multiblock?: Array<[number, number, number]>;
|
|
43
|
+
/**
|
|
44
|
+
* Present when the block is a fluid, whose real surface height and flow
|
|
45
|
+
* direction come from its neighbours and so cannot be baked. The cube here is
|
|
46
|
+
* a stand-in; these are the sheets to mesh the real thing with.
|
|
47
|
+
*/
|
|
48
|
+
fluid?: {
|
|
49
|
+
still: string;
|
|
50
|
+
flow: string;
|
|
51
|
+
overlay?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
interface BlockPackSpriteFrame {
|
|
55
|
+
page: number;
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
/** Duration in game ticks. */
|
|
59
|
+
time: number;
|
|
60
|
+
}
|
|
61
|
+
interface BlockPackSprite {
|
|
62
|
+
page: number;
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
w: number;
|
|
66
|
+
h: number;
|
|
67
|
+
layer: BlockPackRenderLayer;
|
|
68
|
+
/** The displayed sequence, which can revisit a frame; absent when static. */
|
|
69
|
+
frames?: BlockPackSpriteFrame[];
|
|
70
|
+
interpolate?: true;
|
|
71
|
+
}
|
|
72
|
+
interface BlockPackAtlasPage {
|
|
73
|
+
file: string;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
}
|
|
77
|
+
/** `atlas.json`. */
|
|
78
|
+
interface BlockPackAtlasFile {
|
|
79
|
+
/** Edge-extended border per sprite, in pixels. */
|
|
80
|
+
padding: number;
|
|
81
|
+
pages: BlockPackAtlasPage[];
|
|
82
|
+
sprites: Record<string, BlockPackSprite>;
|
|
83
|
+
}
|
|
84
|
+
/** `models.json`, by fully-qualified model id. */
|
|
85
|
+
type BlockPackModelsFile = Record<string, BlockPackModel>;
|
|
86
|
+
/** `blockstates.json`, by block id, with keys and predicates already parsed. */
|
|
87
|
+
type BlockPackBlockStatesFile = Record<string, BlockPackBlockState>;
|
|
88
|
+
/**
|
|
89
|
+
* One block's cases as the pack writes them: the tagged union `evaluateBlockState`
|
|
90
|
+
* takes, flattened to the key the file uses.
|
|
91
|
+
*/
|
|
92
|
+
type BlockPackBlockState = {
|
|
93
|
+
variants: Extract<BlockStateDefinition, {
|
|
94
|
+
kind: 'variants';
|
|
95
|
+
}>['cases'];
|
|
96
|
+
multipart?: undefined;
|
|
97
|
+
} | {
|
|
98
|
+
multipart: Extract<BlockStateDefinition, {
|
|
99
|
+
kind: 'multipart';
|
|
100
|
+
}>['cases'];
|
|
101
|
+
variants?: undefined;
|
|
102
|
+
};
|
|
103
|
+
/** `tints.json`. */
|
|
104
|
+
type BlockPackTintsFile = BlockTintPack;
|
|
105
|
+
/** `meta.json`, written last because it hashes every other file. */
|
|
106
|
+
interface BlockPackMetaFile {
|
|
107
|
+
generator: string;
|
|
108
|
+
version: string;
|
|
109
|
+
namespaces: string[];
|
|
110
|
+
counts: {
|
|
111
|
+
blocks: number;
|
|
112
|
+
models: number;
|
|
113
|
+
sprites: number;
|
|
114
|
+
pages: number;
|
|
115
|
+
failures: number;
|
|
116
|
+
};
|
|
117
|
+
/** sha256 per file, enough to verify a cached copy without refetching it. */
|
|
118
|
+
hashes: Record<string, string>;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { BlockPackElement as a, BlockPackModel as c, BlockPackSprite as d, BlockPackSpriteFrame as f, BlockPackBlockStatesFile as i, BlockPackModelsFile as l, BlockPackAtlasPage as n, BlockPackFace as o, BlockPackTintsFile as p, BlockPackBlockState as r, BlockPackMetaFile as s, BlockPackAtlasFile as t, BlockPackRenderLayer as u };
|
package/dist/pack.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
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-CObtPWzJ.js";
|
|
2
|
+
import { n as ObjMesh, t as MeshGroup } from "./obj-mesh-C6Sp4Ysc.js";
|
|
3
|
+
import { n as BlockTintPack, t as BlockTint } from "./tints-2k3ZhkY3.js";
|
|
4
|
+
import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "./pack-format-BO2FsorN.js";
|
|
5
|
+
export { type BlockModelVariant, type BlockPackAtlasFile, type BlockPackAtlasPage, type BlockPackBlockState, type BlockPackBlockStatesFile, type BlockPackElement, type BlockPackFace, type BlockPackMetaFile, type BlockPackModel, type BlockPackModelsFile, type BlockPackRenderLayer, type BlockPackSprite, type BlockPackSpriteFrame, type BlockPackTintsFile, type BlockProperties, type BlockStateDefinition, type BlockStateMultipartCase, type BlockStateVariantCase, type BlockTint, type BlockTintPack, type MeshGroup, type MultipartCondition, type ObjMesh, evaluateBlockState, matchesCondition, weightedVariantIndex };
|
package/dist/pack.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodecraft/rendermite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./pack": {
|
|
33
|
+
"types": "./dist/pack.d.ts",
|
|
34
|
+
"import": "./dist/pack.js"
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"files": [
|
|
@@ -65,6 +69,7 @@
|
|
|
65
69
|
"@types/yazl": "3.3.1",
|
|
66
70
|
"eslint": "10.8.0",
|
|
67
71
|
"rimraf": "6.1.3",
|
|
72
|
+
"rolldown": "1.2.3",
|
|
68
73
|
"semantic-release": "25.0.9",
|
|
69
74
|
"tsdown": "0.22.14",
|
|
70
75
|
"typescript": "6.0.3",
|