@nodecraft/rendermite 1.0.2 → 1.0.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/atlas/registry.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/compose-qjhyBvnS.js +41 -0
- package/dist/{discovery-CmNYzKPr.d.ts → discovery-D89pVVJA.d.ts} +11 -2
- package/dist/{discovery-BzaOti7l.js → discovery-iph0P2F2.js} +3 -2
- package/dist/{entity-fallback-D9iiUkkS.js → entity-fallback-CdCVEG6X.js} +1 -1
- package/dist/{face-DC6cNMdz.d.ts → face-CpVdnf-w.d.ts} +1 -1
- package/dist/{face-Wfia-_Yx.js → face-D-N1amV4.js} +2 -2
- package/dist/{geo-B5VqGulc.js → geo-u8rndjLA.js} +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/items/discovery.d.ts +2 -2
- package/dist/items/discovery.js +1 -1
- package/dist/{loader-BR58A4Ye.js → loader-A-BZa8J4.js} +11 -1
- package/dist/{loader-lCkMRDH4.d.ts → loader-C-6QN3xv.d.ts} +2 -0
- package/dist/models/loader.d.ts +1 -1
- package/dist/models/loader.js +1 -1
- package/dist/{rasterizer-ABgsWTYN.js → rasterizer-BHWDrmGz.js} +40 -1
- package/dist/{rasterizer-CVOlRsuw.d.ts → rasterizer-Dh35qXbn.d.ts} +10 -1
- package/dist/registry-B9TcjVbs.js +80 -0
- package/dist/render/compose.d.ts +1 -1
- package/dist/render/compose.js +1 -1
- package/dist/render/entity-fallback.d.ts +3 -3
- package/dist/render/entity-fallback.js +1 -1
- package/dist/render/face.d.ts +1 -1
- package/dist/render/face.js +1 -1
- package/dist/render/geo.d.ts +1 -1
- package/dist/render/geo.js +1 -1
- package/dist/render/legacy-tints.d.ts +1 -1
- package/dist/render/obj.d.ts +2 -2
- package/dist/render/obj.js +1 -1
- package/dist/render/rasterizer.d.ts +2 -2
- package/dist/render/rasterizer.js +2 -2
- package/dist/render/renderer.d.ts +1 -1
- package/dist/render/renderer.js +1 -1
- package/dist/render/tints.d.ts +1 -1
- package/dist/{renderer-IC9DBUKp.js → renderer-BeOinVC8.js} +21 -6
- package/dist/{renderer-DQfv6axF.d.ts → renderer-nbMCw1Pl.d.ts} +2 -2
- package/dist/{run-BK7Q8WZ3.d.ts → run-BlSZw9Qk.d.ts} +6 -0
- package/dist/{run-Cp_wk49z.js → run-DI-cB38y.js} +7 -7
- package/dist/run.d.ts +1 -1
- package/dist/run.js +1 -1
- package/dist/{tints-Fr6WoPaU.d.ts → tints-txt-8xI5.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/compose-cph4bfdr.js +0 -27
- package/dist/registry-C9E7jyzG.js +0 -28
package/dist/atlas/registry.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as loadAtlasResolver } from "../registry-
|
|
1
|
+
import { t as loadAtlasResolver } from "../registry-B9TcjVbs.js";
|
|
2
2
|
export { loadAtlasResolver };
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { n as builtinPackPath, t as bedCompatPath } from "./builtin-C8GZEN40.js";
|
|
3
3
|
import { n as LayeredResourceManager, t as FolderResourceManager } from "./manager-dfI7b9N4.js";
|
|
4
4
|
import { t as JarResourceManager } from "./jar-Bt3i0ls4.js";
|
|
5
|
-
import { t as run } from "./run-
|
|
5
|
+
import { t as run } from "./run-DI-cB38y.js";
|
|
6
6
|
import { t as downloadClientJar } from "./download-D9aARBFp.js";
|
|
7
7
|
import { a as prepareVersionResources, i as eraForVersion, n as GEOMETRY_DONOR_VERSIONS } from "./prepare-DROxBZp1.js";
|
|
8
8
|
import path from "node:path";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as blendPixel } from "./blend-CHP2-j9U.js";
|
|
2
|
+
//#region src/render/compose.ts
|
|
3
|
+
/**
|
|
4
|
+
* Per-pixel painter's compositing, mirroring upstream Model::combineFaceImages:
|
|
5
|
+
* at each pixel, faces sorted ascending by that pixel's depth value (0 where the
|
|
6
|
+
* rasterizer never wrote depth — the overdraw band relies on sorting beneath),
|
|
7
|
+
* then source-over blended in that order when alpha > 0.
|
|
8
|
+
*/
|
|
9
|
+
function combineFaceBuffers(width, height, faces) {
|
|
10
|
+
const out = new Float64Array(width * height * 4);
|
|
11
|
+
const order = [...faces];
|
|
12
|
+
for (let pixel = 0; pixel < width * height; pixel++) {
|
|
13
|
+
const x = pixel % width;
|
|
14
|
+
const y = Math.floor(pixel / width);
|
|
15
|
+
const localPixel = (face) => {
|
|
16
|
+
const localX = x - face.x;
|
|
17
|
+
const localY = y - face.y;
|
|
18
|
+
return localX >= 0 && localX < face.width && localY >= 0 && localY < face.height ? localY * face.width + localX : null;
|
|
19
|
+
};
|
|
20
|
+
order.sort((a, b) => {
|
|
21
|
+
const aPixel = localPixel(a);
|
|
22
|
+
const bPixel = localPixel(b);
|
|
23
|
+
return (aPixel === null ? 0 : a.depths[aPixel]) - (bPixel === null ? 0 : b.depths[bPixel]);
|
|
24
|
+
});
|
|
25
|
+
const offset = pixel * 4;
|
|
26
|
+
for (const face of order) {
|
|
27
|
+
const facePixel = localPixel(face);
|
|
28
|
+
if (facePixel === null) continue;
|
|
29
|
+
const faceOffset = facePixel * 4;
|
|
30
|
+
const alpha = face.colors[faceOffset + 3];
|
|
31
|
+
if (alpha > 0) blendPixel(out, offset, face.colors[faceOffset], face.colors[faceOffset + 1], face.colors[faceOffset + 2], alpha);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
data: out
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { combineFaceBuffers as t };
|
|
@@ -7,7 +7,16 @@ interface DiscoveredItem {
|
|
|
7
7
|
id: string;
|
|
8
8
|
source: 'definition' | 'model';
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface ItemDiscoveryOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Drop classic item models that have no matching item/block translation.
|
|
13
|
+
* Enabled by default to avoid publishing state and template models from a
|
|
14
|
+
* raw mod jar. Prepared resource packs can disable it after applying their
|
|
15
|
+
* own registry-aware filtering, preserving renderchest's complete model scan.
|
|
16
|
+
*/
|
|
17
|
+
filterUntranslatedModels?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function discoverItems(resources: ResourceManager, namespace: string, options?: ItemDiscoveryOptions): Promise<DiscoveredItem[]>;
|
|
11
20
|
/**
|
|
12
21
|
* Resolve an item id to the models to render. Definitions are evaluated with
|
|
13
22
|
* static-icon properties; plain model items render the model with no tints
|
|
@@ -15,4 +24,4 @@ declare function discoverItems(resources: ResourceManager, namespace: string): P
|
|
|
15
24
|
*/
|
|
16
25
|
declare function resolveItem(resources: ResourceManager, id: string, properties?: ItemProperties): Promise<ItemRenderInstruction[]>;
|
|
17
26
|
//#endregion
|
|
18
|
-
export { resolveItem as i,
|
|
27
|
+
export { resolveItem as a, discoverItems as i, ItemDiscoveryOptions as n, ItemResolutionError as r, DiscoveredItem as t };
|
|
@@ -9,7 +9,7 @@ import { o as evaluateItemModel } from "./definition-3MBm8ar_.js";
|
|
|
9
9
|
* the form `<ns>:<name>`.
|
|
10
10
|
*/
|
|
11
11
|
var ItemResolutionError = class extends Error {};
|
|
12
|
-
async function discoverItems(resources, namespace) {
|
|
12
|
+
async function discoverItems(resources, namespace, options = {}) {
|
|
13
13
|
const seen = /* @__PURE__ */ new Set();
|
|
14
14
|
const items = [];
|
|
15
15
|
for (const locator of await resources.listResources("itemDefinition", namespace)) {
|
|
@@ -22,7 +22,8 @@ async function discoverItems(resources, namespace) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const filterUntranslated = options.filterUntranslatedModels ?? true;
|
|
26
|
+
const registered = namespace === "minecraft" || !filterUntranslated ? null : await langRegistry(resources, namespace);
|
|
26
27
|
for (const locator of await resources.listResources("model", namespace)) {
|
|
27
28
|
if (!locator.path.startsWith("item/")) continue;
|
|
28
29
|
const name = locator.path.slice(5);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
2
|
-
import { i as renderModel } from "./renderer-
|
|
2
|
+
import { i as renderModel } from "./renderer-BeOinVC8.js";
|
|
3
3
|
//#region src/render/entity-fallback.ts
|
|
4
4
|
/**
|
|
5
5
|
* Heuristic rendering for mod items that parent `builtin/entity` — chests,
|
|
@@ -2,7 +2,7 @@ import { t as FloatTexture } from "./blend-Qvrn6YgK.js";
|
|
|
2
2
|
import { t as Mat4 } from "./vector-DRKRi4--.js";
|
|
3
3
|
import { n as FaceGeometry } from "./geometry-BSVmKx5b.js";
|
|
4
4
|
import { r as LightSource } from "./lighting-3FGRC3Af.js";
|
|
5
|
-
import { t as FaceBuffer } from "./rasterizer-
|
|
5
|
+
import { t as FaceBuffer } from "./rasterizer-Dh35qXbn.js";
|
|
6
6
|
//#region src/render/face.d.ts
|
|
7
7
|
interface TintColor {
|
|
8
8
|
r: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
import { a as tintTexture, n as cloneFloatTexture, r as darkenTexture } from "./blend-CHP2-j9U.js";
|
|
3
|
-
import {
|
|
3
|
+
import { a as phpRound, i as drawTexturedTriangle, n as compactFaceBuffer, r as createFaceBuffer, t as RowCursor } from "./rasterizer-BHWDrmGz.js";
|
|
4
4
|
//#region src/render/face.ts
|
|
5
5
|
/**
|
|
6
6
|
* Face rendering: cull, transform, project, tint, darken, rasterize — a faithful
|
|
@@ -86,7 +86,7 @@ function renderFace(face, width, height, transformation) {
|
|
|
86
86
|
const cursor = new RowCursor();
|
|
87
87
|
drawTexturedTriangle(point(0), point(2), point(3), buffer, texture, cursor);
|
|
88
88
|
drawTexturedTriangle(point(0), point(1), point(2), buffer, texture, cursor);
|
|
89
|
-
return buffer;
|
|
89
|
+
return compactFaceBuffer(buffer);
|
|
90
90
|
}
|
|
91
91
|
//#endregion
|
|
92
92
|
export { renderFace as n, faceMaxZ as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
2
2
|
import { n as displayMatrix } from "./vector-CCxLae_T.js";
|
|
3
3
|
import { s as toFloatTexture } from "./blend-CHP2-j9U.js";
|
|
4
|
-
import { t as combineFaceBuffers } from "./compose-
|
|
5
|
-
import { n as renderFace, t as faceMaxZ } from "./face-
|
|
4
|
+
import { t as combineFaceBuffers } from "./compose-qjhyBvnS.js";
|
|
5
|
+
import { n as renderFace, t as faceMaxZ } from "./face-D-N1amV4.js";
|
|
6
6
|
import { c as lightsForProfile } from "./lighting--5myudVu.js";
|
|
7
7
|
//#region src/render/geo.ts
|
|
8
8
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,18 +3,18 @@ import { a as ResourceManager, i as ResourceKindName, n as LayeredResourceManage
|
|
|
3
3
|
import { a as TextureMeta, i as TextureLoader, o as TextureResolutionError, r as Texture, t as AnimatedTexture } from "./loader-TFFNV4Jl.js";
|
|
4
4
|
import { d as parseAtlasSources, n as AtlasSource, r as AtlasSourceError, s as ResolvedSprite, t as AtlasResolver, u as createAtlasResolver } from "./sources-DH9dk3KF.js";
|
|
5
5
|
import { s as builtinDynamicResources } from "./generators-CCB8h0mP.js";
|
|
6
|
-
import { a as resolveTexture, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "./loader-
|
|
6
|
+
import { a as resolveTexture, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "./loader-C-6QN3xv.js";
|
|
7
7
|
import { c as toFloatTexture, s as toByteTexture, t as FloatTexture } from "./blend-Qvrn6YgK.js";
|
|
8
8
|
import { a as LightingProfileName, i as LightingProfile, r as LightSource, u as lightsForProfile } from "./lighting-3FGRC3Af.js";
|
|
9
|
-
import { a as pointResize, i as boxDownscale, n as RenderOptions, o as renderModel, r as RenderedFrames, s as renderModelFrames, t as ItemRenderError } from "./renderer-
|
|
9
|
+
import { a as pointResize, i as boxDownscale, n as RenderOptions, o as renderModel, r as RenderedFrames, s as renderModelFrames, t as ItemRenderError } from "./renderer-nbMCw1Pl.js";
|
|
10
10
|
import { c as defaultProperties, i as ItemRenderInstruction, l as evaluateItemModel, n as InvalidItemDefinitionError, o as TintDefinition, r as ItemProperties, s as UNKNOWN_MODEL } from "./definition-BwX6Xxv0.js";
|
|
11
|
-
import {
|
|
12
|
-
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, t as DYE_COLORS } from "./tints-
|
|
11
|
+
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "./discovery-D89pVVJA.js";
|
|
12
|
+
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, t as DYE_COLORS } from "./tints-txt-8xI5.js";
|
|
13
13
|
import { i as EncodedIcon, n as EncodeOptions, o as encodeAnimatedIcon, r as EncodedAnimatedIcon, s as encodeIcon, t as AnimatedEncodeOptions } from "./encode-C5kdAm45.js";
|
|
14
14
|
import { t as minifyStylesheet } from "./minify-CIV6enbr.js";
|
|
15
15
|
import { a as compareVersions, o as eraForVersion, s as prepareVersionResources } from "./prepare-wfWtaz_X.js";
|
|
16
16
|
import { i as prepareModResources } from "./prepare-DnnGGv9k.js";
|
|
17
17
|
import { i as itemClass, n as StylesheetOptions, r as generateStylesheet, t as ItemStyle } from "./stylesheet-i-t_7sZ7.js";
|
|
18
|
-
import { i as run, n as RunOptions, r as RunResult, t as ItemFailure } from "./run-
|
|
18
|
+
import { i as run, n as RunOptions, r as RunResult, t as ItemFailure } from "./run-BlSZw9Qk.js";
|
|
19
19
|
import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager } from "./jar-6T3xdgaL.js";
|
|
20
|
-
export { type AnimatedEncodeOptions, AnimatedTexture, type AtlasResolver, type AtlasSource, AtlasSourceError, DYE_COLORS, type DiscoveredItem, type EncodeOptions, type EncodedAnimatedIcon, type EncodedIcon, type FloatTexture, FolderResourceManager, InvalidItemDefinitionError, InvalidResourceLocatorError, InvalidTinterDefinitionError, type ItemFailure, type ItemProperties, ItemRenderError, type ItemRenderInstruction, ItemResolutionError, type ItemStyle, JarResourceManager, LayeredResourceManager, type LightSource, LightingProfile, type LightingProfileName, ModelLoader, ModelResolutionError, type RenderOptions, type RenderedFrames, type ResolvedModel, type ResolvedSprite, ResourceKind, type ResourceKindName, ResourceLocator, type ResourceManager, type RunOptions, type RunResult, type StylesheetOptions, type Texture, TextureLoader, type TextureMeta, TextureResolutionError, type TintDefinition, UNKNOWN_MODEL, UnsafeJarError, boxDownscale, builtinDynamicResources, compareVersions, createAtlasResolver, defaultProperties, discoverItems, encodeAnimatedIcon, encodeIcon, eraForVersion, evaluateItemModel, generateStylesheet, isUnsafeEntryPath, itemClass, lightsForProfile, minifyStylesheet, parseAtlasSources, parseTintValue, pointResize, prepareModResources, prepareVersionResources, renderModel, renderModelFrames, resolveItem, resolveTexture, resolveTint, resolveTints, run, salvageJson, toByteTexture, toFloatTexture };
|
|
20
|
+
export { type AnimatedEncodeOptions, AnimatedTexture, type AtlasResolver, type AtlasSource, AtlasSourceError, DYE_COLORS, type DiscoveredItem, type EncodeOptions, type EncodedAnimatedIcon, type EncodedIcon, type FloatTexture, FolderResourceManager, InvalidItemDefinitionError, InvalidResourceLocatorError, InvalidTinterDefinitionError, type ItemDiscoveryOptions, type ItemFailure, type ItemProperties, ItemRenderError, type ItemRenderInstruction, ItemResolutionError, type ItemStyle, JarResourceManager, LayeredResourceManager, type LightSource, LightingProfile, type LightingProfileName, ModelLoader, ModelResolutionError, type RenderOptions, type RenderedFrames, type ResolvedModel, type ResolvedSprite, ResourceKind, type ResourceKindName, ResourceLocator, type ResourceManager, type RunOptions, type RunResult, type StylesheetOptions, type Texture, TextureLoader, type TextureMeta, TextureResolutionError, type TintDefinition, UNKNOWN_MODEL, UnsafeJarError, boxDownscale, builtinDynamicResources, compareVersions, createAtlasResolver, defaultProperties, discoverItems, encodeAnimatedIcon, encodeIcon, eraForVersion, evaluateItemModel, generateStylesheet, isUnsafeEntryPath, itemClass, lightsForProfile, minifyStylesheet, parseAtlasSources, parseTintValue, pointResize, prepareModResources, prepareVersionResources, renderModel, renderModelFrames, resolveItem, resolveTexture, resolveTint, resolveTints, run, salvageJson, toByteTexture, toFloatTexture };
|
package/dist/index.js
CHANGED
|
@@ -4,17 +4,17 @@ import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager }
|
|
|
4
4
|
import { o as createAtlasResolver, s as parseAtlasSources, t as AtlasSourceError } from "./sources-Bxk-WOzH.js";
|
|
5
5
|
import { a as builtinDynamicResources } from "./generators-CcVRG30y.js";
|
|
6
6
|
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-3MBm8ar_.js";
|
|
7
|
-
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "./discovery-
|
|
8
|
-
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-
|
|
7
|
+
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "./discovery-iph0P2F2.js";
|
|
8
|
+
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-A-BZa8J4.js";
|
|
9
9
|
import { o as toByteTexture, s as toFloatTexture } from "./blend-CHP2-j9U.js";
|
|
10
10
|
import { n as encodeIcon, t as encodeAnimatedIcon } from "./encode-3u49i-eD.js";
|
|
11
11
|
import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
|
|
12
12
|
import { n as itemClass, t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
|
|
13
13
|
import { c as lightsForProfile, r as LightingProfile } from "./lighting--5myudVu.js";
|
|
14
|
-
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-
|
|
14
|
+
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-BeOinVC8.js";
|
|
15
15
|
import { a as resolveTints, i as resolveTint, n as InvalidTinterDefinitionError, r as parseTintValue, t as DYE_COLORS } from "./tints-BtbHegpI.js";
|
|
16
16
|
import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-CBzn3Koc.js";
|
|
17
|
-
import { t as run } from "./run-
|
|
17
|
+
import { t as run } from "./run-DI-cB38y.js";
|
|
18
18
|
import { a as prepareVersionResources, i as eraForVersion, r as compareVersions } from "./prepare-DROxBZp1.js";
|
|
19
19
|
import { n as prepareModResources } from "./prepare-Bvc5ve2m.js";
|
|
20
20
|
export { AnimatedTexture, AtlasSourceError, DYE_COLORS, FolderResourceManager, InvalidItemDefinitionError, InvalidResourceLocatorError, InvalidTinterDefinitionError, ItemRenderError, ItemResolutionError, JarResourceManager, LayeredResourceManager, LightingProfile, ModelLoader, ModelResolutionError, ResourceKind, ResourceLocator, TextureLoader, TextureResolutionError, UNKNOWN_MODEL, UnsafeJarError, boxDownscale, builtinDynamicResources, compareVersions, createAtlasResolver, defaultProperties, discoverItems, encodeAnimatedIcon, encodeIcon, eraForVersion, evaluateItemModel, generateStylesheet, isUnsafeEntryPath, itemClass, lightsForProfile, minifyStylesheet, parseAtlasSources, parseTintValue, pointResize, prepareModResources, prepareVersionResources, renderModel, renderModelFrames, resolveItem, resolveTexture, resolveTint, resolveTints, run, salvageJson, toByteTexture, toFloatTexture };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { DiscoveredItem, ItemResolutionError, discoverItems, resolveItem };
|
|
1
|
+
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "../discovery-D89pVVJA.js";
|
|
2
|
+
export { DiscoveredItem, ItemDiscoveryOptions, ItemResolutionError, discoverItems, resolveItem };
|
package/dist/items/discovery.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "../discovery-
|
|
1
|
+
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "../discovery-iph0P2F2.js";
|
|
2
2
|
export { ItemResolutionError, discoverItems, resolveItem };
|
|
@@ -251,10 +251,20 @@ function salvageJson(text) {
|
|
|
251
251
|
var ModelLoader = class {
|
|
252
252
|
resources;
|
|
253
253
|
cache = /* @__PURE__ */ new Map();
|
|
254
|
+
jsonCache = /* @__PURE__ */ new Map();
|
|
254
255
|
constructor(resources) {
|
|
255
256
|
this.resources = resources;
|
|
256
257
|
}
|
|
257
|
-
|
|
258
|
+
readModelJson(locator) {
|
|
259
|
+
const key = locator.toString();
|
|
260
|
+
let pending = this.jsonCache.get(key);
|
|
261
|
+
if (!pending) {
|
|
262
|
+
pending = this.loadModelJson(locator);
|
|
263
|
+
this.jsonCache.set(key, pending);
|
|
264
|
+
}
|
|
265
|
+
return pending;
|
|
266
|
+
}
|
|
267
|
+
async loadModelJson(locator) {
|
|
258
268
|
const raw = await this.resources.getResource("model", locator);
|
|
259
269
|
if (raw === null) throw new ModelResolutionError(`Model not found: ${locator}`);
|
|
260
270
|
let json;
|
|
@@ -53,8 +53,10 @@ declare function salvageJson(text: string): unknown | null;
|
|
|
53
53
|
declare class ModelLoader {
|
|
54
54
|
private readonly resources;
|
|
55
55
|
private readonly cache;
|
|
56
|
+
private readonly jsonCache;
|
|
56
57
|
constructor(resources: ResourceManager);
|
|
57
58
|
private readModelJson;
|
|
59
|
+
private loadModelJson;
|
|
58
60
|
private resolve;
|
|
59
61
|
/** Load and flatten a model by locator string (e.g. `minecraft:item/stone`). */
|
|
60
62
|
load(locator: string | ResourceLocator): Promise<ResolvedModel>;
|
package/dist/models/loader.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resolveTexture, i as flattenLoaderModel, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "../loader-
|
|
1
|
+
import { a as resolveTexture, i as flattenLoaderModel, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "../loader-C-6QN3xv.js";
|
|
2
2
|
export { ModelLoader, ModelResolutionError, ResolvedModel, flattenLoaderModel, resolveTexture, salvageJson };
|
package/dist/models/loader.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, r as flattenLoaderModel, t as ModelLoader } from "../loader-
|
|
1
|
+
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, r as flattenLoaderModel, t as ModelLoader } from "../loader-A-BZa8J4.js";
|
|
2
2
|
export { ModelLoader, ModelResolutionError, flattenLoaderModel, resolveTexture, salvageJson };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
//#region src/render/rasterizer.ts
|
|
2
2
|
function createFaceBuffer(width, height) {
|
|
3
3
|
return {
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0,
|
|
4
6
|
width,
|
|
5
7
|
height,
|
|
6
8
|
colors: new Float64Array(width * height * 4),
|
|
@@ -8,6 +10,43 @@ function createFaceBuffer(width, height) {
|
|
|
8
10
|
};
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
13
|
+
* Retain only the rectangle containing visible pixels. Complex block models can
|
|
14
|
+
* contain thousands of tiny faces; keeping a full icon-sized color/depth buffer
|
|
15
|
+
* for each one turns a 64px render into gigabytes of transient memory.
|
|
16
|
+
*/
|
|
17
|
+
function compactFaceBuffer(buffer) {
|
|
18
|
+
let minX = buffer.width;
|
|
19
|
+
let minY = buffer.height;
|
|
20
|
+
let maxX = -1;
|
|
21
|
+
let maxY = -1;
|
|
22
|
+
for (let y = 0; y < buffer.height; y++) for (let x = 0; x < buffer.width; x++) {
|
|
23
|
+
if (buffer.colors[(y * buffer.width + x) * 4 + 3] <= 0) continue;
|
|
24
|
+
minX = Math.min(minX, x);
|
|
25
|
+
minY = Math.min(minY, y);
|
|
26
|
+
maxX = Math.max(maxX, x);
|
|
27
|
+
maxY = Math.max(maxY, y);
|
|
28
|
+
}
|
|
29
|
+
if (maxX < minX || maxY < minY) return null;
|
|
30
|
+
const width = maxX - minX + 1;
|
|
31
|
+
const height = maxY - minY + 1;
|
|
32
|
+
const colors = new Float64Array(width * height * 4);
|
|
33
|
+
const depths = new Float64Array(width * height);
|
|
34
|
+
for (let y = 0; y < height; y++) {
|
|
35
|
+
const sourcePixel = (minY + y) * buffer.width + minX;
|
|
36
|
+
const targetPixel = y * width;
|
|
37
|
+
colors.set(buffer.colors.subarray(sourcePixel * 4, (sourcePixel + width) * 4), targetPixel * 4);
|
|
38
|
+
depths.set(buffer.depths.subarray(sourcePixel, sourcePixel + width), targetPixel);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
x: buffer.x + minX,
|
|
42
|
+
y: buffer.y + minY,
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
45
|
+
colors,
|
|
46
|
+
depths
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
11
50
|
* Emulates ImagickPixelIterator's cursor, including the quirk the whole
|
|
12
51
|
* corpus is rendered with: next() on an unconsumed iterator (fresh or just
|
|
13
52
|
* rewound) fetches row 0 instead of advancing. Upstream's moveIterator never
|
|
@@ -136,4 +175,4 @@ function drawTexturedTriangle(p1in, p2in, p3in, buffer, texture, cursor = new Ro
|
|
|
136
175
|
}
|
|
137
176
|
}
|
|
138
177
|
//#endregion
|
|
139
|
-
export { phpRound as i,
|
|
178
|
+
export { phpRound as a, drawTexturedTriangle as i, compactFaceBuffer as n, createFaceBuffer as r, RowCursor as t };
|
|
@@ -2,6 +2,9 @@ import { t as FloatTexture } from "./blend-Qvrn6YgK.js";
|
|
|
2
2
|
//#region src/render/rasterizer.d.ts
|
|
3
3
|
/** Per-face private color + depth buffers, image sized. */
|
|
4
4
|
interface FaceBuffer {
|
|
5
|
+
/** Position within the final image (full-size scratch buffers start at 0,0). */
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
5
8
|
width: number;
|
|
6
9
|
height: number;
|
|
7
10
|
/** RGBA float, overwritten (not blended) by the rasterizer. */
|
|
@@ -10,6 +13,12 @@ interface FaceBuffer {
|
|
|
10
13
|
depths: Float64Array;
|
|
11
14
|
}
|
|
12
15
|
declare function createFaceBuffer(width: number, height: number): FaceBuffer;
|
|
16
|
+
/**
|
|
17
|
+
* Retain only the rectangle containing visible pixels. Complex block models can
|
|
18
|
+
* contain thousands of tiny faces; keeping a full icon-sized color/depth buffer
|
|
19
|
+
* for each one turns a 64px render into gigabytes of transient memory.
|
|
20
|
+
*/
|
|
21
|
+
declare function compactFaceBuffer(buffer: FaceBuffer): FaceBuffer | null;
|
|
13
22
|
interface RasterPoint {
|
|
14
23
|
x: number;
|
|
15
24
|
y: number;
|
|
@@ -38,4 +47,4 @@ declare class RowCursor {
|
|
|
38
47
|
declare function phpRound(value: number): number;
|
|
39
48
|
declare function drawTexturedTriangle(p1in: RasterPoint, p2in: RasterPoint, p3in: RasterPoint, buffer: FaceBuffer, texture: FloatTexture, cursor?: RowCursor): void;
|
|
40
49
|
//#endregion
|
|
41
|
-
export {
|
|
50
|
+
export { createFaceBuffer as a, compactFaceBuffer as i, RasterPoint as n, drawTexturedTriangle as o, RowCursor as r, phpRound as s, FaceBuffer as t };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
2
|
+
import { o as createAtlasResolver, r as PalettedPermutationsSource, s as parseAtlasSources } from "./sources-Bxk-WOzH.js";
|
|
3
|
+
//#region src/atlas/registry.ts
|
|
4
|
+
/**
|
|
5
|
+
* Collects every `atlases/*.json` across namespaces into one resolver.
|
|
6
|
+
* Load order matches upstream: sources from later-loaded files win, so the
|
|
7
|
+
* resolver checks sources in reverse. Unknown source types are skipped with a
|
|
8
|
+
* warning rather than failing the run (mods ship experimental types).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Some mods generate flat item-trim permutations in code rather than declaring
|
|
12
|
+
* them in an atlas. Infer only the exact Minecraft convention when all three
|
|
13
|
+
* inputs exist: `<type>_trim.png`, `trim_palette.png`, and the requested color
|
|
14
|
+
* palette. Direct files and authored atlas sources still take precedence.
|
|
15
|
+
*/
|
|
16
|
+
var InferredItemTrimSource = class {
|
|
17
|
+
cache = /* @__PURE__ */ new Map();
|
|
18
|
+
resources;
|
|
19
|
+
loadTexture;
|
|
20
|
+
constructor(resources, loadTexture) {
|
|
21
|
+
this.resources = resources;
|
|
22
|
+
this.loadTexture = loadTexture;
|
|
23
|
+
}
|
|
24
|
+
async firstTexture(candidates) {
|
|
25
|
+
for (const candidate of candidates) if (await this.resources.hasResource("texture", candidate)) return candidate;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
create(locator) {
|
|
29
|
+
const match = /^(trims\/items\/.+_trim)_(.+)$/.exec(locator.path);
|
|
30
|
+
if (!match) return Promise.resolve(null);
|
|
31
|
+
const [, basePath, variant] = match;
|
|
32
|
+
return (async () => {
|
|
33
|
+
const base = new ResourceLocator(locator.namespace, basePath);
|
|
34
|
+
if (!await this.resources.hasResource("texture", base)) return null;
|
|
35
|
+
const key = await this.firstTexture([new ResourceLocator(locator.namespace, "trims/color_palettes/trim_palette"), ResourceLocator.parse("minecraft:trims/color_palettes/trim_palette")]);
|
|
36
|
+
const palette = await this.firstTexture([new ResourceLocator(locator.namespace, `trims/color_palettes/${variant}`), ResourceLocator.parse(`minecraft:trims/color_palettes/${variant}`)]);
|
|
37
|
+
if (!key || !palette) return null;
|
|
38
|
+
return new PalettedPermutationsSource({
|
|
39
|
+
textures: [base.toString()],
|
|
40
|
+
palette_key: key.toString(),
|
|
41
|
+
permutations: { [variant]: palette.toString() }
|
|
42
|
+
}, this.loadTexture);
|
|
43
|
+
})();
|
|
44
|
+
}
|
|
45
|
+
source(locator) {
|
|
46
|
+
const key = locator.toString();
|
|
47
|
+
let pending = this.cache.get(key);
|
|
48
|
+
if (!pending) {
|
|
49
|
+
pending = this.create(locator);
|
|
50
|
+
this.cache.set(key, pending);
|
|
51
|
+
}
|
|
52
|
+
return pending;
|
|
53
|
+
}
|
|
54
|
+
async has(locator) {
|
|
55
|
+
return await this.source(locator) !== null;
|
|
56
|
+
}
|
|
57
|
+
async resolve(locator) {
|
|
58
|
+
return (await this.source(locator))?.resolve(locator) ?? null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
async function loadAtlasResolver(resources, loadTexture, onWarning) {
|
|
62
|
+
const sources = [new InferredItemTrimSource(resources, loadTexture)];
|
|
63
|
+
for (const namespace of await resources.listNamespaces()) {
|
|
64
|
+
const atlasFiles = await resources.listResources("atlas", namespace);
|
|
65
|
+
atlasFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
66
|
+
for (const file of atlasFiles) {
|
|
67
|
+
const copies = await resources.getAllResources("atlas", file);
|
|
68
|
+
copies.reverse();
|
|
69
|
+
for (const raw of copies) try {
|
|
70
|
+
const json = JSON.parse(raw.toString("utf8"));
|
|
71
|
+
sources.push(...parseAtlasSources(namespace, json, loadTexture, (type) => onWarning?.(`Skipping unknown atlas source type ${type} in ${file}`), (locator) => resources.hasResource("texture", locator)));
|
|
72
|
+
} catch (err) {
|
|
73
|
+
onWarning?.(`Unparseable atlas ${file}: ${err.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return createAtlasResolver(sources);
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { loadAtlasResolver as t };
|
package/dist/render/compose.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as FloatTexture } from "../blend-Qvrn6YgK.js";
|
|
2
|
-
import { t as FaceBuffer } from "../rasterizer-
|
|
2
|
+
import { t as FaceBuffer } from "../rasterizer-Dh35qXbn.js";
|
|
3
3
|
//#region src/render/compose.d.ts
|
|
4
4
|
declare function combineFaceBuffers(width: number, height: number, faces: FaceBuffer[]): FloatTexture;
|
|
5
5
|
//#endregion
|
package/dist/render/compose.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as combineFaceBuffers } from "../compose-
|
|
1
|
+
import { t as combineFaceBuffers } from "../compose-qjhyBvnS.js";
|
|
2
2
|
export { combineFaceBuffers };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as ResourceManager } from "../manager-CoZaeQTu.js";
|
|
2
2
|
import { i as TextureLoader } from "../loader-TFFNV4Jl.js";
|
|
3
|
-
import { t as ModelLoader } from "../loader-
|
|
3
|
+
import { t as ModelLoader } from "../loader-C-6QN3xv.js";
|
|
4
4
|
import { t as FloatTexture } from "../blend-Qvrn6YgK.js";
|
|
5
|
-
import { n as TintColor } from "../face-
|
|
6
|
-
import { n as RenderOptions } from "../renderer-
|
|
5
|
+
import { n as TintColor } from "../face-CpVdnf-w.js";
|
|
6
|
+
import { n as RenderOptions } from "../renderer-nbMCw1Pl.js";
|
|
7
7
|
//#region src/render/entity-fallback.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Dyed variants of vanilla items whose models mods generate at runtime (quark's
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as renderEntityFallback, r as spawnEggTints, t as renderDyedVariantFallback } from "../entity-fallback-
|
|
1
|
+
import { n as renderEntityFallback, r as spawnEggTints, t as renderDyedVariantFallback } from "../entity-fallback-CdCVEG6X.js";
|
|
2
2
|
export { renderDyedVariantFallback, renderEntityFallback, spawnEggTints };
|
package/dist/render/face.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as renderFace, n as TintColor, r as faceMaxZ, t as RenderableFace } from "../face-
|
|
1
|
+
import { i as renderFace, n as TintColor, r as faceMaxZ, t as RenderableFace } from "../face-CpVdnf-w.js";
|
|
2
2
|
export { RenderableFace, TintColor, faceMaxZ, renderFace };
|
package/dist/render/face.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as renderFace, t as faceMaxZ } from "../face-
|
|
1
|
+
import { n as renderFace, t as faceMaxZ } from "../face-D-N1amV4.js";
|
|
2
2
|
export { faceMaxZ, renderFace };
|
package/dist/render/geo.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { a as ResourceManager } from "../manager-CoZaeQTu.js";
|
|
|
3
3
|
import { i as TextureLoader } from "../loader-TFFNV4Jl.js";
|
|
4
4
|
import { t as FloatTexture } from "../blend-Qvrn6YgK.js";
|
|
5
5
|
import { n as FaceGeometry } from "../geometry-BSVmKx5b.js";
|
|
6
|
-
import { n as RenderOptions } from "../renderer-
|
|
6
|
+
import { n as RenderOptions } from "../renderer-nbMCw1Pl.js";
|
|
7
7
|
//#region src/render/geo.d.ts
|
|
8
8
|
interface GeoCube {
|
|
9
9
|
origin?: number[];
|
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-u8rndjLA.js";
|
|
2
2
|
export { findGeoForItem, geoToFaces, parseGeo, renderGeo };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as TextureLoader } from "../loader-TFFNV4Jl.js";
|
|
2
|
-
import { n as TintColor } from "../face-
|
|
2
|
+
import { n as TintColor } from "../face-CpVdnf-w.js";
|
|
3
3
|
//#region src/render/legacy-tints.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Tints for a model rendered without an item definition (pre-1.21.4 eras and
|
package/dist/render/obj.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as ResourceManager } from "../manager-CoZaeQTu.js";
|
|
2
2
|
import { i as TextureLoader } from "../loader-TFFNV4Jl.js";
|
|
3
|
-
import { r as ResolvedModel } from "../loader-
|
|
3
|
+
import { r as ResolvedModel } from "../loader-C-6QN3xv.js";
|
|
4
4
|
import { t as FloatTexture } from "../blend-Qvrn6YgK.js";
|
|
5
5
|
import { n as Vec3 } from "../vector-DRKRi4--.js";
|
|
6
|
-
import { n as RenderOptions } from "../renderer-
|
|
6
|
+
import { n as RenderOptions } from "../renderer-nbMCw1Pl.js";
|
|
7
7
|
//#region src/render/obj.d.ts
|
|
8
8
|
interface ObjTriangle {
|
|
9
9
|
positions: [Vec3, Vec3, Vec3];
|
package/dist/render/obj.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as renderObjModel, o as parseMtl, s as parseObj } from "../renderer-
|
|
1
|
+
import { c as renderObjModel, o as parseMtl, s as parseObj } from "../renderer-BeOinVC8.js";
|
|
2
2
|
export { parseMtl, parseObj, renderObjModel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { FaceBuffer, RasterPoint, RowCursor, createFaceBuffer, drawTexturedTriangle, phpRound };
|
|
1
|
+
import { a as createFaceBuffer, i as compactFaceBuffer, n as RasterPoint, o as drawTexturedTriangle, r as RowCursor, s as phpRound, t as FaceBuffer } from "../rasterizer-Dh35qXbn.js";
|
|
2
|
+
export { FaceBuffer, RasterPoint, RowCursor, compactFaceBuffer, createFaceBuffer, drawTexturedTriangle, phpRound };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { RowCursor, createFaceBuffer, drawTexturedTriangle, phpRound };
|
|
1
|
+
import { a as phpRound, i as drawTexturedTriangle, n as compactFaceBuffer, r as createFaceBuffer, t as RowCursor } from "../rasterizer-BHWDrmGz.js";
|
|
2
|
+
export { RowCursor, compactFaceBuffer, createFaceBuffer, drawTexturedTriangle, phpRound };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as pointResize, i as boxDownscale, n as RenderOptions, o as renderModel, r as RenderedFrames, s as renderModelFrames, t as ItemRenderError } from "../renderer-
|
|
1
|
+
import { a as pointResize, i as boxDownscale, n as RenderOptions, o as renderModel, r as RenderedFrames, s as renderModelFrames, t as ItemRenderError } from "../renderer-nbMCw1Pl.js";
|
|
2
2
|
export { ItemRenderError, RenderOptions, RenderedFrames, boxDownscale, pointResize, renderModel, renderModelFrames };
|
package/dist/render/renderer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "../renderer-
|
|
1
|
+
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "../renderer-BeOinVC8.js";
|
|
2
2
|
export { ItemRenderError, boxDownscale, pointResize, renderModel, renderModelFrames };
|
package/dist/render/tints.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, r as TintContext, t as DYE_COLORS } from "../tints-
|
|
1
|
+
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, r as TintContext, t as DYE_COLORS } from "../tints-txt-8xI5.js";
|
|
2
2
|
export { DYE_COLORS, InvalidTinterDefinitionError, TintContext, parseTintValue, resolveTint, resolveTints };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
2
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-
|
|
3
|
+
import { i as resolveTexture } from "./loader-A-BZa8J4.js";
|
|
4
4
|
import { a as tintTexture, n as cloneFloatTexture, r as darkenTexture, s as toFloatTexture, t as blendPixel } from "./blend-CHP2-j9U.js";
|
|
5
|
-
import { t as combineFaceBuffers } from "./compose-
|
|
6
|
-
import {
|
|
7
|
-
import { n as renderFace, t as faceMaxZ } from "./face-
|
|
5
|
+
import { t as combineFaceBuffers } from "./compose-qjhyBvnS.js";
|
|
6
|
+
import { a as phpRound, i as drawTexturedTriangle, r as createFaceBuffer, t as RowCursor } from "./rasterizer-BHWDrmGz.js";
|
|
7
|
+
import { n as renderFace, t as faceMaxZ } from "./face-D-N1amV4.js";
|
|
8
8
|
import { t as paintBucketFluid } from "./fluid-bucket-D-GpUQjg.js";
|
|
9
9
|
import { r as buildElementFaces } from "./geometry-uIDha8S4.js";
|
|
10
10
|
import { c as lightsForProfile } from "./lighting--5myudVu.js";
|
|
@@ -394,17 +394,32 @@ async function renderElementModel(model, textures, renderSize, options) {
|
|
|
394
394
|
async function renderElementModelWith(model, supplier, renderSize, options) {
|
|
395
395
|
const lights = lightsForProfile(options.lightingProfile);
|
|
396
396
|
const light = model.elementsGuiLight === "side" ? lights.side : lights.front;
|
|
397
|
+
const loadedTextures = /* @__PURE__ */ new Map();
|
|
398
|
+
const floatTextures = /* @__PURE__ */ new Map();
|
|
399
|
+
const load = (reference) => {
|
|
400
|
+
let pending = loadedTextures.get(reference);
|
|
401
|
+
if (!pending) {
|
|
402
|
+
pending = supplier(reference);
|
|
403
|
+
loadedTextures.set(reference, pending);
|
|
404
|
+
}
|
|
405
|
+
return pending;
|
|
406
|
+
};
|
|
397
407
|
const faces = [];
|
|
398
408
|
let skippedFaces = 0;
|
|
399
409
|
for (const element of model.elements) for (const geometry of buildElementFaces(element)) {
|
|
400
|
-
const texture = await
|
|
410
|
+
const texture = await load(geometry.textureRef);
|
|
401
411
|
if (!texture) {
|
|
402
412
|
skippedFaces++;
|
|
403
413
|
continue;
|
|
404
414
|
}
|
|
415
|
+
let float = floatTextures.get(texture);
|
|
416
|
+
if (!float) {
|
|
417
|
+
float = toFloatTexture(texture);
|
|
418
|
+
floatTextures.set(texture, float);
|
|
419
|
+
}
|
|
405
420
|
faces.push({
|
|
406
421
|
geometry,
|
|
407
|
-
texture:
|
|
422
|
+
texture: float,
|
|
408
423
|
light,
|
|
409
424
|
tint: geometry.tintIndex !== null ? options.tints?.[geometry.tintIndex] ?? null : null,
|
|
410
425
|
maxZ: faceMaxZ(geometry)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as ResourceManager } from "./manager-CoZaeQTu.js";
|
|
2
2
|
import { i as TextureLoader } from "./loader-TFFNV4Jl.js";
|
|
3
|
-
import { r as ResolvedModel } from "./loader-
|
|
3
|
+
import { r as ResolvedModel } from "./loader-C-6QN3xv.js";
|
|
4
4
|
import { t as FloatTexture } from "./blend-Qvrn6YgK.js";
|
|
5
5
|
import { t as Mat4 } from "./vector-DRKRi4--.js";
|
|
6
6
|
import { a as LightingProfileName } from "./lighting-3FGRC3Af.js";
|
|
7
|
-
import { n as TintColor } from "./face-
|
|
7
|
+
import { n as TintColor } from "./face-CpVdnf-w.js";
|
|
8
8
|
//#region src/render/renderer.d.ts
|
|
9
9
|
interface RenderOptions {
|
|
10
10
|
size: number;
|
|
@@ -24,6 +24,12 @@ interface RunOptions {
|
|
|
24
24
|
minify?: boolean;
|
|
25
25
|
/** In-flight items (encode overlaps on libvips' threadpool; default 8). */
|
|
26
26
|
concurrency?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Drop classic item models with no matching translation (default true).
|
|
29
|
+
* Disable for a prepared asset tree whose own preprocessing has already
|
|
30
|
+
* filtered synthesized models and where every real model must be retained.
|
|
31
|
+
*/
|
|
32
|
+
filterUntranslatedModels?: boolean;
|
|
27
33
|
lightingProfile?: LightingProfileName;
|
|
28
34
|
itemList?: boolean;
|
|
29
35
|
onProgress?: (done: number, total: number, id: string, error?: string) => void;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
2
2
|
import { n as LayeredResourceManager, t as FolderResourceManager } from "./manager-dfI7b9N4.js";
|
|
3
|
-
import { t as loadAtlasResolver } from "./registry-
|
|
3
|
+
import { t as loadAtlasResolver } from "./registry-B9TcjVbs.js";
|
|
4
4
|
import { a as builtinDynamicResources } from "./generators-CcVRG30y.js";
|
|
5
5
|
import { a as defaultProperties } from "./definition-3MBm8ar_.js";
|
|
6
|
-
import { n as discoverItems, r as resolveItem } from "./discovery-
|
|
7
|
-
import { t as ModelLoader } from "./loader-
|
|
6
|
+
import { n as discoverItems, r as resolveItem } from "./discovery-iph0P2F2.js";
|
|
7
|
+
import { t as ModelLoader } from "./loader-A-BZa8J4.js";
|
|
8
8
|
import { s as toFloatTexture, t as blendPixel } from "./blend-CHP2-j9U.js";
|
|
9
9
|
import { r as encodeRasterAsset, t as encodeAnimatedIcon } from "./encode-3u49i-eD.js";
|
|
10
10
|
import { t as classifyItemStyle } from "./item-styles-DJ3LWZS2.js";
|
|
11
11
|
import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
|
|
12
12
|
import { t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
|
|
13
|
-
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize } from "./renderer-
|
|
14
|
-
import { n as renderEntityFallback, r as spawnEggTints, t as renderDyedVariantFallback } from "./entity-fallback-
|
|
15
|
-
import { i as renderGeo, t as findGeoForItem } from "./geo-
|
|
13
|
+
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize } from "./renderer-BeOinVC8.js";
|
|
14
|
+
import { n as renderEntityFallback, r as spawnEggTints, t as renderDyedVariantFallback } from "./entity-fallback-CdCVEG6X.js";
|
|
15
|
+
import { i as renderGeo, t as findGeoForItem } from "./geo-u8rndjLA.js";
|
|
16
16
|
import { t as legacyTintsForChain } from "./legacy-tints-B09J0Rxh.js";
|
|
17
17
|
import { a as resolveTints } from "./tints-BtbHegpI.js";
|
|
18
18
|
import { n as TextureLoader } from "./loader-CBzn3Koc.js";
|
|
@@ -50,7 +50,7 @@ async function run(options) {
|
|
|
50
50
|
seen.add(placeholder);
|
|
51
51
|
ids.push(placeholder);
|
|
52
52
|
}
|
|
53
|
-
for (const namespace of namespaces) for (const item of await discoverItems(resources, namespace)) {
|
|
53
|
+
for (const namespace of namespaces) for (const item of await discoverItems(resources, namespace, { filterUntranslatedModels: options.filterUntranslatedModels })) {
|
|
54
54
|
if (seen.has(item.id)) continue;
|
|
55
55
|
if (options.builtin && !await itemExistsIn(options.resources, item.id)) continue;
|
|
56
56
|
seen.add(item.id);
|
package/dist/run.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { l as evaluateItemModel } from "./definition-BwX6Xxv0.js";
|
|
2
|
-
import { i as run, n as RunOptions, r as RunResult, t as ItemFailure } from "./run-
|
|
2
|
+
import { i as run, n as RunOptions, r as RunResult, t as ItemFailure } from "./run-BlSZw9Qk.js";
|
|
3
3
|
export { ItemFailure, RunOptions, RunResult, evaluateItemModel, run };
|
package/dist/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as TextureLoader } from "./loader-TFFNV4Jl.js";
|
|
2
|
-
import { n as TintColor } from "./face-
|
|
2
|
+
import { n as TintColor } from "./face-CpVdnf-w.js";
|
|
3
3
|
import { o as TintDefinition } from "./definition-BwX6Xxv0.js";
|
|
4
4
|
//#region src/render/tints.d.ts
|
|
5
5
|
declare class InvalidTinterDefinitionError extends Error {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodecraft/rendermite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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",
|
package/dist/compose-cph4bfdr.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { t as blendPixel } from "./blend-CHP2-j9U.js";
|
|
2
|
-
//#region src/render/compose.ts
|
|
3
|
-
/**
|
|
4
|
-
* Per-pixel painter's compositing, mirroring upstream Model::combineFaceImages:
|
|
5
|
-
* at each pixel, faces sorted ascending by that pixel's depth value (0 where the
|
|
6
|
-
* rasterizer never wrote depth — the overdraw band relies on sorting beneath),
|
|
7
|
-
* then source-over blended in that order when alpha > 0.
|
|
8
|
-
*/
|
|
9
|
-
function combineFaceBuffers(width, height, faces) {
|
|
10
|
-
const out = new Float64Array(width * height * 4);
|
|
11
|
-
const order = [...faces];
|
|
12
|
-
for (let pixel = 0; pixel < width * height; pixel++) {
|
|
13
|
-
order.sort((a, b) => a.depths[pixel] - b.depths[pixel]);
|
|
14
|
-
const offset = pixel * 4;
|
|
15
|
-
for (const face of order) {
|
|
16
|
-
const alpha = face.colors[offset + 3];
|
|
17
|
-
if (alpha > 0) blendPixel(out, offset, face.colors[offset], face.colors[offset + 1], face.colors[offset + 2], alpha);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
width,
|
|
22
|
-
height,
|
|
23
|
-
data: out
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { combineFaceBuffers as t };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { o as createAtlasResolver, s as parseAtlasSources } from "./sources-Bxk-WOzH.js";
|
|
2
|
-
//#region src/atlas/registry.ts
|
|
3
|
-
/**
|
|
4
|
-
* Collects every `atlases/*.json` across namespaces into one resolver.
|
|
5
|
-
* Load order matches upstream: sources from later-loaded files win, so the
|
|
6
|
-
* resolver checks sources in reverse. Unknown source types are skipped with a
|
|
7
|
-
* warning rather than failing the run (mods ship experimental types).
|
|
8
|
-
*/
|
|
9
|
-
async function loadAtlasResolver(resources, loadTexture, onWarning) {
|
|
10
|
-
const sources = [];
|
|
11
|
-
for (const namespace of await resources.listNamespaces()) {
|
|
12
|
-
const atlasFiles = await resources.listResources("atlas", namespace);
|
|
13
|
-
atlasFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
14
|
-
for (const file of atlasFiles) {
|
|
15
|
-
const copies = await resources.getAllResources("atlas", file);
|
|
16
|
-
copies.reverse();
|
|
17
|
-
for (const raw of copies) try {
|
|
18
|
-
const json = JSON.parse(raw.toString("utf8"));
|
|
19
|
-
sources.push(...parseAtlasSources(namespace, json, loadTexture, (type) => onWarning?.(`Skipping unknown atlas source type ${type} in ${file}`), (locator) => resources.hasResource("texture", locator)));
|
|
20
|
-
} catch (err) {
|
|
21
|
-
onWarning?.(`Unparseable atlas ${file}: ${err.message}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return createAtlasResolver(sources);
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { loadAtlasResolver as t };
|