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.js
CHANGED
|
@@ -157,6 +157,7 @@ __export(index_browser_exports, {
|
|
|
157
157
|
DISPLAY_POSITIONS: () => DISPLAY_POSITIONS,
|
|
158
158
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
159
159
|
DisplayPosition: () => DisplayPosition,
|
|
160
|
+
DisplayTransforms: () => DisplayTransforms,
|
|
160
161
|
Entities: () => Entities,
|
|
161
162
|
EntityModels: () => EntityModels,
|
|
162
163
|
EntityObject: () => EntityObject,
|
|
@@ -1250,7 +1251,7 @@ var Meshes = class _Meshes {
|
|
|
1250
1251
|
};
|
|
1251
1252
|
|
|
1252
1253
|
// src/UVMapper.ts
|
|
1253
|
-
var
|
|
1254
|
+
var import_three9 = require("three");
|
|
1254
1255
|
|
|
1255
1256
|
// src/model/ModelMerger.ts
|
|
1256
1257
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1341,15 +1342,77 @@ function isAssetKey(obj) {
|
|
|
1341
1342
|
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1342
1343
|
}
|
|
1343
1344
|
|
|
1345
|
+
// src/model/DisplayTransforms.ts
|
|
1346
|
+
var import_three7 = require("three");
|
|
1347
|
+
|
|
1348
|
+
// src/model/DisplayPosition.ts
|
|
1349
|
+
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
1350
|
+
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1351
|
+
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1352
|
+
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1353
|
+
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1354
|
+
DisplayPosition2["GUI"] = "gui";
|
|
1355
|
+
DisplayPosition2["HEAD"] = "head";
|
|
1356
|
+
DisplayPosition2["GROUND"] = "ground";
|
|
1357
|
+
DisplayPosition2["FIXED"] = "fixed";
|
|
1358
|
+
DisplayPosition2["ON_SHELF"] = "on_shelf";
|
|
1359
|
+
return DisplayPosition2;
|
|
1360
|
+
})(DisplayPosition || {});
|
|
1361
|
+
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1362
|
+
|
|
1363
|
+
// src/model/DisplayTransforms.ts
|
|
1364
|
+
var DisplayTransforms = class {
|
|
1365
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
1366
|
+
static withHandFallbacks(display) {
|
|
1367
|
+
if (!display) return void 0;
|
|
1368
|
+
const resolved = { ...display };
|
|
1369
|
+
for (const [left, right] of [
|
|
1370
|
+
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
1371
|
+
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
1372
|
+
]) {
|
|
1373
|
+
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
1374
|
+
}
|
|
1375
|
+
return resolved;
|
|
1376
|
+
}
|
|
1377
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1378
|
+
static getMatrix(display, position) {
|
|
1379
|
+
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1380
|
+
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1381
|
+
const sign = left ? -1 : 1;
|
|
1382
|
+
const [x, y, z] = transform.rotation ?? [0, 0, 0];
|
|
1383
|
+
const rotation = new import_three7.Quaternion().setFromEuler(new import_three7.Euler(toRadians(x), sign * toRadians(y), sign * toRadians(z), "XYZ"));
|
|
1384
|
+
const translation = new import_three7.Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1385
|
+
translation.x *= sign;
|
|
1386
|
+
const scale = new import_three7.Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1387
|
+
return new import_three7.Matrix4().compose(translation, rotation, scale);
|
|
1388
|
+
}
|
|
1389
|
+
static apply(geometry, matrix) {
|
|
1390
|
+
geometry.applyMatrix4(matrix);
|
|
1391
|
+
if (matrix.determinant() < 0) {
|
|
1392
|
+
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_, i) => i));
|
|
1393
|
+
const index = geometry.index;
|
|
1394
|
+
for (let i = 0; i < index.count; i += 3) {
|
|
1395
|
+
const second = index.getX(i + 1);
|
|
1396
|
+
index.setX(i + 1, index.getX(i + 2));
|
|
1397
|
+
index.setX(i + 2, second);
|
|
1398
|
+
}
|
|
1399
|
+
index.needsUpdate = true;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1344
1404
|
// src/model/ModelMerger.ts
|
|
1345
1405
|
var ModelMerger = class {
|
|
1346
1406
|
static async mergeWithParents(model) {
|
|
1347
1407
|
const models = await this.collectAllParents(model);
|
|
1348
1408
|
let merged = {};
|
|
1349
|
-
for (
|
|
1350
|
-
|
|
1409
|
+
for (const source of [...models, model]) {
|
|
1410
|
+
const inheritedDisplay = merged.display;
|
|
1411
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
1412
|
+
if (source.display) {
|
|
1413
|
+
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1414
|
+
}
|
|
1351
1415
|
}
|
|
1352
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
1353
1416
|
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1354
1417
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1355
1418
|
return merged;
|
|
@@ -1495,7 +1558,7 @@ var BlockStates = class {
|
|
|
1495
1558
|
void 0,
|
|
1496
1559
|
"assets",
|
|
1497
1560
|
".json",
|
|
1498
|
-
|
|
1561
|
+
AssetLoader.ROOT
|
|
1499
1562
|
);
|
|
1500
1563
|
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1501
1564
|
return AssetLoader.get(key, "list" /* LIST */);
|
|
@@ -1604,9 +1667,9 @@ var BatchedExecutor = class {
|
|
|
1604
1667
|
};
|
|
1605
1668
|
|
|
1606
1669
|
// src/util/model.ts
|
|
1607
|
-
var
|
|
1670
|
+
var import_three8 = require("three");
|
|
1608
1671
|
function applyElementRotation(rotation, geometry) {
|
|
1609
|
-
const origin = new
|
|
1672
|
+
const origin = new import_three8.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1610
1673
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1611
1674
|
switch (rotation.axis) {
|
|
1612
1675
|
case "x" /* X */:
|
|
@@ -1631,7 +1694,7 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1631
1694
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1632
1695
|
}
|
|
1633
1696
|
function applyModelPartRotation(modelPart, geometry) {
|
|
1634
|
-
const origin = new
|
|
1697
|
+
const origin = new import_three8.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1635
1698
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1636
1699
|
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1637
1700
|
geometry.rotateY(toRadians(modelPart.yaw));
|
|
@@ -1641,42 +1704,42 @@ function applyModelPartRotation(modelPart, geometry) {
|
|
|
1641
1704
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1642
1705
|
switch (axis) {
|
|
1643
1706
|
case "x" /* X */:
|
|
1644
|
-
obj.rotateOnAxis(new
|
|
1707
|
+
obj.rotateOnAxis(new import_three8.Vector3(1, 0, 0), toRadians(rotation));
|
|
1645
1708
|
break;
|
|
1646
1709
|
case "y" /* Y */:
|
|
1647
|
-
obj.rotateOnAxis(new
|
|
1710
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 1, 0), toRadians(rotation));
|
|
1648
1711
|
break;
|
|
1649
1712
|
case "z" /* Z */:
|
|
1650
|
-
obj.rotateOnAxis(new
|
|
1713
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 0, 1), toRadians(rotation));
|
|
1651
1714
|
break;
|
|
1652
1715
|
}
|
|
1653
1716
|
}
|
|
1654
1717
|
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1655
|
-
let size = new
|
|
1718
|
+
let size = new import_three8.Vector3();
|
|
1656
1719
|
box.getSize(size);
|
|
1657
|
-
let boxGeo = new
|
|
1658
|
-
let wireGeo = new
|
|
1659
|
-
let wireMat = new
|
|
1660
|
-
let wireframe = new
|
|
1720
|
+
let boxGeo = new import_three8.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1721
|
+
let wireGeo = new import_three8.EdgesGeometry(boxGeo);
|
|
1722
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1723
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1661
1724
|
obj.add(wireframe);
|
|
1662
|
-
let axes = new
|
|
1725
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1663
1726
|
obj.add(axes);
|
|
1664
1727
|
}
|
|
1665
1728
|
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1666
|
-
let boxGeo = new
|
|
1667
|
-
let wireGeo = new
|
|
1668
|
-
let wireMat = new
|
|
1669
|
-
let wireframe = new
|
|
1729
|
+
let boxGeo = new import_three8.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1730
|
+
let wireGeo = new import_three8.EdgesGeometry(boxGeo);
|
|
1731
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1732
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1670
1733
|
obj.add(wireframe);
|
|
1671
|
-
let axes = new
|
|
1734
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1672
1735
|
obj.add(axes);
|
|
1673
1736
|
}
|
|
1674
1737
|
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1675
|
-
let wireGeo = new
|
|
1676
|
-
let wireMat = new
|
|
1677
|
-
let wireframe = new
|
|
1738
|
+
let wireGeo = new import_three8.EdgesGeometry(geo);
|
|
1739
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1740
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1678
1741
|
mesh.add(wireframe);
|
|
1679
|
-
let axes = new
|
|
1742
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1680
1743
|
mesh.add(axes);
|
|
1681
1744
|
}
|
|
1682
1745
|
|
|
@@ -1736,17 +1799,17 @@ var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
|
1736
1799
|
if (typeof namespaced !== "undefined") {
|
|
1737
1800
|
return namespaced;
|
|
1738
1801
|
}
|
|
1739
|
-
if (typeof key.root !== "undefined" && key.root !==
|
|
1802
|
+
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1740
1803
|
console.info(p3, "Retrying", key, "with default root+namespace");
|
|
1741
|
-
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1804
|
+
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1742
1805
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1743
1806
|
if (typeof namespacedRooted !== "undefined") {
|
|
1744
1807
|
return namespacedRooted;
|
|
1745
1808
|
}
|
|
1746
1809
|
}
|
|
1747
|
-
} else if (typeof key.root !== "undefined" && key.root !==
|
|
1810
|
+
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1748
1811
|
console.info(p3, "Retrying", key, "with default root");
|
|
1749
|
-
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension,
|
|
1812
|
+
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1750
1813
|
const rooted = await this.load(rootKey, parser);
|
|
1751
1814
|
if (typeof rooted !== "undefined") {
|
|
1752
1815
|
return rooted;
|
|
@@ -1935,6 +1998,20 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1935
1998
|
// src/assets/AssetLoader.ts
|
|
1936
1999
|
var p4 = prefix("AssetLoader");
|
|
1937
2000
|
var _AssetLoader = class _AssetLoader {
|
|
2001
|
+
static get version() {
|
|
2002
|
+
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
2003
|
+
}
|
|
2004
|
+
static setVersion(version) {
|
|
2005
|
+
this.ROOT = `https://assets.mcasset.cloud/${version}`;
|
|
2006
|
+
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
2007
|
+
const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
|
|
2008
|
+
if (index !== -1) {
|
|
2009
|
+
this._SOURCES[index] = { key: "mcassets", source };
|
|
2010
|
+
} else {
|
|
2011
|
+
this.addSource("mcassets", source);
|
|
2012
|
+
}
|
|
2013
|
+
Caching.clear();
|
|
2014
|
+
}
|
|
1938
2015
|
static addSource(key, source, override = true) {
|
|
1939
2016
|
if (override) {
|
|
1940
2017
|
const existing = this.removeSource(key);
|
|
@@ -1997,7 +2074,7 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1997
2074
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
1998
2075
|
_AssetLoader._SOURCES = [];
|
|
1999
2076
|
_AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
|
|
2000
|
-
_AssetLoader.addSource("mcassets", new HostedAssetSource(
|
|
2077
|
+
_AssetLoader.addSource("mcassets", new HostedAssetSource(_AssetLoader.ROOT, { retryDefaults: false }));
|
|
2001
2078
|
var AssetLoader = _AssetLoader;
|
|
2002
2079
|
|
|
2003
2080
|
// src/assets/ModelTextures.ts
|
|
@@ -2220,12 +2297,12 @@ var X = 0;
|
|
|
2220
2297
|
var Y = 1;
|
|
2221
2298
|
var Z = 2;
|
|
2222
2299
|
var FACE_UV_AXES = {
|
|
2223
|
-
east: [new
|
|
2224
|
-
west: [new
|
|
2225
|
-
up: [new
|
|
2226
|
-
down: [new
|
|
2227
|
-
south: [new
|
|
2228
|
-
north: [new
|
|
2300
|
+
east: [new import_three9.Vector3(0, 0, -1), new import_three9.Vector3(0, -1, 0)],
|
|
2301
|
+
west: [new import_three9.Vector3(0, 0, 1), new import_three9.Vector3(0, -1, 0)],
|
|
2302
|
+
up: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, 1)],
|
|
2303
|
+
down: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, -1)],
|
|
2304
|
+
south: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, -1, 0)],
|
|
2305
|
+
north: [new import_three9.Vector3(-1, 0, 0), new import_three9.Vector3(0, -1, 0)]
|
|
2229
2306
|
};
|
|
2230
2307
|
var UVMapper = class {
|
|
2231
2308
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2322,7 +2399,7 @@ var UVMapper = class {
|
|
|
2322
2399
|
return array;
|
|
2323
2400
|
}
|
|
2324
2401
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2325
|
-
return new
|
|
2402
|
+
return new import_three9.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2326
2403
|
}
|
|
2327
2404
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2328
2405
|
const uv = geometry.getAttribute("uv");
|
|
@@ -2400,32 +2477,32 @@ var UVMapper = class {
|
|
|
2400
2477
|
v1 *= scaleV;
|
|
2401
2478
|
u2 *= scaleU;
|
|
2402
2479
|
v2 *= scaleV;
|
|
2403
|
-
let tl = new
|
|
2404
|
-
let tr = new
|
|
2405
|
-
let bl = new
|
|
2406
|
-
let br = new
|
|
2480
|
+
let tl = new import_three9.Vector2(u1, v1);
|
|
2481
|
+
let tr = new import_three9.Vector2(u2, v1);
|
|
2482
|
+
let bl = new import_three9.Vector2(u1, v2);
|
|
2483
|
+
let br = new import_three9.Vector2(u2, v2);
|
|
2407
2484
|
switch (rotation) {
|
|
2408
2485
|
case 0:
|
|
2409
2486
|
case 360:
|
|
2410
2487
|
default:
|
|
2411
2488
|
break;
|
|
2412
2489
|
case 90:
|
|
2413
|
-
tl = new
|
|
2414
|
-
tr = new
|
|
2415
|
-
bl = new
|
|
2416
|
-
br = new
|
|
2490
|
+
tl = new import_three9.Vector2(u1, v2);
|
|
2491
|
+
tr = new import_three9.Vector2(u1, v1);
|
|
2492
|
+
bl = new import_three9.Vector2(u2, v2);
|
|
2493
|
+
br = new import_three9.Vector2(u2, v1);
|
|
2417
2494
|
break;
|
|
2418
2495
|
case 180:
|
|
2419
|
-
tl = new
|
|
2420
|
-
tr = new
|
|
2421
|
-
bl = new
|
|
2422
|
-
br = new
|
|
2496
|
+
tl = new import_three9.Vector2(u2, v2);
|
|
2497
|
+
tr = new import_three9.Vector2(u1, v2);
|
|
2498
|
+
bl = new import_three9.Vector2(u2, v1);
|
|
2499
|
+
br = new import_three9.Vector2(u1, v1);
|
|
2423
2500
|
break;
|
|
2424
2501
|
case 270:
|
|
2425
|
-
tl = new
|
|
2426
|
-
tr = new
|
|
2427
|
-
bl = new
|
|
2428
|
-
br = new
|
|
2502
|
+
tl = new import_three9.Vector2(u2, v1);
|
|
2503
|
+
tr = new import_three9.Vector2(u2, v2);
|
|
2504
|
+
bl = new import_three9.Vector2(u1, v1);
|
|
2505
|
+
br = new import_three9.Vector2(u1, v2);
|
|
2429
2506
|
break;
|
|
2430
2507
|
}
|
|
2431
2508
|
return [tl, tr, bl, br];
|
|
@@ -2572,7 +2649,7 @@ var UVMapper = class {
|
|
|
2572
2649
|
const faceTexture = face.texture.substr(1);
|
|
2573
2650
|
const texPosition = positions[faceTexture] || [0, 0];
|
|
2574
2651
|
const texSize = sizes[faceTexture] || [16, 16];
|
|
2575
|
-
let texPosV = new
|
|
2652
|
+
let texPosV = new import_three9.Vector2(texPosition[0], texPosition[1]);
|
|
2576
2653
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
2577
2654
|
tl.add(texPosV);
|
|
2578
2655
|
tr.add(texPosV);
|
|
@@ -2806,7 +2883,7 @@ var BlockEntityModels = class {
|
|
|
2806
2883
|
};
|
|
2807
2884
|
|
|
2808
2885
|
// src/renderer/SceneObject.ts
|
|
2809
|
-
var
|
|
2886
|
+
var import_three10 = require("three");
|
|
2810
2887
|
|
|
2811
2888
|
// src/instance/InstanceReference.ts
|
|
2812
2889
|
var InstanceReference = class {
|
|
@@ -2865,7 +2942,7 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2865
2942
|
// src/renderer/SceneObject.ts
|
|
2866
2943
|
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
2867
2944
|
var p6 = prefix("SceneObject");
|
|
2868
|
-
var _SceneObject = class _SceneObject extends
|
|
2945
|
+
var _SceneObject = class _SceneObject extends import_three10.Object3D {
|
|
2869
2946
|
constructor(options) {
|
|
2870
2947
|
super();
|
|
2871
2948
|
this.isSceneObject = true;
|
|
@@ -2903,7 +2980,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2903
2980
|
return group;
|
|
2904
2981
|
}
|
|
2905
2982
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
2906
|
-
const obj = new
|
|
2983
|
+
const obj = new import_three10.Object3D();
|
|
2907
2984
|
if (name) {
|
|
2908
2985
|
obj.name = `group:${name}`;
|
|
2909
2986
|
}
|
|
@@ -2953,7 +3030,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2953
3030
|
return mesh;
|
|
2954
3031
|
}
|
|
2955
3032
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
2956
|
-
const mesh = new
|
|
3033
|
+
const mesh = new import_three10.Mesh(geometry, material);
|
|
2957
3034
|
if (name) {
|
|
2958
3035
|
mesh.name = `mesh:${name}`;
|
|
2959
3036
|
}
|
|
@@ -2965,7 +3042,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2965
3042
|
return mesh;
|
|
2966
3043
|
}
|
|
2967
3044
|
createInstancedMesh(name, geometry, material, count) {
|
|
2968
|
-
const mesh = new
|
|
3045
|
+
const mesh = new import_three10.InstancedMesh(geometry, material, count);
|
|
2969
3046
|
mesh.count = 0;
|
|
2970
3047
|
if (name) {
|
|
2971
3048
|
mesh.name = `mesh:${name}`;
|
|
@@ -3043,7 +3120,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3043
3120
|
nextInstance() {
|
|
3044
3121
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3045
3122
|
const i = this._instanceCounter++;
|
|
3046
|
-
this.setMatrixAt(i, new
|
|
3123
|
+
this.setMatrixAt(i, new import_three10.Matrix4());
|
|
3047
3124
|
const mesh = this.children[0];
|
|
3048
3125
|
if (mesh && isInstancedMesh(mesh)) {
|
|
3049
3126
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -3060,7 +3137,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3060
3137
|
}
|
|
3061
3138
|
//</editor-fold>
|
|
3062
3139
|
//<editor-fold desc="TRANSFORMATION">
|
|
3063
|
-
getMatrixAt(index, matrix = new
|
|
3140
|
+
getMatrixAt(index, matrix = new import_three10.Matrix4()) {
|
|
3064
3141
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3065
3142
|
const child = this.children[0];
|
|
3066
3143
|
if (child && isInstancedMesh(child)) {
|
|
@@ -3079,16 +3156,16 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3079
3156
|
}
|
|
3080
3157
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3081
3158
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3082
|
-
const oldPosition = new
|
|
3083
|
-
const oldRotation = new
|
|
3084
|
-
const oldScale = new
|
|
3085
|
-
const matrix = new
|
|
3159
|
+
const oldPosition = new import_three10.Vector3();
|
|
3160
|
+
const oldRotation = new import_three10.Quaternion();
|
|
3161
|
+
const oldScale = new import_three10.Vector3();
|
|
3162
|
+
const matrix = new import_three10.Matrix4();
|
|
3086
3163
|
if (!scale || !rotation || !position) {
|
|
3087
3164
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3088
3165
|
}
|
|
3089
3166
|
matrix.compose(
|
|
3090
3167
|
position ? position : oldPosition,
|
|
3091
|
-
rotation ? new
|
|
3168
|
+
rotation ? new import_three10.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3092
3169
|
scale ? scale : oldScale
|
|
3093
3170
|
);
|
|
3094
3171
|
this.setMatrixAt(index, matrix);
|
|
@@ -3097,7 +3174,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3097
3174
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3098
3175
|
this.setPositionRotationScaleAt(index, position);
|
|
3099
3176
|
}
|
|
3100
|
-
getPositionAt(index, vector = new
|
|
3177
|
+
getPositionAt(index, vector = new import_three10.Vector3()) {
|
|
3101
3178
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3102
3179
|
const matrix = this.getMatrixAt(index);
|
|
3103
3180
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3107,7 +3184,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3107
3184
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3108
3185
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3109
3186
|
}
|
|
3110
|
-
getRotationAt(index, euler = new
|
|
3187
|
+
getRotationAt(index, euler = new import_three10.Euler()) {
|
|
3111
3188
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3112
3189
|
const matrix = this.getMatrixAt(index);
|
|
3113
3190
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -3117,7 +3194,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3117
3194
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3118
3195
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3119
3196
|
}
|
|
3120
|
-
getScaleAt(index, vector = new
|
|
3197
|
+
getScaleAt(index, vector = new import_three10.Vector3()) {
|
|
3121
3198
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3122
3199
|
const matrix = this.getMatrixAt(index);
|
|
3123
3200
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3239,7 +3316,7 @@ function isSceneObject(obj) {
|
|
|
3239
3316
|
|
|
3240
3317
|
// src/entity/scene/EntityObject.ts
|
|
3241
3318
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
3242
|
-
var
|
|
3319
|
+
var import_three12 = require("three");
|
|
3243
3320
|
var THREE3 = __toESM(require("three"));
|
|
3244
3321
|
var EntityObject = class extends SceneObject {
|
|
3245
3322
|
constructor(entity, options) {
|
|
@@ -3277,7 +3354,7 @@ var EntityObject = class extends SceneObject {
|
|
|
3277
3354
|
for (let partName in this.entity.parts) {
|
|
3278
3355
|
const part = this.entity.parts[partName];
|
|
3279
3356
|
const texture = new MinecraftCubeTexture(part.textureOffsetU, part.textureOffsetV, part.textureWidth, part.textureHeight);
|
|
3280
|
-
const partAnchor = new
|
|
3357
|
+
const partAnchor = new import_three12.Object3D();
|
|
3281
3358
|
partAnchor.position.x = part.pivotX;
|
|
3282
3359
|
partAnchor.position.y = part.pivotY;
|
|
3283
3360
|
partAnchor.position.z = part.pivotZ;
|
|
@@ -3331,16 +3408,16 @@ var GuiObject = class extends SceneObject {
|
|
|
3331
3408
|
};
|
|
3332
3409
|
|
|
3333
3410
|
// src/inspector/SceneInspector.ts
|
|
3334
|
-
var
|
|
3411
|
+
var import_three13 = require("three");
|
|
3335
3412
|
var p7 = prefix("SceneInspector");
|
|
3336
3413
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3337
3414
|
var SceneInspector = class {
|
|
3338
3415
|
constructor(renderer) {
|
|
3339
3416
|
this.renderer = renderer;
|
|
3340
|
-
this.mouse = new
|
|
3417
|
+
this.mouse = new import_three13.Vector2();
|
|
3341
3418
|
this.objectInfoContainer = document.createElement("div");
|
|
3342
3419
|
this.objectControlsContainer = document.createElement("div");
|
|
3343
|
-
this.raycaster = new
|
|
3420
|
+
this.raycaster = new import_three13.Raycaster();
|
|
3344
3421
|
this.init();
|
|
3345
3422
|
}
|
|
3346
3423
|
init() {
|
|
@@ -3743,20 +3820,6 @@ function isInstanceable(obj) {
|
|
|
3743
3820
|
return "nextInstance" in obj;
|
|
3744
3821
|
}
|
|
3745
3822
|
|
|
3746
|
-
// src/model/DisplayPosition.ts
|
|
3747
|
-
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
3748
|
-
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
3749
|
-
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
3750
|
-
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
3751
|
-
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
3752
|
-
DisplayPosition2["GUI"] = "gui";
|
|
3753
|
-
DisplayPosition2["HEAD"] = "head";
|
|
3754
|
-
DisplayPosition2["GROUND"] = "ground";
|
|
3755
|
-
DisplayPosition2["FIXED"] = "fixed";
|
|
3756
|
-
return DisplayPosition2;
|
|
3757
|
-
})(DisplayPosition || {});
|
|
3758
|
-
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
3759
|
-
|
|
3760
3823
|
// src/model/GuiLight.ts
|
|
3761
3824
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3762
3825
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3865,10 +3928,10 @@ var BlockTints = class {
|
|
|
3865
3928
|
};
|
|
3866
3929
|
|
|
3867
3930
|
// src/model/scene/ModelObject.ts
|
|
3868
|
-
var
|
|
3931
|
+
var import_three16 = require("three");
|
|
3869
3932
|
|
|
3870
3933
|
// src/three/BufferGeometryUtils.js
|
|
3871
|
-
var
|
|
3934
|
+
var import_three15 = require("three");
|
|
3872
3935
|
function computeTangents(geometry) {
|
|
3873
3936
|
geometry.computeTangents();
|
|
3874
3937
|
console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
|
|
@@ -3880,7 +3943,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3880
3943
|
const attributes = {};
|
|
3881
3944
|
const morphAttributes = {};
|
|
3882
3945
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3883
|
-
const mergedGeometry = new
|
|
3946
|
+
const mergedGeometry = new import_three15.BufferGeometry();
|
|
3884
3947
|
let offset = 0;
|
|
3885
3948
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3886
3949
|
const geometry = geometries[i];
|
|
@@ -4004,7 +4067,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4004
4067
|
array.set(attributes[i].array, offset);
|
|
4005
4068
|
offset += attributes[i].array.length;
|
|
4006
4069
|
}
|
|
4007
|
-
return new
|
|
4070
|
+
return new import_three15.BufferAttribute(array, itemSize, normalized);
|
|
4008
4071
|
}
|
|
4009
4072
|
function interleaveAttributes(attributes) {
|
|
4010
4073
|
let TypedArray;
|
|
@@ -4020,7 +4083,7 @@ function interleaveAttributes(attributes) {
|
|
|
4020
4083
|
arrayLength += attribute.array.length;
|
|
4021
4084
|
stride += attribute.itemSize;
|
|
4022
4085
|
}
|
|
4023
|
-
const interleavedBuffer = new
|
|
4086
|
+
const interleavedBuffer = new import_three15.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4024
4087
|
let offset = 0;
|
|
4025
4088
|
const res = [];
|
|
4026
4089
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4029,7 +4092,7 @@ function interleaveAttributes(attributes) {
|
|
|
4029
4092
|
const attribute = attributes[j];
|
|
4030
4093
|
const itemSize = attribute.itemSize;
|
|
4031
4094
|
const count = attribute.count;
|
|
4032
|
-
const iba = new
|
|
4095
|
+
const iba = new import_three15.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4033
4096
|
res.push(iba);
|
|
4034
4097
|
offset += itemSize;
|
|
4035
4098
|
for (let c = 0; c < count; c++) {
|
|
@@ -4113,13 +4176,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4113
4176
|
const name = attributeNames[i];
|
|
4114
4177
|
const oldAttribute = geometry.getAttribute(name);
|
|
4115
4178
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4116
|
-
const attribute = new
|
|
4179
|
+
const attribute = new import_three15.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4117
4180
|
result.setAttribute(name, attribute);
|
|
4118
4181
|
if (name in morphAttrsArrays) {
|
|
4119
4182
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4120
4183
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4121
4184
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4122
|
-
const morphAttribute = new
|
|
4185
|
+
const morphAttribute = new import_three15.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4123
4186
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4124
4187
|
}
|
|
4125
4188
|
}
|
|
@@ -4128,11 +4191,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4128
4191
|
return result;
|
|
4129
4192
|
}
|
|
4130
4193
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4131
|
-
if (drawMode ===
|
|
4194
|
+
if (drawMode === import_three15.TrianglesDrawMode) {
|
|
4132
4195
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4133
4196
|
return geometry;
|
|
4134
4197
|
}
|
|
4135
|
-
if (drawMode ===
|
|
4198
|
+
if (drawMode === import_three15.TriangleFanDrawMode || drawMode === import_three15.TriangleStripDrawMode) {
|
|
4136
4199
|
let index = geometry.getIndex();
|
|
4137
4200
|
if (index === null) {
|
|
4138
4201
|
const indices = [];
|
|
@@ -4150,7 +4213,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4150
4213
|
}
|
|
4151
4214
|
const numberOfTriangles = index.count - 2;
|
|
4152
4215
|
const newIndices = [];
|
|
4153
|
-
if (drawMode ===
|
|
4216
|
+
if (drawMode === import_three15.TriangleFanDrawMode) {
|
|
4154
4217
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4155
4218
|
newIndices.push(index.getX(0));
|
|
4156
4219
|
newIndices.push(index.getX(i));
|
|
@@ -4186,15 +4249,15 @@ function computeMorphedAttributes(object) {
|
|
|
4186
4249
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4187
4250
|
return null;
|
|
4188
4251
|
}
|
|
4189
|
-
const _vA = new
|
|
4190
|
-
const _vB = new
|
|
4191
|
-
const _vC = new
|
|
4192
|
-
const _tempA = new
|
|
4193
|
-
const _tempB = new
|
|
4194
|
-
const _tempC = new
|
|
4195
|
-
const _morphA = new
|
|
4196
|
-
const _morphB = new
|
|
4197
|
-
const _morphC = new
|
|
4252
|
+
const _vA = new import_three15.Vector3();
|
|
4253
|
+
const _vB = new import_three15.Vector3();
|
|
4254
|
+
const _vC = new import_three15.Vector3();
|
|
4255
|
+
const _tempA = new import_three15.Vector3();
|
|
4256
|
+
const _tempB = new import_three15.Vector3();
|
|
4257
|
+
const _tempC = new import_three15.Vector3();
|
|
4258
|
+
const _morphA = new import_three15.Vector3();
|
|
4259
|
+
const _morphB = new import_three15.Vector3();
|
|
4260
|
+
const _morphC = new import_three15.Vector3();
|
|
4198
4261
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4199
4262
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4200
4263
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4389,8 +4452,8 @@ function computeMorphedAttributes(object) {
|
|
|
4389
4452
|
}
|
|
4390
4453
|
}
|
|
4391
4454
|
}
|
|
4392
|
-
const morphedPositionAttribute = new
|
|
4393
|
-
const morphedNormalAttribute = new
|
|
4455
|
+
const morphedPositionAttribute = new import_three15.Float32BufferAttribute(modifiedPosition, 3);
|
|
4456
|
+
const morphedNormalAttribute = new import_three15.Float32BufferAttribute(modifiedNormal, 3);
|
|
4394
4457
|
return {
|
|
4395
4458
|
positionAttribute,
|
|
4396
4459
|
normalAttribute,
|
|
@@ -4431,13 +4494,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4431
4494
|
createMeshes(force = false) {
|
|
4432
4495
|
if (this.meshesCreated && !force) return;
|
|
4433
4496
|
const mat = Materials.MISSING_TEXTURE;
|
|
4497
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4434
4498
|
let allGeos = [];
|
|
4435
4499
|
if (this.atlas) {
|
|
4436
4500
|
if (this.atlas.model.elements) {
|
|
4437
4501
|
this.atlas.model.elements?.forEach((el) => {
|
|
4438
4502
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4439
4503
|
if (this.options.uvLockRotation) {
|
|
4440
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4504
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three16.Euler(...this.options.uvLockRotation));
|
|
4441
4505
|
}
|
|
4442
4506
|
if (this.options.tints) {
|
|
4443
4507
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4446,19 +4510,20 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4446
4510
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4447
4511
|
const tint = this.options.tints[tintIndex];
|
|
4448
4512
|
if (tint === void 0) continue;
|
|
4449
|
-
const color = new
|
|
4513
|
+
const color = new import_three16.Color(tint);
|
|
4450
4514
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4451
4515
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4452
4516
|
}
|
|
4453
4517
|
}
|
|
4454
|
-
elGeo.setAttribute("color", new
|
|
4518
|
+
elGeo.setAttribute("color", new import_three16.BufferAttribute(colors, 3));
|
|
4455
4519
|
}
|
|
4456
|
-
elGeo.applyMatrix4(new
|
|
4457
|
-
elGeo.applyMatrix4(new
|
|
4520
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4521
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4458
4522
|
if (el.rotation) {
|
|
4459
4523
|
applyElementRotation(el.rotation, elGeo);
|
|
4460
4524
|
}
|
|
4461
|
-
elGeo.applyMatrix4(new
|
|
4525
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(-8, -8, -8));
|
|
4526
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4462
4527
|
if (this.options.mergeMeshes) {
|
|
4463
4528
|
allGeos.push(elGeo);
|
|
4464
4529
|
} else {
|
|
@@ -4479,7 +4544,8 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4479
4544
|
if (allGeos.length > 0) {
|
|
4480
4545
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4481
4546
|
} else {
|
|
4482
|
-
combinedGeo = new
|
|
4547
|
+
combinedGeo = new import_three16.BoxGeometry(16, 16, 16);
|
|
4548
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4483
4549
|
}
|
|
4484
4550
|
combinedGeo.computeBoundingBox();
|
|
4485
4551
|
let mesh;
|
|
@@ -4533,7 +4599,7 @@ function isModelObject(obj) {
|
|
|
4533
4599
|
|
|
4534
4600
|
// src/model/block/scene/BlockObject.ts
|
|
4535
4601
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4536
|
-
var
|
|
4602
|
+
var import_three17 = require("three");
|
|
4537
4603
|
var p10 = prefix("BlockObject");
|
|
4538
4604
|
function matchesCondition(condition, state) {
|
|
4539
4605
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4590,7 +4656,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4590
4656
|
if (isModelObject(model)) {
|
|
4591
4657
|
model.removeFromScene();
|
|
4592
4658
|
} else if (isInstanceReference(model)) {
|
|
4593
|
-
model.setScale(new
|
|
4659
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4594
4660
|
}
|
|
4595
4661
|
}
|
|
4596
4662
|
super.removeFromScene();
|
|
@@ -4651,7 +4717,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4651
4717
|
}
|
|
4652
4718
|
for (let model of this._models) {
|
|
4653
4719
|
if (isInstanceReference(model)) {
|
|
4654
|
-
model.setScale(new
|
|
4720
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4655
4721
|
} else {
|
|
4656
4722
|
model.dispose();
|
|
4657
4723
|
}
|
|
@@ -4688,7 +4754,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4688
4754
|
await this.createVariant(variant);
|
|
4689
4755
|
}
|
|
4690
4756
|
async createVariant(variant) {
|
|
4691
|
-
const rotation = new
|
|
4757
|
+
const rotation = new import_three17.Euler();
|
|
4692
4758
|
if (typeof variant.x !== "undefined") {
|
|
4693
4759
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4694
4760
|
}
|
|
@@ -4775,7 +4841,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4775
4841
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4776
4842
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4777
4843
|
}
|
|
4778
|
-
getMatrixAt(index, matrix = new
|
|
4844
|
+
getMatrixAt(index, matrix = new import_three17.Matrix4()) {
|
|
4779
4845
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4780
4846
|
const child = this._models[0];
|
|
4781
4847
|
if (child && isModelObject(child)) {
|
|
@@ -4854,7 +4920,7 @@ var StructureParser = class {
|
|
|
4854
4920
|
};
|
|
4855
4921
|
|
|
4856
4922
|
// src/renderer/MineRenderScene.ts
|
|
4857
|
-
var
|
|
4923
|
+
var import_three18 = require("three");
|
|
4858
4924
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4859
4925
|
|
|
4860
4926
|
// src/skin/SkinPart.ts
|
|
@@ -5698,7 +5764,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5698
5764
|
};
|
|
5699
5765
|
|
|
5700
5766
|
// src/renderer/MineRenderScene.ts
|
|
5701
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
5767
|
+
var _MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
5702
5768
|
constructor(options) {
|
|
5703
5769
|
super();
|
|
5704
5770
|
this.isMineRenderScene = true;
|
|
@@ -5771,7 +5837,8 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5771
5837
|
console.log("instanceMeshes + key");
|
|
5772
5838
|
let key = asset.key.serialize();
|
|
5773
5839
|
if (isModelObject(obj)) {
|
|
5774
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5840
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5841
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5775
5842
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5776
5843
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5777
5844
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5820,17 +5887,17 @@ function isMineRenderScene(obj) {
|
|
|
5820
5887
|
}
|
|
5821
5888
|
|
|
5822
5889
|
// src/renderer/Renderer.ts
|
|
5823
|
-
var
|
|
5890
|
+
var import_three20 = require("three");
|
|
5824
5891
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5825
5892
|
var import_stats = __toESM(require("stats.js"));
|
|
5826
5893
|
var import_postprocessing = require("postprocessing");
|
|
5827
5894
|
|
|
5828
5895
|
// src/three/OrbitControls.js
|
|
5829
|
-
var
|
|
5896
|
+
var import_three19 = require("three");
|
|
5830
5897
|
var _changeEvent = { type: "change" };
|
|
5831
5898
|
var _startEvent = { type: "start" };
|
|
5832
5899
|
var _endEvent = { type: "end" };
|
|
5833
|
-
var OrbitControls = class extends
|
|
5900
|
+
var OrbitControls = class extends import_three19.EventDispatcher {
|
|
5834
5901
|
constructor(object, domElement) {
|
|
5835
5902
|
super();
|
|
5836
5903
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5839,7 +5906,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5839
5906
|
this.domElement = domElement;
|
|
5840
5907
|
this.domElement.style.touchAction = "none";
|
|
5841
5908
|
this.enabled = true;
|
|
5842
|
-
this.target = new
|
|
5909
|
+
this.target = new import_three19.Vector3();
|
|
5843
5910
|
this.minDistance = 0;
|
|
5844
5911
|
this.maxDistance = Infinity;
|
|
5845
5912
|
this.minZoom = 0;
|
|
@@ -5861,8 +5928,8 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5861
5928
|
this.autoRotate = false;
|
|
5862
5929
|
this.autoRotateSpeed = 2;
|
|
5863
5930
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5864
|
-
this.mouseButtons = { LEFT:
|
|
5865
|
-
this.touches = { ONE:
|
|
5931
|
+
this.mouseButtons = { LEFT: import_three19.MOUSE.ROTATE, MIDDLE: import_three19.MOUSE.DOLLY, RIGHT: import_three19.MOUSE.PAN };
|
|
5932
|
+
this.touches = { ONE: import_three19.TOUCH.ROTATE, TWO: import_three19.TOUCH.DOLLY_PAN };
|
|
5866
5933
|
this.target0 = this.target.clone();
|
|
5867
5934
|
this.position0 = this.object.position.clone();
|
|
5868
5935
|
this.zoom0 = this.object.zoom;
|
|
@@ -5891,11 +5958,11 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5891
5958
|
state = STATE.NONE;
|
|
5892
5959
|
};
|
|
5893
5960
|
this.update = function() {
|
|
5894
|
-
const offset = new
|
|
5895
|
-
const quat = new
|
|
5961
|
+
const offset = new import_three19.Vector3();
|
|
5962
|
+
const quat = new import_three19.Quaternion().setFromUnitVectors(object.up, new import_three19.Vector3(0, 1, 0));
|
|
5896
5963
|
const quatInverse = quat.clone().invert();
|
|
5897
|
-
const lastPosition = new
|
|
5898
|
-
const lastQuaternion = new
|
|
5964
|
+
const lastPosition = new import_three19.Vector3();
|
|
5965
|
+
const lastQuaternion = new import_three19.Quaternion();
|
|
5899
5966
|
const twoPI = 2 * Math.PI;
|
|
5900
5967
|
return function update() {
|
|
5901
5968
|
const position = scope.object.position;
|
|
@@ -5981,20 +6048,20 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5981
6048
|
};
|
|
5982
6049
|
let state = STATE.NONE;
|
|
5983
6050
|
const EPS = 1e-6;
|
|
5984
|
-
const spherical = new
|
|
5985
|
-
const sphericalDelta = new
|
|
6051
|
+
const spherical = new import_three19.Spherical();
|
|
6052
|
+
const sphericalDelta = new import_three19.Spherical();
|
|
5986
6053
|
let scale = 1;
|
|
5987
|
-
const panOffset = new
|
|
6054
|
+
const panOffset = new import_three19.Vector3();
|
|
5988
6055
|
let zoomChanged = false;
|
|
5989
|
-
const rotateStart = new
|
|
5990
|
-
const rotateEnd = new
|
|
5991
|
-
const rotateDelta = new
|
|
5992
|
-
const panStart = new
|
|
5993
|
-
const panEnd = new
|
|
5994
|
-
const panDelta = new
|
|
5995
|
-
const dollyStart = new
|
|
5996
|
-
const dollyEnd = new
|
|
5997
|
-
const dollyDelta = new
|
|
6056
|
+
const rotateStart = new import_three19.Vector2();
|
|
6057
|
+
const rotateEnd = new import_three19.Vector2();
|
|
6058
|
+
const rotateDelta = new import_three19.Vector2();
|
|
6059
|
+
const panStart = new import_three19.Vector2();
|
|
6060
|
+
const panEnd = new import_three19.Vector2();
|
|
6061
|
+
const panDelta = new import_three19.Vector2();
|
|
6062
|
+
const dollyStart = new import_three19.Vector2();
|
|
6063
|
+
const dollyEnd = new import_three19.Vector2();
|
|
6064
|
+
const dollyDelta = new import_three19.Vector2();
|
|
5998
6065
|
const pointers = [];
|
|
5999
6066
|
const pointerPositions = {};
|
|
6000
6067
|
function getAutoRotationAngle() {
|
|
@@ -6010,7 +6077,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6010
6077
|
sphericalDelta.phi -= angle;
|
|
6011
6078
|
}
|
|
6012
6079
|
const panLeft = function() {
|
|
6013
|
-
const v = new
|
|
6080
|
+
const v = new import_three19.Vector3();
|
|
6014
6081
|
return function panLeft2(distance, objectMatrix) {
|
|
6015
6082
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6016
6083
|
v.multiplyScalar(-distance);
|
|
@@ -6018,7 +6085,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6018
6085
|
};
|
|
6019
6086
|
}();
|
|
6020
6087
|
const panUp = function() {
|
|
6021
|
-
const v = new
|
|
6088
|
+
const v = new import_three19.Vector3();
|
|
6022
6089
|
return function panUp2(distance, objectMatrix) {
|
|
6023
6090
|
if (scope.screenSpacePanning === true) {
|
|
6024
6091
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6031,7 +6098,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6031
6098
|
};
|
|
6032
6099
|
}();
|
|
6033
6100
|
const pan = function() {
|
|
6034
|
-
const offset = new
|
|
6101
|
+
const offset = new import_three19.Vector3();
|
|
6035
6102
|
return function pan2(deltaX, deltaY) {
|
|
6036
6103
|
const element = scope.domElement;
|
|
6037
6104
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6280,12 +6347,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6280
6347
|
mouseAction = -1;
|
|
6281
6348
|
}
|
|
6282
6349
|
switch (mouseAction) {
|
|
6283
|
-
case
|
|
6350
|
+
case import_three19.MOUSE.DOLLY:
|
|
6284
6351
|
if (scope.enableZoom === false) return;
|
|
6285
6352
|
handleMouseDownDolly(event);
|
|
6286
6353
|
state = STATE.DOLLY;
|
|
6287
6354
|
break;
|
|
6288
|
-
case
|
|
6355
|
+
case import_three19.MOUSE.ROTATE:
|
|
6289
6356
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6290
6357
|
if (scope.enablePan === false) return;
|
|
6291
6358
|
handleMouseDownPan(event);
|
|
@@ -6296,7 +6363,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6296
6363
|
state = STATE.ROTATE;
|
|
6297
6364
|
}
|
|
6298
6365
|
break;
|
|
6299
|
-
case
|
|
6366
|
+
case import_three19.MOUSE.PAN:
|
|
6300
6367
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6301
6368
|
if (scope.enableRotate === false) return;
|
|
6302
6369
|
handleMouseDownRotate(event);
|
|
@@ -6352,12 +6419,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6352
6419
|
switch (pointers.length) {
|
|
6353
6420
|
case 1:
|
|
6354
6421
|
switch (scope.touches.ONE) {
|
|
6355
|
-
case
|
|
6422
|
+
case import_three19.TOUCH.ROTATE:
|
|
6356
6423
|
if (scope.enableRotate === false) return;
|
|
6357
6424
|
handleTouchStartRotate();
|
|
6358
6425
|
state = STATE.TOUCH_ROTATE;
|
|
6359
6426
|
break;
|
|
6360
|
-
case
|
|
6427
|
+
case import_three19.TOUCH.PAN:
|
|
6361
6428
|
if (scope.enablePan === false) return;
|
|
6362
6429
|
handleTouchStartPan();
|
|
6363
6430
|
state = STATE.TOUCH_PAN;
|
|
@@ -6368,12 +6435,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6368
6435
|
break;
|
|
6369
6436
|
case 2:
|
|
6370
6437
|
switch (scope.touches.TWO) {
|
|
6371
|
-
case
|
|
6438
|
+
case import_three19.TOUCH.DOLLY_PAN:
|
|
6372
6439
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6373
6440
|
handleTouchStartDollyPan();
|
|
6374
6441
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6375
6442
|
break;
|
|
6376
|
-
case
|
|
6443
|
+
case import_three19.TOUCH.DOLLY_ROTATE:
|
|
6377
6444
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6378
6445
|
handleTouchStartDollyRotate();
|
|
6379
6446
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6440,7 +6507,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6440
6507
|
function trackPointer(event) {
|
|
6441
6508
|
let position = pointerPositions[event.pointerId];
|
|
6442
6509
|
if (position === void 0) {
|
|
6443
|
-
position = new
|
|
6510
|
+
position = new import_three19.Vector2();
|
|
6444
6511
|
pointerPositions[event.pointerId] = position;
|
|
6445
6512
|
}
|
|
6446
6513
|
position.set(event.pageX, event.pageY);
|
|
@@ -6460,10 +6527,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6460
6527
|
constructor(object, domElement) {
|
|
6461
6528
|
super(object, domElement);
|
|
6462
6529
|
this.screenSpacePanning = false;
|
|
6463
|
-
this.mouseButtons.LEFT =
|
|
6464
|
-
this.mouseButtons.RIGHT =
|
|
6465
|
-
this.touches.ONE =
|
|
6466
|
-
this.touches.TWO =
|
|
6530
|
+
this.mouseButtons.LEFT = import_three19.MOUSE.PAN;
|
|
6531
|
+
this.mouseButtons.RIGHT = import_three19.MOUSE.ROTATE;
|
|
6532
|
+
this.touches.ONE = import_three19.TOUCH.PAN;
|
|
6533
|
+
this.touches.TWO = import_three19.TOUCH.DOLLY_ROTATE;
|
|
6467
6534
|
}
|
|
6468
6535
|
};
|
|
6469
6536
|
|
|
@@ -6500,14 +6567,14 @@ var _Renderer = class _Renderer {
|
|
|
6500
6567
|
switch (this.options.camera.type) {
|
|
6501
6568
|
case "perspective":
|
|
6502
6569
|
default:
|
|
6503
|
-
return new
|
|
6570
|
+
return new import_three20.PerspectiveCamera(
|
|
6504
6571
|
this.options.camera.perspective.fov,
|
|
6505
6572
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6506
6573
|
this.options.camera.near,
|
|
6507
6574
|
this.options.camera.far
|
|
6508
6575
|
);
|
|
6509
6576
|
case "orthographic":
|
|
6510
|
-
return new
|
|
6577
|
+
return new import_three20.OrthographicCamera(
|
|
6511
6578
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6512
6579
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6513
6580
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6518,7 +6585,7 @@ var _Renderer = class _Renderer {
|
|
|
6518
6585
|
}
|
|
6519
6586
|
}
|
|
6520
6587
|
createRenderer() {
|
|
6521
|
-
const renderer = new
|
|
6588
|
+
const renderer = new import_three20.WebGLRenderer({
|
|
6522
6589
|
antialias: this.options.render.antialias,
|
|
6523
6590
|
alpha: true,
|
|
6524
6591
|
powerPreference: "high-performance",
|
|
@@ -6526,8 +6593,8 @@ var _Renderer = class _Renderer {
|
|
|
6526
6593
|
});
|
|
6527
6594
|
renderer.setClearColor(0, 0);
|
|
6528
6595
|
renderer.shadowMap.enabled = true;
|
|
6529
|
-
renderer.shadowMap.type =
|
|
6530
|
-
renderer.outputColorSpace =
|
|
6596
|
+
renderer.shadowMap.type = import_three20.PCFSoftShadowMap;
|
|
6597
|
+
renderer.outputColorSpace = import_three20.SRGBColorSpace;
|
|
6531
6598
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6532
6599
|
return renderer;
|
|
6533
6600
|
}
|
|
@@ -6561,20 +6628,20 @@ var _Renderer = class _Renderer {
|
|
|
6561
6628
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6562
6629
|
}
|
|
6563
6630
|
if (this.options.debug.grid) {
|
|
6564
|
-
const gridHelper = new
|
|
6631
|
+
const gridHelper = new import_three20.GridHelper(128, 16);
|
|
6565
6632
|
this._debugHelpers.push(gridHelper);
|
|
6566
6633
|
this.scene.add(gridHelper);
|
|
6567
|
-
const gridHelper2 = new
|
|
6634
|
+
const gridHelper2 = new import_three20.GridHelper(128, 16);
|
|
6568
6635
|
this._debugHelpers.push(gridHelper2);
|
|
6569
6636
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6570
6637
|
this.scene.add(gridHelper2);
|
|
6571
|
-
const gridHelper3 = new
|
|
6638
|
+
const gridHelper3 = new import_three20.GridHelper(128, 16);
|
|
6572
6639
|
this._debugHelpers.push(gridHelper3);
|
|
6573
6640
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6574
6641
|
this.scene.add(gridHelper3);
|
|
6575
6642
|
}
|
|
6576
6643
|
if (this.options.debug.axes) {
|
|
6577
|
-
const axesHelper = new
|
|
6644
|
+
const axesHelper = new import_three20.AxesHelper(64);
|
|
6578
6645
|
this._debugHelpers.push(axesHelper);
|
|
6579
6646
|
this.scene.add(axesHelper);
|
|
6580
6647
|
}
|
|
@@ -6778,8 +6845,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6778
6845
|
top: void 0,
|
|
6779
6846
|
bottom: void 0
|
|
6780
6847
|
},
|
|
6781
|
-
position: new
|
|
6782
|
-
lookingAt: new
|
|
6848
|
+
position: new import_three20.Vector3(50, 50, 50),
|
|
6849
|
+
lookingAt: new import_three20.Vector3(0, 0, 0)
|
|
6783
6850
|
},
|
|
6784
6851
|
render: {
|
|
6785
6852
|
fpsLimit: 60,
|
|
@@ -6973,10 +7040,10 @@ var Skins = class {
|
|
|
6973
7040
|
};
|
|
6974
7041
|
|
|
6975
7042
|
// src/world/Chunk.ts
|
|
6976
|
-
var
|
|
7043
|
+
var import_three23 = require("three");
|
|
6977
7044
|
|
|
6978
7045
|
// src/world/MineRenderWorld.ts
|
|
6979
|
-
var
|
|
7046
|
+
var import_three22 = require("three");
|
|
6980
7047
|
var MineRenderWorld = class {
|
|
6981
7048
|
constructor(scene) {
|
|
6982
7049
|
this._size = 4;
|
|
@@ -6987,10 +7054,10 @@ var MineRenderWorld = class {
|
|
|
6987
7054
|
}
|
|
6988
7055
|
getBlockAt(posOrX, y, z) {
|
|
6989
7056
|
if (typeof posOrX == "number") {
|
|
6990
|
-
return this.getBlockAt(new
|
|
7057
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX, y, z));
|
|
6991
7058
|
}
|
|
6992
7059
|
if (isTripleArray(posOrX)) {
|
|
6993
|
-
return this.getBlockAt(new
|
|
7060
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
6994
7061
|
}
|
|
6995
7062
|
const chunk = this.getChunkAt(posOrX);
|
|
6996
7063
|
if (typeof chunk === "undefined") {
|
|
@@ -7001,10 +7068,10 @@ var MineRenderWorld = class {
|
|
|
7001
7068
|
}
|
|
7002
7069
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7003
7070
|
if (typeof posOrX == "number") {
|
|
7004
|
-
return this.setBlockAt(new
|
|
7071
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX, yOrBlock, z), block);
|
|
7005
7072
|
}
|
|
7006
7073
|
if (isTripleArray(posOrX)) {
|
|
7007
|
-
return this.setBlockAt(new
|
|
7074
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7008
7075
|
}
|
|
7009
7076
|
this.validatePosBounds(posOrX);
|
|
7010
7077
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7050,14 +7117,14 @@ var MineRenderWorld = class {
|
|
|
7050
7117
|
return this._chunks[index];
|
|
7051
7118
|
}
|
|
7052
7119
|
static worldToScenePosition(pos) {
|
|
7053
|
-
return new
|
|
7120
|
+
return new import_three22.Vector3(
|
|
7054
7121
|
pos.x * 16,
|
|
7055
7122
|
pos.y * 16,
|
|
7056
7123
|
pos.z * 16
|
|
7057
7124
|
);
|
|
7058
7125
|
}
|
|
7059
7126
|
static sceneToWorldPosition(pos) {
|
|
7060
|
-
return new
|
|
7127
|
+
return new import_three22.Vector3(
|
|
7061
7128
|
pos.x / 16,
|
|
7062
7129
|
pos.y / 16,
|
|
7063
7130
|
pos.z / 16
|
|
@@ -7094,12 +7161,12 @@ var Chunk = class _Chunk {
|
|
|
7094
7161
|
this.x = x;
|
|
7095
7162
|
this.y = y;
|
|
7096
7163
|
this.z = z;
|
|
7097
|
-
let anchor = new
|
|
7164
|
+
let anchor = new import_three23.Object3D();
|
|
7098
7165
|
this._anchor = anchor;
|
|
7099
7166
|
scene.add(anchor);
|
|
7100
7167
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7101
7168
|
addBox3WireframeToObject(
|
|
7102
|
-
new
|
|
7169
|
+
new import_three23.Box3(new import_three23.Vector3(0, 0, 0), new import_three23.Vector3(256, 256, 256)),
|
|
7103
7170
|
anchor,
|
|
7104
7171
|
16776960,
|
|
7105
7172
|
4
|
|
@@ -7107,10 +7174,10 @@ var Chunk = class _Chunk {
|
|
|
7107
7174
|
}
|
|
7108
7175
|
getBlockAt(posOrX, y, z) {
|
|
7109
7176
|
if (typeof posOrX == "number") {
|
|
7110
|
-
return this.getBlockAt(new
|
|
7177
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7111
7178
|
}
|
|
7112
7179
|
if (isTripleArray(posOrX)) {
|
|
7113
|
-
return this.getBlockAt(new
|
|
7180
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7114
7181
|
}
|
|
7115
7182
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7116
7183
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7118,10 +7185,10 @@ var Chunk = class _Chunk {
|
|
|
7118
7185
|
}
|
|
7119
7186
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7120
7187
|
if (typeof posOrX == "number") {
|
|
7121
|
-
return this.setBlockAt(new
|
|
7188
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7122
7189
|
}
|
|
7123
7190
|
if (isTripleArray(posOrX)) {
|
|
7124
|
-
return this.setBlockAt(new
|
|
7191
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7125
7192
|
}
|
|
7126
7193
|
const worldPos = posOrX;
|
|
7127
7194
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7167,7 +7234,7 @@ var Chunk = class _Chunk {
|
|
|
7167
7234
|
}
|
|
7168
7235
|
async clear() {
|
|
7169
7236
|
let promises = [];
|
|
7170
|
-
let pos = new
|
|
7237
|
+
let pos = new import_three23.Vector3();
|
|
7171
7238
|
for (let x = 0; x < 16; x++) {
|
|
7172
7239
|
for (let z = 0; z < 16; z++) {
|
|
7173
7240
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7186,14 +7253,14 @@ var Chunk = class _Chunk {
|
|
|
7186
7253
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7187
7254
|
}
|
|
7188
7255
|
worldPosToChunkPos(pos) {
|
|
7189
|
-
return new
|
|
7256
|
+
return new import_three23.Vector3(
|
|
7190
7257
|
pos.x - this.x * 16,
|
|
7191
7258
|
pos.y - this.y * 16,
|
|
7192
7259
|
pos.z - this.z * 16
|
|
7193
7260
|
);
|
|
7194
7261
|
}
|
|
7195
7262
|
chunkPosToWorldPos(pos) {
|
|
7196
|
-
return new
|
|
7263
|
+
return new import_three23.Vector3(
|
|
7197
7264
|
this.x * 16 + pos.x,
|
|
7198
7265
|
this.y * 16 + pos.y,
|
|
7199
7266
|
this.z * 16 + pos.z
|