minerender 2.1.0-alpha.22 → 2.1.0-alpha.24
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 +43 -48
- package/dist/browser/index.d.ts +43 -48
- package/dist/browser/index.js +121 -147
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +170 -196
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +125 -153
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +43 -48
- package/dist/node/index.d.ts +43 -48
- package/dist/node/index.js +120 -150
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +169 -196
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -45353,7 +45353,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
45353
45353
|
BUILTIN_GENERATED: () => BUILTIN_GENERATED,
|
|
45354
45354
|
BasicAssetKey: () => BasicAssetKey,
|
|
45355
45355
|
BatchedExecutor: () => BatchedExecutor,
|
|
45356
|
-
BlockEntityModels: () => BlockEntityModels,
|
|
45357
45356
|
BlockObject: () => BlockObject,
|
|
45358
45357
|
BlockStates: () => BlockStates,
|
|
45359
45358
|
BlockTints: () => BlockTints,
|
|
@@ -45375,7 +45374,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
45375
45374
|
DisplayPosition: () => DisplayPosition,
|
|
45376
45375
|
DisplayTransforms: () => DisplayTransforms,
|
|
45377
45376
|
Entities: () => Entities,
|
|
45378
|
-
EntityModels: () => EntityModels,
|
|
45379
45377
|
EntityObject: () => EntityObject,
|
|
45380
45378
|
Env: () => Env,
|
|
45381
45379
|
Geometries: () => Geometries,
|
|
@@ -45427,7 +45425,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
45427
45425
|
addWireframeToObject: () => addWireframeToObject,
|
|
45428
45426
|
applyElementRotation: () => applyElementRotation,
|
|
45429
45427
|
applyGenericRotation: () => applyGenericRotation,
|
|
45430
|
-
applyModelPartRotation: () => applyModelPartRotation,
|
|
45431
45428
|
axisToVec3: () => axisToVec3,
|
|
45432
45429
|
base64decode: () => base64decode,
|
|
45433
45430
|
base64encode: () => base64encode,
|
|
@@ -66383,7 +66380,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66383
66380
|
this.listAssetCache,
|
|
66384
66381
|
this.defaultBlockStatesCache,
|
|
66385
66382
|
this.blockTintCache,
|
|
66386
|
-
this.
|
|
66383
|
+
this.entityModelCache
|
|
66387
66384
|
];
|
|
66388
66385
|
}
|
|
66389
66386
|
static clear() {
|
|
@@ -66426,7 +66423,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66426
66423
|
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
66427
66424
|
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
66428
66425
|
_Caching.blockTintCache = _Caching.createAssetCache();
|
|
66429
|
-
_Caching.
|
|
66426
|
+
_Caching.entityModelCache = _Caching.createAssetCache();
|
|
66430
66427
|
var Caching = _Caching;
|
|
66431
66428
|
|
|
66432
66429
|
// src/Geometries.ts
|
|
@@ -67447,7 +67444,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67447
67444
|
void 0,
|
|
67448
67445
|
"assets",
|
|
67449
67446
|
".json",
|
|
67450
|
-
|
|
67447
|
+
AssetLoader.ROOT
|
|
67451
67448
|
);
|
|
67452
67449
|
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
67453
67450
|
return AssetLoader.get(key, "list" /* LIST */);
|
|
@@ -67605,14 +67602,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67605
67602
|
}
|
|
67606
67603
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
67607
67604
|
}
|
|
67608
|
-
function applyModelPartRotation(modelPart, geometry) {
|
|
67609
|
-
const origin = new Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
67610
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
67611
|
-
geometry.rotateX(toRadians(modelPart.pitch));
|
|
67612
|
-
geometry.rotateY(toRadians(modelPart.yaw));
|
|
67613
|
-
geometry.rotateZ(toRadians(modelPart.roll));
|
|
67614
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
67615
|
-
}
|
|
67616
67605
|
function applyGenericRotation(axis, rotation, obj) {
|
|
67617
67606
|
switch (axis) {
|
|
67618
67607
|
case "x" /* X */:
|
|
@@ -67745,17 +67734,17 @@ return ${compiler2.callType("value", tagType)}
|
|
|
67745
67734
|
if (typeof namespaced !== "undefined") {
|
|
67746
67735
|
return namespaced;
|
|
67747
67736
|
}
|
|
67748
|
-
if (typeof key.root !== "undefined" && key.root !==
|
|
67737
|
+
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
67749
67738
|
console.info(p6, "Retrying", key, "with default root+namespace");
|
|
67750
|
-
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
67739
|
+
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
67751
67740
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
67752
67741
|
if (typeof namespacedRooted !== "undefined") {
|
|
67753
67742
|
return namespacedRooted;
|
|
67754
67743
|
}
|
|
67755
67744
|
}
|
|
67756
|
-
} else if (typeof key.root !== "undefined" && key.root !==
|
|
67745
|
+
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
67757
67746
|
console.info(p6, "Retrying", key, "with default root");
|
|
67758
|
-
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
67747
|
+
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
67759
67748
|
const rooted = await this.load(rootKey, parser);
|
|
67760
67749
|
if (typeof rooted !== "undefined") {
|
|
67761
67750
|
return rooted;
|
|
@@ -77402,6 +77391,20 @@ return ${compiler2.callType("value", tagType)}
|
|
|
77402
77391
|
// src/assets/AssetLoader.ts
|
|
77403
77392
|
var p7 = prefix("AssetLoader");
|
|
77404
77393
|
var _AssetLoader = class _AssetLoader {
|
|
77394
|
+
static get version() {
|
|
77395
|
+
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
77396
|
+
}
|
|
77397
|
+
static setVersion(version2) {
|
|
77398
|
+
this.ROOT = `https://assets.mcasset.cloud/${version2}`;
|
|
77399
|
+
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
77400
|
+
const index = this._SOURCES.findIndex((s4) => s4.key === "mcassets");
|
|
77401
|
+
if (index !== -1) {
|
|
77402
|
+
this._SOURCES[index] = { key: "mcassets", source };
|
|
77403
|
+
} else {
|
|
77404
|
+
this.addSource("mcassets", source);
|
|
77405
|
+
}
|
|
77406
|
+
Caching.clear();
|
|
77407
|
+
}
|
|
77405
77408
|
static addSource(key, source, override = true) {
|
|
77406
77409
|
if (override) {
|
|
77407
77410
|
const existing = this.removeSource(key);
|
|
@@ -77464,7 +77467,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
77464
77467
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
77465
77468
|
_AssetLoader._SOURCES = [];
|
|
77466
77469
|
_AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
|
|
77467
|
-
_AssetLoader.addSource("mcassets", new HostedAssetSource(
|
|
77470
|
+
_AssetLoader.addSource("mcassets", new HostedAssetSource(_AssetLoader.ROOT, { retryDefaults: false }));
|
|
77468
77471
|
var AssetLoader = _AssetLoader;
|
|
77469
77472
|
|
|
77470
77473
|
// src/assets/ModelTextures.ts
|
|
@@ -78126,18 +78129,18 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78126
78129
|
}
|
|
78127
78130
|
getUvEast(w4, h5, l4) {
|
|
78128
78131
|
return [
|
|
78129
|
-
[this.mapW(this.u), this.mapH(this.v + l4 + h5)],
|
|
78130
|
-
[this.mapW(this.u + l4), this.mapH(this.v + l4 + h5)],
|
|
78131
|
-
[this.mapW(this.u), this.mapH(this.v + l4)],
|
|
78132
|
-
[this.mapW(this.u + l4), this.mapH(this.v + l4)]
|
|
78132
|
+
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4 + h5)],
|
|
78133
|
+
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4 + h5)],
|
|
78134
|
+
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4)],
|
|
78135
|
+
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4)]
|
|
78133
78136
|
];
|
|
78134
78137
|
}
|
|
78135
78138
|
getUvWest(w4, h5, l4) {
|
|
78136
78139
|
return [
|
|
78137
|
-
[this.mapW(this.u + l4
|
|
78138
|
-
[this.mapW(this.u
|
|
78139
|
-
[this.mapW(this.u + l4
|
|
78140
|
-
[this.mapW(this.u
|
|
78140
|
+
[this.mapW(this.u + l4), this.mapH(this.v + l4 + h5)],
|
|
78141
|
+
[this.mapW(this.u), this.mapH(this.v + l4 + h5)],
|
|
78142
|
+
[this.mapW(this.u + l4), this.mapH(this.v + l4)],
|
|
78143
|
+
[this.mapW(this.u), this.mapH(this.v + l4)]
|
|
78141
78144
|
];
|
|
78142
78145
|
}
|
|
78143
78146
|
getUvUp(w4, h5, l4) {
|
|
@@ -78150,26 +78153,26 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78150
78153
|
}
|
|
78151
78154
|
getUvDown(w4, h5, l4) {
|
|
78152
78155
|
return [
|
|
78153
|
-
[this.mapW(this.u + l4), this.mapH(this.v + l4)],
|
|
78154
|
-
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4)],
|
|
78155
78156
|
[this.mapW(this.u + l4), this.mapH(this.v)],
|
|
78156
|
-
[this.mapW(this.u + l4 + w4), this.mapH(this.v)]
|
|
78157
|
+
[this.mapW(this.u + l4 + w4), this.mapH(this.v)],
|
|
78158
|
+
[this.mapW(this.u + l4), this.mapH(this.v + l4)],
|
|
78159
|
+
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4)]
|
|
78157
78160
|
];
|
|
78158
78161
|
}
|
|
78159
78162
|
getUvSouth(w4, h5, l4) {
|
|
78160
78163
|
return [
|
|
78161
|
-
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4 + h5)],
|
|
78162
78164
|
[this.mapW(this.u + l4 + w4 + l4 + w4), this.mapH(this.v + l4 + h5)],
|
|
78163
|
-
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4)],
|
|
78164
|
-
[this.mapW(this.u + l4 + w4 + l4 + w4), this.mapH(this.v + l4)]
|
|
78165
|
+
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4 + h5)],
|
|
78166
|
+
[this.mapW(this.u + l4 + w4 + l4 + w4), this.mapH(this.v + l4)],
|
|
78167
|
+
[this.mapW(this.u + l4 + w4 + l4), this.mapH(this.v + l4)]
|
|
78165
78168
|
];
|
|
78166
78169
|
}
|
|
78167
78170
|
getUvNorth(w4, h5, l4) {
|
|
78168
78171
|
return [
|
|
78169
|
-
[this.mapW(this.u + l4), this.mapH(this.v + l4 + h5)],
|
|
78170
78172
|
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4 + h5)],
|
|
78171
|
-
[this.mapW(this.u + l4), this.mapH(this.v + l4)],
|
|
78172
|
-
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4)]
|
|
78173
|
+
[this.mapW(this.u + l4), this.mapH(this.v + l4 + h5)],
|
|
78174
|
+
[this.mapW(this.u + l4 + w4), this.mapH(this.v + l4)],
|
|
78175
|
+
[this.mapW(this.u + l4), this.mapH(this.v + l4)]
|
|
78173
78176
|
];
|
|
78174
78177
|
}
|
|
78175
78178
|
getFaceUv(face, w4, h5, l4) {
|
|
@@ -78188,10 +78191,12 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78188
78191
|
return this.getUvNorth(w4, h5, l4);
|
|
78189
78192
|
}
|
|
78190
78193
|
}
|
|
78191
|
-
toUvArray(w4, h5, l4) {
|
|
78194
|
+
toUvArray(w4, h5, l4, mirror = false) {
|
|
78192
78195
|
const uv = [];
|
|
78193
78196
|
for (let i4 = 0; i4 < CUBE_FACES.length; i4++) {
|
|
78194
|
-
|
|
78197
|
+
const face = mirror && i4 < 2 ? CUBE_FACES[1 - i4] : CUBE_FACES[i4];
|
|
78198
|
+
const corners = this.getFaceUv(face, w4, h5, l4);
|
|
78199
|
+
UVMapper.setFaceUvInArray(uv, i4 * 4, mirror ? [corners[1], corners[0], corners[3], corners[2]] : corners);
|
|
78195
78200
|
}
|
|
78196
78201
|
return uv;
|
|
78197
78202
|
}
|
|
@@ -78252,68 +78257,55 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78252
78257
|
init_dirname();
|
|
78253
78258
|
init_buffer2();
|
|
78254
78259
|
init_process2();
|
|
78255
|
-
|
|
78256
|
-
|
|
78257
|
-
|
|
78258
|
-
|
|
78259
|
-
|
|
78260
|
-
|
|
78261
|
-
|
|
78262
|
-
|
|
78263
|
-
|
|
78264
|
-
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
78265
|
-
console.log(key);
|
|
78266
|
-
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
78267
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
78268
|
-
});
|
|
78260
|
+
|
|
78261
|
+
// src/error/MineRenderError.ts
|
|
78262
|
+
init_dirname();
|
|
78263
|
+
init_buffer2();
|
|
78264
|
+
init_process2();
|
|
78265
|
+
var MineRenderError = class _MineRenderError extends Error {
|
|
78266
|
+
constructor(msg) {
|
|
78267
|
+
super(msg);
|
|
78268
|
+
Object.setPrototypeOf(this, _MineRenderError.prototype);
|
|
78269
78269
|
}
|
|
78270
|
-
|
|
78271
|
-
|
|
78272
|
-
const models = await this.getBlockEntityModels();
|
|
78273
|
-
if (!models) {
|
|
78274
|
-
return [];
|
|
78275
|
-
}
|
|
78276
|
-
return Object.keys(models);
|
|
78270
|
+
get name() {
|
|
78271
|
+
return "MineRenderError";
|
|
78277
78272
|
}
|
|
78273
|
+
};
|
|
78274
|
+
|
|
78275
|
+
// src/assets/Entities.ts
|
|
78276
|
+
var Entities = class {
|
|
78278
78277
|
static async getEntityList() {
|
|
78279
|
-
const
|
|
78280
|
-
|
|
78281
|
-
|
|
78282
|
-
|
|
78283
|
-
|
|
78284
|
-
|
|
78285
|
-
|
|
78286
|
-
|
|
78287
|
-
if (!models) {
|
|
78288
|
-
return void 0;
|
|
78289
|
-
}
|
|
78290
|
-
if (!textureKey) {
|
|
78291
|
-
textureKey = modelKey;
|
|
78292
|
-
}
|
|
78293
|
-
const baseKey = modelKey.path.includes("/") ? new BasicAssetKey(modelKey.namespace, modelKey.path.split("/")[0]) : modelKey;
|
|
78294
|
-
return {
|
|
78295
|
-
key: textureKey,
|
|
78296
|
-
parts: models[baseKey.toNamespacedString()]
|
|
78278
|
+
const collect = async (path) => {
|
|
78279
|
+
const prefix2 = path ? `${path}/` : "";
|
|
78280
|
+
const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
|
|
78281
|
+
const list = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
|
|
78282
|
+
if (!list) return [];
|
|
78283
|
+
const files = list.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
|
|
78284
|
+
const children = await Promise.all(list.directories.map((directory) => collect(`${prefix2}${directory}`)));
|
|
78285
|
+
return [...files, ...children.flat()];
|
|
78297
78286
|
};
|
|
78287
|
+
return collect("");
|
|
78298
78288
|
}
|
|
78299
|
-
static async getEntity(modelKey, textureKey) {
|
|
78300
|
-
const
|
|
78301
|
-
|
|
78302
|
-
|
|
78303
|
-
|
|
78304
|
-
|
|
78305
|
-
|
|
78289
|
+
static async getEntity(modelKey, textureKey, options) {
|
|
78290
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
78291
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
78292
|
+
const model = await Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
78293
|
+
if (!model) return void 0;
|
|
78294
|
+
const layerName = options?.layer ?? "main";
|
|
78295
|
+
const layer = model.layers[layerName];
|
|
78296
|
+
if (!layer) {
|
|
78297
|
+
throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
78306
78298
|
}
|
|
78307
|
-
|
|
78308
|
-
|
|
78309
|
-
|
|
78310
|
-
|
|
78311
|
-
|
|
78299
|
+
return { key: textureKey ?? modelKey, layer, id: model.id };
|
|
78300
|
+
}
|
|
78301
|
+
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
78302
|
+
static getBlockList() {
|
|
78303
|
+
return this.getEntityList();
|
|
78304
|
+
}
|
|
78305
|
+
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
78306
|
+
static getBlock(modelKey, textureKey, options) {
|
|
78307
|
+
return this.getEntity(modelKey, textureKey, options);
|
|
78312
78308
|
}
|
|
78313
|
-
};
|
|
78314
|
-
var EntityModels = class {
|
|
78315
|
-
};
|
|
78316
|
-
var BlockEntityModels = class {
|
|
78317
78309
|
};
|
|
78318
78310
|
|
|
78319
78311
|
// src/bedrock/index.ts
|
|
@@ -78422,20 +78414,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78422
78414
|
return obj.isInstanceReference;
|
|
78423
78415
|
}
|
|
78424
78416
|
|
|
78425
|
-
// src/error/MineRenderError.ts
|
|
78426
|
-
init_dirname();
|
|
78427
|
-
init_buffer2();
|
|
78428
|
-
init_process2();
|
|
78429
|
-
var MineRenderError = class _MineRenderError extends Error {
|
|
78430
|
-
constructor(msg) {
|
|
78431
|
-
super(msg);
|
|
78432
|
-
Object.setPrototypeOf(this, _MineRenderError.prototype);
|
|
78433
|
-
}
|
|
78434
|
-
get name() {
|
|
78435
|
-
return "MineRenderError";
|
|
78436
|
-
}
|
|
78437
|
-
};
|
|
78438
|
-
|
|
78439
78417
|
// src/renderer/SceneObject.ts
|
|
78440
78418
|
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
78441
78419
|
var p9 = prefix("SceneObject");
|
|
@@ -78561,15 +78539,8 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78561
78539
|
return this.toggleObjectVisibility(this.getMeshByName(name2), visible);
|
|
78562
78540
|
}
|
|
78563
78541
|
iterateAllMeshes(cb) {
|
|
78564
|
-
this.
|
|
78565
|
-
if (obj
|
|
78566
|
-
cb(obj);
|
|
78567
|
-
}
|
|
78568
|
-
obj.children.forEach((obj1) => {
|
|
78569
|
-
if (obj1.isMesh) {
|
|
78570
|
-
cb(obj1);
|
|
78571
|
-
}
|
|
78572
|
-
});
|
|
78542
|
+
this.traverse((obj) => {
|
|
78543
|
+
if (isMesh(obj)) cb(obj);
|
|
78573
78544
|
});
|
|
78574
78545
|
}
|
|
78575
78546
|
//</editor-fold>
|
|
@@ -78813,13 +78784,13 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78813
78784
|
|
|
78814
78785
|
// src/entity/scene/EntityObject.ts
|
|
78815
78786
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
78816
|
-
var
|
|
78787
|
+
var _EntityObject = class _EntityObject extends SceneObject {
|
|
78817
78788
|
constructor(entity, options) {
|
|
78818
78789
|
super();
|
|
78819
78790
|
this.entity = entity;
|
|
78820
78791
|
this.isEntityObject = true;
|
|
78821
78792
|
this.meshesCreated = false;
|
|
78822
|
-
this.options = (0, import_ts_deepmerge4.default)({},
|
|
78793
|
+
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
78823
78794
|
}
|
|
78824
78795
|
async init() {
|
|
78825
78796
|
this.createMeshes();
|
|
@@ -78829,10 +78800,10 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78829
78800
|
super.dispose();
|
|
78830
78801
|
}
|
|
78831
78802
|
get textureKey() {
|
|
78803
|
+
const key = this.entity.key;
|
|
78832
78804
|
return new AssetKey(
|
|
78833
|
-
|
|
78834
|
-
|
|
78835
|
-
//TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
|
|
78805
|
+
key.namespace,
|
|
78806
|
+
isAssetKey(key) ? key.getFullPath() : key.path,
|
|
78836
78807
|
"textures",
|
|
78837
78808
|
"entity",
|
|
78838
78809
|
"assets",
|
|
@@ -78842,36 +78813,41 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78842
78813
|
async loadTextures() {
|
|
78843
78814
|
this.imageData = await ModelTextures.get(this.textureKey);
|
|
78844
78815
|
}
|
|
78845
|
-
//TODO: abstract this, since extracted model data can be used for entities, blocks, players
|
|
78846
78816
|
createMeshes(force = false) {
|
|
78847
78817
|
if (this.meshesCreated && !force) return;
|
|
78848
|
-
const
|
|
78849
|
-
|
|
78850
|
-
|
|
78851
|
-
|
|
78852
|
-
const partAnchor = new Object3D();
|
|
78853
|
-
partAnchor.position.x = part.pivotX;
|
|
78854
|
-
partAnchor.position.y = part.pivotY;
|
|
78855
|
-
partAnchor.position.z = part.pivotZ;
|
|
78856
|
-
for (let cube of part.cubes) {
|
|
78857
|
-
const w4 = cube.maxX - cube.minX;
|
|
78858
|
-
const h5 = cube.maxY - cube.minY;
|
|
78859
|
-
const l4 = cube.maxZ - cube.minZ;
|
|
78860
|
-
const uv = texture.toUvArray(w4, h5, l4);
|
|
78861
|
-
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w4, h5, l4, uv).clone();
|
|
78862
|
-
cubeGeo.applyMatrix4(new Matrix4().makeTranslation(w4 / 2, h5 / 2, l4 / 2));
|
|
78863
|
-
cubeGeo.applyMatrix4(new Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
|
|
78864
|
-
applyModelPartRotation(part, cubeGeo);
|
|
78865
|
-
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
78866
|
-
partAnchor.add(mesh);
|
|
78867
|
-
if (this.options.wireframe) {
|
|
78868
|
-
addWireframeToMesh(cubeGeo, mesh);
|
|
78869
|
-
}
|
|
78870
|
-
}
|
|
78871
|
-
this.add(partAnchor);
|
|
78872
|
-
}
|
|
78818
|
+
const modelRoot = new Object3D();
|
|
78819
|
+
if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
|
|
78820
|
+
this.add(modelRoot);
|
|
78821
|
+
this.createPart("root", this.entity.layer.root, modelRoot, this.entity.layer.texture, Materials.MISSING_TEXTURE);
|
|
78873
78822
|
this.meshesCreated = true;
|
|
78874
78823
|
}
|
|
78824
|
+
createPart(name2, part, parent, textureSize, material) {
|
|
78825
|
+
const anchor = this.createGroup(name2);
|
|
78826
|
+
anchor.position.fromArray(part.pose.offset);
|
|
78827
|
+
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
78828
|
+
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
78829
|
+
parent.add(anchor);
|
|
78830
|
+
const size = part.texture ?? textureSize;
|
|
78831
|
+
for (const cube of part.cubes) {
|
|
78832
|
+
const [width, height, depth] = cube.size;
|
|
78833
|
+
const [growX, growY, growZ] = cube.grow ?? [0, 0, 0];
|
|
78834
|
+
const texture = new MinecraftCubeTexture(...cube.uv, ...size);
|
|
78835
|
+
const uv = size[0] === 0 || size[1] === 0 ? new Array(48).fill(0) : texture.toUvArray(width, height, depth, cube.mirror);
|
|
78836
|
+
const geometry = this._getBoxGeometryForDimensionsAndUv(
|
|
78837
|
+
width + growX * 2,
|
|
78838
|
+
height + growY * 2,
|
|
78839
|
+
depth + growZ * 2,
|
|
78840
|
+
uv
|
|
78841
|
+
).clone();
|
|
78842
|
+
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
78843
|
+
const mesh = this.createMesh(name2, geometry, material);
|
|
78844
|
+
anchor.add(mesh);
|
|
78845
|
+
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
78846
|
+
}
|
|
78847
|
+
for (const [childName, child] of Object.entries(part.children)) {
|
|
78848
|
+
this.createPart(childName, child, anchor, size, material);
|
|
78849
|
+
}
|
|
78850
|
+
}
|
|
78875
78851
|
async applyTextures() {
|
|
78876
78852
|
const assetKeyStr = this.textureKey.serialize();
|
|
78877
78853
|
const keyStr = `entity:${assetKeyStr}`;
|
|
@@ -78892,7 +78868,8 @@ return ${compiler2.callType("value", tagType)}
|
|
|
78892
78868
|
this.notifyDirty();
|
|
78893
78869
|
}
|
|
78894
78870
|
};
|
|
78895
|
-
|
|
78871
|
+
_EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, { flip: true });
|
|
78872
|
+
var EntityObject = _EntityObject;
|
|
78896
78873
|
function isEntityObject(obj) {
|
|
78897
78874
|
return obj.isEntityObject;
|
|
78898
78875
|
}
|
|
@@ -79397,11 +79374,6 @@ return ${compiler2.callType("value", tagType)}
|
|
|
79397
79374
|
init_buffer2();
|
|
79398
79375
|
init_process2();
|
|
79399
79376
|
|
|
79400
|
-
// src/model/ModelPart.ts
|
|
79401
|
-
init_dirname();
|
|
79402
|
-
init_buffer2();
|
|
79403
|
-
init_process2();
|
|
79404
|
-
|
|
79405
79377
|
// src/model/block/index.ts
|
|
79406
79378
|
init_dirname();
|
|
79407
79379
|
init_buffer2();
|