minerender 2.1.0-alpha.24 → 2.1.0-alpha.25
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 +3 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +33 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +33 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +33 -2
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +3 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +35 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +35 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -413,7 +413,8 @@ var _Caching = class _Caching {
|
|
|
413
413
|
this.listAssetCache,
|
|
414
414
|
this.defaultBlockStatesCache,
|
|
415
415
|
this.blockTintCache,
|
|
416
|
-
this.entityModelCache
|
|
416
|
+
this.entityModelCache,
|
|
417
|
+
this.entityTextureCache
|
|
417
418
|
];
|
|
418
419
|
}
|
|
419
420
|
static clear() {
|
|
@@ -457,6 +458,7 @@ _Caching.listAssetCache = _Caching.createAssetCache();
|
|
|
457
458
|
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
458
459
|
_Caching.blockTintCache = _Caching.createAssetCache();
|
|
459
460
|
_Caching.entityModelCache = _Caching.createAssetCache();
|
|
461
|
+
_Caching.entityTextureCache = _Caching.createAssetCache();
|
|
460
462
|
var Caching = _Caching;
|
|
461
463
|
|
|
462
464
|
// src/Geometries.ts
|
|
@@ -2688,7 +2690,35 @@ var Entities = class {
|
|
|
2688
2690
|
if (!layer) {
|
|
2689
2691
|
throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2690
2692
|
}
|
|
2691
|
-
|
|
2693
|
+
let texture;
|
|
2694
|
+
if (textureKey) {
|
|
2695
|
+
const path2 = isAssetKey(textureKey) ? textureKey.getFullPath() : textureKey.path;
|
|
2696
|
+
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);
|
|
2697
|
+
} else {
|
|
2698
|
+
texture = await this.resolveTexture(modelKey);
|
|
2699
|
+
}
|
|
2700
|
+
return { key: textureKey ?? modelKey, texture, layer, id: model.id };
|
|
2701
|
+
}
|
|
2702
|
+
static async resolveTexture(modelKey) {
|
|
2703
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2704
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2705
|
+
return Caching.entityTextureCache.get(key.serialize(), async () => {
|
|
2706
|
+
const name = path.split("/").pop();
|
|
2707
|
+
for (const candidate of [path, `${path}/${name}`]) {
|
|
2708
|
+
const texture = new AssetKey(modelKey.namespace, candidate, "textures", "entity", "assets", ".png");
|
|
2709
|
+
if (await ModelTextures.get(texture)) return texture;
|
|
2710
|
+
}
|
|
2711
|
+
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json");
|
|
2712
|
+
const list = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
2713
|
+
const files = list?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
2714
|
+
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
2715
|
+
if (!file) return void 0;
|
|
2716
|
+
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json");
|
|
2717
|
+
const variant = await AssetLoader.get(variantKey, "json" /* JSON */);
|
|
2718
|
+
const assets = variant?.assets;
|
|
2719
|
+
const textureId = variant?.asset_id ?? (typeof assets?.wild === "string" ? assets.wild : Object.values(assets ?? {}).find((value) => typeof value === "string"));
|
|
2720
|
+
return typeof textureId === "string" ? AssetKey.parse("textures", textureId) : void 0;
|
|
2721
|
+
});
|
|
2692
2722
|
}
|
|
2693
2723
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
2694
2724
|
static getBlockList() {
|
|
@@ -3133,6 +3163,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
|
|
|
3133
3163
|
super.dispose();
|
|
3134
3164
|
}
|
|
3135
3165
|
get textureKey() {
|
|
3166
|
+
if (this.entity.texture) return this.entity.texture;
|
|
3136
3167
|
const key = this.entity.key;
|
|
3137
3168
|
return new AssetKey(
|
|
3138
3169
|
key.namespace,
|