@nodecraft/rendermite 1.0.6 → 1.1.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/assets/README.md +6 -2
- package/assets/builtin/renderchest/models/item/trident.json +372 -0
- package/assets/builtin-legacy/renderchest/models/item/trident.json +372 -0
- package/assets/mod-models/README.md +130 -0
- package/assets/mod-models/ad_astra/models/item/tier_1_rocket.json +4559 -0
- package/assets/mod-models/ad_astra/models/item/tier_1_rover.json +6021 -0
- package/assets/mod-models/ad_astra/models/item/tier_2_rocket.json +6832 -0
- package/assets/mod-models/ad_astra/models/item/tier_3_rocket.json +8522 -0
- package/assets/mod-models/ad_astra/models/item/tier_4_rocket.json +7498 -0
- package/assets/mod-models/botania/models/item/avatar.json +574 -0
- package/assets/mod-models/botania/models/item/bellows.json +423 -0
- package/assets/mod-models/botania/models/item/brewery.json +894 -0
- package/assets/mod-models/botania/models/item/corporea_index.json +349 -0
- package/assets/mod-models/botania/models/item/gaia_pylon.json +1057 -0
- package/assets/mod-models/botania/models/item/hourglass.json +502 -0
- package/assets/mod-models/botania/models/item/mana_pylon.json +741 -0
- package/assets/mod-models/botania/models/item/natura_pylon.json +1057 -0
- package/assets/mod-models/botania/models/item/teru_teru_bozu.json +347 -0
- package/assets/mod-models/mekanism/models/item/atomic_disassembler.json +1391 -0
- package/assets/mod-models/mekanism/models/item/flamethrower.json +1926 -0
- package/assets/mod-models/mekanism/models/item/free_runners.json +595 -0
- package/assets/mod-models/mekanism/models/item/jetpack.json +1767 -0
- package/assets/mod-models/mekanism/models/item/scuba_mask.json +2305 -0
- package/assets/mod-models/mekanism/models/item/scuba_tank.json +833 -0
- package/assets/mod-tints/README.md +19 -0
- package/assets/mod-tints/mysticalagriculture/items/absorption_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/absorption_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/absorption_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/absorption_iv_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/absorption_v_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/attack_aoe_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/attack_aoe_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/attack_aoe_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/blindness_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/fire_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/flight_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/haste_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/haste_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/haste_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/health_boost_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/health_boost_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/health_boost_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/health_boost_iv_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/health_boost_v_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/hunger_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/jump_boost_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/jump_boost_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/jump_boost_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/luck_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/luck_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/luck_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/mining_aoe_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/mining_aoe_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/mining_aoe_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/mining_aoe_iv_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/mining_fatigue_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/nausea_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/night_vision_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/pathing_aoe_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/pathing_aoe_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/pathing_aoe_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/pathing_aoe_iv_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/poison_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/slow_falling_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/slowness_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/speed_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/speed_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/speed_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/step_assist_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/strength_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/strength_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/strength_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/tilling_aoe_i_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/tilling_aoe_ii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/tilling_aoe_iii_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/tilling_aoe_iv_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/water_breathing_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/weakness_resistance_augment.json +16 -0
- package/assets/mod-tints/mysticalagriculture/items/wither_resistance_augment.json +16 -0
- package/dist/atlas/registry.js +1 -1
- package/dist/blend-8lnfxtLe.d.ts +79 -0
- package/dist/blend-KXMclcHk.js +199 -0
- package/dist/blockstate-CdstnW2-.js +104 -0
- package/dist/{builtin-caYjESh0.js → builtin-WkWjATeh.js} +5 -1
- package/dist/builtin.d.ts +3 -1
- package/dist/builtin.js +2 -2
- package/dist/cli.js +5 -3
- package/dist/{compose-CQCb2LVv.js → compose-BGsNFR12.js} +1 -1
- package/dist/{definition-3MBm8ar_.js → definition-ColsvWrH.js} +20 -1
- package/dist/{definition-BwX6Xxv0.d.ts → definition-ricL7Jqf.d.ts} +2 -0
- package/dist/{discovery-0SM0cTLw.js → discovery-B9aqV_Rz.js} +13 -3
- package/dist/{discovery-wiJBGryo.d.ts → discovery-BPSUtdm4.d.ts} +1 -1
- package/dist/{encode-DaNQF28M.d.ts → encode-DNcXXvYe.d.ts} +1 -1
- package/dist/{encode-D6dQu2dJ.js → encode-LR9wxigC.js} +28 -12
- package/dist/{entity-fallback-BRCeGKBT.js → entity-fallback-BnFMSHS6.js} +180 -10
- package/dist/{face-DmCiHUd5.js → face-CMJ3b3Ae.js} +44 -18
- package/dist/face-cQ-pVHoe.d.ts +44 -0
- package/dist/{fluid-bucket-D-GpUQjg.js → fluid-bucket-BzoLofB_.js} +7 -2
- package/dist/{geo-Diky41Tw.js → geo-w9HHIrb5.js} +87 -13
- package/dist/{geometry-uIDha8S4.js → geometry-Bi-Bf5rb.js} +7 -1
- package/dist/{geometry-BSVmKx5b.d.ts → geometry-w0yQbzDZ.d.ts} +5 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +10 -10
- package/dist/items/blockstate.d.ts +23 -0
- package/dist/items/blockstate.js +2 -0
- package/dist/items/definition.d.ts +1 -1
- package/dist/items/definition.js +1 -1
- package/dist/items/discovery.d.ts +1 -1
- package/dist/items/discovery.js +1 -1
- package/dist/{loader-D22zZME7.d.ts → loader-DD83d80u.d.ts} +2 -1
- package/dist/{loader-B8NJO7pR.js → loader-DwkA9LR5.js} +267 -15
- package/dist/{loader-CfXMxcEV.js → loader-Lb0ZeILz.js} +19 -7
- package/dist/models/loader.d.ts +1 -1
- package/dist/models/loader.js +1 -1
- package/dist/models/types.d.ts +1 -1
- package/dist/models-BKxGkPS7.js +18 -0
- package/dist/mods/models.d.ts +5 -0
- package/dist/mods/models.js +2 -0
- package/dist/mods/prepare.d.ts +1 -1
- package/dist/mods/prepare.js +1 -1
- package/dist/mods/tints.js +1 -1
- package/dist/output/encode.d.ts +1 -1
- package/dist/output/encode.js +1 -1
- package/dist/{pipeline-BIk1RRIp.js → pipeline-BVYj7OP0.js} +72 -19
- package/dist/{pipeline-zq-yU3Te.d.ts → pipeline-CJNiQG-1.d.ts} +15 -5
- package/dist/{prepare-BESRrh6K.js → prepare-D56Z-9cg.js} +7 -2
- package/dist/{prepare-CPxO0kKz.d.ts → prepare-Dce7-HAe.d.ts} +8 -0
- package/dist/{rasterizer-yqJkicm1.d.ts → rasterizer-BSQHEhJ-.d.ts} +4 -2
- package/dist/{rasterizer-76qO8TDh.js → rasterizer-DcVJzkxz.js} +13 -5
- package/dist/{registry-B9TcjVbs.js → registry-DS5PZ57l.js} +8 -1
- package/dist/render/blend.d.ts +2 -2
- package/dist/render/blend.js +2 -2
- package/dist/render/compose.d.ts +2 -2
- package/dist/render/compose.js +1 -1
- package/dist/render/entity-fallback.d.ts +19 -5
- package/dist/render/entity-fallback.js +2 -2
- package/dist/render/face.d.ts +2 -2
- package/dist/render/face.js +2 -2
- package/dist/render/fluid-bucket.js +1 -1
- package/dist/render/geo.d.ts +3 -3
- package/dist/render/geo.js +1 -1
- package/dist/render/geometry.d.ts +1 -1
- package/dist/render/geometry.js +1 -1
- package/dist/render/legacy-tints.d.ts +1 -1
- package/dist/render/obj.d.ts +5 -3
- package/dist/render/obj.js +1 -1
- package/dist/render/pipeline.d.ts +1 -1
- package/dist/render/pipeline.js +1 -1
- package/dist/render/rasterizer.d.ts +1 -1
- package/dist/render/rasterizer.js +1 -1
- 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/render/tints.js +1 -1
- package/dist/{renderer-DVsZHAvf.d.ts → renderer-C79EQDSn.d.ts} +3 -3
- package/dist/{renderer-CjT19tHd.js → renderer-oi1MSF3Y.js} +36 -19
- package/dist/{run-BnICOF4I.js → run-C6AP3Bn8.js} +3 -3
- package/dist/{run-CKUtynTy.d.ts → run-uq8_hUx9.d.ts} +1 -1
- package/dist/run.d.ts +2 -2
- package/dist/run.js +2 -2
- package/dist/textures/loader.js +1 -1
- package/dist/{tints-BtbHegpI.js → tints-3VI_2SNy.js} +107 -1
- package/dist/{tints-B8UJmZMu.js → tints-CebmvjmP.js} +2 -2
- package/dist/{tints-DLBExVWN.d.ts → tints-Do9Sh3dg.d.ts} +2 -2
- package/dist/{types-COGbtA1t.d.ts → types-DpRSF9Vj.d.ts} +8 -0
- package/dist/workers/render-worker.d.ts +1 -1
- package/dist/workers/render-worker.js +1 -1
- package/package.json +1 -1
- package/dist/blend-CHP2-j9U.js +0 -90
- package/dist/blend-CyDIxCne.d.ts +0 -36
- package/dist/face-BIYg14TE.d.ts +0 -30
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { n as FloatTexture } from "./blend-8lnfxtLe.js";
|
|
2
|
+
import { t as Mat4 } from "./vector-DRKRi4--.js";
|
|
3
|
+
import { n as FaceGeometry } from "./geometry-w0yQbzDZ.js";
|
|
4
|
+
import { r as LightSource } from "./lighting-3FGRC3Af.js";
|
|
5
|
+
import { n as FaceBuffer } from "./rasterizer-BSQHEhJ-.js";
|
|
6
|
+
//#region src/render/face.d.ts
|
|
7
|
+
interface TintColor {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
}
|
|
12
|
+
interface RenderableFace {
|
|
13
|
+
geometry: FaceGeometry;
|
|
14
|
+
texture: FloatTexture;
|
|
15
|
+
light: LightSource;
|
|
16
|
+
tint: TintColor | null;
|
|
17
|
+
/** Untransformed model-space max Z — upstream's stable pre-sort key. */
|
|
18
|
+
maxZ: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pre-shaded textures for one model render, with a byte ceiling.
|
|
22
|
+
*
|
|
23
|
+
* Shading a texel as it is sampled is always correct, but for a small sheet it
|
|
24
|
+
* is slower than shading one copy and reusing it: a block model's faces repeat
|
|
25
|
+
* the same few (window, light level) pairs, and there are far more drawn pixels
|
|
26
|
+
* than texels. The reverse holds for a detailed model on a big sheet — every
|
|
27
|
+
* face is its own key, and the copies are what once reached 20 GB for a single
|
|
28
|
+
* icon. So cache while it is cheap and fall through to per-sample shading once
|
|
29
|
+
* the budget is spent; the two produce identical output.
|
|
30
|
+
*/
|
|
31
|
+
interface FaceShadeCache {
|
|
32
|
+
byTexture: WeakMap<FloatTexture, Map<string, FloatTexture>>;
|
|
33
|
+
bytes: number;
|
|
34
|
+
}
|
|
35
|
+
declare function createShadeCache(): FaceShadeCache;
|
|
36
|
+
declare function faceMaxZ(geometry: FaceGeometry): number;
|
|
37
|
+
/** Returns null when the face is culled, degenerate, or has a zero-area UV. */
|
|
38
|
+
declare function renderFace(face: RenderableFace, width: number, height: number, transformation: Mat4,
|
|
39
|
+
/** Reused across a model's faces; cleared here, compacted before return. */
|
|
40
|
+
scratch?: FaceBuffer,
|
|
41
|
+
/** Bounded store of pre-shaded textures; omitted means always shade per sample. */
|
|
42
|
+
shadeCache?: FaceShadeCache): FaceBuffer | null;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { faceMaxZ as a, createShadeCache as i, RenderableFace as n, renderFace as o, TintColor as r, FaceShadeCache as t };
|
|
@@ -58,9 +58,14 @@ function averageColor(texture) {
|
|
|
58
58
|
async function paintBucketFluid(bucket, fluid, textures, resources) {
|
|
59
59
|
const fluidLocator = ResourceLocator.tryParse(fluid);
|
|
60
60
|
if (!fluidLocator) return false;
|
|
61
|
+
const bare = fluidLocator.path.replace(/^fluid_/, "").replace(/_(?:still|flowing|source)$/, "");
|
|
62
|
+
const names = /* @__PURE__ */ new Set([fluidLocator.path, bare]);
|
|
61
63
|
let still = null;
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
+
for (const name of names) {
|
|
65
|
+
for (const pattern of STILL_TEXTURE_PATTERNS) {
|
|
66
|
+
still = await textures.load(new ResourceLocator(fluidLocator.namespace, pattern(name)));
|
|
67
|
+
if (still) break;
|
|
68
|
+
}
|
|
64
69
|
if (still) break;
|
|
65
70
|
}
|
|
66
71
|
still ??= resources ? await particleTexture(fluidLocator, textures, resources) : null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as displayMatrix } from "./vector-CCxLae_T.js";
|
|
2
1
|
import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { n as displayMatrix } from "./vector-CCxLae_T.js";
|
|
3
|
+
import { l as toFloatTexture } from "./blend-KXMclcHk.js";
|
|
4
|
+
import { t as combineFaceBuffers } from "./compose-BGsNFR12.js";
|
|
5
|
+
import { i as createFaceBuffer } from "./rasterizer-DcVJzkxz.js";
|
|
6
|
+
import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-CMJ3b3Ae.js";
|
|
7
7
|
import { c as lightsForProfile } from "./lighting--5myudVu.js";
|
|
8
8
|
//#region src/render/geo.ts
|
|
9
9
|
/**
|
|
@@ -222,6 +222,12 @@ function geoToFaces(geo) {
|
|
|
222
222
|
point[1],
|
|
223
223
|
point[2]
|
|
224
224
|
]);
|
|
225
|
+
corners = [
|
|
226
|
+
corners[0],
|
|
227
|
+
corners[3],
|
|
228
|
+
corners[2],
|
|
229
|
+
corners[1]
|
|
230
|
+
];
|
|
225
231
|
for (const point of corners) for (let axis = 0; axis < 3; axis++) {
|
|
226
232
|
min[axis] = Math.min(min[axis], point[axis]);
|
|
227
233
|
max[axis] = Math.max(max[axis], point[axis]);
|
|
@@ -234,7 +240,9 @@ function geoToFaces(geo) {
|
|
|
234
240
|
textureRef: "#geo",
|
|
235
241
|
rotation: 0,
|
|
236
242
|
tintIndex: null,
|
|
237
|
-
shadeDirectionOverride: null
|
|
243
|
+
shadeDirectionOverride: null,
|
|
244
|
+
emissive: false,
|
|
245
|
+
alpha: 1
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
248
|
}
|
|
@@ -259,10 +267,22 @@ async function findGeoForItem(resources, id) {
|
|
|
259
267
|
`geckolib/geo/${locator.path}.geo.json`,
|
|
260
268
|
`models/geo/${locator.path}.geo.json`
|
|
261
269
|
];
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
270
|
+
const geoPathHits = await Promise.all(geoPaths.map((path) => resources.hasResource("raw", new ResourceLocator(locator.namespace, path))));
|
|
271
|
+
const name = locator.path.split("/").pop() ?? locator.path;
|
|
272
|
+
if (!geoPathHits.includes(true)) {
|
|
273
|
+
const geoFiles = (await resources.listResources("raw", locator.namespace)).map((candidate) => candidate.path).filter((path) => path.endsWith(".geo.json") && /(?:^|\/)(?:geo|geckolib)\//.test(path));
|
|
274
|
+
const matches = geoFiles.filter((path) => path.endsWith(`/${name}.geo.json`)).toSorted((left, right) => left.length - right.length);
|
|
265
275
|
geoPaths.push(...matches);
|
|
276
|
+
if (matches.length === 0) {
|
|
277
|
+
const wanted = new Set(nameTokens(name));
|
|
278
|
+
const scored = geoFiles.map((path) => {
|
|
279
|
+
return {
|
|
280
|
+
path,
|
|
281
|
+
tokens: nameTokens(path.split("/").pop()?.replace(/\.geo\.json$/, "") ?? "")
|
|
282
|
+
};
|
|
283
|
+
}).filter((entry) => entry.tokens.length > 0 && entry.tokens.every((token) => wanted.has(token))).toSorted((left, right) => right.tokens.length - left.tokens.length || left.path.length - right.path.length);
|
|
284
|
+
geoPaths.push(...scored.map((entry) => entry.path));
|
|
285
|
+
}
|
|
266
286
|
}
|
|
267
287
|
for (const geoPath of geoPaths) {
|
|
268
288
|
const raw = await resources.getResource("raw", new ResourceLocator(locator.namespace, geoPath));
|
|
@@ -287,9 +307,63 @@ async function findGeoForItem(resources, id) {
|
|
|
287
307
|
texture
|
|
288
308
|
};
|
|
289
309
|
}
|
|
310
|
+
const geoName = geoPath.split("/").pop()?.replace(/\.geo\.json$/, "") ?? "";
|
|
311
|
+
const named = await findTextureByName(resources, locator.namespace, name) ?? await findVariantTexture(resources, locator.namespace, name) ?? await findTextureByName(resources, locator.namespace, geoName);
|
|
312
|
+
if (named) return {
|
|
313
|
+
geo,
|
|
314
|
+
texture: named
|
|
315
|
+
};
|
|
290
316
|
}
|
|
291
317
|
return null;
|
|
292
318
|
}
|
|
319
|
+
/** Name tokens, dropping the numeric suffixes mods use for shape variants. */
|
|
320
|
+
function nameTokens(name) {
|
|
321
|
+
return name.split(/[/_]/).filter((token) => token.length > 0 && !/^\d+$/.test(token));
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A skin whose name carries every token of the item's, in any order and with
|
|
325
|
+
* decoration allowed. pokeblocks writes `pokedoll_shiny_absol` as
|
|
326
|
+
* `pokedoll_absol_shiny_texture.png`, so neither an exact nor a suffix match
|
|
327
|
+
* finds it. Requiring the item's tokens to all be present keeps this from
|
|
328
|
+
* wandering onto a sibling variant's skin.
|
|
329
|
+
*/
|
|
330
|
+
async function findVariantTexture(resources, namespace, itemName) {
|
|
331
|
+
const wanted = nameTokens(itemName);
|
|
332
|
+
if (wanted.length === 0) return null;
|
|
333
|
+
let best = null;
|
|
334
|
+
let bestExtra = Infinity;
|
|
335
|
+
for (const locator of await resources.listResources("texture", namespace)) {
|
|
336
|
+
const tokens = nameTokens(locator.path.split("/").pop() ?? "").filter((token) => token !== "texture");
|
|
337
|
+
if (!wanted.every((token) => tokens.includes(token))) continue;
|
|
338
|
+
const extra = tokens.length - wanted.length;
|
|
339
|
+
if (extra < bestExtra || extra === bestExtra && best !== null && locator.path.length < best.path.length) {
|
|
340
|
+
best = locator;
|
|
341
|
+
bestExtra = extra;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return best;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The shortest-path texture named after `name`. GeckoLib binds the skin in Java
|
|
348
|
+
* rather than in the geo file, so the only link is the shared name — and a mod
|
|
349
|
+
* may decorate it (pokeblocks files 344 figurines as `<name>_texture.png`).
|
|
350
|
+
* An exact match always wins over a decorated one.
|
|
351
|
+
*/
|
|
352
|
+
async function findTextureByName(resources, namespace, name) {
|
|
353
|
+
if (name === "") return null;
|
|
354
|
+
let best = null;
|
|
355
|
+
let bestExact = false;
|
|
356
|
+
for (const locator of await resources.listResources("texture", namespace)) {
|
|
357
|
+
const leaf = locator.path.split("/").pop() ?? "";
|
|
358
|
+
const exact = leaf === name;
|
|
359
|
+
if (!exact && leaf !== `${name}_texture`) continue;
|
|
360
|
+
if (best === null || exact && !bestExact || exact === bestExact && locator.path.length < best.path.length) {
|
|
361
|
+
best = locator;
|
|
362
|
+
bestExact = exact;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return best;
|
|
366
|
+
}
|
|
293
367
|
/** Render a parsed geo with the standard block gui pose. */
|
|
294
368
|
async function renderGeo(geo, texture, textures, options) {
|
|
295
369
|
const faces = geoToFaces(geo);
|
|
@@ -308,9 +382,9 @@ async function renderGeo(geo, texture, textures, options) {
|
|
|
308
382
|
0,
|
|
309
383
|
0
|
|
310
384
|
], [
|
|
311
|
-
.
|
|
312
|
-
.
|
|
313
|
-
.
|
|
385
|
+
.625,
|
|
386
|
+
.625,
|
|
387
|
+
.625
|
|
314
388
|
]);
|
|
315
389
|
const renderable = faces.map((geometry) => {
|
|
316
390
|
return {
|
|
@@ -324,7 +398,7 @@ async function renderGeo(geo, texture, textures, options) {
|
|
|
324
398
|
renderable.sort((a, b) => a.maxZ - b.maxZ);
|
|
325
399
|
const buffers = [];
|
|
326
400
|
const scratch = createFaceBuffer(renderSize, renderSize);
|
|
327
|
-
const shadeCache =
|
|
401
|
+
const shadeCache = createShadeCache();
|
|
328
402
|
for (const face of renderable) {
|
|
329
403
|
const buffer = renderFace(face, renderSize, renderSize, transformation, scratch, shadeCache);
|
|
330
404
|
if (buffer) buffers.push(buffer);
|
|
@@ -151,7 +151,9 @@ function buildElementFaces(element) {
|
|
|
151
151
|
textureRef: faceJson.texture,
|
|
152
152
|
rotation: faceJson.rotation ?? 0,
|
|
153
153
|
tintIndex: faceJson.tintindex ?? null,
|
|
154
|
-
shadeDirectionOverride: override
|
|
154
|
+
shadeDirectionOverride: override,
|
|
155
|
+
emissive: element.emissive_rc === true,
|
|
156
|
+
alpha: clampAlpha(element.alpha_rc)
|
|
155
157
|
});
|
|
156
158
|
}
|
|
157
159
|
applyElementRotation(element.rotation_rc ?? element.rotation, [
|
|
@@ -166,6 +168,10 @@ function buildElementFaces(element) {
|
|
|
166
168
|
]);
|
|
167
169
|
return faces;
|
|
168
170
|
}
|
|
171
|
+
function clampAlpha(alpha) {
|
|
172
|
+
if (typeof alpha !== "number" || !Number.isFinite(alpha)) return 1;
|
|
173
|
+
return Math.min(1, Math.max(0, alpha));
|
|
174
|
+
}
|
|
169
175
|
function parseShadeOverride(element) {
|
|
170
176
|
const override = element.shade_direction_override;
|
|
171
177
|
if (override && override in FACE_NORMALS) return FACE_NORMALS[override];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FaceDirectionName, o as ModelElementJson, r as ElementRotationJson } from "./types-
|
|
1
|
+
import { a as FaceDirectionName, o as ModelElementJson, r as ElementRotationJson } from "./types-DpRSF9Vj.js";
|
|
2
2
|
import { n as Vec3 } from "./vector-DRKRi4--.js";
|
|
3
3
|
//#region src/render/geometry.d.ts
|
|
4
4
|
interface FaceGeometry {
|
|
@@ -13,6 +13,10 @@ interface FaceGeometry {
|
|
|
13
13
|
rotation: number;
|
|
14
14
|
tintIndex: number | null;
|
|
15
15
|
shadeDirectionOverride: Vec3 | null;
|
|
16
|
+
/** Skip directional shading — the element is drawn fullbright. */
|
|
17
|
+
emissive: boolean;
|
|
18
|
+
/** Constant opacity multiplier in [0,1]; 1 leaves the texture untouched. */
|
|
19
|
+
alpha: number;
|
|
16
20
|
}
|
|
17
21
|
declare const FACE_NORMALS: Record<FaceDirectionName, Vec3>;
|
|
18
22
|
declare function buildElementFaces(element: ModelElementJson): FaceGeometry[];
|
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-Myy22TDL.js";
|
|
4
4
|
import { d as parseAtlasSources, n as AtlasSource, r as AtlasSourceError, s as ResolvedSprite, t as AtlasResolver, u as createAtlasResolver } from "./sources-B9X9w3qP.js";
|
|
5
5
|
import { s as builtinDynamicResources } from "./generators-DhRov4RB.js";
|
|
6
|
-
import { a as resolveTexture, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "./loader-
|
|
7
|
-
import {
|
|
6
|
+
import { a as resolveTexture, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "./loader-DD83d80u.js";
|
|
7
|
+
import { d as toFloatTexture, n as FloatTexture, u as toByteTexture } from "./blend-8lnfxtLe.js";
|
|
8
8
|
import { a as LightingProfileName, i as LightingProfile, r as LightSource, u as lightsForProfile } from "./lighting-3FGRC3Af.js";
|
|
9
|
-
import { a as RenderedFrames, c as renderModel, i as RenderOptions, l as renderModelFrames, o as boxDownscale, r as ItemRenderError, s as pointResize } from "./renderer-
|
|
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-
|
|
11
|
-
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "./discovery-
|
|
12
|
-
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, t as DYE_COLORS } from "./tints-
|
|
13
|
-
import { i as EncodedIcon, n as EncodeOptions, o as encodeAnimatedIcon, r as EncodedAnimatedIcon, s as encodeIcon, t as AnimatedEncodeOptions } from "./encode-
|
|
9
|
+
import { a as RenderedFrames, c as renderModel, i as RenderOptions, l as renderModelFrames, o as boxDownscale, r as ItemRenderError, s as pointResize } from "./renderer-C79EQDSn.js";
|
|
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-ricL7Jqf.js";
|
|
11
|
+
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "./discovery-BPSUtdm4.js";
|
|
12
|
+
import { a as resolveTint, i as parseTintValue, n as InvalidTinterDefinitionError, o as resolveTints, t as DYE_COLORS } from "./tints-Do9Sh3dg.js";
|
|
13
|
+
import { i as EncodedIcon, n as EncodeOptions, o as encodeAnimatedIcon, r as EncodedAnimatedIcon, s as encodeIcon, t as AnimatedEncodeOptions } from "./encode-DNcXXvYe.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-Cs6QDqie.js";
|
|
16
|
-
import { i as prepareModResources } from "./prepare-
|
|
16
|
+
import { i as prepareModResources } from "./prepare-Dce7-HAe.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-uq8_hUx9.js";
|
|
19
19
|
import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager } from "./jar-CFkA-VgT.js";
|
|
20
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
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-3MBm8ar_.js";
|
|
2
1
|
import { n as ResourceLocator, t as InvalidResourceLocatorError } from "./locator-ycZzh_6z.js";
|
|
3
2
|
import { n as LayeredResourceManager, r as ResourceKind, t as FolderResourceManager } from "./manager-CkletR5K.js";
|
|
3
|
+
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-ColsvWrH.js";
|
|
4
4
|
import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager } from "./jar-D9z-X7tA.js";
|
|
5
|
-
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "./discovery-
|
|
6
|
-
import {
|
|
7
|
-
import { n as encodeIcon, t as encodeAnimatedIcon } from "./encode-
|
|
5
|
+
import { n as discoverItems, r as resolveItem, t as ItemResolutionError } from "./discovery-B9aqV_Rz.js";
|
|
6
|
+
import { c as toByteTexture, l as toFloatTexture } from "./blend-KXMclcHk.js";
|
|
7
|
+
import { n as encodeIcon, t as encodeAnimatedIcon } from "./encode-LR9wxigC.js";
|
|
8
8
|
import { a as builtinDynamicResources } from "./generators-BlG4KmtP.js";
|
|
9
9
|
import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
|
|
10
10
|
import { n as itemClass, t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
|
|
11
11
|
import { c as lightsForProfile, r as LightingProfile } from "./lighting--5myudVu.js";
|
|
12
|
-
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-
|
|
13
|
-
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-
|
|
14
|
-
import { a as resolveTints, i as resolveTint, n as InvalidTinterDefinitionError, r as parseTintValue, t as DYE_COLORS } from "./tints-
|
|
12
|
+
import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-DwkA9LR5.js";
|
|
13
|
+
import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-oi1MSF3Y.js";
|
|
14
|
+
import { a as resolveTints, i as resolveTint, n as InvalidTinterDefinitionError, r as parseTintValue, t as DYE_COLORS } from "./tints-3VI_2SNy.js";
|
|
15
15
|
import { o as createAtlasResolver, s as parseAtlasSources, t as AtlasSourceError } from "./sources-Bxk-WOzH.js";
|
|
16
|
-
import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-
|
|
17
|
-
import { t as run } from "./run-
|
|
16
|
+
import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-Lb0ZeILz.js";
|
|
17
|
+
import { t as run } from "./run-C6AP3Bn8.js";
|
|
18
18
|
import { a as prepareVersionResources, i as eraForVersion, r as compareVersions } from "./prepare-Cc8QZ3j0.js";
|
|
19
|
-
import { n as prepareModResources } from "./prepare-
|
|
19
|
+
import { n as prepareModResources } from "./prepare-D56Z-9cg.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 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { n as ResourceLocator } from "../locator-jDbdUeTd.js";
|
|
2
|
+
import { a as ResourceManager } from "../manager-Cv1NeFyF.js";
|
|
3
|
+
import { t as Mat4 } from "../vector-DRKRi4--.js";
|
|
4
|
+
//#region src/items/blockstate.d.ts
|
|
5
|
+
interface ResolvedBlockState {
|
|
6
|
+
model: ResourceLocator;
|
|
7
|
+
/** Blockstate rotations, in degrees; the item transform has to replay them. */
|
|
8
|
+
xRotation: number;
|
|
9
|
+
yRotation: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The block model an item's blockstate names for its default state, or null
|
|
13
|
+
* when the item has no blockstate or it states nothing usable.
|
|
14
|
+
*/
|
|
15
|
+
declare function defaultBlockStateModel(resources: ResourceManager, id: string): Promise<ResolvedBlockState | null>;
|
|
16
|
+
/**
|
|
17
|
+
* The blockstate's own x/y rotation as an item transform. Vanilla applies these
|
|
18
|
+
* about the block's centre, and the game bakes them into the model before the
|
|
19
|
+
* display transform, so they compose the same way here.
|
|
20
|
+
*/
|
|
21
|
+
declare function blockStateTransform(state: ResolvedBlockState): Mat4;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ResolvedBlockState, blockStateTransform, defaultBlockStateModel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as STRING_DEFAULTS, c as defaultProperties, i as ItemRenderInstruction, l as evaluateItemModel, n as InvalidItemDefinitionError, o as TintDefinition, r as ItemProperties, s as UNKNOWN_MODEL, t as CONDITION_DEFAULTS } from "../definition-
|
|
1
|
+
import { a as STRING_DEFAULTS, c as defaultProperties, i as ItemRenderInstruction, l as evaluateItemModel, n as InvalidItemDefinitionError, o as TintDefinition, r as ItemProperties, s as UNKNOWN_MODEL, t as CONDITION_DEFAULTS } from "../definition-ricL7Jqf.js";
|
|
2
2
|
export { CONDITION_DEFAULTS, InvalidItemDefinitionError, ItemProperties, ItemRenderInstruction, STRING_DEFAULTS, TintDefinition, UNKNOWN_MODEL, defaultProperties, evaluateItemModel };
|
package/dist/items/definition.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel, r as STRING_DEFAULTS, t as CONDITION_DEFAULTS } from "../definition-
|
|
1
|
+
import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel, r as STRING_DEFAULTS, t as CONDITION_DEFAULTS } from "../definition-ColsvWrH.js";
|
|
2
2
|
export { CONDITION_DEFAULTS, InvalidItemDefinitionError, STRING_DEFAULTS, UNKNOWN_MODEL, defaultProperties, evaluateItemModel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "../discovery-
|
|
1
|
+
import { a as resolveItem, i as discoverItems, n as ItemDiscoveryOptions, r as ItemResolutionError, t as DiscoveredItem } from "../discovery-BPSUtdm4.js";
|
|
2
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-B9aqV_Rz.js";
|
|
2
2
|
export { ItemResolutionError, discoverItems, resolveItem };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as ResourceLocator } from "./locator-jDbdUeTd.js";
|
|
2
2
|
import { a as ResourceManager } from "./manager-Cv1NeFyF.js";
|
|
3
|
-
import { c as ModelJson, n as DisplayTransformJson, o as ModelElementJson, t as DisplayPosition } from "./types-
|
|
3
|
+
import { c as ModelJson, n as DisplayTransformJson, o as ModelElementJson, t as DisplayPosition } from "./types-DpRSF9Vj.js";
|
|
4
4
|
//#region src/models/loader.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A model with its parent chain flattened: textures merged child-over-parent,
|
|
@@ -28,6 +28,7 @@ interface ResolvedModel {
|
|
|
28
28
|
obj?: {
|
|
29
29
|
model: string;
|
|
30
30
|
flipV: boolean;
|
|
31
|
+
objects?: string[];
|
|
31
32
|
};
|
|
32
33
|
/** Fluid id from a fluid_container loader, for painting bucket contents. */
|
|
33
34
|
fluid?: string;
|