minerender 2.1.0-alpha.146 → 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 +5 -2
- package/dist/node/index.d.ts +5 -2
- package/dist/node/index.js +46 -20
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +46 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -35733,6 +35733,8 @@ void main() {
|
|
|
35733
35733
|
};
|
|
35734
35734
|
}
|
|
35735
35735
|
};
|
|
35736
|
+
/** Cached in place of a missing asset. The caches drop `undefined` results, which would request the asset again. */
|
|
35737
|
+
_Caching.MISSING = false;
|
|
35736
35738
|
_Caching._generation = 0;
|
|
35737
35739
|
_Caching.rawImageCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(5)).buildAsync();
|
|
35738
35740
|
_Caching.imageDataCache = Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(10)).buildAsync();
|
|
@@ -81427,15 +81429,21 @@ ${key}` : key;
|
|
|
81427
81429
|
key.extension += ".mcmeta";
|
|
81428
81430
|
}
|
|
81429
81431
|
const keyStr = key.serialize();
|
|
81430
|
-
|
|
81431
|
-
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
81432
|
-
|
|
81433
|
-
|
|
81434
|
-
|
|
81435
|
-
|
|
81436
|
-
|
|
81432
|
+
const meta = await Caching.textureMetaCache.get(keyStr, (k4) => {
|
|
81433
|
+
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), async (k1) => {
|
|
81434
|
+
if (AssetLoader.persistentScope === "") {
|
|
81435
|
+
const path = key.getFullPath();
|
|
81436
|
+
const slash = path.lastIndexOf("/");
|
|
81437
|
+
const listKey = new AssetKey(key.namespace, `${path.slice(0, slash + 1)}_list`, "textures", void 0, "assets", ".json", key.root);
|
|
81438
|
+
const list2 = await Caching.listAssetCache.get(listKey.serialize(), () => AssetLoader.get(listKey, "list" /* LIST */)).catch(() => void 0);
|
|
81439
|
+
if (list2 && !list2.files.includes(`${path.slice(slash + 1)}${key.extension}`)) return Caching.MISSING;
|
|
81440
|
+
}
|
|
81441
|
+
const asset2 = await AssetLoader.get(key, "meta" /* META */);
|
|
81442
|
+
if (asset2) asset2.key = key;
|
|
81443
|
+
return asset2 ?? Caching.MISSING;
|
|
81437
81444
|
});
|
|
81438
81445
|
});
|
|
81446
|
+
return meta === Caching.MISSING ? void 0 : meta;
|
|
81439
81447
|
}
|
|
81440
81448
|
/** Clears persisted texture metadata. Use {@link Caching.clear} to discard in-memory textures and metadata. */
|
|
81441
81449
|
static async clearCache() {
|
|
@@ -83736,26 +83744,27 @@ ${key}` : key, async () => {
|
|
|
83736
83744
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
83737
83745
|
const root = isAssetKey(modelKey) ? modelKey.root : void 0;
|
|
83738
83746
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json", root);
|
|
83739
|
-
|
|
83747
|
+
const texture = await Caching.entityTextureCache.get(key.serialize(), async () => {
|
|
83740
83748
|
const name2 = path.split("/").pop();
|
|
83741
83749
|
for (const candidate of [path, `${path}/${name2}`]) {
|
|
83742
|
-
const
|
|
83743
|
-
if (await ModelTextures.get(
|
|
83750
|
+
const texture3 = new AssetKey(modelKey.namespace, candidate, "textures", "entity", "assets", ".png", root);
|
|
83751
|
+
if (await ModelTextures.get(texture3)) return texture3;
|
|
83744
83752
|
}
|
|
83745
83753
|
const listKey = new AssetKey(modelKey.namespace, "_list", `${name2}_variant`, void 0, "data", ".json", root);
|
|
83746
83754
|
const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
83747
83755
|
const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
83748
83756
|
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
83749
|
-
if (!file) return
|
|
83757
|
+
if (!file) return Caching.MISSING;
|
|
83750
83758
|
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name2}_variant`, void 0, "data", ".json", root);
|
|
83751
83759
|
const variant = await AssetLoader.get(variantKey, "json" /* JSON */);
|
|
83752
83760
|
const assets = variant?.assets;
|
|
83753
83761
|
const textureId = variant?.asset_id ?? (typeof assets?.wild === "string" ? assets.wild : Object.values(assets ?? {}).find((value) => typeof value === "string"));
|
|
83754
|
-
if (typeof textureId !== "string") return
|
|
83755
|
-
const
|
|
83756
|
-
|
|
83757
|
-
return
|
|
83762
|
+
if (typeof textureId !== "string") return Caching.MISSING;
|
|
83763
|
+
const texture2 = AssetKey.parse("textures", textureId);
|
|
83764
|
+
texture2.root = root;
|
|
83765
|
+
return texture2;
|
|
83758
83766
|
});
|
|
83767
|
+
return texture === Caching.MISSING ? void 0 : texture;
|
|
83759
83768
|
}
|
|
83760
83769
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
83761
83770
|
static getBlockList() {
|
|
@@ -91333,6 +91342,10 @@ ${key}` : key, async () => {
|
|
|
91333
91342
|
});
|
|
91334
91343
|
|
|
91335
91344
|
// src/skin/PlayerHeadTextures.ts
|
|
91345
|
+
var PlayerHeadTextures_exports = {};
|
|
91346
|
+
__export(PlayerHeadTextures_exports, {
|
|
91347
|
+
PlayerHeadTextures: () => PlayerHeadTextures
|
|
91348
|
+
});
|
|
91336
91349
|
var PlayerHeadTextures;
|
|
91337
91350
|
var init_PlayerHeadTextures = __esm({
|
|
91338
91351
|
"src/skin/PlayerHeadTextures.ts"() {
|
|
@@ -93093,17 +93106,25 @@ ${shader.fragmentShader}`.replace(
|
|
|
93093
93106
|
if (!key || this.options.displayPosition) return false;
|
|
93094
93107
|
const generation = this._entityGeneration;
|
|
93095
93108
|
const created = [];
|
|
93109
|
+
const placement = new Matrix4();
|
|
93096
93110
|
let resolved;
|
|
93097
93111
|
try {
|
|
93098
93112
|
resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
|
|
93099
93113
|
if (!resolved) return false;
|
|
93114
|
+
BlockEntities.matrix(resolved, placement);
|
|
93100
93115
|
for (const part of resolved.parts) {
|
|
93101
93116
|
const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
|
|
93102
|
-
|
|
93117
|
+
let texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
93118
|
+
if (part.textureLocation === void 0 && namespace === "minecraft" && path === "player_head") {
|
|
93119
|
+
const { PlayerHeadTextures: PlayerHeadTextures2 } = await Promise.resolve().then(() => (init_PlayerHeadTextures(), PlayerHeadTextures_exports));
|
|
93120
|
+
texture = (await PlayerHeadTextures2.get(void 0, key.root)).texture;
|
|
93121
|
+
}
|
|
93103
93122
|
if (texture) texture.root = key.root;
|
|
93104
93123
|
const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
|
|
93105
93124
|
if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
|
|
93106
|
-
|
|
93125
|
+
const object4 = await this.scene.addEntity(entity, { wireframe: this.options.wireframe });
|
|
93126
|
+
this.placeEntity(object4, placement);
|
|
93127
|
+
created.push(object4);
|
|
93107
93128
|
}
|
|
93108
93129
|
} catch (error2) {
|
|
93109
93130
|
log19.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error2);
|
|
@@ -93114,18 +93135,21 @@ ${shader.fragmentShader}`.replace(
|
|
|
93114
93135
|
this.removeEntities(created);
|
|
93115
93136
|
return true;
|
|
93116
93137
|
}
|
|
93117
|
-
|
|
93138
|
+
this._entityPlacement.copy(placement);
|
|
93118
93139
|
this._entities = created;
|
|
93119
93140
|
this.placeEntities();
|
|
93120
93141
|
this.setVisible(this.visible);
|
|
93121
93142
|
return true;
|
|
93122
93143
|
}
|
|
93123
93144
|
placeEntities() {
|
|
93124
|
-
const matrix = new Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
93125
93145
|
for (const entity of this._entities) {
|
|
93126
|
-
|
|
93146
|
+
this.placeEntity(entity, this._entityPlacement);
|
|
93127
93147
|
}
|
|
93128
93148
|
}
|
|
93149
|
+
placeEntity(entity, placement) {
|
|
93150
|
+
const matrix = new Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(placement);
|
|
93151
|
+
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
93152
|
+
}
|
|
93129
93153
|
get isOccluding() {
|
|
93130
93154
|
if (!this.visible) {
|
|
93131
93155
|
return false;
|