minerender 2.1.0-alpha.136 → 2.1.0-alpha.138
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/esm/Materials.mjs +3 -1
- package/dist/browser/esm/Materials.mjs.map +1 -1
- package/dist/browser/esm/Ticker.mjs +3 -1
- package/dist/browser/esm/Ticker.mjs.map +1 -1
- package/dist/browser/esm/UVMapper.mjs +9 -9
- package/dist/browser/esm/UVMapper.mjs.map +1 -1
- package/dist/browser/esm/assets/AssetLoader.mjs +4 -4
- package/dist/browser/esm/assets/AssetLoader.mjs.map +1 -1
- package/dist/browser/esm/assets/BlockEntities.mjs +3 -1
- package/dist/browser/esm/assets/BlockEntities.mjs.map +1 -1
- package/dist/browser/esm/assets/_fonts/Unihex.mjs +4 -2
- package/dist/browser/esm/assets/_fonts/Unihex.mjs.map +1 -1
- package/dist/browser/esm/assets/source/HostedAssetSource.mjs +6 -7
- package/dist/browser/esm/assets/source/HostedAssetSource.mjs.map +1 -1
- package/dist/browser/esm/env/browser/BrowserCache.mjs +3 -3
- package/dist/browser/esm/env/browser/BrowserCache.mjs.map +1 -1
- package/dist/browser/esm/image/ImageLoader.mjs +3 -3
- package/dist/browser/esm/image/ImageLoader.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +49 -7
- package/dist/browser/esm/inspector/SceneInspector.mjs +3 -3
- package/dist/browser/esm/inspector/SceneInspector.mjs.map +1 -1
- package/dist/browser/esm/instance/InstanceManager.mjs +4 -4
- package/dist/browser/esm/instance/InstanceManager.mjs.map +1 -1
- package/dist/browser/esm/model/block/scene/BlockObject.mjs +3 -1
- package/dist/browser/esm/model/block/scene/BlockObject.mjs.map +1 -1
- package/dist/browser/esm/model/scene/ModelObject.mjs +4 -4
- package/dist/browser/esm/model/scene/ModelObject.mjs.map +1 -1
- package/dist/browser/esm/renderer/Renderer.mjs +4 -2
- package/dist/browser/esm/renderer/Renderer.mjs.map +1 -1
- package/dist/browser/esm/renderer/SceneObject.mjs +0 -6
- package/dist/browser/esm/renderer/SceneObject.mjs.map +1 -1
- package/dist/browser/esm/request/Requests.mjs +3 -3
- package/dist/browser/esm/request/Requests.mjs.map +1 -1
- package/dist/browser/esm/skin/Skins.mjs +6 -4
- package/dist/browser/esm/skin/Skins.mjs.map +1 -1
- package/dist/browser/esm/texture/TextureLoader.mjs +4 -2
- package/dist/browser/esm/texture/TextureLoader.mjs.map +1 -1
- package/dist/browser/esm/util/log.mjs +75 -0
- package/dist/browser/esm/util/log.mjs.map +1 -1
- package/dist/browser/esm/util/performance.mjs.map +1 -1
- package/dist/browser/esm/world/Chunk.mjs +8 -5
- package/dist/browser/esm/world/Chunk.mjs.map +1 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs +96 -54
- package/dist/browser/esm/world/MineRenderWorld.mjs.map +1 -1
- package/dist/browser/esm/world/WorldStreamer.mjs +21 -20
- package/dist/browser/esm/world/WorldStreamer.mjs.map +1 -1
- package/dist/browser/esm/world/_entities/WorldEntities.mjs +3 -1
- package/dist/browser/esm/world/_entities/WorldEntities.mjs.map +1 -1
- package/dist/browser/index.d.ts +49 -7
- package/dist/browser/index.js +566 -461
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +2101 -1994
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +49 -7
- package/dist/node/index.d.ts +49 -7
- package/dist/node/index.js +566 -459
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +537 -431
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -432,12 +432,80 @@ var init_CanvasCompat = __esm({
|
|
|
432
432
|
});
|
|
433
433
|
|
|
434
434
|
// src/util/log.ts
|
|
435
|
+
function readSwitch() {
|
|
436
|
+
switchRead = true;
|
|
437
|
+
let value;
|
|
438
|
+
if (typeof runtime.process?.versions?.node === "string") {
|
|
439
|
+
value = runtime.process.env?.MINERENDER_LOG;
|
|
440
|
+
} else {
|
|
441
|
+
try {
|
|
442
|
+
value = runtime.localStorage?.getItem("minerender:log");
|
|
443
|
+
} catch {
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (value) {
|
|
447
|
+
for (const entry of value.split(",")) {
|
|
448
|
+
const separator = entry.indexOf("=");
|
|
449
|
+
const name = separator < 0 ? void 0 : entry.slice(0, separator).trim();
|
|
450
|
+
const setting = (separator < 0 ? entry : entry.slice(separator + 1)).trim();
|
|
451
|
+
if (!Object.prototype.hasOwnProperty.call(levels, setting) || name === "") continue;
|
|
452
|
+
if (name === void 0) {
|
|
453
|
+
switchThreshold = setting;
|
|
454
|
+
} else {
|
|
455
|
+
switchNamespaces ??= /* @__PURE__ */ new Map();
|
|
456
|
+
switchNamespaces.set(name, setting);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function logger(namespace) {
|
|
462
|
+
const write = (level, args) => {
|
|
463
|
+
if (!switchRead) readSwitch();
|
|
464
|
+
if (levels[level] < levels[switchNamespaces?.get(namespace) ?? switchThreshold ?? namespaces?.get(namespace) ?? threshold]) return;
|
|
465
|
+
if (logHandler) {
|
|
466
|
+
logHandler(level, namespace, args);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (tagStyle === void 0) {
|
|
470
|
+
tagStyle = typeof runtime.process?.versions?.node === "string" ? runtime.process.stdout?.isTTY === true ? "ansi" : "plain" : "browser";
|
|
471
|
+
}
|
|
472
|
+
if (tagStyle === "browser") {
|
|
473
|
+
console[level](`%cMineRender%c ${namespace}`, "background:#3c8527;color:#fff;border-radius:3px;padding:0 4px", "font-weight:bold", ...args);
|
|
474
|
+
} else {
|
|
475
|
+
const color2 = colors[level];
|
|
476
|
+
const tag = `[minerender:${namespace}]`;
|
|
477
|
+
console[level](tagStyle === "ansi" ? `\x1B[${color2}m${tag}\x1B[0m` : tag, ...args);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
return {
|
|
481
|
+
debug: (...args) => write("debug", args),
|
|
482
|
+
info: (...args) => write("info", args),
|
|
483
|
+
warn: (...args) => write("warn", args),
|
|
484
|
+
error: (...args) => write("error", args)
|
|
485
|
+
};
|
|
486
|
+
}
|
|
435
487
|
function prefix(prefix2) {
|
|
436
488
|
return `${FgGreen}MR${BgBlack}${prefix2 ?? ""}${Reset}`;
|
|
437
489
|
}
|
|
438
|
-
var Reset, FgGreen, BgBlack;
|
|
490
|
+
var runtime, levels, colors, threshold, namespaces, logHandler, tagStyle, switchRead, switchThreshold, switchNamespaces, Logging, Reset, FgGreen, BgBlack;
|
|
439
491
|
var init_log = __esm({
|
|
440
492
|
"src/util/log.ts"() {
|
|
493
|
+
runtime = globalThis;
|
|
494
|
+
levels = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 };
|
|
495
|
+
colors = { debug: 90, info: 36, warn: 33, error: 31 };
|
|
496
|
+
threshold = "warn";
|
|
497
|
+
switchRead = false;
|
|
498
|
+
Logging = class {
|
|
499
|
+
/** Updates the given settings and keeps the others. */
|
|
500
|
+
static configure(options) {
|
|
501
|
+
if (options.level !== void 0) threshold = options.level;
|
|
502
|
+
if (options.namespaces !== void 0) namespaces = new Map(Object.entries(options.namespaces));
|
|
503
|
+
}
|
|
504
|
+
/** Sends messages to `handler` instead of the console. Call without an argument to restore console output. */
|
|
505
|
+
static setHandler(handler) {
|
|
506
|
+
logHandler = handler;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
441
509
|
Reset = "\x1B[0m";
|
|
442
510
|
FgGreen = "\x1B[32m";
|
|
443
511
|
BgBlack = "\x1B[40m";
|
|
@@ -497,12 +565,12 @@ async function abortable(promise, signal) {
|
|
|
497
565
|
signal.removeEventListener("abort", abort);
|
|
498
566
|
}
|
|
499
567
|
}
|
|
500
|
-
var import_jobqu,
|
|
568
|
+
var import_jobqu, log, RequestError, RequestQueue, Requests;
|
|
501
569
|
var init_Requests = __esm({
|
|
502
570
|
"src/request/Requests.ts"() {
|
|
503
571
|
import_jobqu = require("jobqu");
|
|
504
572
|
init_log();
|
|
505
|
-
|
|
573
|
+
log = logger("Requests");
|
|
506
574
|
RequestError = class extends Error {
|
|
507
575
|
constructor(message, response, cause) {
|
|
508
576
|
super(message);
|
|
@@ -529,7 +597,7 @@ var init_Requests = __esm({
|
|
|
529
597
|
try {
|
|
530
598
|
return await abortable(this.queue.add(request), signal);
|
|
531
599
|
} catch (error) {
|
|
532
|
-
|
|
600
|
+
log.debug("Request failed", error);
|
|
533
601
|
const delay = this.retryDelay(error, request, retries);
|
|
534
602
|
if (delay === void 0) {
|
|
535
603
|
throw error;
|
|
@@ -715,7 +783,7 @@ var init_base64 = __esm({
|
|
|
715
783
|
});
|
|
716
784
|
|
|
717
785
|
// src/image/ImageLoader.ts
|
|
718
|
-
var
|
|
786
|
+
var log2, ImageLoader;
|
|
719
787
|
var init_ImageLoader = __esm({
|
|
720
788
|
"src/image/ImageLoader.ts"() {
|
|
721
789
|
init_CanvasCompat();
|
|
@@ -726,7 +794,7 @@ var init_ImageLoader = __esm({
|
|
|
726
794
|
init_WrappedImage();
|
|
727
795
|
init_base64();
|
|
728
796
|
init_log();
|
|
729
|
-
|
|
797
|
+
log2 = logger("ImageLoader");
|
|
730
798
|
ImageLoader = class _ImageLoader {
|
|
731
799
|
static _createImage() {
|
|
732
800
|
return createImage();
|
|
@@ -751,7 +819,7 @@ var init_ImageLoader = __esm({
|
|
|
751
819
|
return image;
|
|
752
820
|
}
|
|
753
821
|
static async loadData(src) {
|
|
754
|
-
|
|
822
|
+
log2.debug("loadData", src);
|
|
755
823
|
const image = await this.loadCanvasData(src);
|
|
756
824
|
return image.data.getImageData(0, 0, image.width, image.height);
|
|
757
825
|
}
|
|
@@ -858,13 +926,15 @@ var init_ImageLoader = __esm({
|
|
|
858
926
|
});
|
|
859
927
|
|
|
860
928
|
// src/texture/TextureLoader.ts
|
|
861
|
-
var import_three3, THREE, TextureLoader;
|
|
929
|
+
var import_three3, THREE, log3, TextureLoader;
|
|
862
930
|
var init_TextureLoader = __esm({
|
|
863
931
|
"src/texture/TextureLoader.ts"() {
|
|
864
932
|
import_three3 = require("three");
|
|
865
933
|
THREE = __toESM(require("three"));
|
|
866
934
|
init_ImageLoader();
|
|
867
935
|
init_Textures();
|
|
936
|
+
init_log();
|
|
937
|
+
log3 = logger("TextureLoader");
|
|
868
938
|
TextureLoader = class {
|
|
869
939
|
static {
|
|
870
940
|
this.failedTextures = /* @__PURE__ */ new WeakSet();
|
|
@@ -883,7 +953,7 @@ var init_TextureLoader = __esm({
|
|
|
883
953
|
texture.needsUpdate = true;
|
|
884
954
|
}, (error) => {
|
|
885
955
|
this.failedTextures.add(texture);
|
|
886
|
-
|
|
956
|
+
log3.warn("Failed to load texture", src, error);
|
|
887
957
|
});
|
|
888
958
|
texture.image = image;
|
|
889
959
|
texture.format = format2;
|
|
@@ -899,7 +969,7 @@ var init_TextureLoader = __esm({
|
|
|
899
969
|
texture.needsUpdate = true;
|
|
900
970
|
}).catch((error) => {
|
|
901
971
|
this.failedTextures.add(texture);
|
|
902
|
-
|
|
972
|
+
log3.warn("Failed to load texture", src, error);
|
|
903
973
|
});
|
|
904
974
|
texture.format = format2;
|
|
905
975
|
texture.rotation = rotation;
|
|
@@ -974,7 +1044,7 @@ var init_Textures = __esm({
|
|
|
974
1044
|
});
|
|
975
1045
|
|
|
976
1046
|
// src/Materials.ts
|
|
977
|
-
var import_three5, Materials;
|
|
1047
|
+
var import_three5, log4, Materials;
|
|
978
1048
|
var init_Materials = __esm({
|
|
979
1049
|
"src/Materials.ts"() {
|
|
980
1050
|
init_CacheKey();
|
|
@@ -982,6 +1052,8 @@ var init_Materials = __esm({
|
|
|
982
1052
|
init_Textures();
|
|
983
1053
|
init_TextureLoader();
|
|
984
1054
|
init_Caching();
|
|
1055
|
+
init_log();
|
|
1056
|
+
log4 = logger("Materials");
|
|
985
1057
|
Materials = class _Materials {
|
|
986
1058
|
/** Shared checkerboard material, created on first access. */
|
|
987
1059
|
static get MISSING_TEXTURE() {
|
|
@@ -1252,7 +1324,7 @@ var init_Materials = __esm({
|
|
|
1252
1324
|
Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
|
|
1253
1325
|
return material;
|
|
1254
1326
|
} catch (e) {
|
|
1255
|
-
|
|
1327
|
+
log4.warn(e);
|
|
1256
1328
|
}
|
|
1257
1329
|
return this.createBasicCanvasMaterial(canvas, transparent, shade);
|
|
1258
1330
|
}
|
|
@@ -1393,12 +1465,12 @@ var init_AssetKey = __esm({
|
|
|
1393
1465
|
}
|
|
1394
1466
|
/** Joins the type subdirectory and path without adding a namespace or file extension. */
|
|
1395
1467
|
getFullPath() {
|
|
1396
|
-
let
|
|
1468
|
+
let p = [];
|
|
1397
1469
|
if (this.type) {
|
|
1398
|
-
|
|
1470
|
+
p.push(this.type);
|
|
1399
1471
|
}
|
|
1400
|
-
|
|
1401
|
-
return
|
|
1472
|
+
p.push(this.path);
|
|
1473
|
+
return p.join("/");
|
|
1402
1474
|
}
|
|
1403
1475
|
toNamespacedString() {
|
|
1404
1476
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1444,184 +1516,6 @@ var init_AssetSource = __esm({
|
|
|
1444
1516
|
}
|
|
1445
1517
|
});
|
|
1446
1518
|
|
|
1447
|
-
// src/util/BatchedExecutor.ts
|
|
1448
|
-
var import_jobqu2, BatchedExecutor;
|
|
1449
|
-
var init_BatchedExecutor = __esm({
|
|
1450
|
-
"src/util/BatchedExecutor.ts"() {
|
|
1451
|
-
import_jobqu2 = require("jobqu");
|
|
1452
|
-
BatchedExecutor = class {
|
|
1453
|
-
/**
|
|
1454
|
-
* @param interval - Delay between queue runs, in milliseconds.
|
|
1455
|
-
* @param batch - Maximum tasks started per run and maximum tasks active at once.
|
|
1456
|
-
*/
|
|
1457
|
-
constructor(interval = 1, batch = 30) {
|
|
1458
|
-
if (!Number.isFinite(interval) || interval < 0) throw new RangeError("Batch interval must be finite and nonnegative");
|
|
1459
|
-
if (!Number.isInteger(batch) || batch < 1) throw new RangeError("Batch size must be a positive integer");
|
|
1460
|
-
this.interval = interval;
|
|
1461
|
-
this.batch = batch;
|
|
1462
|
-
this.queue = new import_jobqu2.JobQueue(async (task) => task(), { interval, maxPerRun: batch, maxActive: batch });
|
|
1463
|
-
}
|
|
1464
|
-
/** Queues a task and resolves with its result, or rejects with its error. */
|
|
1465
|
-
submit(task) {
|
|
1466
|
-
return this.queue.add(() => task());
|
|
1467
|
-
}
|
|
1468
|
-
/** Rejects queued and future tasks. Tasks already running are allowed to finish. */
|
|
1469
|
-
stop() {
|
|
1470
|
-
this.queue.end();
|
|
1471
|
-
}
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
});
|
|
1475
|
-
|
|
1476
|
-
// src/util/model.ts
|
|
1477
|
-
function applyElementRotation(rotation, geometry) {
|
|
1478
|
-
const origin = new import_three7.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1479
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1480
|
-
switch (rotation.axis) {
|
|
1481
|
-
case "x" /* X */:
|
|
1482
|
-
geometry.rotateX(toRadians(rotation.angle));
|
|
1483
|
-
break;
|
|
1484
|
-
case "y" /* Y */:
|
|
1485
|
-
geometry.rotateY(toRadians(rotation.angle));
|
|
1486
|
-
break;
|
|
1487
|
-
case "z" /* Z */:
|
|
1488
|
-
geometry.rotateZ(toRadians(rotation.angle));
|
|
1489
|
-
break;
|
|
1490
|
-
}
|
|
1491
|
-
if (rotation.rescale) {
|
|
1492
|
-
const angle = toRadians(rotation.angle);
|
|
1493
|
-
const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));
|
|
1494
|
-
geometry.scale(
|
|
1495
|
-
rotation.axis === "x" /* X */ ? 1 : s,
|
|
1496
|
-
rotation.axis === "y" /* Y */ ? 1 : s,
|
|
1497
|
-
rotation.axis === "z" /* Z */ ? 1 : s
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1500
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1501
|
-
}
|
|
1502
|
-
function applyGenericRotation(axis, rotation, obj) {
|
|
1503
|
-
switch (axis) {
|
|
1504
|
-
case "x" /* X */:
|
|
1505
|
-
obj.rotateOnAxis(new import_three7.Vector3(1, 0, 0), toRadians(rotation));
|
|
1506
|
-
break;
|
|
1507
|
-
case "y" /* Y */:
|
|
1508
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 1, 0), toRadians(rotation));
|
|
1509
|
-
break;
|
|
1510
|
-
case "z" /* Z */:
|
|
1511
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 0, 1), toRadians(rotation));
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
|
|
1516
|
-
let size = new import_three7.Vector3();
|
|
1517
|
-
box.getSize(size);
|
|
1518
|
-
let boxGeo = new import_three7.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1519
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1520
|
-
let wireMat = new import_three7.LineBasicMaterial({ color: color2, linewidth: w });
|
|
1521
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1522
|
-
obj.add(wireframe);
|
|
1523
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1524
|
-
obj.add(axes);
|
|
1525
|
-
}
|
|
1526
|
-
function addWireframeToObject(obj, color2 = 16777215, w = 2) {
|
|
1527
|
-
let boxGeo = new import_three7.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1528
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1529
|
-
let wireMat = new import_three7.LineBasicMaterial({ color: color2, linewidth: w });
|
|
1530
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1531
|
-
obj.add(wireframe);
|
|
1532
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1533
|
-
obj.add(axes);
|
|
1534
|
-
}
|
|
1535
|
-
function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
|
|
1536
|
-
let wireGeo = new import_three7.EdgesGeometry(geo);
|
|
1537
|
-
let wireMat = new import_three7.LineBasicMaterial({ color: color2, linewidth: w });
|
|
1538
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1539
|
-
mesh.add(wireframe);
|
|
1540
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1541
|
-
mesh.add(axes);
|
|
1542
|
-
return () => {
|
|
1543
|
-
wireGeo.dispose();
|
|
1544
|
-
wireMat.dispose();
|
|
1545
|
-
axes.dispose();
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
var import_three7;
|
|
1549
|
-
var init_model = __esm({
|
|
1550
|
-
"src/util/model.ts"() {
|
|
1551
|
-
init_Axis();
|
|
1552
|
-
init_util();
|
|
1553
|
-
import_three7 = require("three");
|
|
1554
|
-
}
|
|
1555
|
-
});
|
|
1556
|
-
|
|
1557
|
-
// src/util/performance.ts
|
|
1558
|
-
function captureException(e, ...extra) {
|
|
1559
|
-
console.error(e, extra);
|
|
1560
|
-
}
|
|
1561
|
-
function timingStart(marker) {
|
|
1562
|
-
console.time(marker);
|
|
1563
|
-
}
|
|
1564
|
-
function timingEnd(marker) {
|
|
1565
|
-
console.timeEnd(marker);
|
|
1566
|
-
}
|
|
1567
|
-
var init_performance = __esm({
|
|
1568
|
-
"src/util/performance.ts"() {
|
|
1569
|
-
}
|
|
1570
|
-
});
|
|
1571
|
-
|
|
1572
|
-
// src/util/sha.ts
|
|
1573
|
-
function sha1(str) {
|
|
1574
|
-
return (0, import_sha1.default)(str).toString();
|
|
1575
|
-
}
|
|
1576
|
-
function sha256(str) {
|
|
1577
|
-
return (0, import_sha256.default)(str).toString();
|
|
1578
|
-
}
|
|
1579
|
-
function sha512(str) {
|
|
1580
|
-
return (0, import_sha512.default)(str).toString();
|
|
1581
|
-
}
|
|
1582
|
-
var import_sha1, import_sha256, import_sha512;
|
|
1583
|
-
var init_sha = __esm({
|
|
1584
|
-
"src/util/sha.ts"() {
|
|
1585
|
-
import_sha1 = __toESM(require("crypto-js/sha1.js"));
|
|
1586
|
-
import_sha256 = __toESM(require("crypto-js/sha256.js"));
|
|
1587
|
-
import_sha512 = __toESM(require("crypto-js/sha512.js"));
|
|
1588
|
-
}
|
|
1589
|
-
});
|
|
1590
|
-
|
|
1591
|
-
// src/util/three.ts
|
|
1592
|
-
function isObject3D(obj) {
|
|
1593
|
-
return obj.isObject3D;
|
|
1594
|
-
}
|
|
1595
|
-
function isMesh(obj) {
|
|
1596
|
-
return obj.isMesh;
|
|
1597
|
-
}
|
|
1598
|
-
function isInstancedMesh(obj) {
|
|
1599
|
-
return obj.isInstancedMesh;
|
|
1600
|
-
}
|
|
1601
|
-
function isPerspectiveCamera(obj) {
|
|
1602
|
-
return obj.isPerspectiveCamera;
|
|
1603
|
-
}
|
|
1604
|
-
function isOrthographicCamera(obj) {
|
|
1605
|
-
return obj.isOrthographicCamera;
|
|
1606
|
-
}
|
|
1607
|
-
var init_three = __esm({
|
|
1608
|
-
"src/util/three.ts"() {
|
|
1609
|
-
}
|
|
1610
|
-
});
|
|
1611
|
-
|
|
1612
|
-
// src/util/index.ts
|
|
1613
|
-
var init_util2 = __esm({
|
|
1614
|
-
"src/util/index.ts"() {
|
|
1615
|
-
init_BatchedExecutor();
|
|
1616
|
-
init_log();
|
|
1617
|
-
init_model();
|
|
1618
|
-
init_performance();
|
|
1619
|
-
init_sha();
|
|
1620
|
-
init_three();
|
|
1621
|
-
init_util();
|
|
1622
|
-
}
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
1519
|
// src/nbt/NBTHelper.ts
|
|
1626
1520
|
function commonJsExports(module2) {
|
|
1627
1521
|
return module2.default ?? module2;
|
|
@@ -1707,8 +1601,8 @@ var require_dist = __commonJS({
|
|
|
1707
1601
|
__assign = Object.assign || function(t) {
|
|
1708
1602
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1709
1603
|
s = arguments[i];
|
|
1710
|
-
for (var
|
|
1711
|
-
t[
|
|
1604
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1605
|
+
t[p] = s[p];
|
|
1712
1606
|
}
|
|
1713
1607
|
return t;
|
|
1714
1608
|
};
|
|
@@ -1800,11 +1694,11 @@ var init_merge = __esm({
|
|
|
1800
1694
|
});
|
|
1801
1695
|
|
|
1802
1696
|
// src/assets/source/HostedAssetSource.ts
|
|
1803
|
-
var BINARY_TIMEOUT,
|
|
1697
|
+
var BINARY_TIMEOUT, log5, DEFAULT_OPTIONS, HostedAssetSource;
|
|
1804
1698
|
var init_HostedAssetSource = __esm({
|
|
1805
1699
|
"src/assets/source/HostedAssetSource.ts"() {
|
|
1806
1700
|
init_AssetSource();
|
|
1807
|
-
|
|
1701
|
+
init_log();
|
|
1808
1702
|
init_nbt();
|
|
1809
1703
|
init_image();
|
|
1810
1704
|
init_AssetKey();
|
|
@@ -1814,7 +1708,7 @@ var init_HostedAssetSource = __esm({
|
|
|
1814
1708
|
init_parser();
|
|
1815
1709
|
init_merge();
|
|
1816
1710
|
BINARY_TIMEOUT = 6e4;
|
|
1817
|
-
|
|
1711
|
+
log5 = logger("HostedAssetSource");
|
|
1818
1712
|
DEFAULT_OPTIONS = {
|
|
1819
1713
|
retryDefaults: true
|
|
1820
1714
|
};
|
|
@@ -1914,14 +1808,14 @@ var init_HostedAssetSource = __esm({
|
|
|
1914
1808
|
return direct;
|
|
1915
1809
|
}
|
|
1916
1810
|
if (key.namespace !== DEFAULT_NAMESPACE) {
|
|
1917
|
-
|
|
1811
|
+
log5.debug("Retrying", key, "with default namespace");
|
|
1918
1812
|
const namespaceKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, key.root);
|
|
1919
1813
|
const namespaced = await this.load(namespaceKey, parser);
|
|
1920
1814
|
if (typeof namespaced !== "undefined") {
|
|
1921
1815
|
return namespaced;
|
|
1922
1816
|
}
|
|
1923
1817
|
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1924
|
-
|
|
1818
|
+
log5.debug("Retrying", key, "with default root+namespace");
|
|
1925
1819
|
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1926
1820
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1927
1821
|
if (typeof namespacedRooted !== "undefined") {
|
|
@@ -1929,7 +1823,7 @@ var init_HostedAssetSource = __esm({
|
|
|
1929
1823
|
}
|
|
1930
1824
|
}
|
|
1931
1825
|
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
1932
|
-
|
|
1826
|
+
log5.debug("Retrying", key, "with default root");
|
|
1933
1827
|
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
1934
1828
|
const rooted = await this.load(rootKey, parser);
|
|
1935
1829
|
if (typeof rooted !== "undefined") {
|
|
@@ -1939,9 +1833,8 @@ var init_HostedAssetSource = __esm({
|
|
|
1939
1833
|
return void 0;
|
|
1940
1834
|
}
|
|
1941
1835
|
async load(key, parser) {
|
|
1942
|
-
console.info(p3, "Loading", key);
|
|
1943
1836
|
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1944
|
-
|
|
1837
|
+
log5.debug("Loading", url);
|
|
1945
1838
|
const request = { url };
|
|
1946
1839
|
try {
|
|
1947
1840
|
parser.config(request);
|
|
@@ -2325,7 +2218,7 @@ var init_source = __esm({
|
|
|
2325
2218
|
});
|
|
2326
2219
|
|
|
2327
2220
|
// src/assets/AssetLoader.ts
|
|
2328
|
-
var
|
|
2221
|
+
var log6, AssetLoader;
|
|
2329
2222
|
var init_AssetLoader = __esm({
|
|
2330
2223
|
"src/assets/AssetLoader.ts"() {
|
|
2331
2224
|
init_AssetDefaults();
|
|
@@ -2333,7 +2226,7 @@ var init_AssetLoader = __esm({
|
|
|
2333
2226
|
init_log();
|
|
2334
2227
|
init_source();
|
|
2335
2228
|
init_Caching();
|
|
2336
|
-
|
|
2229
|
+
log6 = logger("AssetLoader");
|
|
2337
2230
|
AssetLoader = class {
|
|
2338
2231
|
static {
|
|
2339
2232
|
/** Default asset base URL. Use {@link setVersion} to select a Minecraft version. */
|
|
@@ -2396,11 +2289,11 @@ ${key}` : key;
|
|
|
2396
2289
|
if (override) {
|
|
2397
2290
|
const existing = this.removeSource(key);
|
|
2398
2291
|
if (existing) {
|
|
2399
|
-
|
|
2292
|
+
log6.info("Removed existing AssetSource", key);
|
|
2400
2293
|
}
|
|
2401
2294
|
}
|
|
2402
2295
|
this._SOURCES.unshift({ key, source });
|
|
2403
|
-
|
|
2296
|
+
log6.info("Added AssetSource", key);
|
|
2404
2297
|
}
|
|
2405
2298
|
/** Removes and returns the first source with this name. Call {@link Caching.clear} to reload assets. */
|
|
2406
2299
|
static removeSource(key) {
|
|
@@ -2576,9 +2469,11 @@ var init_CanvasImage = __esm({
|
|
|
2576
2469
|
});
|
|
2577
2470
|
|
|
2578
2471
|
// src/Ticker.ts
|
|
2579
|
-
var Ticker;
|
|
2472
|
+
var log7, Ticker;
|
|
2580
2473
|
var init_Ticker = __esm({
|
|
2581
2474
|
"src/Ticker.ts"() {
|
|
2475
|
+
init_log();
|
|
2476
|
+
log7 = logger("Ticker");
|
|
2582
2477
|
Ticker = class _Ticker {
|
|
2583
2478
|
static {
|
|
2584
2479
|
this.TPS = 20;
|
|
@@ -2617,7 +2512,7 @@ var init_Ticker = __esm({
|
|
|
2617
2512
|
try {
|
|
2618
2513
|
t();
|
|
2619
2514
|
} catch (e) {
|
|
2620
|
-
|
|
2515
|
+
log7.warn(e);
|
|
2621
2516
|
}
|
|
2622
2517
|
});
|
|
2623
2518
|
_Ticker.oneSecondTicks++;
|
|
@@ -2856,10 +2751,10 @@ var init_cubeUv = __esm({
|
|
|
2856
2751
|
});
|
|
2857
2752
|
|
|
2858
2753
|
// src/UVMapper.ts
|
|
2859
|
-
var
|
|
2754
|
+
var import_three7, log8, X, Y, Z, FACE_UV_AXES, UVMapper, MinecraftFaceUV;
|
|
2860
2755
|
var init_UVMapper = __esm({
|
|
2861
2756
|
"src/UVMapper.ts"() {
|
|
2862
|
-
|
|
2757
|
+
import_three7 = require("three");
|
|
2863
2758
|
init_CubeFace();
|
|
2864
2759
|
init_ModelTextures();
|
|
2865
2760
|
init_WrappedImage();
|
|
@@ -2871,17 +2766,17 @@ var init_UVMapper = __esm({
|
|
|
2871
2766
|
init_ModelGenerator();
|
|
2872
2767
|
init_log();
|
|
2873
2768
|
init_cubeUv();
|
|
2874
|
-
|
|
2769
|
+
log8 = logger("UVMapper");
|
|
2875
2770
|
X = 0;
|
|
2876
2771
|
Y = 1;
|
|
2877
2772
|
Z = 2;
|
|
2878
2773
|
FACE_UV_AXES = {
|
|
2879
|
-
east: [new
|
|
2880
|
-
west: [new
|
|
2881
|
-
up: [new
|
|
2882
|
-
down: [new
|
|
2883
|
-
south: [new
|
|
2884
|
-
north: [new
|
|
2774
|
+
east: [new import_three7.Vector3(0, 0, -1), new import_three7.Vector3(0, -1, 0)],
|
|
2775
|
+
west: [new import_three7.Vector3(0, 0, 1), new import_three7.Vector3(0, -1, 0)],
|
|
2776
|
+
up: [new import_three7.Vector3(1, 0, 0), new import_three7.Vector3(0, 0, 1)],
|
|
2777
|
+
down: [new import_three7.Vector3(1, 0, 0), new import_three7.Vector3(0, 0, -1)],
|
|
2778
|
+
south: [new import_three7.Vector3(1, 0, 0), new import_three7.Vector3(0, -1, 0)],
|
|
2779
|
+
north: [new import_three7.Vector3(-1, 0, 0), new import_three7.Vector3(0, -1, 0)]
|
|
2885
2780
|
};
|
|
2886
2781
|
UVMapper = class {
|
|
2887
2782
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
@@ -2948,7 +2843,7 @@ var init_UVMapper = __esm({
|
|
|
2948
2843
|
return facesToUvArray(faces, originalTextureSize, actualTextureSize);
|
|
2949
2844
|
}
|
|
2950
2845
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2951
|
-
return new
|
|
2846
|
+
return new import_three7.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2952
2847
|
}
|
|
2953
2848
|
/** Bounds texture sampling to texel centres without changing cropped face UVs. */
|
|
2954
2849
|
static setAtlasUvBounds(geometry, faces, atlas) {
|
|
@@ -2979,7 +2874,7 @@ var init_UVMapper = __esm({
|
|
|
2979
2874
|
bounds.set([minU + insetU, minV + insetV, maxU - insetU, maxV - insetV], (faceIndex * 4 + corner) * 4);
|
|
2980
2875
|
}
|
|
2981
2876
|
}
|
|
2982
|
-
geometry.setAttribute("uvBounds", new
|
|
2877
|
+
geometry.setAttribute("uvBounds", new import_three7.Float32BufferAttribute(bounds, 4));
|
|
2983
2878
|
}
|
|
2984
2879
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2985
2880
|
const uv = geometry.getAttribute("uv");
|
|
@@ -3061,32 +2956,32 @@ var init_UVMapper = __esm({
|
|
|
3061
2956
|
v1 *= scaleV;
|
|
3062
2957
|
u2 *= scaleU;
|
|
3063
2958
|
v2 *= scaleV;
|
|
3064
|
-
let tl = new
|
|
3065
|
-
let tr = new
|
|
3066
|
-
let bl = new
|
|
3067
|
-
let br = new
|
|
2959
|
+
let tl = new import_three7.Vector2(u1, v1);
|
|
2960
|
+
let tr = new import_three7.Vector2(u2, v1);
|
|
2961
|
+
let bl = new import_three7.Vector2(u1, v2);
|
|
2962
|
+
let br = new import_three7.Vector2(u2, v2);
|
|
3068
2963
|
switch (rotation) {
|
|
3069
2964
|
case 0:
|
|
3070
2965
|
case 360:
|
|
3071
2966
|
default:
|
|
3072
2967
|
break;
|
|
3073
2968
|
case 90:
|
|
3074
|
-
tl = new
|
|
3075
|
-
tr = new
|
|
3076
|
-
bl = new
|
|
3077
|
-
br = new
|
|
2969
|
+
tl = new import_three7.Vector2(u1, v2);
|
|
2970
|
+
tr = new import_three7.Vector2(u1, v1);
|
|
2971
|
+
bl = new import_three7.Vector2(u2, v2);
|
|
2972
|
+
br = new import_three7.Vector2(u2, v1);
|
|
3078
2973
|
break;
|
|
3079
2974
|
case 180:
|
|
3080
|
-
tl = new
|
|
3081
|
-
tr = new
|
|
3082
|
-
bl = new
|
|
3083
|
-
br = new
|
|
2975
|
+
tl = new import_three7.Vector2(u2, v2);
|
|
2976
|
+
tr = new import_three7.Vector2(u1, v2);
|
|
2977
|
+
bl = new import_three7.Vector2(u2, v1);
|
|
2978
|
+
br = new import_three7.Vector2(u1, v1);
|
|
3084
2979
|
break;
|
|
3085
2980
|
case 270:
|
|
3086
|
-
tl = new
|
|
3087
|
-
tr = new
|
|
3088
|
-
bl = new
|
|
3089
|
-
br = new
|
|
2981
|
+
tl = new import_three7.Vector2(u2, v1);
|
|
2982
|
+
tr = new import_three7.Vector2(u2, v2);
|
|
2983
|
+
bl = new import_three7.Vector2(u1, v1);
|
|
2984
|
+
br = new import_three7.Vector2(u1, v2);
|
|
3090
2985
|
break;
|
|
3091
2986
|
}
|
|
3092
2987
|
return [tl, tr, bl, br];
|
|
@@ -3104,7 +2999,7 @@ var init_UVMapper = __esm({
|
|
|
3104
2999
|
model.elements = originalModel.elements.map((element) => ({ ...element }));
|
|
3105
3000
|
}
|
|
3106
3001
|
const isItemModel = !("elements" in model);
|
|
3107
|
-
|
|
3002
|
+
log8.debug("Creating Atlas for", model.key);
|
|
3108
3003
|
if (model.textures) {
|
|
3109
3004
|
const promises = [];
|
|
3110
3005
|
const uniqueTextureNames = [];
|
|
@@ -3118,7 +3013,7 @@ var init_UVMapper = __esm({
|
|
|
3118
3013
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
3119
3014
|
promises.push(ModelTextures.get(assetKey).then((asset2) => {
|
|
3120
3015
|
if (!asset2) {
|
|
3121
|
-
|
|
3016
|
+
log8.warn("Missing texture", assetKey);
|
|
3122
3017
|
return;
|
|
3123
3018
|
}
|
|
3124
3019
|
textureMap[textureKey] = new WrappedImage(asset2);
|
|
@@ -3130,7 +3025,7 @@ var init_UVMapper = __esm({
|
|
|
3130
3025
|
}
|
|
3131
3026
|
await Promise.all(promises);
|
|
3132
3027
|
const textureCount = uniqueTextureNames.length;
|
|
3133
|
-
|
|
3028
|
+
log8.debug("Creating Atlas for", textureCount, "textures");
|
|
3134
3029
|
this.fillMissingTextureKeys(model.textures, textureMap);
|
|
3135
3030
|
this.fillMissingTextureKeys(model.textures, metaMap);
|
|
3136
3031
|
const sizes = {};
|
|
@@ -3161,7 +3056,7 @@ var init_UVMapper = __esm({
|
|
|
3161
3056
|
this.fillMissingTextureKeys(model.textures, sizes);
|
|
3162
3057
|
const s = Math.ceil(Math.sqrt(textureCount + 1));
|
|
3163
3058
|
const size = Math.ceil(s * maxWidth);
|
|
3164
|
-
|
|
3059
|
+
log8.debug("Atlas size:", size);
|
|
3165
3060
|
const squaredSize = size * size;
|
|
3166
3061
|
const image = new CanvasImage(size, size);
|
|
3167
3062
|
const missing = Textures.getMissing().image;
|
|
@@ -3240,7 +3135,7 @@ var init_UVMapper = __esm({
|
|
|
3240
3135
|
}
|
|
3241
3136
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
3242
3137
|
if (isItemModel) {
|
|
3243
|
-
|
|
3138
|
+
log8.debug("Generating item model for", model);
|
|
3244
3139
|
model.elements = [];
|
|
3245
3140
|
for (let layerName of ModelGenerator.ITEM_LAYERS) {
|
|
3246
3141
|
const textureImage = textureMap[layerName];
|
|
@@ -3256,7 +3151,7 @@ var init_UVMapper = __esm({
|
|
|
3256
3151
|
), layerName));
|
|
3257
3152
|
}
|
|
3258
3153
|
}
|
|
3259
|
-
|
|
3154
|
+
log8.debug("Item model elements", model.elements);
|
|
3260
3155
|
}
|
|
3261
3156
|
if (!model.elements) {
|
|
3262
3157
|
}
|
|
@@ -3281,7 +3176,7 @@ var init_UVMapper = __esm({
|
|
|
3281
3176
|
const faceTexture = face.texture.substr(1);
|
|
3282
3177
|
const texPosition = positions[faceTexture] || [0, 0];
|
|
3283
3178
|
const texSize = sizes[faceTexture] || [16, 16];
|
|
3284
|
-
let texPosV = new
|
|
3179
|
+
let texPosV = new import_three7.Vector2(texPosition[0], texPosition[1]);
|
|
3285
3180
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
3286
3181
|
tl.add(texPosV);
|
|
3287
3182
|
tr.add(texPosV);
|
|
@@ -3313,7 +3208,7 @@ var init_UVMapper = __esm({
|
|
|
3313
3208
|
hasTranslucency
|
|
3314
3209
|
);
|
|
3315
3210
|
} else {
|
|
3316
|
-
|
|
3211
|
+
log8.warn("Model does not have any textures", model);
|
|
3317
3212
|
}
|
|
3318
3213
|
return void 0;
|
|
3319
3214
|
}
|
|
@@ -3638,10 +3533,10 @@ var init_DisplayPosition = __esm({
|
|
|
3638
3533
|
});
|
|
3639
3534
|
|
|
3640
3535
|
// src/model/DisplayTransforms.ts
|
|
3641
|
-
var
|
|
3536
|
+
var import_three8, DisplayTransforms;
|
|
3642
3537
|
var init_DisplayTransforms = __esm({
|
|
3643
3538
|
"src/model/DisplayTransforms.ts"() {
|
|
3644
|
-
|
|
3539
|
+
import_three8 = require("three");
|
|
3645
3540
|
init_DisplayPosition();
|
|
3646
3541
|
init_util();
|
|
3647
3542
|
DisplayTransforms = class {
|
|
@@ -3660,7 +3555,7 @@ var init_DisplayTransforms = __esm({
|
|
|
3660
3555
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
3661
3556
|
static getMatrix(display, position) {
|
|
3662
3557
|
const transform = this.getTransform(display, position);
|
|
3663
|
-
return new
|
|
3558
|
+
return new import_three8.Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
3664
3559
|
}
|
|
3665
3560
|
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
3666
3561
|
static getTransform(display, position) {
|
|
@@ -3668,10 +3563,10 @@ var init_DisplayTransforms = __esm({
|
|
|
3668
3563
|
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
3669
3564
|
const sign = left ? -1 : 1;
|
|
3670
3565
|
const [x, y, z] = transform.rotation ?? [0, 0, 0];
|
|
3671
|
-
const rotation = new
|
|
3672
|
-
const translation = new
|
|
3566
|
+
const rotation = new import_three8.Quaternion().setFromEuler(new import_three8.Euler(toRadians(x), sign * toRadians(y), sign * toRadians(z), "XYZ"));
|
|
3567
|
+
const translation = new import_three8.Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
3673
3568
|
translation.x *= sign;
|
|
3674
|
-
const scale = new
|
|
3569
|
+
const scale = new import_three8.Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
3675
3570
|
return { position: translation, quaternion: rotation, scale };
|
|
3676
3571
|
}
|
|
3677
3572
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
@@ -3715,7 +3610,7 @@ var init_ModelMerger = __esm({
|
|
|
3715
3610
|
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
3716
3611
|
}
|
|
3717
3612
|
}
|
|
3718
|
-
merged.hierarchy = models.map((m) => m.parent).filter((
|
|
3613
|
+
merged.hierarchy = models.map((m) => m.parent).filter((p) => `${p}`);
|
|
3719
3614
|
merged.hierarchy.push(`${merged.parent}`);
|
|
3720
3615
|
if (model.components) merged.components = model.components;
|
|
3721
3616
|
return merged;
|
|
@@ -3794,11 +3689,11 @@ var init_BannerPatterns = __esm({
|
|
|
3794
3689
|
static async getLayers(value, target, root) {
|
|
3795
3690
|
if (value === void 0) return [];
|
|
3796
3691
|
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
3797
|
-
const
|
|
3692
|
+
const colors2 = value.length ? await this.getColors(root) : void 0;
|
|
3798
3693
|
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
3799
3694
|
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
3800
|
-
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(
|
|
3801
|
-
const color2 =
|
|
3695
|
+
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(colors2, layer.color)) throw new Error(`Unsupported dye color ${layer.color}`);
|
|
3696
|
+
const color2 = colors2[layer.color];
|
|
3802
3697
|
let pattern2 = layer.pattern;
|
|
3803
3698
|
if (typeof pattern2 === "string") {
|
|
3804
3699
|
const id = this.identifier(pattern2);
|
|
@@ -3907,49 +3802,49 @@ var init_ItemTints = __esm({
|
|
|
3907
3802
|
const sources = model.tints;
|
|
3908
3803
|
if (!sources?.length) return tints;
|
|
3909
3804
|
const components = model.components ?? {};
|
|
3910
|
-
const
|
|
3805
|
+
const colors2 = { ...tints };
|
|
3911
3806
|
await Promise.all(sources.map(async (source, index) => {
|
|
3912
|
-
if (
|
|
3807
|
+
if (colors2[index] !== void 0) return;
|
|
3913
3808
|
switch (source.type) {
|
|
3914
3809
|
case "constant":
|
|
3915
3810
|
case "minecraft:constant":
|
|
3916
|
-
|
|
3811
|
+
colors2[index] = this.rgb(source.value);
|
|
3917
3812
|
break;
|
|
3918
3813
|
case "grass":
|
|
3919
3814
|
case "minecraft:grass":
|
|
3920
|
-
|
|
3815
|
+
colors2[index] = await Colormaps.grassColor(model.key, source.temperature, source.downfall);
|
|
3921
3816
|
break;
|
|
3922
3817
|
case "dye":
|
|
3923
3818
|
case "minecraft:dye":
|
|
3924
|
-
|
|
3819
|
+
colors2[index] = this.colorOrDefault(components["minecraft:dyed_color"], source.default, true);
|
|
3925
3820
|
break;
|
|
3926
3821
|
case "potion":
|
|
3927
3822
|
case "minecraft:potion": {
|
|
3928
|
-
|
|
3823
|
+
colors2[index] = await this.potionColor(components["minecraft:potion_contents"], source.default, model.key?.root);
|
|
3929
3824
|
break;
|
|
3930
3825
|
}
|
|
3931
3826
|
case "map_color":
|
|
3932
3827
|
case "minecraft:map_color":
|
|
3933
|
-
|
|
3828
|
+
colors2[index] = this.colorOrDefault(components["minecraft:map_color"], source.default);
|
|
3934
3829
|
break;
|
|
3935
3830
|
case "firework":
|
|
3936
3831
|
case "minecraft:firework": {
|
|
3937
3832
|
const values = this.componentField(components, "firework_explosion", "colors");
|
|
3938
3833
|
if (values !== void 0 && !Array.isArray(values)) throw new MineRenderError("Item tint firework_explosion.colors must be an array");
|
|
3939
3834
|
if (!values?.length) {
|
|
3940
|
-
|
|
3835
|
+
colors2[index] = this.rgb(source.default);
|
|
3941
3836
|
break;
|
|
3942
3837
|
}
|
|
3943
3838
|
const rgb = values.map((value) => this.componentColor(value));
|
|
3944
3839
|
const red = Math.floor(rgb.reduce((sum, color2) => sum + (color2 >> 16 & 255), 0) / rgb.length);
|
|
3945
3840
|
const green = Math.floor(rgb.reduce((sum, color2) => sum + (color2 >> 8 & 255), 0) / rgb.length);
|
|
3946
3841
|
const blue = Math.floor(rgb.reduce((sum, color2) => sum + (color2 & 255), 0) / rgb.length);
|
|
3947
|
-
|
|
3842
|
+
colors2[index] = red << 16 | green << 8 | blue;
|
|
3948
3843
|
break;
|
|
3949
3844
|
}
|
|
3950
3845
|
case "team":
|
|
3951
3846
|
case "minecraft:team":
|
|
3952
|
-
|
|
3847
|
+
colors2[index] = this.rgb(source.default);
|
|
3953
3848
|
break;
|
|
3954
3849
|
case "custom_model_data":
|
|
3955
3850
|
case "minecraft:custom_model_data": {
|
|
@@ -3957,14 +3852,14 @@ var init_ItemTints = __esm({
|
|
|
3957
3852
|
if (!Number.isSafeInteger(colorIndex) || colorIndex < 0) throw new MineRenderError("Item tint custom_model_data index must be a nonnegative integer");
|
|
3958
3853
|
const values = this.componentField(components, "custom_model_data", "colors");
|
|
3959
3854
|
if (values !== void 0 && !Array.isArray(values)) throw new MineRenderError("Item tint custom_model_data.colors must be an array");
|
|
3960
|
-
|
|
3855
|
+
colors2[index] = this.colorOrDefault(values?.[colorIndex], source.default, true);
|
|
3961
3856
|
break;
|
|
3962
3857
|
}
|
|
3963
3858
|
default:
|
|
3964
3859
|
throw new MineRenderError(`Unsupported item tint source ${source.type}`);
|
|
3965
3860
|
}
|
|
3966
3861
|
}));
|
|
3967
|
-
return
|
|
3862
|
+
return colors2;
|
|
3968
3863
|
}
|
|
3969
3864
|
/** Whether a potion component contains a known effect, including effects with hidden particles. */
|
|
3970
3865
|
static async hasPotionEffects(value, root) {
|
|
@@ -4538,7 +4433,7 @@ function createPermutation() {
|
|
|
4538
4433
|
return values;
|
|
4539
4434
|
}
|
|
4540
4435
|
function swampGrassColor(x, z) {
|
|
4541
|
-
const
|
|
4436
|
+
const p = permutation ??= createPermutation();
|
|
4542
4437
|
x *= 0.0225;
|
|
4543
4438
|
z *= 0.0225;
|
|
4544
4439
|
const s = (x + z) * skew;
|
|
@@ -4549,7 +4444,7 @@ function swampGrassColor(x, z) {
|
|
|
4549
4444
|
const corner = (gx, gz, a, b) => {
|
|
4550
4445
|
let falloff = 0.5 - a * a - b * b;
|
|
4551
4446
|
if (falloff < 0) return 0;
|
|
4552
|
-
const gradient = gradients[
|
|
4447
|
+
const gradient = gradients[p[gx + p[gz & 255] & 255] % 12];
|
|
4553
4448
|
falloff *= falloff;
|
|
4554
4449
|
return falloff * falloff * (gradient[0] * a + gradient[1] * b);
|
|
4555
4450
|
};
|
|
@@ -4627,14 +4522,16 @@ var init_Biomes = __esm({
|
|
|
4627
4522
|
});
|
|
4628
4523
|
|
|
4629
4524
|
// src/assets/BlockEntities.ts
|
|
4630
|
-
var
|
|
4525
|
+
var import_three9, log9, BlockEntities;
|
|
4631
4526
|
var init_BlockEntities = __esm({
|
|
4632
4527
|
"src/assets/BlockEntities.ts"() {
|
|
4633
|
-
|
|
4528
|
+
import_three9 = require("three");
|
|
4634
4529
|
init_AssetKey();
|
|
4635
4530
|
init_AssetLoader();
|
|
4636
4531
|
init_source();
|
|
4637
4532
|
init_Caching();
|
|
4533
|
+
init_log();
|
|
4534
|
+
log9 = logger("BlockEntities");
|
|
4638
4535
|
BlockEntities = class {
|
|
4639
4536
|
/**
|
|
4640
4537
|
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
@@ -4648,7 +4545,7 @@ var init_BlockEntities = __esm({
|
|
|
4648
4545
|
try {
|
|
4649
4546
|
return await AssetLoader.get(key, "json" /* JSON */) ?? {};
|
|
4650
4547
|
} catch (error) {
|
|
4651
|
-
|
|
4548
|
+
log9.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
|
|
4652
4549
|
return {};
|
|
4653
4550
|
}
|
|
4654
4551
|
});
|
|
@@ -4675,8 +4572,8 @@ var init_BlockEntities = __esm({
|
|
|
4675
4572
|
return { parts, rotation, translation: entry.translation ?? [0, 0, 0] };
|
|
4676
4573
|
}
|
|
4677
4574
|
/** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
|
|
4678
|
-
static matrix(resolved, matrix = new
|
|
4679
|
-
return matrix.makeTranslation(8, 0, 8).multiply(new
|
|
4575
|
+
static matrix(resolved, matrix = new import_three9.Matrix4()) {
|
|
4576
|
+
return matrix.makeTranslation(8, 0, 8).multiply(new import_three9.Matrix4().makeRotationY(resolved.rotation * Math.PI / 180)).multiply(new import_three9.Matrix4().makeTranslation(resolved.translation[0] - 8, resolved.translation[1], resolved.translation[2] - 8));
|
|
4680
4577
|
}
|
|
4681
4578
|
};
|
|
4682
4579
|
}
|
|
@@ -4919,7 +4816,7 @@ async function parseUnihex(key) {
|
|
|
4919
4816
|
}
|
|
4920
4817
|
return { indices, rows, metrics };
|
|
4921
4818
|
} catch (error) {
|
|
4922
|
-
|
|
4819
|
+
log10.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
|
|
4923
4820
|
return void 0;
|
|
4924
4821
|
}
|
|
4925
4822
|
}
|
|
@@ -4938,7 +4835,7 @@ async function loadUnihex(provider, fontKey, characters) {
|
|
|
4938
4835
|
return { ...override, from, to };
|
|
4939
4836
|
});
|
|
4940
4837
|
} catch (error) {
|
|
4941
|
-
|
|
4838
|
+
log10.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
|
|
4942
4839
|
return glyphs;
|
|
4943
4840
|
}
|
|
4944
4841
|
const file = await Caching.unihexCache.get(key.serialize(), () => parseUnihex(key));
|
|
@@ -4986,7 +4883,7 @@ async function loadUnihex(provider, fontKey, characters) {
|
|
|
4986
4883
|
}
|
|
4987
4884
|
return glyphs;
|
|
4988
4885
|
}
|
|
4989
|
-
var import_zip2, ATLAS_SIZE, GLYPH_HEIGHT, UnihexAtlas, atlases;
|
|
4886
|
+
var import_zip2, log10, ATLAS_SIZE, GLYPH_HEIGHT, UnihexAtlas, atlases;
|
|
4990
4887
|
var init_Unihex = __esm({
|
|
4991
4888
|
"src/assets/_fonts/Unihex.ts"() {
|
|
4992
4889
|
import_zip2 = require("@zip.js/zip.js");
|
|
@@ -4996,6 +4893,8 @@ var init_Unihex = __esm({
|
|
|
4996
4893
|
init_Caching();
|
|
4997
4894
|
init_AssetParsers();
|
|
4998
4895
|
init_CanvasCompat();
|
|
4896
|
+
init_log();
|
|
4897
|
+
log10 = logger("Unihex");
|
|
4999
4898
|
ATLAS_SIZE = 512;
|
|
5000
4899
|
GLYPH_HEIGHT = 16;
|
|
5001
4900
|
UnihexAtlas = class {
|
|
@@ -5160,8 +5059,8 @@ var init_Fonts = __esm({
|
|
|
5160
5059
|
});
|
|
5161
5060
|
|
|
5162
5061
|
// src/entity/EntityAnimation.ts
|
|
5163
|
-
function catmullRom(delta, p0, p1,
|
|
5164
|
-
return 0.5 * (2 * p1 + (
|
|
5062
|
+
function catmullRom(delta, p0, p1, p2, p3) {
|
|
5063
|
+
return 0.5 * (2 * p1 + (p2 - p0) * delta + (2 * p0 - 5 * p1 + 4 * p2 - p3) * delta * delta + (3 * p1 - p0 - 3 * p2 + p3) * delta * delta * delta);
|
|
5165
5064
|
}
|
|
5166
5065
|
function sampleEntityKeyframes(keyframes, time) {
|
|
5167
5066
|
if (keyframes.length === 0) return [0, 0, 0];
|
|
@@ -5214,10 +5113,10 @@ function validateAnimationWeights(weights, count) {
|
|
|
5214
5113
|
}
|
|
5215
5114
|
return values;
|
|
5216
5115
|
}
|
|
5217
|
-
var
|
|
5116
|
+
var import_three10, ZERO, EntityAnimationPlayer;
|
|
5218
5117
|
var init_EntityAnimationPlayer = __esm({
|
|
5219
5118
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
5220
|
-
|
|
5119
|
+
import_three10 = require("three");
|
|
5221
5120
|
init_EntityAnimation();
|
|
5222
5121
|
ZERO = [0, 0, 0];
|
|
5223
5122
|
EntityAnimationPlayer = class {
|
|
@@ -5283,9 +5182,9 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
5283
5182
|
position: object4.position.clone(),
|
|
5284
5183
|
rotation: object4.rotation.clone(),
|
|
5285
5184
|
scale: object4.scale.clone(),
|
|
5286
|
-
basePosition: pose ? new
|
|
5287
|
-
baseRotation: pose ? new
|
|
5288
|
-
baseScale: pose ? new
|
|
5185
|
+
basePosition: pose ? new import_three10.Vector3(...pose.offset) : object4.position.clone(),
|
|
5186
|
+
baseRotation: pose ? new import_three10.Euler(...pose.rotation, "ZYX") : object4.rotation.clone(),
|
|
5187
|
+
baseScale: pose ? new import_three10.Vector3(...pose.scale ?? [1, 1, 1]) : object4.scale.clone()
|
|
5289
5188
|
});
|
|
5290
5189
|
}
|
|
5291
5190
|
}
|
|
@@ -5421,14 +5320,35 @@ var init_InstanceReference = __esm({
|
|
|
5421
5320
|
}
|
|
5422
5321
|
});
|
|
5423
5322
|
|
|
5323
|
+
// src/util/three.ts
|
|
5324
|
+
function isObject3D(obj) {
|
|
5325
|
+
return obj.isObject3D;
|
|
5326
|
+
}
|
|
5327
|
+
function isMesh(obj) {
|
|
5328
|
+
return obj.isMesh;
|
|
5329
|
+
}
|
|
5330
|
+
function isInstancedMesh(obj) {
|
|
5331
|
+
return obj.isInstancedMesh;
|
|
5332
|
+
}
|
|
5333
|
+
function isPerspectiveCamera(obj) {
|
|
5334
|
+
return obj.isPerspectiveCamera;
|
|
5335
|
+
}
|
|
5336
|
+
function isOrthographicCamera(obj) {
|
|
5337
|
+
return obj.isOrthographicCamera;
|
|
5338
|
+
}
|
|
5339
|
+
var init_three = __esm({
|
|
5340
|
+
"src/util/three.ts"() {
|
|
5341
|
+
}
|
|
5342
|
+
});
|
|
5343
|
+
|
|
5424
5344
|
// src/renderer/SceneObject.ts
|
|
5425
5345
|
function isSceneObject(obj) {
|
|
5426
5346
|
return obj.isSceneObject;
|
|
5427
5347
|
}
|
|
5428
|
-
var
|
|
5348
|
+
var import_three11, SceneObject;
|
|
5429
5349
|
var init_SceneObject = __esm({
|
|
5430
5350
|
"src/renderer/SceneObject.ts"() {
|
|
5431
|
-
|
|
5351
|
+
import_three11 = require("three");
|
|
5432
5352
|
init_Geometries();
|
|
5433
5353
|
init_cubeUv();
|
|
5434
5354
|
init_Axis();
|
|
@@ -5438,9 +5358,7 @@ var init_SceneObject = __esm({
|
|
|
5438
5358
|
init_three();
|
|
5439
5359
|
init_Disposable();
|
|
5440
5360
|
init_merge();
|
|
5441
|
-
|
|
5442
|
-
p6 = prefix("SceneObject");
|
|
5443
|
-
SceneObject = class _SceneObject extends import_three12.Object3D {
|
|
5361
|
+
SceneObject = class _SceneObject extends import_three11.Object3D {
|
|
5444
5362
|
constructor(options) {
|
|
5445
5363
|
super();
|
|
5446
5364
|
this.isSceneObject = true;
|
|
@@ -5451,7 +5369,6 @@ var init_SceneObject = __esm({
|
|
|
5451
5369
|
this.freeInstanceIndices = [];
|
|
5452
5370
|
this.hiddenInstanceMatrices = /* @__PURE__ */ new Map();
|
|
5453
5371
|
this.options = (0, import_ts_deepmerge.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5454
|
-
console.log("SceneObject options", this.options);
|
|
5455
5372
|
}
|
|
5456
5373
|
static {
|
|
5457
5374
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge.default)({}, {
|
|
@@ -5488,13 +5405,12 @@ var init_SceneObject = __esm({
|
|
|
5488
5405
|
this.remove(existing);
|
|
5489
5406
|
}
|
|
5490
5407
|
}
|
|
5491
|
-
console.log("add", group, group.name);
|
|
5492
5408
|
this.add(group);
|
|
5493
5409
|
this.notifyDirty();
|
|
5494
5410
|
return group;
|
|
5495
5411
|
}
|
|
5496
5412
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
5497
|
-
const obj = new
|
|
5413
|
+
const obj = new import_three11.Object3D();
|
|
5498
5414
|
if (name) {
|
|
5499
5415
|
obj.name = `group:${name}`;
|
|
5500
5416
|
}
|
|
@@ -5528,11 +5444,9 @@ var init_SceneObject = __esm({
|
|
|
5528
5444
|
if (name) {
|
|
5529
5445
|
const existing = parent.getObjectByName(mesh.name);
|
|
5530
5446
|
if (existing) {
|
|
5531
|
-
console.log("remove", existing.name, existing);
|
|
5532
5447
|
parent.remove(existing);
|
|
5533
5448
|
}
|
|
5534
5449
|
}
|
|
5535
|
-
console.log("add", mesh, mesh.name);
|
|
5536
5450
|
parent.add(mesh);
|
|
5537
5451
|
}
|
|
5538
5452
|
createAndAddMesh(name, group, geometry, material, offsetAxis, offset = 0) {
|
|
@@ -5546,7 +5460,7 @@ var init_SceneObject = __esm({
|
|
|
5546
5460
|
return mesh;
|
|
5547
5461
|
}
|
|
5548
5462
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
5549
|
-
const mesh = new
|
|
5463
|
+
const mesh = new import_three11.Mesh(geometry, material);
|
|
5550
5464
|
if (name) {
|
|
5551
5465
|
mesh.name = `mesh:${name}`;
|
|
5552
5466
|
}
|
|
@@ -5558,7 +5472,7 @@ var init_SceneObject = __esm({
|
|
|
5558
5472
|
return mesh;
|
|
5559
5473
|
}
|
|
5560
5474
|
createInstancedMesh(name, geometry, material, count) {
|
|
5561
|
-
const mesh = new
|
|
5475
|
+
const mesh = new import_three11.InstancedMesh(geometry, material, count);
|
|
5562
5476
|
mesh.count = 0;
|
|
5563
5477
|
this.instanceMesh = mesh;
|
|
5564
5478
|
this._isInstanced = true;
|
|
@@ -5641,11 +5555,11 @@ var init_SceneObject = __esm({
|
|
|
5641
5555
|
this._instanceCounter = this.instanceReferences.size;
|
|
5642
5556
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
5643
5557
|
if (mesh.instanceColor) {
|
|
5644
|
-
mesh.setColorAt(index, new
|
|
5558
|
+
mesh.setColorAt(index, new import_three11.Color(16777215));
|
|
5645
5559
|
mesh.instanceColor.needsUpdate = true;
|
|
5646
5560
|
}
|
|
5647
5561
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
5648
|
-
this.setMatrixAt(index, new
|
|
5562
|
+
this.setMatrixAt(index, new import_three11.Matrix4());
|
|
5649
5563
|
return reference;
|
|
5650
5564
|
}
|
|
5651
5565
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -5659,7 +5573,7 @@ var init_SceneObject = __esm({
|
|
|
5659
5573
|
if (!this.instanceReferences.has(index)) return;
|
|
5660
5574
|
const mesh = this.instanceMesh;
|
|
5661
5575
|
this.hiddenInstanceMatrices.delete(index);
|
|
5662
|
-
this.setMatrixAt(index, new
|
|
5576
|
+
this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
|
|
5663
5577
|
this.instanceReferences.delete(index);
|
|
5664
5578
|
this.freeInstanceIndices.push(index);
|
|
5665
5579
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -5672,7 +5586,7 @@ var init_SceneObject = __esm({
|
|
|
5672
5586
|
const grow = (attribute, fill) => {
|
|
5673
5587
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
5674
5588
|
array.set(attribute.array);
|
|
5675
|
-
return new
|
|
5589
|
+
return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
5676
5590
|
};
|
|
5677
5591
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
5678
5592
|
const color2 = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -5689,7 +5603,7 @@ var init_SceneObject = __esm({
|
|
|
5689
5603
|
}
|
|
5690
5604
|
//</editor-fold>
|
|
5691
5605
|
//<editor-fold desc="TRANSFORMATION">
|
|
5692
|
-
getMatrixAt(index, matrix = new
|
|
5606
|
+
getMatrixAt(index, matrix = new import_three11.Matrix4()) {
|
|
5693
5607
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
5694
5608
|
const hidden = this.hiddenInstanceMatrices.get(index);
|
|
5695
5609
|
if (hidden) {
|
|
@@ -5705,7 +5619,7 @@ var init_SceneObject = __esm({
|
|
|
5705
5619
|
if (hidden) {
|
|
5706
5620
|
hidden.copy(matrix);
|
|
5707
5621
|
}
|
|
5708
|
-
mesh.setMatrixAt(index, hidden ? new
|
|
5622
|
+
mesh.setMatrixAt(index, hidden ? new import_three11.Matrix4().makeScale(0, 0, 0) : matrix);
|
|
5709
5623
|
mesh.instanceMatrix.needsUpdate = true;
|
|
5710
5624
|
mesh.boundingBox = null;
|
|
5711
5625
|
mesh.boundingSphere = null;
|
|
@@ -5733,16 +5647,16 @@ var init_SceneObject = __esm({
|
|
|
5733
5647
|
}
|
|
5734
5648
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
5735
5649
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5736
|
-
const oldPosition = new
|
|
5737
|
-
const oldRotation = new
|
|
5738
|
-
const oldScale = new
|
|
5739
|
-
const matrix = new
|
|
5650
|
+
const oldPosition = new import_three11.Vector3();
|
|
5651
|
+
const oldRotation = new import_three11.Quaternion();
|
|
5652
|
+
const oldScale = new import_three11.Vector3();
|
|
5653
|
+
const matrix = new import_three11.Matrix4();
|
|
5740
5654
|
if (!scale || !rotation || !position) {
|
|
5741
5655
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
5742
5656
|
}
|
|
5743
5657
|
matrix.compose(
|
|
5744
5658
|
position ? position : oldPosition,
|
|
5745
|
-
rotation ? new
|
|
5659
|
+
rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
5746
5660
|
scale ? scale : oldScale
|
|
5747
5661
|
);
|
|
5748
5662
|
this.setMatrixAt(index, matrix);
|
|
@@ -5751,7 +5665,7 @@ var init_SceneObject = __esm({
|
|
|
5751
5665
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5752
5666
|
this.setPositionRotationScaleAt(index, position);
|
|
5753
5667
|
}
|
|
5754
|
-
getPositionAt(index, vector = new
|
|
5668
|
+
getPositionAt(index, vector = new import_three11.Vector3()) {
|
|
5755
5669
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5756
5670
|
const matrix = this.getMatrixAt(index);
|
|
5757
5671
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -5761,17 +5675,17 @@ var init_SceneObject = __esm({
|
|
|
5761
5675
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5762
5676
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
5763
5677
|
}
|
|
5764
|
-
getRotationAt(index, euler = new
|
|
5678
|
+
getRotationAt(index, euler = new import_three11.Euler()) {
|
|
5765
5679
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5766
|
-
const rotation = new
|
|
5767
|
-
this.getMatrixAt(index).decompose(new
|
|
5680
|
+
const rotation = new import_three11.Quaternion();
|
|
5681
|
+
this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
|
|
5768
5682
|
return euler.setFromQuaternion(rotation);
|
|
5769
5683
|
}
|
|
5770
5684
|
setScaleAt(index, scale) {
|
|
5771
5685
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5772
5686
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
5773
5687
|
}
|
|
5774
|
-
getScaleAt(index, vector = new
|
|
5688
|
+
getScaleAt(index, vector = new import_three11.Vector3()) {
|
|
5775
5689
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5776
5690
|
const matrix = this.getMatrixAt(index);
|
|
5777
5691
|
vector.setFromMatrixScale(matrix);
|
|
@@ -5903,6 +5817,87 @@ var init_SceneObject = __esm({
|
|
|
5903
5817
|
}
|
|
5904
5818
|
});
|
|
5905
5819
|
|
|
5820
|
+
// src/util/model.ts
|
|
5821
|
+
function applyElementRotation(rotation, geometry) {
|
|
5822
|
+
const origin = new import_three13.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
5823
|
+
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
5824
|
+
switch (rotation.axis) {
|
|
5825
|
+
case "x" /* X */:
|
|
5826
|
+
geometry.rotateX(toRadians(rotation.angle));
|
|
5827
|
+
break;
|
|
5828
|
+
case "y" /* Y */:
|
|
5829
|
+
geometry.rotateY(toRadians(rotation.angle));
|
|
5830
|
+
break;
|
|
5831
|
+
case "z" /* Z */:
|
|
5832
|
+
geometry.rotateZ(toRadians(rotation.angle));
|
|
5833
|
+
break;
|
|
5834
|
+
}
|
|
5835
|
+
if (rotation.rescale) {
|
|
5836
|
+
const angle = toRadians(rotation.angle);
|
|
5837
|
+
const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));
|
|
5838
|
+
geometry.scale(
|
|
5839
|
+
rotation.axis === "x" /* X */ ? 1 : s,
|
|
5840
|
+
rotation.axis === "y" /* Y */ ? 1 : s,
|
|
5841
|
+
rotation.axis === "z" /* Z */ ? 1 : s
|
|
5842
|
+
);
|
|
5843
|
+
}
|
|
5844
|
+
geometry.translate(origin.x, origin.y, origin.z);
|
|
5845
|
+
}
|
|
5846
|
+
function applyGenericRotation(axis, rotation, obj) {
|
|
5847
|
+
switch (axis) {
|
|
5848
|
+
case "x" /* X */:
|
|
5849
|
+
obj.rotateOnAxis(new import_three13.Vector3(1, 0, 0), toRadians(rotation));
|
|
5850
|
+
break;
|
|
5851
|
+
case "y" /* Y */:
|
|
5852
|
+
obj.rotateOnAxis(new import_three13.Vector3(0, 1, 0), toRadians(rotation));
|
|
5853
|
+
break;
|
|
5854
|
+
case "z" /* Z */:
|
|
5855
|
+
obj.rotateOnAxis(new import_three13.Vector3(0, 0, 1), toRadians(rotation));
|
|
5856
|
+
break;
|
|
5857
|
+
}
|
|
5858
|
+
}
|
|
5859
|
+
function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
|
|
5860
|
+
let size = new import_three13.Vector3();
|
|
5861
|
+
box.getSize(size);
|
|
5862
|
+
let boxGeo = new import_three13.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
5863
|
+
let wireGeo = new import_three13.EdgesGeometry(boxGeo);
|
|
5864
|
+
let wireMat = new import_three13.LineBasicMaterial({ color: color2, linewidth: w });
|
|
5865
|
+
let wireframe = new import_three13.LineSegments(wireGeo, wireMat);
|
|
5866
|
+
obj.add(wireframe);
|
|
5867
|
+
let axes = new import_three13.AxesHelper(1);
|
|
5868
|
+
obj.add(axes);
|
|
5869
|
+
}
|
|
5870
|
+
function addWireframeToObject(obj, color2 = 16777215, w = 2) {
|
|
5871
|
+
let boxGeo = new import_three13.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
5872
|
+
let wireGeo = new import_three13.EdgesGeometry(boxGeo);
|
|
5873
|
+
let wireMat = new import_three13.LineBasicMaterial({ color: color2, linewidth: w });
|
|
5874
|
+
let wireframe = new import_three13.LineSegments(wireGeo, wireMat);
|
|
5875
|
+
obj.add(wireframe);
|
|
5876
|
+
let axes = new import_three13.AxesHelper(1);
|
|
5877
|
+
obj.add(axes);
|
|
5878
|
+
}
|
|
5879
|
+
function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
|
|
5880
|
+
let wireGeo = new import_three13.EdgesGeometry(geo);
|
|
5881
|
+
let wireMat = new import_three13.LineBasicMaterial({ color: color2, linewidth: w });
|
|
5882
|
+
let wireframe = new import_three13.LineSegments(wireGeo, wireMat);
|
|
5883
|
+
mesh.add(wireframe);
|
|
5884
|
+
let axes = new import_three13.AxesHelper(1);
|
|
5885
|
+
mesh.add(axes);
|
|
5886
|
+
return () => {
|
|
5887
|
+
wireGeo.dispose();
|
|
5888
|
+
wireMat.dispose();
|
|
5889
|
+
axes.dispose();
|
|
5890
|
+
};
|
|
5891
|
+
}
|
|
5892
|
+
var import_three13;
|
|
5893
|
+
var init_model = __esm({
|
|
5894
|
+
"src/util/model.ts"() {
|
|
5895
|
+
init_Axis();
|
|
5896
|
+
init_util();
|
|
5897
|
+
import_three13 = require("three");
|
|
5898
|
+
}
|
|
5899
|
+
});
|
|
5900
|
+
|
|
5906
5901
|
// src/entity/scene/EntityObject.ts
|
|
5907
5902
|
var EntityObject_exports = {};
|
|
5908
5903
|
__export(EntityObject_exports, {
|
|
@@ -8419,7 +8414,7 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
8419
8414
|
}
|
|
8420
8415
|
}
|
|
8421
8416
|
}
|
|
8422
|
-
return batches.map(({ image, positions, uvs, colors, indices }) => ({ image, geometry: new import_three20.BufferGeometry().setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3)).setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2)).setAttribute("color", new import_three20.Float32BufferAttribute(
|
|
8417
|
+
return batches.map(({ image, positions, uvs, colors: colors2, indices }) => ({ image, geometry: new import_three20.BufferGeometry().setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3)).setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2)).setAttribute("color", new import_three20.Float32BufferAttribute(colors2, 3)).setIndex(indices) }));
|
|
8423
8418
|
}
|
|
8424
8419
|
var import_three20;
|
|
8425
8420
|
var init_GuiText = __esm({
|
|
@@ -9095,11 +9090,13 @@ var init_ModelCulling = __esm({
|
|
|
9095
9090
|
});
|
|
9096
9091
|
|
|
9097
9092
|
// src/skin/Skins.ts
|
|
9098
|
-
var Skins;
|
|
9093
|
+
var log11, Skins;
|
|
9099
9094
|
var init_Skins = __esm({
|
|
9100
9095
|
"src/skin/Skins.ts"() {
|
|
9101
9096
|
init_Requests();
|
|
9102
9097
|
init_Caching();
|
|
9098
|
+
init_log();
|
|
9099
|
+
log11 = logger("Skins");
|
|
9103
9100
|
Skins = class {
|
|
9104
9101
|
//<editor-fold desc="Skins">
|
|
9105
9102
|
/** Returns a skin URL for {@link MineRenderScene.addSkin}, or `undefined` if name lookup fails. */
|
|
@@ -9171,7 +9168,7 @@ var init_Skins = __esm({
|
|
|
9171
9168
|
}
|
|
9172
9169
|
return void 0;
|
|
9173
9170
|
}).catch((err) => {
|
|
9174
|
-
|
|
9171
|
+
log11.warn(err);
|
|
9175
9172
|
return void 0;
|
|
9176
9173
|
});
|
|
9177
9174
|
}
|
|
@@ -9186,7 +9183,7 @@ var init_Skins = __esm({
|
|
|
9186
9183
|
}
|
|
9187
9184
|
return void 0;
|
|
9188
9185
|
}).catch((err) => {
|
|
9189
|
-
|
|
9186
|
+
log11.warn(err);
|
|
9190
9187
|
return void 0;
|
|
9191
9188
|
});
|
|
9192
9189
|
}
|
|
@@ -9200,7 +9197,7 @@ var init_Skins = __esm({
|
|
|
9200
9197
|
}
|
|
9201
9198
|
return void 0;
|
|
9202
9199
|
}).catch((err) => {
|
|
9203
|
-
|
|
9200
|
+
log11.warn(err);
|
|
9204
9201
|
return void 0;
|
|
9205
9202
|
});
|
|
9206
9203
|
}
|
|
@@ -9224,7 +9221,7 @@ var init_Skins = __esm({
|
|
|
9224
9221
|
}
|
|
9225
9222
|
return void 0;
|
|
9226
9223
|
}).catch((err) => {
|
|
9227
|
-
|
|
9224
|
+
log11.warn(err);
|
|
9228
9225
|
return void 0;
|
|
9229
9226
|
});
|
|
9230
9227
|
}
|
|
@@ -9668,10 +9665,10 @@ var init_SpecialItems = __esm({
|
|
|
9668
9665
|
case "minecraft:shield":
|
|
9669
9666
|
case "shield": {
|
|
9670
9667
|
const banner = special.type === "banner" || special.type === "minecraft:banner";
|
|
9671
|
-
const
|
|
9668
|
+
const colors2 = await BannerPatterns.getColors(root);
|
|
9672
9669
|
const dye = banner ? special.color : components["minecraft:base_color"];
|
|
9673
|
-
if (dye !== void 0 && (typeof dye !== "string" || !Object.prototype.hasOwnProperty.call(
|
|
9674
|
-
const color2 = dye === void 0 ? void 0 :
|
|
9670
|
+
if (dye !== void 0 && (typeof dye !== "string" || !Object.prototype.hasOwnProperty.call(colors2, dye))) throw new Error(`Unsupported dye color ${dye}`);
|
|
9671
|
+
const color2 = dye === void 0 ? void 0 : colors2[dye];
|
|
9675
9672
|
const patterns = await BannerPatterns.getLayers(components["minecraft:banner_patterns"], banner ? "banner" : "shield", root);
|
|
9676
9673
|
const patterned = banner || color2 !== void 0 || patterns.length > 0;
|
|
9677
9674
|
const baseTexture = texture(banner ? "banner_base" : patterned ? "shield_base" : "shield_base_nopattern", "");
|
|
@@ -9696,7 +9693,7 @@ var init_SpecialItems = __esm({
|
|
|
9696
9693
|
}
|
|
9697
9694
|
const tints = {};
|
|
9698
9695
|
if (patterned) {
|
|
9699
|
-
const draws = [{ texture: texture(`${banner ? "banner" : "shield"}/base`, ""), color: color2 ??
|
|
9696
|
+
const draws = [{ texture: texture(`${banner ? "banner" : "shield"}/base`, ""), color: color2 ?? colors2.white }, ...patterns];
|
|
9700
9697
|
draws.forEach((draw, index) => {
|
|
9701
9698
|
const name = index === 0 ? "pattern_base" : `pattern_${index - 1}`;
|
|
9702
9699
|
layers[name] = { key: draw.texture, texture: draw.texture, layer: overlay2, render: "no_outline", tint: name };
|
|
@@ -10026,7 +10023,7 @@ __export(ModelObject_exports, {
|
|
|
10026
10023
|
function isModelObject(obj) {
|
|
10027
10024
|
return obj.isModelObject;
|
|
10028
10025
|
}
|
|
10029
|
-
var import_three27,
|
|
10026
|
+
var import_three27, log12, ModelObject;
|
|
10030
10027
|
var init_ModelObject = __esm({
|
|
10031
10028
|
"src/model/scene/ModelObject.ts"() {
|
|
10032
10029
|
init_SceneObject();
|
|
@@ -10046,7 +10043,7 @@ var init_ModelObject = __esm({
|
|
|
10046
10043
|
init_GuiLight();
|
|
10047
10044
|
init_ItemTints();
|
|
10048
10045
|
init_ItemGlint();
|
|
10049
|
-
|
|
10046
|
+
log12 = logger("ModelObject");
|
|
10050
10047
|
ModelObject = class _ModelObject extends SceneObject {
|
|
10051
10048
|
constructor(originalModel, options) {
|
|
10052
10049
|
super(options);
|
|
@@ -10200,7 +10197,7 @@ var init_ModelObject = __esm({
|
|
|
10200
10197
|
}
|
|
10201
10198
|
UVMapper.setAtlasUvBounds(elGeo, el.faces, this.atlas);
|
|
10202
10199
|
if (this.options.tints) {
|
|
10203
|
-
const
|
|
10200
|
+
const colors2 = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
10204
10201
|
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
10205
10202
|
const tintIndex = el.faces[faceName]?.tintindex;
|
|
10206
10203
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
@@ -10208,10 +10205,10 @@ var init_ModelObject = __esm({
|
|
|
10208
10205
|
if (tint === void 0) continue;
|
|
10209
10206
|
const color2 = new import_three27.Color(tint);
|
|
10210
10207
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
10211
|
-
color2.toArray(
|
|
10208
|
+
color2.toArray(colors2, (faceIndex * 4 + vertex) * 3);
|
|
10212
10209
|
}
|
|
10213
10210
|
}
|
|
10214
|
-
elGeo.setAttribute("color", new import_three27.BufferAttribute(
|
|
10211
|
+
elGeo.setAttribute("color", new import_three27.BufferAttribute(colors2, 3));
|
|
10215
10212
|
}
|
|
10216
10213
|
elGeo.applyMatrix4(new import_three27.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
10217
10214
|
elGeo.applyMatrix4(new import_three27.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
@@ -10231,10 +10228,10 @@ var init_ModelObject = __esm({
|
|
|
10231
10228
|
}
|
|
10232
10229
|
});
|
|
10233
10230
|
} else {
|
|
10234
|
-
|
|
10231
|
+
log12.debug(this.atlas.model, "has no elements");
|
|
10235
10232
|
}
|
|
10236
10233
|
} else {
|
|
10237
|
-
|
|
10234
|
+
log12.debug("Missing atlas for", this);
|
|
10238
10235
|
}
|
|
10239
10236
|
if (this.options.mergeMeshes) {
|
|
10240
10237
|
let combinedGeo;
|
|
@@ -11006,9 +11003,9 @@ var init_FluidModelObject = __esm({
|
|
|
11006
11003
|
}
|
|
11007
11004
|
geometry.clearGroups();
|
|
11008
11005
|
const color2 = new import_three33.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
11009
|
-
const
|
|
11010
|
-
for (let i = 0; i <
|
|
11011
|
-
geometry.setAttribute("color", new import_three33.BufferAttribute(
|
|
11006
|
+
const colors2 = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
11007
|
+
for (let i = 0; i < colors2.length; i += 3) color2.toArray(colors2, i);
|
|
11008
|
+
geometry.setAttribute("color", new import_three33.BufferAttribute(colors2, 3));
|
|
11012
11009
|
geometry.computeBoundingBox();
|
|
11013
11010
|
geometry.computeBoundingSphere();
|
|
11014
11011
|
if (this.options.instanceMeshes) {
|
|
@@ -11045,7 +11042,7 @@ __export(BlockObject_exports, {
|
|
|
11045
11042
|
function isBlockObject(obj) {
|
|
11046
11043
|
return obj.isBlockObject;
|
|
11047
11044
|
}
|
|
11048
|
-
var import_three34, BlockObject;
|
|
11045
|
+
var import_three34, log15, BlockObject;
|
|
11049
11046
|
var init_BlockObject = __esm({
|
|
11050
11047
|
"src/model/block/scene/BlockObject.ts"() {
|
|
11051
11048
|
init_SceneObject();
|
|
@@ -11064,6 +11061,8 @@ var init_BlockObject = __esm({
|
|
|
11064
11061
|
init_BlockEntities();
|
|
11065
11062
|
init_Entities();
|
|
11066
11063
|
init_Biomes();
|
|
11064
|
+
init_log();
|
|
11065
|
+
log15 = logger("BlockObject");
|
|
11067
11066
|
BlockObject = class _BlockObject extends SceneObject {
|
|
11068
11067
|
constructor(blockState3, options) {
|
|
11069
11068
|
super(options);
|
|
@@ -11173,7 +11172,7 @@ var init_BlockObject = __esm({
|
|
|
11173
11172
|
created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
|
|
11174
11173
|
}
|
|
11175
11174
|
} catch (error) {
|
|
11176
|
-
|
|
11175
|
+
log15.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
|
|
11177
11176
|
this.removeEntities(created);
|
|
11178
11177
|
return false;
|
|
11179
11178
|
}
|
|
@@ -11542,6 +11541,7 @@ __export(index_node_exports, {
|
|
|
11542
11541
|
ItemGlint: () => ItemGlint,
|
|
11543
11542
|
ItemTints: () => ItemTints,
|
|
11544
11543
|
LitematicaParser: () => LitematicaParser,
|
|
11544
|
+
Logging: () => Logging,
|
|
11545
11545
|
MapControls: () => MapControls,
|
|
11546
11546
|
Materials: () => Materials,
|
|
11547
11547
|
Meshes: () => Meshes,
|
|
@@ -11656,6 +11656,7 @@ __export(index_node_exports, {
|
|
|
11656
11656
|
isTripleArray: () => isTripleArray,
|
|
11657
11657
|
isVector3: () => isVector3,
|
|
11658
11658
|
layoutGuiText: () => layoutGuiText,
|
|
11659
|
+
logger: () => logger,
|
|
11659
11660
|
md5: () => md5,
|
|
11660
11661
|
mergeBufferAttributes: () => mergeBufferAttributes,
|
|
11661
11662
|
mergeBufferGeometries: () => mergeBufferGeometries,
|
|
@@ -12039,15 +12040,15 @@ var OBJExporter = class {
|
|
|
12039
12040
|
let nbVertex = 0;
|
|
12040
12041
|
const geometry = points.geometry;
|
|
12041
12042
|
const vertices = geometry.getAttribute("position");
|
|
12042
|
-
const
|
|
12043
|
+
const colors2 = geometry.getAttribute("color");
|
|
12043
12044
|
output += "o " + points.name + "\n";
|
|
12044
12045
|
if (vertices !== void 0) {
|
|
12045
12046
|
for (let i = 0, l = vertices.count; i < l; i++, nbVertex++) {
|
|
12046
12047
|
vertex.fromBufferAttribute(vertices, i);
|
|
12047
12048
|
vertex.applyMatrix4(points.matrixWorld);
|
|
12048
12049
|
output += "v " + vertex.x + " " + vertex.y + " " + vertex.z;
|
|
12049
|
-
if (
|
|
12050
|
-
color2.fromBufferAttribute(
|
|
12050
|
+
if (colors2 !== void 0) {
|
|
12051
|
+
color2.fromBufferAttribute(colors2, i);
|
|
12051
12052
|
import_three16.ColorManagement.workingToColorSpace(color2, import_three16.SRGBColorSpace);
|
|
12052
12053
|
output += " " + color2.r + " " + color2.g + " " + color2.b;
|
|
12053
12054
|
}
|
|
@@ -12131,7 +12132,7 @@ var PLYExporter = class {
|
|
|
12131
12132
|
const vertices = geometry.getAttribute("position");
|
|
12132
12133
|
const normals = geometry.getAttribute("normal");
|
|
12133
12134
|
const uvs = geometry.getAttribute("uv");
|
|
12134
|
-
const
|
|
12135
|
+
const colors2 = geometry.getAttribute("color");
|
|
12135
12136
|
const indices = geometry.getIndex();
|
|
12136
12137
|
if (vertices === void 0) {
|
|
12137
12138
|
return;
|
|
@@ -12147,9 +12148,9 @@ var PLYExporter = class {
|
|
|
12147
12148
|
includeUVs = true;
|
|
12148
12149
|
uvType = getPlyType(uvs.array);
|
|
12149
12150
|
}
|
|
12150
|
-
if (
|
|
12151
|
+
if (colors2 !== void 0) {
|
|
12151
12152
|
includeColors = true;
|
|
12152
|
-
colorType = getPlyType(
|
|
12153
|
+
colorType = getPlyType(colors2.array);
|
|
12153
12154
|
}
|
|
12154
12155
|
for (const name of customAttributeNames) {
|
|
12155
12156
|
const attr = geometry.getAttribute(name);
|
|
@@ -12160,16 +12161,16 @@ var PLYExporter = class {
|
|
|
12160
12161
|
const geometry = mesh.geometry;
|
|
12161
12162
|
const vertices = geometry.getAttribute("position");
|
|
12162
12163
|
const normals = geometry.getAttribute("normal");
|
|
12163
|
-
const
|
|
12164
|
+
const colors2 = geometry.getAttribute("color");
|
|
12164
12165
|
vertexCount += vertices.count;
|
|
12165
12166
|
positionType = getPlyType(vertices.array);
|
|
12166
12167
|
if (normals !== void 0) {
|
|
12167
12168
|
includeNormals = true;
|
|
12168
12169
|
normalType = getPlyType(normals.array);
|
|
12169
12170
|
}
|
|
12170
|
-
if (
|
|
12171
|
+
if (colors2 !== void 0) {
|
|
12171
12172
|
includeColors = true;
|
|
12172
|
-
colorType = getPlyType(
|
|
12173
|
+
colorType = getPlyType(colors2.array);
|
|
12173
12174
|
}
|
|
12174
12175
|
for (const name of customAttributeNames) {
|
|
12175
12176
|
const attr = geometry.getAttribute(name);
|
|
@@ -12259,7 +12260,7 @@ property list uchar int vertex_index
|
|
|
12259
12260
|
const vertices = geometry.getAttribute("position");
|
|
12260
12261
|
const normals = geometry.getAttribute("normal");
|
|
12261
12262
|
const uvs = geometry.getAttribute("uv");
|
|
12262
|
-
const
|
|
12263
|
+
const colors2 = geometry.getAttribute("color");
|
|
12263
12264
|
const indices = geometry.getIndex();
|
|
12264
12265
|
normalMatrixWorld.getNormalMatrix(mesh.matrixWorld);
|
|
12265
12266
|
for (let i = 0, l = vertices.count; i < l; i++) {
|
|
@@ -12304,8 +12305,8 @@ property list uchar int vertex_index
|
|
|
12304
12305
|
}
|
|
12305
12306
|
}
|
|
12306
12307
|
if (includeColors === true) {
|
|
12307
|
-
if (
|
|
12308
|
-
tempColor.fromBufferAttribute(
|
|
12308
|
+
if (colors2 != null) {
|
|
12309
|
+
tempColor.fromBufferAttribute(colors2, i);
|
|
12309
12310
|
import_three17.ColorManagement.workingToColorSpace(tempColor, import_three17.SRGBColorSpace);
|
|
12310
12311
|
const r = colorIsFloat ? tempColor.r : Math.round(tempColor.r * colorScale);
|
|
12311
12312
|
const g = colorIsFloat ? tempColor.g : Math.round(tempColor.g * colorScale);
|
|
@@ -12382,7 +12383,7 @@ property list uchar int vertex_index
|
|
|
12382
12383
|
const vertices = geometry.getAttribute("position");
|
|
12383
12384
|
const normals = geometry.getAttribute("normal");
|
|
12384
12385
|
const uvs = geometry.getAttribute("uv");
|
|
12385
|
-
const
|
|
12386
|
+
const colors2 = geometry.getAttribute("color");
|
|
12386
12387
|
const indices = geometry.getIndex();
|
|
12387
12388
|
normalMatrixWorld.getNormalMatrix(mesh.matrixWorld);
|
|
12388
12389
|
for (let i = 0, l = vertices.count; i < l; i++) {
|
|
@@ -12406,8 +12407,8 @@ property list uchar int vertex_index
|
|
|
12406
12407
|
}
|
|
12407
12408
|
}
|
|
12408
12409
|
if (includeColors === true) {
|
|
12409
|
-
if (
|
|
12410
|
-
tempColor.fromBufferAttribute(
|
|
12410
|
+
if (colors2 != null) {
|
|
12411
|
+
tempColor.fromBufferAttribute(colors2, i);
|
|
12411
12412
|
import_three17.ColorManagement.workingToColorSpace(tempColor, import_three17.SRGBColorSpace);
|
|
12412
12413
|
const r = colorIsFloat ? tempColor.r : Math.round(tempColor.r * colorScale);
|
|
12413
12414
|
const g = colorIsFloat ? tempColor.g : Math.round(tempColor.g * colorScale);
|
|
@@ -12649,11 +12650,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
12649
12650
|
if (instanceColor) tint.multiply(instanceColor);
|
|
12650
12651
|
if (bakeColors) {
|
|
12651
12652
|
const original = geometry.getAttribute("color");
|
|
12652
|
-
const
|
|
12653
|
-
for (let i = 0; i <
|
|
12654
|
-
|
|
12653
|
+
const colors2 = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
12654
|
+
for (let i = 0; i < colors2.count; i++) {
|
|
12655
|
+
colors2.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
12655
12656
|
}
|
|
12656
|
-
geometry.setAttribute("color",
|
|
12657
|
+
geometry.setAttribute("color", colors2);
|
|
12657
12658
|
} else if (material.color) {
|
|
12658
12659
|
material.color.copy(tint);
|
|
12659
12660
|
}
|
|
@@ -12702,8 +12703,8 @@ function selectAlphaMode(material, geometry) {
|
|
|
12702
12703
|
const texture = material.map;
|
|
12703
12704
|
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three19.RGBAFormat || texture.type !== import_three19.UnsignedByteType || texture.wrapS !== import_three19.ClampToEdgeWrapping || texture.wrapT !== import_three19.ClampToEdgeWrapping || texture.magFilter !== import_three19.NearestFilter || texture.minFilter !== import_three19.NearestFilter || texture.anisotropy > 1 || texture.offset.x !== 0 || texture.offset.y !== 0 || texture.repeat.x !== 1 || texture.repeat.y !== 1 || texture.rotation !== 0 || !texture.matrixAutoUpdate && !texture.matrix.elements.every((value, i) => value === (i % 4 === 0 ? 1 : 0))) return;
|
|
12704
12705
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
12705
|
-
const
|
|
12706
|
-
if (!uv || material.vertexColors &&
|
|
12706
|
+
const colors2 = geometry.getAttribute("color");
|
|
12707
|
+
if (!uv || material.vertexColors && colors2?.itemSize === 4) return;
|
|
12707
12708
|
const { data, width, height } = texture.image;
|
|
12708
12709
|
if (!data || width < 1 || height < 1 || data.length < width * height * 4) return;
|
|
12709
12710
|
const count = geometry.index?.count ?? uv.count;
|
|
@@ -13112,7 +13113,7 @@ init_SceneObject();
|
|
|
13112
13113
|
init_util();
|
|
13113
13114
|
init_log();
|
|
13114
13115
|
init_three();
|
|
13115
|
-
var
|
|
13116
|
+
var log13 = logger("SceneInspector");
|
|
13116
13117
|
var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
13117
13118
|
var SceneInspector = class {
|
|
13118
13119
|
constructor(renderer) {
|
|
@@ -13206,7 +13207,7 @@ var SceneInspector = class {
|
|
|
13206
13207
|
}
|
|
13207
13208
|
selectObject(targetObject, targetIntersection, instance = this.getIntersectionInstance(targetIntersection)) {
|
|
13208
13209
|
this.selectedObject = targetObject;
|
|
13209
|
-
|
|
13210
|
+
log13.debug("selected", targetObject);
|
|
13210
13211
|
this.redraw(targetObject, targetIntersection, instance);
|
|
13211
13212
|
}
|
|
13212
13213
|
redraw(targetObject, targetIntersection, instance) {
|
|
@@ -13466,7 +13467,7 @@ var SceneStatsDisplay = class {
|
|
|
13466
13467
|
|
|
13467
13468
|
// src/instance/InstanceManager.ts
|
|
13468
13469
|
init_log();
|
|
13469
|
-
var
|
|
13470
|
+
var log14 = logger("InstanceManager");
|
|
13470
13471
|
var InstanceManager = class {
|
|
13471
13472
|
constructor() {
|
|
13472
13473
|
this.isInstanceManager = true;
|
|
@@ -13475,7 +13476,7 @@ var InstanceManager = class {
|
|
|
13475
13476
|
/** Allocates a new placement of a cached model, or returns `undefined` if the key is unknown. */
|
|
13476
13477
|
async get(key) {
|
|
13477
13478
|
if (key in this.instanceCache) {
|
|
13478
|
-
|
|
13479
|
+
log14.debug("key in cache", key);
|
|
13479
13480
|
return (await this.instanceCache[key]).nextInstance();
|
|
13480
13481
|
}
|
|
13481
13482
|
return void 0;
|
|
@@ -13485,7 +13486,7 @@ var InstanceManager = class {
|
|
|
13485
13486
|
if (key in this.instanceCache) {
|
|
13486
13487
|
return await this.get(key);
|
|
13487
13488
|
}
|
|
13488
|
-
|
|
13489
|
+
log14.debug("key not in cache", key);
|
|
13489
13490
|
const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
|
|
13490
13491
|
this.instanceCache[key] = pending;
|
|
13491
13492
|
try {
|
|
@@ -16088,6 +16089,8 @@ var MapControls = class extends OrbitControls {
|
|
|
16088
16089
|
};
|
|
16089
16090
|
|
|
16090
16091
|
// src/renderer/Renderer.ts
|
|
16092
|
+
init_log();
|
|
16093
|
+
var log16 = logger("Renderer");
|
|
16091
16094
|
var Renderer = class _Renderer {
|
|
16092
16095
|
constructor(options, surface) {
|
|
16093
16096
|
this._width = 0;
|
|
@@ -16373,10 +16376,10 @@ var Renderer = class _Renderer {
|
|
|
16373
16376
|
this._element = element;
|
|
16374
16377
|
this._element.appendChild(this.renderer.domElement);
|
|
16375
16378
|
if (this.viewWidth == 0) {
|
|
16376
|
-
|
|
16379
|
+
log16.warn("0 element width");
|
|
16377
16380
|
}
|
|
16378
16381
|
if (this.viewHeight == 0) {
|
|
16379
|
-
|
|
16382
|
+
log16.warn("0 element height");
|
|
16380
16383
|
}
|
|
16381
16384
|
this.resize(this.viewWidth, this.viewHeight);
|
|
16382
16385
|
}
|
|
@@ -17190,8 +17193,62 @@ init_Textures();
|
|
|
17190
17193
|
// src/three/index.ts
|
|
17191
17194
|
init_BufferGeometryUtils();
|
|
17192
17195
|
|
|
17193
|
-
// src/
|
|
17194
|
-
|
|
17196
|
+
// src/util/BatchedExecutor.ts
|
|
17197
|
+
var import_jobqu2 = require("jobqu");
|
|
17198
|
+
var BatchedExecutor = class {
|
|
17199
|
+
/**
|
|
17200
|
+
* @param interval - Delay between queue runs, in milliseconds.
|
|
17201
|
+
* @param batch - Maximum tasks started per run and maximum tasks active at once.
|
|
17202
|
+
*/
|
|
17203
|
+
constructor(interval = 1, batch = 30) {
|
|
17204
|
+
if (!Number.isFinite(interval) || interval < 0) throw new RangeError("Batch interval must be finite and nonnegative");
|
|
17205
|
+
if (!Number.isInteger(batch) || batch < 1) throw new RangeError("Batch size must be a positive integer");
|
|
17206
|
+
this.interval = interval;
|
|
17207
|
+
this.batch = batch;
|
|
17208
|
+
this.queue = new import_jobqu2.JobQueue(async (task) => task(), { interval, maxPerRun: batch, maxActive: batch });
|
|
17209
|
+
}
|
|
17210
|
+
/** Queues a task and resolves with its result, or rejects with its error. */
|
|
17211
|
+
submit(task) {
|
|
17212
|
+
return this.queue.add(() => task());
|
|
17213
|
+
}
|
|
17214
|
+
/** Rejects queued and future tasks. Tasks already running are allowed to finish. */
|
|
17215
|
+
stop() {
|
|
17216
|
+
this.queue.end();
|
|
17217
|
+
}
|
|
17218
|
+
};
|
|
17219
|
+
|
|
17220
|
+
// src/util/index.ts
|
|
17221
|
+
init_log();
|
|
17222
|
+
init_model();
|
|
17223
|
+
|
|
17224
|
+
// src/util/performance.ts
|
|
17225
|
+
function captureException(e, ...extra) {
|
|
17226
|
+
console.error(e, extra);
|
|
17227
|
+
}
|
|
17228
|
+
function timingStart(marker) {
|
|
17229
|
+
console.time(marker);
|
|
17230
|
+
}
|
|
17231
|
+
function timingEnd(marker) {
|
|
17232
|
+
console.timeEnd(marker);
|
|
17233
|
+
}
|
|
17234
|
+
|
|
17235
|
+
// src/util/sha.ts
|
|
17236
|
+
var import_sha1 = __toESM(require("crypto-js/sha1.js"));
|
|
17237
|
+
var import_sha256 = __toESM(require("crypto-js/sha256.js"));
|
|
17238
|
+
var import_sha512 = __toESM(require("crypto-js/sha512.js"));
|
|
17239
|
+
function sha1(str) {
|
|
17240
|
+
return (0, import_sha1.default)(str).toString();
|
|
17241
|
+
}
|
|
17242
|
+
function sha256(str) {
|
|
17243
|
+
return (0, import_sha256.default)(str).toString();
|
|
17244
|
+
}
|
|
17245
|
+
function sha512(str) {
|
|
17246
|
+
return (0, import_sha512.default)(str).toString();
|
|
17247
|
+
}
|
|
17248
|
+
|
|
17249
|
+
// src/util/index.ts
|
|
17250
|
+
init_three();
|
|
17251
|
+
init_util();
|
|
17195
17252
|
|
|
17196
17253
|
// src/world/AnvilParser.ts
|
|
17197
17254
|
init_MineRenderError();
|
|
@@ -18281,6 +18338,8 @@ function hitNormal(hit) {
|
|
|
18281
18338
|
}
|
|
18282
18339
|
|
|
18283
18340
|
// src/world/_entities/WorldEntities.ts
|
|
18341
|
+
init_log();
|
|
18342
|
+
var log17 = logger("WorldEntities");
|
|
18284
18343
|
var WorldEntities = class {
|
|
18285
18344
|
constructor(scene) {
|
|
18286
18345
|
this.scene = scene;
|
|
@@ -18349,7 +18408,7 @@ var WorldEntities = class {
|
|
|
18349
18408
|
placement.owner.set(object4, { type: key.toNamespacedString(), position: placement.position });
|
|
18350
18409
|
this.scene.add(object4);
|
|
18351
18410
|
} catch (error) {
|
|
18352
|
-
|
|
18411
|
+
log17.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error);
|
|
18353
18412
|
} finally {
|
|
18354
18413
|
if (object4 && !placement.owner.has(object4)) object4.dispose();
|
|
18355
18414
|
}
|
|
@@ -18426,14 +18485,14 @@ var BiomeBlend = class {
|
|
|
18426
18485
|
this.tiles.set(key, tile);
|
|
18427
18486
|
} else {
|
|
18428
18487
|
const snapshot = new AssetKey("minecraft", "", void 0, void 0, "assets", ".json", root);
|
|
18429
|
-
const
|
|
18430
|
-
if (!result2.complete && this.tiles.get(key)?.colors ===
|
|
18488
|
+
const colors2 = this.buildTile(kind, snapshot, tileX, quartY, tileZ, this._radius).then((result2) => {
|
|
18489
|
+
if (!result2.complete && this.tiles.get(key)?.colors === colors2) this.tiles.delete(key);
|
|
18431
18490
|
return result2;
|
|
18432
18491
|
}, (error) => {
|
|
18433
|
-
if (this.tiles.get(key)?.colors ===
|
|
18492
|
+
if (this.tiles.get(key)?.colors === colors2) this.tiles.delete(key);
|
|
18434
18493
|
throw error;
|
|
18435
18494
|
});
|
|
18436
|
-
tile = { x: tileX, z: tileZ, colors };
|
|
18495
|
+
tile = { x: tileX, z: tileZ, colors: colors2 };
|
|
18437
18496
|
this.tiles.set(key, tile);
|
|
18438
18497
|
if (this.tiles.size > MAX_TILES) this.tiles.delete(this.tiles.keys().next().value);
|
|
18439
18498
|
}
|
|
@@ -18491,7 +18550,7 @@ var BiomeBlend = class {
|
|
|
18491
18550
|
}
|
|
18492
18551
|
}
|
|
18493
18552
|
}
|
|
18494
|
-
const
|
|
18553
|
+
const colors2 = new Int32Array(256).fill(-1), width = radius * 2 + 1;
|
|
18495
18554
|
for (let z = 0; z < 16; z++) {
|
|
18496
18555
|
for (let x = 0; x < 16; x++) {
|
|
18497
18556
|
if (samples[(z + radius) * size + x + radius] === -1) continue;
|
|
@@ -18499,10 +18558,10 @@ var BiomeBlend = class {
|
|
|
18499
18558
|
const bottomLeft = (z + width) * stride + x, bottomRight = bottomLeft + width;
|
|
18500
18559
|
const sum = (values) => values[bottomRight] - values[bottomLeft] - values[topRight] + values[topLeft];
|
|
18501
18560
|
const count = sum(sums[3]);
|
|
18502
|
-
if (count)
|
|
18561
|
+
if (count) colors2[z * 16 + x] = Math.floor(sum(sums[0]) / count) << 16 | Math.floor(sum(sums[1]) / count) << 8 | Math.floor(sum(sums[2]) / count);
|
|
18503
18562
|
}
|
|
18504
18563
|
}
|
|
18505
|
-
return { colors, complete, failures };
|
|
18564
|
+
return { colors: colors2, complete, failures };
|
|
18506
18565
|
}
|
|
18507
18566
|
};
|
|
18508
18567
|
|
|
@@ -18561,6 +18620,8 @@ function skipsBlockFace(data, rule, block, neighbor, face) {
|
|
|
18561
18620
|
}
|
|
18562
18621
|
|
|
18563
18622
|
// src/world/MineRenderWorld.ts
|
|
18623
|
+
init_log();
|
|
18624
|
+
var log18 = logger("MineRenderWorld");
|
|
18564
18625
|
var MineRenderWorld = class {
|
|
18565
18626
|
constructor(scene, options = {}) {
|
|
18566
18627
|
this._chunks = /* @__PURE__ */ new Map();
|
|
@@ -18650,8 +18711,14 @@ var MineRenderWorld = class {
|
|
|
18650
18711
|
}
|
|
18651
18712
|
return queued;
|
|
18652
18713
|
}
|
|
18653
|
-
async refreshBiomes() {
|
|
18654
|
-
if (this.biomeRefreshing)
|
|
18714
|
+
async refreshBiomes(deferCulling = false) {
|
|
18715
|
+
if (this.biomeRefreshing) {
|
|
18716
|
+
await this.biomeRefreshing;
|
|
18717
|
+
if (!deferCulling) {
|
|
18718
|
+
if (this.pendingCulling.size) await this.updateCulling([]);
|
|
18719
|
+
else await this.culling;
|
|
18720
|
+
}
|
|
18721
|
+
}
|
|
18655
18722
|
if (!this.pendingBiomes.size) return /* @__PURE__ */ new Map();
|
|
18656
18723
|
return this.biomeRefreshing ??= Promise.resolve().then(async () => {
|
|
18657
18724
|
const failures = /* @__PURE__ */ new Map();
|
|
@@ -18663,7 +18730,7 @@ var MineRenderWorld = class {
|
|
|
18663
18730
|
this.pendingBiomes.delete(chunk);
|
|
18664
18731
|
if (this._chunks.get(`${chunk.x}_${chunk.y}_${chunk.z}`) !== chunk) continue;
|
|
18665
18732
|
try {
|
|
18666
|
-
await chunk.refreshBiomes(columns);
|
|
18733
|
+
await chunk.refreshBiomes(columns, deferCulling);
|
|
18667
18734
|
} catch (error) {
|
|
18668
18735
|
failures.set(chunk, error);
|
|
18669
18736
|
if (this._chunks.get(`${chunk.x}_${chunk.y}_${chunk.z}`) === chunk) this.pendingBiomes.set(chunk, void 0);
|
|
@@ -18916,7 +18983,7 @@ var MineRenderWorld = class {
|
|
|
18916
18983
|
} finally {
|
|
18917
18984
|
this.markBiomesChanged(chunk.x, chunk.z, void 0, false);
|
|
18918
18985
|
const failures = await this.refreshBiomes();
|
|
18919
|
-
if (failures.size)
|
|
18986
|
+
if (failures.size) log18.warn("Failed to refresh biome colors", failures.values().next().value);
|
|
18920
18987
|
await this.updateCulling([...changes.values()]);
|
|
18921
18988
|
}
|
|
18922
18989
|
}
|
|
@@ -18925,16 +18992,36 @@ var MineRenderWorld = class {
|
|
|
18925
18992
|
* Coordinates match AnvilChunk.x/z, not block positions. Missing columns are ignored.
|
|
18926
18993
|
*/
|
|
18927
18994
|
async unloadChunkColumn(x, z) {
|
|
18928
|
-
|
|
18929
|
-
|
|
18995
|
+
return this.unloadChunkColumns([{ x, z }]);
|
|
18996
|
+
}
|
|
18997
|
+
/**
|
|
18998
|
+
* Removes chunk columns together and refreshes surviving neighbors once.
|
|
18999
|
+
* Coordinates are absolute chunk columns. Duplicate and missing columns are ignored.
|
|
19000
|
+
*/
|
|
19001
|
+
async unloadChunkColumns(positions) {
|
|
19002
|
+
const columns = /* @__PURE__ */ new Map();
|
|
19003
|
+
for (const position of positions) {
|
|
19004
|
+
const { x, z } = position ?? {};
|
|
19005
|
+
if (!Number.isInteger(x) || !Number.isInteger(z)) {
|
|
19006
|
+
throw new RangeError("Chunk column coordinates must be integers");
|
|
19007
|
+
}
|
|
19008
|
+
columns.set(`${x}_${z}`, { x, z });
|
|
18930
19009
|
}
|
|
18931
|
-
|
|
19010
|
+
if (!columns.size) return;
|
|
18932
19011
|
await this.culling;
|
|
19012
|
+
let sliceStart = performance.now();
|
|
18933
19013
|
try {
|
|
18934
|
-
|
|
19014
|
+
for (const { x, z } of columns.values()) {
|
|
19015
|
+
this.entities?.clearColumn(x, z);
|
|
19016
|
+
await this.clearChunkColumn(x, z);
|
|
19017
|
+
if (performance.now() - sliceStart > 8) {
|
|
19018
|
+
await yieldToEventLoop();
|
|
19019
|
+
sliceStart = performance.now();
|
|
19020
|
+
}
|
|
19021
|
+
}
|
|
18935
19022
|
} finally {
|
|
18936
|
-
const failures = await this.refreshBiomes();
|
|
18937
|
-
if (failures.size)
|
|
19023
|
+
const failures = await this.refreshBiomes(true);
|
|
19024
|
+
if (failures.size) log18.warn("Failed to refresh biome colors", failures.values().next().value);
|
|
18938
19025
|
await this.updateCulling([]);
|
|
18939
19026
|
}
|
|
18940
19027
|
}
|
|
@@ -18996,7 +19083,7 @@ var MineRenderWorld = class {
|
|
|
18996
19083
|
}
|
|
18997
19084
|
this.sectionModels?.clear();
|
|
18998
19085
|
}
|
|
18999
|
-
updateCulling(positions) {
|
|
19086
|
+
updateCulling(positions, defer = false) {
|
|
19000
19087
|
const neighbor = new import_three45.Vector3();
|
|
19001
19088
|
for (const pos of positions) {
|
|
19002
19089
|
const cx = Math.floor(pos.x / 16), cy = Math.floor(pos.y / 16), cz = Math.floor(pos.z / 16);
|
|
@@ -19018,58 +19105,72 @@ var MineRenderWorld = class {
|
|
|
19018
19105
|
}
|
|
19019
19106
|
}
|
|
19020
19107
|
}
|
|
19108
|
+
if (defer) return Promise.resolve();
|
|
19021
19109
|
return this.culling ??= Promise.resolve().then(async () => {
|
|
19022
19110
|
let sliceStart = performance.now();
|
|
19023
19111
|
try {
|
|
19024
19112
|
const culling = await loadBlockCulling();
|
|
19025
19113
|
while (this.pendingCulling.size) {
|
|
19026
|
-
const batch =
|
|
19114
|
+
const batch = new Map(this.pendingCulling);
|
|
19027
19115
|
this.pendingCulling.clear();
|
|
19028
|
-
|
|
19029
|
-
const
|
|
19030
|
-
|
|
19031
|
-
const
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
const
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19116
|
+
try {
|
|
19117
|
+
for (const [chunk, indices] of batch) {
|
|
19118
|
+
const neighbors = CUBE_FACE_OFFSETS.map(([x, y, z]) => this._chunks.get(`${chunk.x + x}_${chunk.y + y}_${chunk.z + z}`));
|
|
19119
|
+
const neighborAt = (x, y, z) => {
|
|
19120
|
+
const lx = x - chunk.x * 16, ly = y - chunk.y * 16, lz = z - chunk.z * 16;
|
|
19121
|
+
const section = neighbors[lx >= 16 ? 0 : lx < 0 ? 1 : ly >= 16 ? 2 : ly < 0 ? 3 : lz >= 16 ? 4 : 5];
|
|
19122
|
+
return [section, (ly & 15) * 256 + (lz & 15) * 16 + (lx & 15)];
|
|
19123
|
+
};
|
|
19124
|
+
const masks = chunk.updateCullMasks(indices === "all" ? void 0 : indices, (x, y, z) => {
|
|
19125
|
+
const [section, i] = neighborAt(x, y, z);
|
|
19126
|
+
return section?.isOccludingIndex(i) ?? false;
|
|
19127
|
+
}, culling, (x, y, z) => {
|
|
19128
|
+
const [section, i] = neighborAt(x, y, z);
|
|
19129
|
+
return section?.visibleBlockIndex(i);
|
|
19130
|
+
});
|
|
19131
|
+
const fluidIndices = indices === "all" ? function* () {
|
|
19132
|
+
for (let index = 0; index < 4096; index++) yield index;
|
|
19133
|
+
}() : indices;
|
|
19134
|
+
for (const index of fluidIndices) {
|
|
19135
|
+
if (!chunk.fluidByteIndex(index) || !chunk.isBlockVisibleIndex(index)) continue;
|
|
19136
|
+
const lx = index % 16, ly = Math.floor(index / 256), lz = Math.floor(index / 16) % 16;
|
|
19137
|
+
const wx = chunk.x * 16 + lx, wy = chunk.y * 16 + ly, wz = chunk.z * 16 + lz;
|
|
19138
|
+
const block = chunk.getBlockAt(neighbor.set(wx, wy, wz));
|
|
19139
|
+
if (block.object?.fluidKind) {
|
|
19140
|
+
await block.object.updateFluid((x, y, z) => {
|
|
19141
|
+
const nx = lx + x, ny = ly + y, nz = lz + z;
|
|
19142
|
+
const section = nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16 ? chunk : this._chunks.get(`${chunk.x + Math.floor(nx / 16)}_${chunk.y + Math.floor(ny / 16)}_${chunk.z + Math.floor(nz / 16)}`);
|
|
19143
|
+
const neighborIndex = (ny & 15) * 256 + (nz & 15) * 16 + (nx & 15);
|
|
19144
|
+
const byte = section?.fluidByteIndex(neighborIndex) ?? 0;
|
|
19145
|
+
return {
|
|
19146
|
+
fluid: fluidKindOf(byte),
|
|
19147
|
+
level: byte & 15,
|
|
19148
|
+
solid: section?.isOccludingIndex(neighborIndex) ?? false
|
|
19149
|
+
};
|
|
19150
|
+
});
|
|
19151
|
+
}
|
|
19152
|
+
}
|
|
19153
|
+
for (const [index, mask] of masks) await chunk.setCullMaskIndex(index, mask);
|
|
19154
|
+
await chunk.refreshLight(indices === "all" ? void 0 : indices);
|
|
19155
|
+
chunk.refreshAmbientOcclusion(this._ambientOcclusion);
|
|
19156
|
+
if ((this._ambientOcclusion || this.ambientOcclusionPending) && performance.now() - sliceStart > 8) {
|
|
19157
|
+
await yieldToEventLoop();
|
|
19158
|
+
sliceStart = performance.now();
|
|
19062
19159
|
}
|
|
19063
19160
|
}
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19161
|
+
const builds = await Promise.allSettled([...batch.keys()].map(async (chunk) => {
|
|
19162
|
+
await chunk.rebuildSectionMesh();
|
|
19163
|
+
batch.delete(chunk);
|
|
19164
|
+
}));
|
|
19165
|
+
const failure = builds.find((result) => result.status === "rejected");
|
|
19166
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
19167
|
+
} catch (error) {
|
|
19168
|
+
for (const [chunk, indices] of batch) {
|
|
19169
|
+
const pending = this.pendingCulling.get(chunk);
|
|
19170
|
+
this.pendingCulling.set(chunk, indices === "all" || pending === "all" ? "all" : /* @__PURE__ */ new Set([...indices, ...pending ?? []]));
|
|
19070
19171
|
}
|
|
19172
|
+
throw error;
|
|
19071
19173
|
}
|
|
19072
|
-
await Promise.all(batch.map(([chunk]) => chunk.rebuildSectionMesh()));
|
|
19073
19174
|
}
|
|
19074
19175
|
} finally {
|
|
19075
19176
|
this.culling = void 0;
|
|
@@ -19086,7 +19187,7 @@ var MineRenderWorld = class {
|
|
|
19086
19187
|
x,
|
|
19087
19188
|
y,
|
|
19088
19189
|
z,
|
|
19089
|
-
(positions) => this.updateCulling(positions),
|
|
19190
|
+
(positions, defer) => this.updateCulling(positions, defer),
|
|
19090
19191
|
this.sectionModels,
|
|
19091
19192
|
(x2, y2, z2) => {
|
|
19092
19193
|
const cx = Math.floor(x2 / 16), cy = Math.floor(y2 / 16), cz = Math.floor(z2 / 16);
|
|
@@ -19359,7 +19460,7 @@ function buildSectionGeometry(input) {
|
|
|
19359
19460
|
}
|
|
19360
19461
|
}
|
|
19361
19462
|
const positions = new Float32Array(faces * 12), normals = new Float32Array(faces * 12);
|
|
19362
|
-
const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16),
|
|
19463
|
+
const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16), colors2 = new Float32Array(faces * 12);
|
|
19363
19464
|
const shade = new Float32Array(faces * 4).fill(1);
|
|
19364
19465
|
const outputIndices = new Uint32Array(faces * 6);
|
|
19365
19466
|
const blockIndices = new Uint16Array(faces);
|
|
@@ -19398,9 +19499,9 @@ function buildSectionGeometry(input) {
|
|
|
19398
19499
|
uvBounds[vertex * 4 + 2] = mapU(template.uvBounds[source * 4 + 2]);
|
|
19399
19500
|
uvBounds[vertex * 4 + 3] = mapV(template.uvBounds[source * 4 + 3]);
|
|
19400
19501
|
const factor = brightness * (ambientMask ? cornerBrightness2[corner] : 1);
|
|
19401
|
-
|
|
19402
|
-
|
|
19403
|
-
|
|
19502
|
+
colors2[vertex * 3] = (tint === void 0 ? template.colors[source * 3] : biomeTints[tint]) * factor;
|
|
19503
|
+
colors2[vertex * 3 + 1] = (tint === void 0 ? template.colors[source * 3 + 1] : biomeTints[tint + 1]) * factor;
|
|
19504
|
+
colors2[vertex * 3 + 2] = (tint === void 0 ? template.colors[source * 3 + 2] : biomeTints[tint + 2]) * factor;
|
|
19404
19505
|
}
|
|
19405
19506
|
for (let corner = 0; corner < 6; corner++) outputIndices[indexOffset++] = start + template.indices[quad * 6 + corner];
|
|
19406
19507
|
}
|
|
@@ -19435,15 +19536,15 @@ function buildSectionGeometry(input) {
|
|
|
19435
19536
|
mapU((rect[0] + rect[2]) / atlas.width),
|
|
19436
19537
|
mapV(1 - rect[1] / atlas.height)
|
|
19437
19538
|
], vertex * 4);
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19539
|
+
colors2[vertex * 3] = tint[0] * brightness;
|
|
19540
|
+
colors2[vertex * 3 + 1] = tint[1] * brightness;
|
|
19541
|
+
colors2[vertex * 3 + 2] = tint[2] * brightness;
|
|
19441
19542
|
}
|
|
19442
19543
|
outputIndices.set([start, start + 1, start + 2, start, start + 2, start + 3], indexOffset);
|
|
19443
19544
|
indexOffset += 6;
|
|
19444
19545
|
}
|
|
19445
19546
|
}
|
|
19446
|
-
return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, shade, indices: outputIndices, blockIndices };
|
|
19547
|
+
return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors: colors2, shade, indices: outputIndices, blockIndices };
|
|
19447
19548
|
});
|
|
19448
19549
|
}
|
|
19449
19550
|
function sectionGeometryTransferables(pages) {
|
|
@@ -19821,11 +19922,14 @@ var Chunk = class _Chunk {
|
|
|
19821
19922
|
this.biomes = copy;
|
|
19822
19923
|
return this.refreshBiomes();
|
|
19823
19924
|
}
|
|
19824
|
-
/**
|
|
19825
|
-
|
|
19826
|
-
|
|
19925
|
+
/**
|
|
19926
|
+
* Rebuilds biome-tinted blocks while preserving hidden blocks and unrelated render objects.
|
|
19927
|
+
* The owning world can defer neighbor culling until all affected chunks are refreshed.
|
|
19928
|
+
*/
|
|
19929
|
+
refreshBiomes(columns, deferCulling = false) {
|
|
19930
|
+
return this.changeBlocks(() => this.refreshBiomeBlocks(columns, deferCulling), true);
|
|
19827
19931
|
}
|
|
19828
|
-
async refreshBiomeBlocks(columns) {
|
|
19932
|
+
async refreshBiomeBlocks(columns, deferCulling = false) {
|
|
19829
19933
|
const blend = columns && this.biomeBlend?.();
|
|
19830
19934
|
const ownColumn = columns?.some((column) => column.x === this.x && column.z === this.z);
|
|
19831
19935
|
const affected = /* @__PURE__ */ new Map();
|
|
@@ -19882,7 +19986,7 @@ var Chunk = class _Chunk {
|
|
|
19882
19986
|
this.renderedBlocks.get(index)?.object?.setVisible(false);
|
|
19883
19987
|
}
|
|
19884
19988
|
const positions = blocks.map(({ index }) => new import_three47.Vector3(...this.positionAt(index)));
|
|
19885
|
-
if (this.onBlocksChanged) await this.onBlocksChanged(positions);
|
|
19989
|
+
if (this.onBlocksChanged) await this.onBlocksChanged(positions, deferCulling);
|
|
19886
19990
|
else await this.rebuildSectionMesh();
|
|
19887
19991
|
}
|
|
19888
19992
|
}
|
|
@@ -20536,19 +20640,12 @@ var WorldStreamer = class {
|
|
|
20536
20640
|
this.loading?.controller.abort();
|
|
20537
20641
|
return this.disposal ??= Promise.resolve().then(async () => {
|
|
20538
20642
|
await this.running?.catch(() => void 0);
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
|
|
20543
|
-
|
|
20544
|
-
} catch (error) {
|
|
20545
|
-
failed = true;
|
|
20546
|
-
failure ??= error;
|
|
20547
|
-
}
|
|
20643
|
+
try {
|
|
20644
|
+
await this.unloadMany([...this.owned.values()]);
|
|
20645
|
+
} finally {
|
|
20646
|
+
this.missing.clear();
|
|
20647
|
+
this.failed.clear();
|
|
20548
20648
|
}
|
|
20549
|
-
this.missing.clear();
|
|
20550
|
-
this.failed.clear();
|
|
20551
|
-
if (failed) throw failure;
|
|
20552
20649
|
}).catch((error) => {
|
|
20553
20650
|
this.disposal = void 0;
|
|
20554
20651
|
throw error;
|
|
@@ -20563,9 +20660,9 @@ var WorldStreamer = class {
|
|
|
20563
20660
|
for (const [key, position2] of this.failed) {
|
|
20564
20661
|
if (!this.within(position2, this.unloadRadius)) this.failed.delete(key);
|
|
20565
20662
|
}
|
|
20566
|
-
const obsolete = [...this.owned.values()].
|
|
20567
|
-
if (obsolete) {
|
|
20568
|
-
await this.
|
|
20663
|
+
const obsolete = [...this.owned.values()].filter((position2) => !this.loaded.has(this.key(position2)) || !this.within(position2, this.unloadRadius));
|
|
20664
|
+
if (obsolete.length) {
|
|
20665
|
+
await this.unloadMany(obsolete);
|
|
20569
20666
|
continue;
|
|
20570
20667
|
}
|
|
20571
20668
|
const position = this.desired.find((position2) => this.needsLoad(position2));
|
|
@@ -20595,7 +20692,7 @@ var WorldStreamer = class {
|
|
|
20595
20692
|
this.loaded.set(this.key(position), position);
|
|
20596
20693
|
} catch (error) {
|
|
20597
20694
|
try {
|
|
20598
|
-
await this.
|
|
20695
|
+
await this.unloadMany([position]);
|
|
20599
20696
|
} catch (cleanupError) {
|
|
20600
20697
|
const failure = error instanceof Error ? error : new Error(String(error));
|
|
20601
20698
|
try {
|
|
@@ -20616,10 +20713,18 @@ var WorldStreamer = class {
|
|
|
20616
20713
|
const key = this.key(position);
|
|
20617
20714
|
return !this.loaded.has(key) && !this.missing.has(key) && !this.failed.has(key);
|
|
20618
20715
|
}
|
|
20619
|
-
async
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20716
|
+
async unloadMany(positions) {
|
|
20717
|
+
if (!positions.length) return;
|
|
20718
|
+
try {
|
|
20719
|
+
await this.world.unloadChunkColumns(positions.map(({ x, z }) => ({ x, z })));
|
|
20720
|
+
} catch (error) {
|
|
20721
|
+
for (const position of positions) this.loaded.delete(this.key(position));
|
|
20722
|
+
throw error;
|
|
20723
|
+
}
|
|
20724
|
+
for (const position of positions) {
|
|
20725
|
+
this.owned.delete(this.key(position));
|
|
20726
|
+
this.loaded.delete(this.key(position));
|
|
20727
|
+
}
|
|
20623
20728
|
}
|
|
20624
20729
|
validateChunk(chunk, position) {
|
|
20625
20730
|
if (chunk.x !== position.x || chunk.z !== position.z) {
|
|
@@ -20863,6 +20968,7 @@ var NodeRenderer = class _NodeRenderer extends Renderer {
|
|
|
20863
20968
|
ItemGlint,
|
|
20864
20969
|
ItemTints,
|
|
20865
20970
|
LitematicaParser,
|
|
20971
|
+
Logging,
|
|
20866
20972
|
MapControls,
|
|
20867
20973
|
Materials,
|
|
20868
20974
|
Meshes,
|
|
@@ -20977,6 +21083,7 @@ var NodeRenderer = class _NodeRenderer extends Renderer {
|
|
|
20977
21083
|
isTripleArray,
|
|
20978
21084
|
isVector3,
|
|
20979
21085
|
layoutGuiText,
|
|
21086
|
+
logger,
|
|
20980
21087
|
md5,
|
|
20981
21088
|
mergeBufferAttributes,
|
|
20982
21089
|
mergeBufferGeometries,
|