minerender 2.1.0-alpha.21 → 2.1.0-alpha.23
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 +16 -4
- package/dist/browser/index.d.ts +16 -4
- package/dist/browser/index.js +258 -191
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +166 -99
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +96 -27
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +16 -4
- package/dist/node/index.d.ts +16 -4
- package/dist/node/index.js +259 -191
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +166 -99
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1098,7 +1098,7 @@ var Meshes = class _Meshes {
|
|
|
1098
1098
|
};
|
|
1099
1099
|
|
|
1100
1100
|
// src/UVMapper.ts
|
|
1101
|
-
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as
|
|
1101
|
+
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as Vector34 } from "three";
|
|
1102
1102
|
|
|
1103
1103
|
// src/model/ModelMerger.ts
|
|
1104
1104
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1189,15 +1189,77 @@ function isAssetKey(obj) {
|
|
|
1189
1189
|
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
|
+
// src/model/DisplayTransforms.ts
|
|
1193
|
+
import { Euler, Matrix4, Quaternion, Vector3 as Vector32 } from "three";
|
|
1194
|
+
|
|
1195
|
+
// src/model/DisplayPosition.ts
|
|
1196
|
+
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
1197
|
+
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1198
|
+
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1199
|
+
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1200
|
+
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1201
|
+
DisplayPosition2["GUI"] = "gui";
|
|
1202
|
+
DisplayPosition2["HEAD"] = "head";
|
|
1203
|
+
DisplayPosition2["GROUND"] = "ground";
|
|
1204
|
+
DisplayPosition2["FIXED"] = "fixed";
|
|
1205
|
+
DisplayPosition2["ON_SHELF"] = "on_shelf";
|
|
1206
|
+
return DisplayPosition2;
|
|
1207
|
+
})(DisplayPosition || {});
|
|
1208
|
+
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1209
|
+
|
|
1210
|
+
// src/model/DisplayTransforms.ts
|
|
1211
|
+
var DisplayTransforms = class {
|
|
1212
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
1213
|
+
static withHandFallbacks(display) {
|
|
1214
|
+
if (!display) return void 0;
|
|
1215
|
+
const resolved = { ...display };
|
|
1216
|
+
for (const [left, right] of [
|
|
1217
|
+
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
1218
|
+
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
1219
|
+
]) {
|
|
1220
|
+
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
1221
|
+
}
|
|
1222
|
+
return resolved;
|
|
1223
|
+
}
|
|
1224
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1225
|
+
static getMatrix(display, position) {
|
|
1226
|
+
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1227
|
+
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1228
|
+
const sign = left ? -1 : 1;
|
|
1229
|
+
const [x, y, z] = transform.rotation ?? [0, 0, 0];
|
|
1230
|
+
const rotation = new Quaternion().setFromEuler(new Euler(toRadians(x), sign * toRadians(y), sign * toRadians(z), "XYZ"));
|
|
1231
|
+
const translation = new Vector32(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1232
|
+
translation.x *= sign;
|
|
1233
|
+
const scale = new Vector32(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1234
|
+
return new Matrix4().compose(translation, rotation, scale);
|
|
1235
|
+
}
|
|
1236
|
+
static apply(geometry, matrix) {
|
|
1237
|
+
geometry.applyMatrix4(matrix);
|
|
1238
|
+
if (matrix.determinant() < 0) {
|
|
1239
|
+
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_, i) => i));
|
|
1240
|
+
const index = geometry.index;
|
|
1241
|
+
for (let i = 0; i < index.count; i += 3) {
|
|
1242
|
+
const second = index.getX(i + 1);
|
|
1243
|
+
index.setX(i + 1, index.getX(i + 2));
|
|
1244
|
+
index.setX(i + 2, second);
|
|
1245
|
+
}
|
|
1246
|
+
index.needsUpdate = true;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1192
1251
|
// src/model/ModelMerger.ts
|
|
1193
1252
|
var ModelMerger = class {
|
|
1194
1253
|
static async mergeWithParents(model) {
|
|
1195
1254
|
const models = await this.collectAllParents(model);
|
|
1196
1255
|
let merged = {};
|
|
1197
|
-
for (
|
|
1198
|
-
|
|
1256
|
+
for (const source of [...models, model]) {
|
|
1257
|
+
const inheritedDisplay = merged.display;
|
|
1258
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
1259
|
+
if (source.display) {
|
|
1260
|
+
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1261
|
+
}
|
|
1199
1262
|
}
|
|
1200
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
1201
1263
|
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1202
1264
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1203
1265
|
return merged;
|
|
@@ -1343,7 +1405,7 @@ var BlockStates = class {
|
|
|
1343
1405
|
void 0,
|
|
1344
1406
|
"assets",
|
|
1345
1407
|
".json",
|
|
1346
|
-
|
|
1408
|
+
AssetLoader.ROOT
|
|
1347
1409
|
);
|
|
1348
1410
|
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1349
1411
|
return AssetLoader.get(key, "list" /* LIST */);
|
|
@@ -1452,9 +1514,9 @@ var BatchedExecutor = class {
|
|
|
1452
1514
|
};
|
|
1453
1515
|
|
|
1454
1516
|
// src/util/model.ts
|
|
1455
|
-
import { AxesHelper, BoxGeometry as BoxGeometry2, EdgesGeometry, LineBasicMaterial, LineSegments, Vector3 as
|
|
1517
|
+
import { AxesHelper, BoxGeometry as BoxGeometry2, EdgesGeometry, LineBasicMaterial, LineSegments, Vector3 as Vector33 } from "three";
|
|
1456
1518
|
function applyElementRotation(rotation, geometry) {
|
|
1457
|
-
const origin = new
|
|
1519
|
+
const origin = new Vector33(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1458
1520
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1459
1521
|
switch (rotation.axis) {
|
|
1460
1522
|
case "x" /* X */:
|
|
@@ -1479,7 +1541,7 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1479
1541
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1480
1542
|
}
|
|
1481
1543
|
function applyModelPartRotation(modelPart, geometry) {
|
|
1482
|
-
const origin = new
|
|
1544
|
+
const origin = new Vector33(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1483
1545
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1484
1546
|
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1485
1547
|
geometry.rotateY(toRadians(modelPart.yaw));
|
|
@@ -1489,18 +1551,18 @@ function applyModelPartRotation(modelPart, geometry) {
|
|
|
1489
1551
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1490
1552
|
switch (axis) {
|
|
1491
1553
|
case "x" /* X */:
|
|
1492
|
-
obj.rotateOnAxis(new
|
|
1554
|
+
obj.rotateOnAxis(new Vector33(1, 0, 0), toRadians(rotation));
|
|
1493
1555
|
break;
|
|
1494
1556
|
case "y" /* Y */:
|
|
1495
|
-
obj.rotateOnAxis(new
|
|
1557
|
+
obj.rotateOnAxis(new Vector33(0, 1, 0), toRadians(rotation));
|
|
1496
1558
|
break;
|
|
1497
1559
|
case "z" /* Z */:
|
|
1498
|
-
obj.rotateOnAxis(new
|
|
1560
|
+
obj.rotateOnAxis(new Vector33(0, 0, 1), toRadians(rotation));
|
|
1499
1561
|
break;
|
|
1500
1562
|
}
|
|
1501
1563
|
}
|
|
1502
1564
|
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1503
|
-
let size = new
|
|
1565
|
+
let size = new Vector33();
|
|
1504
1566
|
box.getSize(size);
|
|
1505
1567
|
let boxGeo = new BoxGeometry2(size.x, size.y, size.z, 1, 1, 1);
|
|
1506
1568
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
@@ -1660,17 +1722,17 @@ var HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
|
1660
1722
|
if (typeof namespaced !== "undefined") {
|
|
1661
1723
|
return namespaced;
|
|
1662
1724
|
}
|
|
1663
|
-
if (typeof key.root !== "undefined" && key.root !==
|
|
1725
|
+
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1664
1726
|
console.info(p3, "Retrying", key, "with default root+namespace");
|
|
1665
|
-
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1727
|
+
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1666
1728
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1667
1729
|
if (typeof namespacedRooted !== "undefined") {
|
|
1668
1730
|
return namespacedRooted;
|
|
1669
1731
|
}
|
|
1670
1732
|
}
|
|
1671
|
-
} else if (typeof key.root !== "undefined" && key.root !==
|
|
1733
|
+
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1672
1734
|
console.info(p3, "Retrying", key, "with default root");
|
|
1673
|
-
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1735
|
+
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1674
1736
|
const rooted = await this.load(rootKey, parser);
|
|
1675
1737
|
if (typeof rooted !== "undefined") {
|
|
1676
1738
|
return rooted;
|
|
@@ -1804,6 +1866,20 @@ var AssetLoader = class {
|
|
|
1804
1866
|
static {
|
|
1805
1867
|
this._SOURCES = [];
|
|
1806
1868
|
}
|
|
1869
|
+
static get version() {
|
|
1870
|
+
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
1871
|
+
}
|
|
1872
|
+
static setVersion(version) {
|
|
1873
|
+
this.ROOT = `https://assets.mcasset.cloud/${version}`;
|
|
1874
|
+
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
1875
|
+
const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
|
|
1876
|
+
if (index !== -1) {
|
|
1877
|
+
this._SOURCES[index] = { key: "mcassets", source };
|
|
1878
|
+
} else {
|
|
1879
|
+
this.addSource("mcassets", source);
|
|
1880
|
+
}
|
|
1881
|
+
Caching.clear();
|
|
1882
|
+
}
|
|
1807
1883
|
static addSource(key, source, override = true) {
|
|
1808
1884
|
if (override) {
|
|
1809
1885
|
const existing = this.removeSource(key);
|
|
@@ -1826,7 +1902,7 @@ var AssetLoader = class {
|
|
|
1826
1902
|
}
|
|
1827
1903
|
static {
|
|
1828
1904
|
this.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
|
|
1829
|
-
this.addSource("mcassets", new HostedAssetSource(
|
|
1905
|
+
this.addSource("mcassets", new HostedAssetSource(this.ROOT, { retryDefaults: false }));
|
|
1830
1906
|
}
|
|
1831
1907
|
static async getAll(key, parser) {
|
|
1832
1908
|
let promises = [];
|
|
@@ -2103,12 +2179,12 @@ var X = 0;
|
|
|
2103
2179
|
var Y = 1;
|
|
2104
2180
|
var Z = 2;
|
|
2105
2181
|
var FACE_UV_AXES = {
|
|
2106
|
-
east: [new
|
|
2107
|
-
west: [new
|
|
2108
|
-
up: [new
|
|
2109
|
-
down: [new
|
|
2110
|
-
south: [new
|
|
2111
|
-
north: [new
|
|
2182
|
+
east: [new Vector34(0, 0, -1), new Vector34(0, -1, 0)],
|
|
2183
|
+
west: [new Vector34(0, 0, 1), new Vector34(0, -1, 0)],
|
|
2184
|
+
up: [new Vector34(1, 0, 0), new Vector34(0, 0, 1)],
|
|
2185
|
+
down: [new Vector34(1, 0, 0), new Vector34(0, 0, -1)],
|
|
2186
|
+
south: [new Vector34(1, 0, 0), new Vector34(0, -1, 0)],
|
|
2187
|
+
north: [new Vector34(-1, 0, 0), new Vector34(0, -1, 0)]
|
|
2112
2188
|
};
|
|
2113
2189
|
var UVMapper = class {
|
|
2114
2190
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2689,7 +2765,7 @@ var BlockEntityModels = class {
|
|
|
2689
2765
|
};
|
|
2690
2766
|
|
|
2691
2767
|
// src/renderer/SceneObject.ts
|
|
2692
|
-
import { Euler as
|
|
2768
|
+
import { Euler as Euler3, InstancedMesh, MathUtils, Matrix4 as Matrix43, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion3, Vector3 as Vector35 } from "three";
|
|
2693
2769
|
|
|
2694
2770
|
// src/instance/InstanceReference.ts
|
|
2695
2771
|
var InstanceReference = class {
|
|
@@ -2934,7 +3010,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2934
3010
|
nextInstance() {
|
|
2935
3011
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2936
3012
|
const i = this._instanceCounter++;
|
|
2937
|
-
this.setMatrixAt(i, new
|
|
3013
|
+
this.setMatrixAt(i, new Matrix43());
|
|
2938
3014
|
const mesh = this.children[0];
|
|
2939
3015
|
if (mesh && isInstancedMesh(mesh)) {
|
|
2940
3016
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -2951,7 +3027,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2951
3027
|
}
|
|
2952
3028
|
//</editor-fold>
|
|
2953
3029
|
//<editor-fold desc="TRANSFORMATION">
|
|
2954
|
-
getMatrixAt(index, matrix = new
|
|
3030
|
+
getMatrixAt(index, matrix = new Matrix43()) {
|
|
2955
3031
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2956
3032
|
const child = this.children[0];
|
|
2957
3033
|
if (child && isInstancedMesh(child)) {
|
|
@@ -2970,16 +3046,16 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2970
3046
|
}
|
|
2971
3047
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2972
3048
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2973
|
-
const oldPosition = new
|
|
2974
|
-
const oldRotation = new
|
|
2975
|
-
const oldScale = new
|
|
2976
|
-
const matrix = new
|
|
3049
|
+
const oldPosition = new Vector35();
|
|
3050
|
+
const oldRotation = new Quaternion3();
|
|
3051
|
+
const oldScale = new Vector35();
|
|
3052
|
+
const matrix = new Matrix43();
|
|
2977
3053
|
if (!scale || !rotation || !position) {
|
|
2978
3054
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
2979
3055
|
}
|
|
2980
3056
|
matrix.compose(
|
|
2981
3057
|
position ? position : oldPosition,
|
|
2982
|
-
rotation ? new
|
|
3058
|
+
rotation ? new Quaternion3().setFromEuler(rotation) : oldRotation,
|
|
2983
3059
|
scale ? scale : oldScale
|
|
2984
3060
|
);
|
|
2985
3061
|
this.setMatrixAt(index, matrix);
|
|
@@ -2988,7 +3064,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2988
3064
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2989
3065
|
this.setPositionRotationScaleAt(index, position);
|
|
2990
3066
|
}
|
|
2991
|
-
getPositionAt(index, vector = new
|
|
3067
|
+
getPositionAt(index, vector = new Vector35()) {
|
|
2992
3068
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2993
3069
|
const matrix = this.getMatrixAt(index);
|
|
2994
3070
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2998,7 +3074,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2998
3074
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2999
3075
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3000
3076
|
}
|
|
3001
|
-
getRotationAt(index, euler = new
|
|
3077
|
+
getRotationAt(index, euler = new Euler3()) {
|
|
3002
3078
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3003
3079
|
const matrix = this.getMatrixAt(index);
|
|
3004
3080
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -3008,7 +3084,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
3008
3084
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3009
3085
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3010
3086
|
}
|
|
3011
|
-
getScaleAt(index, vector = new
|
|
3087
|
+
getScaleAt(index, vector = new Vector35()) {
|
|
3012
3088
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3013
3089
|
const matrix = this.getMatrixAt(index);
|
|
3014
3090
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3629,20 +3705,6 @@ function isInstanceable(obj) {
|
|
|
3629
3705
|
return "nextInstance" in obj;
|
|
3630
3706
|
}
|
|
3631
3707
|
|
|
3632
|
-
// src/model/DisplayPosition.ts
|
|
3633
|
-
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
3634
|
-
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
3635
|
-
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
3636
|
-
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
3637
|
-
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
3638
|
-
DisplayPosition2["GUI"] = "gui";
|
|
3639
|
-
DisplayPosition2["HEAD"] = "head";
|
|
3640
|
-
DisplayPosition2["GROUND"] = "ground";
|
|
3641
|
-
DisplayPosition2["FIXED"] = "fixed";
|
|
3642
|
-
return DisplayPosition2;
|
|
3643
|
-
})(DisplayPosition || {});
|
|
3644
|
-
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
3645
|
-
|
|
3646
3708
|
// src/model/GuiLight.ts
|
|
3647
3709
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3648
3710
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3751,7 +3813,7 @@ var BlockTints = class {
|
|
|
3751
3813
|
};
|
|
3752
3814
|
|
|
3753
3815
|
// src/model/scene/ModelObject.ts
|
|
3754
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as
|
|
3816
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler5, Matrix4 as Matrix46 } from "three";
|
|
3755
3817
|
|
|
3756
3818
|
// src/three/BufferGeometryUtils.js
|
|
3757
3819
|
import {
|
|
@@ -3763,7 +3825,7 @@ import {
|
|
|
3763
3825
|
TriangleFanDrawMode,
|
|
3764
3826
|
TriangleStripDrawMode,
|
|
3765
3827
|
TrianglesDrawMode,
|
|
3766
|
-
Vector3 as
|
|
3828
|
+
Vector3 as Vector37
|
|
3767
3829
|
} from "three";
|
|
3768
3830
|
function computeTangents(geometry) {
|
|
3769
3831
|
geometry.computeTangents();
|
|
@@ -4082,15 +4144,15 @@ function computeMorphedAttributes(object) {
|
|
|
4082
4144
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4083
4145
|
return null;
|
|
4084
4146
|
}
|
|
4085
|
-
const _vA = new
|
|
4086
|
-
const _vB = new
|
|
4087
|
-
const _vC = new
|
|
4088
|
-
const _tempA = new
|
|
4089
|
-
const _tempB = new
|
|
4090
|
-
const _tempC = new
|
|
4091
|
-
const _morphA = new
|
|
4092
|
-
const _morphB = new
|
|
4093
|
-
const _morphC = new
|
|
4147
|
+
const _vA = new Vector37();
|
|
4148
|
+
const _vB = new Vector37();
|
|
4149
|
+
const _vC = new Vector37();
|
|
4150
|
+
const _tempA = new Vector37();
|
|
4151
|
+
const _tempB = new Vector37();
|
|
4152
|
+
const _tempC = new Vector37();
|
|
4153
|
+
const _morphA = new Vector37();
|
|
4154
|
+
const _morphB = new Vector37();
|
|
4155
|
+
const _morphC = new Vector37();
|
|
4094
4156
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4095
4157
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4096
4158
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4330,13 +4392,14 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4330
4392
|
createMeshes(force = false) {
|
|
4331
4393
|
if (this.meshesCreated && !force) return;
|
|
4332
4394
|
const mat = Materials.MISSING_TEXTURE;
|
|
4395
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4333
4396
|
let allGeos = [];
|
|
4334
4397
|
if (this.atlas) {
|
|
4335
4398
|
if (this.atlas.model.elements) {
|
|
4336
4399
|
this.atlas.model.elements?.forEach((el) => {
|
|
4337
4400
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4338
4401
|
if (this.options.uvLockRotation) {
|
|
4339
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4402
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler5(...this.options.uvLockRotation));
|
|
4340
4403
|
}
|
|
4341
4404
|
if (this.options.tints) {
|
|
4342
4405
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4352,12 +4415,13 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4352
4415
|
}
|
|
4353
4416
|
elGeo.setAttribute("color", new BufferAttribute4(colors, 3));
|
|
4354
4417
|
}
|
|
4355
|
-
elGeo.applyMatrix4(new
|
|
4356
|
-
elGeo.applyMatrix4(new
|
|
4418
|
+
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));
|
|
4419
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4357
4420
|
if (el.rotation) {
|
|
4358
4421
|
applyElementRotation(el.rotation, elGeo);
|
|
4359
4422
|
}
|
|
4360
|
-
elGeo.applyMatrix4(new
|
|
4423
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(-8, -8, -8));
|
|
4424
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4361
4425
|
if (this.options.mergeMeshes) {
|
|
4362
4426
|
allGeos.push(elGeo);
|
|
4363
4427
|
} else {
|
|
@@ -4379,6 +4443,7 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4379
4443
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4380
4444
|
} else {
|
|
4381
4445
|
combinedGeo = new BoxGeometry5(16, 16, 16);
|
|
4446
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4382
4447
|
}
|
|
4383
4448
|
combinedGeo.computeBoundingBox();
|
|
4384
4449
|
let mesh;
|
|
@@ -4430,7 +4495,7 @@ function isModelObject(obj) {
|
|
|
4430
4495
|
|
|
4431
4496
|
// src/model/block/scene/BlockObject.ts
|
|
4432
4497
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4433
|
-
import { Euler as
|
|
4498
|
+
import { Euler as Euler6, Matrix4 as Matrix47, Vector3 as Vector38 } from "three";
|
|
4434
4499
|
var p10 = prefix("BlockObject");
|
|
4435
4500
|
function matchesCondition(condition, state) {
|
|
4436
4501
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4492,7 +4557,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4492
4557
|
if (isModelObject(model)) {
|
|
4493
4558
|
model.removeFromScene();
|
|
4494
4559
|
} else if (isInstanceReference(model)) {
|
|
4495
|
-
model.setScale(new
|
|
4560
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4496
4561
|
}
|
|
4497
4562
|
}
|
|
4498
4563
|
super.removeFromScene();
|
|
@@ -4553,7 +4618,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4553
4618
|
}
|
|
4554
4619
|
for (let model of this._models) {
|
|
4555
4620
|
if (isInstanceReference(model)) {
|
|
4556
|
-
model.setScale(new
|
|
4621
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4557
4622
|
} else {
|
|
4558
4623
|
model.dispose();
|
|
4559
4624
|
}
|
|
@@ -4590,7 +4655,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4590
4655
|
await this.createVariant(variant);
|
|
4591
4656
|
}
|
|
4592
4657
|
async createVariant(variant) {
|
|
4593
|
-
const rotation = new
|
|
4658
|
+
const rotation = new Euler6();
|
|
4594
4659
|
if (typeof variant.x !== "undefined") {
|
|
4595
4660
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4596
4661
|
}
|
|
@@ -4677,7 +4742,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4677
4742
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4678
4743
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4679
4744
|
}
|
|
4680
|
-
getMatrixAt(index, matrix = new
|
|
4745
|
+
getMatrixAt(index, matrix = new Matrix47()) {
|
|
4681
4746
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4682
4747
|
const child = this._models[0];
|
|
4683
4748
|
if (child && isModelObject(child)) {
|
|
@@ -5672,7 +5737,8 @@ var MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5672
5737
|
console.log("instanceMeshes + key");
|
|
5673
5738
|
let key = asset.key.serialize();
|
|
5674
5739
|
if (isModelObject(obj)) {
|
|
5675
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5740
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5741
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5676
5742
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5677
5743
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5678
5744
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5719,7 +5785,7 @@ function isMineRenderScene(obj) {
|
|
|
5719
5785
|
}
|
|
5720
5786
|
|
|
5721
5787
|
// src/renderer/Renderer.ts
|
|
5722
|
-
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as
|
|
5788
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector310, WebGLRenderer } from "three";
|
|
5723
5789
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5724
5790
|
import Stats from "stats.js";
|
|
5725
5791
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5728,11 +5794,11 @@ import { EffectComposer, RenderPass } from "postprocessing";
|
|
|
5728
5794
|
import {
|
|
5729
5795
|
EventDispatcher,
|
|
5730
5796
|
MOUSE,
|
|
5731
|
-
Quaternion as
|
|
5797
|
+
Quaternion as Quaternion4,
|
|
5732
5798
|
Spherical,
|
|
5733
5799
|
TOUCH,
|
|
5734
5800
|
Vector2 as Vector23,
|
|
5735
|
-
Vector3 as
|
|
5801
|
+
Vector3 as Vector39
|
|
5736
5802
|
} from "three";
|
|
5737
5803
|
var _changeEvent = { type: "change" };
|
|
5738
5804
|
var _startEvent = { type: "start" };
|
|
@@ -5746,7 +5812,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5746
5812
|
this.domElement = domElement;
|
|
5747
5813
|
this.domElement.style.touchAction = "none";
|
|
5748
5814
|
this.enabled = true;
|
|
5749
|
-
this.target = new
|
|
5815
|
+
this.target = new Vector39();
|
|
5750
5816
|
this.minDistance = 0;
|
|
5751
5817
|
this.maxDistance = Infinity;
|
|
5752
5818
|
this.minZoom = 0;
|
|
@@ -5798,11 +5864,11 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5798
5864
|
state = STATE.NONE;
|
|
5799
5865
|
};
|
|
5800
5866
|
this.update = function() {
|
|
5801
|
-
const offset = new
|
|
5802
|
-
const quat = new
|
|
5867
|
+
const offset = new Vector39();
|
|
5868
|
+
const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector39(0, 1, 0));
|
|
5803
5869
|
const quatInverse = quat.clone().invert();
|
|
5804
|
-
const lastPosition = new
|
|
5805
|
-
const lastQuaternion = new
|
|
5870
|
+
const lastPosition = new Vector39();
|
|
5871
|
+
const lastQuaternion = new Quaternion4();
|
|
5806
5872
|
const twoPI = 2 * Math.PI;
|
|
5807
5873
|
return function update() {
|
|
5808
5874
|
const position = scope.object.position;
|
|
@@ -5891,7 +5957,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5891
5957
|
const spherical = new Spherical();
|
|
5892
5958
|
const sphericalDelta = new Spherical();
|
|
5893
5959
|
let scale = 1;
|
|
5894
|
-
const panOffset = new
|
|
5960
|
+
const panOffset = new Vector39();
|
|
5895
5961
|
let zoomChanged = false;
|
|
5896
5962
|
const rotateStart = new Vector23();
|
|
5897
5963
|
const rotateEnd = new Vector23();
|
|
@@ -5917,7 +5983,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5917
5983
|
sphericalDelta.phi -= angle;
|
|
5918
5984
|
}
|
|
5919
5985
|
const panLeft = function() {
|
|
5920
|
-
const v = new
|
|
5986
|
+
const v = new Vector39();
|
|
5921
5987
|
return function panLeft2(distance, objectMatrix) {
|
|
5922
5988
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5923
5989
|
v.multiplyScalar(-distance);
|
|
@@ -5925,7 +5991,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5925
5991
|
};
|
|
5926
5992
|
}();
|
|
5927
5993
|
const panUp = function() {
|
|
5928
|
-
const v = new
|
|
5994
|
+
const v = new Vector39();
|
|
5929
5995
|
return function panUp2(distance, objectMatrix) {
|
|
5930
5996
|
if (scope.screenSpacePanning === true) {
|
|
5931
5997
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5938,7 +6004,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5938
6004
|
};
|
|
5939
6005
|
}();
|
|
5940
6006
|
const pan = function() {
|
|
5941
|
-
const offset = new
|
|
6007
|
+
const offset = new Vector39();
|
|
5942
6008
|
return function pan2(deltaX, deltaY) {
|
|
5943
6009
|
const element = scope.domElement;
|
|
5944
6010
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6415,8 +6481,8 @@ var Renderer = class _Renderer {
|
|
|
6415
6481
|
top: void 0,
|
|
6416
6482
|
bottom: void 0
|
|
6417
6483
|
},
|
|
6418
|
-
position: new
|
|
6419
|
-
lookingAt: new
|
|
6484
|
+
position: new Vector310(50, 50, 50),
|
|
6485
|
+
lookingAt: new Vector310(0, 0, 0)
|
|
6420
6486
|
},
|
|
6421
6487
|
render: {
|
|
6422
6488
|
fpsLimit: 60,
|
|
@@ -6881,10 +6947,10 @@ var Skins = class {
|
|
|
6881
6947
|
};
|
|
6882
6948
|
|
|
6883
6949
|
// src/world/Chunk.ts
|
|
6884
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6950
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector312 } from "three";
|
|
6885
6951
|
|
|
6886
6952
|
// src/world/MineRenderWorld.ts
|
|
6887
|
-
import { Vector3 as
|
|
6953
|
+
import { Vector3 as Vector311 } from "three";
|
|
6888
6954
|
var MineRenderWorld = class {
|
|
6889
6955
|
constructor(scene) {
|
|
6890
6956
|
this._size = 4;
|
|
@@ -6895,10 +6961,10 @@ var MineRenderWorld = class {
|
|
|
6895
6961
|
}
|
|
6896
6962
|
getBlockAt(posOrX, y, z) {
|
|
6897
6963
|
if (typeof posOrX == "number") {
|
|
6898
|
-
return this.getBlockAt(new
|
|
6964
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6899
6965
|
}
|
|
6900
6966
|
if (isTripleArray(posOrX)) {
|
|
6901
|
-
return this.getBlockAt(new
|
|
6967
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6902
6968
|
}
|
|
6903
6969
|
const chunk = this.getChunkAt(posOrX);
|
|
6904
6970
|
if (typeof chunk === "undefined") {
|
|
@@ -6909,10 +6975,10 @@ var MineRenderWorld = class {
|
|
|
6909
6975
|
}
|
|
6910
6976
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6911
6977
|
if (typeof posOrX == "number") {
|
|
6912
|
-
return this.setBlockAt(new
|
|
6978
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6913
6979
|
}
|
|
6914
6980
|
if (isTripleArray(posOrX)) {
|
|
6915
|
-
return this.setBlockAt(new
|
|
6981
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6916
6982
|
}
|
|
6917
6983
|
this.validatePosBounds(posOrX);
|
|
6918
6984
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6958,14 +7024,14 @@ var MineRenderWorld = class {
|
|
|
6958
7024
|
return this._chunks[index];
|
|
6959
7025
|
}
|
|
6960
7026
|
static worldToScenePosition(pos) {
|
|
6961
|
-
return new
|
|
7027
|
+
return new Vector311(
|
|
6962
7028
|
pos.x * 16,
|
|
6963
7029
|
pos.y * 16,
|
|
6964
7030
|
pos.z * 16
|
|
6965
7031
|
);
|
|
6966
7032
|
}
|
|
6967
7033
|
static sceneToWorldPosition(pos) {
|
|
6968
|
-
return new
|
|
7034
|
+
return new Vector311(
|
|
6969
7035
|
pos.x / 16,
|
|
6970
7036
|
pos.y / 16,
|
|
6971
7037
|
pos.z / 16
|
|
@@ -7007,7 +7073,7 @@ var Chunk = class _Chunk {
|
|
|
7007
7073
|
scene.add(anchor);
|
|
7008
7074
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7009
7075
|
addBox3WireframeToObject(
|
|
7010
|
-
new Box32(new
|
|
7076
|
+
new Box32(new Vector312(0, 0, 0), new Vector312(256, 256, 256)),
|
|
7011
7077
|
anchor,
|
|
7012
7078
|
16776960,
|
|
7013
7079
|
4
|
|
@@ -7015,10 +7081,10 @@ var Chunk = class _Chunk {
|
|
|
7015
7081
|
}
|
|
7016
7082
|
getBlockAt(posOrX, y, z) {
|
|
7017
7083
|
if (typeof posOrX == "number") {
|
|
7018
|
-
return this.getBlockAt(new
|
|
7084
|
+
return this.getBlockAt(new Vector312(posOrX, y, z));
|
|
7019
7085
|
}
|
|
7020
7086
|
if (isTripleArray(posOrX)) {
|
|
7021
|
-
return this.getBlockAt(new
|
|
7087
|
+
return this.getBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]));
|
|
7022
7088
|
}
|
|
7023
7089
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7024
7090
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7026,10 +7092,10 @@ var Chunk = class _Chunk {
|
|
|
7026
7092
|
}
|
|
7027
7093
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7028
7094
|
if (typeof posOrX == "number") {
|
|
7029
|
-
return this.setBlockAt(new
|
|
7095
|
+
return this.setBlockAt(new Vector312(posOrX, yOrBlock, z), block);
|
|
7030
7096
|
}
|
|
7031
7097
|
if (isTripleArray(posOrX)) {
|
|
7032
|
-
return this.setBlockAt(new
|
|
7098
|
+
return this.setBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7033
7099
|
}
|
|
7034
7100
|
const worldPos = posOrX;
|
|
7035
7101
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7075,7 +7141,7 @@ var Chunk = class _Chunk {
|
|
|
7075
7141
|
}
|
|
7076
7142
|
async clear() {
|
|
7077
7143
|
let promises = [];
|
|
7078
|
-
let pos = new
|
|
7144
|
+
let pos = new Vector312();
|
|
7079
7145
|
for (let x = 0; x < 16; x++) {
|
|
7080
7146
|
for (let z = 0; z < 16; z++) {
|
|
7081
7147
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7094,14 +7160,14 @@ var Chunk = class _Chunk {
|
|
|
7094
7160
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7095
7161
|
}
|
|
7096
7162
|
worldPosToChunkPos(pos) {
|
|
7097
|
-
return new
|
|
7163
|
+
return new Vector312(
|
|
7098
7164
|
pos.x - this.x * 16,
|
|
7099
7165
|
pos.y - this.y * 16,
|
|
7100
7166
|
pos.z - this.z * 16
|
|
7101
7167
|
);
|
|
7102
7168
|
}
|
|
7103
7169
|
chunkPosToWorldPos(pos) {
|
|
7104
|
-
return new
|
|
7170
|
+
return new Vector312(
|
|
7105
7171
|
this.x * 16 + pos.x,
|
|
7106
7172
|
this.y * 16 + pos.y,
|
|
7107
7173
|
this.z * 16 + pos.z
|
|
@@ -7140,6 +7206,7 @@ export {
|
|
|
7140
7206
|
DISPLAY_POSITIONS,
|
|
7141
7207
|
DefaultBlockStates,
|
|
7142
7208
|
DisplayPosition,
|
|
7209
|
+
DisplayTransforms,
|
|
7143
7210
|
Entities,
|
|
7144
7211
|
EntityModels,
|
|
7145
7212
|
EntityObject,
|