minerender 2.1.0-alpha.12 → 2.1.0-alpha.14
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 +9 -2
- package/dist/browser/index.d.ts +9 -2
- package/dist/browser/index.js +78 -31
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +78 -31
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +78 -31
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +9 -2
- package/dist/node/index.d.ts +9 -2
- package/dist/node/index.js +78 -31
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +78 -31
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -65263,7 +65263,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
65263
65263
|
|
|
65264
65264
|
// src/Axis.ts
|
|
65265
65265
|
var Axis = /* @__PURE__ */ ((Axis3) => {
|
|
65266
|
-
Axis3["X"] = "
|
|
65266
|
+
Axis3["X"] = "x";
|
|
65267
65267
|
Axis3["Y"] = "y";
|
|
65268
65268
|
Axis3["Z"] = "z";
|
|
65269
65269
|
return Axis3;
|
|
@@ -65271,7 +65271,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
65271
65271
|
var AXES = Object.values(Axis);
|
|
65272
65272
|
function axisToVec3(axis) {
|
|
65273
65273
|
switch (axis) {
|
|
65274
|
-
case "
|
|
65274
|
+
case "x" /* X */:
|
|
65275
65275
|
return new Vector3(1, 0, 0);
|
|
65276
65276
|
case "y" /* Y */:
|
|
65277
65277
|
return new Vector3(0, 1, 0);
|
|
@@ -67173,7 +67173,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67173
67173
|
}
|
|
67174
67174
|
toString() {
|
|
67175
67175
|
let a4 = [
|
|
67176
|
-
|
|
67176
|
+
this.root ?? AssetLoader.ROOT,
|
|
67177
67177
|
this.rootType ?? "__rootType__",
|
|
67178
67178
|
this.assetType ?? "__assetType__",
|
|
67179
67179
|
this.type ?? "__type__",
|
|
@@ -67210,9 +67210,9 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67210
67210
|
const models = await this.collectAllParents(model);
|
|
67211
67211
|
let merged = {};
|
|
67212
67212
|
for (let parentModel of models) {
|
|
67213
|
-
merged =
|
|
67213
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, parentModel);
|
|
67214
67214
|
}
|
|
67215
|
-
merged =
|
|
67215
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
67216
67216
|
merged.hierarchy = models.map((m4) => m4.parent).filter((p15) => `${p15}`);
|
|
67217
67217
|
merged.hierarchy.push(`${merged.parent}`);
|
|
67218
67218
|
return merged;
|
|
@@ -67223,6 +67223,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67223
67223
|
}
|
|
67224
67224
|
const models = [];
|
|
67225
67225
|
const parentKey = AssetKey.parse("models", model.parent);
|
|
67226
|
+
parentKey.root = model.key?.root;
|
|
67226
67227
|
const parentModel = await Models.getRaw(parentKey);
|
|
67227
67228
|
if (parentModel) {
|
|
67228
67229
|
models.unshift(parentModel);
|
|
@@ -67255,26 +67256,58 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67255
67256
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-models"));
|
|
67256
67257
|
}
|
|
67257
67258
|
static async getItemList() {
|
|
67258
|
-
const key = new AssetKey(
|
|
67259
|
-
|
|
67260
|
-
|
|
67261
|
-
"
|
|
67262
|
-
"item",
|
|
67263
|
-
"assets",
|
|
67264
|
-
".json",
|
|
67265
|
-
DEFAULT_ROOT
|
|
67266
|
-
);
|
|
67267
|
-
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
67268
|
-
return AssetLoader.get(key, "list" /* LIST */);
|
|
67259
|
+
const key = new AssetKey(DEFAULT_NAMESPACE, "_list", "items");
|
|
67260
|
+
const legacyKey = new AssetKey(DEFAULT_NAMESPACE, "_list", "models", "item");
|
|
67261
|
+
return Caching.listAssetCache.get(key.serialize(), async () => {
|
|
67262
|
+
return (await AssetLoader.getFirst([key, legacyKey], "list" /* LIST */))?.asset;
|
|
67269
67263
|
}).then((r5) => r5?.files ?? []);
|
|
67270
67264
|
}
|
|
67271
67265
|
static async loadAndMerge(key) {
|
|
67272
|
-
const model = await this.getRaw(key);
|
|
67266
|
+
const model = key.type === "item" ? await this.getItemModel(key) : await this.getRaw(key);
|
|
67273
67267
|
if (!model) {
|
|
67274
67268
|
return void 0;
|
|
67275
67269
|
}
|
|
67276
67270
|
return ModelMerger.mergeWithParents(model);
|
|
67277
67271
|
}
|
|
67272
|
+
static async getItemModel(key) {
|
|
67273
|
+
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
67274
|
+
const model = await this.PERSISTENT_CACHE.getOrLoad(itemKey.serialize(), async () => {
|
|
67275
|
+
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
67276
|
+
if (!result) return void 0;
|
|
67277
|
+
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
67278
|
+
const reference = this.defaultItemModel(result.asset.model, key);
|
|
67279
|
+
const modelKey = AssetKey.parse("models", reference);
|
|
67280
|
+
modelKey.root = key.root;
|
|
67281
|
+
const model2 = await this.getRaw(modelKey);
|
|
67282
|
+
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${reference}`);
|
|
67283
|
+
return model2;
|
|
67284
|
+
});
|
|
67285
|
+
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
67286
|
+
}
|
|
67287
|
+
// Item previews use the GUI context, false conditions, and zero numeric properties.
|
|
67288
|
+
static defaultItemModel(node, key) {
|
|
67289
|
+
if (!node || typeof node.type !== "string") {
|
|
67290
|
+
throw new Error(`Unsupported item model definition for ${key.toNamespacedString()}`);
|
|
67291
|
+
}
|
|
67292
|
+
switch (node.type.replace(/^minecraft:/, "")) {
|
|
67293
|
+
case "model":
|
|
67294
|
+
if (typeof node.model === "string" && node.model) return node.model;
|
|
67295
|
+
break;
|
|
67296
|
+
case "condition":
|
|
67297
|
+
return this.defaultItemModel(node.on_false, key);
|
|
67298
|
+
case "select": {
|
|
67299
|
+
const selected = node.property?.replace(/^minecraft:/, "") === "display_context" ? node.cases?.find((entry) => Array.isArray(entry.when) ? entry.when.includes("gui") : entry.when === "gui")?.model : void 0;
|
|
67300
|
+
return this.defaultItemModel(selected ?? node.fallback, key);
|
|
67301
|
+
}
|
|
67302
|
+
case "range_dispatch": {
|
|
67303
|
+
const selected = node.entries?.reduce((match, entry) => {
|
|
67304
|
+
return entry.threshold <= 0 && (!match || entry.threshold >= match.threshold) ? entry : match;
|
|
67305
|
+
}, void 0);
|
|
67306
|
+
return this.defaultItemModel(selected?.model ?? node.fallback, key);
|
|
67307
|
+
}
|
|
67308
|
+
}
|
|
67309
|
+
throw new Error(`Unsupported item model ${node?.type ?? "definition"} for ${key.toNamespacedString()}`);
|
|
67310
|
+
}
|
|
67278
67311
|
static async getRaw(key) {
|
|
67279
67312
|
if (!key.assetType) {
|
|
67280
67313
|
key.assetType = "models";
|
|
@@ -67384,7 +67417,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67384
67417
|
};
|
|
67385
67418
|
|
|
67386
67419
|
// src/assets/Assets.ts
|
|
67387
|
-
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.
|
|
67420
|
+
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
|
|
67388
67421
|
var DEFAULT_NAMESPACE = "minecraft";
|
|
67389
67422
|
var Assets = class {
|
|
67390
67423
|
/**
|
|
@@ -67468,7 +67501,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67468
67501
|
const origin = new Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
67469
67502
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
67470
67503
|
switch (rotation.axis) {
|
|
67471
|
-
case "
|
|
67504
|
+
case "x" /* X */:
|
|
67472
67505
|
geometry.rotateX(toRadians(rotation.angle));
|
|
67473
67506
|
break;
|
|
67474
67507
|
case "y" /* Y */:
|
|
@@ -67499,7 +67532,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67499
67532
|
}
|
|
67500
67533
|
function applyGenericRotation(axis, rotation, obj) {
|
|
67501
67534
|
switch (axis) {
|
|
67502
|
-
case "
|
|
67535
|
+
case "x" /* X */:
|
|
67503
67536
|
obj.rotateOnAxis(new Vector3(1, 0, 0), toRadians(rotation));
|
|
67504
67537
|
break;
|
|
67505
67538
|
case "y" /* Y */:
|
|
@@ -77317,11 +77350,29 @@ return ${compiler2.callType("value", tagType)}
|
|
|
77317
77350
|
}
|
|
77318
77351
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
77319
77352
|
static async get(key, parser) {
|
|
77353
|
+
const keys = [key];
|
|
77354
|
+
if (key.rootType === "data" && (key.assetType === "structure" || key.assetType === "structures")) {
|
|
77355
|
+
keys.push(new AssetKey(
|
|
77356
|
+
key.namespace,
|
|
77357
|
+
key.path,
|
|
77358
|
+
key.assetType === "structure" ? "structures" : "structure",
|
|
77359
|
+
key.type,
|
|
77360
|
+
key.rootType,
|
|
77361
|
+
key.extension,
|
|
77362
|
+
key.root
|
|
77363
|
+
));
|
|
77364
|
+
}
|
|
77365
|
+
return (await this.getFirst(keys, parser))?.asset;
|
|
77366
|
+
}
|
|
77367
|
+
/** Tries each path within a source before considering lower-priority sources. */
|
|
77368
|
+
static async getFirst(keys, parser) {
|
|
77320
77369
|
const sources = [...this._SOURCES];
|
|
77321
77370
|
for (const source of sources) {
|
|
77322
|
-
const
|
|
77323
|
-
|
|
77324
|
-
|
|
77371
|
+
for (const key of keys) {
|
|
77372
|
+
const result = await source.source.get(key, parser);
|
|
77373
|
+
if (result !== void 0) {
|
|
77374
|
+
return { key, asset: result };
|
|
77375
|
+
}
|
|
77325
77376
|
}
|
|
77326
77377
|
}
|
|
77327
77378
|
return void 0;
|
|
@@ -77865,17 +77916,13 @@ return ${compiler2.callType("value", tagType)}
|
|
|
77865
77916
|
this.setCubeFaceUvInArray(uv, faceIndex * 4, [0, 1, 8 / size, (size - 8) / size]);
|
|
77866
77917
|
continue;
|
|
77867
77918
|
}
|
|
77919
|
+
if (!face.texture) continue;
|
|
77868
77920
|
if (!face.uv) {
|
|
77869
77921
|
face.uv = this.getFallbackUv(element, faceName);
|
|
77870
77922
|
}
|
|
77871
|
-
|
|
77872
|
-
|
|
77873
|
-
|
|
77874
|
-
if (faceTexture) {
|
|
77875
|
-
faceTexture = faceTexture.substr(1);
|
|
77876
|
-
texPosition = positions[faceTexture] || [0, 0];
|
|
77877
|
-
texSize = sizes[faceTexture] || [16, 16];
|
|
77878
|
-
}
|
|
77923
|
+
const faceTexture = face.texture.substr(1);
|
|
77924
|
+
const texPosition = positions[faceTexture] || [0, 0];
|
|
77925
|
+
const texSize = sizes[faceTexture] || [16, 16];
|
|
77879
77926
|
let texPosV = new Vector2(texPosition[0], texPosition[1]);
|
|
77880
77927
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
77881
77928
|
tl.add(texPosV);
|