minerender 2.1.0-alpha.68 → 2.1.0-alpha.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.mts +80 -3
- package/dist/browser/index.d.ts +80 -3
- package/dist/browser/index.js +440 -171
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +298 -29
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +277 -2
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +80 -3
- package/dist/node/index.d.ts +80 -3
- package/dist/node/index.js +445 -171
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +300 -29
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -259,7 +259,8 @@ var init_Caching = __esm({
|
|
|
259
259
|
this.entityModelCache,
|
|
260
260
|
this.entityTextureCache,
|
|
261
261
|
this.entityAnimationCache,
|
|
262
|
-
this.blockEntityIndexCache
|
|
262
|
+
this.blockEntityIndexCache,
|
|
263
|
+
this.fontCache
|
|
263
264
|
];
|
|
264
265
|
}
|
|
265
266
|
static clear() {
|
|
@@ -306,6 +307,7 @@ var init_Caching = __esm({
|
|
|
306
307
|
_Caching.entityTextureCache = _Caching.createAssetCache();
|
|
307
308
|
_Caching.entityAnimationCache = _Caching.createAssetCache();
|
|
308
309
|
_Caching.blockEntityIndexCache = _Caching.createAssetCache();
|
|
310
|
+
_Caching.fontCache = _Caching.createAssetCache();
|
|
309
311
|
Caching = _Caching;
|
|
310
312
|
}
|
|
311
313
|
});
|
|
@@ -4258,7 +4260,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4258
4260
|
const attributes = {};
|
|
4259
4261
|
const morphAttributes = {};
|
|
4260
4262
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4261
|
-
const mergedGeometry = new
|
|
4263
|
+
const mergedGeometry = new import_three22.BufferGeometry();
|
|
4262
4264
|
let offset = 0;
|
|
4263
4265
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4264
4266
|
const geometry = geometries[i];
|
|
@@ -4382,7 +4384,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4382
4384
|
array.set(attributes[i].array, offset);
|
|
4383
4385
|
offset += attributes[i].array.length;
|
|
4384
4386
|
}
|
|
4385
|
-
return new
|
|
4387
|
+
return new import_three22.BufferAttribute(array, itemSize, normalized);
|
|
4386
4388
|
}
|
|
4387
4389
|
function interleaveAttributes(attributes) {
|
|
4388
4390
|
let TypedArray;
|
|
@@ -4398,7 +4400,7 @@ function interleaveAttributes(attributes) {
|
|
|
4398
4400
|
arrayLength += attribute.array.length;
|
|
4399
4401
|
stride += attribute.itemSize;
|
|
4400
4402
|
}
|
|
4401
|
-
const interleavedBuffer = new
|
|
4403
|
+
const interleavedBuffer = new import_three22.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4402
4404
|
let offset = 0;
|
|
4403
4405
|
const res = [];
|
|
4404
4406
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4407,7 +4409,7 @@ function interleaveAttributes(attributes) {
|
|
|
4407
4409
|
const attribute = attributes[j];
|
|
4408
4410
|
const itemSize = attribute.itemSize;
|
|
4409
4411
|
const count = attribute.count;
|
|
4410
|
-
const iba = new
|
|
4412
|
+
const iba = new import_three22.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4411
4413
|
res.push(iba);
|
|
4412
4414
|
offset += itemSize;
|
|
4413
4415
|
for (let c = 0; c < count; c++) {
|
|
@@ -4491,13 +4493,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4491
4493
|
const name = attributeNames[i];
|
|
4492
4494
|
const oldAttribute = geometry.getAttribute(name);
|
|
4493
4495
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4494
|
-
const attribute = new
|
|
4496
|
+
const attribute = new import_three22.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4495
4497
|
result.setAttribute(name, attribute);
|
|
4496
4498
|
if (name in morphAttrsArrays) {
|
|
4497
4499
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4498
4500
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4499
4501
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4500
|
-
const morphAttribute = new
|
|
4502
|
+
const morphAttribute = new import_three22.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4501
4503
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4502
4504
|
}
|
|
4503
4505
|
}
|
|
@@ -4506,11 +4508,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4506
4508
|
return result;
|
|
4507
4509
|
}
|
|
4508
4510
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4509
|
-
if (drawMode ===
|
|
4511
|
+
if (drawMode === import_three22.TrianglesDrawMode) {
|
|
4510
4512
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4511
4513
|
return geometry;
|
|
4512
4514
|
}
|
|
4513
|
-
if (drawMode ===
|
|
4515
|
+
if (drawMode === import_three22.TriangleFanDrawMode || drawMode === import_three22.TriangleStripDrawMode) {
|
|
4514
4516
|
let index = geometry.getIndex();
|
|
4515
4517
|
if (index === null) {
|
|
4516
4518
|
const indices = [];
|
|
@@ -4528,7 +4530,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4528
4530
|
}
|
|
4529
4531
|
const numberOfTriangles = index.count - 2;
|
|
4530
4532
|
const newIndices = [];
|
|
4531
|
-
if (drawMode ===
|
|
4533
|
+
if (drawMode === import_three22.TriangleFanDrawMode) {
|
|
4532
4534
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4533
4535
|
newIndices.push(index.getX(0));
|
|
4534
4536
|
newIndices.push(index.getX(i));
|
|
@@ -4564,15 +4566,15 @@ function computeMorphedAttributes(object) {
|
|
|
4564
4566
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4565
4567
|
return null;
|
|
4566
4568
|
}
|
|
4567
|
-
const _vA = new
|
|
4568
|
-
const _vB = new
|
|
4569
|
-
const _vC = new
|
|
4570
|
-
const _tempA = new
|
|
4571
|
-
const _tempB = new
|
|
4572
|
-
const _tempC = new
|
|
4573
|
-
const _morphA = new
|
|
4574
|
-
const _morphB = new
|
|
4575
|
-
const _morphC = new
|
|
4569
|
+
const _vA = new import_three22.Vector3();
|
|
4570
|
+
const _vB = new import_three22.Vector3();
|
|
4571
|
+
const _vC = new import_three22.Vector3();
|
|
4572
|
+
const _tempA = new import_three22.Vector3();
|
|
4573
|
+
const _tempB = new import_three22.Vector3();
|
|
4574
|
+
const _tempC = new import_three22.Vector3();
|
|
4575
|
+
const _morphA = new import_three22.Vector3();
|
|
4576
|
+
const _morphB = new import_three22.Vector3();
|
|
4577
|
+
const _morphC = new import_three22.Vector3();
|
|
4576
4578
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4577
4579
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4578
4580
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4767,8 +4769,8 @@ function computeMorphedAttributes(object) {
|
|
|
4767
4769
|
}
|
|
4768
4770
|
}
|
|
4769
4771
|
}
|
|
4770
|
-
const morphedPositionAttribute = new
|
|
4771
|
-
const morphedNormalAttribute = new
|
|
4772
|
+
const morphedPositionAttribute = new import_three22.Float32BufferAttribute(modifiedPosition, 3);
|
|
4773
|
+
const morphedNormalAttribute = new import_three22.Float32BufferAttribute(modifiedNormal, 3);
|
|
4772
4774
|
return {
|
|
4773
4775
|
positionAttribute,
|
|
4774
4776
|
normalAttribute,
|
|
@@ -4776,24 +4778,24 @@ function computeMorphedAttributes(object) {
|
|
|
4776
4778
|
morphedNormalAttribute
|
|
4777
4779
|
};
|
|
4778
4780
|
}
|
|
4779
|
-
var
|
|
4781
|
+
var import_three22;
|
|
4780
4782
|
var init_BufferGeometryUtils = __esm({
|
|
4781
4783
|
"src/three/BufferGeometryUtils.js"() {
|
|
4782
|
-
|
|
4784
|
+
import_three22 = require("three");
|
|
4783
4785
|
}
|
|
4784
4786
|
});
|
|
4785
4787
|
|
|
4786
4788
|
// src/model/ModelCulling.ts
|
|
4787
|
-
var
|
|
4789
|
+
var import_three23, ModelCulling;
|
|
4788
4790
|
var init_ModelCulling = __esm({
|
|
4789
4791
|
"src/model/ModelCulling.ts"() {
|
|
4790
|
-
|
|
4792
|
+
import_three23 = require("three");
|
|
4791
4793
|
init_CubeFace();
|
|
4792
4794
|
ModelCulling = class {
|
|
4793
4795
|
static toLocalMask(worldMask, rotation) {
|
|
4794
4796
|
let localMask = 0;
|
|
4795
4797
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4796
|
-
const normal = new
|
|
4798
|
+
const normal = new import_three23.Vector3(...offset).applyEuler(rotation);
|
|
4797
4799
|
const worldFace = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
4798
4800
|
if (worldFace < 0) return 0;
|
|
4799
4801
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4826,10 +4828,10 @@ var init_ModelCulling = __esm({
|
|
|
4826
4828
|
});
|
|
4827
4829
|
|
|
4828
4830
|
// src/model/SpecialItems.ts
|
|
4829
|
-
var
|
|
4831
|
+
var import_three24, SpecialItems;
|
|
4830
4832
|
var init_SpecialItems = __esm({
|
|
4831
4833
|
"src/model/SpecialItems.ts"() {
|
|
4832
|
-
|
|
4834
|
+
import_three24 = require("three");
|
|
4833
4835
|
init_AssetKey();
|
|
4834
4836
|
init_Entities();
|
|
4835
4837
|
SpecialItems = class {
|
|
@@ -4857,7 +4859,7 @@ var init_SpecialItems = __esm({
|
|
|
4857
4859
|
case "minecraft:chest":
|
|
4858
4860
|
case "chest": {
|
|
4859
4861
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4860
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4862
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three24.Matrix4(), {
|
|
4861
4863
|
lid: [angle, 0, 0],
|
|
4862
4864
|
lock: [angle, 0, 0]
|
|
4863
4865
|
});
|
|
@@ -4866,11 +4868,11 @@ var init_SpecialItems = __esm({
|
|
|
4866
4868
|
}
|
|
4867
4869
|
case "minecraft:bed":
|
|
4868
4870
|
case "bed": {
|
|
4869
|
-
const transform = new
|
|
4871
|
+
const transform = new import_three24.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three24.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three24.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three24.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
4870
4872
|
const key = texture(special.texture, "bed");
|
|
4871
4873
|
return Promise.all([
|
|
4872
4874
|
load("bed_head", key, transform),
|
|
4873
|
-
load("bed_foot", key, new
|
|
4875
|
+
load("bed_foot", key, new import_three24.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4874
4876
|
]);
|
|
4875
4877
|
}
|
|
4876
4878
|
case "minecraft:head":
|
|
@@ -4895,7 +4897,7 @@ var init_SpecialItems = __esm({
|
|
|
4895
4897
|
return [await load(
|
|
4896
4898
|
id,
|
|
4897
4899
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4898
|
-
new
|
|
4900
|
+
new import_three24.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three24.Matrix4().makeScale(-1, -1, 1)),
|
|
4899
4901
|
rotations
|
|
4900
4902
|
)];
|
|
4901
4903
|
}
|
|
@@ -5023,13 +5025,13 @@ var init_ItemTints = __esm({
|
|
|
5023
5025
|
function isModelObject(obj) {
|
|
5024
5026
|
return obj.isModelObject;
|
|
5025
5027
|
}
|
|
5026
|
-
var
|
|
5028
|
+
var import_three25, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
|
|
5027
5029
|
var init_ModelObject = __esm({
|
|
5028
5030
|
"src/model/scene/ModelObject.ts"() {
|
|
5029
5031
|
init_SceneObject();
|
|
5030
5032
|
init_Materials();
|
|
5031
5033
|
init_UVMapper();
|
|
5032
|
-
|
|
5034
|
+
import_three25 = require("three");
|
|
5033
5035
|
init_BufferGeometryUtils();
|
|
5034
5036
|
init_model();
|
|
5035
5037
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -5061,8 +5063,8 @@ var init_ModelObject = __esm({
|
|
|
5061
5063
|
const special = this.originalModel.special;
|
|
5062
5064
|
if (special) {
|
|
5063
5065
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
5064
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
5065
|
-
transform.multiply(new
|
|
5066
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three25.Matrix4();
|
|
5067
|
+
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5066
5068
|
try {
|
|
5067
5069
|
for (const part of parts) {
|
|
5068
5070
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -5125,7 +5127,7 @@ var init_ModelObject = __esm({
|
|
|
5125
5127
|
elGeo.clearGroups();
|
|
5126
5128
|
}
|
|
5127
5129
|
if (this.options.uvLockRotation) {
|
|
5128
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5130
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three25.Euler(...this.options.uvLockRotation));
|
|
5129
5131
|
}
|
|
5130
5132
|
if (this.options.tints) {
|
|
5131
5133
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5134,19 +5136,19 @@ var init_ModelObject = __esm({
|
|
|
5134
5136
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5135
5137
|
const tint = this.options.tints[tintIndex];
|
|
5136
5138
|
if (tint === void 0) continue;
|
|
5137
|
-
const color = new
|
|
5139
|
+
const color = new import_three25.Color(tint);
|
|
5138
5140
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5139
5141
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5140
5142
|
}
|
|
5141
5143
|
}
|
|
5142
|
-
elGeo.setAttribute("color", new
|
|
5144
|
+
elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
|
|
5143
5145
|
}
|
|
5144
|
-
elGeo.applyMatrix4(new
|
|
5145
|
-
elGeo.applyMatrix4(new
|
|
5146
|
+
elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
5147
|
+
elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
5146
5148
|
if (el.rotation) {
|
|
5147
5149
|
applyElementRotation(el.rotation, elGeo);
|
|
5148
5150
|
}
|
|
5149
|
-
elGeo.applyMatrix4(new
|
|
5151
|
+
elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5150
5152
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
5151
5153
|
if (this.options.mergeMeshes) {
|
|
5152
5154
|
allGeos.push(elGeo);
|
|
@@ -5168,7 +5170,7 @@ var init_ModelObject = __esm({
|
|
|
5168
5170
|
if (allGeos.length > 0) {
|
|
5169
5171
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
5170
5172
|
} else {
|
|
5171
|
-
combinedGeo = new
|
|
5173
|
+
combinedGeo = new import_three25.BoxGeometry(16, 16, 16);
|
|
5172
5174
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
5173
5175
|
}
|
|
5174
5176
|
combinedGeo.computeBoundingBox();
|
|
@@ -5280,7 +5282,7 @@ function ownHeight(sample) {
|
|
|
5280
5282
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5281
5283
|
}
|
|
5282
5284
|
function createFluidGeometry(kind, sample) {
|
|
5283
|
-
const geometry = new
|
|
5285
|
+
const geometry = new import_three30.BufferGeometry();
|
|
5284
5286
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5285
5287
|
const self = sample(0, 0, 0);
|
|
5286
5288
|
const height = (x, z) => {
|
|
@@ -5379,16 +5381,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5379
5381
|
1
|
|
5380
5382
|
);
|
|
5381
5383
|
}
|
|
5382
|
-
geometry.setAttribute("position", new
|
|
5383
|
-
geometry.setAttribute("normal", new
|
|
5384
|
-
geometry.setAttribute("uv", new
|
|
5384
|
+
geometry.setAttribute("position", new import_three30.Float32BufferAttribute(positions, 3));
|
|
5385
|
+
geometry.setAttribute("normal", new import_three30.Float32BufferAttribute(normals, 3));
|
|
5386
|
+
geometry.setAttribute("uv", new import_three30.Float32BufferAttribute(uvs, 2));
|
|
5385
5387
|
geometry.setIndex(indices);
|
|
5386
5388
|
return geometry;
|
|
5387
5389
|
}
|
|
5388
|
-
var
|
|
5390
|
+
var import_three30, fluidRules, HORIZONTAL, EPSILON;
|
|
5389
5391
|
var init_FluidGeometry = __esm({
|
|
5390
5392
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5391
|
-
|
|
5393
|
+
import_three30 = require("three");
|
|
5392
5394
|
init_fluidBlocks();
|
|
5393
5395
|
fluidRules = fluidBlocks_default;
|
|
5394
5396
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5417,10 +5419,10 @@ function sampleFluid(kind, sample) {
|
|
|
5417
5419
|
}
|
|
5418
5420
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5419
5421
|
}
|
|
5420
|
-
var
|
|
5422
|
+
var import_three31, FluidModelObject;
|
|
5421
5423
|
var init_FluidModelObject = __esm({
|
|
5422
5424
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5423
|
-
|
|
5425
|
+
import_three31 = require("three");
|
|
5424
5426
|
init_AssetKey();
|
|
5425
5427
|
init_Materials();
|
|
5426
5428
|
init_ModelObject();
|
|
@@ -5453,10 +5455,10 @@ var init_FluidModelObject = __esm({
|
|
|
5453
5455
|
}
|
|
5454
5456
|
}
|
|
5455
5457
|
geometry.clearGroups();
|
|
5456
|
-
const color = new
|
|
5458
|
+
const color = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5457
5459
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5458
5460
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5459
|
-
geometry.setAttribute("color", new
|
|
5461
|
+
geometry.setAttribute("color", new import_three31.BufferAttribute(colors, 3));
|
|
5460
5462
|
geometry.computeBoundingBox();
|
|
5461
5463
|
geometry.computeBoundingSphere();
|
|
5462
5464
|
if (this.options.instanceMeshes) {
|
|
@@ -5470,7 +5472,7 @@ var init_FluidModelObject = __esm({
|
|
|
5470
5472
|
super.applyTextures();
|
|
5471
5473
|
this.iterateAllMeshes((mesh) => {
|
|
5472
5474
|
const material = mesh.material;
|
|
5473
|
-
material.side =
|
|
5475
|
+
material.side = import_three31.DoubleSide;
|
|
5474
5476
|
material.forceSinglePass = true;
|
|
5475
5477
|
material.depthWrite = !material.transparent;
|
|
5476
5478
|
});
|
|
@@ -5532,6 +5534,7 @@ __export(index_browser_exports, {
|
|
|
5532
5534
|
EntityObject: () => EntityObject,
|
|
5533
5535
|
Env: () => Env,
|
|
5534
5536
|
FluidModelObject: () => FluidModelObject,
|
|
5537
|
+
Fonts: () => Fonts,
|
|
5535
5538
|
Geometries: () => Geometries,
|
|
5536
5539
|
GuiHelper: () => GuiHelper,
|
|
5537
5540
|
GuiLight: () => GuiLight,
|
|
@@ -5603,6 +5606,7 @@ __export(index_browser_exports, {
|
|
|
5603
5606
|
computeTangents: () => computeTangents,
|
|
5604
5607
|
createCanvas: () => createCanvas,
|
|
5605
5608
|
createFluidGeometry: () => createFluidGeometry,
|
|
5609
|
+
createGuiTextGeometry: () => createGuiTextGeometry,
|
|
5606
5610
|
createGuiTextureGeometry: () => createGuiTextureGeometry,
|
|
5607
5611
|
createImage: () => createImage,
|
|
5608
5612
|
entityAnimationTime: () => entityAnimationTime,
|
|
@@ -5632,6 +5636,7 @@ __export(index_browser_exports, {
|
|
|
5632
5636
|
isTransformable: () => isTransformable,
|
|
5633
5637
|
isTripleArray: () => isTripleArray,
|
|
5634
5638
|
isVector3: () => isVector3,
|
|
5639
|
+
layoutGuiText: () => layoutGuiText,
|
|
5635
5640
|
md5: () => md5,
|
|
5636
5641
|
mergeBufferAttributes: () => mergeBufferAttributes,
|
|
5637
5642
|
mergeBufferGeometries: () => mergeBufferGeometries,
|
|
@@ -5903,6 +5908,101 @@ var BlockEntities = class {
|
|
|
5903
5908
|
// src/assets/index.ts
|
|
5904
5909
|
init_BlockStates();
|
|
5905
5910
|
init_Entities();
|
|
5911
|
+
|
|
5912
|
+
// src/assets/Fonts.ts
|
|
5913
|
+
init_AssetKey();
|
|
5914
|
+
init_AssetLoader();
|
|
5915
|
+
init_AssetParsers();
|
|
5916
|
+
init_ModelTextures();
|
|
5917
|
+
init_Caching();
|
|
5918
|
+
var Fonts = class {
|
|
5919
|
+
static async get(key = "minecraft:default") {
|
|
5920
|
+
const fontKey = typeof key === "string" ? AssetKey.parse("font", key) : key;
|
|
5921
|
+
return await Caching.fontCache.get(fontKey.serialize(), () => this.load(fontKey, []));
|
|
5922
|
+
}
|
|
5923
|
+
static relatedKey(assetType, id, origin) {
|
|
5924
|
+
const key = AssetKey.parse(assetType, id);
|
|
5925
|
+
key.root = origin.root;
|
|
5926
|
+
return key;
|
|
5927
|
+
}
|
|
5928
|
+
static async load(key, parents) {
|
|
5929
|
+
const serialized = key.serialize();
|
|
5930
|
+
if (parents.includes(serialized)) throw new Error(`Cyclic font reference: ${key.toNamespacedString()}`);
|
|
5931
|
+
const stack = await AssetLoader.getAll(key, "json" /* JSON */);
|
|
5932
|
+
if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
|
|
5933
|
+
const glyphs = /* @__PURE__ */ new Map();
|
|
5934
|
+
for (const asset of stack) {
|
|
5935
|
+
for (const provider of asset.providers) {
|
|
5936
|
+
if (provider.filter?.uniform || provider.filter?.jp) continue;
|
|
5937
|
+
let provided;
|
|
5938
|
+
switch (provider.type) {
|
|
5939
|
+
case "bitmap":
|
|
5940
|
+
case "minecraft:bitmap":
|
|
5941
|
+
provided = await this.bitmap(provider, key);
|
|
5942
|
+
break;
|
|
5943
|
+
case "space":
|
|
5944
|
+
case "minecraft:space":
|
|
5945
|
+
provided = new Map(Object.entries(provider.advances).map(([character, advance]) => [
|
|
5946
|
+
character,
|
|
5947
|
+
{ x: 0, y: 0, width: 0, height: 0, scale: 1, ascent: 0, advance }
|
|
5948
|
+
]));
|
|
5949
|
+
break;
|
|
5950
|
+
case "reference":
|
|
5951
|
+
case "minecraft:reference":
|
|
5952
|
+
provided = (await this.load(this.relatedKey("font", provider.id, key), [...parents, serialized])).glyphs;
|
|
5953
|
+
break;
|
|
5954
|
+
default:
|
|
5955
|
+
continue;
|
|
5956
|
+
}
|
|
5957
|
+
for (const [character, glyph] of provided) {
|
|
5958
|
+
if (character !== "\0" && !glyphs.has(character)) glyphs.set(character, glyph);
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5962
|
+
return { glyphs };
|
|
5963
|
+
}
|
|
5964
|
+
static async bitmap(provider, fontKey) {
|
|
5965
|
+
const rows = provider.chars.map((row) => [...row]);
|
|
5966
|
+
const columns = rows[0]?.length;
|
|
5967
|
+
if (!columns || rows.some((row) => row.length !== columns)) {
|
|
5968
|
+
throw new Error(`Invalid character grid in font ${fontKey.toNamespacedString()}`);
|
|
5969
|
+
}
|
|
5970
|
+
const key = this.relatedKey("textures", provider.file, fontKey);
|
|
5971
|
+
const image = await ModelTextures.get(key);
|
|
5972
|
+
if (!image) throw new Error(`Could not load font texture ${key.toNamespacedString()}`);
|
|
5973
|
+
const width = Math.floor(image.width / columns), height = Math.floor(image.height / rows.length);
|
|
5974
|
+
if (!width || !height) throw new Error(`Font texture ${key.toNamespacedString()} is smaller than its character grid`);
|
|
5975
|
+
const scale = (provider.height ?? 8) / height;
|
|
5976
|
+
const pixels = image.data.getImageData(0, 0, image.width, image.height).data;
|
|
5977
|
+
const glyphs = /* @__PURE__ */ new Map();
|
|
5978
|
+
rows.forEach((row, rowIndex) => row.forEach((character, columnIndex) => {
|
|
5979
|
+
if (character === "\0") return;
|
|
5980
|
+
const x = columnIndex * width, y = rowIndex * height;
|
|
5981
|
+
let occupiedWidth = 0;
|
|
5982
|
+
for (let column = width - 1; column >= 0 && !occupiedWidth; column--) {
|
|
5983
|
+
for (let row2 = 0; row2 < height; row2++) {
|
|
5984
|
+
if (pixels[((y + row2) * image.width + x + column) * 4 + 3] !== 0) {
|
|
5985
|
+
occupiedWidth = column + 1;
|
|
5986
|
+
break;
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
}
|
|
5990
|
+
glyphs.set(character, {
|
|
5991
|
+
image: image.data.canvas,
|
|
5992
|
+
x,
|
|
5993
|
+
y,
|
|
5994
|
+
width,
|
|
5995
|
+
height,
|
|
5996
|
+
scale,
|
|
5997
|
+
ascent: provider.ascent,
|
|
5998
|
+
advance: Math.floor(occupiedWidth * scale + 0.5) + 1
|
|
5999
|
+
});
|
|
6000
|
+
}));
|
|
6001
|
+
return glyphs;
|
|
6002
|
+
}
|
|
6003
|
+
};
|
|
6004
|
+
|
|
6005
|
+
// src/assets/index.ts
|
|
5906
6006
|
init_ModelTextures();
|
|
5907
6007
|
init_Models();
|
|
5908
6008
|
init_source();
|
|
@@ -8860,7 +8960,137 @@ function copyDataTexture(source) {
|
|
|
8860
8960
|
|
|
8861
8961
|
// src/gui/GuiHelper.ts
|
|
8862
8962
|
init_AssetKey();
|
|
8963
|
+
|
|
8964
|
+
// src/gui/GuiText.ts
|
|
8965
|
+
var import_three20 = require("three");
|
|
8966
|
+
async function layoutGuiText(text, options = {}) {
|
|
8967
|
+
const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
|
|
8968
|
+
if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
|
|
8969
|
+
throw new Error("Text wrap width and line height must be positive");
|
|
8970
|
+
}
|
|
8971
|
+
const font = await Fonts.get(options.font);
|
|
8972
|
+
const runs = typeof text === "string" ? [{ text }] : text;
|
|
8973
|
+
const glyphs = [], lineWidths = [];
|
|
8974
|
+
let line = [], width = 0;
|
|
8975
|
+
let trailingNewline = false;
|
|
8976
|
+
const finishLine = (entries) => {
|
|
8977
|
+
let x = 0;
|
|
8978
|
+
for (const entry of entries) {
|
|
8979
|
+
glyphs.push({ ...entry, x, y: lineWidths.length * lineHeight });
|
|
8980
|
+
x += entry.advance;
|
|
8981
|
+
}
|
|
8982
|
+
lineWidths.push(x);
|
|
8983
|
+
};
|
|
8984
|
+
for (const run of runs) {
|
|
8985
|
+
const style = {
|
|
8986
|
+
color: run.color ?? options.color ?? 16777215,
|
|
8987
|
+
bold: run.bold ?? options.bold ?? false,
|
|
8988
|
+
italic: run.italic ?? options.italic ?? false
|
|
8989
|
+
};
|
|
8990
|
+
for (const character of run.text.replace(/\r\n?/g, "\n")) {
|
|
8991
|
+
trailingNewline = character === "\n";
|
|
8992
|
+
if (character === "\n") {
|
|
8993
|
+
finishLine(line);
|
|
8994
|
+
line = [];
|
|
8995
|
+
width = 0;
|
|
8996
|
+
continue;
|
|
8997
|
+
}
|
|
8998
|
+
const glyph = font.glyphs.get(character);
|
|
8999
|
+
const advance = (glyph?.advance ?? 6) + (style.bold ? 1 : 0);
|
|
9000
|
+
line.push({ character, glyph, advance, style, x: 0, y: 0 });
|
|
9001
|
+
width += advance;
|
|
9002
|
+
while (width > maxWidth && line.length > 1) {
|
|
9003
|
+
let space = -1;
|
|
9004
|
+
for (let i = 0; i < line.length; i++) if (line[i].character === " ") space = i;
|
|
9005
|
+
const split = space >= 0 ? space : line.length - 1;
|
|
9006
|
+
if (split > 0) finishLine(line.slice(0, split));
|
|
9007
|
+
line = line.slice(split + (space >= 0 ? 1 : 0));
|
|
9008
|
+
width = line.reduce((sum, entry) => sum + entry.advance, 0);
|
|
9009
|
+
}
|
|
9010
|
+
}
|
|
9011
|
+
}
|
|
9012
|
+
if (line.length || !lineWidths.length || trailingNewline) finishLine(line);
|
|
9013
|
+
return { glyphs, lineWidths, width: Math.max(0, ...lineWidths), height: lineWidths.length * lineHeight };
|
|
9014
|
+
}
|
|
9015
|
+
function createGuiTextGeometry(layout, shadow = true) {
|
|
9016
|
+
const batches = [];
|
|
9017
|
+
for (const isShadow of shadow ? [true, false] : [false]) {
|
|
9018
|
+
let batch;
|
|
9019
|
+
for (const entry of layout.glyphs) {
|
|
9020
|
+
const { glyph, style } = entry;
|
|
9021
|
+
if (glyph && !glyph.image) continue;
|
|
9022
|
+
if (!batch || batch.image !== glyph?.image) {
|
|
9023
|
+
batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
|
|
9024
|
+
batches.push(batch);
|
|
9025
|
+
}
|
|
9026
|
+
const color = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
|
|
9027
|
+
const offset = isShadow ? 1 : 0;
|
|
9028
|
+
const top = glyph ? 7 - glyph.ascent : 0;
|
|
9029
|
+
const height = glyph ? glyph.height * glyph.scale : 8;
|
|
9030
|
+
const width = glyph ? glyph.width * glyph.scale : 5;
|
|
9031
|
+
const shear = (y) => style.italic ? 1 - 0.25 * y : 0;
|
|
9032
|
+
const quad = (left, upper, right, lower, boldOffset) => {
|
|
9033
|
+
const base = batch.positions.length / 3;
|
|
9034
|
+
const x = entry.x + offset + boldOffset, y = entry.y + offset;
|
|
9035
|
+
batch.positions.push(
|
|
9036
|
+
x + left + shear(upper),
|
|
9037
|
+
-y - upper,
|
|
9038
|
+
0,
|
|
9039
|
+
x + right + shear(upper),
|
|
9040
|
+
-y - upper,
|
|
9041
|
+
0,
|
|
9042
|
+
x + left + shear(lower),
|
|
9043
|
+
-y - lower,
|
|
9044
|
+
0,
|
|
9045
|
+
x + right + shear(lower),
|
|
9046
|
+
-y - lower,
|
|
9047
|
+
0
|
|
9048
|
+
);
|
|
9049
|
+
const u0 = glyph ? glyph.x / glyph.image.width : 0;
|
|
9050
|
+
const u1 = glyph ? (glyph.x + glyph.width) / glyph.image.width : 1;
|
|
9051
|
+
const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
|
|
9052
|
+
const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
|
|
9053
|
+
batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
|
|
9054
|
+
for (let i = 0; i < 4; i++) batch.colors.push(color.r, color.g, color.b);
|
|
9055
|
+
batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
|
|
9056
|
+
};
|
|
9057
|
+
for (const boldOffset of style.bold ? [0, 1] : [0]) {
|
|
9058
|
+
if (glyph) quad(0, top, width, top + height, boldOffset);
|
|
9059
|
+
else {
|
|
9060
|
+
quad(0, 0, 5, 1, boldOffset);
|
|
9061
|
+
quad(0, 7, 5, 8, boldOffset);
|
|
9062
|
+
quad(0, 1, 1, 7, boldOffset);
|
|
9063
|
+
quad(4, 1, 5, 7, boldOffset);
|
|
9064
|
+
}
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
}
|
|
9068
|
+
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(colors, 3)).setIndex(indices) }));
|
|
9069
|
+
}
|
|
9070
|
+
|
|
9071
|
+
// src/gui/GuiHelper.ts
|
|
8863
9072
|
var GuiHelper = class {
|
|
9073
|
+
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
9074
|
+
static async tooltip(lines, options = {}) {
|
|
9075
|
+
if (!lines.length) return [];
|
|
9076
|
+
const { position = [0, 0], titleGap = 2, lineHeight = 10, shadow = true, ...style } = options;
|
|
9077
|
+
const textOptions = { ...style, lineHeight, shadow };
|
|
9078
|
+
const layouts = await Promise.all(lines.map((line) => layoutGuiText(line, textOptions)));
|
|
9079
|
+
const width = Math.max(...layouts.map((layout) => layout.width));
|
|
9080
|
+
const height = layouts.reduce((sum, layout) => sum + layout.height, 0) - 2 + (lines.length > 1 ? titleGap : 0);
|
|
9081
|
+
const layers = ["background", "frame"].map((part) => ({
|
|
9082
|
+
name: `tooltip-${part}`,
|
|
9083
|
+
texture: `minecraft:gui/sprites/tooltip/${part}`,
|
|
9084
|
+
position: [position[0] - 12, position[1] - 12],
|
|
9085
|
+
size: [width + 24, height + 24]
|
|
9086
|
+
}));
|
|
9087
|
+
let y = position[1];
|
|
9088
|
+
lines.forEach((text, index) => {
|
|
9089
|
+
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
|
|
9090
|
+
y += layouts[index].height + (index === 0 ? titleGap : 0);
|
|
9091
|
+
});
|
|
9092
|
+
return layers;
|
|
9093
|
+
}
|
|
8864
9094
|
static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
|
|
8865
9095
|
const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
|
|
8866
9096
|
return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
|
|
@@ -8925,11 +9155,11 @@ var GuiHelper = class {
|
|
|
8925
9155
|
};
|
|
8926
9156
|
|
|
8927
9157
|
// src/gui/GuiTextureGeometry.ts
|
|
8928
|
-
var
|
|
9158
|
+
var import_three21 = require("three");
|
|
8929
9159
|
function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
|
|
8930
9160
|
if (crop || !scaling || scaling.type === "stretch") {
|
|
8931
9161
|
const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
|
|
8932
|
-
const geometry = new
|
|
9162
|
+
const geometry = new import_three21.PlaneGeometry(width, height);
|
|
8933
9163
|
const uv = geometry.getAttribute("uv");
|
|
8934
9164
|
for (let i = 0; i < uv.count; i++) {
|
|
8935
9165
|
uv.setXY(
|
|
@@ -9000,11 +9230,11 @@ function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop,
|
|
|
9000
9230
|
}
|
|
9001
9231
|
}
|
|
9002
9232
|
}
|
|
9003
|
-
return new
|
|
9233
|
+
return new import_three21.BufferGeometry().setAttribute("position", new import_three21.Float32BufferAttribute(positions, 3)).setAttribute("normal", new import_three21.Float32BufferAttribute(normals, 3)).setAttribute("uv", new import_three21.Float32BufferAttribute(uvs, 2)).setIndex(indices);
|
|
9004
9234
|
}
|
|
9005
9235
|
|
|
9006
9236
|
// src/gui/scene/GuiObject.ts
|
|
9007
|
-
var
|
|
9237
|
+
var import_three26 = require("three");
|
|
9008
9238
|
init_AssetKey();
|
|
9009
9239
|
init_ModelTextures();
|
|
9010
9240
|
init_Models();
|
|
@@ -9020,9 +9250,10 @@ var GuiObject = class extends SceneObject {
|
|
|
9020
9250
|
this.textureLayers = textureLayers;
|
|
9021
9251
|
this.isGuiObject = true;
|
|
9022
9252
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
9023
|
-
this.bounds = new
|
|
9253
|
+
this.bounds = new import_three26.Box2();
|
|
9024
9254
|
this.geometries = /* @__PURE__ */ new Set();
|
|
9025
9255
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
9256
|
+
this.textMaterials = /* @__PURE__ */ new Map();
|
|
9026
9257
|
this.initialized = false;
|
|
9027
9258
|
}
|
|
9028
9259
|
async init() {
|
|
@@ -9031,6 +9262,43 @@ var GuiObject = class extends SceneObject {
|
|
|
9031
9262
|
let depth = 0;
|
|
9032
9263
|
for (const [index, layer] of this.textureLayers.entries()) {
|
|
9033
9264
|
const [x, y] = layer.position ?? [0, 0];
|
|
9265
|
+
if ("text" in layer) {
|
|
9266
|
+
const layout = await layoutGuiText(layer.text, layer);
|
|
9267
|
+
const group = new import_three26.Group();
|
|
9268
|
+
group.name = `group:${layer.name ?? index}`;
|
|
9269
|
+
group.position.set(x, -y, depth);
|
|
9270
|
+
const [width2, height2] = layer.size ?? [layout.width, layout.height];
|
|
9271
|
+
group.scale.set(layout.width ? width2 / layout.width : 1, height2 / layout.height, 1);
|
|
9272
|
+
this.add(group);
|
|
9273
|
+
const parts = createGuiTextGeometry(layout, layer.shadow);
|
|
9274
|
+
const bounds = new import_three26.Box3();
|
|
9275
|
+
for (const [partIndex, { image: image2, geometry: geometry2 }] of parts.entries()) {
|
|
9276
|
+
this.geometries.add(geometry2);
|
|
9277
|
+
geometry2.computeBoundingBox();
|
|
9278
|
+
bounds.union(geometry2.boundingBox);
|
|
9279
|
+
let material2 = this.textMaterials.get(image2);
|
|
9280
|
+
if (!material2) {
|
|
9281
|
+
material2 = image2 ? Materials.createGuiCanvasMaterial(image2) : new import_three26.MeshBasicMaterial({ transparent: true, depthWrite: false, side: import_three26.DoubleSide, toneMapped: false });
|
|
9282
|
+
material2.vertexColors = true;
|
|
9283
|
+
this.textMaterials.set(image2, material2);
|
|
9284
|
+
this.ownedMaterials.add(material2);
|
|
9285
|
+
}
|
|
9286
|
+
const mesh2 = new import_three26.Mesh(geometry2, material2);
|
|
9287
|
+
mesh2.name = `mesh:${layer.name ?? index}:${partIndex}`;
|
|
9288
|
+
mesh2.renderOrder = index + partIndex / (parts.length + 1) * 0.5;
|
|
9289
|
+
group.add(mesh2);
|
|
9290
|
+
}
|
|
9291
|
+
group.updateMatrix();
|
|
9292
|
+
bounds.applyMatrix4(group.matrix);
|
|
9293
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9294
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
|
|
9295
|
+
if (!bounds.isEmpty()) {
|
|
9296
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
|
|
9297
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
|
|
9298
|
+
}
|
|
9299
|
+
depth += 0.01;
|
|
9300
|
+
continue;
|
|
9301
|
+
}
|
|
9034
9302
|
if ("item" in layer) {
|
|
9035
9303
|
const [width2, height2] = layer.size ?? [16, 16];
|
|
9036
9304
|
const item = await this.createItem(layer, index);
|
|
@@ -9038,17 +9306,17 @@ var GuiObject = class extends SceneObject {
|
|
|
9038
9306
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
9039
9307
|
item.updateWorldMatrix(true, true);
|
|
9040
9308
|
const inverse = this.matrixWorld.clone().invert();
|
|
9041
|
-
const bounds = new
|
|
9309
|
+
const bounds = new import_three26.Box3();
|
|
9042
9310
|
item.iterateAllMeshes((mesh2) => {
|
|
9043
9311
|
mesh2.geometry.computeBoundingBox();
|
|
9044
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
9312
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three26.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
9045
9313
|
});
|
|
9046
9314
|
item.position.z = depth - bounds.min.z;
|
|
9047
9315
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
9048
|
-
this.bounds.expandByPoint(new
|
|
9049
|
-
this.bounds.expandByPoint(new
|
|
9050
|
-
this.bounds.expandByPoint(new
|
|
9051
|
-
this.bounds.expandByPoint(new
|
|
9316
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9317
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
|
|
9318
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
|
|
9319
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
|
|
9052
9320
|
continue;
|
|
9053
9321
|
}
|
|
9054
9322
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -9058,13 +9326,13 @@ var GuiObject = class extends SceneObject {
|
|
|
9058
9326
|
const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
|
|
9059
9327
|
const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
|
|
9060
9328
|
this.geometries.add(geometry);
|
|
9061
|
-
const mesh = new
|
|
9329
|
+
const mesh = new import_three26.Mesh(geometry, material);
|
|
9062
9330
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
9063
9331
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
9064
9332
|
mesh.renderOrder = index;
|
|
9065
9333
|
this.add(mesh);
|
|
9066
|
-
this.bounds.expandByPoint(new
|
|
9067
|
-
this.bounds.expandByPoint(new
|
|
9334
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9335
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width, y + height));
|
|
9068
9336
|
depth += 0.01;
|
|
9069
9337
|
}
|
|
9070
9338
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -9122,10 +9390,11 @@ var GuiObject = class extends SceneObject {
|
|
|
9122
9390
|
for (const geometry of this.geometries) geometry.dispose();
|
|
9123
9391
|
this.geometries.clear();
|
|
9124
9392
|
for (const material of this.ownedMaterials) {
|
|
9125
|
-
material.map
|
|
9393
|
+
material.map?.dispose();
|
|
9126
9394
|
material.dispose();
|
|
9127
9395
|
}
|
|
9128
9396
|
this.ownedMaterials.clear();
|
|
9397
|
+
this.textMaterials.clear();
|
|
9129
9398
|
this.bounds.makeEmpty();
|
|
9130
9399
|
this.initialized = false;
|
|
9131
9400
|
super.disposeAndRemoveAllChildren();
|
|
@@ -9139,7 +9408,7 @@ function isGuiObject(obj) {
|
|
|
9139
9408
|
init_image();
|
|
9140
9409
|
|
|
9141
9410
|
// src/inspector/SceneInspector.ts
|
|
9142
|
-
var
|
|
9411
|
+
var import_three27 = require("three");
|
|
9143
9412
|
init_SceneObject();
|
|
9144
9413
|
init_util();
|
|
9145
9414
|
init_log();
|
|
@@ -9149,11 +9418,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
9149
9418
|
var SceneInspector = class {
|
|
9150
9419
|
constructor(renderer) {
|
|
9151
9420
|
this.renderer = renderer;
|
|
9152
|
-
this.mouse = new
|
|
9421
|
+
this.mouse = new import_three27.Vector2();
|
|
9153
9422
|
this.listeners = new AbortController();
|
|
9154
9423
|
this.objectInfoContainer = document.createElement("div");
|
|
9155
9424
|
this.objectControlsContainer = document.createElement("div");
|
|
9156
|
-
this.raycaster = new
|
|
9425
|
+
this.raycaster = new import_three27.Raycaster();
|
|
9157
9426
|
this.init();
|
|
9158
9427
|
}
|
|
9159
9428
|
init() {
|
|
@@ -9556,7 +9825,7 @@ init_ModelMerger();
|
|
|
9556
9825
|
init_SpecialItems();
|
|
9557
9826
|
|
|
9558
9827
|
// src/model/block/BlockStateResolver.ts
|
|
9559
|
-
var
|
|
9828
|
+
var import_three29 = require("three");
|
|
9560
9829
|
init_BlockStates();
|
|
9561
9830
|
init_MineRenderError();
|
|
9562
9831
|
init_util();
|
|
@@ -9634,7 +9903,7 @@ var BlockStateResolver = class {
|
|
|
9634
9903
|
return variants[variants.length - 1];
|
|
9635
9904
|
}
|
|
9636
9905
|
static rotation(variant) {
|
|
9637
|
-
const rotation = new
|
|
9906
|
+
const rotation = new import_three29.Euler();
|
|
9638
9907
|
if (typeof variant.x !== "undefined") {
|
|
9639
9908
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
9640
9909
|
}
|
|
@@ -9726,7 +9995,7 @@ init_SceneObject();
|
|
|
9726
9995
|
init_ModelObject();
|
|
9727
9996
|
init_Models();
|
|
9728
9997
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9729
|
-
var
|
|
9998
|
+
var import_three32 = require("three");
|
|
9730
9999
|
init_MineRenderError();
|
|
9731
10000
|
init_InstanceReference();
|
|
9732
10001
|
init_AssetKey();
|
|
@@ -9748,7 +10017,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9748
10017
|
this._models = [];
|
|
9749
10018
|
this._cullMask = 0;
|
|
9750
10019
|
this._entities = [];
|
|
9751
|
-
this._entityPlacement = new
|
|
10020
|
+
this._entityPlacement = new import_three32.Matrix4();
|
|
9752
10021
|
this._entityGeneration = 0;
|
|
9753
10022
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9754
10023
|
}
|
|
@@ -9844,7 +10113,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9844
10113
|
return true;
|
|
9845
10114
|
}
|
|
9846
10115
|
placeEntities() {
|
|
9847
|
-
const matrix = new
|
|
10116
|
+
const matrix = new import_three32.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9848
10117
|
for (const entity of this._entities) {
|
|
9849
10118
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9850
10119
|
}
|
|
@@ -9866,12 +10135,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9866
10135
|
getModelCullMask(model, worldMask) {
|
|
9867
10136
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9868
10137
|
if (object.options.displayPosition) return 0;
|
|
9869
|
-
const position = new
|
|
9870
|
-
const rotation = new
|
|
9871
|
-
const scale = new
|
|
10138
|
+
const position = new import_three32.Vector3();
|
|
10139
|
+
const rotation = new import_three32.Quaternion();
|
|
10140
|
+
const scale = new import_three32.Vector3();
|
|
9872
10141
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9873
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9874
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
10142
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three32.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
10143
|
+
return ModelCulling.toLocalMask(worldMask, new import_three32.Euler().setFromQuaternion(rotation));
|
|
9875
10144
|
}
|
|
9876
10145
|
async setCullMask(worldMask) {
|
|
9877
10146
|
worldMask &= 63;
|
|
@@ -9937,7 +10206,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9937
10206
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9938
10207
|
);
|
|
9939
10208
|
const previous = this._fluidModel;
|
|
9940
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
10209
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three32.Matrix4().makeTranslation(...this.position.toArray());
|
|
9941
10210
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9942
10211
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9943
10212
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -10079,7 +10348,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10079
10348
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
10080
10349
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
10081
10350
|
}
|
|
10082
|
-
getMatrixAt(index, matrix = new
|
|
10351
|
+
getMatrixAt(index, matrix = new import_three32.Matrix4()) {
|
|
10083
10352
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
10084
10353
|
const child = this._models[0];
|
|
10085
10354
|
if (child && isModelObject(child)) {
|
|
@@ -11955,7 +12224,7 @@ init_ModelObject();
|
|
|
11955
12224
|
init_nbt();
|
|
11956
12225
|
|
|
11957
12226
|
// src/renderer/MineRenderScene.ts
|
|
11958
|
-
var
|
|
12227
|
+
var import_three34 = require("three");
|
|
11959
12228
|
init_SceneObject();
|
|
11960
12229
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
11961
12230
|
init_ModelObject();
|
|
@@ -12688,7 +12957,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12688
12957
|
init_util();
|
|
12689
12958
|
|
|
12690
12959
|
// src/skin/SkinTextures.ts
|
|
12691
|
-
var
|
|
12960
|
+
var import_three33 = require("three");
|
|
12692
12961
|
init_Caching();
|
|
12693
12962
|
init_CacheKey();
|
|
12694
12963
|
init_MineRenderError();
|
|
@@ -12772,11 +13041,11 @@ var SkinTextures = class {
|
|
|
12772
13041
|
});
|
|
12773
13042
|
}
|
|
12774
13043
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12775
|
-
const texture = Textures.initTextureProps(new
|
|
12776
|
-
texture.colorSpace =
|
|
13044
|
+
const texture = Textures.initTextureProps(new import_three33.DataTexture(pixels, width, height));
|
|
13045
|
+
texture.colorSpace = import_three33.SRGBColorSpace;
|
|
12777
13046
|
texture.flipY = true;
|
|
12778
13047
|
texture.needsUpdate = true;
|
|
12779
|
-
return new
|
|
13048
|
+
return new import_three33.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three33.DoubleSide : import_three33.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12780
13049
|
}
|
|
12781
13050
|
static isSlim(image, scale) {
|
|
12782
13051
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -13006,7 +13275,7 @@ var SkinObject = class extends SceneObject {
|
|
|
13006
13275
|
// src/renderer/MineRenderScene.ts
|
|
13007
13276
|
init_EntityObject();
|
|
13008
13277
|
init_ItemTints();
|
|
13009
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
13278
|
+
var _MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
13010
13279
|
constructor(options) {
|
|
13011
13280
|
super();
|
|
13012
13281
|
this.isMineRenderScene = true;
|
|
@@ -13135,7 +13404,7 @@ function isMineRenderScene(obj) {
|
|
|
13135
13404
|
}
|
|
13136
13405
|
|
|
13137
13406
|
// src/renderer/Renderer.ts
|
|
13138
|
-
var
|
|
13407
|
+
var import_three36 = require("three");
|
|
13139
13408
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
13140
13409
|
var import_stats = __toESM(require("stats.js"));
|
|
13141
13410
|
var import_postprocessing = require("postprocessing");
|
|
@@ -13144,11 +13413,11 @@ init_Model();
|
|
|
13144
13413
|
init_three();
|
|
13145
13414
|
|
|
13146
13415
|
// src/three/OrbitControls.js
|
|
13147
|
-
var
|
|
13416
|
+
var import_three35 = require("three");
|
|
13148
13417
|
var _changeEvent = { type: "change" };
|
|
13149
13418
|
var _startEvent = { type: "start" };
|
|
13150
13419
|
var _endEvent = { type: "end" };
|
|
13151
|
-
var OrbitControls = class extends
|
|
13420
|
+
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13152
13421
|
constructor(object, domElement) {
|
|
13153
13422
|
super();
|
|
13154
13423
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -13157,7 +13426,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13157
13426
|
this.domElement = domElement;
|
|
13158
13427
|
this.domElement.style.touchAction = "none";
|
|
13159
13428
|
this.enabled = true;
|
|
13160
|
-
this.target = new
|
|
13429
|
+
this.target = new import_three35.Vector3();
|
|
13161
13430
|
this.minDistance = 0;
|
|
13162
13431
|
this.maxDistance = Infinity;
|
|
13163
13432
|
this.minZoom = 0;
|
|
@@ -13179,8 +13448,8 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13179
13448
|
this.autoRotate = false;
|
|
13180
13449
|
this.autoRotateSpeed = 2;
|
|
13181
13450
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
13182
|
-
this.mouseButtons = { LEFT:
|
|
13183
|
-
this.touches = { ONE:
|
|
13451
|
+
this.mouseButtons = { LEFT: import_three35.MOUSE.ROTATE, MIDDLE: import_three35.MOUSE.DOLLY, RIGHT: import_three35.MOUSE.PAN };
|
|
13452
|
+
this.touches = { ONE: import_three35.TOUCH.ROTATE, TWO: import_three35.TOUCH.DOLLY_PAN };
|
|
13184
13453
|
this.target0 = this.target.clone();
|
|
13185
13454
|
this.position0 = this.object.position.clone();
|
|
13186
13455
|
this.zoom0 = this.object.zoom;
|
|
@@ -13209,11 +13478,11 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13209
13478
|
state = STATE.NONE;
|
|
13210
13479
|
};
|
|
13211
13480
|
this.update = function() {
|
|
13212
|
-
const offset = new
|
|
13213
|
-
const quat = new
|
|
13481
|
+
const offset = new import_three35.Vector3();
|
|
13482
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object.up, new import_three35.Vector3(0, 1, 0));
|
|
13214
13483
|
const quatInverse = quat.clone().invert();
|
|
13215
|
-
const lastPosition = new
|
|
13216
|
-
const lastQuaternion = new
|
|
13484
|
+
const lastPosition = new import_three35.Vector3();
|
|
13485
|
+
const lastQuaternion = new import_three35.Quaternion();
|
|
13217
13486
|
const twoPI = 2 * Math.PI;
|
|
13218
13487
|
return function update() {
|
|
13219
13488
|
const position = scope.object.position;
|
|
@@ -13299,20 +13568,20 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13299
13568
|
};
|
|
13300
13569
|
let state = STATE.NONE;
|
|
13301
13570
|
const EPS = 1e-6;
|
|
13302
|
-
const spherical = new
|
|
13303
|
-
const sphericalDelta = new
|
|
13571
|
+
const spherical = new import_three35.Spherical();
|
|
13572
|
+
const sphericalDelta = new import_three35.Spherical();
|
|
13304
13573
|
let scale = 1;
|
|
13305
|
-
const panOffset = new
|
|
13574
|
+
const panOffset = new import_three35.Vector3();
|
|
13306
13575
|
let zoomChanged = false;
|
|
13307
|
-
const rotateStart = new
|
|
13308
|
-
const rotateEnd = new
|
|
13309
|
-
const rotateDelta = new
|
|
13310
|
-
const panStart = new
|
|
13311
|
-
const panEnd = new
|
|
13312
|
-
const panDelta = new
|
|
13313
|
-
const dollyStart = new
|
|
13314
|
-
const dollyEnd = new
|
|
13315
|
-
const dollyDelta = new
|
|
13576
|
+
const rotateStart = new import_three35.Vector2();
|
|
13577
|
+
const rotateEnd = new import_three35.Vector2();
|
|
13578
|
+
const rotateDelta = new import_three35.Vector2();
|
|
13579
|
+
const panStart = new import_three35.Vector2();
|
|
13580
|
+
const panEnd = new import_three35.Vector2();
|
|
13581
|
+
const panDelta = new import_three35.Vector2();
|
|
13582
|
+
const dollyStart = new import_three35.Vector2();
|
|
13583
|
+
const dollyEnd = new import_three35.Vector2();
|
|
13584
|
+
const dollyDelta = new import_three35.Vector2();
|
|
13316
13585
|
const pointers = [];
|
|
13317
13586
|
const pointerPositions = {};
|
|
13318
13587
|
function getAutoRotationAngle() {
|
|
@@ -13328,7 +13597,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13328
13597
|
sphericalDelta.phi -= angle;
|
|
13329
13598
|
}
|
|
13330
13599
|
const panLeft = function() {
|
|
13331
|
-
const v = new
|
|
13600
|
+
const v = new import_three35.Vector3();
|
|
13332
13601
|
return function panLeft2(distance, objectMatrix) {
|
|
13333
13602
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
13334
13603
|
v.multiplyScalar(-distance);
|
|
@@ -13336,7 +13605,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13336
13605
|
};
|
|
13337
13606
|
}();
|
|
13338
13607
|
const panUp = function() {
|
|
13339
|
-
const v = new
|
|
13608
|
+
const v = new import_three35.Vector3();
|
|
13340
13609
|
return function panUp2(distance, objectMatrix) {
|
|
13341
13610
|
if (scope.screenSpacePanning === true) {
|
|
13342
13611
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -13349,7 +13618,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13349
13618
|
};
|
|
13350
13619
|
}();
|
|
13351
13620
|
const pan = function() {
|
|
13352
|
-
const offset = new
|
|
13621
|
+
const offset = new import_three35.Vector3();
|
|
13353
13622
|
return function pan2(deltaX, deltaY) {
|
|
13354
13623
|
const element = scope.domElement;
|
|
13355
13624
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13598,12 +13867,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13598
13867
|
mouseAction = -1;
|
|
13599
13868
|
}
|
|
13600
13869
|
switch (mouseAction) {
|
|
13601
|
-
case
|
|
13870
|
+
case import_three35.MOUSE.DOLLY:
|
|
13602
13871
|
if (scope.enableZoom === false) return;
|
|
13603
13872
|
handleMouseDownDolly(event);
|
|
13604
13873
|
state = STATE.DOLLY;
|
|
13605
13874
|
break;
|
|
13606
|
-
case
|
|
13875
|
+
case import_three35.MOUSE.ROTATE:
|
|
13607
13876
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13608
13877
|
if (scope.enablePan === false) return;
|
|
13609
13878
|
handleMouseDownPan(event);
|
|
@@ -13614,7 +13883,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13614
13883
|
state = STATE.ROTATE;
|
|
13615
13884
|
}
|
|
13616
13885
|
break;
|
|
13617
|
-
case
|
|
13886
|
+
case import_three35.MOUSE.PAN:
|
|
13618
13887
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13619
13888
|
if (scope.enableRotate === false) return;
|
|
13620
13889
|
handleMouseDownRotate(event);
|
|
@@ -13670,12 +13939,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13670
13939
|
switch (pointers.length) {
|
|
13671
13940
|
case 1:
|
|
13672
13941
|
switch (scope.touches.ONE) {
|
|
13673
|
-
case
|
|
13942
|
+
case import_three35.TOUCH.ROTATE:
|
|
13674
13943
|
if (scope.enableRotate === false) return;
|
|
13675
13944
|
handleTouchStartRotate();
|
|
13676
13945
|
state = STATE.TOUCH_ROTATE;
|
|
13677
13946
|
break;
|
|
13678
|
-
case
|
|
13947
|
+
case import_three35.TOUCH.PAN:
|
|
13679
13948
|
if (scope.enablePan === false) return;
|
|
13680
13949
|
handleTouchStartPan();
|
|
13681
13950
|
state = STATE.TOUCH_PAN;
|
|
@@ -13686,12 +13955,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13686
13955
|
break;
|
|
13687
13956
|
case 2:
|
|
13688
13957
|
switch (scope.touches.TWO) {
|
|
13689
|
-
case
|
|
13958
|
+
case import_three35.TOUCH.DOLLY_PAN:
|
|
13690
13959
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13691
13960
|
handleTouchStartDollyPan();
|
|
13692
13961
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13693
13962
|
break;
|
|
13694
|
-
case
|
|
13963
|
+
case import_three35.TOUCH.DOLLY_ROTATE:
|
|
13695
13964
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13696
13965
|
handleTouchStartDollyRotate();
|
|
13697
13966
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13758,7 +14027,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13758
14027
|
function trackPointer(event) {
|
|
13759
14028
|
let position = pointerPositions[event.pointerId];
|
|
13760
14029
|
if (position === void 0) {
|
|
13761
|
-
position = new
|
|
14030
|
+
position = new import_three35.Vector2();
|
|
13762
14031
|
pointerPositions[event.pointerId] = position;
|
|
13763
14032
|
}
|
|
13764
14033
|
position.set(event.pageX, event.pageY);
|
|
@@ -13778,10 +14047,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13778
14047
|
constructor(object, domElement) {
|
|
13779
14048
|
super(object, domElement);
|
|
13780
14049
|
this.screenSpacePanning = false;
|
|
13781
|
-
this.mouseButtons.LEFT =
|
|
13782
|
-
this.mouseButtons.RIGHT =
|
|
13783
|
-
this.touches.ONE =
|
|
13784
|
-
this.touches.TWO =
|
|
14050
|
+
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14051
|
+
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
14052
|
+
this.touches.ONE = import_three35.TOUCH.PAN;
|
|
14053
|
+
this.touches.TWO = import_three35.TOUCH.DOLLY_ROTATE;
|
|
13785
14054
|
}
|
|
13786
14055
|
};
|
|
13787
14056
|
|
|
@@ -13832,14 +14101,14 @@ var _Renderer = class _Renderer {
|
|
|
13832
14101
|
switch (this.options.camera.type) {
|
|
13833
14102
|
case "perspective":
|
|
13834
14103
|
default:
|
|
13835
|
-
return new
|
|
14104
|
+
return new import_three36.PerspectiveCamera(
|
|
13836
14105
|
this.options.camera.perspective.fov,
|
|
13837
14106
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13838
14107
|
this.options.camera.near,
|
|
13839
14108
|
this.options.camera.far
|
|
13840
14109
|
);
|
|
13841
14110
|
case "orthographic":
|
|
13842
|
-
return new
|
|
14111
|
+
return new import_three36.OrthographicCamera(
|
|
13843
14112
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13844
14113
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13845
14114
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13850,7 +14119,7 @@ var _Renderer = class _Renderer {
|
|
|
13850
14119
|
}
|
|
13851
14120
|
}
|
|
13852
14121
|
createRenderer() {
|
|
13853
|
-
const renderer = new
|
|
14122
|
+
const renderer = new import_three36.WebGLRenderer({
|
|
13854
14123
|
antialias: this.options.render.antialias,
|
|
13855
14124
|
alpha: true,
|
|
13856
14125
|
powerPreference: "high-performance",
|
|
@@ -13858,8 +14127,8 @@ var _Renderer = class _Renderer {
|
|
|
13858
14127
|
});
|
|
13859
14128
|
renderer.setClearColor(0, 0);
|
|
13860
14129
|
renderer.shadowMap.enabled = true;
|
|
13861
|
-
renderer.shadowMap.type =
|
|
13862
|
-
renderer.outputColorSpace =
|
|
14130
|
+
renderer.shadowMap.type = import_three36.PCFShadowMap;
|
|
14131
|
+
renderer.outputColorSpace = import_three36.SRGBColorSpace;
|
|
13863
14132
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13864
14133
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13865
14134
|
return renderer;
|
|
@@ -13894,20 +14163,20 @@ var _Renderer = class _Renderer {
|
|
|
13894
14163
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13895
14164
|
}
|
|
13896
14165
|
if (this.options.debug.grid) {
|
|
13897
|
-
const gridHelper = new
|
|
14166
|
+
const gridHelper = new import_three36.GridHelper(128, 16);
|
|
13898
14167
|
this._debugHelpers.push(gridHelper);
|
|
13899
14168
|
this.scene.add(gridHelper);
|
|
13900
|
-
const gridHelper2 = new
|
|
14169
|
+
const gridHelper2 = new import_three36.GridHelper(128, 16);
|
|
13901
14170
|
this._debugHelpers.push(gridHelper2);
|
|
13902
14171
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13903
14172
|
this.scene.add(gridHelper2);
|
|
13904
|
-
const gridHelper3 = new
|
|
14173
|
+
const gridHelper3 = new import_three36.GridHelper(128, 16);
|
|
13905
14174
|
this._debugHelpers.push(gridHelper3);
|
|
13906
14175
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13907
14176
|
this.scene.add(gridHelper3);
|
|
13908
14177
|
}
|
|
13909
14178
|
if (this.options.debug.axes) {
|
|
13910
|
-
const axesHelper = new
|
|
14179
|
+
const axesHelper = new import_three36.AxesHelper(64);
|
|
13911
14180
|
this._debugHelpers.push(axesHelper);
|
|
13912
14181
|
this.scene.add(axesHelper);
|
|
13913
14182
|
}
|
|
@@ -14166,8 +14435,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
14166
14435
|
top: void 0,
|
|
14167
14436
|
bottom: void 0
|
|
14168
14437
|
},
|
|
14169
|
-
position: new
|
|
14170
|
-
lookingAt: new
|
|
14438
|
+
position: new import_three36.Vector3(50, 50, 50),
|
|
14439
|
+
lookingAt: new import_three36.Vector3(0, 0, 0)
|
|
14171
14440
|
},
|
|
14172
14441
|
render: {
|
|
14173
14442
|
fpsLimit: 60,
|
|
@@ -14632,12 +14901,12 @@ var AnvilParser = class {
|
|
|
14632
14901
|
};
|
|
14633
14902
|
|
|
14634
14903
|
// src/world/Chunk.ts
|
|
14635
|
-
var
|
|
14904
|
+
var import_three41 = require("three");
|
|
14636
14905
|
init_BlockStates();
|
|
14637
14906
|
init_AssetKey();
|
|
14638
14907
|
|
|
14639
14908
|
// src/world/MineRenderWorld.ts
|
|
14640
|
-
var
|
|
14909
|
+
var import_three39 = require("three");
|
|
14641
14910
|
init_Model();
|
|
14642
14911
|
init_BatchedExecutor();
|
|
14643
14912
|
init_AssetKey();
|
|
@@ -14645,7 +14914,7 @@ init_BlockStates();
|
|
|
14645
14914
|
init_CubeFace();
|
|
14646
14915
|
|
|
14647
14916
|
// src/world/SectionModels.ts
|
|
14648
|
-
var
|
|
14917
|
+
var import_three38 = require("three");
|
|
14649
14918
|
init_AssetKey();
|
|
14650
14919
|
init_Models();
|
|
14651
14920
|
init_CubeFace();
|
|
@@ -14711,12 +14980,12 @@ var SectionModels = class {
|
|
|
14711
14980
|
});
|
|
14712
14981
|
await object.init();
|
|
14713
14982
|
const geometry = object.children[0].geometry;
|
|
14714
|
-
geometry.applyMatrix4(new
|
|
14983
|
+
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
14715
14984
|
object.clear();
|
|
14716
14985
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14717
14986
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14718
14987
|
if (local < 0) return 0;
|
|
14719
|
-
const normal = new
|
|
14988
|
+
const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14720
14989
|
const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
14721
14990
|
return 1 << world;
|
|
14722
14991
|
});
|
|
@@ -14746,20 +15015,20 @@ var MineRenderWorld = class {
|
|
|
14746
15015
|
}
|
|
14747
15016
|
getBlockAt(posOrX, y, z) {
|
|
14748
15017
|
if (typeof posOrX == "number") {
|
|
14749
|
-
return this.getBlockAt(new
|
|
15018
|
+
return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
|
|
14750
15019
|
}
|
|
14751
15020
|
if (isTripleArray(posOrX)) {
|
|
14752
|
-
return this.getBlockAt(new
|
|
15021
|
+
return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14753
15022
|
}
|
|
14754
15023
|
this.validatePosBounds(posOrX);
|
|
14755
15024
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14756
15025
|
}
|
|
14757
15026
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14758
15027
|
if (typeof posOrX == "number") {
|
|
14759
|
-
return this.setBlockAt(new
|
|
15028
|
+
return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
|
|
14760
15029
|
}
|
|
14761
15030
|
if (isTripleArray(posOrX)) {
|
|
14762
|
-
return this.setBlockAt(new
|
|
15031
|
+
return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14763
15032
|
}
|
|
14764
15033
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14765
15034
|
}
|
|
@@ -14770,10 +15039,10 @@ var MineRenderWorld = class {
|
|
|
14770
15039
|
}
|
|
14771
15040
|
async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
|
|
14772
15041
|
if (typeof posOrX === "number") {
|
|
14773
|
-
return this.setBlockVisibleAt(new
|
|
15042
|
+
return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
|
|
14774
15043
|
}
|
|
14775
15044
|
if (isTripleArray(posOrX)) {
|
|
14776
|
-
return this.setBlockVisibleAt(new
|
|
15045
|
+
return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
|
|
14777
15046
|
}
|
|
14778
15047
|
this.validatePosBounds(posOrX);
|
|
14779
15048
|
await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
|
|
@@ -14790,7 +15059,7 @@ var MineRenderWorld = class {
|
|
|
14790
15059
|
const collect = async (positions2) => {
|
|
14791
15060
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14792
15061
|
};
|
|
14793
|
-
const place = (block) => this.placeBlock(new
|
|
15062
|
+
const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
|
|
14794
15063
|
const keys = /* @__PURE__ */ new Map();
|
|
14795
15064
|
for (const block of multiblock.blocks) {
|
|
14796
15065
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14868,13 +15137,13 @@ var MineRenderWorld = class {
|
|
|
14868
15137
|
for (const pos of positions) {
|
|
14869
15138
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14870
15139
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14871
|
-
const neighbor = pos.clone().add(new
|
|
15140
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
|
|
14872
15141
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14873
15142
|
}
|
|
14874
15143
|
for (let y = -1; y <= 1; y++) {
|
|
14875
15144
|
for (let z = -1; z <= 1; z++) {
|
|
14876
15145
|
for (let x = -1; x <= 1; x++) {
|
|
14877
|
-
const neighbor = pos.clone().add(new
|
|
15146
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
14878
15147
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14879
15148
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14880
15149
|
}
|
|
@@ -14898,7 +15167,7 @@ var MineRenderWorld = class {
|
|
|
14898
15167
|
}
|
|
14899
15168
|
if (block.object?.fluidKind) {
|
|
14900
15169
|
await block.object.updateFluid((x, y, z) => {
|
|
14901
|
-
const neighbor = pos.clone().add(new
|
|
15170
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
14902
15171
|
const section = this.getChunkAt(neighbor);
|
|
14903
15172
|
const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
14904
15173
|
return {
|
|
@@ -14910,7 +15179,7 @@ var MineRenderWorld = class {
|
|
|
14910
15179
|
}
|
|
14911
15180
|
let mask = 0;
|
|
14912
15181
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14913
|
-
const neighbor = pos.clone().add(new
|
|
15182
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
|
|
14914
15183
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14915
15184
|
mask |= 1 << face;
|
|
14916
15185
|
}
|
|
@@ -14944,14 +15213,14 @@ var MineRenderWorld = class {
|
|
|
14944
15213
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14945
15214
|
}
|
|
14946
15215
|
static worldToScenePosition(pos) {
|
|
14947
|
-
return new
|
|
15216
|
+
return new import_three39.Vector3(
|
|
14948
15217
|
pos.x * 16,
|
|
14949
15218
|
pos.y * 16,
|
|
14950
15219
|
pos.z * 16
|
|
14951
15220
|
);
|
|
14952
15221
|
}
|
|
14953
15222
|
static sceneToWorldPosition(pos) {
|
|
14954
|
-
return new
|
|
15223
|
+
return new import_three39.Vector3(
|
|
14955
15224
|
pos.x / 16,
|
|
14956
15225
|
pos.y / 16,
|
|
14957
15226
|
pos.z / 16
|
|
@@ -14974,10 +15243,10 @@ var MineRenderWorld = class {
|
|
|
14974
15243
|
init_Model();
|
|
14975
15244
|
|
|
14976
15245
|
// src/world/SectionMesh.ts
|
|
14977
|
-
var
|
|
15246
|
+
var import_three40 = require("three");
|
|
14978
15247
|
init_CanvasCompat();
|
|
14979
15248
|
init_Materials();
|
|
14980
|
-
var SectionMesh = class _SectionMesh extends
|
|
15249
|
+
var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
14981
15250
|
constructor() {
|
|
14982
15251
|
super(...arguments);
|
|
14983
15252
|
this.ownedMeshes = [];
|
|
@@ -15050,18 +15319,18 @@ var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
|
15050
15319
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
15051
15320
|
}
|
|
15052
15321
|
}
|
|
15053
|
-
const geometry = new
|
|
15054
|
-
geometry.setAttribute("position", new
|
|
15055
|
-
geometry.setAttribute("normal", new
|
|
15056
|
-
geometry.setAttribute("uv", new
|
|
15057
|
-
geometry.setAttribute("color", new
|
|
15322
|
+
const geometry = new import_three40.BufferGeometry();
|
|
15323
|
+
geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
|
|
15324
|
+
geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
|
|
15325
|
+
geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
|
|
15326
|
+
geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
|
|
15058
15327
|
geometry.setIndex(indices);
|
|
15059
15328
|
geometry.computeBoundingBox();
|
|
15060
15329
|
geometry.computeBoundingSphere();
|
|
15061
15330
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
15062
15331
|
material.vertexColors = true;
|
|
15063
15332
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
15064
|
-
const mesh = new
|
|
15333
|
+
const mesh = new import_three40.Mesh(geometry, material);
|
|
15065
15334
|
section.add(mesh);
|
|
15066
15335
|
section.ownedMeshes.push({ mesh, texture });
|
|
15067
15336
|
}
|
|
@@ -15097,10 +15366,10 @@ var Chunk = class _Chunk {
|
|
|
15097
15366
|
}
|
|
15098
15367
|
getBlockAt(posOrX, y, z) {
|
|
15099
15368
|
if (typeof posOrX == "number") {
|
|
15100
|
-
return this.getBlockAt(new
|
|
15369
|
+
return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
|
|
15101
15370
|
}
|
|
15102
15371
|
if (isTripleArray(posOrX)) {
|
|
15103
|
-
return this.getBlockAt(new
|
|
15372
|
+
return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
15104
15373
|
}
|
|
15105
15374
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
15106
15375
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -15108,10 +15377,10 @@ var Chunk = class _Chunk {
|
|
|
15108
15377
|
}
|
|
15109
15378
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
15110
15379
|
if (typeof posOrX == "number") {
|
|
15111
|
-
return this.setBlockAt(new
|
|
15380
|
+
return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
|
|
15112
15381
|
}
|
|
15113
15382
|
if (isTripleArray(posOrX)) {
|
|
15114
|
-
return this.setBlockAt(new
|
|
15383
|
+
return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
15115
15384
|
}
|
|
15116
15385
|
const worldPos = posOrX;
|
|
15117
15386
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -15223,7 +15492,7 @@ var Chunk = class _Chunk {
|
|
|
15223
15492
|
}
|
|
15224
15493
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
15225
15494
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
15226
|
-
new
|
|
15495
|
+
new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
15227
15496
|
));
|
|
15228
15497
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
15229
15498
|
this.sectionBlocks.clear();
|
|
@@ -15248,14 +15517,14 @@ var Chunk = class _Chunk {
|
|
|
15248
15517
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
15249
15518
|
}
|
|
15250
15519
|
worldPosToChunkPos(pos) {
|
|
15251
|
-
return new
|
|
15520
|
+
return new import_three41.Vector3(
|
|
15252
15521
|
pos.x - this.x * 16,
|
|
15253
15522
|
pos.y - this.y * 16,
|
|
15254
15523
|
pos.z - this.z * 16
|
|
15255
15524
|
);
|
|
15256
15525
|
}
|
|
15257
15526
|
chunkPosToWorldPos(pos) {
|
|
15258
|
-
return new
|
|
15527
|
+
return new import_three41.Vector3(
|
|
15259
15528
|
this.x * 16 + pos.x,
|
|
15260
15529
|
this.y * 16 + pos.y,
|
|
15261
15530
|
this.z * 16 + pos.z
|