minerender 2.1.0-alpha.20 → 2.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.mts +21 -4
- package/dist/browser/index.d.ts +21 -4
- package/dist/browser/index.js +327 -185
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +235 -93
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +186 -37
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +21 -4
- package/dist/node/index.d.ts +21 -4
- package/dist/node/index.js +331 -185
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +237 -93
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -140,6 +140,7 @@ __export(index_node_exports, {
|
|
|
140
140
|
BlockEntityModels: () => BlockEntityModels,
|
|
141
141
|
BlockObject: () => BlockObject,
|
|
142
142
|
BlockStates: () => BlockStates,
|
|
143
|
+
BlockTints: () => BlockTints,
|
|
143
144
|
BrowserArchiveProxy: () => BrowserArchiveProxy,
|
|
144
145
|
CUBE_FACES: () => CUBE_FACES,
|
|
145
146
|
Caching: () => Caching,
|
|
@@ -154,6 +155,7 @@ __export(index_node_exports, {
|
|
|
154
155
|
DISPLAY_POSITIONS: () => DISPLAY_POSITIONS,
|
|
155
156
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
156
157
|
DisplayPosition: () => DisplayPosition,
|
|
158
|
+
DisplayTransforms: () => DisplayTransforms,
|
|
157
159
|
Entities: () => Entities,
|
|
158
160
|
EntityModels: () => EntityModels,
|
|
159
161
|
EntityObject: () => EntityObject,
|
|
@@ -556,6 +558,9 @@ var Caching = class _Caching {
|
|
|
556
558
|
static {
|
|
557
559
|
this.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
558
560
|
}
|
|
561
|
+
static {
|
|
562
|
+
this.blockTintCache = _Caching.createAssetCache();
|
|
563
|
+
}
|
|
559
564
|
static {
|
|
560
565
|
this.entityModelsCache = _Caching.createAssetCache();
|
|
561
566
|
}
|
|
@@ -581,6 +586,7 @@ var Caching = class _Caching {
|
|
|
581
586
|
this.blockStateCache,
|
|
582
587
|
this.listAssetCache,
|
|
583
588
|
this.defaultBlockStatesCache,
|
|
589
|
+
this.blockTintCache,
|
|
584
590
|
this.entityModelsCache
|
|
585
591
|
];
|
|
586
592
|
}
|
|
@@ -1249,7 +1255,7 @@ var Meshes = class _Meshes {
|
|
|
1249
1255
|
};
|
|
1250
1256
|
|
|
1251
1257
|
// src/UVMapper.ts
|
|
1252
|
-
var
|
|
1258
|
+
var import_three9 = require("three");
|
|
1253
1259
|
|
|
1254
1260
|
// src/model/ModelMerger.ts
|
|
1255
1261
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1340,15 +1346,77 @@ function isAssetKey(obj) {
|
|
|
1340
1346
|
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1341
1347
|
}
|
|
1342
1348
|
|
|
1349
|
+
// src/model/DisplayTransforms.ts
|
|
1350
|
+
var import_three7 = require("three");
|
|
1351
|
+
|
|
1352
|
+
// src/model/DisplayPosition.ts
|
|
1353
|
+
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
1354
|
+
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1355
|
+
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1356
|
+
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1357
|
+
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1358
|
+
DisplayPosition2["GUI"] = "gui";
|
|
1359
|
+
DisplayPosition2["HEAD"] = "head";
|
|
1360
|
+
DisplayPosition2["GROUND"] = "ground";
|
|
1361
|
+
DisplayPosition2["FIXED"] = "fixed";
|
|
1362
|
+
DisplayPosition2["ON_SHELF"] = "on_shelf";
|
|
1363
|
+
return DisplayPosition2;
|
|
1364
|
+
})(DisplayPosition || {});
|
|
1365
|
+
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1366
|
+
|
|
1367
|
+
// src/model/DisplayTransforms.ts
|
|
1368
|
+
var DisplayTransforms = class {
|
|
1369
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
1370
|
+
static withHandFallbacks(display) {
|
|
1371
|
+
if (!display) return void 0;
|
|
1372
|
+
const resolved = { ...display };
|
|
1373
|
+
for (const [left, right] of [
|
|
1374
|
+
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
1375
|
+
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
1376
|
+
]) {
|
|
1377
|
+
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
1378
|
+
}
|
|
1379
|
+
return resolved;
|
|
1380
|
+
}
|
|
1381
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1382
|
+
static getMatrix(display, position) {
|
|
1383
|
+
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1384
|
+
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1385
|
+
const sign = left ? -1 : 1;
|
|
1386
|
+
const [x, y, z] = transform.rotation ?? [0, 0, 0];
|
|
1387
|
+
const rotation = new import_three7.Quaternion().setFromEuler(new import_three7.Euler(toRadians(x), sign * toRadians(y), sign * toRadians(z), "XYZ"));
|
|
1388
|
+
const translation = new import_three7.Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1389
|
+
translation.x *= sign;
|
|
1390
|
+
const scale = new import_three7.Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1391
|
+
return new import_three7.Matrix4().compose(translation, rotation, scale);
|
|
1392
|
+
}
|
|
1393
|
+
static apply(geometry, matrix) {
|
|
1394
|
+
geometry.applyMatrix4(matrix);
|
|
1395
|
+
if (matrix.determinant() < 0) {
|
|
1396
|
+
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_, i) => i));
|
|
1397
|
+
const index = geometry.index;
|
|
1398
|
+
for (let i = 0; i < index.count; i += 3) {
|
|
1399
|
+
const second = index.getX(i + 1);
|
|
1400
|
+
index.setX(i + 1, index.getX(i + 2));
|
|
1401
|
+
index.setX(i + 2, second);
|
|
1402
|
+
}
|
|
1403
|
+
index.needsUpdate = true;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1343
1408
|
// src/model/ModelMerger.ts
|
|
1344
1409
|
var ModelMerger = class {
|
|
1345
1410
|
static async mergeWithParents(model) {
|
|
1346
1411
|
const models = await this.collectAllParents(model);
|
|
1347
1412
|
let merged = {};
|
|
1348
|
-
for (
|
|
1349
|
-
|
|
1413
|
+
for (const source of [...models, model]) {
|
|
1414
|
+
const inheritedDisplay = merged.display;
|
|
1415
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
1416
|
+
if (source.display) {
|
|
1417
|
+
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1418
|
+
}
|
|
1350
1419
|
}
|
|
1351
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
1352
1420
|
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1353
1421
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1354
1422
|
return merged;
|
|
@@ -1603,9 +1671,9 @@ var BatchedExecutor = class {
|
|
|
1603
1671
|
};
|
|
1604
1672
|
|
|
1605
1673
|
// src/util/model.ts
|
|
1606
|
-
var
|
|
1674
|
+
var import_three8 = require("three");
|
|
1607
1675
|
function applyElementRotation(rotation, geometry) {
|
|
1608
|
-
const origin = new
|
|
1676
|
+
const origin = new import_three8.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1609
1677
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1610
1678
|
switch (rotation.axis) {
|
|
1611
1679
|
case "x" /* X */:
|
|
@@ -1630,7 +1698,7 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1630
1698
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1631
1699
|
}
|
|
1632
1700
|
function applyModelPartRotation(modelPart, geometry) {
|
|
1633
|
-
const origin = new
|
|
1701
|
+
const origin = new import_three8.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1634
1702
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1635
1703
|
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1636
1704
|
geometry.rotateY(toRadians(modelPart.yaw));
|
|
@@ -1640,42 +1708,42 @@ function applyModelPartRotation(modelPart, geometry) {
|
|
|
1640
1708
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1641
1709
|
switch (axis) {
|
|
1642
1710
|
case "x" /* X */:
|
|
1643
|
-
obj.rotateOnAxis(new
|
|
1711
|
+
obj.rotateOnAxis(new import_three8.Vector3(1, 0, 0), toRadians(rotation));
|
|
1644
1712
|
break;
|
|
1645
1713
|
case "y" /* Y */:
|
|
1646
|
-
obj.rotateOnAxis(new
|
|
1714
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 1, 0), toRadians(rotation));
|
|
1647
1715
|
break;
|
|
1648
1716
|
case "z" /* Z */:
|
|
1649
|
-
obj.rotateOnAxis(new
|
|
1717
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 0, 1), toRadians(rotation));
|
|
1650
1718
|
break;
|
|
1651
1719
|
}
|
|
1652
1720
|
}
|
|
1653
1721
|
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1654
|
-
let size = new
|
|
1722
|
+
let size = new import_three8.Vector3();
|
|
1655
1723
|
box.getSize(size);
|
|
1656
|
-
let boxGeo = new
|
|
1657
|
-
let wireGeo = new
|
|
1658
|
-
let wireMat = new
|
|
1659
|
-
let wireframe = new
|
|
1724
|
+
let boxGeo = new import_three8.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1725
|
+
let wireGeo = new import_three8.EdgesGeometry(boxGeo);
|
|
1726
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1727
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1660
1728
|
obj.add(wireframe);
|
|
1661
|
-
let axes = new
|
|
1729
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1662
1730
|
obj.add(axes);
|
|
1663
1731
|
}
|
|
1664
1732
|
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1665
|
-
let boxGeo = new
|
|
1666
|
-
let wireGeo = new
|
|
1667
|
-
let wireMat = new
|
|
1668
|
-
let wireframe = new
|
|
1733
|
+
let boxGeo = new import_three8.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1734
|
+
let wireGeo = new import_three8.EdgesGeometry(boxGeo);
|
|
1735
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1736
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1669
1737
|
obj.add(wireframe);
|
|
1670
|
-
let axes = new
|
|
1738
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1671
1739
|
obj.add(axes);
|
|
1672
1740
|
}
|
|
1673
1741
|
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1674
|
-
let wireGeo = new
|
|
1675
|
-
let wireMat = new
|
|
1676
|
-
let wireframe = new
|
|
1742
|
+
let wireGeo = new import_three8.EdgesGeometry(geo);
|
|
1743
|
+
let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
|
|
1744
|
+
let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
|
|
1677
1745
|
mesh.add(wireframe);
|
|
1678
|
-
let axes = new
|
|
1746
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1679
1747
|
mesh.add(axes);
|
|
1680
1748
|
}
|
|
1681
1749
|
|
|
@@ -2254,12 +2322,12 @@ var X = 0;
|
|
|
2254
2322
|
var Y = 1;
|
|
2255
2323
|
var Z = 2;
|
|
2256
2324
|
var FACE_UV_AXES = {
|
|
2257
|
-
east: [new
|
|
2258
|
-
west: [new
|
|
2259
|
-
up: [new
|
|
2260
|
-
down: [new
|
|
2261
|
-
south: [new
|
|
2262
|
-
north: [new
|
|
2325
|
+
east: [new import_three9.Vector3(0, 0, -1), new import_three9.Vector3(0, -1, 0)],
|
|
2326
|
+
west: [new import_three9.Vector3(0, 0, 1), new import_three9.Vector3(0, -1, 0)],
|
|
2327
|
+
up: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, 1)],
|
|
2328
|
+
down: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, -1)],
|
|
2329
|
+
south: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, -1, 0)],
|
|
2330
|
+
north: [new import_three9.Vector3(-1, 0, 0), new import_three9.Vector3(0, -1, 0)]
|
|
2263
2331
|
};
|
|
2264
2332
|
var UVMapper = class {
|
|
2265
2333
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2356,7 +2424,7 @@ var UVMapper = class {
|
|
|
2356
2424
|
return array;
|
|
2357
2425
|
}
|
|
2358
2426
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2359
|
-
return new
|
|
2427
|
+
return new import_three9.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2360
2428
|
}
|
|
2361
2429
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2362
2430
|
const uv = geometry.getAttribute("uv");
|
|
@@ -2434,32 +2502,32 @@ var UVMapper = class {
|
|
|
2434
2502
|
v1 *= scaleV;
|
|
2435
2503
|
u2 *= scaleU;
|
|
2436
2504
|
v2 *= scaleV;
|
|
2437
|
-
let tl = new
|
|
2438
|
-
let tr = new
|
|
2439
|
-
let bl = new
|
|
2440
|
-
let br = new
|
|
2505
|
+
let tl = new import_three9.Vector2(u1, v1);
|
|
2506
|
+
let tr = new import_three9.Vector2(u2, v1);
|
|
2507
|
+
let bl = new import_three9.Vector2(u1, v2);
|
|
2508
|
+
let br = new import_three9.Vector2(u2, v2);
|
|
2441
2509
|
switch (rotation) {
|
|
2442
2510
|
case 0:
|
|
2443
2511
|
case 360:
|
|
2444
2512
|
default:
|
|
2445
2513
|
break;
|
|
2446
2514
|
case 90:
|
|
2447
|
-
tl = new
|
|
2448
|
-
tr = new
|
|
2449
|
-
bl = new
|
|
2450
|
-
br = new
|
|
2515
|
+
tl = new import_three9.Vector2(u1, v2);
|
|
2516
|
+
tr = new import_three9.Vector2(u1, v1);
|
|
2517
|
+
bl = new import_three9.Vector2(u2, v2);
|
|
2518
|
+
br = new import_three9.Vector2(u2, v1);
|
|
2451
2519
|
break;
|
|
2452
2520
|
case 180:
|
|
2453
|
-
tl = new
|
|
2454
|
-
tr = new
|
|
2455
|
-
bl = new
|
|
2456
|
-
br = new
|
|
2521
|
+
tl = new import_three9.Vector2(u2, v2);
|
|
2522
|
+
tr = new import_three9.Vector2(u1, v2);
|
|
2523
|
+
bl = new import_three9.Vector2(u2, v1);
|
|
2524
|
+
br = new import_three9.Vector2(u1, v1);
|
|
2457
2525
|
break;
|
|
2458
2526
|
case 270:
|
|
2459
|
-
tl = new
|
|
2460
|
-
tr = new
|
|
2461
|
-
bl = new
|
|
2462
|
-
br = new
|
|
2527
|
+
tl = new import_three9.Vector2(u2, v1);
|
|
2528
|
+
tr = new import_three9.Vector2(u2, v2);
|
|
2529
|
+
bl = new import_three9.Vector2(u1, v1);
|
|
2530
|
+
br = new import_three9.Vector2(u1, v2);
|
|
2463
2531
|
break;
|
|
2464
2532
|
}
|
|
2465
2533
|
return [tl, tr, bl, br];
|
|
@@ -2606,7 +2674,7 @@ var UVMapper = class {
|
|
|
2606
2674
|
const faceTexture = face.texture.substr(1);
|
|
2607
2675
|
const texPosition = positions[faceTexture] || [0, 0];
|
|
2608
2676
|
const texSize = sizes[faceTexture] || [16, 16];
|
|
2609
|
-
let texPosV = new
|
|
2677
|
+
let texPosV = new import_three9.Vector2(texPosition[0], texPosition[1]);
|
|
2610
2678
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
2611
2679
|
tl.add(texPosV);
|
|
2612
2680
|
tr.add(texPosV);
|
|
@@ -2840,7 +2908,7 @@ var BlockEntityModels = class {
|
|
|
2840
2908
|
};
|
|
2841
2909
|
|
|
2842
2910
|
// src/renderer/SceneObject.ts
|
|
2843
|
-
var
|
|
2911
|
+
var import_three10 = require("three");
|
|
2844
2912
|
|
|
2845
2913
|
// src/instance/InstanceReference.ts
|
|
2846
2914
|
var InstanceReference = class {
|
|
@@ -2899,7 +2967,7 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2899
2967
|
// src/renderer/SceneObject.ts
|
|
2900
2968
|
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
2901
2969
|
var p6 = prefix("SceneObject");
|
|
2902
|
-
var SceneObject = class _SceneObject extends
|
|
2970
|
+
var SceneObject = class _SceneObject extends import_three10.Object3D {
|
|
2903
2971
|
constructor(options) {
|
|
2904
2972
|
super();
|
|
2905
2973
|
this.isSceneObject = true;
|
|
@@ -2945,7 +3013,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2945
3013
|
return group;
|
|
2946
3014
|
}
|
|
2947
3015
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
2948
|
-
const obj = new
|
|
3016
|
+
const obj = new import_three10.Object3D();
|
|
2949
3017
|
if (name) {
|
|
2950
3018
|
obj.name = `group:${name}`;
|
|
2951
3019
|
}
|
|
@@ -2995,7 +3063,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2995
3063
|
return mesh;
|
|
2996
3064
|
}
|
|
2997
3065
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
2998
|
-
const mesh = new
|
|
3066
|
+
const mesh = new import_three10.Mesh(geometry, material);
|
|
2999
3067
|
if (name) {
|
|
3000
3068
|
mesh.name = `mesh:${name}`;
|
|
3001
3069
|
}
|
|
@@ -3007,7 +3075,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3007
3075
|
return mesh;
|
|
3008
3076
|
}
|
|
3009
3077
|
createInstancedMesh(name, geometry, material, count) {
|
|
3010
|
-
const mesh = new
|
|
3078
|
+
const mesh = new import_three10.InstancedMesh(geometry, material, count);
|
|
3011
3079
|
mesh.count = 0;
|
|
3012
3080
|
if (name) {
|
|
3013
3081
|
mesh.name = `mesh:${name}`;
|
|
@@ -3085,7 +3153,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3085
3153
|
nextInstance() {
|
|
3086
3154
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3087
3155
|
const i = this._instanceCounter++;
|
|
3088
|
-
this.setMatrixAt(i, new
|
|
3156
|
+
this.setMatrixAt(i, new import_three10.Matrix4());
|
|
3089
3157
|
const mesh = this.children[0];
|
|
3090
3158
|
if (mesh && isInstancedMesh(mesh)) {
|
|
3091
3159
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -3102,7 +3170,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3102
3170
|
}
|
|
3103
3171
|
//</editor-fold>
|
|
3104
3172
|
//<editor-fold desc="TRANSFORMATION">
|
|
3105
|
-
getMatrixAt(index, matrix = new
|
|
3173
|
+
getMatrixAt(index, matrix = new import_three10.Matrix4()) {
|
|
3106
3174
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3107
3175
|
const child = this.children[0];
|
|
3108
3176
|
if (child && isInstancedMesh(child)) {
|
|
@@ -3121,16 +3189,16 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3121
3189
|
}
|
|
3122
3190
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3123
3191
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3124
|
-
const oldPosition = new
|
|
3125
|
-
const oldRotation = new
|
|
3126
|
-
const oldScale = new
|
|
3127
|
-
const matrix = new
|
|
3192
|
+
const oldPosition = new import_three10.Vector3();
|
|
3193
|
+
const oldRotation = new import_three10.Quaternion();
|
|
3194
|
+
const oldScale = new import_three10.Vector3();
|
|
3195
|
+
const matrix = new import_three10.Matrix4();
|
|
3128
3196
|
if (!scale || !rotation || !position) {
|
|
3129
3197
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3130
3198
|
}
|
|
3131
3199
|
matrix.compose(
|
|
3132
3200
|
position ? position : oldPosition,
|
|
3133
|
-
rotation ? new
|
|
3201
|
+
rotation ? new import_three10.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3134
3202
|
scale ? scale : oldScale
|
|
3135
3203
|
);
|
|
3136
3204
|
this.setMatrixAt(index, matrix);
|
|
@@ -3139,7 +3207,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3139
3207
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3140
3208
|
this.setPositionRotationScaleAt(index, position);
|
|
3141
3209
|
}
|
|
3142
|
-
getPositionAt(index, vector = new
|
|
3210
|
+
getPositionAt(index, vector = new import_three10.Vector3()) {
|
|
3143
3211
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3144
3212
|
const matrix = this.getMatrixAt(index);
|
|
3145
3213
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3149,7 +3217,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3149
3217
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3150
3218
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3151
3219
|
}
|
|
3152
|
-
getRotationAt(index, euler = new
|
|
3220
|
+
getRotationAt(index, euler = new import_three10.Euler()) {
|
|
3153
3221
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3154
3222
|
const matrix = this.getMatrixAt(index);
|
|
3155
3223
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -3159,7 +3227,7 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3159
3227
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3160
3228
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3161
3229
|
}
|
|
3162
|
-
getScaleAt(index, vector = new
|
|
3230
|
+
getScaleAt(index, vector = new import_three10.Vector3()) {
|
|
3163
3231
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3164
3232
|
const matrix = this.getMatrixAt(index);
|
|
3165
3233
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3274,7 +3342,7 @@ function isSceneObject(obj) {
|
|
|
3274
3342
|
|
|
3275
3343
|
// src/entity/scene/EntityObject.ts
|
|
3276
3344
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
3277
|
-
var
|
|
3345
|
+
var import_three12 = require("three");
|
|
3278
3346
|
var THREE3 = __toESM(require("three"));
|
|
3279
3347
|
var EntityObject = class extends SceneObject {
|
|
3280
3348
|
constructor(entity, options) {
|
|
@@ -3315,7 +3383,7 @@ var EntityObject = class extends SceneObject {
|
|
|
3315
3383
|
for (let partName in this.entity.parts) {
|
|
3316
3384
|
const part = this.entity.parts[partName];
|
|
3317
3385
|
const texture = new MinecraftCubeTexture(part.textureOffsetU, part.textureOffsetV, part.textureWidth, part.textureHeight);
|
|
3318
|
-
const partAnchor = new
|
|
3386
|
+
const partAnchor = new import_three12.Object3D();
|
|
3319
3387
|
partAnchor.position.x = part.pivotX;
|
|
3320
3388
|
partAnchor.position.y = part.pivotY;
|
|
3321
3389
|
partAnchor.position.z = part.pivotZ;
|
|
@@ -3368,16 +3436,16 @@ var GuiObject = class extends SceneObject {
|
|
|
3368
3436
|
};
|
|
3369
3437
|
|
|
3370
3438
|
// src/inspector/SceneInspector.ts
|
|
3371
|
-
var
|
|
3439
|
+
var import_three13 = require("three");
|
|
3372
3440
|
var p7 = prefix("SceneInspector");
|
|
3373
3441
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3374
3442
|
var SceneInspector = class {
|
|
3375
3443
|
constructor(renderer) {
|
|
3376
3444
|
this.renderer = renderer;
|
|
3377
|
-
this.mouse = new
|
|
3445
|
+
this.mouse = new import_three13.Vector2();
|
|
3378
3446
|
this.objectInfoContainer = document.createElement("div");
|
|
3379
3447
|
this.objectControlsContainer = document.createElement("div");
|
|
3380
|
-
this.raycaster = new
|
|
3448
|
+
this.raycaster = new import_three13.Raycaster();
|
|
3381
3449
|
this.init();
|
|
3382
3450
|
}
|
|
3383
3451
|
init() {
|
|
@@ -3780,20 +3848,6 @@ function isInstanceable(obj) {
|
|
|
3780
3848
|
return "nextInstance" in obj;
|
|
3781
3849
|
}
|
|
3782
3850
|
|
|
3783
|
-
// src/model/DisplayPosition.ts
|
|
3784
|
-
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
3785
|
-
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
3786
|
-
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
3787
|
-
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
3788
|
-
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
3789
|
-
DisplayPosition2["GUI"] = "gui";
|
|
3790
|
-
DisplayPosition2["HEAD"] = "head";
|
|
3791
|
-
DisplayPosition2["GROUND"] = "ground";
|
|
3792
|
-
DisplayPosition2["FIXED"] = "fixed";
|
|
3793
|
-
return DisplayPosition2;
|
|
3794
|
-
})(DisplayPosition || {});
|
|
3795
|
-
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
3796
|
-
|
|
3797
3851
|
// src/model/GuiLight.ts
|
|
3798
3852
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3799
3853
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3816,11 +3870,96 @@ function isQuadArray(obj) {
|
|
|
3816
3870
|
return Array.isArray(obj) && obj.length === 4;
|
|
3817
3871
|
}
|
|
3818
3872
|
|
|
3873
|
+
// src/model/block/blockTints.json
|
|
3874
|
+
var blockTints_default = {
|
|
3875
|
+
"minecraft:large_fern": { source: "grass" },
|
|
3876
|
+
"minecraft:tall_grass": { source: "grass" },
|
|
3877
|
+
"minecraft:grass_block": { source: "grass" },
|
|
3878
|
+
"minecraft:fern": { source: "grass" },
|
|
3879
|
+
"minecraft:grass": { source: "grass" },
|
|
3880
|
+
"minecraft:short_grass": { source: "grass" },
|
|
3881
|
+
"minecraft:potted_fern": { source: "grass" },
|
|
3882
|
+
"minecraft:bush": { source: "grass" },
|
|
3883
|
+
"minecraft:pink_petals": { source: "grass", untinted: [0] },
|
|
3884
|
+
"minecraft:wildflowers": { source: "grass", untinted: [0] },
|
|
3885
|
+
"minecraft:spruce_leaves": { source: "constant", color: 6396257 },
|
|
3886
|
+
"minecraft:birch_leaves": { source: "constant", color: 8431445 },
|
|
3887
|
+
"minecraft:oak_leaves": { source: "constant", color: 4764952 },
|
|
3888
|
+
"minecraft:jungle_leaves": { source: "constant", color: 4764952 },
|
|
3889
|
+
"minecraft:acacia_leaves": { source: "constant", color: 4764952 },
|
|
3890
|
+
"minecraft:dark_oak_leaves": { source: "constant", color: 4764952 },
|
|
3891
|
+
"minecraft:vine": { source: "constant", color: 4764952 },
|
|
3892
|
+
"minecraft:mangrove_leaves": { source: "constant", color: 4764952 },
|
|
3893
|
+
"minecraft:leaf_litter": { source: "constant", color: 6044722 },
|
|
3894
|
+
"minecraft:water_cauldron": { source: "constant", color: 4159204 },
|
|
3895
|
+
"minecraft:redstone_wire": { source: "redstone" },
|
|
3896
|
+
"minecraft:attached_melon_stem": { source: "constant", color: 14731036 },
|
|
3897
|
+
"minecraft:attached_pumpkin_stem": { source: "constant", color: 14731036 },
|
|
3898
|
+
"minecraft:melon_stem": { source: "stem" },
|
|
3899
|
+
"minecraft:pumpkin_stem": { source: "stem" },
|
|
3900
|
+
"minecraft:lily_pad": { source: "constant", color: 7455580 }
|
|
3901
|
+
};
|
|
3902
|
+
|
|
3903
|
+
// src/model/block/BlockTints.ts
|
|
3904
|
+
var rules = blockTints_default;
|
|
3905
|
+
var BlockTints = class {
|
|
3906
|
+
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
3907
|
+
static async get(key, state, model, tints) {
|
|
3908
|
+
const rule = key && rules[key.toNamespacedString()];
|
|
3909
|
+
if (!key || !rule) return tints;
|
|
3910
|
+
const indices = /* @__PURE__ */ new Set();
|
|
3911
|
+
for (const element of model.elements ?? []) {
|
|
3912
|
+
for (const face of Object.values(element.faces)) {
|
|
3913
|
+
const index = face?.tintindex;
|
|
3914
|
+
if (index !== void 0 && index >= 0 && tints?.[index] === void 0 && !rule.untinted?.includes(index)) {
|
|
3915
|
+
indices.add(index);
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
if (!indices.size) return tints;
|
|
3920
|
+
let color;
|
|
3921
|
+
switch (rule.source) {
|
|
3922
|
+
case "constant":
|
|
3923
|
+
color = rule.color;
|
|
3924
|
+
break;
|
|
3925
|
+
case "grass":
|
|
3926
|
+
color = await this.grassColor(key);
|
|
3927
|
+
break;
|
|
3928
|
+
case "redstone": {
|
|
3929
|
+
const power = Number(state.power ?? 0) / 15;
|
|
3930
|
+
const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
|
|
3931
|
+
const green = Math.max(0, power * power * 0.7 - 0.5);
|
|
3932
|
+
const blue = Math.max(0, power * power * 0.6 - 0.7);
|
|
3933
|
+
color = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
|
|
3934
|
+
break;
|
|
3935
|
+
}
|
|
3936
|
+
case "stem": {
|
|
3937
|
+
const age = Number(state.age ?? 0);
|
|
3938
|
+
color = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
|
|
3939
|
+
break;
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
|
|
3943
|
+
}
|
|
3944
|
+
static async grassColor(origin) {
|
|
3945
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
3946
|
+
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
3947
|
+
const image = await ModelTextures.get(key);
|
|
3948
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
3949
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
3950
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
3951
|
+
}
|
|
3952
|
+
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
3953
|
+
return red << 16 | green << 8 | blue;
|
|
3954
|
+
});
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3957
|
+
|
|
3819
3958
|
// src/model/scene/ModelObject.ts
|
|
3820
|
-
var
|
|
3959
|
+
var import_three16 = require("three");
|
|
3821
3960
|
|
|
3822
3961
|
// src/three/BufferGeometryUtils.js
|
|
3823
|
-
var
|
|
3962
|
+
var import_three15 = require("three");
|
|
3824
3963
|
function computeTangents(geometry) {
|
|
3825
3964
|
geometry.computeTangents();
|
|
3826
3965
|
console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
|
|
@@ -3832,7 +3971,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3832
3971
|
const attributes = {};
|
|
3833
3972
|
const morphAttributes = {};
|
|
3834
3973
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3835
|
-
const mergedGeometry = new
|
|
3974
|
+
const mergedGeometry = new import_three15.BufferGeometry();
|
|
3836
3975
|
let offset = 0;
|
|
3837
3976
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3838
3977
|
const geometry = geometries[i];
|
|
@@ -3956,7 +4095,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
3956
4095
|
array.set(attributes[i].array, offset);
|
|
3957
4096
|
offset += attributes[i].array.length;
|
|
3958
4097
|
}
|
|
3959
|
-
return new
|
|
4098
|
+
return new import_three15.BufferAttribute(array, itemSize, normalized);
|
|
3960
4099
|
}
|
|
3961
4100
|
function interleaveAttributes(attributes) {
|
|
3962
4101
|
let TypedArray;
|
|
@@ -3972,7 +4111,7 @@ function interleaveAttributes(attributes) {
|
|
|
3972
4111
|
arrayLength += attribute.array.length;
|
|
3973
4112
|
stride += attribute.itemSize;
|
|
3974
4113
|
}
|
|
3975
|
-
const interleavedBuffer = new
|
|
4114
|
+
const interleavedBuffer = new import_three15.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
3976
4115
|
let offset = 0;
|
|
3977
4116
|
const res = [];
|
|
3978
4117
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -3981,7 +4120,7 @@ function interleaveAttributes(attributes) {
|
|
|
3981
4120
|
const attribute = attributes[j];
|
|
3982
4121
|
const itemSize = attribute.itemSize;
|
|
3983
4122
|
const count = attribute.count;
|
|
3984
|
-
const iba = new
|
|
4123
|
+
const iba = new import_three15.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
3985
4124
|
res.push(iba);
|
|
3986
4125
|
offset += itemSize;
|
|
3987
4126
|
for (let c = 0; c < count; c++) {
|
|
@@ -4065,13 +4204,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4065
4204
|
const name = attributeNames[i];
|
|
4066
4205
|
const oldAttribute = geometry.getAttribute(name);
|
|
4067
4206
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4068
|
-
const attribute = new
|
|
4207
|
+
const attribute = new import_three15.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4069
4208
|
result.setAttribute(name, attribute);
|
|
4070
4209
|
if (name in morphAttrsArrays) {
|
|
4071
4210
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4072
4211
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4073
4212
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4074
|
-
const morphAttribute = new
|
|
4213
|
+
const morphAttribute = new import_three15.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4075
4214
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4076
4215
|
}
|
|
4077
4216
|
}
|
|
@@ -4080,11 +4219,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4080
4219
|
return result;
|
|
4081
4220
|
}
|
|
4082
4221
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4083
|
-
if (drawMode ===
|
|
4222
|
+
if (drawMode === import_three15.TrianglesDrawMode) {
|
|
4084
4223
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4085
4224
|
return geometry;
|
|
4086
4225
|
}
|
|
4087
|
-
if (drawMode ===
|
|
4226
|
+
if (drawMode === import_three15.TriangleFanDrawMode || drawMode === import_three15.TriangleStripDrawMode) {
|
|
4088
4227
|
let index = geometry.getIndex();
|
|
4089
4228
|
if (index === null) {
|
|
4090
4229
|
const indices = [];
|
|
@@ -4102,7 +4241,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4102
4241
|
}
|
|
4103
4242
|
const numberOfTriangles = index.count - 2;
|
|
4104
4243
|
const newIndices = [];
|
|
4105
|
-
if (drawMode ===
|
|
4244
|
+
if (drawMode === import_three15.TriangleFanDrawMode) {
|
|
4106
4245
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4107
4246
|
newIndices.push(index.getX(0));
|
|
4108
4247
|
newIndices.push(index.getX(i));
|
|
@@ -4138,15 +4277,15 @@ function computeMorphedAttributes(object) {
|
|
|
4138
4277
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4139
4278
|
return null;
|
|
4140
4279
|
}
|
|
4141
|
-
const _vA = new
|
|
4142
|
-
const _vB = new
|
|
4143
|
-
const _vC = new
|
|
4144
|
-
const _tempA = new
|
|
4145
|
-
const _tempB = new
|
|
4146
|
-
const _tempC = new
|
|
4147
|
-
const _morphA = new
|
|
4148
|
-
const _morphB = new
|
|
4149
|
-
const _morphC = new
|
|
4280
|
+
const _vA = new import_three15.Vector3();
|
|
4281
|
+
const _vB = new import_three15.Vector3();
|
|
4282
|
+
const _vC = new import_three15.Vector3();
|
|
4283
|
+
const _tempA = new import_three15.Vector3();
|
|
4284
|
+
const _tempB = new import_three15.Vector3();
|
|
4285
|
+
const _tempC = new import_three15.Vector3();
|
|
4286
|
+
const _morphA = new import_three15.Vector3();
|
|
4287
|
+
const _morphB = new import_three15.Vector3();
|
|
4288
|
+
const _morphC = new import_three15.Vector3();
|
|
4150
4289
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4151
4290
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4152
4291
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4341,8 +4480,8 @@ function computeMorphedAttributes(object) {
|
|
|
4341
4480
|
}
|
|
4342
4481
|
}
|
|
4343
4482
|
}
|
|
4344
|
-
const morphedPositionAttribute = new
|
|
4345
|
-
const morphedNormalAttribute = new
|
|
4483
|
+
const morphedPositionAttribute = new import_three15.Float32BufferAttribute(modifiedPosition, 3);
|
|
4484
|
+
const morphedNormalAttribute = new import_three15.Float32BufferAttribute(modifiedNormal, 3);
|
|
4346
4485
|
return {
|
|
4347
4486
|
positionAttribute,
|
|
4348
4487
|
normalAttribute,
|
|
@@ -4386,13 +4525,14 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4386
4525
|
createMeshes(force = false) {
|
|
4387
4526
|
if (this.meshesCreated && !force) return;
|
|
4388
4527
|
const mat = Materials.MISSING_TEXTURE;
|
|
4528
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4389
4529
|
let allGeos = [];
|
|
4390
4530
|
if (this.atlas) {
|
|
4391
4531
|
if (this.atlas.model.elements) {
|
|
4392
4532
|
this.atlas.model.elements?.forEach((el) => {
|
|
4393
4533
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4394
4534
|
if (this.options.uvLockRotation) {
|
|
4395
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4535
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three16.Euler(...this.options.uvLockRotation));
|
|
4396
4536
|
}
|
|
4397
4537
|
if (this.options.tints) {
|
|
4398
4538
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4401,19 +4541,20 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4401
4541
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4402
4542
|
const tint = this.options.tints[tintIndex];
|
|
4403
4543
|
if (tint === void 0) continue;
|
|
4404
|
-
const color = new
|
|
4544
|
+
const color = new import_three16.Color(tint);
|
|
4405
4545
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4406
4546
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4407
4547
|
}
|
|
4408
4548
|
}
|
|
4409
|
-
elGeo.setAttribute("color", new
|
|
4549
|
+
elGeo.setAttribute("color", new import_three16.BufferAttribute(colors, 3));
|
|
4410
4550
|
}
|
|
4411
|
-
elGeo.applyMatrix4(new
|
|
4412
|
-
elGeo.applyMatrix4(new
|
|
4551
|
+
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));
|
|
4552
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4413
4553
|
if (el.rotation) {
|
|
4414
4554
|
applyElementRotation(el.rotation, elGeo);
|
|
4415
4555
|
}
|
|
4416
|
-
elGeo.applyMatrix4(new
|
|
4556
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(-8, -8, -8));
|
|
4557
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4417
4558
|
if (this.options.mergeMeshes) {
|
|
4418
4559
|
allGeos.push(elGeo);
|
|
4419
4560
|
} else {
|
|
@@ -4434,7 +4575,8 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4434
4575
|
if (allGeos.length > 0) {
|
|
4435
4576
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4436
4577
|
} else {
|
|
4437
|
-
combinedGeo = new
|
|
4578
|
+
combinedGeo = new import_three16.BoxGeometry(16, 16, 16);
|
|
4579
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4438
4580
|
}
|
|
4439
4581
|
combinedGeo.computeBoundingBox();
|
|
4440
4582
|
let mesh;
|
|
@@ -4486,7 +4628,7 @@ function isModelObject(obj) {
|
|
|
4486
4628
|
|
|
4487
4629
|
// src/model/block/scene/BlockObject.ts
|
|
4488
4630
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4489
|
-
var
|
|
4631
|
+
var import_three17 = require("three");
|
|
4490
4632
|
var p10 = prefix("BlockObject");
|
|
4491
4633
|
function matchesCondition(condition, state) {
|
|
4492
4634
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4548,7 +4690,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4548
4690
|
if (isModelObject(model)) {
|
|
4549
4691
|
model.removeFromScene();
|
|
4550
4692
|
} else if (isInstanceReference(model)) {
|
|
4551
|
-
model.setScale(new
|
|
4693
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4552
4694
|
}
|
|
4553
4695
|
}
|
|
4554
4696
|
super.removeFromScene();
|
|
@@ -4609,7 +4751,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4609
4751
|
}
|
|
4610
4752
|
for (let model of this._models) {
|
|
4611
4753
|
if (isInstanceReference(model)) {
|
|
4612
|
-
model.setScale(new
|
|
4754
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4613
4755
|
} else {
|
|
4614
4756
|
model.dispose();
|
|
4615
4757
|
}
|
|
@@ -4646,7 +4788,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4646
4788
|
await this.createVariant(variant);
|
|
4647
4789
|
}
|
|
4648
4790
|
async createVariant(variant) {
|
|
4649
|
-
const rotation = new
|
|
4791
|
+
const rotation = new import_three17.Euler();
|
|
4650
4792
|
if (typeof variant.x !== "undefined") {
|
|
4651
4793
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4652
4794
|
}
|
|
@@ -4656,6 +4798,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4656
4798
|
const model = await Models.getMerged(AssetKey.parse("models", variant.model));
|
|
4657
4799
|
const options = {
|
|
4658
4800
|
...this.options,
|
|
4801
|
+
tints: model ? await BlockTints.get(this.blockState.key, this.state, model, this.options.tints) : this.options.tints,
|
|
4659
4802
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
4660
4803
|
};
|
|
4661
4804
|
const obj = await this.scene.addModel(model, options);
|
|
@@ -4732,7 +4875,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4732
4875
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4733
4876
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4734
4877
|
}
|
|
4735
|
-
getMatrixAt(index, matrix = new
|
|
4878
|
+
getMatrixAt(index, matrix = new import_three17.Matrix4()) {
|
|
4736
4879
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4737
4880
|
const child = this._models[0];
|
|
4738
4881
|
if (child && isModelObject(child)) {
|
|
@@ -4807,7 +4950,7 @@ var StructureParser = class {
|
|
|
4807
4950
|
};
|
|
4808
4951
|
|
|
4809
4952
|
// src/renderer/MineRenderScene.ts
|
|
4810
|
-
var
|
|
4953
|
+
var import_three18 = require("three");
|
|
4811
4954
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4812
4955
|
|
|
4813
4956
|
// src/skin/SkinPart.ts
|
|
@@ -5651,7 +5794,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5651
5794
|
};
|
|
5652
5795
|
|
|
5653
5796
|
// src/renderer/MineRenderScene.ts
|
|
5654
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
5797
|
+
var MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
5655
5798
|
constructor(options) {
|
|
5656
5799
|
super();
|
|
5657
5800
|
this.isMineRenderScene = true;
|
|
@@ -5727,7 +5870,8 @@ var MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5727
5870
|
console.log("instanceMeshes + key");
|
|
5728
5871
|
let key = asset.key.serialize();
|
|
5729
5872
|
if (isModelObject(obj)) {
|
|
5730
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5873
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5874
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5731
5875
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5732
5876
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5733
5877
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5774,17 +5918,17 @@ function isMineRenderScene(obj) {
|
|
|
5774
5918
|
}
|
|
5775
5919
|
|
|
5776
5920
|
// src/renderer/Renderer.ts
|
|
5777
|
-
var
|
|
5921
|
+
var import_three20 = require("three");
|
|
5778
5922
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5779
5923
|
var import_stats = __toESM(require("stats.js"));
|
|
5780
5924
|
var import_postprocessing = require("postprocessing");
|
|
5781
5925
|
|
|
5782
5926
|
// src/three/OrbitControls.js
|
|
5783
|
-
var
|
|
5927
|
+
var import_three19 = require("three");
|
|
5784
5928
|
var _changeEvent = { type: "change" };
|
|
5785
5929
|
var _startEvent = { type: "start" };
|
|
5786
5930
|
var _endEvent = { type: "end" };
|
|
5787
|
-
var OrbitControls = class extends
|
|
5931
|
+
var OrbitControls = class extends import_three19.EventDispatcher {
|
|
5788
5932
|
constructor(object, domElement) {
|
|
5789
5933
|
super();
|
|
5790
5934
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5793,7 +5937,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5793
5937
|
this.domElement = domElement;
|
|
5794
5938
|
this.domElement.style.touchAction = "none";
|
|
5795
5939
|
this.enabled = true;
|
|
5796
|
-
this.target = new
|
|
5940
|
+
this.target = new import_three19.Vector3();
|
|
5797
5941
|
this.minDistance = 0;
|
|
5798
5942
|
this.maxDistance = Infinity;
|
|
5799
5943
|
this.minZoom = 0;
|
|
@@ -5815,8 +5959,8 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5815
5959
|
this.autoRotate = false;
|
|
5816
5960
|
this.autoRotateSpeed = 2;
|
|
5817
5961
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5818
|
-
this.mouseButtons = { LEFT:
|
|
5819
|
-
this.touches = { ONE:
|
|
5962
|
+
this.mouseButtons = { LEFT: import_three19.MOUSE.ROTATE, MIDDLE: import_three19.MOUSE.DOLLY, RIGHT: import_three19.MOUSE.PAN };
|
|
5963
|
+
this.touches = { ONE: import_three19.TOUCH.ROTATE, TWO: import_three19.TOUCH.DOLLY_PAN };
|
|
5820
5964
|
this.target0 = this.target.clone();
|
|
5821
5965
|
this.position0 = this.object.position.clone();
|
|
5822
5966
|
this.zoom0 = this.object.zoom;
|
|
@@ -5845,11 +5989,11 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5845
5989
|
state = STATE.NONE;
|
|
5846
5990
|
};
|
|
5847
5991
|
this.update = function() {
|
|
5848
|
-
const offset = new
|
|
5849
|
-
const quat = new
|
|
5992
|
+
const offset = new import_three19.Vector3();
|
|
5993
|
+
const quat = new import_three19.Quaternion().setFromUnitVectors(object.up, new import_three19.Vector3(0, 1, 0));
|
|
5850
5994
|
const quatInverse = quat.clone().invert();
|
|
5851
|
-
const lastPosition = new
|
|
5852
|
-
const lastQuaternion = new
|
|
5995
|
+
const lastPosition = new import_three19.Vector3();
|
|
5996
|
+
const lastQuaternion = new import_three19.Quaternion();
|
|
5853
5997
|
const twoPI = 2 * Math.PI;
|
|
5854
5998
|
return function update() {
|
|
5855
5999
|
const position = scope.object.position;
|
|
@@ -5935,20 +6079,20 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5935
6079
|
};
|
|
5936
6080
|
let state = STATE.NONE;
|
|
5937
6081
|
const EPS = 1e-6;
|
|
5938
|
-
const spherical = new
|
|
5939
|
-
const sphericalDelta = new
|
|
6082
|
+
const spherical = new import_three19.Spherical();
|
|
6083
|
+
const sphericalDelta = new import_three19.Spherical();
|
|
5940
6084
|
let scale = 1;
|
|
5941
|
-
const panOffset = new
|
|
6085
|
+
const panOffset = new import_three19.Vector3();
|
|
5942
6086
|
let zoomChanged = false;
|
|
5943
|
-
const rotateStart = new
|
|
5944
|
-
const rotateEnd = new
|
|
5945
|
-
const rotateDelta = new
|
|
5946
|
-
const panStart = new
|
|
5947
|
-
const panEnd = new
|
|
5948
|
-
const panDelta = new
|
|
5949
|
-
const dollyStart = new
|
|
5950
|
-
const dollyEnd = new
|
|
5951
|
-
const dollyDelta = new
|
|
6087
|
+
const rotateStart = new import_three19.Vector2();
|
|
6088
|
+
const rotateEnd = new import_three19.Vector2();
|
|
6089
|
+
const rotateDelta = new import_three19.Vector2();
|
|
6090
|
+
const panStart = new import_three19.Vector2();
|
|
6091
|
+
const panEnd = new import_three19.Vector2();
|
|
6092
|
+
const panDelta = new import_three19.Vector2();
|
|
6093
|
+
const dollyStart = new import_three19.Vector2();
|
|
6094
|
+
const dollyEnd = new import_three19.Vector2();
|
|
6095
|
+
const dollyDelta = new import_three19.Vector2();
|
|
5952
6096
|
const pointers = [];
|
|
5953
6097
|
const pointerPositions = {};
|
|
5954
6098
|
function getAutoRotationAngle() {
|
|
@@ -5964,7 +6108,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5964
6108
|
sphericalDelta.phi -= angle;
|
|
5965
6109
|
}
|
|
5966
6110
|
const panLeft = function() {
|
|
5967
|
-
const v = new
|
|
6111
|
+
const v = new import_three19.Vector3();
|
|
5968
6112
|
return function panLeft2(distance, objectMatrix) {
|
|
5969
6113
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5970
6114
|
v.multiplyScalar(-distance);
|
|
@@ -5972,7 +6116,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5972
6116
|
};
|
|
5973
6117
|
}();
|
|
5974
6118
|
const panUp = function() {
|
|
5975
|
-
const v = new
|
|
6119
|
+
const v = new import_three19.Vector3();
|
|
5976
6120
|
return function panUp2(distance, objectMatrix) {
|
|
5977
6121
|
if (scope.screenSpacePanning === true) {
|
|
5978
6122
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5985,7 +6129,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5985
6129
|
};
|
|
5986
6130
|
}();
|
|
5987
6131
|
const pan = function() {
|
|
5988
|
-
const offset = new
|
|
6132
|
+
const offset = new import_three19.Vector3();
|
|
5989
6133
|
return function pan2(deltaX, deltaY) {
|
|
5990
6134
|
const element = scope.domElement;
|
|
5991
6135
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6234,12 +6378,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6234
6378
|
mouseAction = -1;
|
|
6235
6379
|
}
|
|
6236
6380
|
switch (mouseAction) {
|
|
6237
|
-
case
|
|
6381
|
+
case import_three19.MOUSE.DOLLY:
|
|
6238
6382
|
if (scope.enableZoom === false) return;
|
|
6239
6383
|
handleMouseDownDolly(event);
|
|
6240
6384
|
state = STATE.DOLLY;
|
|
6241
6385
|
break;
|
|
6242
|
-
case
|
|
6386
|
+
case import_three19.MOUSE.ROTATE:
|
|
6243
6387
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6244
6388
|
if (scope.enablePan === false) return;
|
|
6245
6389
|
handleMouseDownPan(event);
|
|
@@ -6250,7 +6394,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6250
6394
|
state = STATE.ROTATE;
|
|
6251
6395
|
}
|
|
6252
6396
|
break;
|
|
6253
|
-
case
|
|
6397
|
+
case import_three19.MOUSE.PAN:
|
|
6254
6398
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6255
6399
|
if (scope.enableRotate === false) return;
|
|
6256
6400
|
handleMouseDownRotate(event);
|
|
@@ -6306,12 +6450,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6306
6450
|
switch (pointers.length) {
|
|
6307
6451
|
case 1:
|
|
6308
6452
|
switch (scope.touches.ONE) {
|
|
6309
|
-
case
|
|
6453
|
+
case import_three19.TOUCH.ROTATE:
|
|
6310
6454
|
if (scope.enableRotate === false) return;
|
|
6311
6455
|
handleTouchStartRotate();
|
|
6312
6456
|
state = STATE.TOUCH_ROTATE;
|
|
6313
6457
|
break;
|
|
6314
|
-
case
|
|
6458
|
+
case import_three19.TOUCH.PAN:
|
|
6315
6459
|
if (scope.enablePan === false) return;
|
|
6316
6460
|
handleTouchStartPan();
|
|
6317
6461
|
state = STATE.TOUCH_PAN;
|
|
@@ -6322,12 +6466,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6322
6466
|
break;
|
|
6323
6467
|
case 2:
|
|
6324
6468
|
switch (scope.touches.TWO) {
|
|
6325
|
-
case
|
|
6469
|
+
case import_three19.TOUCH.DOLLY_PAN:
|
|
6326
6470
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6327
6471
|
handleTouchStartDollyPan();
|
|
6328
6472
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6329
6473
|
break;
|
|
6330
|
-
case
|
|
6474
|
+
case import_three19.TOUCH.DOLLY_ROTATE:
|
|
6331
6475
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6332
6476
|
handleTouchStartDollyRotate();
|
|
6333
6477
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6394,7 +6538,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6394
6538
|
function trackPointer(event) {
|
|
6395
6539
|
let position = pointerPositions[event.pointerId];
|
|
6396
6540
|
if (position === void 0) {
|
|
6397
|
-
position = new
|
|
6541
|
+
position = new import_three19.Vector2();
|
|
6398
6542
|
pointerPositions[event.pointerId] = position;
|
|
6399
6543
|
}
|
|
6400
6544
|
position.set(event.pageX, event.pageY);
|
|
@@ -6414,10 +6558,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6414
6558
|
constructor(object, domElement) {
|
|
6415
6559
|
super(object, domElement);
|
|
6416
6560
|
this.screenSpacePanning = false;
|
|
6417
|
-
this.mouseButtons.LEFT =
|
|
6418
|
-
this.mouseButtons.RIGHT =
|
|
6419
|
-
this.touches.ONE =
|
|
6420
|
-
this.touches.TWO =
|
|
6561
|
+
this.mouseButtons.LEFT = import_three19.MOUSE.PAN;
|
|
6562
|
+
this.mouseButtons.RIGHT = import_three19.MOUSE.ROTATE;
|
|
6563
|
+
this.touches.ONE = import_three19.TOUCH.PAN;
|
|
6564
|
+
this.touches.TWO = import_three19.TOUCH.DOLLY_ROTATE;
|
|
6421
6565
|
}
|
|
6422
6566
|
};
|
|
6423
6567
|
|
|
@@ -6462,8 +6606,8 @@ var Renderer = class _Renderer {
|
|
|
6462
6606
|
top: void 0,
|
|
6463
6607
|
bottom: void 0
|
|
6464
6608
|
},
|
|
6465
|
-
position: new
|
|
6466
|
-
lookingAt: new
|
|
6609
|
+
position: new import_three20.Vector3(50, 50, 50),
|
|
6610
|
+
lookingAt: new import_three20.Vector3(0, 0, 0)
|
|
6467
6611
|
},
|
|
6468
6612
|
render: {
|
|
6469
6613
|
fpsLimit: 60,
|
|
@@ -6493,14 +6637,14 @@ var Renderer = class _Renderer {
|
|
|
6493
6637
|
switch (this.options.camera.type) {
|
|
6494
6638
|
case "perspective":
|
|
6495
6639
|
default:
|
|
6496
|
-
return new
|
|
6640
|
+
return new import_three20.PerspectiveCamera(
|
|
6497
6641
|
this.options.camera.perspective.fov,
|
|
6498
6642
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6499
6643
|
this.options.camera.near,
|
|
6500
6644
|
this.options.camera.far
|
|
6501
6645
|
);
|
|
6502
6646
|
case "orthographic":
|
|
6503
|
-
return new
|
|
6647
|
+
return new import_three20.OrthographicCamera(
|
|
6504
6648
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6505
6649
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6506
6650
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6511,7 +6655,7 @@ var Renderer = class _Renderer {
|
|
|
6511
6655
|
}
|
|
6512
6656
|
}
|
|
6513
6657
|
createRenderer() {
|
|
6514
|
-
const renderer = new
|
|
6658
|
+
const renderer = new import_three20.WebGLRenderer({
|
|
6515
6659
|
antialias: this.options.render.antialias,
|
|
6516
6660
|
alpha: true,
|
|
6517
6661
|
powerPreference: "high-performance",
|
|
@@ -6519,8 +6663,8 @@ var Renderer = class _Renderer {
|
|
|
6519
6663
|
});
|
|
6520
6664
|
renderer.setClearColor(0, 0);
|
|
6521
6665
|
renderer.shadowMap.enabled = true;
|
|
6522
|
-
renderer.shadowMap.type =
|
|
6523
|
-
renderer.outputColorSpace =
|
|
6666
|
+
renderer.shadowMap.type = import_three20.PCFSoftShadowMap;
|
|
6667
|
+
renderer.outputColorSpace = import_three20.SRGBColorSpace;
|
|
6524
6668
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6525
6669
|
return renderer;
|
|
6526
6670
|
}
|
|
@@ -6554,20 +6698,20 @@ var Renderer = class _Renderer {
|
|
|
6554
6698
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6555
6699
|
}
|
|
6556
6700
|
if (this.options.debug.grid) {
|
|
6557
|
-
const gridHelper = new
|
|
6701
|
+
const gridHelper = new import_three20.GridHelper(128, 16);
|
|
6558
6702
|
this._debugHelpers.push(gridHelper);
|
|
6559
6703
|
this.scene.add(gridHelper);
|
|
6560
|
-
const gridHelper2 = new
|
|
6704
|
+
const gridHelper2 = new import_three20.GridHelper(128, 16);
|
|
6561
6705
|
this._debugHelpers.push(gridHelper2);
|
|
6562
6706
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6563
6707
|
this.scene.add(gridHelper2);
|
|
6564
|
-
const gridHelper3 = new
|
|
6708
|
+
const gridHelper3 = new import_three20.GridHelper(128, 16);
|
|
6565
6709
|
this._debugHelpers.push(gridHelper3);
|
|
6566
6710
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6567
6711
|
this.scene.add(gridHelper3);
|
|
6568
6712
|
}
|
|
6569
6713
|
if (this.options.debug.axes) {
|
|
6570
|
-
const axesHelper = new
|
|
6714
|
+
const axesHelper = new import_three20.AxesHelper(64);
|
|
6571
6715
|
this._debugHelpers.push(axesHelper);
|
|
6572
6716
|
this.scene.add(axesHelper);
|
|
6573
6717
|
}
|
|
@@ -6928,10 +7072,10 @@ var Skins = class {
|
|
|
6928
7072
|
};
|
|
6929
7073
|
|
|
6930
7074
|
// src/world/Chunk.ts
|
|
6931
|
-
var
|
|
7075
|
+
var import_three23 = require("three");
|
|
6932
7076
|
|
|
6933
7077
|
// src/world/MineRenderWorld.ts
|
|
6934
|
-
var
|
|
7078
|
+
var import_three22 = require("three");
|
|
6935
7079
|
var MineRenderWorld = class {
|
|
6936
7080
|
constructor(scene) {
|
|
6937
7081
|
this._size = 4;
|
|
@@ -6942,10 +7086,10 @@ var MineRenderWorld = class {
|
|
|
6942
7086
|
}
|
|
6943
7087
|
getBlockAt(posOrX, y, z) {
|
|
6944
7088
|
if (typeof posOrX == "number") {
|
|
6945
|
-
return this.getBlockAt(new
|
|
7089
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX, y, z));
|
|
6946
7090
|
}
|
|
6947
7091
|
if (isTripleArray(posOrX)) {
|
|
6948
|
-
return this.getBlockAt(new
|
|
7092
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
6949
7093
|
}
|
|
6950
7094
|
const chunk = this.getChunkAt(posOrX);
|
|
6951
7095
|
if (typeof chunk === "undefined") {
|
|
@@ -6956,10 +7100,10 @@ var MineRenderWorld = class {
|
|
|
6956
7100
|
}
|
|
6957
7101
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6958
7102
|
if (typeof posOrX == "number") {
|
|
6959
|
-
return this.setBlockAt(new
|
|
7103
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX, yOrBlock, z), block);
|
|
6960
7104
|
}
|
|
6961
7105
|
if (isTripleArray(posOrX)) {
|
|
6962
|
-
return this.setBlockAt(new
|
|
7106
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6963
7107
|
}
|
|
6964
7108
|
this.validatePosBounds(posOrX);
|
|
6965
7109
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7005,14 +7149,14 @@ var MineRenderWorld = class {
|
|
|
7005
7149
|
return this._chunks[index];
|
|
7006
7150
|
}
|
|
7007
7151
|
static worldToScenePosition(pos) {
|
|
7008
|
-
return new
|
|
7152
|
+
return new import_three22.Vector3(
|
|
7009
7153
|
pos.x * 16,
|
|
7010
7154
|
pos.y * 16,
|
|
7011
7155
|
pos.z * 16
|
|
7012
7156
|
);
|
|
7013
7157
|
}
|
|
7014
7158
|
static sceneToWorldPosition(pos) {
|
|
7015
|
-
return new
|
|
7159
|
+
return new import_three22.Vector3(
|
|
7016
7160
|
pos.x / 16,
|
|
7017
7161
|
pos.y / 16,
|
|
7018
7162
|
pos.z / 16
|
|
@@ -7049,12 +7193,12 @@ var Chunk = class _Chunk {
|
|
|
7049
7193
|
this.x = x;
|
|
7050
7194
|
this.y = y;
|
|
7051
7195
|
this.z = z;
|
|
7052
|
-
let anchor = new
|
|
7196
|
+
let anchor = new import_three23.Object3D();
|
|
7053
7197
|
this._anchor = anchor;
|
|
7054
7198
|
scene.add(anchor);
|
|
7055
7199
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7056
7200
|
addBox3WireframeToObject(
|
|
7057
|
-
new
|
|
7201
|
+
new import_three23.Box3(new import_three23.Vector3(0, 0, 0), new import_three23.Vector3(256, 256, 256)),
|
|
7058
7202
|
anchor,
|
|
7059
7203
|
16776960,
|
|
7060
7204
|
4
|
|
@@ -7062,10 +7206,10 @@ var Chunk = class _Chunk {
|
|
|
7062
7206
|
}
|
|
7063
7207
|
getBlockAt(posOrX, y, z) {
|
|
7064
7208
|
if (typeof posOrX == "number") {
|
|
7065
|
-
return this.getBlockAt(new
|
|
7209
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7066
7210
|
}
|
|
7067
7211
|
if (isTripleArray(posOrX)) {
|
|
7068
|
-
return this.getBlockAt(new
|
|
7212
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7069
7213
|
}
|
|
7070
7214
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7071
7215
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7073,10 +7217,10 @@ var Chunk = class _Chunk {
|
|
|
7073
7217
|
}
|
|
7074
7218
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7075
7219
|
if (typeof posOrX == "number") {
|
|
7076
|
-
return this.setBlockAt(new
|
|
7220
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7077
7221
|
}
|
|
7078
7222
|
if (isTripleArray(posOrX)) {
|
|
7079
|
-
return this.setBlockAt(new
|
|
7223
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7080
7224
|
}
|
|
7081
7225
|
const worldPos = posOrX;
|
|
7082
7226
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7122,7 +7266,7 @@ var Chunk = class _Chunk {
|
|
|
7122
7266
|
}
|
|
7123
7267
|
async clear() {
|
|
7124
7268
|
let promises = [];
|
|
7125
|
-
let pos = new
|
|
7269
|
+
let pos = new import_three23.Vector3();
|
|
7126
7270
|
for (let x = 0; x < 16; x++) {
|
|
7127
7271
|
for (let z = 0; z < 16; z++) {
|
|
7128
7272
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7141,14 +7285,14 @@ var Chunk = class _Chunk {
|
|
|
7141
7285
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7142
7286
|
}
|
|
7143
7287
|
worldPosToChunkPos(pos) {
|
|
7144
|
-
return new
|
|
7288
|
+
return new import_three23.Vector3(
|
|
7145
7289
|
pos.x - this.x * 16,
|
|
7146
7290
|
pos.y - this.y * 16,
|
|
7147
7291
|
pos.z - this.z * 16
|
|
7148
7292
|
);
|
|
7149
7293
|
}
|
|
7150
7294
|
chunkPosToWorldPos(pos) {
|
|
7151
|
-
return new
|
|
7295
|
+
return new import_three23.Vector3(
|
|
7152
7296
|
this.x * 16 + pos.x,
|
|
7153
7297
|
this.y * 16 + pos.y,
|
|
7154
7298
|
this.z * 16 + pos.z
|
|
@@ -7173,6 +7317,7 @@ var Chunk = class _Chunk {
|
|
|
7173
7317
|
BlockEntityModels,
|
|
7174
7318
|
BlockObject,
|
|
7175
7319
|
BlockStates,
|
|
7320
|
+
BlockTints,
|
|
7176
7321
|
BrowserArchiveProxy,
|
|
7177
7322
|
CUBE_FACES,
|
|
7178
7323
|
Caching,
|
|
@@ -7187,6 +7332,7 @@ var Chunk = class _Chunk {
|
|
|
7187
7332
|
DISPLAY_POSITIONS,
|
|
7188
7333
|
DefaultBlockStates,
|
|
7189
7334
|
DisplayPosition,
|
|
7335
|
+
DisplayTransforms,
|
|
7190
7336
|
Entities,
|
|
7191
7337
|
EntityModels,
|
|
7192
7338
|
EntityObject,
|