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.d.mts
CHANGED
|
@@ -716,6 +716,7 @@ declare class DefaultBlockStates implements MinecraftAsset {
|
|
|
716
716
|
|
|
717
717
|
interface EntityModel {
|
|
718
718
|
key: BasicAssetKey;
|
|
719
|
+
texture?: AssetKey;
|
|
719
720
|
layer: EntityModelLayer;
|
|
720
721
|
id: string;
|
|
721
722
|
}
|
|
@@ -725,6 +726,7 @@ interface EntityModelFile extends MinecraftAsset {
|
|
|
725
726
|
}
|
|
726
727
|
interface EntityModelLayer {
|
|
727
728
|
texture: [number, number];
|
|
729
|
+
textureLocation?: string;
|
|
728
730
|
root: EntityModelPart;
|
|
729
731
|
}
|
|
730
732
|
interface EntityModelPart {
|
|
@@ -748,6 +750,7 @@ interface EntityModelCube {
|
|
|
748
750
|
declare class Entities {
|
|
749
751
|
static getEntityList(): Promise<string[]>;
|
|
750
752
|
static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
753
|
+
static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
|
|
751
754
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
752
755
|
static getBlockList(): Promise<string[]>;
|
|
753
756
|
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
@@ -1291,6 +1294,7 @@ declare class Caching {
|
|
|
1291
1294
|
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1292
1295
|
static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
|
|
1293
1296
|
static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
|
|
1297
|
+
static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
|
|
1294
1298
|
private static createAssetCache;
|
|
1295
1299
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1296
1300
|
private static get all();
|
package/dist/node/index.d.ts
CHANGED
|
@@ -716,6 +716,7 @@ declare class DefaultBlockStates implements MinecraftAsset {
|
|
|
716
716
|
|
|
717
717
|
interface EntityModel {
|
|
718
718
|
key: BasicAssetKey;
|
|
719
|
+
texture?: AssetKey;
|
|
719
720
|
layer: EntityModelLayer;
|
|
720
721
|
id: string;
|
|
721
722
|
}
|
|
@@ -725,6 +726,7 @@ interface EntityModelFile extends MinecraftAsset {
|
|
|
725
726
|
}
|
|
726
727
|
interface EntityModelLayer {
|
|
727
728
|
texture: [number, number];
|
|
729
|
+
textureLocation?: string;
|
|
728
730
|
root: EntityModelPart;
|
|
729
731
|
}
|
|
730
732
|
interface EntityModelPart {
|
|
@@ -748,6 +750,7 @@ interface EntityModelCube {
|
|
|
748
750
|
declare class Entities {
|
|
749
751
|
static getEntityList(): Promise<string[]>;
|
|
750
752
|
static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
753
|
+
static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
|
|
751
754
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
752
755
|
static getBlockList(): Promise<string[]>;
|
|
753
756
|
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
@@ -1291,6 +1294,7 @@ declare class Caching {
|
|
|
1291
1294
|
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1292
1295
|
static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
|
|
1293
1296
|
static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
|
|
1297
|
+
static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
|
|
1294
1298
|
private static createAssetCache;
|
|
1295
1299
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1296
1300
|
private static get all();
|
package/dist/node/index.js
CHANGED
|
@@ -561,6 +561,9 @@ var Caching = class _Caching {
|
|
|
561
561
|
static {
|
|
562
562
|
this.entityModelCache = _Caching.createAssetCache();
|
|
563
563
|
}
|
|
564
|
+
static {
|
|
565
|
+
this.entityTextureCache = _Caching.createAssetCache();
|
|
566
|
+
}
|
|
564
567
|
static createAssetCache() {
|
|
565
568
|
return import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
566
569
|
}
|
|
@@ -584,7 +587,8 @@ var Caching = class _Caching {
|
|
|
584
587
|
this.listAssetCache,
|
|
585
588
|
this.defaultBlockStatesCache,
|
|
586
589
|
this.blockTintCache,
|
|
587
|
-
this.entityModelCache
|
|
590
|
+
this.entityModelCache,
|
|
591
|
+
this.entityTextureCache
|
|
588
592
|
];
|
|
589
593
|
}
|
|
590
594
|
static clear() {
|
|
@@ -2882,7 +2886,37 @@ var Entities = class {
|
|
|
2882
2886
|
if (!layer) {
|
|
2883
2887
|
throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2884
2888
|
}
|
|
2885
|
-
|
|
2889
|
+
let texture;
|
|
2890
|
+
if (textureKey) {
|
|
2891
|
+
const path2 = isAssetKey(textureKey) ? textureKey.getFullPath() : textureKey.path;
|
|
2892
|
+
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);
|
|
2893
|
+
} else if (layer.textureLocation !== void 0) {
|
|
2894
|
+
texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
2895
|
+
} else {
|
|
2896
|
+
texture = await this.resolveTexture(modelKey);
|
|
2897
|
+
}
|
|
2898
|
+
return { key: textureKey ?? modelKey, texture, layer, id: model.id };
|
|
2899
|
+
}
|
|
2900
|
+
static async resolveTexture(modelKey) {
|
|
2901
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2902
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2903
|
+
return Caching.entityTextureCache.get(key.serialize(), async () => {
|
|
2904
|
+
const name = path.split("/").pop();
|
|
2905
|
+
for (const candidate of [path, `${path}/${name}`]) {
|
|
2906
|
+
const texture = new AssetKey(modelKey.namespace, candidate, "textures", "entity", "assets", ".png");
|
|
2907
|
+
if (await ModelTextures.get(texture)) return texture;
|
|
2908
|
+
}
|
|
2909
|
+
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json");
|
|
2910
|
+
const list = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
2911
|
+
const files = list?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
2912
|
+
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
2913
|
+
if (!file) return void 0;
|
|
2914
|
+
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json");
|
|
2915
|
+
const variant = await AssetLoader.get(variantKey, "json" /* JSON */);
|
|
2916
|
+
const assets = variant?.assets;
|
|
2917
|
+
const textureId = variant?.asset_id ?? (typeof assets?.wild === "string" ? assets.wild : Object.values(assets ?? {}).find((value) => typeof value === "string"));
|
|
2918
|
+
return typeof textureId === "string" ? AssetKey.parse("textures", textureId) : void 0;
|
|
2919
|
+
});
|
|
2886
2920
|
}
|
|
2887
2921
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
2888
2922
|
static getBlockList() {
|
|
@@ -3331,6 +3365,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
3331
3365
|
super.dispose();
|
|
3332
3366
|
}
|
|
3333
3367
|
get textureKey() {
|
|
3368
|
+
if (this.entity.texture) return this.entity.texture;
|
|
3334
3369
|
const key = this.entity.key;
|
|
3335
3370
|
return new AssetKey(
|
|
3336
3371
|
key.namespace,
|