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/node/index.js
CHANGED
|
@@ -297,6 +297,9 @@ var init_Caching = __esm({
|
|
|
297
297
|
static {
|
|
298
298
|
this.blockEntityIndexCache = _Caching.createAssetCache();
|
|
299
299
|
}
|
|
300
|
+
static {
|
|
301
|
+
this.fontCache = _Caching.createAssetCache();
|
|
302
|
+
}
|
|
300
303
|
static createAssetCache() {
|
|
301
304
|
return import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
302
305
|
}
|
|
@@ -323,7 +326,8 @@ var init_Caching = __esm({
|
|
|
323
326
|
this.entityModelCache,
|
|
324
327
|
this.entityTextureCache,
|
|
325
328
|
this.entityAnimationCache,
|
|
326
|
-
this.blockEntityIndexCache
|
|
329
|
+
this.blockEntityIndexCache,
|
|
330
|
+
this.fontCache
|
|
327
331
|
];
|
|
328
332
|
}
|
|
329
333
|
static clear() {
|
|
@@ -4346,7 +4350,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4346
4350
|
const attributes = {};
|
|
4347
4351
|
const morphAttributes = {};
|
|
4348
4352
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4349
|
-
const mergedGeometry = new
|
|
4353
|
+
const mergedGeometry = new import_three22.BufferGeometry();
|
|
4350
4354
|
let offset = 0;
|
|
4351
4355
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4352
4356
|
const geometry = geometries[i];
|
|
@@ -4470,7 +4474,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4470
4474
|
array.set(attributes[i].array, offset);
|
|
4471
4475
|
offset += attributes[i].array.length;
|
|
4472
4476
|
}
|
|
4473
|
-
return new
|
|
4477
|
+
return new import_three22.BufferAttribute(array, itemSize, normalized);
|
|
4474
4478
|
}
|
|
4475
4479
|
function interleaveAttributes(attributes) {
|
|
4476
4480
|
let TypedArray;
|
|
@@ -4486,7 +4490,7 @@ function interleaveAttributes(attributes) {
|
|
|
4486
4490
|
arrayLength += attribute.array.length;
|
|
4487
4491
|
stride += attribute.itemSize;
|
|
4488
4492
|
}
|
|
4489
|
-
const interleavedBuffer = new
|
|
4493
|
+
const interleavedBuffer = new import_three22.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4490
4494
|
let offset = 0;
|
|
4491
4495
|
const res = [];
|
|
4492
4496
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4495,7 +4499,7 @@ function interleaveAttributes(attributes) {
|
|
|
4495
4499
|
const attribute = attributes[j];
|
|
4496
4500
|
const itemSize = attribute.itemSize;
|
|
4497
4501
|
const count = attribute.count;
|
|
4498
|
-
const iba = new
|
|
4502
|
+
const iba = new import_three22.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4499
4503
|
res.push(iba);
|
|
4500
4504
|
offset += itemSize;
|
|
4501
4505
|
for (let c = 0; c < count; c++) {
|
|
@@ -4579,13 +4583,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4579
4583
|
const name = attributeNames[i];
|
|
4580
4584
|
const oldAttribute = geometry.getAttribute(name);
|
|
4581
4585
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4582
|
-
const attribute = new
|
|
4586
|
+
const attribute = new import_three22.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4583
4587
|
result.setAttribute(name, attribute);
|
|
4584
4588
|
if (name in morphAttrsArrays) {
|
|
4585
4589
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4586
4590
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4587
4591
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4588
|
-
const morphAttribute = new
|
|
4592
|
+
const morphAttribute = new import_three22.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4589
4593
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4590
4594
|
}
|
|
4591
4595
|
}
|
|
@@ -4594,11 +4598,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4594
4598
|
return result;
|
|
4595
4599
|
}
|
|
4596
4600
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4597
|
-
if (drawMode ===
|
|
4601
|
+
if (drawMode === import_three22.TrianglesDrawMode) {
|
|
4598
4602
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4599
4603
|
return geometry;
|
|
4600
4604
|
}
|
|
4601
|
-
if (drawMode ===
|
|
4605
|
+
if (drawMode === import_three22.TriangleFanDrawMode || drawMode === import_three22.TriangleStripDrawMode) {
|
|
4602
4606
|
let index = geometry.getIndex();
|
|
4603
4607
|
if (index === null) {
|
|
4604
4608
|
const indices = [];
|
|
@@ -4616,7 +4620,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4616
4620
|
}
|
|
4617
4621
|
const numberOfTriangles = index.count - 2;
|
|
4618
4622
|
const newIndices = [];
|
|
4619
|
-
if (drawMode ===
|
|
4623
|
+
if (drawMode === import_three22.TriangleFanDrawMode) {
|
|
4620
4624
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4621
4625
|
newIndices.push(index.getX(0));
|
|
4622
4626
|
newIndices.push(index.getX(i));
|
|
@@ -4652,15 +4656,15 @@ function computeMorphedAttributes(object) {
|
|
|
4652
4656
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4653
4657
|
return null;
|
|
4654
4658
|
}
|
|
4655
|
-
const _vA = new
|
|
4656
|
-
const _vB = new
|
|
4657
|
-
const _vC = new
|
|
4658
|
-
const _tempA = new
|
|
4659
|
-
const _tempB = new
|
|
4660
|
-
const _tempC = new
|
|
4661
|
-
const _morphA = new
|
|
4662
|
-
const _morphB = new
|
|
4663
|
-
const _morphC = new
|
|
4659
|
+
const _vA = new import_three22.Vector3();
|
|
4660
|
+
const _vB = new import_three22.Vector3();
|
|
4661
|
+
const _vC = new import_three22.Vector3();
|
|
4662
|
+
const _tempA = new import_three22.Vector3();
|
|
4663
|
+
const _tempB = new import_three22.Vector3();
|
|
4664
|
+
const _tempC = new import_three22.Vector3();
|
|
4665
|
+
const _morphA = new import_three22.Vector3();
|
|
4666
|
+
const _morphB = new import_three22.Vector3();
|
|
4667
|
+
const _morphC = new import_three22.Vector3();
|
|
4664
4668
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4665
4669
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4666
4670
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4855,8 +4859,8 @@ function computeMorphedAttributes(object) {
|
|
|
4855
4859
|
}
|
|
4856
4860
|
}
|
|
4857
4861
|
}
|
|
4858
|
-
const morphedPositionAttribute = new
|
|
4859
|
-
const morphedNormalAttribute = new
|
|
4862
|
+
const morphedPositionAttribute = new import_three22.Float32BufferAttribute(modifiedPosition, 3);
|
|
4863
|
+
const morphedNormalAttribute = new import_three22.Float32BufferAttribute(modifiedNormal, 3);
|
|
4860
4864
|
return {
|
|
4861
4865
|
positionAttribute,
|
|
4862
4866
|
normalAttribute,
|
|
@@ -4864,24 +4868,24 @@ function computeMorphedAttributes(object) {
|
|
|
4864
4868
|
morphedNormalAttribute
|
|
4865
4869
|
};
|
|
4866
4870
|
}
|
|
4867
|
-
var
|
|
4871
|
+
var import_three22;
|
|
4868
4872
|
var init_BufferGeometryUtils = __esm({
|
|
4869
4873
|
"src/three/BufferGeometryUtils.js"() {
|
|
4870
|
-
|
|
4874
|
+
import_three22 = require("three");
|
|
4871
4875
|
}
|
|
4872
4876
|
});
|
|
4873
4877
|
|
|
4874
4878
|
// src/model/ModelCulling.ts
|
|
4875
|
-
var
|
|
4879
|
+
var import_three23, ModelCulling;
|
|
4876
4880
|
var init_ModelCulling = __esm({
|
|
4877
4881
|
"src/model/ModelCulling.ts"() {
|
|
4878
|
-
|
|
4882
|
+
import_three23 = require("three");
|
|
4879
4883
|
init_CubeFace();
|
|
4880
4884
|
ModelCulling = class {
|
|
4881
4885
|
static toLocalMask(worldMask, rotation) {
|
|
4882
4886
|
let localMask = 0;
|
|
4883
4887
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4884
|
-
const normal = new
|
|
4888
|
+
const normal = new import_three23.Vector3(...offset).applyEuler(rotation);
|
|
4885
4889
|
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);
|
|
4886
4890
|
if (worldFace < 0) return 0;
|
|
4887
4891
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4914,10 +4918,10 @@ var init_ModelCulling = __esm({
|
|
|
4914
4918
|
});
|
|
4915
4919
|
|
|
4916
4920
|
// src/model/SpecialItems.ts
|
|
4917
|
-
var
|
|
4921
|
+
var import_three24, SpecialItems;
|
|
4918
4922
|
var init_SpecialItems = __esm({
|
|
4919
4923
|
"src/model/SpecialItems.ts"() {
|
|
4920
|
-
|
|
4924
|
+
import_three24 = require("three");
|
|
4921
4925
|
init_AssetKey();
|
|
4922
4926
|
init_Entities();
|
|
4923
4927
|
SpecialItems = class {
|
|
@@ -4945,7 +4949,7 @@ var init_SpecialItems = __esm({
|
|
|
4945
4949
|
case "minecraft:chest":
|
|
4946
4950
|
case "chest": {
|
|
4947
4951
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4948
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4952
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three24.Matrix4(), {
|
|
4949
4953
|
lid: [angle, 0, 0],
|
|
4950
4954
|
lock: [angle, 0, 0]
|
|
4951
4955
|
});
|
|
@@ -4954,11 +4958,11 @@ var init_SpecialItems = __esm({
|
|
|
4954
4958
|
}
|
|
4955
4959
|
case "minecraft:bed":
|
|
4956
4960
|
case "bed": {
|
|
4957
|
-
const transform = new
|
|
4961
|
+
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));
|
|
4958
4962
|
const key = texture(special.texture, "bed");
|
|
4959
4963
|
return Promise.all([
|
|
4960
4964
|
load("bed_head", key, transform),
|
|
4961
|
-
load("bed_foot", key, new
|
|
4965
|
+
load("bed_foot", key, new import_three24.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4962
4966
|
]);
|
|
4963
4967
|
}
|
|
4964
4968
|
case "minecraft:head":
|
|
@@ -4983,7 +4987,7 @@ var init_SpecialItems = __esm({
|
|
|
4983
4987
|
return [await load(
|
|
4984
4988
|
id,
|
|
4985
4989
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4986
|
-
new
|
|
4990
|
+
new import_three24.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three24.Matrix4().makeScale(-1, -1, 1)),
|
|
4987
4991
|
rotations
|
|
4988
4992
|
)];
|
|
4989
4993
|
}
|
|
@@ -5111,13 +5115,13 @@ var init_ItemTints = __esm({
|
|
|
5111
5115
|
function isModelObject(obj) {
|
|
5112
5116
|
return obj.isModelObject;
|
|
5113
5117
|
}
|
|
5114
|
-
var
|
|
5118
|
+
var import_three25, import_ts_deepmerge5, p7, ModelObject;
|
|
5115
5119
|
var init_ModelObject = __esm({
|
|
5116
5120
|
"src/model/scene/ModelObject.ts"() {
|
|
5117
5121
|
init_SceneObject();
|
|
5118
5122
|
init_Materials();
|
|
5119
5123
|
init_UVMapper();
|
|
5120
|
-
|
|
5124
|
+
import_three25 = require("three");
|
|
5121
5125
|
init_BufferGeometryUtils();
|
|
5122
5126
|
init_model();
|
|
5123
5127
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -5152,8 +5156,8 @@ var init_ModelObject = __esm({
|
|
|
5152
5156
|
const special = this.originalModel.special;
|
|
5153
5157
|
if (special) {
|
|
5154
5158
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
5155
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
5156
|
-
transform.multiply(new
|
|
5159
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three25.Matrix4();
|
|
5160
|
+
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5157
5161
|
try {
|
|
5158
5162
|
for (const part of parts) {
|
|
5159
5163
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -5216,7 +5220,7 @@ var init_ModelObject = __esm({
|
|
|
5216
5220
|
elGeo.clearGroups();
|
|
5217
5221
|
}
|
|
5218
5222
|
if (this.options.uvLockRotation) {
|
|
5219
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5223
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three25.Euler(...this.options.uvLockRotation));
|
|
5220
5224
|
}
|
|
5221
5225
|
if (this.options.tints) {
|
|
5222
5226
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5225,19 +5229,19 @@ var init_ModelObject = __esm({
|
|
|
5225
5229
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5226
5230
|
const tint = this.options.tints[tintIndex];
|
|
5227
5231
|
if (tint === void 0) continue;
|
|
5228
|
-
const color = new
|
|
5232
|
+
const color = new import_three25.Color(tint);
|
|
5229
5233
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5230
5234
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5231
5235
|
}
|
|
5232
5236
|
}
|
|
5233
|
-
elGeo.setAttribute("color", new
|
|
5237
|
+
elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
|
|
5234
5238
|
}
|
|
5235
|
-
elGeo.applyMatrix4(new
|
|
5236
|
-
elGeo.applyMatrix4(new
|
|
5239
|
+
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));
|
|
5240
|
+
elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
5237
5241
|
if (el.rotation) {
|
|
5238
5242
|
applyElementRotation(el.rotation, elGeo);
|
|
5239
5243
|
}
|
|
5240
|
-
elGeo.applyMatrix4(new
|
|
5244
|
+
elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5241
5245
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
5242
5246
|
if (this.options.mergeMeshes) {
|
|
5243
5247
|
allGeos.push(elGeo);
|
|
@@ -5259,7 +5263,7 @@ var init_ModelObject = __esm({
|
|
|
5259
5263
|
if (allGeos.length > 0) {
|
|
5260
5264
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
5261
5265
|
} else {
|
|
5262
|
-
combinedGeo = new
|
|
5266
|
+
combinedGeo = new import_three25.BoxGeometry(16, 16, 16);
|
|
5263
5267
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
5264
5268
|
}
|
|
5265
5269
|
combinedGeo.computeBoundingBox();
|
|
@@ -5369,7 +5373,7 @@ function ownHeight(sample) {
|
|
|
5369
5373
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5370
5374
|
}
|
|
5371
5375
|
function createFluidGeometry(kind, sample) {
|
|
5372
|
-
const geometry = new
|
|
5376
|
+
const geometry = new import_three30.BufferGeometry();
|
|
5373
5377
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5374
5378
|
const self = sample(0, 0, 0);
|
|
5375
5379
|
const height = (x, z) => {
|
|
@@ -5468,16 +5472,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5468
5472
|
1
|
|
5469
5473
|
);
|
|
5470
5474
|
}
|
|
5471
|
-
geometry.setAttribute("position", new
|
|
5472
|
-
geometry.setAttribute("normal", new
|
|
5473
|
-
geometry.setAttribute("uv", new
|
|
5475
|
+
geometry.setAttribute("position", new import_three30.Float32BufferAttribute(positions, 3));
|
|
5476
|
+
geometry.setAttribute("normal", new import_three30.Float32BufferAttribute(normals, 3));
|
|
5477
|
+
geometry.setAttribute("uv", new import_three30.Float32BufferAttribute(uvs, 2));
|
|
5474
5478
|
geometry.setIndex(indices);
|
|
5475
5479
|
return geometry;
|
|
5476
5480
|
}
|
|
5477
|
-
var
|
|
5481
|
+
var import_three30, fluidRules, HORIZONTAL, EPSILON;
|
|
5478
5482
|
var init_FluidGeometry = __esm({
|
|
5479
5483
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5480
|
-
|
|
5484
|
+
import_three30 = require("three");
|
|
5481
5485
|
init_fluidBlocks();
|
|
5482
5486
|
fluidRules = fluidBlocks_default;
|
|
5483
5487
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5506,10 +5510,10 @@ function sampleFluid(kind, sample) {
|
|
|
5506
5510
|
}
|
|
5507
5511
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5508
5512
|
}
|
|
5509
|
-
var
|
|
5513
|
+
var import_three31, FluidModelObject;
|
|
5510
5514
|
var init_FluidModelObject = __esm({
|
|
5511
5515
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5512
|
-
|
|
5516
|
+
import_three31 = require("three");
|
|
5513
5517
|
init_AssetKey();
|
|
5514
5518
|
init_Materials();
|
|
5515
5519
|
init_ModelObject();
|
|
@@ -5542,10 +5546,10 @@ var init_FluidModelObject = __esm({
|
|
|
5542
5546
|
}
|
|
5543
5547
|
}
|
|
5544
5548
|
geometry.clearGroups();
|
|
5545
|
-
const color = new
|
|
5549
|
+
const color = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5546
5550
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5547
5551
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5548
|
-
geometry.setAttribute("color", new
|
|
5552
|
+
geometry.setAttribute("color", new import_three31.BufferAttribute(colors, 3));
|
|
5549
5553
|
geometry.computeBoundingBox();
|
|
5550
5554
|
geometry.computeBoundingSphere();
|
|
5551
5555
|
if (this.options.instanceMeshes) {
|
|
@@ -5559,7 +5563,7 @@ var init_FluidModelObject = __esm({
|
|
|
5559
5563
|
super.applyTextures();
|
|
5560
5564
|
this.iterateAllMeshes((mesh) => {
|
|
5561
5565
|
const material = mesh.material;
|
|
5562
|
-
material.side =
|
|
5566
|
+
material.side = import_three31.DoubleSide;
|
|
5563
5567
|
material.forceSinglePass = true;
|
|
5564
5568
|
material.depthWrite = !material.transparent;
|
|
5565
5569
|
});
|
|
@@ -5619,6 +5623,7 @@ __export(index_node_exports, {
|
|
|
5619
5623
|
EntityObject: () => EntityObject,
|
|
5620
5624
|
Env: () => Env,
|
|
5621
5625
|
FluidModelObject: () => FluidModelObject,
|
|
5626
|
+
Fonts: () => Fonts,
|
|
5622
5627
|
Geometries: () => Geometries,
|
|
5623
5628
|
GuiHelper: () => GuiHelper,
|
|
5624
5629
|
GuiLight: () => GuiLight,
|
|
@@ -5692,6 +5697,7 @@ __export(index_node_exports, {
|
|
|
5692
5697
|
computeTangents: () => computeTangents,
|
|
5693
5698
|
createCanvas: () => createCanvas2,
|
|
5694
5699
|
createFluidGeometry: () => createFluidGeometry,
|
|
5700
|
+
createGuiTextGeometry: () => createGuiTextGeometry,
|
|
5695
5701
|
createGuiTextureGeometry: () => createGuiTextureGeometry,
|
|
5696
5702
|
createImage: () => createImage,
|
|
5697
5703
|
entityAnimationTime: () => entityAnimationTime,
|
|
@@ -5721,6 +5727,7 @@ __export(index_node_exports, {
|
|
|
5721
5727
|
isTransformable: () => isTransformable,
|
|
5722
5728
|
isTripleArray: () => isTripleArray,
|
|
5723
5729
|
isVector3: () => isVector3,
|
|
5730
|
+
layoutGuiText: () => layoutGuiText,
|
|
5724
5731
|
md5: () => md5,
|
|
5725
5732
|
mergeBufferAttributes: () => mergeBufferAttributes,
|
|
5726
5733
|
mergeBufferGeometries: () => mergeBufferGeometries,
|
|
@@ -5953,6 +5960,101 @@ var BlockEntities = class {
|
|
|
5953
5960
|
// src/assets/index.ts
|
|
5954
5961
|
init_BlockStates();
|
|
5955
5962
|
init_Entities();
|
|
5963
|
+
|
|
5964
|
+
// src/assets/Fonts.ts
|
|
5965
|
+
init_AssetKey();
|
|
5966
|
+
init_AssetLoader();
|
|
5967
|
+
init_AssetParsers();
|
|
5968
|
+
init_ModelTextures();
|
|
5969
|
+
init_Caching();
|
|
5970
|
+
var Fonts = class {
|
|
5971
|
+
static async get(key = "minecraft:default") {
|
|
5972
|
+
const fontKey = typeof key === "string" ? AssetKey.parse("font", key) : key;
|
|
5973
|
+
return await Caching.fontCache.get(fontKey.serialize(), () => this.load(fontKey, []));
|
|
5974
|
+
}
|
|
5975
|
+
static relatedKey(assetType, id, origin) {
|
|
5976
|
+
const key = AssetKey.parse(assetType, id);
|
|
5977
|
+
key.root = origin.root;
|
|
5978
|
+
return key;
|
|
5979
|
+
}
|
|
5980
|
+
static async load(key, parents) {
|
|
5981
|
+
const serialized = key.serialize();
|
|
5982
|
+
if (parents.includes(serialized)) throw new Error(`Cyclic font reference: ${key.toNamespacedString()}`);
|
|
5983
|
+
const stack = await AssetLoader.getAll(key, "json" /* JSON */);
|
|
5984
|
+
if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
|
|
5985
|
+
const glyphs = /* @__PURE__ */ new Map();
|
|
5986
|
+
for (const asset of stack) {
|
|
5987
|
+
for (const provider of asset.providers) {
|
|
5988
|
+
if (provider.filter?.uniform || provider.filter?.jp) continue;
|
|
5989
|
+
let provided;
|
|
5990
|
+
switch (provider.type) {
|
|
5991
|
+
case "bitmap":
|
|
5992
|
+
case "minecraft:bitmap":
|
|
5993
|
+
provided = await this.bitmap(provider, key);
|
|
5994
|
+
break;
|
|
5995
|
+
case "space":
|
|
5996
|
+
case "minecraft:space":
|
|
5997
|
+
provided = new Map(Object.entries(provider.advances).map(([character, advance]) => [
|
|
5998
|
+
character,
|
|
5999
|
+
{ x: 0, y: 0, width: 0, height: 0, scale: 1, ascent: 0, advance }
|
|
6000
|
+
]));
|
|
6001
|
+
break;
|
|
6002
|
+
case "reference":
|
|
6003
|
+
case "minecraft:reference":
|
|
6004
|
+
provided = (await this.load(this.relatedKey("font", provider.id, key), [...parents, serialized])).glyphs;
|
|
6005
|
+
break;
|
|
6006
|
+
default:
|
|
6007
|
+
continue;
|
|
6008
|
+
}
|
|
6009
|
+
for (const [character, glyph] of provided) {
|
|
6010
|
+
if (character !== "\0" && !glyphs.has(character)) glyphs.set(character, glyph);
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
return { glyphs };
|
|
6015
|
+
}
|
|
6016
|
+
static async bitmap(provider, fontKey) {
|
|
6017
|
+
const rows = provider.chars.map((row) => [...row]);
|
|
6018
|
+
const columns = rows[0]?.length;
|
|
6019
|
+
if (!columns || rows.some((row) => row.length !== columns)) {
|
|
6020
|
+
throw new Error(`Invalid character grid in font ${fontKey.toNamespacedString()}`);
|
|
6021
|
+
}
|
|
6022
|
+
const key = this.relatedKey("textures", provider.file, fontKey);
|
|
6023
|
+
const image = await ModelTextures.get(key);
|
|
6024
|
+
if (!image) throw new Error(`Could not load font texture ${key.toNamespacedString()}`);
|
|
6025
|
+
const width = Math.floor(image.width / columns), height = Math.floor(image.height / rows.length);
|
|
6026
|
+
if (!width || !height) throw new Error(`Font texture ${key.toNamespacedString()} is smaller than its character grid`);
|
|
6027
|
+
const scale = (provider.height ?? 8) / height;
|
|
6028
|
+
const pixels = image.data.getImageData(0, 0, image.width, image.height).data;
|
|
6029
|
+
const glyphs = /* @__PURE__ */ new Map();
|
|
6030
|
+
rows.forEach((row, rowIndex) => row.forEach((character, columnIndex) => {
|
|
6031
|
+
if (character === "\0") return;
|
|
6032
|
+
const x = columnIndex * width, y = rowIndex * height;
|
|
6033
|
+
let occupiedWidth = 0;
|
|
6034
|
+
for (let column = width - 1; column >= 0 && !occupiedWidth; column--) {
|
|
6035
|
+
for (let row2 = 0; row2 < height; row2++) {
|
|
6036
|
+
if (pixels[((y + row2) * image.width + x + column) * 4 + 3] !== 0) {
|
|
6037
|
+
occupiedWidth = column + 1;
|
|
6038
|
+
break;
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
glyphs.set(character, {
|
|
6043
|
+
image: image.data.canvas,
|
|
6044
|
+
x,
|
|
6045
|
+
y,
|
|
6046
|
+
width,
|
|
6047
|
+
height,
|
|
6048
|
+
scale,
|
|
6049
|
+
ascent: provider.ascent,
|
|
6050
|
+
advance: Math.floor(occupiedWidth * scale + 0.5) + 1
|
|
6051
|
+
});
|
|
6052
|
+
}));
|
|
6053
|
+
return glyphs;
|
|
6054
|
+
}
|
|
6055
|
+
};
|
|
6056
|
+
|
|
6057
|
+
// src/assets/index.ts
|
|
5956
6058
|
init_ModelTextures();
|
|
5957
6059
|
init_Models();
|
|
5958
6060
|
init_source();
|
|
@@ -8910,7 +9012,137 @@ function copyDataTexture(source) {
|
|
|
8910
9012
|
|
|
8911
9013
|
// src/gui/GuiHelper.ts
|
|
8912
9014
|
init_AssetKey();
|
|
9015
|
+
|
|
9016
|
+
// src/gui/GuiText.ts
|
|
9017
|
+
var import_three20 = require("three");
|
|
9018
|
+
async function layoutGuiText(text, options = {}) {
|
|
9019
|
+
const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
|
|
9020
|
+
if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
|
|
9021
|
+
throw new Error("Text wrap width and line height must be positive");
|
|
9022
|
+
}
|
|
9023
|
+
const font = await Fonts.get(options.font);
|
|
9024
|
+
const runs = typeof text === "string" ? [{ text }] : text;
|
|
9025
|
+
const glyphs = [], lineWidths = [];
|
|
9026
|
+
let line = [], width = 0;
|
|
9027
|
+
let trailingNewline = false;
|
|
9028
|
+
const finishLine = (entries) => {
|
|
9029
|
+
let x = 0;
|
|
9030
|
+
for (const entry of entries) {
|
|
9031
|
+
glyphs.push({ ...entry, x, y: lineWidths.length * lineHeight });
|
|
9032
|
+
x += entry.advance;
|
|
9033
|
+
}
|
|
9034
|
+
lineWidths.push(x);
|
|
9035
|
+
};
|
|
9036
|
+
for (const run of runs) {
|
|
9037
|
+
const style = {
|
|
9038
|
+
color: run.color ?? options.color ?? 16777215,
|
|
9039
|
+
bold: run.bold ?? options.bold ?? false,
|
|
9040
|
+
italic: run.italic ?? options.italic ?? false
|
|
9041
|
+
};
|
|
9042
|
+
for (const character of run.text.replace(/\r\n?/g, "\n")) {
|
|
9043
|
+
trailingNewline = character === "\n";
|
|
9044
|
+
if (character === "\n") {
|
|
9045
|
+
finishLine(line);
|
|
9046
|
+
line = [];
|
|
9047
|
+
width = 0;
|
|
9048
|
+
continue;
|
|
9049
|
+
}
|
|
9050
|
+
const glyph = font.glyphs.get(character);
|
|
9051
|
+
const advance = (glyph?.advance ?? 6) + (style.bold ? 1 : 0);
|
|
9052
|
+
line.push({ character, glyph, advance, style, x: 0, y: 0 });
|
|
9053
|
+
width += advance;
|
|
9054
|
+
while (width > maxWidth && line.length > 1) {
|
|
9055
|
+
let space = -1;
|
|
9056
|
+
for (let i = 0; i < line.length; i++) if (line[i].character === " ") space = i;
|
|
9057
|
+
const split = space >= 0 ? space : line.length - 1;
|
|
9058
|
+
if (split > 0) finishLine(line.slice(0, split));
|
|
9059
|
+
line = line.slice(split + (space >= 0 ? 1 : 0));
|
|
9060
|
+
width = line.reduce((sum, entry) => sum + entry.advance, 0);
|
|
9061
|
+
}
|
|
9062
|
+
}
|
|
9063
|
+
}
|
|
9064
|
+
if (line.length || !lineWidths.length || trailingNewline) finishLine(line);
|
|
9065
|
+
return { glyphs, lineWidths, width: Math.max(0, ...lineWidths), height: lineWidths.length * lineHeight };
|
|
9066
|
+
}
|
|
9067
|
+
function createGuiTextGeometry(layout, shadow = true) {
|
|
9068
|
+
const batches = [];
|
|
9069
|
+
for (const isShadow of shadow ? [true, false] : [false]) {
|
|
9070
|
+
let batch;
|
|
9071
|
+
for (const entry of layout.glyphs) {
|
|
9072
|
+
const { glyph, style } = entry;
|
|
9073
|
+
if (glyph && !glyph.image) continue;
|
|
9074
|
+
if (!batch || batch.image !== glyph?.image) {
|
|
9075
|
+
batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
|
|
9076
|
+
batches.push(batch);
|
|
9077
|
+
}
|
|
9078
|
+
const color = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
|
|
9079
|
+
const offset = isShadow ? 1 : 0;
|
|
9080
|
+
const top = glyph ? 7 - glyph.ascent : 0;
|
|
9081
|
+
const height = glyph ? glyph.height * glyph.scale : 8;
|
|
9082
|
+
const width = glyph ? glyph.width * glyph.scale : 5;
|
|
9083
|
+
const shear = (y) => style.italic ? 1 - 0.25 * y : 0;
|
|
9084
|
+
const quad = (left, upper, right, lower, boldOffset) => {
|
|
9085
|
+
const base = batch.positions.length / 3;
|
|
9086
|
+
const x = entry.x + offset + boldOffset, y = entry.y + offset;
|
|
9087
|
+
batch.positions.push(
|
|
9088
|
+
x + left + shear(upper),
|
|
9089
|
+
-y - upper,
|
|
9090
|
+
0,
|
|
9091
|
+
x + right + shear(upper),
|
|
9092
|
+
-y - upper,
|
|
9093
|
+
0,
|
|
9094
|
+
x + left + shear(lower),
|
|
9095
|
+
-y - lower,
|
|
9096
|
+
0,
|
|
9097
|
+
x + right + shear(lower),
|
|
9098
|
+
-y - lower,
|
|
9099
|
+
0
|
|
9100
|
+
);
|
|
9101
|
+
const u0 = glyph ? glyph.x / glyph.image.width : 0;
|
|
9102
|
+
const u1 = glyph ? (glyph.x + glyph.width) / glyph.image.width : 1;
|
|
9103
|
+
const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
|
|
9104
|
+
const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
|
|
9105
|
+
batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
|
|
9106
|
+
for (let i = 0; i < 4; i++) batch.colors.push(color.r, color.g, color.b);
|
|
9107
|
+
batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
|
|
9108
|
+
};
|
|
9109
|
+
for (const boldOffset of style.bold ? [0, 1] : [0]) {
|
|
9110
|
+
if (glyph) quad(0, top, width, top + height, boldOffset);
|
|
9111
|
+
else {
|
|
9112
|
+
quad(0, 0, 5, 1, boldOffset);
|
|
9113
|
+
quad(0, 7, 5, 8, boldOffset);
|
|
9114
|
+
quad(0, 1, 1, 7, boldOffset);
|
|
9115
|
+
quad(4, 1, 5, 7, boldOffset);
|
|
9116
|
+
}
|
|
9117
|
+
}
|
|
9118
|
+
}
|
|
9119
|
+
}
|
|
9120
|
+
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) }));
|
|
9121
|
+
}
|
|
9122
|
+
|
|
9123
|
+
// src/gui/GuiHelper.ts
|
|
8913
9124
|
var GuiHelper = class {
|
|
9125
|
+
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
9126
|
+
static async tooltip(lines, options = {}) {
|
|
9127
|
+
if (!lines.length) return [];
|
|
9128
|
+
const { position = [0, 0], titleGap = 2, lineHeight = 10, shadow = true, ...style } = options;
|
|
9129
|
+
const textOptions = { ...style, lineHeight, shadow };
|
|
9130
|
+
const layouts = await Promise.all(lines.map((line) => layoutGuiText(line, textOptions)));
|
|
9131
|
+
const width = Math.max(...layouts.map((layout) => layout.width));
|
|
9132
|
+
const height = layouts.reduce((sum, layout) => sum + layout.height, 0) - 2 + (lines.length > 1 ? titleGap : 0);
|
|
9133
|
+
const layers = ["background", "frame"].map((part) => ({
|
|
9134
|
+
name: `tooltip-${part}`,
|
|
9135
|
+
texture: `minecraft:gui/sprites/tooltip/${part}`,
|
|
9136
|
+
position: [position[0] - 12, position[1] - 12],
|
|
9137
|
+
size: [width + 24, height + 24]
|
|
9138
|
+
}));
|
|
9139
|
+
let y = position[1];
|
|
9140
|
+
lines.forEach((text, index) => {
|
|
9141
|
+
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
|
|
9142
|
+
y += layouts[index].height + (index === 0 ? titleGap : 0);
|
|
9143
|
+
});
|
|
9144
|
+
return layers;
|
|
9145
|
+
}
|
|
8914
9146
|
static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
|
|
8915
9147
|
const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
|
|
8916
9148
|
return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
|
|
@@ -8975,11 +9207,11 @@ var GuiHelper = class {
|
|
|
8975
9207
|
};
|
|
8976
9208
|
|
|
8977
9209
|
// src/gui/GuiTextureGeometry.ts
|
|
8978
|
-
var
|
|
9210
|
+
var import_three21 = require("three");
|
|
8979
9211
|
function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
|
|
8980
9212
|
if (crop || !scaling || scaling.type === "stretch") {
|
|
8981
9213
|
const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
|
|
8982
|
-
const geometry = new
|
|
9214
|
+
const geometry = new import_three21.PlaneGeometry(width, height);
|
|
8983
9215
|
const uv = geometry.getAttribute("uv");
|
|
8984
9216
|
for (let i = 0; i < uv.count; i++) {
|
|
8985
9217
|
uv.setXY(
|
|
@@ -9050,11 +9282,11 @@ function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop,
|
|
|
9050
9282
|
}
|
|
9051
9283
|
}
|
|
9052
9284
|
}
|
|
9053
|
-
return new
|
|
9285
|
+
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);
|
|
9054
9286
|
}
|
|
9055
9287
|
|
|
9056
9288
|
// src/gui/scene/GuiObject.ts
|
|
9057
|
-
var
|
|
9289
|
+
var import_three26 = require("three");
|
|
9058
9290
|
init_AssetKey();
|
|
9059
9291
|
init_ModelTextures();
|
|
9060
9292
|
init_Models();
|
|
@@ -9070,9 +9302,10 @@ var GuiObject = class extends SceneObject {
|
|
|
9070
9302
|
this.textureLayers = textureLayers;
|
|
9071
9303
|
this.isGuiObject = true;
|
|
9072
9304
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
9073
|
-
this.bounds = new
|
|
9305
|
+
this.bounds = new import_three26.Box2();
|
|
9074
9306
|
this.geometries = /* @__PURE__ */ new Set();
|
|
9075
9307
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
9308
|
+
this.textMaterials = /* @__PURE__ */ new Map();
|
|
9076
9309
|
this.initialized = false;
|
|
9077
9310
|
}
|
|
9078
9311
|
async init() {
|
|
@@ -9081,6 +9314,43 @@ var GuiObject = class extends SceneObject {
|
|
|
9081
9314
|
let depth = 0;
|
|
9082
9315
|
for (const [index, layer] of this.textureLayers.entries()) {
|
|
9083
9316
|
const [x, y] = layer.position ?? [0, 0];
|
|
9317
|
+
if ("text" in layer) {
|
|
9318
|
+
const layout = await layoutGuiText(layer.text, layer);
|
|
9319
|
+
const group = new import_three26.Group();
|
|
9320
|
+
group.name = `group:${layer.name ?? index}`;
|
|
9321
|
+
group.position.set(x, -y, depth);
|
|
9322
|
+
const [width2, height2] = layer.size ?? [layout.width, layout.height];
|
|
9323
|
+
group.scale.set(layout.width ? width2 / layout.width : 1, height2 / layout.height, 1);
|
|
9324
|
+
this.add(group);
|
|
9325
|
+
const parts = createGuiTextGeometry(layout, layer.shadow);
|
|
9326
|
+
const bounds = new import_three26.Box3();
|
|
9327
|
+
for (const [partIndex, { image: image2, geometry: geometry2 }] of parts.entries()) {
|
|
9328
|
+
this.geometries.add(geometry2);
|
|
9329
|
+
geometry2.computeBoundingBox();
|
|
9330
|
+
bounds.union(geometry2.boundingBox);
|
|
9331
|
+
let material2 = this.textMaterials.get(image2);
|
|
9332
|
+
if (!material2) {
|
|
9333
|
+
material2 = image2 ? Materials.createGuiCanvasMaterial(image2) : new import_three26.MeshBasicMaterial({ transparent: true, depthWrite: false, side: import_three26.DoubleSide, toneMapped: false });
|
|
9334
|
+
material2.vertexColors = true;
|
|
9335
|
+
this.textMaterials.set(image2, material2);
|
|
9336
|
+
this.ownedMaterials.add(material2);
|
|
9337
|
+
}
|
|
9338
|
+
const mesh2 = new import_three26.Mesh(geometry2, material2);
|
|
9339
|
+
mesh2.name = `mesh:${layer.name ?? index}:${partIndex}`;
|
|
9340
|
+
mesh2.renderOrder = index + partIndex / (parts.length + 1) * 0.5;
|
|
9341
|
+
group.add(mesh2);
|
|
9342
|
+
}
|
|
9343
|
+
group.updateMatrix();
|
|
9344
|
+
bounds.applyMatrix4(group.matrix);
|
|
9345
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9346
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
|
|
9347
|
+
if (!bounds.isEmpty()) {
|
|
9348
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
|
|
9349
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
|
|
9350
|
+
}
|
|
9351
|
+
depth += 0.01;
|
|
9352
|
+
continue;
|
|
9353
|
+
}
|
|
9084
9354
|
if ("item" in layer) {
|
|
9085
9355
|
const [width2, height2] = layer.size ?? [16, 16];
|
|
9086
9356
|
const item = await this.createItem(layer, index);
|
|
@@ -9088,17 +9358,17 @@ var GuiObject = class extends SceneObject {
|
|
|
9088
9358
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
9089
9359
|
item.updateWorldMatrix(true, true);
|
|
9090
9360
|
const inverse = this.matrixWorld.clone().invert();
|
|
9091
|
-
const bounds = new
|
|
9361
|
+
const bounds = new import_three26.Box3();
|
|
9092
9362
|
item.iterateAllMeshes((mesh2) => {
|
|
9093
9363
|
mesh2.geometry.computeBoundingBox();
|
|
9094
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
9364
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three26.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
9095
9365
|
});
|
|
9096
9366
|
item.position.z = depth - bounds.min.z;
|
|
9097
9367
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
9098
|
-
this.bounds.expandByPoint(new
|
|
9099
|
-
this.bounds.expandByPoint(new
|
|
9100
|
-
this.bounds.expandByPoint(new
|
|
9101
|
-
this.bounds.expandByPoint(new
|
|
9368
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9369
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
|
|
9370
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
|
|
9371
|
+
this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
|
|
9102
9372
|
continue;
|
|
9103
9373
|
}
|
|
9104
9374
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -9108,13 +9378,13 @@ var GuiObject = class extends SceneObject {
|
|
|
9108
9378
|
const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
|
|
9109
9379
|
const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
|
|
9110
9380
|
this.geometries.add(geometry);
|
|
9111
|
-
const mesh = new
|
|
9381
|
+
const mesh = new import_three26.Mesh(geometry, material);
|
|
9112
9382
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
9113
9383
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
9114
9384
|
mesh.renderOrder = index;
|
|
9115
9385
|
this.add(mesh);
|
|
9116
|
-
this.bounds.expandByPoint(new
|
|
9117
|
-
this.bounds.expandByPoint(new
|
|
9386
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x, y));
|
|
9387
|
+
this.bounds.expandByPoint(new import_three26.Vector2(x + width, y + height));
|
|
9118
9388
|
depth += 0.01;
|
|
9119
9389
|
}
|
|
9120
9390
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -9172,10 +9442,11 @@ var GuiObject = class extends SceneObject {
|
|
|
9172
9442
|
for (const geometry of this.geometries) geometry.dispose();
|
|
9173
9443
|
this.geometries.clear();
|
|
9174
9444
|
for (const material of this.ownedMaterials) {
|
|
9175
|
-
material.map
|
|
9445
|
+
material.map?.dispose();
|
|
9176
9446
|
material.dispose();
|
|
9177
9447
|
}
|
|
9178
9448
|
this.ownedMaterials.clear();
|
|
9449
|
+
this.textMaterials.clear();
|
|
9179
9450
|
this.bounds.makeEmpty();
|
|
9180
9451
|
this.initialized = false;
|
|
9181
9452
|
super.disposeAndRemoveAllChildren();
|
|
@@ -9189,7 +9460,7 @@ function isGuiObject(obj) {
|
|
|
9189
9460
|
init_image();
|
|
9190
9461
|
|
|
9191
9462
|
// src/inspector/SceneInspector.ts
|
|
9192
|
-
var
|
|
9463
|
+
var import_three27 = require("three");
|
|
9193
9464
|
init_SceneObject();
|
|
9194
9465
|
init_util();
|
|
9195
9466
|
init_log();
|
|
@@ -9199,11 +9470,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
9199
9470
|
var SceneInspector = class {
|
|
9200
9471
|
constructor(renderer) {
|
|
9201
9472
|
this.renderer = renderer;
|
|
9202
|
-
this.mouse = new
|
|
9473
|
+
this.mouse = new import_three27.Vector2();
|
|
9203
9474
|
this.listeners = new AbortController();
|
|
9204
9475
|
this.objectInfoContainer = document.createElement("div");
|
|
9205
9476
|
this.objectControlsContainer = document.createElement("div");
|
|
9206
|
-
this.raycaster = new
|
|
9477
|
+
this.raycaster = new import_three27.Raycaster();
|
|
9207
9478
|
this.init();
|
|
9208
9479
|
}
|
|
9209
9480
|
init() {
|
|
@@ -9606,7 +9877,7 @@ init_ModelMerger();
|
|
|
9606
9877
|
init_SpecialItems();
|
|
9607
9878
|
|
|
9608
9879
|
// src/model/block/BlockStateResolver.ts
|
|
9609
|
-
var
|
|
9880
|
+
var import_three29 = require("three");
|
|
9610
9881
|
init_BlockStates();
|
|
9611
9882
|
init_MineRenderError();
|
|
9612
9883
|
init_util();
|
|
@@ -9684,7 +9955,7 @@ var BlockStateResolver = class {
|
|
|
9684
9955
|
return variants[variants.length - 1];
|
|
9685
9956
|
}
|
|
9686
9957
|
static rotation(variant) {
|
|
9687
|
-
const rotation = new
|
|
9958
|
+
const rotation = new import_three29.Euler();
|
|
9688
9959
|
if (typeof variant.x !== "undefined") {
|
|
9689
9960
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
9690
9961
|
}
|
|
@@ -9776,7 +10047,7 @@ init_SceneObject();
|
|
|
9776
10047
|
init_ModelObject();
|
|
9777
10048
|
init_Models();
|
|
9778
10049
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9779
|
-
var
|
|
10050
|
+
var import_three32 = require("three");
|
|
9780
10051
|
init_MineRenderError();
|
|
9781
10052
|
init_InstanceReference();
|
|
9782
10053
|
init_AssetKey();
|
|
@@ -9798,7 +10069,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9798
10069
|
this._models = [];
|
|
9799
10070
|
this._cullMask = 0;
|
|
9800
10071
|
this._entities = [];
|
|
9801
|
-
this._entityPlacement = new
|
|
10072
|
+
this._entityPlacement = new import_three32.Matrix4();
|
|
9802
10073
|
this._entityGeneration = 0;
|
|
9803
10074
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9804
10075
|
}
|
|
@@ -9899,7 +10170,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9899
10170
|
return true;
|
|
9900
10171
|
}
|
|
9901
10172
|
placeEntities() {
|
|
9902
|
-
const matrix = new
|
|
10173
|
+
const matrix = new import_three32.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9903
10174
|
for (const entity of this._entities) {
|
|
9904
10175
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9905
10176
|
}
|
|
@@ -9921,12 +10192,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9921
10192
|
getModelCullMask(model, worldMask) {
|
|
9922
10193
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9923
10194
|
if (object.options.displayPosition) return 0;
|
|
9924
|
-
const position = new
|
|
9925
|
-
const rotation = new
|
|
9926
|
-
const scale = new
|
|
10195
|
+
const position = new import_three32.Vector3();
|
|
10196
|
+
const rotation = new import_three32.Quaternion();
|
|
10197
|
+
const scale = new import_three32.Vector3();
|
|
9927
10198
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9928
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9929
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
10199
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three32.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
10200
|
+
return ModelCulling.toLocalMask(worldMask, new import_three32.Euler().setFromQuaternion(rotation));
|
|
9930
10201
|
}
|
|
9931
10202
|
async setCullMask(worldMask) {
|
|
9932
10203
|
worldMask &= 63;
|
|
@@ -9992,7 +10263,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9992
10263
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9993
10264
|
);
|
|
9994
10265
|
const previous = this._fluidModel;
|
|
9995
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
10266
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three32.Matrix4().makeTranslation(...this.position.toArray());
|
|
9996
10267
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9997
10268
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9998
10269
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -10134,7 +10405,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10134
10405
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
10135
10406
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
10136
10407
|
}
|
|
10137
|
-
getMatrixAt(index, matrix = new
|
|
10408
|
+
getMatrixAt(index, matrix = new import_three32.Matrix4()) {
|
|
10138
10409
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
10139
10410
|
const child = this._models[0];
|
|
10140
10411
|
if (child && isModelObject(child)) {
|
|
@@ -12006,7 +12277,7 @@ init_ModelObject();
|
|
|
12006
12277
|
init_nbt();
|
|
12007
12278
|
|
|
12008
12279
|
// src/renderer/MineRenderScene.ts
|
|
12009
|
-
var
|
|
12280
|
+
var import_three34 = require("three");
|
|
12010
12281
|
init_SceneObject();
|
|
12011
12282
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
12012
12283
|
init_ModelObject();
|
|
@@ -12739,7 +13010,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12739
13010
|
init_util();
|
|
12740
13011
|
|
|
12741
13012
|
// src/skin/SkinTextures.ts
|
|
12742
|
-
var
|
|
13013
|
+
var import_three33 = require("three");
|
|
12743
13014
|
init_Caching();
|
|
12744
13015
|
init_CacheKey();
|
|
12745
13016
|
init_MineRenderError();
|
|
@@ -12823,11 +13094,11 @@ var SkinTextures = class {
|
|
|
12823
13094
|
});
|
|
12824
13095
|
}
|
|
12825
13096
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12826
|
-
const texture = Textures.initTextureProps(new
|
|
12827
|
-
texture.colorSpace =
|
|
13097
|
+
const texture = Textures.initTextureProps(new import_three33.DataTexture(pixels, width, height));
|
|
13098
|
+
texture.colorSpace = import_three33.SRGBColorSpace;
|
|
12828
13099
|
texture.flipY = true;
|
|
12829
13100
|
texture.needsUpdate = true;
|
|
12830
|
-
return new
|
|
13101
|
+
return new import_three33.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three33.DoubleSide : import_three33.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12831
13102
|
}
|
|
12832
13103
|
static isSlim(image, scale) {
|
|
12833
13104
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -13057,7 +13328,7 @@ var SkinObject = class extends SceneObject {
|
|
|
13057
13328
|
// src/renderer/MineRenderScene.ts
|
|
13058
13329
|
init_EntityObject();
|
|
13059
13330
|
init_ItemTints();
|
|
13060
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
13331
|
+
var MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
13061
13332
|
constructor(options) {
|
|
13062
13333
|
super();
|
|
13063
13334
|
this.isMineRenderScene = true;
|
|
@@ -13187,7 +13458,7 @@ function isMineRenderScene(obj) {
|
|
|
13187
13458
|
}
|
|
13188
13459
|
|
|
13189
13460
|
// src/renderer/Renderer.ts
|
|
13190
|
-
var
|
|
13461
|
+
var import_three36 = require("three");
|
|
13191
13462
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
13192
13463
|
var import_stats = __toESM(require("stats.js"));
|
|
13193
13464
|
var import_postprocessing = require("postprocessing");
|
|
@@ -13196,11 +13467,11 @@ init_Model();
|
|
|
13196
13467
|
init_three();
|
|
13197
13468
|
|
|
13198
13469
|
// src/three/OrbitControls.js
|
|
13199
|
-
var
|
|
13470
|
+
var import_three35 = require("three");
|
|
13200
13471
|
var _changeEvent = { type: "change" };
|
|
13201
13472
|
var _startEvent = { type: "start" };
|
|
13202
13473
|
var _endEvent = { type: "end" };
|
|
13203
|
-
var OrbitControls = class extends
|
|
13474
|
+
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13204
13475
|
constructor(object, domElement) {
|
|
13205
13476
|
super();
|
|
13206
13477
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -13209,7 +13480,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13209
13480
|
this.domElement = domElement;
|
|
13210
13481
|
this.domElement.style.touchAction = "none";
|
|
13211
13482
|
this.enabled = true;
|
|
13212
|
-
this.target = new
|
|
13483
|
+
this.target = new import_three35.Vector3();
|
|
13213
13484
|
this.minDistance = 0;
|
|
13214
13485
|
this.maxDistance = Infinity;
|
|
13215
13486
|
this.minZoom = 0;
|
|
@@ -13231,8 +13502,8 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13231
13502
|
this.autoRotate = false;
|
|
13232
13503
|
this.autoRotateSpeed = 2;
|
|
13233
13504
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
13234
|
-
this.mouseButtons = { LEFT:
|
|
13235
|
-
this.touches = { ONE:
|
|
13505
|
+
this.mouseButtons = { LEFT: import_three35.MOUSE.ROTATE, MIDDLE: import_three35.MOUSE.DOLLY, RIGHT: import_three35.MOUSE.PAN };
|
|
13506
|
+
this.touches = { ONE: import_three35.TOUCH.ROTATE, TWO: import_three35.TOUCH.DOLLY_PAN };
|
|
13236
13507
|
this.target0 = this.target.clone();
|
|
13237
13508
|
this.position0 = this.object.position.clone();
|
|
13238
13509
|
this.zoom0 = this.object.zoom;
|
|
@@ -13261,11 +13532,11 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13261
13532
|
state = STATE.NONE;
|
|
13262
13533
|
};
|
|
13263
13534
|
this.update = function() {
|
|
13264
|
-
const offset = new
|
|
13265
|
-
const quat = new
|
|
13535
|
+
const offset = new import_three35.Vector3();
|
|
13536
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object.up, new import_three35.Vector3(0, 1, 0));
|
|
13266
13537
|
const quatInverse = quat.clone().invert();
|
|
13267
|
-
const lastPosition = new
|
|
13268
|
-
const lastQuaternion = new
|
|
13538
|
+
const lastPosition = new import_three35.Vector3();
|
|
13539
|
+
const lastQuaternion = new import_three35.Quaternion();
|
|
13269
13540
|
const twoPI = 2 * Math.PI;
|
|
13270
13541
|
return function update() {
|
|
13271
13542
|
const position = scope.object.position;
|
|
@@ -13351,20 +13622,20 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13351
13622
|
};
|
|
13352
13623
|
let state = STATE.NONE;
|
|
13353
13624
|
const EPS = 1e-6;
|
|
13354
|
-
const spherical = new
|
|
13355
|
-
const sphericalDelta = new
|
|
13625
|
+
const spherical = new import_three35.Spherical();
|
|
13626
|
+
const sphericalDelta = new import_three35.Spherical();
|
|
13356
13627
|
let scale = 1;
|
|
13357
|
-
const panOffset = new
|
|
13628
|
+
const panOffset = new import_three35.Vector3();
|
|
13358
13629
|
let zoomChanged = false;
|
|
13359
|
-
const rotateStart = new
|
|
13360
|
-
const rotateEnd = new
|
|
13361
|
-
const rotateDelta = new
|
|
13362
|
-
const panStart = new
|
|
13363
|
-
const panEnd = new
|
|
13364
|
-
const panDelta = new
|
|
13365
|
-
const dollyStart = new
|
|
13366
|
-
const dollyEnd = new
|
|
13367
|
-
const dollyDelta = new
|
|
13630
|
+
const rotateStart = new import_three35.Vector2();
|
|
13631
|
+
const rotateEnd = new import_three35.Vector2();
|
|
13632
|
+
const rotateDelta = new import_three35.Vector2();
|
|
13633
|
+
const panStart = new import_three35.Vector2();
|
|
13634
|
+
const panEnd = new import_three35.Vector2();
|
|
13635
|
+
const panDelta = new import_three35.Vector2();
|
|
13636
|
+
const dollyStart = new import_three35.Vector2();
|
|
13637
|
+
const dollyEnd = new import_three35.Vector2();
|
|
13638
|
+
const dollyDelta = new import_three35.Vector2();
|
|
13368
13639
|
const pointers = [];
|
|
13369
13640
|
const pointerPositions = {};
|
|
13370
13641
|
function getAutoRotationAngle() {
|
|
@@ -13380,7 +13651,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13380
13651
|
sphericalDelta.phi -= angle;
|
|
13381
13652
|
}
|
|
13382
13653
|
const panLeft = function() {
|
|
13383
|
-
const v = new
|
|
13654
|
+
const v = new import_three35.Vector3();
|
|
13384
13655
|
return function panLeft2(distance, objectMatrix) {
|
|
13385
13656
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
13386
13657
|
v.multiplyScalar(-distance);
|
|
@@ -13388,7 +13659,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13388
13659
|
};
|
|
13389
13660
|
}();
|
|
13390
13661
|
const panUp = function() {
|
|
13391
|
-
const v = new
|
|
13662
|
+
const v = new import_three35.Vector3();
|
|
13392
13663
|
return function panUp2(distance, objectMatrix) {
|
|
13393
13664
|
if (scope.screenSpacePanning === true) {
|
|
13394
13665
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -13401,7 +13672,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13401
13672
|
};
|
|
13402
13673
|
}();
|
|
13403
13674
|
const pan = function() {
|
|
13404
|
-
const offset = new
|
|
13675
|
+
const offset = new import_three35.Vector3();
|
|
13405
13676
|
return function pan2(deltaX, deltaY) {
|
|
13406
13677
|
const element = scope.domElement;
|
|
13407
13678
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13650,12 +13921,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13650
13921
|
mouseAction = -1;
|
|
13651
13922
|
}
|
|
13652
13923
|
switch (mouseAction) {
|
|
13653
|
-
case
|
|
13924
|
+
case import_three35.MOUSE.DOLLY:
|
|
13654
13925
|
if (scope.enableZoom === false) return;
|
|
13655
13926
|
handleMouseDownDolly(event);
|
|
13656
13927
|
state = STATE.DOLLY;
|
|
13657
13928
|
break;
|
|
13658
|
-
case
|
|
13929
|
+
case import_three35.MOUSE.ROTATE:
|
|
13659
13930
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13660
13931
|
if (scope.enablePan === false) return;
|
|
13661
13932
|
handleMouseDownPan(event);
|
|
@@ -13666,7 +13937,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13666
13937
|
state = STATE.ROTATE;
|
|
13667
13938
|
}
|
|
13668
13939
|
break;
|
|
13669
|
-
case
|
|
13940
|
+
case import_three35.MOUSE.PAN:
|
|
13670
13941
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13671
13942
|
if (scope.enableRotate === false) return;
|
|
13672
13943
|
handleMouseDownRotate(event);
|
|
@@ -13722,12 +13993,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13722
13993
|
switch (pointers.length) {
|
|
13723
13994
|
case 1:
|
|
13724
13995
|
switch (scope.touches.ONE) {
|
|
13725
|
-
case
|
|
13996
|
+
case import_three35.TOUCH.ROTATE:
|
|
13726
13997
|
if (scope.enableRotate === false) return;
|
|
13727
13998
|
handleTouchStartRotate();
|
|
13728
13999
|
state = STATE.TOUCH_ROTATE;
|
|
13729
14000
|
break;
|
|
13730
|
-
case
|
|
14001
|
+
case import_three35.TOUCH.PAN:
|
|
13731
14002
|
if (scope.enablePan === false) return;
|
|
13732
14003
|
handleTouchStartPan();
|
|
13733
14004
|
state = STATE.TOUCH_PAN;
|
|
@@ -13738,12 +14009,12 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13738
14009
|
break;
|
|
13739
14010
|
case 2:
|
|
13740
14011
|
switch (scope.touches.TWO) {
|
|
13741
|
-
case
|
|
14012
|
+
case import_three35.TOUCH.DOLLY_PAN:
|
|
13742
14013
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13743
14014
|
handleTouchStartDollyPan();
|
|
13744
14015
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13745
14016
|
break;
|
|
13746
|
-
case
|
|
14017
|
+
case import_three35.TOUCH.DOLLY_ROTATE:
|
|
13747
14018
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13748
14019
|
handleTouchStartDollyRotate();
|
|
13749
14020
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13810,7 +14081,7 @@ var OrbitControls = class extends import_three34.EventDispatcher {
|
|
|
13810
14081
|
function trackPointer(event) {
|
|
13811
14082
|
let position = pointerPositions[event.pointerId];
|
|
13812
14083
|
if (position === void 0) {
|
|
13813
|
-
position = new
|
|
14084
|
+
position = new import_three35.Vector2();
|
|
13814
14085
|
pointerPositions[event.pointerId] = position;
|
|
13815
14086
|
}
|
|
13816
14087
|
position.set(event.pageX, event.pageY);
|
|
@@ -13830,10 +14101,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13830
14101
|
constructor(object, domElement) {
|
|
13831
14102
|
super(object, domElement);
|
|
13832
14103
|
this.screenSpacePanning = false;
|
|
13833
|
-
this.mouseButtons.LEFT =
|
|
13834
|
-
this.mouseButtons.RIGHT =
|
|
13835
|
-
this.touches.ONE =
|
|
13836
|
-
this.touches.TWO =
|
|
14104
|
+
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14105
|
+
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
14106
|
+
this.touches.ONE = import_three35.TOUCH.PAN;
|
|
14107
|
+
this.touches.TWO = import_three35.TOUCH.DOLLY_ROTATE;
|
|
13837
14108
|
}
|
|
13838
14109
|
};
|
|
13839
14110
|
|
|
@@ -13892,8 +14163,8 @@ var Renderer = class _Renderer {
|
|
|
13892
14163
|
top: void 0,
|
|
13893
14164
|
bottom: void 0
|
|
13894
14165
|
},
|
|
13895
|
-
position: new
|
|
13896
|
-
lookingAt: new
|
|
14166
|
+
position: new import_three36.Vector3(50, 50, 50),
|
|
14167
|
+
lookingAt: new import_three36.Vector3(0, 0, 0)
|
|
13897
14168
|
},
|
|
13898
14169
|
render: {
|
|
13899
14170
|
fpsLimit: 60,
|
|
@@ -13924,14 +14195,14 @@ var Renderer = class _Renderer {
|
|
|
13924
14195
|
switch (this.options.camera.type) {
|
|
13925
14196
|
case "perspective":
|
|
13926
14197
|
default:
|
|
13927
|
-
return new
|
|
14198
|
+
return new import_three36.PerspectiveCamera(
|
|
13928
14199
|
this.options.camera.perspective.fov,
|
|
13929
14200
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13930
14201
|
this.options.camera.near,
|
|
13931
14202
|
this.options.camera.far
|
|
13932
14203
|
);
|
|
13933
14204
|
case "orthographic":
|
|
13934
|
-
return new
|
|
14205
|
+
return new import_three36.OrthographicCamera(
|
|
13935
14206
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13936
14207
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13937
14208
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13942,7 +14213,7 @@ var Renderer = class _Renderer {
|
|
|
13942
14213
|
}
|
|
13943
14214
|
}
|
|
13944
14215
|
createRenderer() {
|
|
13945
|
-
const renderer = new
|
|
14216
|
+
const renderer = new import_three36.WebGLRenderer({
|
|
13946
14217
|
antialias: this.options.render.antialias,
|
|
13947
14218
|
alpha: true,
|
|
13948
14219
|
powerPreference: "high-performance",
|
|
@@ -13950,8 +14221,8 @@ var Renderer = class _Renderer {
|
|
|
13950
14221
|
});
|
|
13951
14222
|
renderer.setClearColor(0, 0);
|
|
13952
14223
|
renderer.shadowMap.enabled = true;
|
|
13953
|
-
renderer.shadowMap.type =
|
|
13954
|
-
renderer.outputColorSpace =
|
|
14224
|
+
renderer.shadowMap.type = import_three36.PCFShadowMap;
|
|
14225
|
+
renderer.outputColorSpace = import_three36.SRGBColorSpace;
|
|
13955
14226
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13956
14227
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13957
14228
|
return renderer;
|
|
@@ -13986,20 +14257,20 @@ var Renderer = class _Renderer {
|
|
|
13986
14257
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13987
14258
|
}
|
|
13988
14259
|
if (this.options.debug.grid) {
|
|
13989
|
-
const gridHelper = new
|
|
14260
|
+
const gridHelper = new import_three36.GridHelper(128, 16);
|
|
13990
14261
|
this._debugHelpers.push(gridHelper);
|
|
13991
14262
|
this.scene.add(gridHelper);
|
|
13992
|
-
const gridHelper2 = new
|
|
14263
|
+
const gridHelper2 = new import_three36.GridHelper(128, 16);
|
|
13993
14264
|
this._debugHelpers.push(gridHelper2);
|
|
13994
14265
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13995
14266
|
this.scene.add(gridHelper2);
|
|
13996
|
-
const gridHelper3 = new
|
|
14267
|
+
const gridHelper3 = new import_three36.GridHelper(128, 16);
|
|
13997
14268
|
this._debugHelpers.push(gridHelper3);
|
|
13998
14269
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13999
14270
|
this.scene.add(gridHelper3);
|
|
14000
14271
|
}
|
|
14001
14272
|
if (this.options.debug.axes) {
|
|
14002
|
-
const axesHelper = new
|
|
14273
|
+
const axesHelper = new import_three36.AxesHelper(64);
|
|
14003
14274
|
this._debugHelpers.push(axesHelper);
|
|
14004
14275
|
this.scene.add(axesHelper);
|
|
14005
14276
|
}
|
|
@@ -14685,12 +14956,12 @@ var AnvilParser = class {
|
|
|
14685
14956
|
};
|
|
14686
14957
|
|
|
14687
14958
|
// src/world/Chunk.ts
|
|
14688
|
-
var
|
|
14959
|
+
var import_three41 = require("three");
|
|
14689
14960
|
init_BlockStates();
|
|
14690
14961
|
init_AssetKey();
|
|
14691
14962
|
|
|
14692
14963
|
// src/world/MineRenderWorld.ts
|
|
14693
|
-
var
|
|
14964
|
+
var import_three39 = require("three");
|
|
14694
14965
|
init_Model();
|
|
14695
14966
|
init_BatchedExecutor();
|
|
14696
14967
|
init_AssetKey();
|
|
@@ -14698,7 +14969,7 @@ init_BlockStates();
|
|
|
14698
14969
|
init_CubeFace();
|
|
14699
14970
|
|
|
14700
14971
|
// src/world/SectionModels.ts
|
|
14701
|
-
var
|
|
14972
|
+
var import_three38 = require("three");
|
|
14702
14973
|
init_AssetKey();
|
|
14703
14974
|
init_Models();
|
|
14704
14975
|
init_CubeFace();
|
|
@@ -14764,12 +15035,12 @@ var SectionModels = class {
|
|
|
14764
15035
|
});
|
|
14765
15036
|
await object.init();
|
|
14766
15037
|
const geometry = object.children[0].geometry;
|
|
14767
|
-
geometry.applyMatrix4(new
|
|
15038
|
+
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
14768
15039
|
object.clear();
|
|
14769
15040
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14770
15041
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14771
15042
|
if (local < 0) return 0;
|
|
14772
|
-
const normal = new
|
|
15043
|
+
const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14773
15044
|
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);
|
|
14774
15045
|
return 1 << world;
|
|
14775
15046
|
});
|
|
@@ -14799,20 +15070,20 @@ var MineRenderWorld = class {
|
|
|
14799
15070
|
}
|
|
14800
15071
|
getBlockAt(posOrX, y, z) {
|
|
14801
15072
|
if (typeof posOrX == "number") {
|
|
14802
|
-
return this.getBlockAt(new
|
|
15073
|
+
return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
|
|
14803
15074
|
}
|
|
14804
15075
|
if (isTripleArray(posOrX)) {
|
|
14805
|
-
return this.getBlockAt(new
|
|
15076
|
+
return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14806
15077
|
}
|
|
14807
15078
|
this.validatePosBounds(posOrX);
|
|
14808
15079
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14809
15080
|
}
|
|
14810
15081
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14811
15082
|
if (typeof posOrX == "number") {
|
|
14812
|
-
return this.setBlockAt(new
|
|
15083
|
+
return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
|
|
14813
15084
|
}
|
|
14814
15085
|
if (isTripleArray(posOrX)) {
|
|
14815
|
-
return this.setBlockAt(new
|
|
15086
|
+
return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14816
15087
|
}
|
|
14817
15088
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14818
15089
|
}
|
|
@@ -14823,10 +15094,10 @@ var MineRenderWorld = class {
|
|
|
14823
15094
|
}
|
|
14824
15095
|
async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
|
|
14825
15096
|
if (typeof posOrX === "number") {
|
|
14826
|
-
return this.setBlockVisibleAt(new
|
|
15097
|
+
return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
|
|
14827
15098
|
}
|
|
14828
15099
|
if (isTripleArray(posOrX)) {
|
|
14829
|
-
return this.setBlockVisibleAt(new
|
|
15100
|
+
return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
|
|
14830
15101
|
}
|
|
14831
15102
|
this.validatePosBounds(posOrX);
|
|
14832
15103
|
await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
|
|
@@ -14843,7 +15114,7 @@ var MineRenderWorld = class {
|
|
|
14843
15114
|
const collect = async (positions2) => {
|
|
14844
15115
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14845
15116
|
};
|
|
14846
|
-
const place = (block) => this.placeBlock(new
|
|
15117
|
+
const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
|
|
14847
15118
|
const keys = /* @__PURE__ */ new Map();
|
|
14848
15119
|
for (const block of multiblock.blocks) {
|
|
14849
15120
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14921,13 +15192,13 @@ var MineRenderWorld = class {
|
|
|
14921
15192
|
for (const pos of positions) {
|
|
14922
15193
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14923
15194
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14924
|
-
const neighbor = pos.clone().add(new
|
|
15195
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
|
|
14925
15196
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14926
15197
|
}
|
|
14927
15198
|
for (let y = -1; y <= 1; y++) {
|
|
14928
15199
|
for (let z = -1; z <= 1; z++) {
|
|
14929
15200
|
for (let x = -1; x <= 1; x++) {
|
|
14930
|
-
const neighbor = pos.clone().add(new
|
|
15201
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
14931
15202
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14932
15203
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14933
15204
|
}
|
|
@@ -14951,7 +15222,7 @@ var MineRenderWorld = class {
|
|
|
14951
15222
|
}
|
|
14952
15223
|
if (block.object?.fluidKind) {
|
|
14953
15224
|
await block.object.updateFluid((x, y, z) => {
|
|
14954
|
-
const neighbor = pos.clone().add(new
|
|
15225
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
14955
15226
|
const section = this.getChunkAt(neighbor);
|
|
14956
15227
|
const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
14957
15228
|
return {
|
|
@@ -14963,7 +15234,7 @@ var MineRenderWorld = class {
|
|
|
14963
15234
|
}
|
|
14964
15235
|
let mask = 0;
|
|
14965
15236
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14966
|
-
const neighbor = pos.clone().add(new
|
|
15237
|
+
const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
|
|
14967
15238
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14968
15239
|
mask |= 1 << face;
|
|
14969
15240
|
}
|
|
@@ -14997,14 +15268,14 @@ var MineRenderWorld = class {
|
|
|
14997
15268
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14998
15269
|
}
|
|
14999
15270
|
static worldToScenePosition(pos) {
|
|
15000
|
-
return new
|
|
15271
|
+
return new import_three39.Vector3(
|
|
15001
15272
|
pos.x * 16,
|
|
15002
15273
|
pos.y * 16,
|
|
15003
15274
|
pos.z * 16
|
|
15004
15275
|
);
|
|
15005
15276
|
}
|
|
15006
15277
|
static sceneToWorldPosition(pos) {
|
|
15007
|
-
return new
|
|
15278
|
+
return new import_three39.Vector3(
|
|
15008
15279
|
pos.x / 16,
|
|
15009
15280
|
pos.y / 16,
|
|
15010
15281
|
pos.z / 16
|
|
@@ -15027,10 +15298,10 @@ var MineRenderWorld = class {
|
|
|
15027
15298
|
init_Model();
|
|
15028
15299
|
|
|
15029
15300
|
// src/world/SectionMesh.ts
|
|
15030
|
-
var
|
|
15301
|
+
var import_three40 = require("three");
|
|
15031
15302
|
init_CanvasCompat();
|
|
15032
15303
|
init_Materials();
|
|
15033
|
-
var SectionMesh = class _SectionMesh extends
|
|
15304
|
+
var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
15034
15305
|
constructor() {
|
|
15035
15306
|
super(...arguments);
|
|
15036
15307
|
this.ownedMeshes = [];
|
|
@@ -15103,18 +15374,18 @@ var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
|
15103
15374
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
15104
15375
|
}
|
|
15105
15376
|
}
|
|
15106
|
-
const geometry = new
|
|
15107
|
-
geometry.setAttribute("position", new
|
|
15108
|
-
geometry.setAttribute("normal", new
|
|
15109
|
-
geometry.setAttribute("uv", new
|
|
15110
|
-
geometry.setAttribute("color", new
|
|
15377
|
+
const geometry = new import_three40.BufferGeometry();
|
|
15378
|
+
geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
|
|
15379
|
+
geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
|
|
15380
|
+
geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
|
|
15381
|
+
geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
|
|
15111
15382
|
geometry.setIndex(indices);
|
|
15112
15383
|
geometry.computeBoundingBox();
|
|
15113
15384
|
geometry.computeBoundingSphere();
|
|
15114
15385
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
15115
15386
|
material.vertexColors = true;
|
|
15116
15387
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
15117
|
-
const mesh = new
|
|
15388
|
+
const mesh = new import_three40.Mesh(geometry, material);
|
|
15118
15389
|
section.add(mesh);
|
|
15119
15390
|
section.ownedMeshes.push({ mesh, texture });
|
|
15120
15391
|
}
|
|
@@ -15150,10 +15421,10 @@ var Chunk = class _Chunk {
|
|
|
15150
15421
|
}
|
|
15151
15422
|
getBlockAt(posOrX, y, z) {
|
|
15152
15423
|
if (typeof posOrX == "number") {
|
|
15153
|
-
return this.getBlockAt(new
|
|
15424
|
+
return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
|
|
15154
15425
|
}
|
|
15155
15426
|
if (isTripleArray(posOrX)) {
|
|
15156
|
-
return this.getBlockAt(new
|
|
15427
|
+
return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
15157
15428
|
}
|
|
15158
15429
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
15159
15430
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -15161,10 +15432,10 @@ var Chunk = class _Chunk {
|
|
|
15161
15432
|
}
|
|
15162
15433
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
15163
15434
|
if (typeof posOrX == "number") {
|
|
15164
|
-
return this.setBlockAt(new
|
|
15435
|
+
return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
|
|
15165
15436
|
}
|
|
15166
15437
|
if (isTripleArray(posOrX)) {
|
|
15167
|
-
return this.setBlockAt(new
|
|
15438
|
+
return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
15168
15439
|
}
|
|
15169
15440
|
const worldPos = posOrX;
|
|
15170
15441
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -15276,7 +15547,7 @@ var Chunk = class _Chunk {
|
|
|
15276
15547
|
}
|
|
15277
15548
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
15278
15549
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
15279
|
-
new
|
|
15550
|
+
new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
15280
15551
|
));
|
|
15281
15552
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
15282
15553
|
this.sectionBlocks.clear();
|
|
@@ -15301,14 +15572,14 @@ var Chunk = class _Chunk {
|
|
|
15301
15572
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
15302
15573
|
}
|
|
15303
15574
|
worldPosToChunkPos(pos) {
|
|
15304
|
-
return new
|
|
15575
|
+
return new import_three41.Vector3(
|
|
15305
15576
|
pos.x - this.x * 16,
|
|
15306
15577
|
pos.y - this.y * 16,
|
|
15307
15578
|
pos.z - this.z * 16
|
|
15308
15579
|
);
|
|
15309
15580
|
}
|
|
15310
15581
|
chunkPosToWorldPos(pos) {
|
|
15311
|
-
return new
|
|
15582
|
+
return new import_three41.Vector3(
|
|
15312
15583
|
this.x * 16 + pos.x,
|
|
15313
15584
|
this.y * 16 + pos.y,
|
|
15314
15585
|
this.z * 16 + pos.z
|
|
@@ -15360,6 +15631,7 @@ var Chunk = class _Chunk {
|
|
|
15360
15631
|
EntityObject,
|
|
15361
15632
|
Env,
|
|
15362
15633
|
FluidModelObject,
|
|
15634
|
+
Fonts,
|
|
15363
15635
|
Geometries,
|
|
15364
15636
|
GuiHelper,
|
|
15365
15637
|
GuiLight,
|
|
@@ -15433,6 +15705,7 @@ var Chunk = class _Chunk {
|
|
|
15433
15705
|
computeTangents,
|
|
15434
15706
|
createCanvas,
|
|
15435
15707
|
createFluidGeometry,
|
|
15708
|
+
createGuiTextGeometry,
|
|
15436
15709
|
createGuiTextureGeometry,
|
|
15437
15710
|
createImage,
|
|
15438
15711
|
entityAnimationTime,
|
|
@@ -15462,6 +15735,7 @@ var Chunk = class _Chunk {
|
|
|
15462
15735
|
isTransformable,
|
|
15463
15736
|
isTripleArray,
|
|
15464
15737
|
isVector3,
|
|
15738
|
+
layoutGuiText,
|
|
15465
15739
|
md5,
|
|
15466
15740
|
mergeBufferAttributes,
|
|
15467
15741
|
mergeBufferGeometries,
|