minerender 2.1.0-alpha.24 → 2.1.0-alpha.26
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 +4 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +35 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +35 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +35 -2
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +4 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.js +37 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +37 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -407,6 +407,9 @@ var Caching = class _Caching {
|
|
|
407
407
|
static {
|
|
408
408
|
this.entityModelCache = _Caching.createAssetCache();
|
|
409
409
|
}
|
|
410
|
+
static {
|
|
411
|
+
this.entityTextureCache = _Caching.createAssetCache();
|
|
412
|
+
}
|
|
410
413
|
static createAssetCache() {
|
|
411
414
|
return Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
|
|
412
415
|
}
|
|
@@ -430,7 +433,8 @@ var Caching = class _Caching {
|
|
|
430
433
|
this.listAssetCache,
|
|
431
434
|
this.defaultBlockStatesCache,
|
|
432
435
|
this.blockTintCache,
|
|
433
|
-
this.entityModelCache
|
|
436
|
+
this.entityModelCache,
|
|
437
|
+
this.entityTextureCache
|
|
434
438
|
];
|
|
435
439
|
}
|
|
436
440
|
static clear() {
|
|
@@ -2728,7 +2732,37 @@ var Entities = class {
|
|
|
2728
2732
|
if (!layer) {
|
|
2729
2733
|
throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2730
2734
|
}
|
|
2731
|
-
|
|
2735
|
+
let texture;
|
|
2736
|
+
if (textureKey) {
|
|
2737
|
+
const path2 = isAssetKey(textureKey) ? textureKey.getFullPath() : textureKey.path;
|
|
2738
|
+
texture = isAssetKey(textureKey) && textureKey.assetType === "textures" && path2.startsWith("entity/") ? textureKey : new AssetKey(textureKey.namespace, path2, "textures", "entity", "assets", ".png", isAssetKey(textureKey) ? textureKey.root : void 0);
|
|
2739
|
+
} else if (layer.textureLocation !== void 0) {
|
|
2740
|
+
texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
2741
|
+
} else {
|
|
2742
|
+
texture = await this.resolveTexture(modelKey);
|
|
2743
|
+
}
|
|
2744
|
+
return { key: textureKey ?? modelKey, texture, layer, id: model.id };
|
|
2745
|
+
}
|
|
2746
|
+
static async resolveTexture(modelKey) {
|
|
2747
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2748
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2749
|
+
return Caching.entityTextureCache.get(key.serialize(), async () => {
|
|
2750
|
+
const name = path.split("/").pop();
|
|
2751
|
+
for (const candidate of [path, `${path}/${name}`]) {
|
|
2752
|
+
const texture = new AssetKey(modelKey.namespace, candidate, "textures", "entity", "assets", ".png");
|
|
2753
|
+
if (await ModelTextures.get(texture)) return texture;
|
|
2754
|
+
}
|
|
2755
|
+
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json");
|
|
2756
|
+
const list = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
2757
|
+
const files = list?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
2758
|
+
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
2759
|
+
if (!file) return void 0;
|
|
2760
|
+
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json");
|
|
2761
|
+
const variant = await AssetLoader.get(variantKey, "json" /* JSON */);
|
|
2762
|
+
const assets = variant?.assets;
|
|
2763
|
+
const textureId = variant?.asset_id ?? (typeof assets?.wild === "string" ? assets.wild : Object.values(assets ?? {}).find((value) => typeof value === "string"));
|
|
2764
|
+
return typeof textureId === "string" ? AssetKey.parse("textures", textureId) : void 0;
|
|
2765
|
+
});
|
|
2732
2766
|
}
|
|
2733
2767
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
2734
2768
|
static getBlockList() {
|
|
@@ -3177,6 +3211,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
3177
3211
|
super.dispose();
|
|
3178
3212
|
}
|
|
3179
3213
|
get textureKey() {
|
|
3214
|
+
if (this.entity.texture) return this.entity.texture;
|
|
3180
3215
|
const key = this.entity.key;
|
|
3181
3216
|
return new AssetKey(
|
|
3182
3217
|
key.namespace,
|