minerender 2.1.0-alpha.67 → 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.
@@ -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 import_three20.BufferGeometry();
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 import_three20.BufferAttribute(array, itemSize, normalized);
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 import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
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 import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
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 import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
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 import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
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 === import_three20.TrianglesDrawMode) {
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 === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
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 === import_three20.TriangleFanDrawMode) {
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 import_three20.Vector3();
4656
- const _vB = new import_three20.Vector3();
4657
- const _vC = new import_three20.Vector3();
4658
- const _tempA = new import_three20.Vector3();
4659
- const _tempB = new import_three20.Vector3();
4660
- const _tempC = new import_three20.Vector3();
4661
- const _morphA = new import_three20.Vector3();
4662
- const _morphB = new import_three20.Vector3();
4663
- const _morphC = new import_three20.Vector3();
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 import_three20.Float32BufferAttribute(modifiedPosition, 3);
4859
- const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
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 import_three20;
4871
+ var import_three22;
4868
4872
  var init_BufferGeometryUtils = __esm({
4869
4873
  "src/three/BufferGeometryUtils.js"() {
4870
- import_three20 = require("three");
4874
+ import_three22 = require("three");
4871
4875
  }
4872
4876
  });
4873
4877
 
4874
4878
  // src/model/ModelCulling.ts
4875
- var import_three21, ModelCulling;
4879
+ var import_three23, ModelCulling;
4876
4880
  var init_ModelCulling = __esm({
4877
4881
  "src/model/ModelCulling.ts"() {
4878
- import_three21 = require("three");
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 import_three21.Vector3(...offset).applyEuler(rotation);
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 import_three22, SpecialItems;
4921
+ var import_three24, SpecialItems;
4918
4922
  var init_SpecialItems = __esm({
4919
4923
  "src/model/SpecialItems.ts"() {
4920
- import_three22 = require("three");
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 import_three22.Matrix4(), {
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 import_three22.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three22.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three22.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three22.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
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 import_three22.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
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 import_three22.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three22.Matrix4().makeScale(-1, -1, 1)),
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 import_three23, import_ts_deepmerge5, p7, ModelObject;
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
- import_three23 = require("three");
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 import_three23.Matrix4();
5156
- transform.multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
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 import_three23.Euler(...this.options.uvLockRotation));
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 import_three23.Color(tint);
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 import_three23.BufferAttribute(colors, 3));
5237
+ elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
5234
5238
  }
5235
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
5236
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
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 import_three23.Matrix4().makeTranslation(-8, -8, -8));
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 import_three23.BoxGeometry(16, 16, 16);
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 import_three28.BufferGeometry();
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 import_three28.Float32BufferAttribute(positions, 3));
5472
- geometry.setAttribute("normal", new import_three28.Float32BufferAttribute(normals, 3));
5473
- geometry.setAttribute("uv", new import_three28.Float32BufferAttribute(uvs, 2));
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 import_three28, fluidRules, HORIZONTAL, EPSILON;
5481
+ var import_three30, fluidRules, HORIZONTAL, EPSILON;
5478
5482
  var init_FluidGeometry = __esm({
5479
5483
  "src/model/fluid/FluidGeometry.ts"() {
5480
- import_three28 = require("three");
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 import_three29, FluidModelObject;
5513
+ var import_three31, FluidModelObject;
5510
5514
  var init_FluidModelObject = __esm({
5511
5515
  "src/model/fluid/FluidModelObject.ts"() {
5512
- import_three29 = require("three");
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 import_three29.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
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 import_three29.BufferAttribute(colors, 3));
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 = import_three29.DoubleSide;
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,8 @@ __export(index_node_exports, {
5692
5697
  computeTangents: () => computeTangents,
5693
5698
  createCanvas: () => createCanvas2,
5694
5699
  createFluidGeometry: () => createFluidGeometry,
5700
+ createGuiTextGeometry: () => createGuiTextGeometry,
5701
+ createGuiTextureGeometry: () => createGuiTextureGeometry,
5695
5702
  createImage: () => createImage,
5696
5703
  entityAnimationTime: () => entityAnimationTime,
5697
5704
  estimateBytesUsed: () => estimateBytesUsed,
@@ -5720,6 +5727,7 @@ __export(index_node_exports, {
5720
5727
  isTransformable: () => isTransformable,
5721
5728
  isTripleArray: () => isTripleArray,
5722
5729
  isVector3: () => isVector3,
5730
+ layoutGuiText: () => layoutGuiText,
5723
5731
  md5: () => md5,
5724
5732
  mergeBufferAttributes: () => mergeBufferAttributes,
5725
5733
  mergeBufferGeometries: () => mergeBufferGeometries,
@@ -5952,6 +5960,101 @@ var BlockEntities = class {
5952
5960
  // src/assets/index.ts
5953
5961
  init_BlockStates();
5954
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
5955
6058
  init_ModelTextures();
5956
6059
  init_Models();
5957
6060
  init_source();
@@ -8909,7 +9012,137 @@ function copyDataTexture(source) {
8909
9012
 
8910
9013
  // src/gui/GuiHelper.ts
8911
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
8912
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
+ }
8913
9146
  static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
8914
9147
  const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
8915
9148
  return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
@@ -8973,8 +9206,87 @@ var GuiHelper = class {
8973
9206
  }
8974
9207
  };
8975
9208
 
9209
+ // src/gui/GuiTextureGeometry.ts
9210
+ var import_three21 = require("three");
9211
+ function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
9212
+ if (crop || !scaling || scaling.type === "stretch") {
9213
+ const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
9214
+ const geometry = new import_three21.PlaneGeometry(width, height);
9215
+ const uv = geometry.getAttribute("uv");
9216
+ for (let i = 0; i < uv.count; i++) {
9217
+ uv.setXY(
9218
+ i,
9219
+ (x + uv.getX(i) * w) / imageWidth,
9220
+ 1 - (y + (1 - uv.getY(i)) * h) / imageHeight
9221
+ );
9222
+ }
9223
+ return geometry;
9224
+ }
9225
+ const sw = scaling.width, sh = scaling.height;
9226
+ if (![sw, sh].every((value) => Number.isInteger(value) && value > 0)) {
9227
+ throw new Error("GUI sprite dimensions must be positive integers");
9228
+ }
9229
+ if (![width, height].every((value) => Number.isFinite(value) && value >= 0)) {
9230
+ throw new Error("GUI output dimensions must be finite and nonnegative");
9231
+ }
9232
+ const positions = [], uvs = [], normals = [], indices = [];
9233
+ function quad(x, y, w, h, u, v, uw, vh) {
9234
+ if (w <= 0 || h <= 0) return;
9235
+ const index = positions.length / 3;
9236
+ const left = x - width / 2, top = height / 2 - y;
9237
+ positions.push(left, top, 0, left + w, top, 0, left, top - h, 0, left + w, top - h, 0);
9238
+ uvs.push(
9239
+ u / sw,
9240
+ 1 - v / sh,
9241
+ (u + uw) / sw,
9242
+ 1 - v / sh,
9243
+ u / sw,
9244
+ 1 - (v + vh) / sh,
9245
+ (u + uw) / sw,
9246
+ 1 - (v + vh) / sh
9247
+ );
9248
+ normals.push(0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1);
9249
+ indices.push(index, index + 2, index + 1, index + 2, index + 3, index + 1);
9250
+ }
9251
+ function tile(x, y, w, h, u, v, tw, th) {
9252
+ for (let dy = 0; dy < h; dy += th) {
9253
+ for (let dx = 0; dx < w; dx += tw) {
9254
+ const cw = Math.min(tw, w - dx), ch = Math.min(th, h - dy);
9255
+ quad(x + dx, y + dy, cw, ch, u, v, cw, ch);
9256
+ }
9257
+ }
9258
+ }
9259
+ if (scaling.type === "tile") {
9260
+ tile(0, 0, width, height, 0, 0, sw, sh);
9261
+ } else {
9262
+ let segments = function(size, sourceSize, start, end) {
9263
+ if (size === sourceSize) return [[0, size, 0, sourceSize]];
9264
+ start = Math.min(start, Math.floor(size / 2));
9265
+ end = Math.min(end, Math.floor(size / 2));
9266
+ return [
9267
+ [0, start, 0, start],
9268
+ [start, size - start - end, start, sourceSize - start - end],
9269
+ [size - end, end, sourceSize - end, end]
9270
+ ];
9271
+ };
9272
+ const border = typeof scaling.border === "number" ? { left: scaling.border, top: scaling.border, right: scaling.border, bottom: scaling.border } : scaling.border;
9273
+ if (!border || typeof scaling.border === "number" && scaling.border <= 0 || ![border.left, border.top, border.right, border.bottom].every((value) => Number.isInteger(value) && value >= 0) || border.left + border.right >= sw || border.top + border.bottom >= sh) {
9274
+ throw new Error("GUI nine-slice borders must be nonnegative integers with a nonempty center");
9275
+ }
9276
+ const columns = segments(width, sw, border.left, border.right);
9277
+ const rows = segments(height, sh, border.top, border.bottom);
9278
+ for (const [y, h, v, vh] of rows) {
9279
+ for (const [x, w, u, uw] of columns) {
9280
+ if (w <= 0 || h <= 0) continue;
9281
+ (scaling.stretch_inner ? quad : tile)(x, y, w, h, u, v, uw, vh);
9282
+ }
9283
+ }
9284
+ }
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);
9286
+ }
9287
+
8976
9288
  // src/gui/scene/GuiObject.ts
8977
- var import_three24 = require("three");
9289
+ var import_three26 = require("three");
8978
9290
  init_AssetKey();
8979
9291
  init_ModelTextures();
8980
9292
  init_Models();
@@ -8990,9 +9302,10 @@ var GuiObject = class extends SceneObject {
8990
9302
  this.textureLayers = textureLayers;
8991
9303
  this.isGuiObject = true;
8992
9304
  /** Local bounds in GUI pixels, with y growing down from the origin. */
8993
- this.bounds = new import_three24.Box2();
9305
+ this.bounds = new import_three26.Box2();
8994
9306
  this.geometries = /* @__PURE__ */ new Set();
8995
9307
  this.ownedMaterials = /* @__PURE__ */ new Set();
9308
+ this.textMaterials = /* @__PURE__ */ new Map();
8996
9309
  this.initialized = false;
8997
9310
  }
8998
9311
  async init() {
@@ -9001,6 +9314,43 @@ var GuiObject = class extends SceneObject {
9001
9314
  let depth = 0;
9002
9315
  for (const [index, layer] of this.textureLayers.entries()) {
9003
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
+ }
9004
9354
  if ("item" in layer) {
9005
9355
  const [width2, height2] = layer.size ?? [16, 16];
9006
9356
  const item = await this.createItem(layer, index);
@@ -9008,41 +9358,33 @@ var GuiObject = class extends SceneObject {
9008
9358
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
9009
9359
  item.updateWorldMatrix(true, true);
9010
9360
  const inverse = this.matrixWorld.clone().invert();
9011
- const bounds = new import_three24.Box3();
9361
+ const bounds = new import_three26.Box3();
9012
9362
  item.iterateAllMeshes((mesh2) => {
9013
9363
  mesh2.geometry.computeBoundingBox();
9014
- bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three24.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
9364
+ bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three26.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
9015
9365
  });
9016
9366
  item.position.z = depth - bounds.min.z;
9017
9367
  depth += bounds.max.z - bounds.min.z + 0.01;
9018
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
9019
- this.bounds.expandByPoint(new import_three24.Vector2(x + width2, y + height2));
9020
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.min.x, -bounds.max.y));
9021
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.max.x, -bounds.min.y));
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));
9022
9372
  continue;
9023
9373
  }
9024
9374
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
9025
9375
  const material = await this.loadMaterial(key);
9026
9376
  const image = material.map.image;
9027
- const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
9028
- const [width, height] = layer.size ?? [cropWidth, cropHeight];
9029
- const geometry = new import_three24.PlaneGeometry(width, height);
9377
+ const scaling = layer.crop ? void 0 : (await ModelTextures.getMeta(key))?.gui?.scaling;
9378
+ const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
9379
+ const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
9030
9380
  this.geometries.add(geometry);
9031
- const uv = geometry.getAttribute("uv");
9032
- for (let i = 0; i < uv.count; i++) {
9033
- uv.setXY(
9034
- i,
9035
- (cropX + uv.getX(i) * cropWidth) / image.width,
9036
- 1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
9037
- );
9038
- }
9039
- const mesh = new import_three24.Mesh(geometry, material);
9381
+ const mesh = new import_three26.Mesh(geometry, material);
9040
9382
  mesh.name = `mesh:${layer.name ?? index}`;
9041
9383
  mesh.position.set(x + width / 2, -y - height / 2, depth);
9042
9384
  mesh.renderOrder = index;
9043
9385
  this.add(mesh);
9044
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
9045
- this.bounds.expandByPoint(new import_three24.Vector2(x + width, y + height));
9386
+ this.bounds.expandByPoint(new import_three26.Vector2(x, y));
9387
+ this.bounds.expandByPoint(new import_three26.Vector2(x + width, y + height));
9046
9388
  depth += 0.01;
9047
9389
  }
9048
9390
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -9100,10 +9442,11 @@ var GuiObject = class extends SceneObject {
9100
9442
  for (const geometry of this.geometries) geometry.dispose();
9101
9443
  this.geometries.clear();
9102
9444
  for (const material of this.ownedMaterials) {
9103
- material.map.dispose();
9445
+ material.map?.dispose();
9104
9446
  material.dispose();
9105
9447
  }
9106
9448
  this.ownedMaterials.clear();
9449
+ this.textMaterials.clear();
9107
9450
  this.bounds.makeEmpty();
9108
9451
  this.initialized = false;
9109
9452
  super.disposeAndRemoveAllChildren();
@@ -9117,7 +9460,7 @@ function isGuiObject(obj) {
9117
9460
  init_image();
9118
9461
 
9119
9462
  // src/inspector/SceneInspector.ts
9120
- var import_three25 = require("three");
9463
+ var import_three27 = require("three");
9121
9464
  init_SceneObject();
9122
9465
  init_util();
9123
9466
  init_log();
@@ -9127,11 +9470,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
9127
9470
  var SceneInspector = class {
9128
9471
  constructor(renderer) {
9129
9472
  this.renderer = renderer;
9130
- this.mouse = new import_three25.Vector2();
9473
+ this.mouse = new import_three27.Vector2();
9131
9474
  this.listeners = new AbortController();
9132
9475
  this.objectInfoContainer = document.createElement("div");
9133
9476
  this.objectControlsContainer = document.createElement("div");
9134
- this.raycaster = new import_three25.Raycaster();
9477
+ this.raycaster = new import_three27.Raycaster();
9135
9478
  this.init();
9136
9479
  }
9137
9480
  init() {
@@ -9534,7 +9877,7 @@ init_ModelMerger();
9534
9877
  init_SpecialItems();
9535
9878
 
9536
9879
  // src/model/block/BlockStateResolver.ts
9537
- var import_three27 = require("three");
9880
+ var import_three29 = require("three");
9538
9881
  init_BlockStates();
9539
9882
  init_MineRenderError();
9540
9883
  init_util();
@@ -9612,7 +9955,7 @@ var BlockStateResolver = class {
9612
9955
  return variants[variants.length - 1];
9613
9956
  }
9614
9957
  static rotation(variant) {
9615
- const rotation = new import_three27.Euler();
9958
+ const rotation = new import_three29.Euler();
9616
9959
  if (typeof variant.x !== "undefined") {
9617
9960
  rotation.x = toRadians(clampRotationDegrees(variant.x));
9618
9961
  }
@@ -9704,7 +10047,7 @@ init_SceneObject();
9704
10047
  init_ModelObject();
9705
10048
  init_Models();
9706
10049
  var import_ts_deepmerge6 = __toESM(require_dist());
9707
- var import_three30 = require("three");
10050
+ var import_three32 = require("three");
9708
10051
  init_MineRenderError();
9709
10052
  init_InstanceReference();
9710
10053
  init_AssetKey();
@@ -9726,7 +10069,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9726
10069
  this._models = [];
9727
10070
  this._cullMask = 0;
9728
10071
  this._entities = [];
9729
- this._entityPlacement = new import_three30.Matrix4();
10072
+ this._entityPlacement = new import_three32.Matrix4();
9730
10073
  this._entityGeneration = 0;
9731
10074
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
9732
10075
  }
@@ -9827,7 +10170,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9827
10170
  return true;
9828
10171
  }
9829
10172
  placeEntities() {
9830
- const matrix = new import_three30.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
10173
+ const matrix = new import_three32.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9831
10174
  for (const entity of this._entities) {
9832
10175
  matrix.decompose(entity.position, entity.quaternion, entity.scale);
9833
10176
  }
@@ -9849,12 +10192,12 @@ var BlockObject = class _BlockObject extends SceneObject {
9849
10192
  getModelCullMask(model, worldMask) {
9850
10193
  const object = isInstanceReference(model) ? model.instanceable : model;
9851
10194
  if (object.options.displayPosition) return 0;
9852
- const position = new import_three30.Vector3();
9853
- const rotation = new import_three30.Quaternion();
9854
- const scale = new import_three30.Vector3();
10195
+ const position = new import_three32.Vector3();
10196
+ const rotation = new import_three32.Quaternion();
10197
+ const scale = new import_three32.Vector3();
9855
10198
  this.getModelMatrix(model).decompose(position, rotation, scale);
9856
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three30.Vector3(1, 1, 1)) > 1e-10) return 0;
9857
- return ModelCulling.toLocalMask(worldMask, new import_three30.Euler().setFromQuaternion(rotation));
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));
9858
10201
  }
9859
10202
  async setCullMask(worldMask) {
9860
10203
  worldMask &= 63;
@@ -9920,7 +10263,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9920
10263
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
9921
10264
  );
9922
10265
  const previous = this._fluidModel;
9923
- const matrix = previous ? this.getModelMatrix(previous) : new import_three30.Matrix4().makeTranslation(...this.position.toArray());
10266
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three32.Matrix4().makeTranslation(...this.position.toArray());
9924
10267
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
9925
10268
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
9926
10269
  this._models = this._models.filter((model) => model !== previous);
@@ -10062,7 +10405,7 @@ var BlockObject = class _BlockObject extends SceneObject {
10062
10405
  setPositionRotationScaleAt(index, position, rotation, scale) {
10063
10406
  super.setPositionRotationScaleAt(index, position, rotation, scale);
10064
10407
  }
10065
- getMatrixAt(index, matrix = new import_three30.Matrix4()) {
10408
+ getMatrixAt(index, matrix = new import_three32.Matrix4()) {
10066
10409
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
10067
10410
  const child = this._models[0];
10068
10411
  if (child && isModelObject(child)) {
@@ -11934,7 +12277,7 @@ init_ModelObject();
11934
12277
  init_nbt();
11935
12278
 
11936
12279
  // src/renderer/MineRenderScene.ts
11937
- var import_three32 = require("three");
12280
+ var import_three34 = require("three");
11938
12281
  init_SceneObject();
11939
12282
  var import_ts_deepmerge8 = __toESM(require_dist());
11940
12283
  init_ModelObject();
@@ -12667,7 +13010,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
12667
13010
  init_util();
12668
13011
 
12669
13012
  // src/skin/SkinTextures.ts
12670
- var import_three31 = require("three");
13013
+ var import_three33 = require("three");
12671
13014
  init_Caching();
12672
13015
  init_CacheKey();
12673
13016
  init_MineRenderError();
@@ -12751,11 +13094,11 @@ var SkinTextures = class {
12751
13094
  });
12752
13095
  }
12753
13096
  static createMaterial(pixels, width, height, transparent = true) {
12754
- const texture = Textures.initTextureProps(new import_three31.DataTexture(pixels, width, height));
12755
- texture.colorSpace = import_three31.SRGBColorSpace;
13097
+ const texture = Textures.initTextureProps(new import_three33.DataTexture(pixels, width, height));
13098
+ texture.colorSpace = import_three33.SRGBColorSpace;
12756
13099
  texture.flipY = true;
12757
13100
  texture.needsUpdate = true;
12758
- return new import_three31.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three31.DoubleSide : import_three31.FrontSide, alphaTest: transparent ? 0.1 : 0 });
13101
+ return new import_three33.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three33.DoubleSide : import_three33.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12759
13102
  }
12760
13103
  static isSlim(image, scale) {
12761
13104
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -12985,7 +13328,7 @@ var SkinObject = class extends SceneObject {
12985
13328
  // src/renderer/MineRenderScene.ts
12986
13329
  init_EntityObject();
12987
13330
  init_ItemTints();
12988
- var MineRenderScene = class _MineRenderScene extends import_three32.Scene {
13331
+ var MineRenderScene = class _MineRenderScene extends import_three34.Scene {
12989
13332
  constructor(options) {
12990
13333
  super();
12991
13334
  this.isMineRenderScene = true;
@@ -13115,7 +13458,7 @@ function isMineRenderScene(obj) {
13115
13458
  }
13116
13459
 
13117
13460
  // src/renderer/Renderer.ts
13118
- var import_three34 = require("three");
13461
+ var import_three36 = require("three");
13119
13462
  var import_ts_deepmerge9 = __toESM(require_dist());
13120
13463
  var import_stats = __toESM(require("stats.js"));
13121
13464
  var import_postprocessing = require("postprocessing");
@@ -13124,11 +13467,11 @@ init_Model();
13124
13467
  init_three();
13125
13468
 
13126
13469
  // src/three/OrbitControls.js
13127
- var import_three33 = require("three");
13470
+ var import_three35 = require("three");
13128
13471
  var _changeEvent = { type: "change" };
13129
13472
  var _startEvent = { type: "start" };
13130
13473
  var _endEvent = { type: "end" };
13131
- var OrbitControls = class extends import_three33.EventDispatcher {
13474
+ var OrbitControls = class extends import_three35.EventDispatcher {
13132
13475
  constructor(object, domElement) {
13133
13476
  super();
13134
13477
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -13137,7 +13480,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13137
13480
  this.domElement = domElement;
13138
13481
  this.domElement.style.touchAction = "none";
13139
13482
  this.enabled = true;
13140
- this.target = new import_three33.Vector3();
13483
+ this.target = new import_three35.Vector3();
13141
13484
  this.minDistance = 0;
13142
13485
  this.maxDistance = Infinity;
13143
13486
  this.minZoom = 0;
@@ -13159,8 +13502,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13159
13502
  this.autoRotate = false;
13160
13503
  this.autoRotateSpeed = 2;
13161
13504
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
13162
- this.mouseButtons = { LEFT: import_three33.MOUSE.ROTATE, MIDDLE: import_three33.MOUSE.DOLLY, RIGHT: import_three33.MOUSE.PAN };
13163
- this.touches = { ONE: import_three33.TOUCH.ROTATE, TWO: import_three33.TOUCH.DOLLY_PAN };
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 };
13164
13507
  this.target0 = this.target.clone();
13165
13508
  this.position0 = this.object.position.clone();
13166
13509
  this.zoom0 = this.object.zoom;
@@ -13189,11 +13532,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13189
13532
  state = STATE.NONE;
13190
13533
  };
13191
13534
  this.update = function() {
13192
- const offset = new import_three33.Vector3();
13193
- const quat = new import_three33.Quaternion().setFromUnitVectors(object.up, new import_three33.Vector3(0, 1, 0));
13535
+ const offset = new import_three35.Vector3();
13536
+ const quat = new import_three35.Quaternion().setFromUnitVectors(object.up, new import_three35.Vector3(0, 1, 0));
13194
13537
  const quatInverse = quat.clone().invert();
13195
- const lastPosition = new import_three33.Vector3();
13196
- const lastQuaternion = new import_three33.Quaternion();
13538
+ const lastPosition = new import_three35.Vector3();
13539
+ const lastQuaternion = new import_three35.Quaternion();
13197
13540
  const twoPI = 2 * Math.PI;
13198
13541
  return function update() {
13199
13542
  const position = scope.object.position;
@@ -13279,20 +13622,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13279
13622
  };
13280
13623
  let state = STATE.NONE;
13281
13624
  const EPS = 1e-6;
13282
- const spherical = new import_three33.Spherical();
13283
- const sphericalDelta = new import_three33.Spherical();
13625
+ const spherical = new import_three35.Spherical();
13626
+ const sphericalDelta = new import_three35.Spherical();
13284
13627
  let scale = 1;
13285
- const panOffset = new import_three33.Vector3();
13628
+ const panOffset = new import_three35.Vector3();
13286
13629
  let zoomChanged = false;
13287
- const rotateStart = new import_three33.Vector2();
13288
- const rotateEnd = new import_three33.Vector2();
13289
- const rotateDelta = new import_three33.Vector2();
13290
- const panStart = new import_three33.Vector2();
13291
- const panEnd = new import_three33.Vector2();
13292
- const panDelta = new import_three33.Vector2();
13293
- const dollyStart = new import_three33.Vector2();
13294
- const dollyEnd = new import_three33.Vector2();
13295
- const dollyDelta = new import_three33.Vector2();
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();
13296
13639
  const pointers = [];
13297
13640
  const pointerPositions = {};
13298
13641
  function getAutoRotationAngle() {
@@ -13308,7 +13651,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13308
13651
  sphericalDelta.phi -= angle;
13309
13652
  }
13310
13653
  const panLeft = function() {
13311
- const v = new import_three33.Vector3();
13654
+ const v = new import_three35.Vector3();
13312
13655
  return function panLeft2(distance, objectMatrix) {
13313
13656
  v.setFromMatrixColumn(objectMatrix, 0);
13314
13657
  v.multiplyScalar(-distance);
@@ -13316,7 +13659,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13316
13659
  };
13317
13660
  }();
13318
13661
  const panUp = function() {
13319
- const v = new import_three33.Vector3();
13662
+ const v = new import_three35.Vector3();
13320
13663
  return function panUp2(distance, objectMatrix) {
13321
13664
  if (scope.screenSpacePanning === true) {
13322
13665
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -13329,7 +13672,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13329
13672
  };
13330
13673
  }();
13331
13674
  const pan = function() {
13332
- const offset = new import_three33.Vector3();
13675
+ const offset = new import_three35.Vector3();
13333
13676
  return function pan2(deltaX, deltaY) {
13334
13677
  const element = scope.domElement;
13335
13678
  if (scope.object.isPerspectiveCamera) {
@@ -13578,12 +13921,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13578
13921
  mouseAction = -1;
13579
13922
  }
13580
13923
  switch (mouseAction) {
13581
- case import_three33.MOUSE.DOLLY:
13924
+ case import_three35.MOUSE.DOLLY:
13582
13925
  if (scope.enableZoom === false) return;
13583
13926
  handleMouseDownDolly(event);
13584
13927
  state = STATE.DOLLY;
13585
13928
  break;
13586
- case import_three33.MOUSE.ROTATE:
13929
+ case import_three35.MOUSE.ROTATE:
13587
13930
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13588
13931
  if (scope.enablePan === false) return;
13589
13932
  handleMouseDownPan(event);
@@ -13594,7 +13937,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13594
13937
  state = STATE.ROTATE;
13595
13938
  }
13596
13939
  break;
13597
- case import_three33.MOUSE.PAN:
13940
+ case import_three35.MOUSE.PAN:
13598
13941
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13599
13942
  if (scope.enableRotate === false) return;
13600
13943
  handleMouseDownRotate(event);
@@ -13650,12 +13993,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13650
13993
  switch (pointers.length) {
13651
13994
  case 1:
13652
13995
  switch (scope.touches.ONE) {
13653
- case import_three33.TOUCH.ROTATE:
13996
+ case import_three35.TOUCH.ROTATE:
13654
13997
  if (scope.enableRotate === false) return;
13655
13998
  handleTouchStartRotate();
13656
13999
  state = STATE.TOUCH_ROTATE;
13657
14000
  break;
13658
- case import_three33.TOUCH.PAN:
14001
+ case import_three35.TOUCH.PAN:
13659
14002
  if (scope.enablePan === false) return;
13660
14003
  handleTouchStartPan();
13661
14004
  state = STATE.TOUCH_PAN;
@@ -13666,12 +14009,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13666
14009
  break;
13667
14010
  case 2:
13668
14011
  switch (scope.touches.TWO) {
13669
- case import_three33.TOUCH.DOLLY_PAN:
14012
+ case import_three35.TOUCH.DOLLY_PAN:
13670
14013
  if (scope.enableZoom === false && scope.enablePan === false) return;
13671
14014
  handleTouchStartDollyPan();
13672
14015
  state = STATE.TOUCH_DOLLY_PAN;
13673
14016
  break;
13674
- case import_three33.TOUCH.DOLLY_ROTATE:
14017
+ case import_three35.TOUCH.DOLLY_ROTATE:
13675
14018
  if (scope.enableZoom === false && scope.enableRotate === false) return;
13676
14019
  handleTouchStartDollyRotate();
13677
14020
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -13738,7 +14081,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13738
14081
  function trackPointer(event) {
13739
14082
  let position = pointerPositions[event.pointerId];
13740
14083
  if (position === void 0) {
13741
- position = new import_three33.Vector2();
14084
+ position = new import_three35.Vector2();
13742
14085
  pointerPositions[event.pointerId] = position;
13743
14086
  }
13744
14087
  position.set(event.pageX, event.pageY);
@@ -13758,10 +14101,10 @@ var MapControls = class extends OrbitControls {
13758
14101
  constructor(object, domElement) {
13759
14102
  super(object, domElement);
13760
14103
  this.screenSpacePanning = false;
13761
- this.mouseButtons.LEFT = import_three33.MOUSE.PAN;
13762
- this.mouseButtons.RIGHT = import_three33.MOUSE.ROTATE;
13763
- this.touches.ONE = import_three33.TOUCH.PAN;
13764
- this.touches.TWO = import_three33.TOUCH.DOLLY_ROTATE;
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;
13765
14108
  }
13766
14109
  };
13767
14110
 
@@ -13820,8 +14163,8 @@ var Renderer = class _Renderer {
13820
14163
  top: void 0,
13821
14164
  bottom: void 0
13822
14165
  },
13823
- position: new import_three34.Vector3(50, 50, 50),
13824
- lookingAt: new import_three34.Vector3(0, 0, 0)
14166
+ position: new import_three36.Vector3(50, 50, 50),
14167
+ lookingAt: new import_three36.Vector3(0, 0, 0)
13825
14168
  },
13826
14169
  render: {
13827
14170
  fpsLimit: 60,
@@ -13852,14 +14195,14 @@ var Renderer = class _Renderer {
13852
14195
  switch (this.options.camera.type) {
13853
14196
  case "perspective":
13854
14197
  default:
13855
- return new import_three34.PerspectiveCamera(
14198
+ return new import_three36.PerspectiveCamera(
13856
14199
  this.options.camera.perspective.fov,
13857
14200
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
13858
14201
  this.options.camera.near,
13859
14202
  this.options.camera.far
13860
14203
  );
13861
14204
  case "orthographic":
13862
- return new import_three34.OrthographicCamera(
14205
+ return new import_three36.OrthographicCamera(
13863
14206
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
13864
14207
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
13865
14208
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -13870,7 +14213,7 @@ var Renderer = class _Renderer {
13870
14213
  }
13871
14214
  }
13872
14215
  createRenderer() {
13873
- const renderer = new import_three34.WebGLRenderer({
14216
+ const renderer = new import_three36.WebGLRenderer({
13874
14217
  antialias: this.options.render.antialias,
13875
14218
  alpha: true,
13876
14219
  powerPreference: "high-performance",
@@ -13878,8 +14221,8 @@ var Renderer = class _Renderer {
13878
14221
  });
13879
14222
  renderer.setClearColor(0, 0);
13880
14223
  renderer.shadowMap.enabled = true;
13881
- renderer.shadowMap.type = import_three34.PCFShadowMap;
13882
- renderer.outputColorSpace = import_three34.SRGBColorSpace;
14224
+ renderer.shadowMap.type = import_three36.PCFShadowMap;
14225
+ renderer.outputColorSpace = import_three36.SRGBColorSpace;
13883
14226
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
13884
14227
  renderer.setSize(this.viewWidth, this.viewHeight);
13885
14228
  return renderer;
@@ -13914,20 +14257,20 @@ var Renderer = class _Renderer {
13914
14257
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
13915
14258
  }
13916
14259
  if (this.options.debug.grid) {
13917
- const gridHelper = new import_three34.GridHelper(128, 16);
14260
+ const gridHelper = new import_three36.GridHelper(128, 16);
13918
14261
  this._debugHelpers.push(gridHelper);
13919
14262
  this.scene.add(gridHelper);
13920
- const gridHelper2 = new import_three34.GridHelper(128, 16);
14263
+ const gridHelper2 = new import_three36.GridHelper(128, 16);
13921
14264
  this._debugHelpers.push(gridHelper2);
13922
14265
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
13923
14266
  this.scene.add(gridHelper2);
13924
- const gridHelper3 = new import_three34.GridHelper(128, 16);
14267
+ const gridHelper3 = new import_three36.GridHelper(128, 16);
13925
14268
  this._debugHelpers.push(gridHelper3);
13926
14269
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
13927
14270
  this.scene.add(gridHelper3);
13928
14271
  }
13929
14272
  if (this.options.debug.axes) {
13930
- const axesHelper = new import_three34.AxesHelper(64);
14273
+ const axesHelper = new import_three36.AxesHelper(64);
13931
14274
  this._debugHelpers.push(axesHelper);
13932
14275
  this.scene.add(axesHelper);
13933
14276
  }
@@ -14613,12 +14956,12 @@ var AnvilParser = class {
14613
14956
  };
14614
14957
 
14615
14958
  // src/world/Chunk.ts
14616
- var import_three39 = require("three");
14959
+ var import_three41 = require("three");
14617
14960
  init_BlockStates();
14618
14961
  init_AssetKey();
14619
14962
 
14620
14963
  // src/world/MineRenderWorld.ts
14621
- var import_three37 = require("three");
14964
+ var import_three39 = require("three");
14622
14965
  init_Model();
14623
14966
  init_BatchedExecutor();
14624
14967
  init_AssetKey();
@@ -14626,7 +14969,7 @@ init_BlockStates();
14626
14969
  init_CubeFace();
14627
14970
 
14628
14971
  // src/world/SectionModels.ts
14629
- var import_three36 = require("three");
14972
+ var import_three38 = require("three");
14630
14973
  init_AssetKey();
14631
14974
  init_Models();
14632
14975
  init_CubeFace();
@@ -14692,12 +15035,12 @@ var SectionModels = class {
14692
15035
  });
14693
15036
  await object.init();
14694
15037
  const geometry = object.children[0].geometry;
14695
- geometry.applyMatrix4(new import_three36.Matrix4().makeRotationFromEuler(rotation));
15038
+ geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
14696
15039
  object.clear();
14697
15040
  const cullFaces = CUBE_FACES.map((face) => {
14698
15041
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14699
15042
  if (local < 0) return 0;
14700
- const normal = new import_three36.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
15043
+ const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14701
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);
14702
15045
  return 1 << world;
14703
15046
  });
@@ -14727,20 +15070,20 @@ var MineRenderWorld = class {
14727
15070
  }
14728
15071
  getBlockAt(posOrX, y, z) {
14729
15072
  if (typeof posOrX == "number") {
14730
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
15073
+ return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
14731
15074
  }
14732
15075
  if (isTripleArray(posOrX)) {
14733
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15076
+ return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14734
15077
  }
14735
15078
  this.validatePosBounds(posOrX);
14736
15079
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
14737
15080
  }
14738
15081
  async setBlockAt(posOrX, yOrBlock, z, block) {
14739
15082
  if (typeof posOrX == "number") {
14740
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
15083
+ return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
14741
15084
  }
14742
15085
  if (isTripleArray(posOrX)) {
14743
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15086
+ return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14744
15087
  }
14745
15088
  return this.placeBlock(posOrX, yOrBlock);
14746
15089
  }
@@ -14751,10 +15094,10 @@ var MineRenderWorld = class {
14751
15094
  }
14752
15095
  async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
14753
15096
  if (typeof posOrX === "number") {
14754
- return this.setBlockVisibleAt(new import_three37.Vector3(posOrX, yOrVisible, z), visible);
15097
+ return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
14755
15098
  }
14756
15099
  if (isTripleArray(posOrX)) {
14757
- return this.setBlockVisibleAt(new import_three37.Vector3(...posOrX), yOrVisible);
15100
+ return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
14758
15101
  }
14759
15102
  this.validatePosBounds(posOrX);
14760
15103
  await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
@@ -14771,7 +15114,7 @@ var MineRenderWorld = class {
14771
15114
  const collect = async (positions2) => {
14772
15115
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
14773
15116
  };
14774
- const place = (block) => this.placeBlock(new import_three37.Vector3(...block.position), block, collect);
15117
+ const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
14775
15118
  const keys = /* @__PURE__ */ new Map();
14776
15119
  for (const block of multiblock.blocks) {
14777
15120
  if (Chunk.isAir(block)) continue;
@@ -14849,13 +15192,13 @@ var MineRenderWorld = class {
14849
15192
  for (const pos of positions) {
14850
15193
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
14851
15194
  for (const offset of CUBE_FACE_OFFSETS) {
14852
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
15195
+ const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
14853
15196
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14854
15197
  }
14855
15198
  for (let y = -1; y <= 1; y++) {
14856
15199
  for (let z = -1; z <= 1; z++) {
14857
15200
  for (let x = -1; x <= 1; x++) {
14858
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
15201
+ const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
14859
15202
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
14860
15203
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14861
15204
  }
@@ -14879,7 +15222,7 @@ var MineRenderWorld = class {
14879
15222
  }
14880
15223
  if (block.object?.fluidKind) {
14881
15224
  await block.object.updateFluid((x, y, z) => {
14882
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
15225
+ const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
14883
15226
  const section = this.getChunkAt(neighbor);
14884
15227
  const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
14885
15228
  return {
@@ -14891,7 +15234,7 @@ var MineRenderWorld = class {
14891
15234
  }
14892
15235
  let mask = 0;
14893
15236
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
14894
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
15237
+ const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
14895
15238
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
14896
15239
  mask |= 1 << face;
14897
15240
  }
@@ -14925,14 +15268,14 @@ var MineRenderWorld = class {
14925
15268
  return this._chunks.get(this.worldPosToChunkKey(pos));
14926
15269
  }
14927
15270
  static worldToScenePosition(pos) {
14928
- return new import_three37.Vector3(
15271
+ return new import_three39.Vector3(
14929
15272
  pos.x * 16,
14930
15273
  pos.y * 16,
14931
15274
  pos.z * 16
14932
15275
  );
14933
15276
  }
14934
15277
  static sceneToWorldPosition(pos) {
14935
- return new import_three37.Vector3(
15278
+ return new import_three39.Vector3(
14936
15279
  pos.x / 16,
14937
15280
  pos.y / 16,
14938
15281
  pos.z / 16
@@ -14955,10 +15298,10 @@ var MineRenderWorld = class {
14955
15298
  init_Model();
14956
15299
 
14957
15300
  // src/world/SectionMesh.ts
14958
- var import_three38 = require("three");
15301
+ var import_three40 = require("three");
14959
15302
  init_CanvasCompat();
14960
15303
  init_Materials();
14961
- var SectionMesh = class _SectionMesh extends import_three38.Group {
15304
+ var SectionMesh = class _SectionMesh extends import_three40.Group {
14962
15305
  constructor() {
14963
15306
  super(...arguments);
14964
15307
  this.ownedMeshes = [];
@@ -15031,18 +15374,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
15031
15374
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
15032
15375
  }
15033
15376
  }
15034
- const geometry = new import_three38.BufferGeometry();
15035
- geometry.setAttribute("position", new import_three38.Float32BufferAttribute(positions, 3));
15036
- geometry.setAttribute("normal", new import_three38.Float32BufferAttribute(normals, 3));
15037
- geometry.setAttribute("uv", new import_three38.Float32BufferAttribute(uvs, 2));
15038
- geometry.setAttribute("color", new import_three38.Float32BufferAttribute(colors, 3));
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));
15039
15382
  geometry.setIndex(indices);
15040
15383
  geometry.computeBoundingBox();
15041
15384
  geometry.computeBoundingSphere();
15042
15385
  const material = Materials.createShadedCanvasMaterial(canvas, false);
15043
15386
  material.vertexColors = true;
15044
15387
  const texture = material.uniforms?.map?.value ?? material.map;
15045
- const mesh = new import_three38.Mesh(geometry, material);
15388
+ const mesh = new import_three40.Mesh(geometry, material);
15046
15389
  section.add(mesh);
15047
15390
  section.ownedMeshes.push({ mesh, texture });
15048
15391
  }
@@ -15078,10 +15421,10 @@ var Chunk = class _Chunk {
15078
15421
  }
15079
15422
  getBlockAt(posOrX, y, z) {
15080
15423
  if (typeof posOrX == "number") {
15081
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
15424
+ return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
15082
15425
  }
15083
15426
  if (isTripleArray(posOrX)) {
15084
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15427
+ return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15085
15428
  }
15086
15429
  const pos = this.worldPosToChunkPos(posOrX);
15087
15430
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -15089,10 +15432,10 @@ var Chunk = class _Chunk {
15089
15432
  }
15090
15433
  async setBlockAt(posOrX, yOrBlock, z, block) {
15091
15434
  if (typeof posOrX == "number") {
15092
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
15435
+ return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
15093
15436
  }
15094
15437
  if (isTripleArray(posOrX)) {
15095
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15438
+ return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15096
15439
  }
15097
15440
  const worldPos = posOrX;
15098
15441
  const pos = this.worldPosToChunkPos(worldPos);
@@ -15204,7 +15547,7 @@ var Chunk = class _Chunk {
15204
15547
  }
15205
15548
  async clear(onBlocksChanged = this.onBlocksChanged) {
15206
15549
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
15207
- new import_three39.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
15550
+ new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
15208
15551
  ));
15209
15552
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
15210
15553
  this.sectionBlocks.clear();
@@ -15229,14 +15572,14 @@ var Chunk = class _Chunk {
15229
15572
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
15230
15573
  }
15231
15574
  worldPosToChunkPos(pos) {
15232
- return new import_three39.Vector3(
15575
+ return new import_three41.Vector3(
15233
15576
  pos.x - this.x * 16,
15234
15577
  pos.y - this.y * 16,
15235
15578
  pos.z - this.z * 16
15236
15579
  );
15237
15580
  }
15238
15581
  chunkPosToWorldPos(pos) {
15239
- return new import_three39.Vector3(
15582
+ return new import_three41.Vector3(
15240
15583
  this.x * 16 + pos.x,
15241
15584
  this.y * 16 + pos.y,
15242
15585
  this.z * 16 + pos.z
@@ -15288,6 +15631,7 @@ var Chunk = class _Chunk {
15288
15631
  EntityObject,
15289
15632
  Env,
15290
15633
  FluidModelObject,
15634
+ Fonts,
15291
15635
  Geometries,
15292
15636
  GuiHelper,
15293
15637
  GuiLight,
@@ -15361,6 +15705,8 @@ var Chunk = class _Chunk {
15361
15705
  computeTangents,
15362
15706
  createCanvas,
15363
15707
  createFluidGeometry,
15708
+ createGuiTextGeometry,
15709
+ createGuiTextureGeometry,
15364
15710
  createImage,
15365
15711
  entityAnimationTime,
15366
15712
  estimateBytesUsed,
@@ -15389,6 +15735,7 @@ var Chunk = class _Chunk {
15389
15735
  isTransformable,
15390
15736
  isTripleArray,
15391
15737
  isVector3,
15738
+ layoutGuiText,
15392
15739
  md5,
15393
15740
  mergeBufferAttributes,
15394
15741
  mergeBufferGeometries,