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/browser/index.js
CHANGED
|
@@ -140,6 +140,7 @@ __export(index_browser_exports, {
|
|
|
140
140
|
BlockEntityModels: () => BlockEntityModels,
|
|
141
141
|
BlockObject: () => BlockObject,
|
|
142
142
|
BlockStates: () => BlockStates,
|
|
143
|
+
BlockTints: () => BlockTints,
|
|
143
144
|
BrowserArchiveProxy: () => BrowserArchiveProxy,
|
|
144
145
|
BrowserCache: () => BrowserCache,
|
|
145
146
|
BrowserEnv: () => BrowserEnv,
|
|
@@ -156,6 +157,7 @@ __export(index_browser_exports, {
|
|
|
156
157
|
DISPLAY_POSITIONS: () => DISPLAY_POSITIONS,
|
|
157
158
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
158
159
|
DisplayPosition: () => DisplayPosition,
|
|
160
|
+
DisplayTransforms: () => DisplayTransforms,
|
|
159
161
|
Entities: () => Entities,
|
|
160
162
|
EntityModels: () => EntityModels,
|
|
161
163
|
EntityObject: () => EntityObject,
|
|
@@ -568,6 +570,7 @@ var _Caching = class _Caching {
|
|
|
568
570
|
this.blockStateCache,
|
|
569
571
|
this.listAssetCache,
|
|
570
572
|
this.defaultBlockStatesCache,
|
|
573
|
+
this.blockTintCache,
|
|
571
574
|
this.entityModelsCache
|
|
572
575
|
];
|
|
573
576
|
}
|
|
@@ -610,6 +613,7 @@ _Caching.modelTextureAtlasCache = import_loading_cache.Caches.builder().expireAf
|
|
|
610
613
|
_Caching.blockStateCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
611
614
|
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
612
615
|
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
616
|
+
_Caching.blockTintCache = _Caching.createAssetCache();
|
|
613
617
|
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
614
618
|
var Caching = _Caching;
|
|
615
619
|
|
|
@@ -1247,7 +1251,7 @@ var Meshes = class _Meshes {
|
|
|
1247
1251
|
};
|
|
1248
1252
|
|
|
1249
1253
|
// src/UVMapper.ts
|
|
1250
|
-
var
|
|
1254
|
+
var import_three9 = require("three");
|
|
1251
1255
|
|
|
1252
1256
|
// src/model/ModelMerger.ts
|
|
1253
1257
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1338,15 +1342,77 @@ function isAssetKey(obj) {
|
|
|
1338
1342
|
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1339
1343
|
}
|
|
1340
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
|
+
|
|
1341
1404
|
// src/model/ModelMerger.ts
|
|
1342
1405
|
var ModelMerger = class {
|
|
1343
1406
|
static async mergeWithParents(model) {
|
|
1344
1407
|
const models = await this.collectAllParents(model);
|
|
1345
1408
|
let merged = {};
|
|
1346
|
-
for (
|
|
1347
|
-
|
|
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
|
+
}
|
|
1348
1415
|
}
|
|
1349
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, model);
|
|
1350
1416
|
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1351
1417
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1352
1418
|
return merged;
|
|
@@ -1601,9 +1667,9 @@ var BatchedExecutor = class {
|
|
|
1601
1667
|
};
|
|
1602
1668
|
|
|
1603
1669
|
// src/util/model.ts
|
|
1604
|
-
var
|
|
1670
|
+
var import_three8 = require("three");
|
|
1605
1671
|
function applyElementRotation(rotation, geometry) {
|
|
1606
|
-
const origin = new
|
|
1672
|
+
const origin = new import_three8.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1607
1673
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1608
1674
|
switch (rotation.axis) {
|
|
1609
1675
|
case "x" /* X */:
|
|
@@ -1628,7 +1694,7 @@ function applyElementRotation(rotation, geometry) {
|
|
|
1628
1694
|
geometry.translate(origin.x, origin.y, origin.z);
|
|
1629
1695
|
}
|
|
1630
1696
|
function applyModelPartRotation(modelPart, geometry) {
|
|
1631
|
-
const origin = new
|
|
1697
|
+
const origin = new import_three8.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1632
1698
|
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1633
1699
|
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1634
1700
|
geometry.rotateY(toRadians(modelPart.yaw));
|
|
@@ -1638,42 +1704,42 @@ function applyModelPartRotation(modelPart, geometry) {
|
|
|
1638
1704
|
function applyGenericRotation(axis, rotation, obj) {
|
|
1639
1705
|
switch (axis) {
|
|
1640
1706
|
case "x" /* X */:
|
|
1641
|
-
obj.rotateOnAxis(new
|
|
1707
|
+
obj.rotateOnAxis(new import_three8.Vector3(1, 0, 0), toRadians(rotation));
|
|
1642
1708
|
break;
|
|
1643
1709
|
case "y" /* Y */:
|
|
1644
|
-
obj.rotateOnAxis(new
|
|
1710
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 1, 0), toRadians(rotation));
|
|
1645
1711
|
break;
|
|
1646
1712
|
case "z" /* Z */:
|
|
1647
|
-
obj.rotateOnAxis(new
|
|
1713
|
+
obj.rotateOnAxis(new import_three8.Vector3(0, 0, 1), toRadians(rotation));
|
|
1648
1714
|
break;
|
|
1649
1715
|
}
|
|
1650
1716
|
}
|
|
1651
1717
|
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1652
|
-
let size = new
|
|
1718
|
+
let size = new import_three8.Vector3();
|
|
1653
1719
|
box.getSize(size);
|
|
1654
|
-
let boxGeo = new
|
|
1655
|
-
let wireGeo = new
|
|
1656
|
-
let wireMat = new
|
|
1657
|
-
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);
|
|
1658
1724
|
obj.add(wireframe);
|
|
1659
|
-
let axes = new
|
|
1725
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1660
1726
|
obj.add(axes);
|
|
1661
1727
|
}
|
|
1662
1728
|
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1663
|
-
let boxGeo = new
|
|
1664
|
-
let wireGeo = new
|
|
1665
|
-
let wireMat = new
|
|
1666
|
-
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);
|
|
1667
1733
|
obj.add(wireframe);
|
|
1668
|
-
let axes = new
|
|
1734
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1669
1735
|
obj.add(axes);
|
|
1670
1736
|
}
|
|
1671
1737
|
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1672
|
-
let wireGeo = new
|
|
1673
|
-
let wireMat = new
|
|
1674
|
-
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);
|
|
1675
1741
|
mesh.add(wireframe);
|
|
1676
|
-
let axes = new
|
|
1742
|
+
let axes = new import_three8.AxesHelper(1);
|
|
1677
1743
|
mesh.add(axes);
|
|
1678
1744
|
}
|
|
1679
1745
|
|
|
@@ -2217,12 +2283,12 @@ var X = 0;
|
|
|
2217
2283
|
var Y = 1;
|
|
2218
2284
|
var Z = 2;
|
|
2219
2285
|
var FACE_UV_AXES = {
|
|
2220
|
-
east: [new
|
|
2221
|
-
west: [new
|
|
2222
|
-
up: [new
|
|
2223
|
-
down: [new
|
|
2224
|
-
south: [new
|
|
2225
|
-
north: [new
|
|
2286
|
+
east: [new import_three9.Vector3(0, 0, -1), new import_three9.Vector3(0, -1, 0)],
|
|
2287
|
+
west: [new import_three9.Vector3(0, 0, 1), new import_three9.Vector3(0, -1, 0)],
|
|
2288
|
+
up: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, 1)],
|
|
2289
|
+
down: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, 0, -1)],
|
|
2290
|
+
south: [new import_three9.Vector3(1, 0, 0), new import_three9.Vector3(0, -1, 0)],
|
|
2291
|
+
north: [new import_three9.Vector3(-1, 0, 0), new import_three9.Vector3(0, -1, 0)]
|
|
2226
2292
|
};
|
|
2227
2293
|
var UVMapper = class {
|
|
2228
2294
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2319,7 +2385,7 @@ var UVMapper = class {
|
|
|
2319
2385
|
return array;
|
|
2320
2386
|
}
|
|
2321
2387
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2322
|
-
return new
|
|
2388
|
+
return new import_three9.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2323
2389
|
}
|
|
2324
2390
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2325
2391
|
const uv = geometry.getAttribute("uv");
|
|
@@ -2397,32 +2463,32 @@ var UVMapper = class {
|
|
|
2397
2463
|
v1 *= scaleV;
|
|
2398
2464
|
u2 *= scaleU;
|
|
2399
2465
|
v2 *= scaleV;
|
|
2400
|
-
let tl = new
|
|
2401
|
-
let tr = new
|
|
2402
|
-
let bl = new
|
|
2403
|
-
let br = new
|
|
2466
|
+
let tl = new import_three9.Vector2(u1, v1);
|
|
2467
|
+
let tr = new import_three9.Vector2(u2, v1);
|
|
2468
|
+
let bl = new import_three9.Vector2(u1, v2);
|
|
2469
|
+
let br = new import_three9.Vector2(u2, v2);
|
|
2404
2470
|
switch (rotation) {
|
|
2405
2471
|
case 0:
|
|
2406
2472
|
case 360:
|
|
2407
2473
|
default:
|
|
2408
2474
|
break;
|
|
2409
2475
|
case 90:
|
|
2410
|
-
tl = new
|
|
2411
|
-
tr = new
|
|
2412
|
-
bl = new
|
|
2413
|
-
br = new
|
|
2476
|
+
tl = new import_three9.Vector2(u1, v2);
|
|
2477
|
+
tr = new import_three9.Vector2(u1, v1);
|
|
2478
|
+
bl = new import_three9.Vector2(u2, v2);
|
|
2479
|
+
br = new import_three9.Vector2(u2, v1);
|
|
2414
2480
|
break;
|
|
2415
2481
|
case 180:
|
|
2416
|
-
tl = new
|
|
2417
|
-
tr = new
|
|
2418
|
-
bl = new
|
|
2419
|
-
br = new
|
|
2482
|
+
tl = new import_three9.Vector2(u2, v2);
|
|
2483
|
+
tr = new import_three9.Vector2(u1, v2);
|
|
2484
|
+
bl = new import_three9.Vector2(u2, v1);
|
|
2485
|
+
br = new import_three9.Vector2(u1, v1);
|
|
2420
2486
|
break;
|
|
2421
2487
|
case 270:
|
|
2422
|
-
tl = new
|
|
2423
|
-
tr = new
|
|
2424
|
-
bl = new
|
|
2425
|
-
br = new
|
|
2488
|
+
tl = new import_three9.Vector2(u2, v1);
|
|
2489
|
+
tr = new import_three9.Vector2(u2, v2);
|
|
2490
|
+
bl = new import_three9.Vector2(u1, v1);
|
|
2491
|
+
br = new import_three9.Vector2(u1, v2);
|
|
2426
2492
|
break;
|
|
2427
2493
|
}
|
|
2428
2494
|
return [tl, tr, bl, br];
|
|
@@ -2569,7 +2635,7 @@ var UVMapper = class {
|
|
|
2569
2635
|
const faceTexture = face.texture.substr(1);
|
|
2570
2636
|
const texPosition = positions[faceTexture] || [0, 0];
|
|
2571
2637
|
const texSize = sizes[faceTexture] || [16, 16];
|
|
2572
|
-
let texPosV = new
|
|
2638
|
+
let texPosV = new import_three9.Vector2(texPosition[0], texPosition[1]);
|
|
2573
2639
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
2574
2640
|
tl.add(texPosV);
|
|
2575
2641
|
tr.add(texPosV);
|
|
@@ -2803,7 +2869,7 @@ var BlockEntityModels = class {
|
|
|
2803
2869
|
};
|
|
2804
2870
|
|
|
2805
2871
|
// src/renderer/SceneObject.ts
|
|
2806
|
-
var
|
|
2872
|
+
var import_three10 = require("three");
|
|
2807
2873
|
|
|
2808
2874
|
// src/instance/InstanceReference.ts
|
|
2809
2875
|
var InstanceReference = class {
|
|
@@ -2862,7 +2928,7 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2862
2928
|
// src/renderer/SceneObject.ts
|
|
2863
2929
|
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
2864
2930
|
var p6 = prefix("SceneObject");
|
|
2865
|
-
var _SceneObject = class _SceneObject extends
|
|
2931
|
+
var _SceneObject = class _SceneObject extends import_three10.Object3D {
|
|
2866
2932
|
constructor(options) {
|
|
2867
2933
|
super();
|
|
2868
2934
|
this.isSceneObject = true;
|
|
@@ -2900,7 +2966,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2900
2966
|
return group;
|
|
2901
2967
|
}
|
|
2902
2968
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
2903
|
-
const obj = new
|
|
2969
|
+
const obj = new import_three10.Object3D();
|
|
2904
2970
|
if (name) {
|
|
2905
2971
|
obj.name = `group:${name}`;
|
|
2906
2972
|
}
|
|
@@ -2950,7 +3016,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2950
3016
|
return mesh;
|
|
2951
3017
|
}
|
|
2952
3018
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
2953
|
-
const mesh = new
|
|
3019
|
+
const mesh = new import_three10.Mesh(geometry, material);
|
|
2954
3020
|
if (name) {
|
|
2955
3021
|
mesh.name = `mesh:${name}`;
|
|
2956
3022
|
}
|
|
@@ -2962,7 +3028,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2962
3028
|
return mesh;
|
|
2963
3029
|
}
|
|
2964
3030
|
createInstancedMesh(name, geometry, material, count) {
|
|
2965
|
-
const mesh = new
|
|
3031
|
+
const mesh = new import_three10.InstancedMesh(geometry, material, count);
|
|
2966
3032
|
mesh.count = 0;
|
|
2967
3033
|
if (name) {
|
|
2968
3034
|
mesh.name = `mesh:${name}`;
|
|
@@ -3040,7 +3106,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3040
3106
|
nextInstance() {
|
|
3041
3107
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3042
3108
|
const i = this._instanceCounter++;
|
|
3043
|
-
this.setMatrixAt(i, new
|
|
3109
|
+
this.setMatrixAt(i, new import_three10.Matrix4());
|
|
3044
3110
|
const mesh = this.children[0];
|
|
3045
3111
|
if (mesh && isInstancedMesh(mesh)) {
|
|
3046
3112
|
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
@@ -3057,7 +3123,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3057
3123
|
}
|
|
3058
3124
|
//</editor-fold>
|
|
3059
3125
|
//<editor-fold desc="TRANSFORMATION">
|
|
3060
|
-
getMatrixAt(index, matrix = new
|
|
3126
|
+
getMatrixAt(index, matrix = new import_three10.Matrix4()) {
|
|
3061
3127
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3062
3128
|
const child = this.children[0];
|
|
3063
3129
|
if (child && isInstancedMesh(child)) {
|
|
@@ -3076,16 +3142,16 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3076
3142
|
}
|
|
3077
3143
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3078
3144
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3079
|
-
const oldPosition = new
|
|
3080
|
-
const oldRotation = new
|
|
3081
|
-
const oldScale = new
|
|
3082
|
-
const matrix = new
|
|
3145
|
+
const oldPosition = new import_three10.Vector3();
|
|
3146
|
+
const oldRotation = new import_three10.Quaternion();
|
|
3147
|
+
const oldScale = new import_three10.Vector3();
|
|
3148
|
+
const matrix = new import_three10.Matrix4();
|
|
3083
3149
|
if (!scale || !rotation || !position) {
|
|
3084
3150
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3085
3151
|
}
|
|
3086
3152
|
matrix.compose(
|
|
3087
3153
|
position ? position : oldPosition,
|
|
3088
|
-
rotation ? new
|
|
3154
|
+
rotation ? new import_three10.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3089
3155
|
scale ? scale : oldScale
|
|
3090
3156
|
);
|
|
3091
3157
|
this.setMatrixAt(index, matrix);
|
|
@@ -3094,7 +3160,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3094
3160
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3095
3161
|
this.setPositionRotationScaleAt(index, position);
|
|
3096
3162
|
}
|
|
3097
|
-
getPositionAt(index, vector = new
|
|
3163
|
+
getPositionAt(index, vector = new import_three10.Vector3()) {
|
|
3098
3164
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3099
3165
|
const matrix = this.getMatrixAt(index);
|
|
3100
3166
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3104,7 +3170,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3104
3170
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3105
3171
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3106
3172
|
}
|
|
3107
|
-
getRotationAt(index, euler = new
|
|
3173
|
+
getRotationAt(index, euler = new import_three10.Euler()) {
|
|
3108
3174
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3109
3175
|
const matrix = this.getMatrixAt(index);
|
|
3110
3176
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -3114,7 +3180,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3114
3180
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3115
3181
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3116
3182
|
}
|
|
3117
|
-
getScaleAt(index, vector = new
|
|
3183
|
+
getScaleAt(index, vector = new import_three10.Vector3()) {
|
|
3118
3184
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3119
3185
|
const matrix = this.getMatrixAt(index);
|
|
3120
3186
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3236,7 +3302,7 @@ function isSceneObject(obj) {
|
|
|
3236
3302
|
|
|
3237
3303
|
// src/entity/scene/EntityObject.ts
|
|
3238
3304
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
3239
|
-
var
|
|
3305
|
+
var import_three12 = require("three");
|
|
3240
3306
|
var THREE3 = __toESM(require("three"));
|
|
3241
3307
|
var EntityObject = class extends SceneObject {
|
|
3242
3308
|
constructor(entity, options) {
|
|
@@ -3274,7 +3340,7 @@ var EntityObject = class extends SceneObject {
|
|
|
3274
3340
|
for (let partName in this.entity.parts) {
|
|
3275
3341
|
const part = this.entity.parts[partName];
|
|
3276
3342
|
const texture = new MinecraftCubeTexture(part.textureOffsetU, part.textureOffsetV, part.textureWidth, part.textureHeight);
|
|
3277
|
-
const partAnchor = new
|
|
3343
|
+
const partAnchor = new import_three12.Object3D();
|
|
3278
3344
|
partAnchor.position.x = part.pivotX;
|
|
3279
3345
|
partAnchor.position.y = part.pivotY;
|
|
3280
3346
|
partAnchor.position.z = part.pivotZ;
|
|
@@ -3328,16 +3394,16 @@ var GuiObject = class extends SceneObject {
|
|
|
3328
3394
|
};
|
|
3329
3395
|
|
|
3330
3396
|
// src/inspector/SceneInspector.ts
|
|
3331
|
-
var
|
|
3397
|
+
var import_three13 = require("three");
|
|
3332
3398
|
var p7 = prefix("SceneInspector");
|
|
3333
3399
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3334
3400
|
var SceneInspector = class {
|
|
3335
3401
|
constructor(renderer) {
|
|
3336
3402
|
this.renderer = renderer;
|
|
3337
|
-
this.mouse = new
|
|
3403
|
+
this.mouse = new import_three13.Vector2();
|
|
3338
3404
|
this.objectInfoContainer = document.createElement("div");
|
|
3339
3405
|
this.objectControlsContainer = document.createElement("div");
|
|
3340
|
-
this.raycaster = new
|
|
3406
|
+
this.raycaster = new import_three13.Raycaster();
|
|
3341
3407
|
this.init();
|
|
3342
3408
|
}
|
|
3343
3409
|
init() {
|
|
@@ -3740,20 +3806,6 @@ function isInstanceable(obj) {
|
|
|
3740
3806
|
return "nextInstance" in obj;
|
|
3741
3807
|
}
|
|
3742
3808
|
|
|
3743
|
-
// src/model/DisplayPosition.ts
|
|
3744
|
-
var DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
|
|
3745
|
-
DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
3746
|
-
DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
3747
|
-
DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
3748
|
-
DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
3749
|
-
DisplayPosition2["GUI"] = "gui";
|
|
3750
|
-
DisplayPosition2["HEAD"] = "head";
|
|
3751
|
-
DisplayPosition2["GROUND"] = "ground";
|
|
3752
|
-
DisplayPosition2["FIXED"] = "fixed";
|
|
3753
|
-
return DisplayPosition2;
|
|
3754
|
-
})(DisplayPosition || {});
|
|
3755
|
-
var DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
3756
|
-
|
|
3757
3809
|
// src/model/GuiLight.ts
|
|
3758
3810
|
var GuiLight = /* @__PURE__ */ ((GuiLight2) => {
|
|
3759
3811
|
GuiLight2["FRONT"] = "front";
|
|
@@ -3776,11 +3828,96 @@ function isQuadArray(obj) {
|
|
|
3776
3828
|
return Array.isArray(obj) && obj.length === 4;
|
|
3777
3829
|
}
|
|
3778
3830
|
|
|
3831
|
+
// src/model/block/blockTints.json
|
|
3832
|
+
var blockTints_default = {
|
|
3833
|
+
"minecraft:large_fern": { source: "grass" },
|
|
3834
|
+
"minecraft:tall_grass": { source: "grass" },
|
|
3835
|
+
"minecraft:grass_block": { source: "grass" },
|
|
3836
|
+
"minecraft:fern": { source: "grass" },
|
|
3837
|
+
"minecraft:grass": { source: "grass" },
|
|
3838
|
+
"minecraft:short_grass": { source: "grass" },
|
|
3839
|
+
"minecraft:potted_fern": { source: "grass" },
|
|
3840
|
+
"minecraft:bush": { source: "grass" },
|
|
3841
|
+
"minecraft:pink_petals": { source: "grass", untinted: [0] },
|
|
3842
|
+
"minecraft:wildflowers": { source: "grass", untinted: [0] },
|
|
3843
|
+
"minecraft:spruce_leaves": { source: "constant", color: 6396257 },
|
|
3844
|
+
"minecraft:birch_leaves": { source: "constant", color: 8431445 },
|
|
3845
|
+
"minecraft:oak_leaves": { source: "constant", color: 4764952 },
|
|
3846
|
+
"minecraft:jungle_leaves": { source: "constant", color: 4764952 },
|
|
3847
|
+
"minecraft:acacia_leaves": { source: "constant", color: 4764952 },
|
|
3848
|
+
"minecraft:dark_oak_leaves": { source: "constant", color: 4764952 },
|
|
3849
|
+
"minecraft:vine": { source: "constant", color: 4764952 },
|
|
3850
|
+
"minecraft:mangrove_leaves": { source: "constant", color: 4764952 },
|
|
3851
|
+
"minecraft:leaf_litter": { source: "constant", color: 6044722 },
|
|
3852
|
+
"minecraft:water_cauldron": { source: "constant", color: 4159204 },
|
|
3853
|
+
"minecraft:redstone_wire": { source: "redstone" },
|
|
3854
|
+
"minecraft:attached_melon_stem": { source: "constant", color: 14731036 },
|
|
3855
|
+
"minecraft:attached_pumpkin_stem": { source: "constant", color: 14731036 },
|
|
3856
|
+
"minecraft:melon_stem": { source: "stem" },
|
|
3857
|
+
"minecraft:pumpkin_stem": { source: "stem" },
|
|
3858
|
+
"minecraft:lily_pad": { source: "constant", color: 7455580 }
|
|
3859
|
+
};
|
|
3860
|
+
|
|
3861
|
+
// src/model/block/BlockTints.ts
|
|
3862
|
+
var rules = blockTints_default;
|
|
3863
|
+
var BlockTints = class {
|
|
3864
|
+
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
3865
|
+
static async get(key, state, model, tints) {
|
|
3866
|
+
const rule = key && rules[key.toNamespacedString()];
|
|
3867
|
+
if (!key || !rule) return tints;
|
|
3868
|
+
const indices = /* @__PURE__ */ new Set();
|
|
3869
|
+
for (const element of model.elements ?? []) {
|
|
3870
|
+
for (const face of Object.values(element.faces)) {
|
|
3871
|
+
const index = face?.tintindex;
|
|
3872
|
+
if (index !== void 0 && index >= 0 && tints?.[index] === void 0 && !rule.untinted?.includes(index)) {
|
|
3873
|
+
indices.add(index);
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
if (!indices.size) return tints;
|
|
3878
|
+
let color;
|
|
3879
|
+
switch (rule.source) {
|
|
3880
|
+
case "constant":
|
|
3881
|
+
color = rule.color;
|
|
3882
|
+
break;
|
|
3883
|
+
case "grass":
|
|
3884
|
+
color = await this.grassColor(key);
|
|
3885
|
+
break;
|
|
3886
|
+
case "redstone": {
|
|
3887
|
+
const power = Number(state.power ?? 0) / 15;
|
|
3888
|
+
const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
|
|
3889
|
+
const green = Math.max(0, power * power * 0.7 - 0.5);
|
|
3890
|
+
const blue = Math.max(0, power * power * 0.6 - 0.7);
|
|
3891
|
+
color = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
|
|
3892
|
+
break;
|
|
3893
|
+
}
|
|
3894
|
+
case "stem": {
|
|
3895
|
+
const age = Number(state.age ?? 0);
|
|
3896
|
+
color = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
|
|
3897
|
+
break;
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
|
|
3901
|
+
}
|
|
3902
|
+
static async grassColor(origin) {
|
|
3903
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
3904
|
+
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
3905
|
+
const image = await ModelTextures.get(key);
|
|
3906
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
3907
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
3908
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
3909
|
+
}
|
|
3910
|
+
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
3911
|
+
return red << 16 | green << 8 | blue;
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
|
|
3779
3916
|
// src/model/scene/ModelObject.ts
|
|
3780
|
-
var
|
|
3917
|
+
var import_three16 = require("three");
|
|
3781
3918
|
|
|
3782
3919
|
// src/three/BufferGeometryUtils.js
|
|
3783
|
-
var
|
|
3920
|
+
var import_three15 = require("three");
|
|
3784
3921
|
function computeTangents(geometry) {
|
|
3785
3922
|
geometry.computeTangents();
|
|
3786
3923
|
console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
|
|
@@ -3792,7 +3929,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3792
3929
|
const attributes = {};
|
|
3793
3930
|
const morphAttributes = {};
|
|
3794
3931
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3795
|
-
const mergedGeometry = new
|
|
3932
|
+
const mergedGeometry = new import_three15.BufferGeometry();
|
|
3796
3933
|
let offset = 0;
|
|
3797
3934
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3798
3935
|
const geometry = geometries[i];
|
|
@@ -3916,7 +4053,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
3916
4053
|
array.set(attributes[i].array, offset);
|
|
3917
4054
|
offset += attributes[i].array.length;
|
|
3918
4055
|
}
|
|
3919
|
-
return new
|
|
4056
|
+
return new import_three15.BufferAttribute(array, itemSize, normalized);
|
|
3920
4057
|
}
|
|
3921
4058
|
function interleaveAttributes(attributes) {
|
|
3922
4059
|
let TypedArray;
|
|
@@ -3932,7 +4069,7 @@ function interleaveAttributes(attributes) {
|
|
|
3932
4069
|
arrayLength += attribute.array.length;
|
|
3933
4070
|
stride += attribute.itemSize;
|
|
3934
4071
|
}
|
|
3935
|
-
const interleavedBuffer = new
|
|
4072
|
+
const interleavedBuffer = new import_three15.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
3936
4073
|
let offset = 0;
|
|
3937
4074
|
const res = [];
|
|
3938
4075
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -3941,7 +4078,7 @@ function interleaveAttributes(attributes) {
|
|
|
3941
4078
|
const attribute = attributes[j];
|
|
3942
4079
|
const itemSize = attribute.itemSize;
|
|
3943
4080
|
const count = attribute.count;
|
|
3944
|
-
const iba = new
|
|
4081
|
+
const iba = new import_three15.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
3945
4082
|
res.push(iba);
|
|
3946
4083
|
offset += itemSize;
|
|
3947
4084
|
for (let c = 0; c < count; c++) {
|
|
@@ -4025,13 +4162,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4025
4162
|
const name = attributeNames[i];
|
|
4026
4163
|
const oldAttribute = geometry.getAttribute(name);
|
|
4027
4164
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4028
|
-
const attribute = new
|
|
4165
|
+
const attribute = new import_three15.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4029
4166
|
result.setAttribute(name, attribute);
|
|
4030
4167
|
if (name in morphAttrsArrays) {
|
|
4031
4168
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4032
4169
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4033
4170
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4034
|
-
const morphAttribute = new
|
|
4171
|
+
const morphAttribute = new import_three15.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4035
4172
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4036
4173
|
}
|
|
4037
4174
|
}
|
|
@@ -4040,11 +4177,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4040
4177
|
return result;
|
|
4041
4178
|
}
|
|
4042
4179
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4043
|
-
if (drawMode ===
|
|
4180
|
+
if (drawMode === import_three15.TrianglesDrawMode) {
|
|
4044
4181
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4045
4182
|
return geometry;
|
|
4046
4183
|
}
|
|
4047
|
-
if (drawMode ===
|
|
4184
|
+
if (drawMode === import_three15.TriangleFanDrawMode || drawMode === import_three15.TriangleStripDrawMode) {
|
|
4048
4185
|
let index = geometry.getIndex();
|
|
4049
4186
|
if (index === null) {
|
|
4050
4187
|
const indices = [];
|
|
@@ -4062,7 +4199,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4062
4199
|
}
|
|
4063
4200
|
const numberOfTriangles = index.count - 2;
|
|
4064
4201
|
const newIndices = [];
|
|
4065
|
-
if (drawMode ===
|
|
4202
|
+
if (drawMode === import_three15.TriangleFanDrawMode) {
|
|
4066
4203
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4067
4204
|
newIndices.push(index.getX(0));
|
|
4068
4205
|
newIndices.push(index.getX(i));
|
|
@@ -4098,15 +4235,15 @@ function computeMorphedAttributes(object) {
|
|
|
4098
4235
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4099
4236
|
return null;
|
|
4100
4237
|
}
|
|
4101
|
-
const _vA = new
|
|
4102
|
-
const _vB = new
|
|
4103
|
-
const _vC = new
|
|
4104
|
-
const _tempA = new
|
|
4105
|
-
const _tempB = new
|
|
4106
|
-
const _tempC = new
|
|
4107
|
-
const _morphA = new
|
|
4108
|
-
const _morphB = new
|
|
4109
|
-
const _morphC = new
|
|
4238
|
+
const _vA = new import_three15.Vector3();
|
|
4239
|
+
const _vB = new import_three15.Vector3();
|
|
4240
|
+
const _vC = new import_three15.Vector3();
|
|
4241
|
+
const _tempA = new import_three15.Vector3();
|
|
4242
|
+
const _tempB = new import_three15.Vector3();
|
|
4243
|
+
const _tempC = new import_three15.Vector3();
|
|
4244
|
+
const _morphA = new import_three15.Vector3();
|
|
4245
|
+
const _morphB = new import_three15.Vector3();
|
|
4246
|
+
const _morphC = new import_three15.Vector3();
|
|
4110
4247
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4111
4248
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4112
4249
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4301,8 +4438,8 @@ function computeMorphedAttributes(object) {
|
|
|
4301
4438
|
}
|
|
4302
4439
|
}
|
|
4303
4440
|
}
|
|
4304
|
-
const morphedPositionAttribute = new
|
|
4305
|
-
const morphedNormalAttribute = new
|
|
4441
|
+
const morphedPositionAttribute = new import_three15.Float32BufferAttribute(modifiedPosition, 3);
|
|
4442
|
+
const morphedNormalAttribute = new import_three15.Float32BufferAttribute(modifiedNormal, 3);
|
|
4306
4443
|
return {
|
|
4307
4444
|
positionAttribute,
|
|
4308
4445
|
normalAttribute,
|
|
@@ -4343,13 +4480,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4343
4480
|
createMeshes(force = false) {
|
|
4344
4481
|
if (this.meshesCreated && !force) return;
|
|
4345
4482
|
const mat = Materials.MISSING_TEXTURE;
|
|
4483
|
+
const displayTransform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : void 0;
|
|
4346
4484
|
let allGeos = [];
|
|
4347
4485
|
if (this.atlas) {
|
|
4348
4486
|
if (this.atlas.model.elements) {
|
|
4349
4487
|
this.atlas.model.elements?.forEach((el) => {
|
|
4350
4488
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4351
4489
|
if (this.options.uvLockRotation) {
|
|
4352
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4490
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three16.Euler(...this.options.uvLockRotation));
|
|
4353
4491
|
}
|
|
4354
4492
|
if (this.options.tints) {
|
|
4355
4493
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4358,19 +4496,20 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4358
4496
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4359
4497
|
const tint = this.options.tints[tintIndex];
|
|
4360
4498
|
if (tint === void 0) continue;
|
|
4361
|
-
const color = new
|
|
4499
|
+
const color = new import_three16.Color(tint);
|
|
4362
4500
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4363
4501
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4364
4502
|
}
|
|
4365
4503
|
}
|
|
4366
|
-
elGeo.setAttribute("color", new
|
|
4504
|
+
elGeo.setAttribute("color", new import_three16.BufferAttribute(colors, 3));
|
|
4367
4505
|
}
|
|
4368
|
-
elGeo.applyMatrix4(new
|
|
4369
|
-
elGeo.applyMatrix4(new
|
|
4506
|
+
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));
|
|
4507
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4370
4508
|
if (el.rotation) {
|
|
4371
4509
|
applyElementRotation(el.rotation, elGeo);
|
|
4372
4510
|
}
|
|
4373
|
-
elGeo.applyMatrix4(new
|
|
4511
|
+
elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(-8, -8, -8));
|
|
4512
|
+
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4374
4513
|
if (this.options.mergeMeshes) {
|
|
4375
4514
|
allGeos.push(elGeo);
|
|
4376
4515
|
} else {
|
|
@@ -4391,7 +4530,8 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4391
4530
|
if (allGeos.length > 0) {
|
|
4392
4531
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4393
4532
|
} else {
|
|
4394
|
-
combinedGeo = new
|
|
4533
|
+
combinedGeo = new import_three16.BoxGeometry(16, 16, 16);
|
|
4534
|
+
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4395
4535
|
}
|
|
4396
4536
|
combinedGeo.computeBoundingBox();
|
|
4397
4537
|
let mesh;
|
|
@@ -4445,7 +4585,7 @@ function isModelObject(obj) {
|
|
|
4445
4585
|
|
|
4446
4586
|
// src/model/block/scene/BlockObject.ts
|
|
4447
4587
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4448
|
-
var
|
|
4588
|
+
var import_three17 = require("three");
|
|
4449
4589
|
var p10 = prefix("BlockObject");
|
|
4450
4590
|
function matchesCondition(condition, state) {
|
|
4451
4591
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4502,7 +4642,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4502
4642
|
if (isModelObject(model)) {
|
|
4503
4643
|
model.removeFromScene();
|
|
4504
4644
|
} else if (isInstanceReference(model)) {
|
|
4505
|
-
model.setScale(new
|
|
4645
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4506
4646
|
}
|
|
4507
4647
|
}
|
|
4508
4648
|
super.removeFromScene();
|
|
@@ -4563,7 +4703,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4563
4703
|
}
|
|
4564
4704
|
for (let model of this._models) {
|
|
4565
4705
|
if (isInstanceReference(model)) {
|
|
4566
|
-
model.setScale(new
|
|
4706
|
+
model.setScale(new import_three17.Vector3(0, 0, 0));
|
|
4567
4707
|
} else {
|
|
4568
4708
|
model.dispose();
|
|
4569
4709
|
}
|
|
@@ -4600,7 +4740,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4600
4740
|
await this.createVariant(variant);
|
|
4601
4741
|
}
|
|
4602
4742
|
async createVariant(variant) {
|
|
4603
|
-
const rotation = new
|
|
4743
|
+
const rotation = new import_three17.Euler();
|
|
4604
4744
|
if (typeof variant.x !== "undefined") {
|
|
4605
4745
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4606
4746
|
}
|
|
@@ -4610,6 +4750,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4610
4750
|
const model = await Models.getMerged(AssetKey.parse("models", variant.model));
|
|
4611
4751
|
const options = {
|
|
4612
4752
|
...this.options,
|
|
4753
|
+
tints: model ? await BlockTints.get(this.blockState.key, this.state, model, this.options.tints) : this.options.tints,
|
|
4613
4754
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
4614
4755
|
};
|
|
4615
4756
|
const obj = await this.scene.addModel(model, options);
|
|
@@ -4686,7 +4827,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4686
4827
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4687
4828
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4688
4829
|
}
|
|
4689
|
-
getMatrixAt(index, matrix = new
|
|
4830
|
+
getMatrixAt(index, matrix = new import_three17.Matrix4()) {
|
|
4690
4831
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4691
4832
|
const child = this._models[0];
|
|
4692
4833
|
if (child && isModelObject(child)) {
|
|
@@ -4765,7 +4906,7 @@ var StructureParser = class {
|
|
|
4765
4906
|
};
|
|
4766
4907
|
|
|
4767
4908
|
// src/renderer/MineRenderScene.ts
|
|
4768
|
-
var
|
|
4909
|
+
var import_three18 = require("three");
|
|
4769
4910
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4770
4911
|
|
|
4771
4912
|
// src/skin/SkinPart.ts
|
|
@@ -5609,7 +5750,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5609
5750
|
};
|
|
5610
5751
|
|
|
5611
5752
|
// src/renderer/MineRenderScene.ts
|
|
5612
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
5753
|
+
var _MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
5613
5754
|
constructor(options) {
|
|
5614
5755
|
super();
|
|
5615
5756
|
this.isMineRenderScene = true;
|
|
@@ -5682,7 +5823,8 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5682
5823
|
console.log("instanceMeshes + key");
|
|
5683
5824
|
let key = asset.key.serialize();
|
|
5684
5825
|
if (isModelObject(obj)) {
|
|
5685
|
-
const { uvLockRotation, tints } = obj.options;
|
|
5826
|
+
const { displayPosition, uvLockRotation, tints } = obj.options;
|
|
5827
|
+
if (displayPosition) key += `|display:${displayPosition}`;
|
|
5686
5828
|
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
5687
5829
|
const palette = Object.entries(tints ?? {}).sort(([a], [b]) => Number(a) - Number(b));
|
|
5688
5830
|
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
@@ -5731,17 +5873,17 @@ function isMineRenderScene(obj) {
|
|
|
5731
5873
|
}
|
|
5732
5874
|
|
|
5733
5875
|
// src/renderer/Renderer.ts
|
|
5734
|
-
var
|
|
5876
|
+
var import_three20 = require("three");
|
|
5735
5877
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5736
5878
|
var import_stats = __toESM(require("stats.js"));
|
|
5737
5879
|
var import_postprocessing = require("postprocessing");
|
|
5738
5880
|
|
|
5739
5881
|
// src/three/OrbitControls.js
|
|
5740
|
-
var
|
|
5882
|
+
var import_three19 = require("three");
|
|
5741
5883
|
var _changeEvent = { type: "change" };
|
|
5742
5884
|
var _startEvent = { type: "start" };
|
|
5743
5885
|
var _endEvent = { type: "end" };
|
|
5744
|
-
var OrbitControls = class extends
|
|
5886
|
+
var OrbitControls = class extends import_three19.EventDispatcher {
|
|
5745
5887
|
constructor(object, domElement) {
|
|
5746
5888
|
super();
|
|
5747
5889
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5750,7 +5892,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5750
5892
|
this.domElement = domElement;
|
|
5751
5893
|
this.domElement.style.touchAction = "none";
|
|
5752
5894
|
this.enabled = true;
|
|
5753
|
-
this.target = new
|
|
5895
|
+
this.target = new import_three19.Vector3();
|
|
5754
5896
|
this.minDistance = 0;
|
|
5755
5897
|
this.maxDistance = Infinity;
|
|
5756
5898
|
this.minZoom = 0;
|
|
@@ -5772,8 +5914,8 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5772
5914
|
this.autoRotate = false;
|
|
5773
5915
|
this.autoRotateSpeed = 2;
|
|
5774
5916
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5775
|
-
this.mouseButtons = { LEFT:
|
|
5776
|
-
this.touches = { ONE:
|
|
5917
|
+
this.mouseButtons = { LEFT: import_three19.MOUSE.ROTATE, MIDDLE: import_three19.MOUSE.DOLLY, RIGHT: import_three19.MOUSE.PAN };
|
|
5918
|
+
this.touches = { ONE: import_three19.TOUCH.ROTATE, TWO: import_three19.TOUCH.DOLLY_PAN };
|
|
5777
5919
|
this.target0 = this.target.clone();
|
|
5778
5920
|
this.position0 = this.object.position.clone();
|
|
5779
5921
|
this.zoom0 = this.object.zoom;
|
|
@@ -5802,11 +5944,11 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5802
5944
|
state = STATE.NONE;
|
|
5803
5945
|
};
|
|
5804
5946
|
this.update = function() {
|
|
5805
|
-
const offset = new
|
|
5806
|
-
const quat = new
|
|
5947
|
+
const offset = new import_three19.Vector3();
|
|
5948
|
+
const quat = new import_three19.Quaternion().setFromUnitVectors(object.up, new import_three19.Vector3(0, 1, 0));
|
|
5807
5949
|
const quatInverse = quat.clone().invert();
|
|
5808
|
-
const lastPosition = new
|
|
5809
|
-
const lastQuaternion = new
|
|
5950
|
+
const lastPosition = new import_three19.Vector3();
|
|
5951
|
+
const lastQuaternion = new import_three19.Quaternion();
|
|
5810
5952
|
const twoPI = 2 * Math.PI;
|
|
5811
5953
|
return function update() {
|
|
5812
5954
|
const position = scope.object.position;
|
|
@@ -5892,20 +6034,20 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5892
6034
|
};
|
|
5893
6035
|
let state = STATE.NONE;
|
|
5894
6036
|
const EPS = 1e-6;
|
|
5895
|
-
const spherical = new
|
|
5896
|
-
const sphericalDelta = new
|
|
6037
|
+
const spherical = new import_three19.Spherical();
|
|
6038
|
+
const sphericalDelta = new import_three19.Spherical();
|
|
5897
6039
|
let scale = 1;
|
|
5898
|
-
const panOffset = new
|
|
6040
|
+
const panOffset = new import_three19.Vector3();
|
|
5899
6041
|
let zoomChanged = false;
|
|
5900
|
-
const rotateStart = new
|
|
5901
|
-
const rotateEnd = new
|
|
5902
|
-
const rotateDelta = new
|
|
5903
|
-
const panStart = new
|
|
5904
|
-
const panEnd = new
|
|
5905
|
-
const panDelta = new
|
|
5906
|
-
const dollyStart = new
|
|
5907
|
-
const dollyEnd = new
|
|
5908
|
-
const dollyDelta = new
|
|
6042
|
+
const rotateStart = new import_three19.Vector2();
|
|
6043
|
+
const rotateEnd = new import_three19.Vector2();
|
|
6044
|
+
const rotateDelta = new import_three19.Vector2();
|
|
6045
|
+
const panStart = new import_three19.Vector2();
|
|
6046
|
+
const panEnd = new import_three19.Vector2();
|
|
6047
|
+
const panDelta = new import_three19.Vector2();
|
|
6048
|
+
const dollyStart = new import_three19.Vector2();
|
|
6049
|
+
const dollyEnd = new import_three19.Vector2();
|
|
6050
|
+
const dollyDelta = new import_three19.Vector2();
|
|
5909
6051
|
const pointers = [];
|
|
5910
6052
|
const pointerPositions = {};
|
|
5911
6053
|
function getAutoRotationAngle() {
|
|
@@ -5921,7 +6063,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5921
6063
|
sphericalDelta.phi -= angle;
|
|
5922
6064
|
}
|
|
5923
6065
|
const panLeft = function() {
|
|
5924
|
-
const v = new
|
|
6066
|
+
const v = new import_three19.Vector3();
|
|
5925
6067
|
return function panLeft2(distance, objectMatrix) {
|
|
5926
6068
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5927
6069
|
v.multiplyScalar(-distance);
|
|
@@ -5929,7 +6071,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5929
6071
|
};
|
|
5930
6072
|
}();
|
|
5931
6073
|
const panUp = function() {
|
|
5932
|
-
const v = new
|
|
6074
|
+
const v = new import_three19.Vector3();
|
|
5933
6075
|
return function panUp2(distance, objectMatrix) {
|
|
5934
6076
|
if (scope.screenSpacePanning === true) {
|
|
5935
6077
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5942,7 +6084,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
5942
6084
|
};
|
|
5943
6085
|
}();
|
|
5944
6086
|
const pan = function() {
|
|
5945
|
-
const offset = new
|
|
6087
|
+
const offset = new import_three19.Vector3();
|
|
5946
6088
|
return function pan2(deltaX, deltaY) {
|
|
5947
6089
|
const element = scope.domElement;
|
|
5948
6090
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6191,12 +6333,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6191
6333
|
mouseAction = -1;
|
|
6192
6334
|
}
|
|
6193
6335
|
switch (mouseAction) {
|
|
6194
|
-
case
|
|
6336
|
+
case import_three19.MOUSE.DOLLY:
|
|
6195
6337
|
if (scope.enableZoom === false) return;
|
|
6196
6338
|
handleMouseDownDolly(event);
|
|
6197
6339
|
state = STATE.DOLLY;
|
|
6198
6340
|
break;
|
|
6199
|
-
case
|
|
6341
|
+
case import_three19.MOUSE.ROTATE:
|
|
6200
6342
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6201
6343
|
if (scope.enablePan === false) return;
|
|
6202
6344
|
handleMouseDownPan(event);
|
|
@@ -6207,7 +6349,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6207
6349
|
state = STATE.ROTATE;
|
|
6208
6350
|
}
|
|
6209
6351
|
break;
|
|
6210
|
-
case
|
|
6352
|
+
case import_three19.MOUSE.PAN:
|
|
6211
6353
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6212
6354
|
if (scope.enableRotate === false) return;
|
|
6213
6355
|
handleMouseDownRotate(event);
|
|
@@ -6263,12 +6405,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6263
6405
|
switch (pointers.length) {
|
|
6264
6406
|
case 1:
|
|
6265
6407
|
switch (scope.touches.ONE) {
|
|
6266
|
-
case
|
|
6408
|
+
case import_three19.TOUCH.ROTATE:
|
|
6267
6409
|
if (scope.enableRotate === false) return;
|
|
6268
6410
|
handleTouchStartRotate();
|
|
6269
6411
|
state = STATE.TOUCH_ROTATE;
|
|
6270
6412
|
break;
|
|
6271
|
-
case
|
|
6413
|
+
case import_three19.TOUCH.PAN:
|
|
6272
6414
|
if (scope.enablePan === false) return;
|
|
6273
6415
|
handleTouchStartPan();
|
|
6274
6416
|
state = STATE.TOUCH_PAN;
|
|
@@ -6279,12 +6421,12 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6279
6421
|
break;
|
|
6280
6422
|
case 2:
|
|
6281
6423
|
switch (scope.touches.TWO) {
|
|
6282
|
-
case
|
|
6424
|
+
case import_three19.TOUCH.DOLLY_PAN:
|
|
6283
6425
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6284
6426
|
handleTouchStartDollyPan();
|
|
6285
6427
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6286
6428
|
break;
|
|
6287
|
-
case
|
|
6429
|
+
case import_three19.TOUCH.DOLLY_ROTATE:
|
|
6288
6430
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6289
6431
|
handleTouchStartDollyRotate();
|
|
6290
6432
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6351,7 +6493,7 @@ var OrbitControls = class extends import_three18.EventDispatcher {
|
|
|
6351
6493
|
function trackPointer(event) {
|
|
6352
6494
|
let position = pointerPositions[event.pointerId];
|
|
6353
6495
|
if (position === void 0) {
|
|
6354
|
-
position = new
|
|
6496
|
+
position = new import_three19.Vector2();
|
|
6355
6497
|
pointerPositions[event.pointerId] = position;
|
|
6356
6498
|
}
|
|
6357
6499
|
position.set(event.pageX, event.pageY);
|
|
@@ -6371,10 +6513,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6371
6513
|
constructor(object, domElement) {
|
|
6372
6514
|
super(object, domElement);
|
|
6373
6515
|
this.screenSpacePanning = false;
|
|
6374
|
-
this.mouseButtons.LEFT =
|
|
6375
|
-
this.mouseButtons.RIGHT =
|
|
6376
|
-
this.touches.ONE =
|
|
6377
|
-
this.touches.TWO =
|
|
6516
|
+
this.mouseButtons.LEFT = import_three19.MOUSE.PAN;
|
|
6517
|
+
this.mouseButtons.RIGHT = import_three19.MOUSE.ROTATE;
|
|
6518
|
+
this.touches.ONE = import_three19.TOUCH.PAN;
|
|
6519
|
+
this.touches.TWO = import_three19.TOUCH.DOLLY_ROTATE;
|
|
6378
6520
|
}
|
|
6379
6521
|
};
|
|
6380
6522
|
|
|
@@ -6411,14 +6553,14 @@ var _Renderer = class _Renderer {
|
|
|
6411
6553
|
switch (this.options.camera.type) {
|
|
6412
6554
|
case "perspective":
|
|
6413
6555
|
default:
|
|
6414
|
-
return new
|
|
6556
|
+
return new import_three20.PerspectiveCamera(
|
|
6415
6557
|
this.options.camera.perspective.fov,
|
|
6416
6558
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6417
6559
|
this.options.camera.near,
|
|
6418
6560
|
this.options.camera.far
|
|
6419
6561
|
);
|
|
6420
6562
|
case "orthographic":
|
|
6421
|
-
return new
|
|
6563
|
+
return new import_three20.OrthographicCamera(
|
|
6422
6564
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6423
6565
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6424
6566
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6429,7 +6571,7 @@ var _Renderer = class _Renderer {
|
|
|
6429
6571
|
}
|
|
6430
6572
|
}
|
|
6431
6573
|
createRenderer() {
|
|
6432
|
-
const renderer = new
|
|
6574
|
+
const renderer = new import_three20.WebGLRenderer({
|
|
6433
6575
|
antialias: this.options.render.antialias,
|
|
6434
6576
|
alpha: true,
|
|
6435
6577
|
powerPreference: "high-performance",
|
|
@@ -6437,8 +6579,8 @@ var _Renderer = class _Renderer {
|
|
|
6437
6579
|
});
|
|
6438
6580
|
renderer.setClearColor(0, 0);
|
|
6439
6581
|
renderer.shadowMap.enabled = true;
|
|
6440
|
-
renderer.shadowMap.type =
|
|
6441
|
-
renderer.outputColorSpace =
|
|
6582
|
+
renderer.shadowMap.type = import_three20.PCFSoftShadowMap;
|
|
6583
|
+
renderer.outputColorSpace = import_three20.SRGBColorSpace;
|
|
6442
6584
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6443
6585
|
return renderer;
|
|
6444
6586
|
}
|
|
@@ -6472,20 +6614,20 @@ var _Renderer = class _Renderer {
|
|
|
6472
6614
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6473
6615
|
}
|
|
6474
6616
|
if (this.options.debug.grid) {
|
|
6475
|
-
const gridHelper = new
|
|
6617
|
+
const gridHelper = new import_three20.GridHelper(128, 16);
|
|
6476
6618
|
this._debugHelpers.push(gridHelper);
|
|
6477
6619
|
this.scene.add(gridHelper);
|
|
6478
|
-
const gridHelper2 = new
|
|
6620
|
+
const gridHelper2 = new import_three20.GridHelper(128, 16);
|
|
6479
6621
|
this._debugHelpers.push(gridHelper2);
|
|
6480
6622
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6481
6623
|
this.scene.add(gridHelper2);
|
|
6482
|
-
const gridHelper3 = new
|
|
6624
|
+
const gridHelper3 = new import_three20.GridHelper(128, 16);
|
|
6483
6625
|
this._debugHelpers.push(gridHelper3);
|
|
6484
6626
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6485
6627
|
this.scene.add(gridHelper3);
|
|
6486
6628
|
}
|
|
6487
6629
|
if (this.options.debug.axes) {
|
|
6488
|
-
const axesHelper = new
|
|
6630
|
+
const axesHelper = new import_three20.AxesHelper(64);
|
|
6489
6631
|
this._debugHelpers.push(axesHelper);
|
|
6490
6632
|
this.scene.add(axesHelper);
|
|
6491
6633
|
}
|
|
@@ -6689,8 +6831,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6689
6831
|
top: void 0,
|
|
6690
6832
|
bottom: void 0
|
|
6691
6833
|
},
|
|
6692
|
-
position: new
|
|
6693
|
-
lookingAt: new
|
|
6834
|
+
position: new import_three20.Vector3(50, 50, 50),
|
|
6835
|
+
lookingAt: new import_three20.Vector3(0, 0, 0)
|
|
6694
6836
|
},
|
|
6695
6837
|
render: {
|
|
6696
6838
|
fpsLimit: 60,
|
|
@@ -6884,10 +7026,10 @@ var Skins = class {
|
|
|
6884
7026
|
};
|
|
6885
7027
|
|
|
6886
7028
|
// src/world/Chunk.ts
|
|
6887
|
-
var
|
|
7029
|
+
var import_three23 = require("three");
|
|
6888
7030
|
|
|
6889
7031
|
// src/world/MineRenderWorld.ts
|
|
6890
|
-
var
|
|
7032
|
+
var import_three22 = require("three");
|
|
6891
7033
|
var MineRenderWorld = class {
|
|
6892
7034
|
constructor(scene) {
|
|
6893
7035
|
this._size = 4;
|
|
@@ -6898,10 +7040,10 @@ var MineRenderWorld = class {
|
|
|
6898
7040
|
}
|
|
6899
7041
|
getBlockAt(posOrX, y, z) {
|
|
6900
7042
|
if (typeof posOrX == "number") {
|
|
6901
|
-
return this.getBlockAt(new
|
|
7043
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX, y, z));
|
|
6902
7044
|
}
|
|
6903
7045
|
if (isTripleArray(posOrX)) {
|
|
6904
|
-
return this.getBlockAt(new
|
|
7046
|
+
return this.getBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
6905
7047
|
}
|
|
6906
7048
|
const chunk = this.getChunkAt(posOrX);
|
|
6907
7049
|
if (typeof chunk === "undefined") {
|
|
@@ -6912,10 +7054,10 @@ var MineRenderWorld = class {
|
|
|
6912
7054
|
}
|
|
6913
7055
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6914
7056
|
if (typeof posOrX == "number") {
|
|
6915
|
-
return this.setBlockAt(new
|
|
7057
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX, yOrBlock, z), block);
|
|
6916
7058
|
}
|
|
6917
7059
|
if (isTripleArray(posOrX)) {
|
|
6918
|
-
return this.setBlockAt(new
|
|
7060
|
+
return this.setBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6919
7061
|
}
|
|
6920
7062
|
this.validatePosBounds(posOrX);
|
|
6921
7063
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6961,14 +7103,14 @@ var MineRenderWorld = class {
|
|
|
6961
7103
|
return this._chunks[index];
|
|
6962
7104
|
}
|
|
6963
7105
|
static worldToScenePosition(pos) {
|
|
6964
|
-
return new
|
|
7106
|
+
return new import_three22.Vector3(
|
|
6965
7107
|
pos.x * 16,
|
|
6966
7108
|
pos.y * 16,
|
|
6967
7109
|
pos.z * 16
|
|
6968
7110
|
);
|
|
6969
7111
|
}
|
|
6970
7112
|
static sceneToWorldPosition(pos) {
|
|
6971
|
-
return new
|
|
7113
|
+
return new import_three22.Vector3(
|
|
6972
7114
|
pos.x / 16,
|
|
6973
7115
|
pos.y / 16,
|
|
6974
7116
|
pos.z / 16
|
|
@@ -7005,12 +7147,12 @@ var Chunk = class _Chunk {
|
|
|
7005
7147
|
this.x = x;
|
|
7006
7148
|
this.y = y;
|
|
7007
7149
|
this.z = z;
|
|
7008
|
-
let anchor = new
|
|
7150
|
+
let anchor = new import_three23.Object3D();
|
|
7009
7151
|
this._anchor = anchor;
|
|
7010
7152
|
scene.add(anchor);
|
|
7011
7153
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7012
7154
|
addBox3WireframeToObject(
|
|
7013
|
-
new
|
|
7155
|
+
new import_three23.Box3(new import_three23.Vector3(0, 0, 0), new import_three23.Vector3(256, 256, 256)),
|
|
7014
7156
|
anchor,
|
|
7015
7157
|
16776960,
|
|
7016
7158
|
4
|
|
@@ -7018,10 +7160,10 @@ var Chunk = class _Chunk {
|
|
|
7018
7160
|
}
|
|
7019
7161
|
getBlockAt(posOrX, y, z) {
|
|
7020
7162
|
if (typeof posOrX == "number") {
|
|
7021
|
-
return this.getBlockAt(new
|
|
7163
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7022
7164
|
}
|
|
7023
7165
|
if (isTripleArray(posOrX)) {
|
|
7024
|
-
return this.getBlockAt(new
|
|
7166
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7025
7167
|
}
|
|
7026
7168
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7027
7169
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7029,10 +7171,10 @@ var Chunk = class _Chunk {
|
|
|
7029
7171
|
}
|
|
7030
7172
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7031
7173
|
if (typeof posOrX == "number") {
|
|
7032
|
-
return this.setBlockAt(new
|
|
7174
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7033
7175
|
}
|
|
7034
7176
|
if (isTripleArray(posOrX)) {
|
|
7035
|
-
return this.setBlockAt(new
|
|
7177
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7036
7178
|
}
|
|
7037
7179
|
const worldPos = posOrX;
|
|
7038
7180
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7078,7 +7220,7 @@ var Chunk = class _Chunk {
|
|
|
7078
7220
|
}
|
|
7079
7221
|
async clear() {
|
|
7080
7222
|
let promises = [];
|
|
7081
|
-
let pos = new
|
|
7223
|
+
let pos = new import_three23.Vector3();
|
|
7082
7224
|
for (let x = 0; x < 16; x++) {
|
|
7083
7225
|
for (let z = 0; z < 16; z++) {
|
|
7084
7226
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7097,14 +7239,14 @@ var Chunk = class _Chunk {
|
|
|
7097
7239
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7098
7240
|
}
|
|
7099
7241
|
worldPosToChunkPos(pos) {
|
|
7100
|
-
return new
|
|
7242
|
+
return new import_three23.Vector3(
|
|
7101
7243
|
pos.x - this.x * 16,
|
|
7102
7244
|
pos.y - this.y * 16,
|
|
7103
7245
|
pos.z - this.z * 16
|
|
7104
7246
|
);
|
|
7105
7247
|
}
|
|
7106
7248
|
chunkPosToWorldPos(pos) {
|
|
7107
|
-
return new
|
|
7249
|
+
return new import_three23.Vector3(
|
|
7108
7250
|
this.x * 16 + pos.x,
|
|
7109
7251
|
this.y * 16 + pos.y,
|
|
7110
7252
|
this.z * 16 + pos.z
|