minerender 2.1.0-alpha.80 → 2.1.0-alpha.83
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/browser/index.d.mts +60 -5
- package/dist/browser/index.d.ts +60 -5
- package/dist/browser/index.js +171 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +178 -13
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +174 -6
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +60 -5
- package/dist/node/index.d.ts +60 -5
- package/dist/node/index.js +175 -6
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +180 -13
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -41423,7 +41423,8 @@ void main() {
|
|
|
41423
41423
|
this.entityTextureCache,
|
|
41424
41424
|
this.entityAnimationCache,
|
|
41425
41425
|
this.blockEntityIndexCache,
|
|
41426
|
-
this.fontCache
|
|
41426
|
+
this.fontCache,
|
|
41427
|
+
this.bannerPatternCache
|
|
41427
41428
|
];
|
|
41428
41429
|
}
|
|
41429
41430
|
/** Invalidates in-memory entries so later lookups reload them. Persisted entries are retained. */
|
|
@@ -41472,6 +41473,7 @@ void main() {
|
|
|
41472
41473
|
_Caching.entityAnimationCache = _Caching.createAssetCache();
|
|
41473
41474
|
_Caching.blockEntityIndexCache = _Caching.createAssetCache();
|
|
41474
41475
|
_Caching.fontCache = _Caching.createAssetCache();
|
|
41476
|
+
_Caching.bannerPatternCache = _Caching.createAssetCache();
|
|
41475
41477
|
Caching = _Caching;
|
|
41476
41478
|
}
|
|
41477
41479
|
});
|
|
@@ -42499,6 +42501,7 @@ void main() {
|
|
|
42499
42501
|
material.depthWrite = false;
|
|
42500
42502
|
break;
|
|
42501
42503
|
case "eyes":
|
|
42504
|
+
case "no_outline":
|
|
42502
42505
|
material.transparent = true;
|
|
42503
42506
|
material.alphaTest = 0;
|
|
42504
42507
|
material.depthWrite = false;
|
|
@@ -43108,6 +43111,82 @@ void main() {
|
|
|
43108
43111
|
}
|
|
43109
43112
|
});
|
|
43110
43113
|
|
|
43114
|
+
// src/assets/BannerPatterns.ts
|
|
43115
|
+
var DYE_COLORS, BannerPatterns;
|
|
43116
|
+
var init_BannerPatterns = __esm({
|
|
43117
|
+
"src/assets/BannerPatterns.ts"() {
|
|
43118
|
+
init_dirname();
|
|
43119
|
+
init_buffer2();
|
|
43120
|
+
init_process2();
|
|
43121
|
+
init_AssetKey();
|
|
43122
|
+
init_AssetLoader();
|
|
43123
|
+
init_AssetParsers();
|
|
43124
|
+
init_Caching();
|
|
43125
|
+
DYE_COLORS = Object.freeze({
|
|
43126
|
+
white: 16383998,
|
|
43127
|
+
orange: 16351261,
|
|
43128
|
+
magenta: 13061821,
|
|
43129
|
+
light_blue: 3847130,
|
|
43130
|
+
yellow: 16701501,
|
|
43131
|
+
lime: 8439583,
|
|
43132
|
+
pink: 15961002,
|
|
43133
|
+
gray: 4673362,
|
|
43134
|
+
light_gray: 10329495,
|
|
43135
|
+
cyan: 1481884,
|
|
43136
|
+
purple: 8991416,
|
|
43137
|
+
blue: 3949738,
|
|
43138
|
+
brown: 8606770,
|
|
43139
|
+
green: 6192150,
|
|
43140
|
+
red: 11546150,
|
|
43141
|
+
black: 1908001
|
|
43142
|
+
});
|
|
43143
|
+
BannerPatterns = class {
|
|
43144
|
+
/** Lists namespaced pattern IDs from the selected namespace's data directory. */
|
|
43145
|
+
static async getList(namespace = "minecraft", root) {
|
|
43146
|
+
const collect = async (path) => {
|
|
43147
|
+
const prefix2 = path ? `${path}/` : "";
|
|
43148
|
+
const key = new AssetKey(namespace, `${prefix2}_list`, "banner_pattern", void 0, "data", ".json", root);
|
|
43149
|
+
const list2 = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
|
|
43150
|
+
if (!list2) return [];
|
|
43151
|
+
const files = list2.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${namespace}:${prefix2}${file.slice(0, -5)}`);
|
|
43152
|
+
const children = await Promise.all(list2.directories.map((directory) => collect(`${prefix2}${directory}`)));
|
|
43153
|
+
return [...files, ...children.flat()];
|
|
43154
|
+
};
|
|
43155
|
+
return collect("");
|
|
43156
|
+
}
|
|
43157
|
+
/** Returns the named dye's sRGB value, rejecting unknown colors. */
|
|
43158
|
+
static getColor(color3) {
|
|
43159
|
+
if (typeof color3 !== "string" || !Object.prototype.hasOwnProperty.call(DYE_COLORS, color3)) throw new Error(`Unsupported dye color ${color3}`);
|
|
43160
|
+
return DYE_COLORS[color3];
|
|
43161
|
+
}
|
|
43162
|
+
/** Resolves the first 16 layers of a `banner_patterns` component, preserving their order. */
|
|
43163
|
+
static async getLayers(value, target, root) {
|
|
43164
|
+
if (value === void 0) return [];
|
|
43165
|
+
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
43166
|
+
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
43167
|
+
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
43168
|
+
const color3 = this.getColor(layer.color);
|
|
43169
|
+
let pattern2 = layer.pattern;
|
|
43170
|
+
if (typeof pattern2 === "string") {
|
|
43171
|
+
const id = this.identifier(pattern2);
|
|
43172
|
+
const key = new AssetKey(id.namespace, id.getFullPath(), "banner_pattern", void 0, "data", ".json", root);
|
|
43173
|
+
pattern2 = await Caching.bannerPatternCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
43174
|
+
if (!pattern2) throw new Error(`Missing banner pattern ${layer.pattern}`);
|
|
43175
|
+
}
|
|
43176
|
+
if (!pattern2 || typeof pattern2 !== "object" || Array.isArray(pattern2) || typeof pattern2.translation_key !== "string") throw new Error("Banner patterns require asset_id and translation_key");
|
|
43177
|
+
const asset2 = this.identifier(pattern2.asset_id);
|
|
43178
|
+
return { color: color3, texture: new AssetKey(asset2.namespace, `${target}/${asset2.getFullPath()}`, "textures", "entity", "assets", ".png", root) };
|
|
43179
|
+
}));
|
|
43180
|
+
}
|
|
43181
|
+
static identifier(value) {
|
|
43182
|
+
if (typeof value !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value)) throw new Error(`Invalid banner-pattern identifier ${value}`);
|
|
43183
|
+
const [namespace, path] = value.includes(":") ? value.split(":") : ["minecraft", value];
|
|
43184
|
+
return new AssetKey(namespace, path);
|
|
43185
|
+
}
|
|
43186
|
+
};
|
|
43187
|
+
}
|
|
43188
|
+
});
|
|
43189
|
+
|
|
43111
43190
|
// src/assets/Models.ts
|
|
43112
43191
|
var Models;
|
|
43113
43192
|
var init_Models = __esm({
|
|
@@ -43123,6 +43202,7 @@ void main() {
|
|
|
43123
43202
|
init_AssetKey();
|
|
43124
43203
|
init_AssetParsers();
|
|
43125
43204
|
init_DisplayPosition();
|
|
43205
|
+
init_BannerPatterns();
|
|
43126
43206
|
Models = class _Models {
|
|
43127
43207
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
43128
43208
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
@@ -43312,6 +43392,19 @@ void main() {
|
|
|
43312
43392
|
if (!node.base || !node.model || typeof node.model !== "object") break;
|
|
43313
43393
|
const special = node.model;
|
|
43314
43394
|
switch (special.type) {
|
|
43395
|
+
case "banner":
|
|
43396
|
+
case "minecraft:banner":
|
|
43397
|
+
if (typeof special.color === "string" && Object.prototype.hasOwnProperty.call(DYE_COLORS, special.color)) return { model: node.base, special };
|
|
43398
|
+
break;
|
|
43399
|
+
case "shield":
|
|
43400
|
+
case "minecraft:shield":
|
|
43401
|
+
return { model: node.base, special };
|
|
43402
|
+
case "shulker_box":
|
|
43403
|
+
case "minecraft:shulker_box":
|
|
43404
|
+
if (typeof special.texture === "string" && special.texture && (special.openness === void 0 || typeof special.openness === "number" && Number.isFinite(special.openness)) && (special.orientation === void 0 || ["down", "up", "north", "south", "west", "east"].includes(special.orientation))) {
|
|
43405
|
+
return { model: node.base, special };
|
|
43406
|
+
}
|
|
43407
|
+
break;
|
|
43315
43408
|
case "chest":
|
|
43316
43409
|
case "minecraft:chest":
|
|
43317
43410
|
case "bed":
|
|
@@ -90384,9 +90477,11 @@ ${key}` : key;
|
|
|
90384
90477
|
init_three_module();
|
|
90385
90478
|
init_AssetKey();
|
|
90386
90479
|
init_Entities();
|
|
90480
|
+
init_BannerPatterns();
|
|
90481
|
+
init_ModelTextures();
|
|
90387
90482
|
SpecialItems = class {
|
|
90388
90483
|
/** Resolves the static entity parts drawn by a special item renderer, in model units. */
|
|
90389
|
-
static async getParts(special, root) {
|
|
90484
|
+
static async getParts(special, root, components = {}) {
|
|
90390
90485
|
const texture = (id, directory) => {
|
|
90391
90486
|
const key = AssetKey.parse("textures", id);
|
|
90392
90487
|
return new AssetKey(
|
|
@@ -90399,13 +90494,60 @@ ${key}` : key;
|
|
|
90399
90494
|
root
|
|
90400
90495
|
);
|
|
90401
90496
|
};
|
|
90402
|
-
const load = async (id, textureKey, transform, rotations = {}) => {
|
|
90497
|
+
const load = async (id, textureKey, transform, rotations = {}, layers = ["main"]) => {
|
|
90403
90498
|
const key = new AssetKey("minecraft", id, void 0, void 0, "entity-models", ".json", root);
|
|
90404
|
-
const model = await Entities.getEntity(key, textureKey, { layer:
|
|
90499
|
+
const model = await Entities.getEntity(key, textureKey, layers.length === 1 ? { layer: layers[0] } : {
|
|
90500
|
+
layers,
|
|
90501
|
+
textures: textureKey ? Object.fromEntries(layers.map((name2) => [name2, textureKey])) : void 0
|
|
90502
|
+
});
|
|
90405
90503
|
if (!model) throw new Error(`Missing entity model minecraft:${id} for special item ${special.type}`);
|
|
90406
90504
|
return { model, transform, rotations };
|
|
90407
90505
|
};
|
|
90408
90506
|
switch (special.type) {
|
|
90507
|
+
case "minecraft:banner":
|
|
90508
|
+
case "banner":
|
|
90509
|
+
case "minecraft:shield":
|
|
90510
|
+
case "shield": {
|
|
90511
|
+
const banner = special.type === "banner" || special.type === "minecraft:banner";
|
|
90512
|
+
const color3 = banner ? BannerPatterns.getColor(special.color) : components["minecraft:base_color"] === void 0 ? void 0 : BannerPatterns.getColor(components["minecraft:base_color"]);
|
|
90513
|
+
const patterns = await BannerPatterns.getLayers(components["minecraft:banner_patterns"], banner ? "banner" : "shield", root);
|
|
90514
|
+
const patterned = banner || color3 !== void 0 || patterns.length > 0;
|
|
90515
|
+
const baseTexture = texture(banner ? "banner_base" : patterned ? "shield_base" : "shield_base_nopattern", "");
|
|
90516
|
+
const transform = banner ? new Matrix4().makeTranslation(8, 0, 8).multiply(new Matrix4().makeScale(2 / 3, -2 / 3, -2 / 3)) : new Matrix4().makeScale(1, -1, -1);
|
|
90517
|
+
const part = await load(banner ? "standing_banner" : "shield", baseTexture, transform, {}, banner ? ["main", "flag"] : ["main"]);
|
|
90518
|
+
const layers = Object.fromEntries(Object.entries(part.model.layers ?? { main: part.model }).map(([name2, layer]) => [name2, { ...layer, render: "solid" }]));
|
|
90519
|
+
let overlay2;
|
|
90520
|
+
if (banner) {
|
|
90521
|
+
const flagLayer = layers.flag;
|
|
90522
|
+
const flag = flagLayer?.layer.root.children.flag;
|
|
90523
|
+
if (!flag) throw new Error("Banner entity model is missing its flag layer");
|
|
90524
|
+
overlay2 = { ...flagLayer.layer, root: { ...flagLayer.layer.root, children: {
|
|
90525
|
+
...flagLayer.layer.root.children,
|
|
90526
|
+
flag: { ...flag, pose: { ...flag.pose, rotation: [-25e-4 * Math.PI, flag.pose.rotation[1], flag.pose.rotation[2]] } }
|
|
90527
|
+
} } };
|
|
90528
|
+
layers.flag = { ...flagLayer, layer: overlay2 };
|
|
90529
|
+
} else {
|
|
90530
|
+
const main = layers.main.layer;
|
|
90531
|
+
const plate = main.root.children.plate;
|
|
90532
|
+
if (!plate) throw new Error("Shield entity model is missing its plate");
|
|
90533
|
+
overlay2 = { ...main, root: { ...main.root, cubes: [], children: { plate } } };
|
|
90534
|
+
}
|
|
90535
|
+
const tints = {};
|
|
90536
|
+
if (patterned) {
|
|
90537
|
+
const draws = [{ texture: texture(`${banner ? "banner" : "shield"}/base`, ""), color: color3 ?? DYE_COLORS.white }, ...patterns];
|
|
90538
|
+
draws.forEach((draw, index) => {
|
|
90539
|
+
const name2 = index === 0 ? "pattern_base" : `pattern_${index - 1}`;
|
|
90540
|
+
layers[name2] = { key: draw.texture, texture: draw.texture, layer: overlay2, render: "no_outline", tint: name2 };
|
|
90541
|
+
tints[name2] = draw.color;
|
|
90542
|
+
});
|
|
90543
|
+
}
|
|
90544
|
+
await Promise.all([...new Map(Object.values(layers).map((layer) => [layer.texture.serialize(), layer.texture])).values()].map(async (key) => {
|
|
90545
|
+
if (!await ModelTextures.preload(key)) throw new Error(`Missing special item texture ${key.toNamespacedString()}`);
|
|
90546
|
+
}));
|
|
90547
|
+
part.model = { ...part.model, ...layers.main, layers };
|
|
90548
|
+
part.tints = tints;
|
|
90549
|
+
return [part];
|
|
90550
|
+
}
|
|
90409
90551
|
case "minecraft:chest":
|
|
90410
90552
|
case "chest": {
|
|
90411
90553
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
@@ -90416,6 +90558,26 @@ ${key}` : key;
|
|
|
90416
90558
|
chest.model = { ...chest.model, render: "solid", layers: void 0 };
|
|
90417
90559
|
return [chest];
|
|
90418
90560
|
}
|
|
90561
|
+
case "minecraft:shulker_box":
|
|
90562
|
+
case "shulker_box": {
|
|
90563
|
+
const openness = special.openness === void 0 ? 0 : special.openness;
|
|
90564
|
+
const orientation = special.orientation === void 0 ? "up" : special.orientation;
|
|
90565
|
+
const directions = {
|
|
90566
|
+
down: [Math.PI, 0, 0],
|
|
90567
|
+
up: [0, 0, 0],
|
|
90568
|
+
north: [Math.PI / 2, 0, Math.PI],
|
|
90569
|
+
south: [Math.PI / 2, 0, 0],
|
|
90570
|
+
west: [Math.PI / 2, 0, Math.PI / 2],
|
|
90571
|
+
east: [Math.PI / 2, 0, -Math.PI / 2]
|
|
90572
|
+
};
|
|
90573
|
+
if (!Object.prototype.hasOwnProperty.call(directions, orientation)) throw new Error(`Unsupported shulker-box orientation ${orientation}`);
|
|
90574
|
+
if (typeof openness !== "number" || !Number.isFinite(openness)) throw new Error("Shulker-box openness must be finite");
|
|
90575
|
+
if (typeof special.texture !== "string" || !special.texture) throw new Error("Shulker-box texture is required");
|
|
90576
|
+
const transform = new Matrix4().makeTranslation(8, 8, 8).multiply(new Matrix4().makeScale(0.9995, 0.9995, 0.9995)).multiply(new Matrix4().makeRotationFromEuler(new Euler(...directions[orientation], "XYZ"))).multiply(new Matrix4().makeScale(1, -1, -1)).multiply(new Matrix4().makeTranslation(0, -16, 0));
|
|
90577
|
+
const box = await load("shulker_box", texture(special.texture, "shulker"), transform, { lid: [0, openness * Math.PI * 1.5, 0] });
|
|
90578
|
+
box.positions = { lid: [0, 24 - openness * 8, 0] };
|
|
90579
|
+
return [box];
|
|
90580
|
+
}
|
|
90419
90581
|
case "minecraft:bed":
|
|
90420
90582
|
case "bed": {
|
|
90421
90583
|
const transform = new Matrix4().makeTranslation(0, 9, 0).multiply(new Matrix4().makeRotationX(Math.PI / 2)).multiply(new Matrix4().makeTranslation(8, 8, 8)).multiply(new Matrix4().makeRotationZ(Math.PI)).multiply(new Matrix4().makeTranslation(-8, -8, -8));
|
|
@@ -90692,12 +90854,12 @@ ${shader.fragmentShader}`.replace(
|
|
|
90692
90854
|
this.options.tints = await ItemTints.get(this.originalModel, this.options.tints);
|
|
90693
90855
|
const special = this.originalModel.special;
|
|
90694
90856
|
if (special) {
|
|
90695
|
-
const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
90857
|
+
const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
|
|
90696
90858
|
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new Matrix4();
|
|
90697
90859
|
transform.multiply(new Matrix4().makeTranslation(-8, -8, -8));
|
|
90698
90860
|
try {
|
|
90699
90861
|
for (const part of parts2) {
|
|
90700
|
-
const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
90862
|
+
const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints });
|
|
90701
90863
|
object3.matrix.copy(transform).multiply(part.transform);
|
|
90702
90864
|
object3.matrixWorldNeedsUpdate = true;
|
|
90703
90865
|
object3.matrixAutoUpdate = false;
|
|
@@ -90716,6 +90878,9 @@ ${shader.fragmentShader}`.replace(
|
|
|
90716
90878
|
for (const [name2, rotation] of Object.entries(part.rotations)) {
|
|
90717
90879
|
object3.getGroupByName(name2)?.rotation.set(...rotation, "ZYX");
|
|
90718
90880
|
}
|
|
90881
|
+
for (const [name2, position] of Object.entries(part.positions ?? {})) {
|
|
90882
|
+
object3.getGroupByName(name2)?.position.set(...position);
|
|
90883
|
+
}
|
|
90719
90884
|
}
|
|
90720
90885
|
} catch (error2) {
|
|
90721
90886
|
this.disposeAndRemoveAllChildren();
|
|
@@ -93965,6 +94130,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
93965
94130
|
Axis: () => Axis,
|
|
93966
94131
|
BUILTIN_ENTITY: () => BUILTIN_ENTITY,
|
|
93967
94132
|
BUILTIN_GENERATED: () => BUILTIN_GENERATED,
|
|
94133
|
+
BannerPatterns: () => BannerPatterns,
|
|
93968
94134
|
BasicAssetKey: () => BasicAssetKey,
|
|
93969
94135
|
BatchedExecutor: () => BatchedExecutor,
|
|
93970
94136
|
BlockEntities: () => BlockEntities,
|
|
@@ -93989,6 +94155,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
93989
94155
|
DEFAULT_ROOT: () => DEFAULT_ROOT,
|
|
93990
94156
|
DEFAULT_UV: () => DEFAULT_UV,
|
|
93991
94157
|
DISPLAY_POSITIONS: () => DISPLAY_POSITIONS,
|
|
94158
|
+
DYE_COLORS: () => DYE_COLORS,
|
|
93992
94159
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
93993
94160
|
DisplayPosition: () => DisplayPosition,
|
|
93994
94161
|
DisplayTransforms: () => DisplayTransforms,
|
|
@@ -94396,6 +94563,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
94396
94563
|
init_AssetKey();
|
|
94397
94564
|
init_AssetLoader();
|
|
94398
94565
|
init_Assets();
|
|
94566
|
+
init_BannerPatterns();
|
|
94399
94567
|
|
|
94400
94568
|
// src/assets/BlockEntities.ts
|
|
94401
94569
|
init_dirname();
|