minerender 2.1.0-alpha.145 → 2.1.0-alpha.147
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/esm/assets/Entities.mjs +9 -8
- package/dist/browser/esm/assets/Entities.mjs.map +1 -1
- package/dist/browser/esm/assets/ModelTextures.mjs +13 -7
- package/dist/browser/esm/assets/ModelTextures.mjs.map +1 -1
- package/dist/browser/esm/cache/Caching.mjs +2 -0
- package/dist/browser/esm/cache/Caching.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +5 -2
- package/dist/browser/esm/model/block/scene/BlockObject.mjs +16 -5
- package/dist/browser/esm/model/block/scene/BlockObject.mjs.map +1 -1
- package/dist/browser/index.d.ts +5 -2
- package/dist/browser/index.js +44 -20
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +44 -20
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +6 -2
- package/dist/node/index.d.ts +6 -2
- package/dist/node/index.js +59 -22
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +59 -22
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -386,6 +386,8 @@ var init_Caching = __esm({
|
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
|
+
/** Cached in place of a missing asset. The caches drop `undefined` results, which would request the asset again. */
|
|
390
|
+
_Caching.MISSING = false;
|
|
389
391
|
_Caching._generation = 0;
|
|
390
392
|
_Caching.rawImageCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(5)).buildAsync();
|
|
391
393
|
_Caching.imageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
@@ -2321,15 +2323,21 @@ var init_ModelTextures = __esm({
|
|
|
2321
2323
|
key.extension += ".mcmeta";
|
|
2322
2324
|
}
|
|
2323
2325
|
const keyStr = key.serialize();
|
|
2324
|
-
|
|
2325
|
-
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2326
|
+
const meta = await Caching.textureMetaCache.get(keyStr, (k) => {
|
|
2327
|
+
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), async (k1) => {
|
|
2328
|
+
if (AssetLoader.persistentScope === "") {
|
|
2329
|
+
const path = key.getFullPath();
|
|
2330
|
+
const slash = path.lastIndexOf("/");
|
|
2331
|
+
const listKey = new AssetKey(key.namespace, `${path.slice(0, slash + 1)}_list`, "textures", void 0, "assets", ".json", key.root);
|
|
2332
|
+
const list2 = await Caching.listAssetCache.get(listKey.serialize(), () => AssetLoader.get(listKey, "list" /* LIST */)).catch(() => void 0);
|
|
2333
|
+
if (list2 && !list2.files.includes(`${path.slice(slash + 1)}${key.extension}`)) return Caching.MISSING;
|
|
2334
|
+
}
|
|
2335
|
+
const asset2 = await AssetLoader.get(key, "meta" /* META */);
|
|
2336
|
+
if (asset2) asset2.key = key;
|
|
2337
|
+
return asset2 ?? Caching.MISSING;
|
|
2331
2338
|
});
|
|
2332
2339
|
});
|
|
2340
|
+
return meta === Caching.MISSING ? void 0 : meta;
|
|
2333
2341
|
}
|
|
2334
2342
|
/** Clears persisted texture metadata. Use {@link Caching.clear} to discard in-memory textures and metadata. */
|
|
2335
2343
|
static async clearCache() {
|
|
@@ -4558,26 +4566,27 @@ var init_Entities = __esm({
|
|
|
4558
4566
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
4559
4567
|
const root = isAssetKey(modelKey) ? modelKey.root : void 0;
|
|
4560
4568
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json", root);
|
|
4561
|
-
|
|
4569
|
+
const texture = await Caching.entityTextureCache.get(key.serialize(), async () => {
|
|
4562
4570
|
const name = path.split("/").pop();
|
|
4563
4571
|
for (const candidate of [path, `${path}/${name}`]) {
|
|
4564
|
-
const
|
|
4565
|
-
if (await ModelTextures.get(
|
|
4572
|
+
const texture3 = new AssetKey(modelKey.namespace, candidate, "textures", "entity", "assets", ".png", root);
|
|
4573
|
+
if (await ModelTextures.get(texture3)) return texture3;
|
|
4566
4574
|
}
|
|
4567
4575
|
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json", root);
|
|
4568
4576
|
const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
4569
4577
|
const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
4570
4578
|
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
4571
|
-
if (!file) return
|
|
4579
|
+
if (!file) return Caching.MISSING;
|
|
4572
4580
|
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json", root);
|
|
4573
4581
|
const variant = await AssetLoader.get(variantKey, "json" /* JSON */);
|
|
4574
4582
|
const assets = variant?.assets;
|
|
4575
4583
|
const textureId = variant?.asset_id ?? (typeof assets?.wild === "string" ? assets.wild : Object.values(assets ?? {}).find((value) => typeof value === "string"));
|
|
4576
|
-
if (typeof textureId !== "string") return
|
|
4577
|
-
const
|
|
4578
|
-
|
|
4579
|
-
return
|
|
4584
|
+
if (typeof textureId !== "string") return Caching.MISSING;
|
|
4585
|
+
const texture2 = AssetKey.parse("textures", textureId);
|
|
4586
|
+
texture2.root = root;
|
|
4587
|
+
return texture2;
|
|
4580
4588
|
});
|
|
4589
|
+
return texture === Caching.MISSING ? void 0 : texture;
|
|
4581
4590
|
}
|
|
4582
4591
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
4583
4592
|
static getBlockList() {
|
|
@@ -9368,6 +9377,10 @@ var init_SkinTextures = __esm({
|
|
|
9368
9377
|
});
|
|
9369
9378
|
|
|
9370
9379
|
// src/skin/PlayerHeadTextures.ts
|
|
9380
|
+
var PlayerHeadTextures_exports = {};
|
|
9381
|
+
__export(PlayerHeadTextures_exports, {
|
|
9382
|
+
PlayerHeadTextures: () => PlayerHeadTextures
|
|
9383
|
+
});
|
|
9371
9384
|
var PlayerHeadTextures;
|
|
9372
9385
|
var init_PlayerHeadTextures = __esm({
|
|
9373
9386
|
"src/skin/PlayerHeadTextures.ts"() {
|
|
@@ -11093,17 +11106,25 @@ var init_BlockObject = __esm({
|
|
|
11093
11106
|
if (!key || this.options.displayPosition) return false;
|
|
11094
11107
|
const generation = this._entityGeneration;
|
|
11095
11108
|
const created = [];
|
|
11109
|
+
const placement = new import_three34.Matrix4();
|
|
11096
11110
|
let resolved;
|
|
11097
11111
|
try {
|
|
11098
11112
|
resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
|
|
11099
11113
|
if (!resolved) return false;
|
|
11114
|
+
BlockEntities.matrix(resolved, placement);
|
|
11100
11115
|
for (const part of resolved.parts) {
|
|
11101
11116
|
const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
|
|
11102
|
-
|
|
11117
|
+
let texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
11118
|
+
if (part.textureLocation === void 0 && namespace === "minecraft" && path === "player_head") {
|
|
11119
|
+
const { PlayerHeadTextures: PlayerHeadTextures2 } = await Promise.resolve().then(() => (init_PlayerHeadTextures(), PlayerHeadTextures_exports));
|
|
11120
|
+
texture = (await PlayerHeadTextures2.get(void 0, key.root)).texture;
|
|
11121
|
+
}
|
|
11103
11122
|
if (texture) texture.root = key.root;
|
|
11104
11123
|
const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
|
|
11105
11124
|
if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
|
|
11106
|
-
|
|
11125
|
+
const object4 = await this.scene.addEntity(entity, { wireframe: this.options.wireframe });
|
|
11126
|
+
this.placeEntity(object4, placement);
|
|
11127
|
+
created.push(object4);
|
|
11107
11128
|
}
|
|
11108
11129
|
} catch (error) {
|
|
11109
11130
|
log17.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
|
|
@@ -11114,18 +11135,21 @@ var init_BlockObject = __esm({
|
|
|
11114
11135
|
this.removeEntities(created);
|
|
11115
11136
|
return true;
|
|
11116
11137
|
}
|
|
11117
|
-
|
|
11138
|
+
this._entityPlacement.copy(placement);
|
|
11118
11139
|
this._entities = created;
|
|
11119
11140
|
this.placeEntities();
|
|
11120
11141
|
this.setVisible(this.visible);
|
|
11121
11142
|
return true;
|
|
11122
11143
|
}
|
|
11123
11144
|
placeEntities() {
|
|
11124
|
-
const matrix = new import_three34.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
11125
11145
|
for (const entity of this._entities) {
|
|
11126
|
-
|
|
11146
|
+
this.placeEntity(entity, this._entityPlacement);
|
|
11127
11147
|
}
|
|
11128
11148
|
}
|
|
11149
|
+
placeEntity(entity, placement) {
|
|
11150
|
+
const matrix = new import_three34.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(placement);
|
|
11151
|
+
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
11152
|
+
}
|
|
11129
11153
|
get isOccluding() {
|
|
11130
11154
|
if (!this.visible) {
|
|
11131
11155
|
return false;
|