minerender 2.1.0-alpha.21 → 2.1.0-alpha.22
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 +14 -4
- package/dist/browser/index.d.ts +14 -4
- package/dist/browser/index.js +238 -185
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +146 -93
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +76 -21
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +14 -4
- package/dist/node/index.d.ts +14 -4
- package/dist/node/index.js +239 -185
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +146 -93
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1093,7 +1093,7 @@ var Meshes = class _Meshes {
|
|
|
1093
1093
|
};
|
|
1094
1094
|
|
|
1095
1095
|
// src/UVMapper.ts
|
|
1096
|
-
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as
|
|
1096
|
+
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as Vector34 } from "three";
|
|
1097
1097
|
|
|
1098
1098
|
// src/model/ModelMerger.ts
|
|
1099
1099
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1184,15 +1184,77 @@ function isAssetKey(obj) {
|
|
|
1184
1184
|
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
+
// src/model/DisplayTransforms.ts
|
|
1188
|
+
import { Euler, Matrix4, Quaternion, Vector3 as Vector32 } from "three";
|
|
1189
|
+
|
|
1190
|
+
// src/model/DisplayPosition.ts
|
|
1191
|
+
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
1192
|
+
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1193
|
+
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1194
|
+
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1195
|
+
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1196
|
+
DisplayPosition2["GUI"] = "gui";
|
|
1197
|
+
DisplayPosition2["HEAD"] = "head";
|
|
1198
|
+
DisplayPosition2["GROUND"] = "ground";
|
|
1199
|
+
DisplayPosition2["FIXED"] = "fixed";
|
|
1200
|
+
DisplayPosition2["ON_SHELF"] = "on_shelf";
|
|
1201
|
+
return DisplayPosition2;
|
|
1202
|
+
})(DisplayPosition || {});
|
|
1203
|
+
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1204
|
+
|
|
1205
|
+
// src/model/DisplayTransforms.ts
|
|
1206
|
+
var DisplayTransforms = class {
|
|
1207
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
1208
|
+
static withHandFallbacks(display) {
|
|
1209
|
+
if (!display) return void 0;
|
|
1210
|
+
const resolved = { ...display };
|
|
1211
|
+
for (const [left, right] of [
|
|
1212
|
+
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
1213
|
+
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
1214
|
+
]) {
|
|
1215
|
+
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
1216
|
+
}
|
|
1217
|
+
return resolved;
|
|
1218
|
+
}
|
|
1219
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1220
|
+
static getMatrix(display, position) {
|
|
1221
|
+
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1222
|
+
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1223
|
+
const sign = left ? -1 : 1;
|
|
1224
|
+
const [x, y, z] = transform.rotation ?? [0, 0, 0];
|
|
1225
|
+
const rotation = new Quaternion().setFromEuler(new Euler(toRadians(x), sign * toRadians(y), sign * toRadians(z), "XYZ"));
|
|
1226
|
+
const translation = new Vector32(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1227
|
+
translation.x *= sign;
|
|
1228
|
+
const scale = new Vector32(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1229
|
+
return new Matrix4().compose(translation, rotation, scale);
|
|
1230
|
+
}
|
|
1231
|
+
static apply(geometry, matrix) {
|
|
1232
|
+
geometry.applyMatrix4(matrix);
|
|
1233
|
+
if (matrix.determinant() < 0) {
|
|
1234
|
+
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_, i) => i));
|
|
1235
|
+
const index = geometry.index;
|
|
1236
|
+
for (let i = 0; i < index.count; i += 3) {
|
|
1237
|
+
const second = index.getX(i + 1);
|
|
1238
|
+
index.setX(i + 1, index.getX(i + 2));
|
|
1239
|
+
index.setX(i + 2, second);
|
|
1240
|
+
}
|
|
1241
|
+
index.needsUpdate = true;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1187
1246
|
// src/model/ModelMerger.ts
|
|
1188
1247
|
var ModelMerger = class {
|
|
1189
1248
|
static async mergeWithParents(model) {
|
|
1190
1249
|
const models = await this.collectAllParents(model);
|
|
1191
1250
|
let merged = {};
|
|
1192
|
-
for (
|
|
1193
|
-
|
|
1251
|
+
for (const source of [...models, model]) {
|
|
1252
|
+
const inheritedDisplay = merged.display;
|
|
1253
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
1254
|
+
if (source.display) {
|
|
1255
|
+
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1256
|
+
}
|
|
1194
1257
|
}
|
|
1195
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
1196
1258
|
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1197
1259
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1198
1260
|
return merged;
|
|
@@ -1447,9 +1509,9 @@ var BatchedExecutor = class {
|
|
|
1447
1509
|
};
|
|
1448
1510
|
|
|
1449
1511
|
// src/util/model.ts
|
|
1450
|
-
import { AxesHelper, BoxGeometry as BoxGeometry2, EdgesGeometry, LineBasicMaterial, LineSegments, Vector3 as
|
|
1512
|
+
import { AxesHelper, BoxGeometry as BoxGeometry2, EdgesGeometry, LineBasicMaterial, LineSegments, Vector3 as Vector33 } from "three";
|
|
1451
1513
|
function applyElementRotation(rotation, geometry) {
|
|
1452
|
-
const origin = new
|
|
1514
|
+
const origin = new Vector33(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1453
1515
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1454
1516
|
switch (rotation.axis) {
|
|
1455
1517
|
case "x" /* X */:
|
|
@@ -1474,7 +1536,7 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1474
1536
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1475
1537
|
}
|
|
1476
1538
|
function applyModelPartRotation(modelPart, geometry) {
|
|
1477
|
-
const origin = new
|
|
1539
|
+
const origin = new Vector33(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1478
1540
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1479
1541
|
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1480
1542
|
geometry.rotateY(toRadians(modelPart.yaw));
|
|
@@ -1484,18 +1546,18 @@ function applyModelPartRotation(modelPart, geometry) {
|
|
|
1484
1546
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1485
1547
|
switch (axis) {
|
|
1486
1548
|
case "x" /* X */:
|
|
1487
|
-
obj.rotateOnAxis(new
|
|
1549
|
+
obj.rotateOnAxis(new Vector33(1, 0, 0), toRadians(rotation));
|
|
1488
1550
|
break;
|
|
1489
1551
|
case "y" /* Y */:
|
|
1490
|
-
obj.rotateOnAxis(new
|
|
1552
|
+
obj.rotateOnAxis(new Vector33(0, 1, 0), toRadians(rotation));
|
|
1491
1553
|
break;
|
|
1492
1554
|
case "z" /* Z */:
|
|
1493
|
-
obj.rotateOnAxis(new
|
|
1555
|
+
obj.rotateOnAxis(new Vector33(0, 0, 1), toRadians(rotation));
|
|
1494
1556
|
break;
|
|
1495
1557
|
}
|
|
1496
1558
|
}
|
|
1497
1559
|
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1498
|
-
let size = new
|
|
1560
|
+
let size = new Vector33();
|
|
1499
1561
|
box.getSize(size);
|
|
1500
1562
|
let boxGeo = new BoxGeometry2(size.x, size.y, size.z, 1, 1, 1);
|
|
1501
1563
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
@@ -2063,12 +2125,12 @@ var X = 0;
|
|
|
2063
2125
|
var Y = 1;
|
|
2064
2126
|
var Z = 2;
|
|
2065
2127
|
var FACE_UV_AXES = {
|
|
2066
|
-
east: [new
|
|
2067
|
-
west: [new
|
|
2068
|
-
up: [new
|
|
2069
|
-
down: [new
|
|
2070
|
-
south: [new
|
|
2071
|
-
north: [new
|
|
2128
|
+
east: [new Vector34(0, 0, -1), new Vector34(0, -1, 0)],
|
|
2129
|
+
west: [new Vector34(0, 0, 1), new Vector34(0, -1, 0)],
|
|
2130
|
+
up: [new Vector34(1, 0, 0), new Vector34(0, 0, 1)],
|
|
2131
|
+
down: [new Vector34(1, 0, 0), new Vector34(0, 0, -1)],
|
|
2132
|
+
south: [new Vector34(1, 0, 0), new Vector34(0, -1, 0)],
|
|
2133
|
+
north: [new Vector34(-1, 0, 0), new Vector34(0, -1, 0)]
|
|
2072
2134
|
};
|
|
2073
2135
|
var UVMapper = class {
|
|
2074
2136
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2649,7 +2711,7 @@ var BlockEntityModels = class {
|
|
|
2649
2711
|
};
|
|
2650
2712
|
|
|
2651
2713
|
// src/renderer/SceneObject.ts
|
|
2652
|
-
import { Euler as
|
|
2714
|
+
import { Euler as Euler3, InstancedMesh, MathUtils, Matrix4 as Matrix43, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion3, Vector3 as Vector35 } from "three";
|
|
2653
2715
|
|
|
2654
2716
|
// src/instance/InstanceReference.ts
|
|
2655
2717
|
var InstanceReference = class {
|
|
@@ -2886,7 +2948,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2886
2948
|
nextInstance() {
|
|
2887
2949
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2888
2950
|
const i = this._instanceCounter++;
|
|
2889
|
-
this.setMatrixAt(i, new
|
|
2951
|
+
this.setMatrixAt(i, new Matrix43());
|
|
2890
2952
|
const mesh = this.children[0];
|
|
2891
2953
|
if (mesh && isInstancedMesh(mesh)) {
|
|
2892
2954
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -2903,7 +2965,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2903
2965
|
}
|
|
2904
2966
|
//</editor-fold>
|
|
2905
2967
|
//<editor-fold desc="TRANSFORMATION">
|
|
2906
|
-
getMatrixAt(index, matrix = new
|
|
2968
|
+
getMatrixAt(index, matrix = new Matrix43()) {
|
|
2907
2969
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2908
2970
|
const child = this.children[0];
|
|
2909
2971
|
if (child && isInstancedMesh(child)) {
|
|
@@ -2922,16 +2984,16 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2922
2984
|
}
|
|
2923
2985
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2924
2986
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2925
|
-
const oldPosition = new
|
|
2926
|
-
const oldRotation = new
|
|
2927
|
-
const oldScale = new
|
|
2928
|
-
const matrix = new
|
|
2987
|
+
const oldPosition = new Vector35();
|
|
2988
|
+
const oldRotation = new Quaternion3();
|
|
2989
|
+
const oldScale = new Vector35();
|
|
2990
|
+
const matrix = new Matrix43();
|
|
2929
2991
|
if (!scale || !rotation || !position) {
|
|
2930
2992
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
2931
2993
|
}
|
|
2932
2994
|
matrix.compose(
|
|
2933
2995
|
position ? position : oldPosition,
|
|
2934
|
-
rotation ? new
|
|
2996
|
+
rotation ? new Quaternion3().setFromEuler(rotation) : oldRotation,
|
|
2935
2997
|
scale ? scale : oldScale
|
|
2936
2998
|
);
|
|
2937
2999
|
this.setMatrixAt(index, matrix);
|
|
@@ -2940,7 +3002,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2940
3002
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2941
3003
|
this.setPositionRotationScaleAt(index, position);
|
|
2942
3004
|
}
|
|
2943
|
-
getPositionAt(index, vector = new
|
|
3005
|
+
getPositionAt(index, vector = new Vector35()) {
|
|
2944
3006
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2945
3007
|
const matrix = this.getMatrixAt(index);
|
|
2946
3008
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2950,7 +3012,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2950
3012
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2951
3013
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
2952
3014
|
}
|
|
2953
|
-
getRotationAt(index, euler = new
|
|
3015
|
+
getRotationAt(index, euler = new Euler3()) {
|
|
2954
3016
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2955
3017
|
const matrix = this.getMatrixAt(index);
|
|
2956
3018
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -2960,7 +3022,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2960
3022
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2961
3023
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
2962
3024
|
}
|
|
2963
|
-
getScaleAt(index, vector = new
|
|
3025
|
+
getScaleAt(index, vector = new Vector35()) {
|
|
2964
3026
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2965
3027
|
const matrix = this.getMatrixAt(index);
|
|
2966
3028
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3586,20 +3648,6 @@ function isInstanceable(obj) {
|
|
|
3586
3648
|
return "nextInstance" in obj;
|
|
3587
3649
|
}
|
|
3588
3650
|
|
|
3589
|
-
// src/model/DisplayPosition.ts
|
|
3590
|
-
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
3591
|
-
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
3592
|
-
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
3593
|
-
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
3594
|
-
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
3595
|
-
DisplayPosition2["GUI"] = "gui";
|
|
3596
|
-
DisplayPosition2["HEAD"] = "head";
|
|
3597
|
-
DisplayPosition2["GROUND"] = "ground";
|
|
3598
|
-
DisplayPosition2["FIXED"] = "fixed";
|
|
3599
|
-
return DisplayPosition2;
|
|
3600
|
-
})(DisplayPosition || {});
|
|
3601
|
-
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
3602
|
-
|
|
3603
3651
|
// src/model/GuiLight.ts
|
|
3604
3652
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3605
3653
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3708,7 +3756,7 @@ var BlockTints = class {
|
|
|
3708
3756
|
};
|
|
3709
3757
|
|
|
3710
3758
|
// src/model/scene/ModelObject.ts
|
|
3711
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as
|
|
3759
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler5, Matrix4 as Matrix46 } from "three";
|
|
3712
3760
|
|
|
3713
3761
|
// src/three/BufferGeometryUtils.js
|
|
3714
3762
|
import {
|
|
@@ -3720,7 +3768,7 @@ import {
|
|
|
3720
3768
|
TriangleFanDrawMode,
|
|
3721
3769
|
TriangleStripDrawMode,
|
|
3722
3770
|
TrianglesDrawMode,
|
|
3723
|
-
Vector3 as
|
|
3771
|
+
Vector3 as Vector37
|
|
3724
3772
|
} from "three";
|
|
3725
3773
|
function computeTangents(geometry) {
|
|
3726
3774
|
geometry.computeTangents();
|
|
@@ -4039,15 +4087,15 @@ function computeMorphedAttributes(object) {
|
|
|
4039
4087
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4040
4088
|
return null;
|
|
4041
4089
|
}
|
|
4042
|
-
const _vA = new
|
|
4043
|
-
const _vB = new
|
|
4044
|
-
const _vC = new
|
|
4045
|
-
const _tempA = new
|
|
4046
|
-
const _tempB = new
|
|
4047
|
-
const _tempC = new
|
|
4048
|
-
const _morphA = new
|
|
4049
|
-
const _morphB = new
|
|
4050
|
-
const _morphC = new
|
|
4090
|
+
const _vA = new Vector37();
|
|
4091
|
+
const _vB = new Vector37();
|
|
4092
|
+
const _vC = new Vector37();
|
|
4093
|
+
const _tempA = new Vector37();
|
|
4094
|
+
const _tempB = new Vector37();
|
|
4095
|
+
const _tempC = new Vector37();
|
|
4096
|
+
const _morphA = new Vector37();
|
|
4097
|
+
const _morphB = new Vector37();
|
|
4098
|
+
const _morphC = new Vector37();
|
|
4051
4099
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4052
4100
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4053
4101
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4284,13 +4332,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4284
4332
|
createMeshes(force = false) {
|
|
4285
4333
|
if (this.meshesCreated && !force) return;
|
|
4286
4334
|
const mat = Materials.MISSING_TEXTURE;
|
|
4335
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4287
4336
|
let allGeos = [];
|
|
4288
4337
|
if (this.atlas) {
|
|
4289
4338
|
if (this.atlas.model.elements) {
|
|
4290
4339
|
this.atlas.model.elements?.forEach((el) => {
|
|
4291
4340
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4292
4341
|
if (this.options.uvLockRotation) {
|
|
4293
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4342
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler5(...this.options.uvLockRotation));
|
|
4294
4343
|
}
|
|
4295
4344
|
if (this.options.tints) {
|
|
4296
4345
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4306,12 +4355,13 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4306
4355
|
}
|
|
4307
4356
|
elGeo.setAttribute("color", new BufferAttribute4(colors, 3));
|
|
4308
4357
|
}
|
|
4309
|
-
elGeo.applyMatrix4(new
|
|
4310
|
-
elGeo.applyMatrix4(new
|
|
4358
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4359
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4311
4360
|
if (el.rotation) {
|
|
4312
4361
|
applyElementRotation(el.rotation, elGeo);
|
|
4313
4362
|
}
|
|
4314
|
-
elGeo.applyMatrix4(new
|
|
4363
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(-8, -8, -8));
|
|
4364
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4315
4365
|
if (this.options.mergeMeshes) {
|
|
4316
4366
|
allGeos.push(elGeo);
|
|
4317
4367
|
} else {
|
|
@@ -4333,6 +4383,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4333
4383
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4334
4384
|
} else {
|
|
4335
4385
|
combinedGeo = new BoxGeometry5(16, 16, 16);
|
|
4386
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4336
4387
|
}
|
|
4337
4388
|
combinedGeo.computeBoundingBox();
|
|
4338
4389
|
let mesh;
|
|
@@ -4386,7 +4437,7 @@ function isModelObject(obj) {
|
|
|
4386
4437
|
|
|
4387
4438
|
// src/model/block/scene/BlockObject.ts
|
|
4388
4439
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4389
|
-
import { Euler as
|
|
4440
|
+
import { Euler as Euler6, Matrix4 as Matrix47, Vector3 as Vector38 } from "three";
|
|
4390
4441
|
var p10 = prefix("BlockObject");
|
|
4391
4442
|
function matchesCondition(condition, state) {
|
|
4392
4443
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4443,7 +4494,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4443
4494
|
if (isModelObject(model)) {
|
|
4444
4495
|
model.removeFromScene();
|
|
4445
4496
|
} else if (isInstanceReference(model)) {
|
|
4446
|
-
model.setScale(new
|
|
4497
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4447
4498
|
}
|
|
4448
4499
|
}
|
|
4449
4500
|
super.removeFromScene();
|
|
@@ -4504,7 +4555,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4504
4555
|
}
|
|
4505
4556
|
for (let model of this._models) {
|
|
4506
4557
|
if (isInstanceReference(model)) {
|
|
4507
|
-
model.setScale(new
|
|
4558
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4508
4559
|
} else {
|
|
4509
4560
|
model.dispose();
|
|
4510
4561
|
}
|
|
@@ -4541,7 +4592,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4541
4592
|
await this.createVariant(variant);
|
|
4542
4593
|
}
|
|
4543
4594
|
async createVariant(variant) {
|
|
4544
|
-
const rotation = new
|
|
4595
|
+
const rotation = new Euler6();
|
|
4545
4596
|
if (typeof variant.x !== "undefined") {
|
|
4546
4597
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4547
4598
|
}
|
|
@@ -4628,7 +4679,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4628
4679
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4629
4680
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4630
4681
|
}
|
|
4631
|
-
getMatrixAt(index, matrix = new
|
|
4682
|
+
getMatrixAt(index, matrix = new Matrix47()) {
|
|
4632
4683
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4633
4684
|
const child = this._models[0];
|
|
4634
4685
|
if (child && isModelObject(child)) {
|
|
@@ -5624,7 +5675,8 @@ var _MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5624
5675
|
console.log("instanceMeshes + key");
|
|
5625
5676
|
let key = asset.key.serialize();
|
|
5626
5677
|
if (isModelObject(obj)) {
|
|
5627
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5678
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5679
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5628
5680
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5629
5681
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5630
5682
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5673,7 +5725,7 @@ function isMineRenderScene(obj) {
|
|
|
5673
5725
|
}
|
|
5674
5726
|
|
|
5675
5727
|
// src/renderer/Renderer.ts
|
|
5676
|
-
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as
|
|
5728
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector310, WebGLRenderer } from "three";
|
|
5677
5729
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5678
5730
|
import Stats from "stats.js";
|
|
5679
5731
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5682,11 +5734,11 @@ import { EffectComposer, RenderPass } from "postprocessing";
|
|
|
5682
5734
|
import {
|
|
5683
5735
|
EventDispatcher,
|
|
5684
5736
|
MOUSE,
|
|
5685
|
-
Quaternion as
|
|
5737
|
+
Quaternion as Quaternion4,
|
|
5686
5738
|
Spherical,
|
|
5687
5739
|
TOUCH,
|
|
5688
5740
|
Vector2 as Vector23,
|
|
5689
|
-
Vector3 as
|
|
5741
|
+
Vector3 as Vector39
|
|
5690
5742
|
} from "three";
|
|
5691
5743
|
var _changeEvent = { type: "change" };
|
|
5692
5744
|
var _startEvent = { type: "start" };
|
|
@@ -5700,7 +5752,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5700
5752
|
this.domElement = domElement;
|
|
5701
5753
|
this.domElement.style.touchAction = "none";
|
|
5702
5754
|
this.enabled = true;
|
|
5703
|
-
this.target = new
|
|
5755
|
+
this.target = new Vector39();
|
|
5704
5756
|
this.minDistance = 0;
|
|
5705
5757
|
this.maxDistance = Infinity;
|
|
5706
5758
|
this.minZoom = 0;
|
|
@@ -5752,11 +5804,11 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5752
5804
|
state = STATE.NONE;
|
|
5753
5805
|
};
|
|
5754
5806
|
this.update = function() {
|
|
5755
|
-
const offset = new
|
|
5756
|
-
const quat = new
|
|
5807
|
+
const offset = new Vector39();
|
|
5808
|
+
const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector39(0, 1, 0));
|
|
5757
5809
|
const quatInverse = quat.clone().invert();
|
|
5758
|
-
const lastPosition = new
|
|
5759
|
-
const lastQuaternion = new
|
|
5810
|
+
const lastPosition = new Vector39();
|
|
5811
|
+
const lastQuaternion = new Quaternion4();
|
|
5760
5812
|
const twoPI = 2 * Math.PI;
|
|
5761
5813
|
return function update() {
|
|
5762
5814
|
const position = scope.object.position;
|
|
@@ -5845,7 +5897,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5845
5897
|
const spherical = new Spherical();
|
|
5846
5898
|
const sphericalDelta = new Spherical();
|
|
5847
5899
|
let scale = 1;
|
|
5848
|
-
const panOffset = new
|
|
5900
|
+
const panOffset = new Vector39();
|
|
5849
5901
|
let zoomChanged = false;
|
|
5850
5902
|
const rotateStart = new Vector23();
|
|
5851
5903
|
const rotateEnd = new Vector23();
|
|
@@ -5871,7 +5923,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5871
5923
|
sphericalDelta.phi -= angle;
|
|
5872
5924
|
}
|
|
5873
5925
|
const panLeft = function() {
|
|
5874
|
-
const v = new
|
|
5926
|
+
const v = new Vector39();
|
|
5875
5927
|
return function panLeft2(distance, objectMatrix) {
|
|
5876
5928
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5877
5929
|
v.multiplyScalar(-distance);
|
|
@@ -5879,7 +5931,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5879
5931
|
};
|
|
5880
5932
|
}();
|
|
5881
5933
|
const panUp = function() {
|
|
5882
|
-
const v = new
|
|
5934
|
+
const v = new Vector39();
|
|
5883
5935
|
return function panUp2(distance, objectMatrix) {
|
|
5884
5936
|
if (scope.screenSpacePanning === true) {
|
|
5885
5937
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5892,7 +5944,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5892
5944
|
};
|
|
5893
5945
|
}();
|
|
5894
5946
|
const pan = function() {
|
|
5895
|
-
const offset = new
|
|
5947
|
+
const offset = new Vector39();
|
|
5896
5948
|
return function pan2(deltaX, deltaY) {
|
|
5897
5949
|
const element = scope.domElement;
|
|
5898
5950
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6639,8 +6691,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6639
6691
|
top: void 0,
|
|
6640
6692
|
bottom: void 0
|
|
6641
6693
|
},
|
|
6642
|
-
position: new
|
|
6643
|
-
lookingAt: new
|
|
6694
|
+
position: new Vector310(50, 50, 50),
|
|
6695
|
+
lookingAt: new Vector310(0, 0, 0)
|
|
6644
6696
|
},
|
|
6645
6697
|
render: {
|
|
6646
6698
|
fpsLimit: 60,
|
|
@@ -6834,10 +6886,10 @@ var Skins = class {
|
|
|
6834
6886
|
};
|
|
6835
6887
|
|
|
6836
6888
|
// src/world/Chunk.ts
|
|
6837
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6889
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector312 } from "three";
|
|
6838
6890
|
|
|
6839
6891
|
// src/world/MineRenderWorld.ts
|
|
6840
|
-
import { Vector3 as
|
|
6892
|
+
import { Vector3 as Vector311 } from "three";
|
|
6841
6893
|
var MineRenderWorld = class {
|
|
6842
6894
|
constructor(scene) {
|
|
6843
6895
|
this._size = 4;
|
|
@@ -6848,10 +6900,10 @@ var MineRenderWorld = class {
|
|
|
6848
6900
|
}
|
|
6849
6901
|
getBlockAt(posOrX, y, z) {
|
|
6850
6902
|
if (typeof posOrX == "number") {
|
|
6851
|
-
return this.getBlockAt(new
|
|
6903
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6852
6904
|
}
|
|
6853
6905
|
if (isTripleArray(posOrX)) {
|
|
6854
|
-
return this.getBlockAt(new
|
|
6906
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6855
6907
|
}
|
|
6856
6908
|
const chunk = this.getChunkAt(posOrX);
|
|
6857
6909
|
if (typeof chunk === "undefined") {
|
|
@@ -6862,10 +6914,10 @@ var MineRenderWorld = class {
|
|
|
6862
6914
|
}
|
|
6863
6915
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6864
6916
|
if (typeof posOrX == "number") {
|
|
6865
|
-
return this.setBlockAt(new
|
|
6917
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6866
6918
|
}
|
|
6867
6919
|
if (isTripleArray(posOrX)) {
|
|
6868
|
-
return this.setBlockAt(new
|
|
6920
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6869
6921
|
}
|
|
6870
6922
|
this.validatePosBounds(posOrX);
|
|
6871
6923
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6911,14 +6963,14 @@ var MineRenderWorld = class {
|
|
|
6911
6963
|
return this._chunks[index];
|
|
6912
6964
|
}
|
|
6913
6965
|
static worldToScenePosition(pos) {
|
|
6914
|
-
return new
|
|
6966
|
+
return new Vector311(
|
|
6915
6967
|
pos.x * 16,
|
|
6916
6968
|
pos.y * 16,
|
|
6917
6969
|
pos.z * 16
|
|
6918
6970
|
);
|
|
6919
6971
|
}
|
|
6920
6972
|
static sceneToWorldPosition(pos) {
|
|
6921
|
-
return new
|
|
6973
|
+
return new Vector311(
|
|
6922
6974
|
pos.x / 16,
|
|
6923
6975
|
pos.y / 16,
|
|
6924
6976
|
pos.z / 16
|
|
@@ -6960,7 +7012,7 @@ var Chunk = class _Chunk {
|
|
|
6960
7012
|
scene.add(anchor);
|
|
6961
7013
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
6962
7014
|
addBox3WireframeToObject(
|
|
6963
|
-
new Box32(new
|
|
7015
|
+
new Box32(new Vector312(0, 0, 0), new Vector312(256, 256, 256)),
|
|
6964
7016
|
anchor,
|
|
6965
7017
|
16776960,
|
|
6966
7018
|
4
|
|
@@ -6968,10 +7020,10 @@ var Chunk = class _Chunk {
|
|
|
6968
7020
|
}
|
|
6969
7021
|
getBlockAt(posOrX, y, z) {
|
|
6970
7022
|
if (typeof posOrX == "number") {
|
|
6971
|
-
return this.getBlockAt(new
|
|
7023
|
+
return this.getBlockAt(new Vector312(posOrX, y, z));
|
|
6972
7024
|
}
|
|
6973
7025
|
if (isTripleArray(posOrX)) {
|
|
6974
|
-
return this.getBlockAt(new
|
|
7026
|
+
return this.getBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]));
|
|
6975
7027
|
}
|
|
6976
7028
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
6977
7029
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -6979,10 +7031,10 @@ var Chunk = class _Chunk {
|
|
|
6979
7031
|
}
|
|
6980
7032
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6981
7033
|
if (typeof posOrX == "number") {
|
|
6982
|
-
return this.setBlockAt(new
|
|
7034
|
+
return this.setBlockAt(new Vector312(posOrX, yOrBlock, z), block);
|
|
6983
7035
|
}
|
|
6984
7036
|
if (isTripleArray(posOrX)) {
|
|
6985
|
-
return this.setBlockAt(new
|
|
7037
|
+
return this.setBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6986
7038
|
}
|
|
6987
7039
|
const worldPos = posOrX;
|
|
6988
7040
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7028,7 +7080,7 @@ var Chunk = class _Chunk {
|
|
|
7028
7080
|
}
|
|
7029
7081
|
async clear() {
|
|
7030
7082
|
let promises = [];
|
|
7031
|
-
let pos = new
|
|
7083
|
+
let pos = new Vector312();
|
|
7032
7084
|
for (let x = 0; x < 16; x++) {
|
|
7033
7085
|
for (let z = 0; z < 16; z++) {
|
|
7034
7086
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7047,14 +7099,14 @@ var Chunk = class _Chunk {
|
|
|
7047
7099
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7048
7100
|
}
|
|
7049
7101
|
worldPosToChunkPos(pos) {
|
|
7050
|
-
return new
|
|
7102
|
+
return new Vector312(
|
|
7051
7103
|
pos.x - this.x * 16,
|
|
7052
7104
|
pos.y - this.y * 16,
|
|
7053
7105
|
pos.z - this.z * 16
|
|
7054
7106
|
);
|
|
7055
7107
|
}
|
|
7056
7108
|
chunkPosToWorldPos(pos) {
|
|
7057
|
-
return new
|
|
7109
|
+
return new Vector312(
|
|
7058
7110
|
this.x * 16 + pos.x,
|
|
7059
7111
|
this.y * 16 + pos.y,
|
|
7060
7112
|
this.z * 16 + pos.z
|
|
@@ -7095,6 +7147,7 @@ export {
|
|
|
7095
7147
|
DISPLAY_POSITIONS,
|
|
7096
7148
|
DefaultBlockStates,
|
|
7097
7149
|
DisplayPosition,
|
|
7150
|
+
DisplayTransforms,
|
|
7098
7151
|
Entities,
|
|
7099
7152
|
EntityModels,
|
|
7100
7153
|
EntityObject,
|