minerender 2.1.0-alpha.23 → 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 +41 -48
- package/dist/browser/index.d.ts +41 -48
- package/dist/browser/index.js +101 -141
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +150 -190
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +105 -147
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +41 -48
- package/dist/node/index.d.ts +41 -48
- package/dist/node/index.js +100 -144
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +149 -190
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -413,7 +413,7 @@ var _Caching = class _Caching {
|
|
|
413
413
|
this.listAssetCache,
|
|
414
414
|
this.defaultBlockStatesCache,
|
|
415
415
|
this.blockTintCache,
|
|
416
|
-
this.
|
|
416
|
+
this.entityModelCache
|
|
417
417
|
];
|
|
418
418
|
}
|
|
419
419
|
static clear() {
|
|
@@ -456,7 +456,7 @@ _Caching.blockStateCache = Caches.builder().expireAfterWrite(Time.minutes(10)).e
|
|
|
456
456
|
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
457
457
|
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
458
458
|
_Caching.blockTintCache = _Caching.createAssetCache();
|
|
459
|
-
_Caching.
|
|
459
|
+
_Caching.entityModelCache = _Caching.createAssetCache();
|
|
460
460
|
var Caching = _Caching;
|
|
461
461
|
|
|
462
462
|
// src/Geometries.ts
|
|
@@ -1535,14 +1535,6 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1537
1537
|
}
|
|
1538
|
-
function applyModelPartRotation(modelPart, geometry) {
|
|
1539
|
-
const origin = new Vector33(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1540
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1541
|
-
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1542
|
-
geometry.rotateY(toRadians(modelPart.yaw));
|
|
1543
|
-
geometry.rotateZ(toRadians(modelPart.roll));
|
|
1544
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1545
|
-
}
|
|
1546
1538
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1547
1539
|
switch (axis) {
|
|
1548
1540
|
case "x" /* X */:
|
|
@@ -2564,18 +2556,18 @@ var MinecraftCubeTexture = class {
|
|
|
2564
2556
|
}
|
|
2565
2557
|
getUvEast(w, h, l) {
|
|
2566
2558
|
return [
|
|
2567
|
-
[this.mapW(this.u), this.mapH(this.v + l + h)],
|
|
2568
|
-
[this.mapW(this.u + l), this.mapH(this.v + l + h)],
|
|
2569
|
-
[this.mapW(this.u), this.mapH(this.v + l)],
|
|
2570
|
-
[this.mapW(this.u + l), this.mapH(this.v + l)]
|
|
2559
|
+
[this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
|
|
2560
|
+
[this.mapW(this.u + l + w), this.mapH(this.v + l + h)],
|
|
2561
|
+
[this.mapW(this.u + l + w + l), this.mapH(this.v + l)],
|
|
2562
|
+
[this.mapW(this.u + l + w), this.mapH(this.v + l)]
|
|
2571
2563
|
];
|
|
2572
2564
|
}
|
|
2573
2565
|
getUvWest(w, h, l) {
|
|
2574
2566
|
return [
|
|
2575
|
-
[this.mapW(this.u + l
|
|
2576
|
-
[this.mapW(this.u
|
|
2577
|
-
[this.mapW(this.u + l
|
|
2578
|
-
[this.mapW(this.u
|
|
2567
|
+
[this.mapW(this.u + l), this.mapH(this.v + l + h)],
|
|
2568
|
+
[this.mapW(this.u), this.mapH(this.v + l + h)],
|
|
2569
|
+
[this.mapW(this.u + l), this.mapH(this.v + l)],
|
|
2570
|
+
[this.mapW(this.u), this.mapH(this.v + l)]
|
|
2579
2571
|
];
|
|
2580
2572
|
}
|
|
2581
2573
|
getUvUp(w, h, l) {
|
|
@@ -2588,26 +2580,26 @@ var MinecraftCubeTexture = class {
|
|
|
2588
2580
|
}
|
|
2589
2581
|
getUvDown(w, h, l) {
|
|
2590
2582
|
return [
|
|
2591
|
-
[this.mapW(this.u + l), this.mapH(this.v + l)],
|
|
2592
|
-
[this.mapW(this.u + l + w), this.mapH(this.v + l)],
|
|
2593
2583
|
[this.mapW(this.u + l), this.mapH(this.v)],
|
|
2594
|
-
[this.mapW(this.u + l + w), this.mapH(this.v)]
|
|
2584
|
+
[this.mapW(this.u + l + w), this.mapH(this.v)],
|
|
2585
|
+
[this.mapW(this.u + l), this.mapH(this.v + l)],
|
|
2586
|
+
[this.mapW(this.u + l + w), this.mapH(this.v + l)]
|
|
2595
2587
|
];
|
|
2596
2588
|
}
|
|
2597
2589
|
getUvSouth(w, h, l) {
|
|
2598
2590
|
return [
|
|
2599
|
-
[this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
|
|
2600
2591
|
[this.mapW(this.u + l + w + l + w), this.mapH(this.v + l + h)],
|
|
2601
|
-
[this.mapW(this.u + l + w + l), this.mapH(this.v + l)],
|
|
2602
|
-
[this.mapW(this.u + l + w + l + w), this.mapH(this.v + l)]
|
|
2592
|
+
[this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
|
|
2593
|
+
[this.mapW(this.u + l + w + l + w), this.mapH(this.v + l)],
|
|
2594
|
+
[this.mapW(this.u + l + w + l), this.mapH(this.v + l)]
|
|
2603
2595
|
];
|
|
2604
2596
|
}
|
|
2605
2597
|
getUvNorth(w, h, l) {
|
|
2606
2598
|
return [
|
|
2607
|
-
[this.mapW(this.u + l), this.mapH(this.v + l + h)],
|
|
2608
2599
|
[this.mapW(this.u + l + w), this.mapH(this.v + l + h)],
|
|
2609
|
-
[this.mapW(this.u + l), this.mapH(this.v + l)],
|
|
2610
|
-
[this.mapW(this.u + l + w), this.mapH(this.v + l)]
|
|
2600
|
+
[this.mapW(this.u + l), this.mapH(this.v + l + h)],
|
|
2601
|
+
[this.mapW(this.u + l + w), this.mapH(this.v + l)],
|
|
2602
|
+
[this.mapW(this.u + l), this.mapH(this.v + l)]
|
|
2611
2603
|
];
|
|
2612
2604
|
}
|
|
2613
2605
|
getFaceUv(face, w, h, l) {
|
|
@@ -2626,10 +2618,12 @@ var MinecraftCubeTexture = class {
|
|
|
2626
2618
|
return this.getUvNorth(w, h, l);
|
|
2627
2619
|
}
|
|
2628
2620
|
}
|
|
2629
|
-
toUvArray(w, h, l) {
|
|
2621
|
+
toUvArray(w, h, l, mirror = false) {
|
|
2630
2622
|
const uv = [];
|
|
2631
2623
|
for (let i = 0; i < CUBE_FACES.length; i++) {
|
|
2632
|
-
|
|
2624
|
+
const face = mirror && i < 2 ? CUBE_FACES[1 - i] : CUBE_FACES[i];
|
|
2625
|
+
const corners = this.getFaceUv(face, w, h, l);
|
|
2626
|
+
UVMapper.setFaceUvInArray(uv, i * 4, mirror ? [corners[1], corners[0], corners[3], corners[2]] : corners);
|
|
2633
2627
|
}
|
|
2634
2628
|
return uv;
|
|
2635
2629
|
}
|
|
@@ -2659,69 +2653,51 @@ function shutdown() {
|
|
|
2659
2653
|
Caching.end();
|
|
2660
2654
|
}
|
|
2661
2655
|
|
|
2662
|
-
// src/
|
|
2663
|
-
var
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2668
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2669
|
-
});
|
|
2670
|
-
}
|
|
2671
|
-
static async getEntityModels() {
|
|
2672
|
-
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2673
|
-
console.log(key);
|
|
2674
|
-
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2675
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2676
|
-
});
|
|
2656
|
+
// src/error/MineRenderError.ts
|
|
2657
|
+
var MineRenderError = class _MineRenderError extends Error {
|
|
2658
|
+
constructor(msg) {
|
|
2659
|
+
super(msg);
|
|
2660
|
+
Object.setPrototypeOf(this, _MineRenderError.prototype);
|
|
2677
2661
|
}
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
const models = await this.getBlockEntityModels();
|
|
2681
|
-
if (!models) {
|
|
2682
|
-
return [];
|
|
2683
|
-
}
|
|
2684
|
-
return Object.keys(models);
|
|
2662
|
+
get name() {
|
|
2663
|
+
return "MineRenderError";
|
|
2685
2664
|
}
|
|
2665
|
+
};
|
|
2666
|
+
|
|
2667
|
+
// src/assets/Entities.ts
|
|
2668
|
+
var Entities = class {
|
|
2686
2669
|
static async getEntityList() {
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
if (!models) {
|
|
2696
|
-
return void 0;
|
|
2697
|
-
}
|
|
2698
|
-
if (!textureKey) {
|
|
2699
|
-
textureKey = modelKey;
|
|
2700
|
-
}
|
|
2701
|
-
const baseKey = modelKey.path.includes("/") ? new BasicAssetKey(modelKey.namespace, modelKey.path.split("/")[0]) : modelKey;
|
|
2702
|
-
return {
|
|
2703
|
-
key: textureKey,
|
|
2704
|
-
parts: models[baseKey.toNamespacedString()]
|
|
2670
|
+
const collect = async (path) => {
|
|
2671
|
+
const prefix2 = path ? `${path}/` : "";
|
|
2672
|
+
const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
|
|
2673
|
+
const list = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
|
|
2674
|
+
if (!list) return [];
|
|
2675
|
+
const files = list.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
|
|
2676
|
+
const children = await Promise.all(list.directories.map((directory) => collect(`${prefix2}${directory}`)));
|
|
2677
|
+
return [...files, ...children.flat()];
|
|
2705
2678
|
};
|
|
2679
|
+
return collect("");
|
|
2706
2680
|
}
|
|
2707
|
-
static async getEntity(modelKey, textureKey) {
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2710
|
-
|
|
2681
|
+
static async getEntity(modelKey, textureKey, options) {
|
|
2682
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2683
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2684
|
+
const model = await Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
2685
|
+
if (!model) return void 0;
|
|
2686
|
+
const layerName = options?.layer ?? "main";
|
|
2687
|
+
const layer = model.layers[layerName];
|
|
2688
|
+
if (!layer) {
|
|
2689
|
+
throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2711
2690
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
return
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2691
|
+
return { key: textureKey ?? modelKey, layer, id: model.id };
|
|
2692
|
+
}
|
|
2693
|
+
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
2694
|
+
static getBlockList() {
|
|
2695
|
+
return this.getEntityList();
|
|
2696
|
+
}
|
|
2697
|
+
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
2698
|
+
static getBlock(modelKey, textureKey, options) {
|
|
2699
|
+
return this.getEntity(modelKey, textureKey, options);
|
|
2720
2700
|
}
|
|
2721
|
-
};
|
|
2722
|
-
var EntityModels = class {
|
|
2723
|
-
};
|
|
2724
|
-
var BlockEntityModels = class {
|
|
2725
2701
|
};
|
|
2726
2702
|
|
|
2727
2703
|
// src/renderer/SceneObject.ts
|
|
@@ -2770,17 +2746,6 @@ function isInstanceReference(obj) {
|
|
|
2770
2746
|
return obj.isInstanceReference;
|
|
2771
2747
|
}
|
|
2772
2748
|
|
|
2773
|
-
// src/error/MineRenderError.ts
|
|
2774
|
-
var MineRenderError = class _MineRenderError extends Error {
|
|
2775
|
-
constructor(msg) {
|
|
2776
|
-
super(msg);
|
|
2777
|
-
Object.setPrototypeOf(this, _MineRenderError.prototype);
|
|
2778
|
-
}
|
|
2779
|
-
get name() {
|
|
2780
|
-
return "MineRenderError";
|
|
2781
|
-
}
|
|
2782
|
-
};
|
|
2783
|
-
|
|
2784
2749
|
// src/renderer/SceneObject.ts
|
|
2785
2750
|
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
2786
2751
|
var p6 = prefix("SceneObject");
|
|
@@ -2906,15 +2871,8 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2906
2871
|
return this.toggleObjectVisibility(this.getMeshByName(name), visible);
|
|
2907
2872
|
}
|
|
2908
2873
|
iterateAllMeshes(cb) {
|
|
2909
|
-
this.
|
|
2910
|
-
if (obj
|
|
2911
|
-
cb(obj);
|
|
2912
|
-
}
|
|
2913
|
-
obj.children.forEach((obj1) => {
|
|
2914
|
-
if (obj1.isMesh) {
|
|
2915
|
-
cb(obj1);
|
|
2916
|
-
}
|
|
2917
|
-
});
|
|
2874
|
+
this.traverse((obj) => {
|
|
2875
|
+
if (isMesh(obj)) cb(obj);
|
|
2918
2876
|
});
|
|
2919
2877
|
}
|
|
2920
2878
|
//</editor-fold>
|
|
@@ -3159,14 +3117,13 @@ function isSceneObject(obj) {
|
|
|
3159
3117
|
// src/entity/scene/EntityObject.ts
|
|
3160
3118
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
3161
3119
|
import { Object3D as Object3D3 } from "three";
|
|
3162
|
-
|
|
3163
|
-
var EntityObject = class extends SceneObject {
|
|
3120
|
+
var _EntityObject = class _EntityObject extends SceneObject {
|
|
3164
3121
|
constructor(entity, options) {
|
|
3165
3122
|
super();
|
|
3166
3123
|
this.entity = entity;
|
|
3167
3124
|
this.isEntityObject = true;
|
|
3168
3125
|
this.meshesCreated = false;
|
|
3169
|
-
this.options = (0, import_ts_deepmerge4.default)({},
|
|
3126
|
+
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
3170
3127
|
}
|
|
3171
3128
|
async init() {
|
|
3172
3129
|
this.createMeshes();
|
|
@@ -3176,10 +3133,10 @@ var EntityObject = class extends SceneObject {
|
|
|
3176
3133
|
super.dispose();
|
|
3177
3134
|
}
|
|
3178
3135
|
get textureKey() {
|
|
3136
|
+
const key = this.entity.key;
|
|
3179
3137
|
return new AssetKey(
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
//TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
|
|
3138
|
+
key.namespace,
|
|
3139
|
+
isAssetKey(key) ? key.getFullPath() : key.path,
|
|
3183
3140
|
"textures",
|
|
3184
3141
|
"entity",
|
|
3185
3142
|
"assets",
|
|
@@ -3189,36 +3146,41 @@ var EntityObject = class extends SceneObject {
|
|
|
3189
3146
|
async loadTextures() {
|
|
3190
3147
|
this.imageData = await ModelTextures.get(this.textureKey);
|
|
3191
3148
|
}
|
|
3192
|
-
//TODO: abstract this, since extracted model data can be used for entities, blocks, players
|
|
3193
3149
|
createMeshes(force = false) {
|
|
3194
3150
|
if (this.meshesCreated && !force) return;
|
|
3195
|
-
const
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
const partAnchor = new Object3D3();
|
|
3200
|
-
partAnchor.position.x = part.pivotX;
|
|
3201
|
-
partAnchor.position.y = part.pivotY;
|
|
3202
|
-
partAnchor.position.z = part.pivotZ;
|
|
3203
|
-
for (let cube of part.cubes) {
|
|
3204
|
-
const w = cube.maxX - cube.minX;
|
|
3205
|
-
const h = cube.maxY - cube.minY;
|
|
3206
|
-
const l = cube.maxZ - cube.minZ;
|
|
3207
|
-
const uv = texture.toUvArray(w, h, l);
|
|
3208
|
-
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
|
|
3209
|
-
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
|
|
3210
|
-
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
|
|
3211
|
-
applyModelPartRotation(part, cubeGeo);
|
|
3212
|
-
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
3213
|
-
partAnchor.add(mesh);
|
|
3214
|
-
if (this.options.wireframe) {
|
|
3215
|
-
addWireframeToMesh(cubeGeo, mesh);
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
this.add(partAnchor);
|
|
3219
|
-
}
|
|
3151
|
+
const modelRoot = new Object3D3();
|
|
3152
|
+
if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
|
|
3153
|
+
this.add(modelRoot);
|
|
3154
|
+
this.createPart("root", this.entity.layer.root, modelRoot, this.entity.layer.texture, Materials.MISSING_TEXTURE);
|
|
3220
3155
|
this.meshesCreated = true;
|
|
3221
3156
|
}
|
|
3157
|
+
createPart(name, part, parent, textureSize, material) {
|
|
3158
|
+
const anchor = this.createGroup(name);
|
|
3159
|
+
anchor.position.fromArray(part.pose.offset);
|
|
3160
|
+
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
3161
|
+
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
3162
|
+
parent.add(anchor);
|
|
3163
|
+
const size = part.texture ?? textureSize;
|
|
3164
|
+
for (const cube of part.cubes) {
|
|
3165
|
+
const [width, height, depth] = cube.size;
|
|
3166
|
+
const [growX, growY, growZ] = cube.grow ?? [0, 0, 0];
|
|
3167
|
+
const texture = new MinecraftCubeTexture(...cube.uv, ...size);
|
|
3168
|
+
const uv = size[0] === 0 || size[1] === 0 ? new Array(48).fill(0) : texture.toUvArray(width, height, depth, cube.mirror);
|
|
3169
|
+
const geometry = this._getBoxGeometryForDimensionsAndUv(
|
|
3170
|
+
width + growX * 2,
|
|
3171
|
+
height + growY * 2,
|
|
3172
|
+
depth + growZ * 2,
|
|
3173
|
+
uv
|
|
3174
|
+
).clone();
|
|
3175
|
+
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
3176
|
+
const mesh = this.createMesh(name, geometry, material);
|
|
3177
|
+
anchor.add(mesh);
|
|
3178
|
+
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
3179
|
+
}
|
|
3180
|
+
for (const [childName, child] of Object.entries(part.children)) {
|
|
3181
|
+
this.createPart(childName, child, anchor, size, material);
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3222
3184
|
async applyTextures() {
|
|
3223
3185
|
const assetKeyStr = this.textureKey.serialize();
|
|
3224
3186
|
const keyStr = `entity:${assetKeyStr}`;
|
|
@@ -3239,7 +3201,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3239
3201
|
this.notifyDirty();
|
|
3240
3202
|
}
|
|
3241
3203
|
};
|
|
3242
|
-
|
|
3204
|
+
_EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, { flip: true });
|
|
3205
|
+
var EntityObject = _EntityObject;
|
|
3243
3206
|
function isEntityObject(obj) {
|
|
3244
3207
|
return obj.isEntityObject;
|
|
3245
3208
|
}
|
|
@@ -3770,7 +3733,7 @@ var BlockTints = class {
|
|
|
3770
3733
|
};
|
|
3771
3734
|
|
|
3772
3735
|
// src/model/scene/ModelObject.ts
|
|
3773
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as
|
|
3736
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler4, Matrix4 as Matrix44 } from "three";
|
|
3774
3737
|
|
|
3775
3738
|
// src/three/BufferGeometryUtils.js
|
|
3776
3739
|
import {
|
|
@@ -3782,7 +3745,7 @@ import {
|
|
|
3782
3745
|
TriangleFanDrawMode,
|
|
3783
3746
|
TriangleStripDrawMode,
|
|
3784
3747
|
TrianglesDrawMode,
|
|
3785
|
-
Vector3 as
|
|
3748
|
+
Vector3 as Vector36
|
|
3786
3749
|
} from "three";
|
|
3787
3750
|
function computeTangents(geometry) {
|
|
3788
3751
|
geometry.computeTangents();
|
|
@@ -4101,15 +4064,15 @@ function computeMorphedAttributes(object) {
|
|
|
4101
4064
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4102
4065
|
return null;
|
|
4103
4066
|
}
|
|
4104
|
-
const _vA = new
|
|
4105
|
-
const _vB = new
|
|
4106
|
-
const _vC = new
|
|
4107
|
-
const _tempA = new
|
|
4108
|
-
const _tempB = new
|
|
4109
|
-
const _tempC = new
|
|
4110
|
-
const _morphA = new
|
|
4111
|
-
const _morphB = new
|
|
4112
|
-
const _morphC = new
|
|
4067
|
+
const _vA = new Vector36();
|
|
4068
|
+
const _vB = new Vector36();
|
|
4069
|
+
const _vC = new Vector36();
|
|
4070
|
+
const _tempA = new Vector36();
|
|
4071
|
+
const _tempB = new Vector36();
|
|
4072
|
+
const _tempC = new Vector36();
|
|
4073
|
+
const _morphA = new Vector36();
|
|
4074
|
+
const _morphB = new Vector36();
|
|
4075
|
+
const _morphC = new Vector36();
|
|
4113
4076
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4114
4077
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4115
4078
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4353,7 +4316,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4353
4316
|
this.atlas.model.elements?.forEach((el) => {
|
|
4354
4317
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4355
4318
|
if (this.options.uvLockRotation) {
|
|
4356
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4319
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler4(...this.options.uvLockRotation));
|
|
4357
4320
|
}
|
|
4358
4321
|
if (this.options.tints) {
|
|
4359
4322
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4369,12 +4332,12 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4369
4332
|
}
|
|
4370
4333
|
elGeo.setAttribute("color", new BufferAttribute4(colors, 3));
|
|
4371
4334
|
}
|
|
4372
|
-
elGeo.applyMatrix4(new
|
|
4373
|
-
elGeo.applyMatrix4(new
|
|
4335
|
+
elGeo.applyMatrix4(new Matrix44().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4336
|
+
elGeo.applyMatrix4(new Matrix44().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4374
4337
|
if (el.rotation) {
|
|
4375
4338
|
applyElementRotation(el.rotation, elGeo);
|
|
4376
4339
|
}
|
|
4377
|
-
elGeo.applyMatrix4(new
|
|
4340
|
+
elGeo.applyMatrix4(new Matrix44().makeTranslation(-8, -8, -8));
|
|
4378
4341
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4379
4342
|
if (this.options.mergeMeshes) {
|
|
4380
4343
|
allGeos.push(elGeo);
|
|
@@ -4451,7 +4414,7 @@ function isModelObject(obj) {
|
|
|
4451
4414
|
|
|
4452
4415
|
// src/model/block/scene/BlockObject.ts
|
|
4453
4416
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4454
|
-
import { Euler as
|
|
4417
|
+
import { Euler as Euler5, Matrix4 as Matrix45, Vector3 as Vector37 } from "three";
|
|
4455
4418
|
var p10 = prefix("BlockObject");
|
|
4456
4419
|
function matchesCondition(condition, state) {
|
|
4457
4420
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4508,7 +4471,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4508
4471
|
if (isModelObject(model)) {
|
|
4509
4472
|
model.removeFromScene();
|
|
4510
4473
|
} else if (isInstanceReference(model)) {
|
|
4511
|
-
model.setScale(new
|
|
4474
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4512
4475
|
}
|
|
4513
4476
|
}
|
|
4514
4477
|
super.removeFromScene();
|
|
@@ -4569,7 +4532,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4569
4532
|
}
|
|
4570
4533
|
for (let model of this._models) {
|
|
4571
4534
|
if (isInstanceReference(model)) {
|
|
4572
|
-
model.setScale(new
|
|
4535
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4573
4536
|
} else {
|
|
4574
4537
|
model.dispose();
|
|
4575
4538
|
}
|
|
@@ -4606,7 +4569,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4606
4569
|
await this.createVariant(variant);
|
|
4607
4570
|
}
|
|
4608
4571
|
async createVariant(variant) {
|
|
4609
|
-
const rotation = new
|
|
4572
|
+
const rotation = new Euler5();
|
|
4610
4573
|
if (typeof variant.x !== "undefined") {
|
|
4611
4574
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4612
4575
|
}
|
|
@@ -4693,7 +4656,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4693
4656
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4694
4657
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4695
4658
|
}
|
|
4696
|
-
getMatrixAt(index, matrix = new
|
|
4659
|
+
getMatrixAt(index, matrix = new Matrix45()) {
|
|
4697
4660
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4698
4661
|
const child = this._models[0];
|
|
4699
4662
|
if (child && isModelObject(child)) {
|
|
@@ -5739,7 +5702,7 @@ function isMineRenderScene(obj) {
|
|
|
5739
5702
|
}
|
|
5740
5703
|
|
|
5741
5704
|
// src/renderer/Renderer.ts
|
|
5742
|
-
import { AxesHelper as
|
|
5705
|
+
import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector39, WebGLRenderer } from "three";
|
|
5743
5706
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5744
5707
|
import Stats from "stats.js";
|
|
5745
5708
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5752,7 +5715,7 @@ import {
|
|
|
5752
5715
|
Spherical,
|
|
5753
5716
|
TOUCH,
|
|
5754
5717
|
Vector2 as Vector23,
|
|
5755
|
-
Vector3 as
|
|
5718
|
+
Vector3 as Vector38
|
|
5756
5719
|
} from "three";
|
|
5757
5720
|
var _changeEvent = { type: "change" };
|
|
5758
5721
|
var _startEvent = { type: "start" };
|
|
@@ -5766,7 +5729,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5766
5729
|
this.domElement = domElement;
|
|
5767
5730
|
this.domElement.style.touchAction = "none";
|
|
5768
5731
|
this.enabled = true;
|
|
5769
|
-
this.target = new
|
|
5732
|
+
this.target = new Vector38();
|
|
5770
5733
|
this.minDistance = 0;
|
|
5771
5734
|
this.maxDistance = Infinity;
|
|
5772
5735
|
this.minZoom = 0;
|
|
@@ -5818,10 +5781,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5818
5781
|
state = STATE.NONE;
|
|
5819
5782
|
};
|
|
5820
5783
|
this.update = function() {
|
|
5821
|
-
const offset = new
|
|
5822
|
-
const quat = new Quaternion4().setFromUnitVectors(object.up, new
|
|
5784
|
+
const offset = new Vector38();
|
|
5785
|
+
const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector38(0, 1, 0));
|
|
5823
5786
|
const quatInverse = quat.clone().invert();
|
|
5824
|
-
const lastPosition = new
|
|
5787
|
+
const lastPosition = new Vector38();
|
|
5825
5788
|
const lastQuaternion = new Quaternion4();
|
|
5826
5789
|
const twoPI = 2 * Math.PI;
|
|
5827
5790
|
return function update() {
|
|
@@ -5911,7 +5874,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5911
5874
|
const spherical = new Spherical();
|
|
5912
5875
|
const sphericalDelta = new Spherical();
|
|
5913
5876
|
let scale = 1;
|
|
5914
|
-
const panOffset = new
|
|
5877
|
+
const panOffset = new Vector38();
|
|
5915
5878
|
let zoomChanged = false;
|
|
5916
5879
|
const rotateStart = new Vector23();
|
|
5917
5880
|
const rotateEnd = new Vector23();
|
|
@@ -5937,7 +5900,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5937
5900
|
sphericalDelta.phi -= angle;
|
|
5938
5901
|
}
|
|
5939
5902
|
const panLeft = function() {
|
|
5940
|
-
const v = new
|
|
5903
|
+
const v = new Vector38();
|
|
5941
5904
|
return function panLeft2(distance, objectMatrix) {
|
|
5942
5905
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5943
5906
|
v.multiplyScalar(-distance);
|
|
@@ -5945,7 +5908,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5945
5908
|
};
|
|
5946
5909
|
}();
|
|
5947
5910
|
const panUp = function() {
|
|
5948
|
-
const v = new
|
|
5911
|
+
const v = new Vector38();
|
|
5949
5912
|
return function panUp2(distance, objectMatrix) {
|
|
5950
5913
|
if (scope.screenSpacePanning === true) {
|
|
5951
5914
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5958,7 +5921,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5958
5921
|
};
|
|
5959
5922
|
}();
|
|
5960
5923
|
const pan = function() {
|
|
5961
|
-
const offset = new
|
|
5924
|
+
const offset = new Vector38();
|
|
5962
5925
|
return function pan2(deltaX, deltaY) {
|
|
5963
5926
|
const element = scope.domElement;
|
|
5964
5927
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6501,7 +6464,7 @@ var _Renderer = class _Renderer {
|
|
|
6501
6464
|
this.scene.add(gridHelper3);
|
|
6502
6465
|
}
|
|
6503
6466
|
if (this.options.debug.axes) {
|
|
6504
|
-
const axesHelper = new
|
|
6467
|
+
const axesHelper = new AxesHelper2(64);
|
|
6505
6468
|
this._debugHelpers.push(axesHelper);
|
|
6506
6469
|
this.scene.add(axesHelper);
|
|
6507
6470
|
}
|
|
@@ -6705,8 +6668,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6705
6668
|
top: void 0,
|
|
6706
6669
|
bottom: void 0
|
|
6707
6670
|
},
|
|
6708
|
-
position: new
|
|
6709
|
-
lookingAt: new
|
|
6671
|
+
position: new Vector39(50, 50, 50),
|
|
6672
|
+
lookingAt: new Vector39(0, 0, 0)
|
|
6710
6673
|
},
|
|
6711
6674
|
render: {
|
|
6712
6675
|
fpsLimit: 60,
|
|
@@ -6900,10 +6863,10 @@ var Skins = class {
|
|
|
6900
6863
|
};
|
|
6901
6864
|
|
|
6902
6865
|
// src/world/Chunk.ts
|
|
6903
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6866
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector311 } from "three";
|
|
6904
6867
|
|
|
6905
6868
|
// src/world/MineRenderWorld.ts
|
|
6906
|
-
import { Vector3 as
|
|
6869
|
+
import { Vector3 as Vector310 } from "three";
|
|
6907
6870
|
var MineRenderWorld = class {
|
|
6908
6871
|
constructor(scene) {
|
|
6909
6872
|
this._size = 4;
|
|
@@ -6914,10 +6877,10 @@ var MineRenderWorld = class {
|
|
|
6914
6877
|
}
|
|
6915
6878
|
getBlockAt(posOrX, y, z) {
|
|
6916
6879
|
if (typeof posOrX == "number") {
|
|
6917
|
-
return this.getBlockAt(new
|
|
6880
|
+
return this.getBlockAt(new Vector310(posOrX, y, z));
|
|
6918
6881
|
}
|
|
6919
6882
|
if (isTripleArray(posOrX)) {
|
|
6920
|
-
return this.getBlockAt(new
|
|
6883
|
+
return this.getBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]));
|
|
6921
6884
|
}
|
|
6922
6885
|
const chunk = this.getChunkAt(posOrX);
|
|
6923
6886
|
if (typeof chunk === "undefined") {
|
|
@@ -6928,10 +6891,10 @@ var MineRenderWorld = class {
|
|
|
6928
6891
|
}
|
|
6929
6892
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6930
6893
|
if (typeof posOrX == "number") {
|
|
6931
|
-
return this.setBlockAt(new
|
|
6894
|
+
return this.setBlockAt(new Vector310(posOrX, yOrBlock, z), block);
|
|
6932
6895
|
}
|
|
6933
6896
|
if (isTripleArray(posOrX)) {
|
|
6934
|
-
return this.setBlockAt(new
|
|
6897
|
+
return this.setBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6935
6898
|
}
|
|
6936
6899
|
this.validatePosBounds(posOrX);
|
|
6937
6900
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6977,14 +6940,14 @@ var MineRenderWorld = class {
|
|
|
6977
6940
|
return this._chunks[index];
|
|
6978
6941
|
}
|
|
6979
6942
|
static worldToScenePosition(pos) {
|
|
6980
|
-
return new
|
|
6943
|
+
return new Vector310(
|
|
6981
6944
|
pos.x * 16,
|
|
6982
6945
|
pos.y * 16,
|
|
6983
6946
|
pos.z * 16
|
|
6984
6947
|
);
|
|
6985
6948
|
}
|
|
6986
6949
|
static sceneToWorldPosition(pos) {
|
|
6987
|
-
return new
|
|
6950
|
+
return new Vector310(
|
|
6988
6951
|
pos.x / 16,
|
|
6989
6952
|
pos.y / 16,
|
|
6990
6953
|
pos.z / 16
|
|
@@ -7026,7 +6989,7 @@ var Chunk = class _Chunk {
|
|
|
7026
6989
|
scene.add(anchor);
|
|
7027
6990
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7028
6991
|
addBox3WireframeToObject(
|
|
7029
|
-
new Box32(new
|
|
6992
|
+
new Box32(new Vector311(0, 0, 0), new Vector311(256, 256, 256)),
|
|
7030
6993
|
anchor,
|
|
7031
6994
|
16776960,
|
|
7032
6995
|
4
|
|
@@ -7034,10 +6997,10 @@ var Chunk = class _Chunk {
|
|
|
7034
6997
|
}
|
|
7035
6998
|
getBlockAt(posOrX, y, z) {
|
|
7036
6999
|
if (typeof posOrX == "number") {
|
|
7037
|
-
return this.getBlockAt(new
|
|
7000
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
7038
7001
|
}
|
|
7039
7002
|
if (isTripleArray(posOrX)) {
|
|
7040
|
-
return this.getBlockAt(new
|
|
7003
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
7041
7004
|
}
|
|
7042
7005
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7043
7006
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7045,10 +7008,10 @@ var Chunk = class _Chunk {
|
|
|
7045
7008
|
}
|
|
7046
7009
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7047
7010
|
if (typeof posOrX == "number") {
|
|
7048
|
-
return this.setBlockAt(new
|
|
7011
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
7049
7012
|
}
|
|
7050
7013
|
if (isTripleArray(posOrX)) {
|
|
7051
|
-
return this.setBlockAt(new
|
|
7014
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7052
7015
|
}
|
|
7053
7016
|
const worldPos = posOrX;
|
|
7054
7017
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7094,7 +7057,7 @@ var Chunk = class _Chunk {
|
|
|
7094
7057
|
}
|
|
7095
7058
|
async clear() {
|
|
7096
7059
|
let promises = [];
|
|
7097
|
-
let pos = new
|
|
7060
|
+
let pos = new Vector311();
|
|
7098
7061
|
for (let x = 0; x < 16; x++) {
|
|
7099
7062
|
for (let z = 0; z < 16; z++) {
|
|
7100
7063
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7113,14 +7076,14 @@ var Chunk = class _Chunk {
|
|
|
7113
7076
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7114
7077
|
}
|
|
7115
7078
|
worldPosToChunkPos(pos) {
|
|
7116
|
-
return new
|
|
7079
|
+
return new Vector311(
|
|
7117
7080
|
pos.x - this.x * 16,
|
|
7118
7081
|
pos.y - this.y * 16,
|
|
7119
7082
|
pos.z - this.z * 16
|
|
7120
7083
|
);
|
|
7121
7084
|
}
|
|
7122
7085
|
chunkPosToWorldPos(pos) {
|
|
7123
|
-
return new
|
|
7086
|
+
return new Vector311(
|
|
7124
7087
|
this.x * 16 + pos.x,
|
|
7125
7088
|
this.y * 16 + pos.y,
|
|
7126
7089
|
this.z * 16 + pos.z
|
|
@@ -7141,7 +7104,6 @@ export {
|
|
|
7141
7104
|
BUILTIN_GENERATED,
|
|
7142
7105
|
BasicAssetKey,
|
|
7143
7106
|
BatchedExecutor,
|
|
7144
|
-
BlockEntityModels,
|
|
7145
7107
|
BlockObject,
|
|
7146
7108
|
BlockStates,
|
|
7147
7109
|
BlockTints,
|
|
@@ -7163,7 +7125,6 @@ export {
|
|
|
7163
7125
|
DisplayPosition,
|
|
7164
7126
|
DisplayTransforms,
|
|
7165
7127
|
Entities,
|
|
7166
|
-
EntityModels,
|
|
7167
7128
|
EntityObject,
|
|
7168
7129
|
Env,
|
|
7169
7130
|
Geometries,
|
|
@@ -7215,7 +7176,6 @@ export {
|
|
|
7215
7176
|
addWireframeToObject,
|
|
7216
7177
|
applyElementRotation,
|
|
7217
7178
|
applyGenericRotation,
|
|
7218
|
-
applyModelPartRotation,
|
|
7219
7179
|
axisToVec3,
|
|
7220
7180
|
base64decode,
|
|
7221
7181
|
base64encode,
|