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/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;
|
|
@@ -1338,7 +1400,7 @@ var BlockStates = class {
|
|
|
1338
1400
|
void 0,
|
|
1339
1401
|
"assets",
|
|
1340
1402
|
".json",
|
|
1341
|
-
|
|
1403
|
+
AssetLoader.ROOT
|
|
1342
1404
|
);
|
|
1343
1405
|
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1344
1406
|
return AssetLoader.get(key, "list" /* LIST */);
|
|
@@ -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);
|
|
@@ -1579,17 +1641,17 @@ var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
|
1579
1641
|
if (typeof namespaced !== "undefined") {
|
|
1580
1642
|
return namespaced;
|
|
1581
1643
|
}
|
|
1582
|
-
if (typeof key.root !== "undefined" && key.root !==
|
|
1644
|
+
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1583
1645
|
console.info(p3, "Retrying", key, "with default root+namespace");
|
|
1584
|
-
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1646
|
+
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1585
1647
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1586
1648
|
if (typeof namespacedRooted !== "undefined") {
|
|
1587
1649
|
return namespacedRooted;
|
|
1588
1650
|
}
|
|
1589
1651
|
}
|
|
1590
|
-
} else if (typeof key.root !== "undefined" && key.root !==
|
|
1652
|
+
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1591
1653
|
console.info(p3, "Retrying", key, "with default root");
|
|
1592
|
-
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1654
|
+
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1593
1655
|
const rooted = await this.load(rootKey, parser);
|
|
1594
1656
|
if (typeof rooted !== "undefined") {
|
|
1595
1657
|
return rooted;
|
|
@@ -1778,6 +1840,20 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1778
1840
|
// src/assets/AssetLoader.ts
|
|
1779
1841
|
var p4 = prefix("AssetLoader");
|
|
1780
1842
|
var _AssetLoader = class _AssetLoader {
|
|
1843
|
+
static get version() {
|
|
1844
|
+
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
1845
|
+
}
|
|
1846
|
+
static setVersion(version) {
|
|
1847
|
+
this.ROOT = `https://assets.mcasset.cloud/${version}`;
|
|
1848
|
+
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
1849
|
+
const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
|
|
1850
|
+
if (index !== -1) {
|
|
1851
|
+
this._SOURCES[index] = { key: "mcassets", source };
|
|
1852
|
+
} else {
|
|
1853
|
+
this.addSource("mcassets", source);
|
|
1854
|
+
}
|
|
1855
|
+
Caching.clear();
|
|
1856
|
+
}
|
|
1781
1857
|
static addSource(key, source, override = true) {
|
|
1782
1858
|
if (override) {
|
|
1783
1859
|
const existing = this.removeSource(key);
|
|
@@ -1840,7 +1916,7 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1840
1916
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
1841
1917
|
_AssetLoader._SOURCES = [];
|
|
1842
1918
|
_AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
|
|
1843
|
-
_AssetLoader.addSource("mcassets", new HostedAssetSource(
|
|
1919
|
+
_AssetLoader.addSource("mcassets", new HostedAssetSource(_AssetLoader.ROOT, { retryDefaults: false }));
|
|
1844
1920
|
var AssetLoader = _AssetLoader;
|
|
1845
1921
|
|
|
1846
1922
|
// src/assets/ModelTextures.ts
|
|
@@ -2063,12 +2139,12 @@ var X = 0;
|
|
|
2063
2139
|
var Y = 1;
|
|
2064
2140
|
var Z = 2;
|
|
2065
2141
|
var FACE_UV_AXES = {
|
|
2066
|
-
east: [new
|
|
2067
|
-
west: [new
|
|
2068
|
-
up: [new
|
|
2069
|
-
down: [new
|
|
2070
|
-
south: [new
|
|
2071
|
-
north: [new
|
|
2142
|
+
east: [new Vector34(0, 0, -1), new Vector34(0, -1, 0)],
|
|
2143
|
+
west: [new Vector34(0, 0, 1), new Vector34(0, -1, 0)],
|
|
2144
|
+
up: [new Vector34(1, 0, 0), new Vector34(0, 0, 1)],
|
|
2145
|
+
down: [new Vector34(1, 0, 0), new Vector34(0, 0, -1)],
|
|
2146
|
+
south: [new Vector34(1, 0, 0), new Vector34(0, -1, 0)],
|
|
2147
|
+
north: [new Vector34(-1, 0, 0), new Vector34(0, -1, 0)]
|
|
2072
2148
|
};
|
|
2073
2149
|
var UVMapper = class {
|
|
2074
2150
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2649,7 +2725,7 @@ var BlockEntityModels = class {
|
|
|
2649
2725
|
};
|
|
2650
2726
|
|
|
2651
2727
|
// src/renderer/SceneObject.ts
|
|
2652
|
-
import { Euler as
|
|
2728
|
+
import { Euler as Euler3, InstancedMesh, MathUtils, Matrix4 as Matrix43, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion3, Vector3 as Vector35 } from "three";
|
|
2653
2729
|
|
|
2654
2730
|
// src/instance/InstanceReference.ts
|
|
2655
2731
|
var InstanceReference = class {
|
|
@@ -2886,7 +2962,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2886
2962
|
nextInstance() {
|
|
2887
2963
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2888
2964
|
const i = this._instanceCounter++;
|
|
2889
|
-
this.setMatrixAt(i, new
|
|
2965
|
+
this.setMatrixAt(i, new Matrix43());
|
|
2890
2966
|
const mesh = this.children[0];
|
|
2891
2967
|
if (mesh && isInstancedMesh(mesh)) {
|
|
2892
2968
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -2903,7 +2979,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2903
2979
|
}
|
|
2904
2980
|
//</editor-fold>
|
|
2905
2981
|
//<editor-fold desc="TRANSFORMATION">
|
|
2906
|
-
getMatrixAt(index, matrix = new
|
|
2982
|
+
getMatrixAt(index, matrix = new Matrix43()) {
|
|
2907
2983
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2908
2984
|
const child = this.children[0];
|
|
2909
2985
|
if (child && isInstancedMesh(child)) {
|
|
@@ -2922,16 +2998,16 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2922
2998
|
}
|
|
2923
2999
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2924
3000
|
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
|
|
3001
|
+
const oldPosition = new Vector35();
|
|
3002
|
+
const oldRotation = new Quaternion3();
|
|
3003
|
+
const oldScale = new Vector35();
|
|
3004
|
+
const matrix = new Matrix43();
|
|
2929
3005
|
if (!scale || !rotation || !position) {
|
|
2930
3006
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
2931
3007
|
}
|
|
2932
3008
|
matrix.compose(
|
|
2933
3009
|
position ? position : oldPosition,
|
|
2934
|
-
rotation ? new
|
|
3010
|
+
rotation ? new Quaternion3().setFromEuler(rotation) : oldRotation,
|
|
2935
3011
|
scale ? scale : oldScale
|
|
2936
3012
|
);
|
|
2937
3013
|
this.setMatrixAt(index, matrix);
|
|
@@ -2940,7 +3016,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2940
3016
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2941
3017
|
this.setPositionRotationScaleAt(index, position);
|
|
2942
3018
|
}
|
|
2943
|
-
getPositionAt(index, vector = new
|
|
3019
|
+
getPositionAt(index, vector = new Vector35()) {
|
|
2944
3020
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2945
3021
|
const matrix = this.getMatrixAt(index);
|
|
2946
3022
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2950,7 +3026,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2950
3026
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2951
3027
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
2952
3028
|
}
|
|
2953
|
-
getRotationAt(index, euler = new
|
|
3029
|
+
getRotationAt(index, euler = new Euler3()) {
|
|
2954
3030
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2955
3031
|
const matrix = this.getMatrixAt(index);
|
|
2956
3032
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -2960,7 +3036,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2960
3036
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2961
3037
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
2962
3038
|
}
|
|
2963
|
-
getScaleAt(index, vector = new
|
|
3039
|
+
getScaleAt(index, vector = new Vector35()) {
|
|
2964
3040
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2965
3041
|
const matrix = this.getMatrixAt(index);
|
|
2966
3042
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3586,20 +3662,6 @@ function isInstanceable(obj) {
|
|
|
3586
3662
|
return "nextInstance" in obj;
|
|
3587
3663
|
}
|
|
3588
3664
|
|
|
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
3665
|
// src/model/GuiLight.ts
|
|
3604
3666
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3605
3667
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3708,7 +3770,7 @@ var BlockTints = class {
|
|
|
3708
3770
|
};
|
|
3709
3771
|
|
|
3710
3772
|
// src/model/scene/ModelObject.ts
|
|
3711
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as
|
|
3773
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler5, Matrix4 as Matrix46 } from "three";
|
|
3712
3774
|
|
|
3713
3775
|
// src/three/BufferGeometryUtils.js
|
|
3714
3776
|
import {
|
|
@@ -3720,7 +3782,7 @@ import {
|
|
|
3720
3782
|
TriangleFanDrawMode,
|
|
3721
3783
|
TriangleStripDrawMode,
|
|
3722
3784
|
TrianglesDrawMode,
|
|
3723
|
-
Vector3 as
|
|
3785
|
+
Vector3 as Vector37
|
|
3724
3786
|
} from "three";
|
|
3725
3787
|
function computeTangents(geometry) {
|
|
3726
3788
|
geometry.computeTangents();
|
|
@@ -4039,15 +4101,15 @@ function computeMorphedAttributes(object) {
|
|
|
4039
4101
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4040
4102
|
return null;
|
|
4041
4103
|
}
|
|
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
|
|
4104
|
+
const _vA = new Vector37();
|
|
4105
|
+
const _vB = new Vector37();
|
|
4106
|
+
const _vC = new Vector37();
|
|
4107
|
+
const _tempA = new Vector37();
|
|
4108
|
+
const _tempB = new Vector37();
|
|
4109
|
+
const _tempC = new Vector37();
|
|
4110
|
+
const _morphA = new Vector37();
|
|
4111
|
+
const _morphB = new Vector37();
|
|
4112
|
+
const _morphC = new Vector37();
|
|
4051
4113
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4052
4114
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4053
4115
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4284,13 +4346,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4284
4346
|
createMeshes(force = false) {
|
|
4285
4347
|
if (this.meshesCreated && !force) return;
|
|
4286
4348
|
const mat = Materials.MISSING_TEXTURE;
|
|
4349
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4287
4350
|
let allGeos = [];
|
|
4288
4351
|
if (this.atlas) {
|
|
4289
4352
|
if (this.atlas.model.elements) {
|
|
4290
4353
|
this.atlas.model.elements?.forEach((el) => {
|
|
4291
4354
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4292
4355
|
if (this.options.uvLockRotation) {
|
|
4293
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4356
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler5(...this.options.uvLockRotation));
|
|
4294
4357
|
}
|
|
4295
4358
|
if (this.options.tints) {
|
|
4296
4359
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4306,12 +4369,13 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4306
4369
|
}
|
|
4307
4370
|
elGeo.setAttribute("color", new BufferAttribute4(colors, 3));
|
|
4308
4371
|
}
|
|
4309
|
-
elGeo.applyMatrix4(new
|
|
4310
|
-
elGeo.applyMatrix4(new
|
|
4372
|
+
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));
|
|
4373
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4311
4374
|
if (el.rotation) {
|
|
4312
4375
|
applyElementRotation(el.rotation, elGeo);
|
|
4313
4376
|
}
|
|
4314
|
-
elGeo.applyMatrix4(new
|
|
4377
|
+
elGeo.applyMatrix4(new Matrix46().makeTranslation(-8, -8, -8));
|
|
4378
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4315
4379
|
if (this.options.mergeMeshes) {
|
|
4316
4380
|
allGeos.push(elGeo);
|
|
4317
4381
|
} else {
|
|
@@ -4333,6 +4397,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4333
4397
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4334
4398
|
} else {
|
|
4335
4399
|
combinedGeo = new BoxGeometry5(16, 16, 16);
|
|
4400
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4336
4401
|
}
|
|
4337
4402
|
combinedGeo.computeBoundingBox();
|
|
4338
4403
|
let mesh;
|
|
@@ -4386,7 +4451,7 @@ function isModelObject(obj) {
|
|
|
4386
4451
|
|
|
4387
4452
|
// src/model/block/scene/BlockObject.ts
|
|
4388
4453
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4389
|
-
import { Euler as
|
|
4454
|
+
import { Euler as Euler6, Matrix4 as Matrix47, Vector3 as Vector38 } from "three";
|
|
4390
4455
|
var p10 = prefix("BlockObject");
|
|
4391
4456
|
function matchesCondition(condition, state) {
|
|
4392
4457
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4443,7 +4508,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4443
4508
|
if (isModelObject(model)) {
|
|
4444
4509
|
model.removeFromScene();
|
|
4445
4510
|
} else if (isInstanceReference(model)) {
|
|
4446
|
-
model.setScale(new
|
|
4511
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4447
4512
|
}
|
|
4448
4513
|
}
|
|
4449
4514
|
super.removeFromScene();
|
|
@@ -4504,7 +4569,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4504
4569
|
}
|
|
4505
4570
|
for (let model of this._models) {
|
|
4506
4571
|
if (isInstanceReference(model)) {
|
|
4507
|
-
model.setScale(new
|
|
4572
|
+
model.setScale(new Vector38(0, 0, 0));
|
|
4508
4573
|
} else {
|
|
4509
4574
|
model.dispose();
|
|
4510
4575
|
}
|
|
@@ -4541,7 +4606,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4541
4606
|
await this.createVariant(variant);
|
|
4542
4607
|
}
|
|
4543
4608
|
async createVariant(variant) {
|
|
4544
|
-
const rotation = new
|
|
4609
|
+
const rotation = new Euler6();
|
|
4545
4610
|
if (typeof variant.x !== "undefined") {
|
|
4546
4611
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4547
4612
|
}
|
|
@@ -4628,7 +4693,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4628
4693
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4629
4694
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4630
4695
|
}
|
|
4631
|
-
getMatrixAt(index, matrix = new
|
|
4696
|
+
getMatrixAt(index, matrix = new Matrix47()) {
|
|
4632
4697
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4633
4698
|
const child = this._models[0];
|
|
4634
4699
|
if (child && isModelObject(child)) {
|
|
@@ -5624,7 +5689,8 @@ var _MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5624
5689
|
console.log("instanceMeshes + key");
|
|
5625
5690
|
let key = asset.key.serialize();
|
|
5626
5691
|
if (isModelObject(obj)) {
|
|
5627
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5692
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5693
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5628
5694
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5629
5695
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5630
5696
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5673,7 +5739,7 @@ function isMineRenderScene(obj) {
|
|
|
5673
5739
|
}
|
|
5674
5740
|
|
|
5675
5741
|
// src/renderer/Renderer.ts
|
|
5676
|
-
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as
|
|
5742
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector310, WebGLRenderer } from "three";
|
|
5677
5743
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5678
5744
|
import Stats from "stats.js";
|
|
5679
5745
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5682,11 +5748,11 @@ import { EffectComposer, RenderPass } from "postprocessing";
|
|
|
5682
5748
|
import {
|
|
5683
5749
|
EventDispatcher,
|
|
5684
5750
|
MOUSE,
|
|
5685
|
-
Quaternion as
|
|
5751
|
+
Quaternion as Quaternion4,
|
|
5686
5752
|
Spherical,
|
|
5687
5753
|
TOUCH,
|
|
5688
5754
|
Vector2 as Vector23,
|
|
5689
|
-
Vector3 as
|
|
5755
|
+
Vector3 as Vector39
|
|
5690
5756
|
} from "three";
|
|
5691
5757
|
var _changeEvent = { type: "change" };
|
|
5692
5758
|
var _startEvent = { type: "start" };
|
|
@@ -5700,7 +5766,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5700
5766
|
this.domElement = domElement;
|
|
5701
5767
|
this.domElement.style.touchAction = "none";
|
|
5702
5768
|
this.enabled = true;
|
|
5703
|
-
this.target = new
|
|
5769
|
+
this.target = new Vector39();
|
|
5704
5770
|
this.minDistance = 0;
|
|
5705
5771
|
this.maxDistance = Infinity;
|
|
5706
5772
|
this.minZoom = 0;
|
|
@@ -5752,11 +5818,11 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5752
5818
|
state = STATE.NONE;
|
|
5753
5819
|
};
|
|
5754
5820
|
this.update = function() {
|
|
5755
|
-
const offset = new
|
|
5756
|
-
const quat = new
|
|
5821
|
+
const offset = new Vector39();
|
|
5822
|
+
const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector39(0, 1, 0));
|
|
5757
5823
|
const quatInverse = quat.clone().invert();
|
|
5758
|
-
const lastPosition = new
|
|
5759
|
-
const lastQuaternion = new
|
|
5824
|
+
const lastPosition = new Vector39();
|
|
5825
|
+
const lastQuaternion = new Quaternion4();
|
|
5760
5826
|
const twoPI = 2 * Math.PI;
|
|
5761
5827
|
return function update() {
|
|
5762
5828
|
const position = scope.object.position;
|
|
@@ -5845,7 +5911,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5845
5911
|
const spherical = new Spherical();
|
|
5846
5912
|
const sphericalDelta = new Spherical();
|
|
5847
5913
|
let scale = 1;
|
|
5848
|
-
const panOffset = new
|
|
5914
|
+
const panOffset = new Vector39();
|
|
5849
5915
|
let zoomChanged = false;
|
|
5850
5916
|
const rotateStart = new Vector23();
|
|
5851
5917
|
const rotateEnd = new Vector23();
|
|
@@ -5871,7 +5937,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5871
5937
|
sphericalDelta.phi -= angle;
|
|
5872
5938
|
}
|
|
5873
5939
|
const panLeft = function() {
|
|
5874
|
-
const v = new
|
|
5940
|
+
const v = new Vector39();
|
|
5875
5941
|
return function panLeft2(distance, objectMatrix) {
|
|
5876
5942
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5877
5943
|
v.multiplyScalar(-distance);
|
|
@@ -5879,7 +5945,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5879
5945
|
};
|
|
5880
5946
|
}();
|
|
5881
5947
|
const panUp = function() {
|
|
5882
|
-
const v = new
|
|
5948
|
+
const v = new Vector39();
|
|
5883
5949
|
return function panUp2(distance, objectMatrix) {
|
|
5884
5950
|
if (scope.screenSpacePanning === true) {
|
|
5885
5951
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5892,7 +5958,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5892
5958
|
};
|
|
5893
5959
|
}();
|
|
5894
5960
|
const pan = function() {
|
|
5895
|
-
const offset = new
|
|
5961
|
+
const offset = new Vector39();
|
|
5896
5962
|
return function pan2(deltaX, deltaY) {
|
|
5897
5963
|
const element = scope.domElement;
|
|
5898
5964
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6639,8 +6705,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6639
6705
|
top: void 0,
|
|
6640
6706
|
bottom: void 0
|
|
6641
6707
|
},
|
|
6642
|
-
position: new
|
|
6643
|
-
lookingAt: new
|
|
6708
|
+
position: new Vector310(50, 50, 50),
|
|
6709
|
+
lookingAt: new Vector310(0, 0, 0)
|
|
6644
6710
|
},
|
|
6645
6711
|
render: {
|
|
6646
6712
|
fpsLimit: 60,
|
|
@@ -6834,10 +6900,10 @@ var Skins = class {
|
|
|
6834
6900
|
};
|
|
6835
6901
|
|
|
6836
6902
|
// src/world/Chunk.ts
|
|
6837
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6903
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector312 } from "three";
|
|
6838
6904
|
|
|
6839
6905
|
// src/world/MineRenderWorld.ts
|
|
6840
|
-
import { Vector3 as
|
|
6906
|
+
import { Vector3 as Vector311 } from "three";
|
|
6841
6907
|
var MineRenderWorld = class {
|
|
6842
6908
|
constructor(scene) {
|
|
6843
6909
|
this._size = 4;
|
|
@@ -6848,10 +6914,10 @@ var MineRenderWorld = class {
|
|
|
6848
6914
|
}
|
|
6849
6915
|
getBlockAt(posOrX, y, z) {
|
|
6850
6916
|
if (typeof posOrX == "number") {
|
|
6851
|
-
return this.getBlockAt(new
|
|
6917
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6852
6918
|
}
|
|
6853
6919
|
if (isTripleArray(posOrX)) {
|
|
6854
|
-
return this.getBlockAt(new
|
|
6920
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6855
6921
|
}
|
|
6856
6922
|
const chunk = this.getChunkAt(posOrX);
|
|
6857
6923
|
if (typeof chunk === "undefined") {
|
|
@@ -6862,10 +6928,10 @@ var MineRenderWorld = class {
|
|
|
6862
6928
|
}
|
|
6863
6929
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6864
6930
|
if (typeof posOrX == "number") {
|
|
6865
|
-
return this.setBlockAt(new
|
|
6931
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6866
6932
|
}
|
|
6867
6933
|
if (isTripleArray(posOrX)) {
|
|
6868
|
-
return this.setBlockAt(new
|
|
6934
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6869
6935
|
}
|
|
6870
6936
|
this.validatePosBounds(posOrX);
|
|
6871
6937
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6911,14 +6977,14 @@ var MineRenderWorld = class {
|
|
|
6911
6977
|
return this._chunks[index];
|
|
6912
6978
|
}
|
|
6913
6979
|
static worldToScenePosition(pos) {
|
|
6914
|
-
return new
|
|
6980
|
+
return new Vector311(
|
|
6915
6981
|
pos.x * 16,
|
|
6916
6982
|
pos.y * 16,
|
|
6917
6983
|
pos.z * 16
|
|
6918
6984
|
);
|
|
6919
6985
|
}
|
|
6920
6986
|
static sceneToWorldPosition(pos) {
|
|
6921
|
-
return new
|
|
6987
|
+
return new Vector311(
|
|
6922
6988
|
pos.x / 16,
|
|
6923
6989
|
pos.y / 16,
|
|
6924
6990
|
pos.z / 16
|
|
@@ -6960,7 +7026,7 @@ var Chunk = class _Chunk {
|
|
|
6960
7026
|
scene.add(anchor);
|
|
6961
7027
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
6962
7028
|
addBox3WireframeToObject(
|
|
6963
|
-
new Box32(new
|
|
7029
|
+
new Box32(new Vector312(0, 0, 0), new Vector312(256, 256, 256)),
|
|
6964
7030
|
anchor,
|
|
6965
7031
|
16776960,
|
|
6966
7032
|
4
|
|
@@ -6968,10 +7034,10 @@ var Chunk = class _Chunk {
|
|
|
6968
7034
|
}
|
|
6969
7035
|
getBlockAt(posOrX, y, z) {
|
|
6970
7036
|
if (typeof posOrX == "number") {
|
|
6971
|
-
return this.getBlockAt(new
|
|
7037
|
+
return this.getBlockAt(new Vector312(posOrX, y, z));
|
|
6972
7038
|
}
|
|
6973
7039
|
if (isTripleArray(posOrX)) {
|
|
6974
|
-
return this.getBlockAt(new
|
|
7040
|
+
return this.getBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]));
|
|
6975
7041
|
}
|
|
6976
7042
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
6977
7043
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -6979,10 +7045,10 @@ var Chunk = class _Chunk {
|
|
|
6979
7045
|
}
|
|
6980
7046
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6981
7047
|
if (typeof posOrX == "number") {
|
|
6982
|
-
return this.setBlockAt(new
|
|
7048
|
+
return this.setBlockAt(new Vector312(posOrX, yOrBlock, z), block);
|
|
6983
7049
|
}
|
|
6984
7050
|
if (isTripleArray(posOrX)) {
|
|
6985
|
-
return this.setBlockAt(new
|
|
7051
|
+
return this.setBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6986
7052
|
}
|
|
6987
7053
|
const worldPos = posOrX;
|
|
6988
7054
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7028,7 +7094,7 @@ var Chunk = class _Chunk {
|
|
|
7028
7094
|
}
|
|
7029
7095
|
async clear() {
|
|
7030
7096
|
let promises = [];
|
|
7031
|
-
let pos = new
|
|
7097
|
+
let pos = new Vector312();
|
|
7032
7098
|
for (let x = 0; x < 16; x++) {
|
|
7033
7099
|
for (let z = 0; z < 16; z++) {
|
|
7034
7100
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7047,14 +7113,14 @@ var Chunk = class _Chunk {
|
|
|
7047
7113
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7048
7114
|
}
|
|
7049
7115
|
worldPosToChunkPos(pos) {
|
|
7050
|
-
return new
|
|
7116
|
+
return new Vector312(
|
|
7051
7117
|
pos.x - this.x * 16,
|
|
7052
7118
|
pos.y - this.y * 16,
|
|
7053
7119
|
pos.z - this.z * 16
|
|
7054
7120
|
);
|
|
7055
7121
|
}
|
|
7056
7122
|
chunkPosToWorldPos(pos) {
|
|
7057
|
-
return new
|
|
7123
|
+
return new Vector312(
|
|
7058
7124
|
this.x * 16 + pos.x,
|
|
7059
7125
|
this.y * 16 + pos.y,
|
|
7060
7126
|
this.z * 16 + pos.z
|
|
@@ -7095,6 +7161,7 @@ export {
|
|
|
7095
7161
|
DISPLAY_POSITIONS,
|
|
7096
7162
|
DefaultBlockStates,
|
|
7097
7163
|
DisplayPosition,
|
|
7164
|
+
DisplayTransforms,
|
|
7098
7165
|
Entities,
|
|
7099
7166
|
EntityModels,
|
|
7100
7167
|
EntityObject,
|