minerender 2.1.0-alpha.20 → 2.1.0-alpha.21
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 +8 -1
- package/dist/browser/index.d.ts +8 -1
- package/dist/browser/index.js +89 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +89 -0
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +110 -16
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +8 -1
- package/dist/node/index.d.ts +8 -1
- package/dist/node/index.js +92 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +91 -0
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -25869,17 +25869,17 @@ var MineRender = (() => {
|
|
|
25869
25869
|
expr = expr.replace(/\$/g, "$$$$");
|
|
25870
25870
|
return str.replace(new RegExp(dataVar, "g"), expr + "$1");
|
|
25871
25871
|
}
|
|
25872
|
-
function schemaHasRules(schema,
|
|
25872
|
+
function schemaHasRules(schema, rules2) {
|
|
25873
25873
|
if (typeof schema == "boolean") return !schema;
|
|
25874
|
-
for (var key in schema) if (
|
|
25874
|
+
for (var key in schema) if (rules2[key]) return true;
|
|
25875
25875
|
}
|
|
25876
|
-
function schemaHasRulesExcept(schema,
|
|
25876
|
+
function schemaHasRulesExcept(schema, rules2, exceptKeyword) {
|
|
25877
25877
|
if (typeof schema == "boolean") return !schema && exceptKeyword != "not";
|
|
25878
|
-
for (var key in schema) if (key != exceptKeyword &&
|
|
25878
|
+
for (var key in schema) if (key != exceptKeyword && rules2[key]) return true;
|
|
25879
25879
|
}
|
|
25880
|
-
function schemaUnknownRules(schema,
|
|
25880
|
+
function schemaUnknownRules(schema, rules2) {
|
|
25881
25881
|
if (typeof schema == "boolean") return;
|
|
25882
|
-
for (var key in schema) if (!
|
|
25882
|
+
for (var key in schema) if (!rules2[key]) return key;
|
|
25883
25883
|
}
|
|
25884
25884
|
function toQuotedString(str) {
|
|
25885
25885
|
return "'" + escapeQuotes(str) + "'";
|
|
@@ -26806,9 +26806,9 @@ var MineRender = (() => {
|
|
|
26806
26806
|
out += " var " + $valid + " = errors === errs_" + $lvl + ";";
|
|
26807
26807
|
}
|
|
26808
26808
|
function $shouldUseGroup($rulesGroup2) {
|
|
26809
|
-
var
|
|
26810
|
-
for (var i4 = 0; i4 <
|
|
26811
|
-
if ($shouldUseRule(
|
|
26809
|
+
var rules2 = $rulesGroup2.rules;
|
|
26810
|
+
for (var i4 = 0; i4 < rules2.length; i4++)
|
|
26811
|
+
if ($shouldUseRule(rules2[i4])) return true;
|
|
26812
26812
|
}
|
|
26813
26813
|
function $shouldUseRule($rule2) {
|
|
26814
26814
|
return it.schema[$rule2.keyword] !== void 0 || $rule2.implements && $ruleImplementsSomeKeyword($rule2);
|
|
@@ -29887,7 +29887,7 @@ var MineRender = (() => {
|
|
|
29887
29887
|
init_process2();
|
|
29888
29888
|
var ruleModules = require_dotjs();
|
|
29889
29889
|
var toHash = require_util().toHash;
|
|
29890
|
-
module2.exports = function
|
|
29890
|
+
module2.exports = function rules2() {
|
|
29891
29891
|
var RULES = [
|
|
29892
29892
|
{
|
|
29893
29893
|
type: "number",
|
|
@@ -30624,10 +30624,10 @@ var MineRender = (() => {
|
|
|
30624
30624
|
delete RULES.all[keyword];
|
|
30625
30625
|
delete RULES.custom[keyword];
|
|
30626
30626
|
for (var i4 = 0; i4 < RULES.length; i4++) {
|
|
30627
|
-
var
|
|
30628
|
-
for (var j4 = 0; j4 <
|
|
30629
|
-
if (
|
|
30630
|
-
|
|
30627
|
+
var rules2 = RULES[i4].rules;
|
|
30628
|
+
for (var j4 = 0; j4 < rules2.length; j4++) {
|
|
30629
|
+
if (rules2[j4].keyword == keyword) {
|
|
30630
|
+
rules2.splice(j4, 1);
|
|
30631
30631
|
break;
|
|
30632
30632
|
}
|
|
30633
30633
|
}
|
|
@@ -30683,7 +30683,7 @@ var MineRender = (() => {
|
|
|
30683
30683
|
var SchemaObject = require_schema_obj();
|
|
30684
30684
|
var stableStringify = require_fast_json_stable_stringify();
|
|
30685
30685
|
var formats = require_formats();
|
|
30686
|
-
var
|
|
30686
|
+
var rules2 = require_rules();
|
|
30687
30687
|
var $dataMetaSchema = require_data();
|
|
30688
30688
|
var util = require_util();
|
|
30689
30689
|
module2.exports = Ajv;
|
|
@@ -30722,7 +30722,7 @@ var MineRender = (() => {
|
|
|
30722
30722
|
this._cache = opts.cache || new Cache();
|
|
30723
30723
|
this._loadingSchemas = {};
|
|
30724
30724
|
this._compilations = [];
|
|
30725
|
-
this.RULES =
|
|
30725
|
+
this.RULES = rules2();
|
|
30726
30726
|
this._getId = chooseGetId(opts);
|
|
30727
30727
|
opts.loopRequired = opts.loopRequired || Infinity;
|
|
30728
30728
|
if (opts.errorDataPath == "property") opts._errorDataPathProperty = true;
|
|
@@ -45356,6 +45356,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
45356
45356
|
BlockEntityModels: () => BlockEntityModels,
|
|
45357
45357
|
BlockObject: () => BlockObject,
|
|
45358
45358
|
BlockStates: () => BlockStates,
|
|
45359
|
+
BlockTints: () => BlockTints,
|
|
45359
45360
|
BrowserArchiveProxy: () => BrowserArchiveProxy,
|
|
45360
45361
|
BrowserCache: () => BrowserCache,
|
|
45361
45362
|
BrowserEnv: () => BrowserEnv,
|
|
@@ -66380,6 +66381,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66380
66381
|
this.blockStateCache,
|
|
66381
66382
|
this.listAssetCache,
|
|
66382
66383
|
this.defaultBlockStatesCache,
|
|
66384
|
+
this.blockTintCache,
|
|
66383
66385
|
this.entityModelsCache
|
|
66384
66386
|
];
|
|
66385
66387
|
}
|
|
@@ -66422,6 +66424,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66422
66424
|
_Caching.blockStateCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
|
|
66423
66425
|
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
66424
66426
|
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
66427
|
+
_Caching.blockTintCache = _Caching.createAssetCache();
|
|
66425
66428
|
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
66426
66429
|
var Caching = _Caching;
|
|
66427
66430
|
|
|
@@ -79368,6 +79371,96 @@ return ${compiler2.callType("value", tagType)}
|
|
|
79368
79371
|
init_buffer2();
|
|
79369
79372
|
init_process2();
|
|
79370
79373
|
|
|
79374
|
+
// src/model/block/BlockTints.ts
|
|
79375
|
+
init_dirname();
|
|
79376
|
+
init_buffer2();
|
|
79377
|
+
init_process2();
|
|
79378
|
+
|
|
79379
|
+
// src/model/block/blockTints.json
|
|
79380
|
+
var blockTints_default = {
|
|
79381
|
+
"minecraft:large_fern": { source: "grass" },
|
|
79382
|
+
"minecraft:tall_grass": { source: "grass" },
|
|
79383
|
+
"minecraft:grass_block": { source: "grass" },
|
|
79384
|
+
"minecraft:fern": { source: "grass" },
|
|
79385
|
+
"minecraft:grass": { source: "grass" },
|
|
79386
|
+
"minecraft:short_grass": { source: "grass" },
|
|
79387
|
+
"minecraft:potted_fern": { source: "grass" },
|
|
79388
|
+
"minecraft:bush": { source: "grass" },
|
|
79389
|
+
"minecraft:pink_petals": { source: "grass", untinted: [0] },
|
|
79390
|
+
"minecraft:wildflowers": { source: "grass", untinted: [0] },
|
|
79391
|
+
"minecraft:spruce_leaves": { source: "constant", color: 6396257 },
|
|
79392
|
+
"minecraft:birch_leaves": { source: "constant", color: 8431445 },
|
|
79393
|
+
"minecraft:oak_leaves": { source: "constant", color: 4764952 },
|
|
79394
|
+
"minecraft:jungle_leaves": { source: "constant", color: 4764952 },
|
|
79395
|
+
"minecraft:acacia_leaves": { source: "constant", color: 4764952 },
|
|
79396
|
+
"minecraft:dark_oak_leaves": { source: "constant", color: 4764952 },
|
|
79397
|
+
"minecraft:vine": { source: "constant", color: 4764952 },
|
|
79398
|
+
"minecraft:mangrove_leaves": { source: "constant", color: 4764952 },
|
|
79399
|
+
"minecraft:leaf_litter": { source: "constant", color: 6044722 },
|
|
79400
|
+
"minecraft:water_cauldron": { source: "constant", color: 4159204 },
|
|
79401
|
+
"minecraft:redstone_wire": { source: "redstone" },
|
|
79402
|
+
"minecraft:attached_melon_stem": { source: "constant", color: 14731036 },
|
|
79403
|
+
"minecraft:attached_pumpkin_stem": { source: "constant", color: 14731036 },
|
|
79404
|
+
"minecraft:melon_stem": { source: "stem" },
|
|
79405
|
+
"minecraft:pumpkin_stem": { source: "stem" },
|
|
79406
|
+
"minecraft:lily_pad": { source: "constant", color: 7455580 }
|
|
79407
|
+
};
|
|
79408
|
+
|
|
79409
|
+
// src/model/block/BlockTints.ts
|
|
79410
|
+
var rules = blockTints_default;
|
|
79411
|
+
var BlockTints = class {
|
|
79412
|
+
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
79413
|
+
static async get(key, state, model, tints) {
|
|
79414
|
+
const rule = key && rules[key.toNamespacedString()];
|
|
79415
|
+
if (!key || !rule) return tints;
|
|
79416
|
+
const indices = /* @__PURE__ */ new Set();
|
|
79417
|
+
for (const element of model.elements ?? []) {
|
|
79418
|
+
for (const face of Object.values(element.faces)) {
|
|
79419
|
+
const index = face?.tintindex;
|
|
79420
|
+
if (index !== void 0 && index >= 0 && tints?.[index] === void 0 && !rule.untinted?.includes(index)) {
|
|
79421
|
+
indices.add(index);
|
|
79422
|
+
}
|
|
79423
|
+
}
|
|
79424
|
+
}
|
|
79425
|
+
if (!indices.size) return tints;
|
|
79426
|
+
let color2;
|
|
79427
|
+
switch (rule.source) {
|
|
79428
|
+
case "constant":
|
|
79429
|
+
color2 = rule.color;
|
|
79430
|
+
break;
|
|
79431
|
+
case "grass":
|
|
79432
|
+
color2 = await this.grassColor(key);
|
|
79433
|
+
break;
|
|
79434
|
+
case "redstone": {
|
|
79435
|
+
const power = Number(state.power ?? 0) / 15;
|
|
79436
|
+
const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
|
|
79437
|
+
const green = Math.max(0, power * power * 0.7 - 0.5);
|
|
79438
|
+
const blue = Math.max(0, power * power * 0.6 - 0.7);
|
|
79439
|
+
color2 = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
|
|
79440
|
+
break;
|
|
79441
|
+
}
|
|
79442
|
+
case "stem": {
|
|
79443
|
+
const age = Number(state.age ?? 0);
|
|
79444
|
+
color2 = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
|
|
79445
|
+
break;
|
|
79446
|
+
}
|
|
79447
|
+
}
|
|
79448
|
+
return { ...Object.fromEntries([...indices].map((index) => [index, color2])), ...tints };
|
|
79449
|
+
}
|
|
79450
|
+
static async grassColor(origin) {
|
|
79451
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
79452
|
+
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
79453
|
+
const image = await ModelTextures.get(key);
|
|
79454
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
79455
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
79456
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
79457
|
+
}
|
|
79458
|
+
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
79459
|
+
return red << 16 | green << 8 | blue;
|
|
79460
|
+
});
|
|
79461
|
+
}
|
|
79462
|
+
};
|
|
79463
|
+
|
|
79371
79464
|
// src/model/block/scene/index.ts
|
|
79372
79465
|
init_dirname();
|
|
79373
79466
|
init_buffer2();
|
|
@@ -80215,6 +80308,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
80215
80308
|
const model = await Models.getMerged(AssetKey.parse("models", variant.model));
|
|
80216
80309
|
const options = {
|
|
80217
80310
|
...this.options,
|
|
80311
|
+
tints: model ? await BlockTints.get(this.blockState.key, this.state, model, this.options.tints) : this.options.tints,
|
|
80218
80312
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
80219
80313
|
};
|
|
80220
80314
|
const obj = await this.scene.addModel(model, options);
|