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.
@@ -259,7 +259,8 @@ var init_Caching = __esm({
259
259
  this.entityModelCache,
260
260
  this.entityTextureCache,
261
261
  this.entityAnimationCache,
262
- this.blockEntityIndexCache
262
+ this.blockEntityIndexCache,
263
+ this.fontCache
263
264
  ];
264
265
  }
265
266
  static clear() {
@@ -306,6 +307,7 @@ var init_Caching = __esm({
306
307
  _Caching.entityTextureCache = _Caching.createAssetCache();
307
308
  _Caching.entityAnimationCache = _Caching.createAssetCache();
308
309
  _Caching.blockEntityIndexCache = _Caching.createAssetCache();
310
+ _Caching.fontCache = _Caching.createAssetCache();
309
311
  Caching = _Caching;
310
312
  }
311
313
  });
@@ -4258,7 +4260,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
4258
4260
  const attributes = {};
4259
4261
  const morphAttributes = {};
4260
4262
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
4261
- const mergedGeometry = new import_three20.BufferGeometry();
4263
+ const mergedGeometry = new import_three22.BufferGeometry();
4262
4264
  let offset = 0;
4263
4265
  for (let i = 0; i < geometries.length; ++i) {
4264
4266
  const geometry = geometries[i];
@@ -4382,7 +4384,7 @@ function mergeBufferAttributes(attributes) {
4382
4384
  array.set(attributes[i].array, offset);
4383
4385
  offset += attributes[i].array.length;
4384
4386
  }
4385
- return new import_three20.BufferAttribute(array, itemSize, normalized);
4387
+ return new import_three22.BufferAttribute(array, itemSize, normalized);
4386
4388
  }
4387
4389
  function interleaveAttributes(attributes) {
4388
4390
  let TypedArray;
@@ -4398,7 +4400,7 @@ function interleaveAttributes(attributes) {
4398
4400
  arrayLength += attribute.array.length;
4399
4401
  stride += attribute.itemSize;
4400
4402
  }
4401
- const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
4403
+ const interleavedBuffer = new import_three22.InterleavedBuffer(new TypedArray(arrayLength), stride);
4402
4404
  let offset = 0;
4403
4405
  const res = [];
4404
4406
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -4407,7 +4409,7 @@ function interleaveAttributes(attributes) {
4407
4409
  const attribute = attributes[j];
4408
4410
  const itemSize = attribute.itemSize;
4409
4411
  const count = attribute.count;
4410
- const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4412
+ const iba = new import_three22.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4411
4413
  res.push(iba);
4412
4414
  offset += itemSize;
4413
4415
  for (let c = 0; c < count; c++) {
@@ -4491,13 +4493,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4491
4493
  const name = attributeNames[i];
4492
4494
  const oldAttribute = geometry.getAttribute(name);
4493
4495
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
4494
- const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4496
+ const attribute = new import_three22.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4495
4497
  result.setAttribute(name, attribute);
4496
4498
  if (name in morphAttrsArrays) {
4497
4499
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
4498
4500
  const oldMorphAttribute = geometry.morphAttributes[name][j];
4499
4501
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
4500
- const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4502
+ const morphAttribute = new import_three22.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4501
4503
  result.morphAttributes[name][j] = morphAttribute;
4502
4504
  }
4503
4505
  }
@@ -4506,11 +4508,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4506
4508
  return result;
4507
4509
  }
4508
4510
  function toTrianglesDrawMode(geometry, drawMode) {
4509
- if (drawMode === import_three20.TrianglesDrawMode) {
4511
+ if (drawMode === import_three22.TrianglesDrawMode) {
4510
4512
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
4511
4513
  return geometry;
4512
4514
  }
4513
- if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
4515
+ if (drawMode === import_three22.TriangleFanDrawMode || drawMode === import_three22.TriangleStripDrawMode) {
4514
4516
  let index = geometry.getIndex();
4515
4517
  if (index === null) {
4516
4518
  const indices = [];
@@ -4528,7 +4530,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
4528
4530
  }
4529
4531
  const numberOfTriangles = index.count - 2;
4530
4532
  const newIndices = [];
4531
- if (drawMode === import_three20.TriangleFanDrawMode) {
4533
+ if (drawMode === import_three22.TriangleFanDrawMode) {
4532
4534
  for (let i = 1; i <= numberOfTriangles; i++) {
4533
4535
  newIndices.push(index.getX(0));
4534
4536
  newIndices.push(index.getX(i));
@@ -4564,15 +4566,15 @@ function computeMorphedAttributes(object) {
4564
4566
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4565
4567
  return null;
4566
4568
  }
4567
- const _vA = new import_three20.Vector3();
4568
- const _vB = new import_three20.Vector3();
4569
- const _vC = new import_three20.Vector3();
4570
- const _tempA = new import_three20.Vector3();
4571
- const _tempB = new import_three20.Vector3();
4572
- const _tempC = new import_three20.Vector3();
4573
- const _morphA = new import_three20.Vector3();
4574
- const _morphB = new import_three20.Vector3();
4575
- const _morphC = new import_three20.Vector3();
4569
+ const _vA = new import_three22.Vector3();
4570
+ const _vB = new import_three22.Vector3();
4571
+ const _vC = new import_three22.Vector3();
4572
+ const _tempA = new import_three22.Vector3();
4573
+ const _tempB = new import_three22.Vector3();
4574
+ const _tempC = new import_three22.Vector3();
4575
+ const _morphA = new import_three22.Vector3();
4576
+ const _morphB = new import_three22.Vector3();
4577
+ const _morphC = new import_three22.Vector3();
4576
4578
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4577
4579
  _vA.fromBufferAttribute(attribute, a2);
4578
4580
  _vB.fromBufferAttribute(attribute, b2);
@@ -4767,8 +4769,8 @@ function computeMorphedAttributes(object) {
4767
4769
  }
4768
4770
  }
4769
4771
  }
4770
- const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4771
- const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4772
+ const morphedPositionAttribute = new import_three22.Float32BufferAttribute(modifiedPosition, 3);
4773
+ const morphedNormalAttribute = new import_three22.Float32BufferAttribute(modifiedNormal, 3);
4772
4774
  return {
4773
4775
  positionAttribute,
4774
4776
  normalAttribute,
@@ -4776,24 +4778,24 @@ function computeMorphedAttributes(object) {
4776
4778
  morphedNormalAttribute
4777
4779
  };
4778
4780
  }
4779
- var import_three20;
4781
+ var import_three22;
4780
4782
  var init_BufferGeometryUtils = __esm({
4781
4783
  "src/three/BufferGeometryUtils.js"() {
4782
- import_three20 = require("three");
4784
+ import_three22 = require("three");
4783
4785
  }
4784
4786
  });
4785
4787
 
4786
4788
  // src/model/ModelCulling.ts
4787
- var import_three21, ModelCulling;
4789
+ var import_three23, ModelCulling;
4788
4790
  var init_ModelCulling = __esm({
4789
4791
  "src/model/ModelCulling.ts"() {
4790
- import_three21 = require("three");
4792
+ import_three23 = require("three");
4791
4793
  init_CubeFace();
4792
4794
  ModelCulling = class {
4793
4795
  static toLocalMask(worldMask, rotation) {
4794
4796
  let localMask = 0;
4795
4797
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4796
- const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4798
+ const normal = new import_three23.Vector3(...offset).applyEuler(rotation);
4797
4799
  const worldFace = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
4798
4800
  if (worldFace < 0) return 0;
4799
4801
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4826,10 +4828,10 @@ var init_ModelCulling = __esm({
4826
4828
  });
4827
4829
 
4828
4830
  // src/model/SpecialItems.ts
4829
- var import_three22, SpecialItems;
4831
+ var import_three24, SpecialItems;
4830
4832
  var init_SpecialItems = __esm({
4831
4833
  "src/model/SpecialItems.ts"() {
4832
- import_three22 = require("three");
4834
+ import_three24 = require("three");
4833
4835
  init_AssetKey();
4834
4836
  init_Entities();
4835
4837
  SpecialItems = class {
@@ -4857,7 +4859,7 @@ var init_SpecialItems = __esm({
4857
4859
  case "minecraft:chest":
4858
4860
  case "chest": {
4859
4861
  const angle = -(special.openness ?? 0) * Math.PI / 2;
4860
- const chest = await load("chest", texture(special.texture, "chest"), new import_three22.Matrix4(), {
4862
+ const chest = await load("chest", texture(special.texture, "chest"), new import_three24.Matrix4(), {
4861
4863
  lid: [angle, 0, 0],
4862
4864
  lock: [angle, 0, 0]
4863
4865
  });
@@ -4866,11 +4868,11 @@ var init_SpecialItems = __esm({
4866
4868
  }
4867
4869
  case "minecraft:bed":
4868
4870
  case "bed": {
4869
- const transform = new 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));
4871
+ const transform = new import_three24.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three24.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three24.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three24.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
4870
4872
  const key = texture(special.texture, "bed");
4871
4873
  return Promise.all([
4872
4874
  load("bed_head", key, transform),
4873
- load("bed_foot", key, new import_three22.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4875
+ load("bed_foot", key, new import_three24.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4874
4876
  ]);
4875
4877
  }
4876
4878
  case "minecraft:head":
@@ -4895,7 +4897,7 @@ var init_SpecialItems = __esm({
4895
4897
  return [await load(
4896
4898
  id,
4897
4899
  special.texture ? texture(special.texture, "") : void 0,
4898
- new import_three22.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three22.Matrix4().makeScale(-1, -1, 1)),
4900
+ new import_three24.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three24.Matrix4().makeScale(-1, -1, 1)),
4899
4901
  rotations
4900
4902
  )];
4901
4903
  }
@@ -5023,13 +5025,13 @@ var init_ItemTints = __esm({
5023
5025
  function isModelObject(obj) {
5024
5026
  return obj.isModelObject;
5025
5027
  }
5026
- var import_three23, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
5028
+ var import_three25, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
5027
5029
  var init_ModelObject = __esm({
5028
5030
  "src/model/scene/ModelObject.ts"() {
5029
5031
  init_SceneObject();
5030
5032
  init_Materials();
5031
5033
  init_UVMapper();
5032
- import_three23 = require("three");
5034
+ import_three25 = require("three");
5033
5035
  init_BufferGeometryUtils();
5034
5036
  init_model();
5035
5037
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -5061,8 +5063,8 @@ var init_ModelObject = __esm({
5061
5063
  const special = this.originalModel.special;
5062
5064
  if (special) {
5063
5065
  const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
5064
- const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three23.Matrix4();
5065
- transform.multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5066
+ const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three25.Matrix4();
5067
+ transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
5066
5068
  try {
5067
5069
  for (const part of parts) {
5068
5070
  const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
@@ -5125,7 +5127,7 @@ var init_ModelObject = __esm({
5125
5127
  elGeo.clearGroups();
5126
5128
  }
5127
5129
  if (this.options.uvLockRotation) {
5128
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three23.Euler(...this.options.uvLockRotation));
5130
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three25.Euler(...this.options.uvLockRotation));
5129
5131
  }
5130
5132
  if (this.options.tints) {
5131
5133
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -5134,19 +5136,19 @@ var init_ModelObject = __esm({
5134
5136
  if (tintIndex === void 0 || tintIndex < 0) continue;
5135
5137
  const tint = this.options.tints[tintIndex];
5136
5138
  if (tint === void 0) continue;
5137
- const color = new import_three23.Color(tint);
5139
+ const color = new import_three25.Color(tint);
5138
5140
  for (let vertex = 0; vertex < 4; vertex++) {
5139
5141
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5140
5142
  }
5141
5143
  }
5142
- elGeo.setAttribute("color", new import_three23.BufferAttribute(colors, 3));
5144
+ elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
5143
5145
  }
5144
- 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));
5145
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5146
+ elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
5147
+ elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5146
5148
  if (el.rotation) {
5147
5149
  applyElementRotation(el.rotation, elGeo);
5148
5150
  }
5149
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5151
+ elGeo.applyMatrix4(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
5150
5152
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
5151
5153
  if (this.options.mergeMeshes) {
5152
5154
  allGeos.push(elGeo);
@@ -5168,7 +5170,7 @@ var init_ModelObject = __esm({
5168
5170
  if (allGeos.length > 0) {
5169
5171
  combinedGeo = mergeBufferGeometries(allGeos);
5170
5172
  } else {
5171
- combinedGeo = new import_three23.BoxGeometry(16, 16, 16);
5173
+ combinedGeo = new import_three25.BoxGeometry(16, 16, 16);
5172
5174
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
5173
5175
  }
5174
5176
  combinedGeo.computeBoundingBox();
@@ -5280,7 +5282,7 @@ function ownHeight(sample) {
5280
5282
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
5281
5283
  }
5282
5284
  function createFluidGeometry(kind, sample) {
5283
- const geometry = new import_three28.BufferGeometry();
5285
+ const geometry = new import_three30.BufferGeometry();
5284
5286
  const positions = [], normals = [], uvs = [], indices = [];
5285
5287
  const self = sample(0, 0, 0);
5286
5288
  const height = (x, z) => {
@@ -5379,16 +5381,16 @@ function createFluidGeometry(kind, sample) {
5379
5381
  1
5380
5382
  );
5381
5383
  }
5382
- geometry.setAttribute("position", new import_three28.Float32BufferAttribute(positions, 3));
5383
- geometry.setAttribute("normal", new import_three28.Float32BufferAttribute(normals, 3));
5384
- geometry.setAttribute("uv", new import_three28.Float32BufferAttribute(uvs, 2));
5384
+ geometry.setAttribute("position", new import_three30.Float32BufferAttribute(positions, 3));
5385
+ geometry.setAttribute("normal", new import_three30.Float32BufferAttribute(normals, 3));
5386
+ geometry.setAttribute("uv", new import_three30.Float32BufferAttribute(uvs, 2));
5385
5387
  geometry.setIndex(indices);
5386
5388
  return geometry;
5387
5389
  }
5388
- var import_three28, fluidRules, HORIZONTAL, EPSILON;
5390
+ var import_three30, fluidRules, HORIZONTAL, EPSILON;
5389
5391
  var init_FluidGeometry = __esm({
5390
5392
  "src/model/fluid/FluidGeometry.ts"() {
5391
- import_three28 = require("three");
5393
+ import_three30 = require("three");
5392
5394
  init_fluidBlocks();
5393
5395
  fluidRules = fluidBlocks_default;
5394
5396
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -5417,10 +5419,10 @@ function sampleFluid(kind, sample) {
5417
5419
  }
5418
5420
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
5419
5421
  }
5420
- var import_three29, FluidModelObject;
5422
+ var import_three31, FluidModelObject;
5421
5423
  var init_FluidModelObject = __esm({
5422
5424
  "src/model/fluid/FluidModelObject.ts"() {
5423
- import_three29 = require("three");
5425
+ import_three31 = require("three");
5424
5426
  init_AssetKey();
5425
5427
  init_Materials();
5426
5428
  init_ModelObject();
@@ -5453,10 +5455,10 @@ var init_FluidModelObject = __esm({
5453
5455
  }
5454
5456
  }
5455
5457
  geometry.clearGroups();
5456
- const color = new import_three29.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5458
+ const color = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5457
5459
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5458
5460
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5459
- geometry.setAttribute("color", new import_three29.BufferAttribute(colors, 3));
5461
+ geometry.setAttribute("color", new import_three31.BufferAttribute(colors, 3));
5460
5462
  geometry.computeBoundingBox();
5461
5463
  geometry.computeBoundingSphere();
5462
5464
  if (this.options.instanceMeshes) {
@@ -5470,7 +5472,7 @@ var init_FluidModelObject = __esm({
5470
5472
  super.applyTextures();
5471
5473
  this.iterateAllMeshes((mesh) => {
5472
5474
  const material = mesh.material;
5473
- material.side = import_three29.DoubleSide;
5475
+ material.side = import_three31.DoubleSide;
5474
5476
  material.forceSinglePass = true;
5475
5477
  material.depthWrite = !material.transparent;
5476
5478
  });
@@ -5532,6 +5534,7 @@ __export(index_browser_exports, {
5532
5534
  EntityObject: () => EntityObject,
5533
5535
  Env: () => Env,
5534
5536
  FluidModelObject: () => FluidModelObject,
5537
+ Fonts: () => Fonts,
5535
5538
  Geometries: () => Geometries,
5536
5539
  GuiHelper: () => GuiHelper,
5537
5540
  GuiLight: () => GuiLight,
@@ -5603,6 +5606,8 @@ __export(index_browser_exports, {
5603
5606
  computeTangents: () => computeTangents,
5604
5607
  createCanvas: () => createCanvas,
5605
5608
  createFluidGeometry: () => createFluidGeometry,
5609
+ createGuiTextGeometry: () => createGuiTextGeometry,
5610
+ createGuiTextureGeometry: () => createGuiTextureGeometry,
5606
5611
  createImage: () => createImage,
5607
5612
  entityAnimationTime: () => entityAnimationTime,
5608
5613
  estimateBytesUsed: () => estimateBytesUsed,
@@ -5631,6 +5636,7 @@ __export(index_browser_exports, {
5631
5636
  isTransformable: () => isTransformable,
5632
5637
  isTripleArray: () => isTripleArray,
5633
5638
  isVector3: () => isVector3,
5639
+ layoutGuiText: () => layoutGuiText,
5634
5640
  md5: () => md5,
5635
5641
  mergeBufferAttributes: () => mergeBufferAttributes,
5636
5642
  mergeBufferGeometries: () => mergeBufferGeometries,
@@ -5902,6 +5908,101 @@ var BlockEntities = class {
5902
5908
  // src/assets/index.ts
5903
5909
  init_BlockStates();
5904
5910
  init_Entities();
5911
+
5912
+ // src/assets/Fonts.ts
5913
+ init_AssetKey();
5914
+ init_AssetLoader();
5915
+ init_AssetParsers();
5916
+ init_ModelTextures();
5917
+ init_Caching();
5918
+ var Fonts = class {
5919
+ static async get(key = "minecraft:default") {
5920
+ const fontKey = typeof key === "string" ? AssetKey.parse("font", key) : key;
5921
+ return await Caching.fontCache.get(fontKey.serialize(), () => this.load(fontKey, []));
5922
+ }
5923
+ static relatedKey(assetType, id, origin) {
5924
+ const key = AssetKey.parse(assetType, id);
5925
+ key.root = origin.root;
5926
+ return key;
5927
+ }
5928
+ static async load(key, parents) {
5929
+ const serialized = key.serialize();
5930
+ if (parents.includes(serialized)) throw new Error(`Cyclic font reference: ${key.toNamespacedString()}`);
5931
+ const stack = await AssetLoader.getAll(key, "json" /* JSON */);
5932
+ if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
5933
+ const glyphs = /* @__PURE__ */ new Map();
5934
+ for (const asset of stack) {
5935
+ for (const provider of asset.providers) {
5936
+ if (provider.filter?.uniform || provider.filter?.jp) continue;
5937
+ let provided;
5938
+ switch (provider.type) {
5939
+ case "bitmap":
5940
+ case "minecraft:bitmap":
5941
+ provided = await this.bitmap(provider, key);
5942
+ break;
5943
+ case "space":
5944
+ case "minecraft:space":
5945
+ provided = new Map(Object.entries(provider.advances).map(([character, advance]) => [
5946
+ character,
5947
+ { x: 0, y: 0, width: 0, height: 0, scale: 1, ascent: 0, advance }
5948
+ ]));
5949
+ break;
5950
+ case "reference":
5951
+ case "minecraft:reference":
5952
+ provided = (await this.load(this.relatedKey("font", provider.id, key), [...parents, serialized])).glyphs;
5953
+ break;
5954
+ default:
5955
+ continue;
5956
+ }
5957
+ for (const [character, glyph] of provided) {
5958
+ if (character !== "\0" && !glyphs.has(character)) glyphs.set(character, glyph);
5959
+ }
5960
+ }
5961
+ }
5962
+ return { glyphs };
5963
+ }
5964
+ static async bitmap(provider, fontKey) {
5965
+ const rows = provider.chars.map((row) => [...row]);
5966
+ const columns = rows[0]?.length;
5967
+ if (!columns || rows.some((row) => row.length !== columns)) {
5968
+ throw new Error(`Invalid character grid in font ${fontKey.toNamespacedString()}`);
5969
+ }
5970
+ const key = this.relatedKey("textures", provider.file, fontKey);
5971
+ const image = await ModelTextures.get(key);
5972
+ if (!image) throw new Error(`Could not load font texture ${key.toNamespacedString()}`);
5973
+ const width = Math.floor(image.width / columns), height = Math.floor(image.height / rows.length);
5974
+ if (!width || !height) throw new Error(`Font texture ${key.toNamespacedString()} is smaller than its character grid`);
5975
+ const scale = (provider.height ?? 8) / height;
5976
+ const pixels = image.data.getImageData(0, 0, image.width, image.height).data;
5977
+ const glyphs = /* @__PURE__ */ new Map();
5978
+ rows.forEach((row, rowIndex) => row.forEach((character, columnIndex) => {
5979
+ if (character === "\0") return;
5980
+ const x = columnIndex * width, y = rowIndex * height;
5981
+ let occupiedWidth = 0;
5982
+ for (let column = width - 1; column >= 0 && !occupiedWidth; column--) {
5983
+ for (let row2 = 0; row2 < height; row2++) {
5984
+ if (pixels[((y + row2) * image.width + x + column) * 4 + 3] !== 0) {
5985
+ occupiedWidth = column + 1;
5986
+ break;
5987
+ }
5988
+ }
5989
+ }
5990
+ glyphs.set(character, {
5991
+ image: image.data.canvas,
5992
+ x,
5993
+ y,
5994
+ width,
5995
+ height,
5996
+ scale,
5997
+ ascent: provider.ascent,
5998
+ advance: Math.floor(occupiedWidth * scale + 0.5) + 1
5999
+ });
6000
+ }));
6001
+ return glyphs;
6002
+ }
6003
+ };
6004
+
6005
+ // src/assets/index.ts
5905
6006
  init_ModelTextures();
5906
6007
  init_Models();
5907
6008
  init_source();
@@ -8859,7 +8960,137 @@ function copyDataTexture(source) {
8859
8960
 
8860
8961
  // src/gui/GuiHelper.ts
8861
8962
  init_AssetKey();
8963
+
8964
+ // src/gui/GuiText.ts
8965
+ var import_three20 = require("three");
8966
+ async function layoutGuiText(text, options = {}) {
8967
+ const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
8968
+ if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
8969
+ throw new Error("Text wrap width and line height must be positive");
8970
+ }
8971
+ const font = await Fonts.get(options.font);
8972
+ const runs = typeof text === "string" ? [{ text }] : text;
8973
+ const glyphs = [], lineWidths = [];
8974
+ let line = [], width = 0;
8975
+ let trailingNewline = false;
8976
+ const finishLine = (entries) => {
8977
+ let x = 0;
8978
+ for (const entry of entries) {
8979
+ glyphs.push({ ...entry, x, y: lineWidths.length * lineHeight });
8980
+ x += entry.advance;
8981
+ }
8982
+ lineWidths.push(x);
8983
+ };
8984
+ for (const run of runs) {
8985
+ const style = {
8986
+ color: run.color ?? options.color ?? 16777215,
8987
+ bold: run.bold ?? options.bold ?? false,
8988
+ italic: run.italic ?? options.italic ?? false
8989
+ };
8990
+ for (const character of run.text.replace(/\r\n?/g, "\n")) {
8991
+ trailingNewline = character === "\n";
8992
+ if (character === "\n") {
8993
+ finishLine(line);
8994
+ line = [];
8995
+ width = 0;
8996
+ continue;
8997
+ }
8998
+ const glyph = font.glyphs.get(character);
8999
+ const advance = (glyph?.advance ?? 6) + (style.bold ? 1 : 0);
9000
+ line.push({ character, glyph, advance, style, x: 0, y: 0 });
9001
+ width += advance;
9002
+ while (width > maxWidth && line.length > 1) {
9003
+ let space = -1;
9004
+ for (let i = 0; i < line.length; i++) if (line[i].character === " ") space = i;
9005
+ const split = space >= 0 ? space : line.length - 1;
9006
+ if (split > 0) finishLine(line.slice(0, split));
9007
+ line = line.slice(split + (space >= 0 ? 1 : 0));
9008
+ width = line.reduce((sum, entry) => sum + entry.advance, 0);
9009
+ }
9010
+ }
9011
+ }
9012
+ if (line.length || !lineWidths.length || trailingNewline) finishLine(line);
9013
+ return { glyphs, lineWidths, width: Math.max(0, ...lineWidths), height: lineWidths.length * lineHeight };
9014
+ }
9015
+ function createGuiTextGeometry(layout, shadow = true) {
9016
+ const batches = [];
9017
+ for (const isShadow of shadow ? [true, false] : [false]) {
9018
+ let batch;
9019
+ for (const entry of layout.glyphs) {
9020
+ const { glyph, style } = entry;
9021
+ if (glyph && !glyph.image) continue;
9022
+ if (!batch || batch.image !== glyph?.image) {
9023
+ batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
9024
+ batches.push(batch);
9025
+ }
9026
+ const color = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
9027
+ const offset = isShadow ? 1 : 0;
9028
+ const top = glyph ? 7 - glyph.ascent : 0;
9029
+ const height = glyph ? glyph.height * glyph.scale : 8;
9030
+ const width = glyph ? glyph.width * glyph.scale : 5;
9031
+ const shear = (y) => style.italic ? 1 - 0.25 * y : 0;
9032
+ const quad = (left, upper, right, lower, boldOffset) => {
9033
+ const base = batch.positions.length / 3;
9034
+ const x = entry.x + offset + boldOffset, y = entry.y + offset;
9035
+ batch.positions.push(
9036
+ x + left + shear(upper),
9037
+ -y - upper,
9038
+ 0,
9039
+ x + right + shear(upper),
9040
+ -y - upper,
9041
+ 0,
9042
+ x + left + shear(lower),
9043
+ -y - lower,
9044
+ 0,
9045
+ x + right + shear(lower),
9046
+ -y - lower,
9047
+ 0
9048
+ );
9049
+ const u0 = glyph ? glyph.x / glyph.image.width : 0;
9050
+ const u1 = glyph ? (glyph.x + glyph.width) / glyph.image.width : 1;
9051
+ const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
9052
+ const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
9053
+ batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
9054
+ for (let i = 0; i < 4; i++) batch.colors.push(color.r, color.g, color.b);
9055
+ batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
9056
+ };
9057
+ for (const boldOffset of style.bold ? [0, 1] : [0]) {
9058
+ if (glyph) quad(0, top, width, top + height, boldOffset);
9059
+ else {
9060
+ quad(0, 0, 5, 1, boldOffset);
9061
+ quad(0, 7, 5, 8, boldOffset);
9062
+ quad(0, 1, 1, 7, boldOffset);
9063
+ quad(4, 1, 5, 7, boldOffset);
9064
+ }
9065
+ }
9066
+ }
9067
+ }
9068
+ return batches.map(({ image, positions, uvs, colors, indices }) => ({ image, geometry: new import_three20.BufferGeometry().setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3)).setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2)).setAttribute("color", new import_three20.Float32BufferAttribute(colors, 3)).setIndex(indices) }));
9069
+ }
9070
+
9071
+ // src/gui/GuiHelper.ts
8862
9072
  var GuiHelper = class {
9073
+ /** Sizes a tooltip around supplied text; the first entry is its title. */
9074
+ static async tooltip(lines, options = {}) {
9075
+ if (!lines.length) return [];
9076
+ const { position = [0, 0], titleGap = 2, lineHeight = 10, shadow = true, ...style } = options;
9077
+ const textOptions = { ...style, lineHeight, shadow };
9078
+ const layouts = await Promise.all(lines.map((line) => layoutGuiText(line, textOptions)));
9079
+ const width = Math.max(...layouts.map((layout) => layout.width));
9080
+ const height = layouts.reduce((sum, layout) => sum + layout.height, 0) - 2 + (lines.length > 1 ? titleGap : 0);
9081
+ const layers = ["background", "frame"].map((part) => ({
9082
+ name: `tooltip-${part}`,
9083
+ texture: `minecraft:gui/sprites/tooltip/${part}`,
9084
+ position: [position[0] - 12, position[1] - 12],
9085
+ size: [width + 24, height + 24]
9086
+ }));
9087
+ let y = position[1];
9088
+ lines.forEach((text, index) => {
9089
+ layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
9090
+ y += layouts[index].height + (index === 0 ? titleGap : 0);
9091
+ });
9092
+ return layers;
9093
+ }
8863
9094
  static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
8864
9095
  const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
8865
9096
  return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
@@ -8923,8 +9154,87 @@ var GuiHelper = class {
8923
9154
  }
8924
9155
  };
8925
9156
 
9157
+ // src/gui/GuiTextureGeometry.ts
9158
+ var import_three21 = require("three");
9159
+ function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
9160
+ if (crop || !scaling || scaling.type === "stretch") {
9161
+ const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
9162
+ const geometry = new import_three21.PlaneGeometry(width, height);
9163
+ const uv = geometry.getAttribute("uv");
9164
+ for (let i = 0; i < uv.count; i++) {
9165
+ uv.setXY(
9166
+ i,
9167
+ (x + uv.getX(i) * w) / imageWidth,
9168
+ 1 - (y + (1 - uv.getY(i)) * h) / imageHeight
9169
+ );
9170
+ }
9171
+ return geometry;
9172
+ }
9173
+ const sw = scaling.width, sh = scaling.height;
9174
+ if (![sw, sh].every((value) => Number.isInteger(value) && value > 0)) {
9175
+ throw new Error("GUI sprite dimensions must be positive integers");
9176
+ }
9177
+ if (![width, height].every((value) => Number.isFinite(value) && value >= 0)) {
9178
+ throw new Error("GUI output dimensions must be finite and nonnegative");
9179
+ }
9180
+ const positions = [], uvs = [], normals = [], indices = [];
9181
+ function quad(x, y, w, h, u, v, uw, vh) {
9182
+ if (w <= 0 || h <= 0) return;
9183
+ const index = positions.length / 3;
9184
+ const left = x - width / 2, top = height / 2 - y;
9185
+ positions.push(left, top, 0, left + w, top, 0, left, top - h, 0, left + w, top - h, 0);
9186
+ uvs.push(
9187
+ u / sw,
9188
+ 1 - v / sh,
9189
+ (u + uw) / sw,
9190
+ 1 - v / sh,
9191
+ u / sw,
9192
+ 1 - (v + vh) / sh,
9193
+ (u + uw) / sw,
9194
+ 1 - (v + vh) / sh
9195
+ );
9196
+ normals.push(0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1);
9197
+ indices.push(index, index + 2, index + 1, index + 2, index + 3, index + 1);
9198
+ }
9199
+ function tile(x, y, w, h, u, v, tw, th) {
9200
+ for (let dy = 0; dy < h; dy += th) {
9201
+ for (let dx = 0; dx < w; dx += tw) {
9202
+ const cw = Math.min(tw, w - dx), ch = Math.min(th, h - dy);
9203
+ quad(x + dx, y + dy, cw, ch, u, v, cw, ch);
9204
+ }
9205
+ }
9206
+ }
9207
+ if (scaling.type === "tile") {
9208
+ tile(0, 0, width, height, 0, 0, sw, sh);
9209
+ } else {
9210
+ let segments = function(size, sourceSize, start, end) {
9211
+ if (size === sourceSize) return [[0, size, 0, sourceSize]];
9212
+ start = Math.min(start, Math.floor(size / 2));
9213
+ end = Math.min(end, Math.floor(size / 2));
9214
+ return [
9215
+ [0, start, 0, start],
9216
+ [start, size - start - end, start, sourceSize - start - end],
9217
+ [size - end, end, sourceSize - end, end]
9218
+ ];
9219
+ };
9220
+ const border = typeof scaling.border === "number" ? { left: scaling.border, top: scaling.border, right: scaling.border, bottom: scaling.border } : scaling.border;
9221
+ 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) {
9222
+ throw new Error("GUI nine-slice borders must be nonnegative integers with a nonempty center");
9223
+ }
9224
+ const columns = segments(width, sw, border.left, border.right);
9225
+ const rows = segments(height, sh, border.top, border.bottom);
9226
+ for (const [y, h, v, vh] of rows) {
9227
+ for (const [x, w, u, uw] of columns) {
9228
+ if (w <= 0 || h <= 0) continue;
9229
+ (scaling.stretch_inner ? quad : tile)(x, y, w, h, u, v, uw, vh);
9230
+ }
9231
+ }
9232
+ }
9233
+ return new import_three21.BufferGeometry().setAttribute("position", new import_three21.Float32BufferAttribute(positions, 3)).setAttribute("normal", new import_three21.Float32BufferAttribute(normals, 3)).setAttribute("uv", new import_three21.Float32BufferAttribute(uvs, 2)).setIndex(indices);
9234
+ }
9235
+
8926
9236
  // src/gui/scene/GuiObject.ts
8927
- var import_three24 = require("three");
9237
+ var import_three26 = require("three");
8928
9238
  init_AssetKey();
8929
9239
  init_ModelTextures();
8930
9240
  init_Models();
@@ -8940,9 +9250,10 @@ var GuiObject = class extends SceneObject {
8940
9250
  this.textureLayers = textureLayers;
8941
9251
  this.isGuiObject = true;
8942
9252
  /** Local bounds in GUI pixels, with y growing down from the origin. */
8943
- this.bounds = new import_three24.Box2();
9253
+ this.bounds = new import_three26.Box2();
8944
9254
  this.geometries = /* @__PURE__ */ new Set();
8945
9255
  this.ownedMaterials = /* @__PURE__ */ new Set();
9256
+ this.textMaterials = /* @__PURE__ */ new Map();
8946
9257
  this.initialized = false;
8947
9258
  }
8948
9259
  async init() {
@@ -8951,6 +9262,43 @@ var GuiObject = class extends SceneObject {
8951
9262
  let depth = 0;
8952
9263
  for (const [index, layer] of this.textureLayers.entries()) {
8953
9264
  const [x, y] = layer.position ?? [0, 0];
9265
+ if ("text" in layer) {
9266
+ const layout = await layoutGuiText(layer.text, layer);
9267
+ const group = new import_three26.Group();
9268
+ group.name = `group:${layer.name ?? index}`;
9269
+ group.position.set(x, -y, depth);
9270
+ const [width2, height2] = layer.size ?? [layout.width, layout.height];
9271
+ group.scale.set(layout.width ? width2 / layout.width : 1, height2 / layout.height, 1);
9272
+ this.add(group);
9273
+ const parts = createGuiTextGeometry(layout, layer.shadow);
9274
+ const bounds = new import_three26.Box3();
9275
+ for (const [partIndex, { image: image2, geometry: geometry2 }] of parts.entries()) {
9276
+ this.geometries.add(geometry2);
9277
+ geometry2.computeBoundingBox();
9278
+ bounds.union(geometry2.boundingBox);
9279
+ let material2 = this.textMaterials.get(image2);
9280
+ if (!material2) {
9281
+ material2 = image2 ? Materials.createGuiCanvasMaterial(image2) : new import_three26.MeshBasicMaterial({ transparent: true, depthWrite: false, side: import_three26.DoubleSide, toneMapped: false });
9282
+ material2.vertexColors = true;
9283
+ this.textMaterials.set(image2, material2);
9284
+ this.ownedMaterials.add(material2);
9285
+ }
9286
+ const mesh2 = new import_three26.Mesh(geometry2, material2);
9287
+ mesh2.name = `mesh:${layer.name ?? index}:${partIndex}`;
9288
+ mesh2.renderOrder = index + partIndex / (parts.length + 1) * 0.5;
9289
+ group.add(mesh2);
9290
+ }
9291
+ group.updateMatrix();
9292
+ bounds.applyMatrix4(group.matrix);
9293
+ this.bounds.expandByPoint(new import_three26.Vector2(x, y));
9294
+ this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
9295
+ if (!bounds.isEmpty()) {
9296
+ this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
9297
+ this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
9298
+ }
9299
+ depth += 0.01;
9300
+ continue;
9301
+ }
8954
9302
  if ("item" in layer) {
8955
9303
  const [width2, height2] = layer.size ?? [16, 16];
8956
9304
  const item = await this.createItem(layer, index);
@@ -8958,41 +9306,33 @@ var GuiObject = class extends SceneObject {
8958
9306
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
8959
9307
  item.updateWorldMatrix(true, true);
8960
9308
  const inverse = this.matrixWorld.clone().invert();
8961
- const bounds = new import_three24.Box3();
9309
+ const bounds = new import_three26.Box3();
8962
9310
  item.iterateAllMeshes((mesh2) => {
8963
9311
  mesh2.geometry.computeBoundingBox();
8964
- bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three24.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
9312
+ bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three26.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
8965
9313
  });
8966
9314
  item.position.z = depth - bounds.min.z;
8967
9315
  depth += bounds.max.z - bounds.min.z + 0.01;
8968
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8969
- this.bounds.expandByPoint(new import_three24.Vector2(x + width2, y + height2));
8970
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.min.x, -bounds.max.y));
8971
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.max.x, -bounds.min.y));
9316
+ this.bounds.expandByPoint(new import_three26.Vector2(x, y));
9317
+ this.bounds.expandByPoint(new import_three26.Vector2(x + width2, y + height2));
9318
+ this.bounds.expandByPoint(new import_three26.Vector2(bounds.min.x, -bounds.max.y));
9319
+ this.bounds.expandByPoint(new import_three26.Vector2(bounds.max.x, -bounds.min.y));
8972
9320
  continue;
8973
9321
  }
8974
9322
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
8975
9323
  const material = await this.loadMaterial(key);
8976
9324
  const image = material.map.image;
8977
- const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
8978
- const [width, height] = layer.size ?? [cropWidth, cropHeight];
8979
- const geometry = new import_three24.PlaneGeometry(width, height);
9325
+ const scaling = layer.crop ? void 0 : (await ModelTextures.getMeta(key))?.gui?.scaling;
9326
+ const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
9327
+ const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
8980
9328
  this.geometries.add(geometry);
8981
- const uv = geometry.getAttribute("uv");
8982
- for (let i = 0; i < uv.count; i++) {
8983
- uv.setXY(
8984
- i,
8985
- (cropX + uv.getX(i) * cropWidth) / image.width,
8986
- 1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
8987
- );
8988
- }
8989
- const mesh = new import_three24.Mesh(geometry, material);
9329
+ const mesh = new import_three26.Mesh(geometry, material);
8990
9330
  mesh.name = `mesh:${layer.name ?? index}`;
8991
9331
  mesh.position.set(x + width / 2, -y - height / 2, depth);
8992
9332
  mesh.renderOrder = index;
8993
9333
  this.add(mesh);
8994
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8995
- this.bounds.expandByPoint(new import_three24.Vector2(x + width, y + height));
9334
+ this.bounds.expandByPoint(new import_three26.Vector2(x, y));
9335
+ this.bounds.expandByPoint(new import_three26.Vector2(x + width, y + height));
8996
9336
  depth += 0.01;
8997
9337
  }
8998
9338
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -9050,10 +9390,11 @@ var GuiObject = class extends SceneObject {
9050
9390
  for (const geometry of this.geometries) geometry.dispose();
9051
9391
  this.geometries.clear();
9052
9392
  for (const material of this.ownedMaterials) {
9053
- material.map.dispose();
9393
+ material.map?.dispose();
9054
9394
  material.dispose();
9055
9395
  }
9056
9396
  this.ownedMaterials.clear();
9397
+ this.textMaterials.clear();
9057
9398
  this.bounds.makeEmpty();
9058
9399
  this.initialized = false;
9059
9400
  super.disposeAndRemoveAllChildren();
@@ -9067,7 +9408,7 @@ function isGuiObject(obj) {
9067
9408
  init_image();
9068
9409
 
9069
9410
  // src/inspector/SceneInspector.ts
9070
- var import_three25 = require("three");
9411
+ var import_three27 = require("three");
9071
9412
  init_SceneObject();
9072
9413
  init_util();
9073
9414
  init_log();
@@ -9077,11 +9418,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
9077
9418
  var SceneInspector = class {
9078
9419
  constructor(renderer) {
9079
9420
  this.renderer = renderer;
9080
- this.mouse = new import_three25.Vector2();
9421
+ this.mouse = new import_three27.Vector2();
9081
9422
  this.listeners = new AbortController();
9082
9423
  this.objectInfoContainer = document.createElement("div");
9083
9424
  this.objectControlsContainer = document.createElement("div");
9084
- this.raycaster = new import_three25.Raycaster();
9425
+ this.raycaster = new import_three27.Raycaster();
9085
9426
  this.init();
9086
9427
  }
9087
9428
  init() {
@@ -9484,7 +9825,7 @@ init_ModelMerger();
9484
9825
  init_SpecialItems();
9485
9826
 
9486
9827
  // src/model/block/BlockStateResolver.ts
9487
- var import_three27 = require("three");
9828
+ var import_three29 = require("three");
9488
9829
  init_BlockStates();
9489
9830
  init_MineRenderError();
9490
9831
  init_util();
@@ -9562,7 +9903,7 @@ var BlockStateResolver = class {
9562
9903
  return variants[variants.length - 1];
9563
9904
  }
9564
9905
  static rotation(variant) {
9565
- const rotation = new import_three27.Euler();
9906
+ const rotation = new import_three29.Euler();
9566
9907
  if (typeof variant.x !== "undefined") {
9567
9908
  rotation.x = toRadians(clampRotationDegrees(variant.x));
9568
9909
  }
@@ -9654,7 +9995,7 @@ init_SceneObject();
9654
9995
  init_ModelObject();
9655
9996
  init_Models();
9656
9997
  var import_ts_deepmerge6 = __toESM(require_dist());
9657
- var import_three30 = require("three");
9998
+ var import_three32 = require("three");
9658
9999
  init_MineRenderError();
9659
10000
  init_InstanceReference();
9660
10001
  init_AssetKey();
@@ -9676,7 +10017,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9676
10017
  this._models = [];
9677
10018
  this._cullMask = 0;
9678
10019
  this._entities = [];
9679
- this._entityPlacement = new import_three30.Matrix4();
10020
+ this._entityPlacement = new import_three32.Matrix4();
9680
10021
  this._entityGeneration = 0;
9681
10022
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
9682
10023
  }
@@ -9772,7 +10113,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9772
10113
  return true;
9773
10114
  }
9774
10115
  placeEntities() {
9775
- const matrix = new import_three30.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
10116
+ const matrix = new import_three32.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9776
10117
  for (const entity of this._entities) {
9777
10118
  matrix.decompose(entity.position, entity.quaternion, entity.scale);
9778
10119
  }
@@ -9794,12 +10135,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
9794
10135
  getModelCullMask(model, worldMask) {
9795
10136
  const object = isInstanceReference(model) ? model.instanceable : model;
9796
10137
  if (object.options.displayPosition) return 0;
9797
- const position = new import_three30.Vector3();
9798
- const rotation = new import_three30.Quaternion();
9799
- const scale = new import_three30.Vector3();
10138
+ const position = new import_three32.Vector3();
10139
+ const rotation = new import_three32.Quaternion();
10140
+ const scale = new import_three32.Vector3();
9800
10141
  this.getModelMatrix(model).decompose(position, rotation, scale);
9801
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three30.Vector3(1, 1, 1)) > 1e-10) return 0;
9802
- return ModelCulling.toLocalMask(worldMask, new import_three30.Euler().setFromQuaternion(rotation));
10142
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three32.Vector3(1, 1, 1)) > 1e-10) return 0;
10143
+ return ModelCulling.toLocalMask(worldMask, new import_three32.Euler().setFromQuaternion(rotation));
9803
10144
  }
9804
10145
  async setCullMask(worldMask) {
9805
10146
  worldMask &= 63;
@@ -9865,7 +10206,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9865
10206
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
9866
10207
  );
9867
10208
  const previous = this._fluidModel;
9868
- const matrix = previous ? this.getModelMatrix(previous) : new import_three30.Matrix4().makeTranslation(...this.position.toArray());
10209
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three32.Matrix4().makeTranslation(...this.position.toArray());
9869
10210
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
9870
10211
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
9871
10212
  this._models = this._models.filter((model) => model !== previous);
@@ -10007,7 +10348,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
10007
10348
  setPositionRotationScaleAt(index, position, rotation, scale) {
10008
10349
  super.setPositionRotationScaleAt(index, position, rotation, scale);
10009
10350
  }
10010
- getMatrixAt(index, matrix = new import_three30.Matrix4()) {
10351
+ getMatrixAt(index, matrix = new import_three32.Matrix4()) {
10011
10352
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
10012
10353
  const child = this._models[0];
10013
10354
  if (child && isModelObject(child)) {
@@ -11883,7 +12224,7 @@ init_ModelObject();
11883
12224
  init_nbt();
11884
12225
 
11885
12226
  // src/renderer/MineRenderScene.ts
11886
- var import_three32 = require("three");
12227
+ var import_three34 = require("three");
11887
12228
  init_SceneObject();
11888
12229
  var import_ts_deepmerge8 = __toESM(require_dist());
11889
12230
  init_ModelObject();
@@ -12616,7 +12957,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
12616
12957
  init_util();
12617
12958
 
12618
12959
  // src/skin/SkinTextures.ts
12619
- var import_three31 = require("three");
12960
+ var import_three33 = require("three");
12620
12961
  init_Caching();
12621
12962
  init_CacheKey();
12622
12963
  init_MineRenderError();
@@ -12700,11 +13041,11 @@ var SkinTextures = class {
12700
13041
  });
12701
13042
  }
12702
13043
  static createMaterial(pixels, width, height, transparent = true) {
12703
- const texture = Textures.initTextureProps(new import_three31.DataTexture(pixels, width, height));
12704
- texture.colorSpace = import_three31.SRGBColorSpace;
13044
+ const texture = Textures.initTextureProps(new import_three33.DataTexture(pixels, width, height));
13045
+ texture.colorSpace = import_three33.SRGBColorSpace;
12705
13046
  texture.flipY = true;
12706
13047
  texture.needsUpdate = true;
12707
- return new import_three31.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three31.DoubleSide : import_three31.FrontSide, alphaTest: transparent ? 0.1 : 0 });
13048
+ return new import_three33.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three33.DoubleSide : import_three33.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12708
13049
  }
12709
13050
  static isSlim(image, scale) {
12710
13051
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -12934,7 +13275,7 @@ var SkinObject = class extends SceneObject {
12934
13275
  // src/renderer/MineRenderScene.ts
12935
13276
  init_EntityObject();
12936
13277
  init_ItemTints();
12937
- var _MineRenderScene = class _MineRenderScene extends import_three32.Scene {
13278
+ var _MineRenderScene = class _MineRenderScene extends import_three34.Scene {
12938
13279
  constructor(options) {
12939
13280
  super();
12940
13281
  this.isMineRenderScene = true;
@@ -13063,7 +13404,7 @@ function isMineRenderScene(obj) {
13063
13404
  }
13064
13405
 
13065
13406
  // src/renderer/Renderer.ts
13066
- var import_three34 = require("three");
13407
+ var import_three36 = require("three");
13067
13408
  var import_ts_deepmerge9 = __toESM(require_dist());
13068
13409
  var import_stats = __toESM(require("stats.js"));
13069
13410
  var import_postprocessing = require("postprocessing");
@@ -13072,11 +13413,11 @@ init_Model();
13072
13413
  init_three();
13073
13414
 
13074
13415
  // src/three/OrbitControls.js
13075
- var import_three33 = require("three");
13416
+ var import_three35 = require("three");
13076
13417
  var _changeEvent = { type: "change" };
13077
13418
  var _startEvent = { type: "start" };
13078
13419
  var _endEvent = { type: "end" };
13079
- var OrbitControls = class extends import_three33.EventDispatcher {
13420
+ var OrbitControls = class extends import_three35.EventDispatcher {
13080
13421
  constructor(object, domElement) {
13081
13422
  super();
13082
13423
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -13085,7 +13426,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13085
13426
  this.domElement = domElement;
13086
13427
  this.domElement.style.touchAction = "none";
13087
13428
  this.enabled = true;
13088
- this.target = new import_three33.Vector3();
13429
+ this.target = new import_three35.Vector3();
13089
13430
  this.minDistance = 0;
13090
13431
  this.maxDistance = Infinity;
13091
13432
  this.minZoom = 0;
@@ -13107,8 +13448,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13107
13448
  this.autoRotate = false;
13108
13449
  this.autoRotateSpeed = 2;
13109
13450
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
13110
- this.mouseButtons = { LEFT: import_three33.MOUSE.ROTATE, MIDDLE: import_three33.MOUSE.DOLLY, RIGHT: import_three33.MOUSE.PAN };
13111
- this.touches = { ONE: import_three33.TOUCH.ROTATE, TWO: import_three33.TOUCH.DOLLY_PAN };
13451
+ this.mouseButtons = { LEFT: import_three35.MOUSE.ROTATE, MIDDLE: import_three35.MOUSE.DOLLY, RIGHT: import_three35.MOUSE.PAN };
13452
+ this.touches = { ONE: import_three35.TOUCH.ROTATE, TWO: import_three35.TOUCH.DOLLY_PAN };
13112
13453
  this.target0 = this.target.clone();
13113
13454
  this.position0 = this.object.position.clone();
13114
13455
  this.zoom0 = this.object.zoom;
@@ -13137,11 +13478,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13137
13478
  state = STATE.NONE;
13138
13479
  };
13139
13480
  this.update = function() {
13140
- const offset = new import_three33.Vector3();
13141
- const quat = new import_three33.Quaternion().setFromUnitVectors(object.up, new import_three33.Vector3(0, 1, 0));
13481
+ const offset = new import_three35.Vector3();
13482
+ const quat = new import_three35.Quaternion().setFromUnitVectors(object.up, new import_three35.Vector3(0, 1, 0));
13142
13483
  const quatInverse = quat.clone().invert();
13143
- const lastPosition = new import_three33.Vector3();
13144
- const lastQuaternion = new import_three33.Quaternion();
13484
+ const lastPosition = new import_three35.Vector3();
13485
+ const lastQuaternion = new import_three35.Quaternion();
13145
13486
  const twoPI = 2 * Math.PI;
13146
13487
  return function update() {
13147
13488
  const position = scope.object.position;
@@ -13227,20 +13568,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13227
13568
  };
13228
13569
  let state = STATE.NONE;
13229
13570
  const EPS = 1e-6;
13230
- const spherical = new import_three33.Spherical();
13231
- const sphericalDelta = new import_three33.Spherical();
13571
+ const spherical = new import_three35.Spherical();
13572
+ const sphericalDelta = new import_three35.Spherical();
13232
13573
  let scale = 1;
13233
- const panOffset = new import_three33.Vector3();
13574
+ const panOffset = new import_three35.Vector3();
13234
13575
  let zoomChanged = false;
13235
- const rotateStart = new import_three33.Vector2();
13236
- const rotateEnd = new import_three33.Vector2();
13237
- const rotateDelta = new import_three33.Vector2();
13238
- const panStart = new import_three33.Vector2();
13239
- const panEnd = new import_three33.Vector2();
13240
- const panDelta = new import_three33.Vector2();
13241
- const dollyStart = new import_three33.Vector2();
13242
- const dollyEnd = new import_three33.Vector2();
13243
- const dollyDelta = new import_three33.Vector2();
13576
+ const rotateStart = new import_three35.Vector2();
13577
+ const rotateEnd = new import_three35.Vector2();
13578
+ const rotateDelta = new import_three35.Vector2();
13579
+ const panStart = new import_three35.Vector2();
13580
+ const panEnd = new import_three35.Vector2();
13581
+ const panDelta = new import_three35.Vector2();
13582
+ const dollyStart = new import_three35.Vector2();
13583
+ const dollyEnd = new import_three35.Vector2();
13584
+ const dollyDelta = new import_three35.Vector2();
13244
13585
  const pointers = [];
13245
13586
  const pointerPositions = {};
13246
13587
  function getAutoRotationAngle() {
@@ -13256,7 +13597,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13256
13597
  sphericalDelta.phi -= angle;
13257
13598
  }
13258
13599
  const panLeft = function() {
13259
- const v = new import_three33.Vector3();
13600
+ const v = new import_three35.Vector3();
13260
13601
  return function panLeft2(distance, objectMatrix) {
13261
13602
  v.setFromMatrixColumn(objectMatrix, 0);
13262
13603
  v.multiplyScalar(-distance);
@@ -13264,7 +13605,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13264
13605
  };
13265
13606
  }();
13266
13607
  const panUp = function() {
13267
- const v = new import_three33.Vector3();
13608
+ const v = new import_three35.Vector3();
13268
13609
  return function panUp2(distance, objectMatrix) {
13269
13610
  if (scope.screenSpacePanning === true) {
13270
13611
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -13277,7 +13618,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13277
13618
  };
13278
13619
  }();
13279
13620
  const pan = function() {
13280
- const offset = new import_three33.Vector3();
13621
+ const offset = new import_three35.Vector3();
13281
13622
  return function pan2(deltaX, deltaY) {
13282
13623
  const element = scope.domElement;
13283
13624
  if (scope.object.isPerspectiveCamera) {
@@ -13526,12 +13867,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13526
13867
  mouseAction = -1;
13527
13868
  }
13528
13869
  switch (mouseAction) {
13529
- case import_three33.MOUSE.DOLLY:
13870
+ case import_three35.MOUSE.DOLLY:
13530
13871
  if (scope.enableZoom === false) return;
13531
13872
  handleMouseDownDolly(event);
13532
13873
  state = STATE.DOLLY;
13533
13874
  break;
13534
- case import_three33.MOUSE.ROTATE:
13875
+ case import_three35.MOUSE.ROTATE:
13535
13876
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13536
13877
  if (scope.enablePan === false) return;
13537
13878
  handleMouseDownPan(event);
@@ -13542,7 +13883,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13542
13883
  state = STATE.ROTATE;
13543
13884
  }
13544
13885
  break;
13545
- case import_three33.MOUSE.PAN:
13886
+ case import_three35.MOUSE.PAN:
13546
13887
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13547
13888
  if (scope.enableRotate === false) return;
13548
13889
  handleMouseDownRotate(event);
@@ -13598,12 +13939,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13598
13939
  switch (pointers.length) {
13599
13940
  case 1:
13600
13941
  switch (scope.touches.ONE) {
13601
- case import_three33.TOUCH.ROTATE:
13942
+ case import_three35.TOUCH.ROTATE:
13602
13943
  if (scope.enableRotate === false) return;
13603
13944
  handleTouchStartRotate();
13604
13945
  state = STATE.TOUCH_ROTATE;
13605
13946
  break;
13606
- case import_three33.TOUCH.PAN:
13947
+ case import_three35.TOUCH.PAN:
13607
13948
  if (scope.enablePan === false) return;
13608
13949
  handleTouchStartPan();
13609
13950
  state = STATE.TOUCH_PAN;
@@ -13614,12 +13955,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13614
13955
  break;
13615
13956
  case 2:
13616
13957
  switch (scope.touches.TWO) {
13617
- case import_three33.TOUCH.DOLLY_PAN:
13958
+ case import_three35.TOUCH.DOLLY_PAN:
13618
13959
  if (scope.enableZoom === false && scope.enablePan === false) return;
13619
13960
  handleTouchStartDollyPan();
13620
13961
  state = STATE.TOUCH_DOLLY_PAN;
13621
13962
  break;
13622
- case import_three33.TOUCH.DOLLY_ROTATE:
13963
+ case import_three35.TOUCH.DOLLY_ROTATE:
13623
13964
  if (scope.enableZoom === false && scope.enableRotate === false) return;
13624
13965
  handleTouchStartDollyRotate();
13625
13966
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -13686,7 +14027,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13686
14027
  function trackPointer(event) {
13687
14028
  let position = pointerPositions[event.pointerId];
13688
14029
  if (position === void 0) {
13689
- position = new import_three33.Vector2();
14030
+ position = new import_three35.Vector2();
13690
14031
  pointerPositions[event.pointerId] = position;
13691
14032
  }
13692
14033
  position.set(event.pageX, event.pageY);
@@ -13706,10 +14047,10 @@ var MapControls = class extends OrbitControls {
13706
14047
  constructor(object, domElement) {
13707
14048
  super(object, domElement);
13708
14049
  this.screenSpacePanning = false;
13709
- this.mouseButtons.LEFT = import_three33.MOUSE.PAN;
13710
- this.mouseButtons.RIGHT = import_three33.MOUSE.ROTATE;
13711
- this.touches.ONE = import_three33.TOUCH.PAN;
13712
- this.touches.TWO = import_three33.TOUCH.DOLLY_ROTATE;
14050
+ this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
14051
+ this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
14052
+ this.touches.ONE = import_three35.TOUCH.PAN;
14053
+ this.touches.TWO = import_three35.TOUCH.DOLLY_ROTATE;
13713
14054
  }
13714
14055
  };
13715
14056
 
@@ -13760,14 +14101,14 @@ var _Renderer = class _Renderer {
13760
14101
  switch (this.options.camera.type) {
13761
14102
  case "perspective":
13762
14103
  default:
13763
- return new import_three34.PerspectiveCamera(
14104
+ return new import_three36.PerspectiveCamera(
13764
14105
  this.options.camera.perspective.fov,
13765
14106
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
13766
14107
  this.options.camera.near,
13767
14108
  this.options.camera.far
13768
14109
  );
13769
14110
  case "orthographic":
13770
- return new import_three34.OrthographicCamera(
14111
+ return new import_three36.OrthographicCamera(
13771
14112
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
13772
14113
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
13773
14114
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -13778,7 +14119,7 @@ var _Renderer = class _Renderer {
13778
14119
  }
13779
14120
  }
13780
14121
  createRenderer() {
13781
- const renderer = new import_three34.WebGLRenderer({
14122
+ const renderer = new import_three36.WebGLRenderer({
13782
14123
  antialias: this.options.render.antialias,
13783
14124
  alpha: true,
13784
14125
  powerPreference: "high-performance",
@@ -13786,8 +14127,8 @@ var _Renderer = class _Renderer {
13786
14127
  });
13787
14128
  renderer.setClearColor(0, 0);
13788
14129
  renderer.shadowMap.enabled = true;
13789
- renderer.shadowMap.type = import_three34.PCFShadowMap;
13790
- renderer.outputColorSpace = import_three34.SRGBColorSpace;
14130
+ renderer.shadowMap.type = import_three36.PCFShadowMap;
14131
+ renderer.outputColorSpace = import_three36.SRGBColorSpace;
13791
14132
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
13792
14133
  renderer.setSize(this.viewWidth, this.viewHeight);
13793
14134
  return renderer;
@@ -13822,20 +14163,20 @@ var _Renderer = class _Renderer {
13822
14163
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
13823
14164
  }
13824
14165
  if (this.options.debug.grid) {
13825
- const gridHelper = new import_three34.GridHelper(128, 16);
14166
+ const gridHelper = new import_three36.GridHelper(128, 16);
13826
14167
  this._debugHelpers.push(gridHelper);
13827
14168
  this.scene.add(gridHelper);
13828
- const gridHelper2 = new import_three34.GridHelper(128, 16);
14169
+ const gridHelper2 = new import_three36.GridHelper(128, 16);
13829
14170
  this._debugHelpers.push(gridHelper2);
13830
14171
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
13831
14172
  this.scene.add(gridHelper2);
13832
- const gridHelper3 = new import_three34.GridHelper(128, 16);
14173
+ const gridHelper3 = new import_three36.GridHelper(128, 16);
13833
14174
  this._debugHelpers.push(gridHelper3);
13834
14175
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
13835
14176
  this.scene.add(gridHelper3);
13836
14177
  }
13837
14178
  if (this.options.debug.axes) {
13838
- const axesHelper = new import_three34.AxesHelper(64);
14179
+ const axesHelper = new import_three36.AxesHelper(64);
13839
14180
  this._debugHelpers.push(axesHelper);
13840
14181
  this.scene.add(axesHelper);
13841
14182
  }
@@ -14094,8 +14435,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
14094
14435
  top: void 0,
14095
14436
  bottom: void 0
14096
14437
  },
14097
- position: new import_three34.Vector3(50, 50, 50),
14098
- lookingAt: new import_three34.Vector3(0, 0, 0)
14438
+ position: new import_three36.Vector3(50, 50, 50),
14439
+ lookingAt: new import_three36.Vector3(0, 0, 0)
14099
14440
  },
14100
14441
  render: {
14101
14442
  fpsLimit: 60,
@@ -14560,12 +14901,12 @@ var AnvilParser = class {
14560
14901
  };
14561
14902
 
14562
14903
  // src/world/Chunk.ts
14563
- var import_three39 = require("three");
14904
+ var import_three41 = require("three");
14564
14905
  init_BlockStates();
14565
14906
  init_AssetKey();
14566
14907
 
14567
14908
  // src/world/MineRenderWorld.ts
14568
- var import_three37 = require("three");
14909
+ var import_three39 = require("three");
14569
14910
  init_Model();
14570
14911
  init_BatchedExecutor();
14571
14912
  init_AssetKey();
@@ -14573,7 +14914,7 @@ init_BlockStates();
14573
14914
  init_CubeFace();
14574
14915
 
14575
14916
  // src/world/SectionModels.ts
14576
- var import_three36 = require("three");
14917
+ var import_three38 = require("three");
14577
14918
  init_AssetKey();
14578
14919
  init_Models();
14579
14920
  init_CubeFace();
@@ -14639,12 +14980,12 @@ var SectionModels = class {
14639
14980
  });
14640
14981
  await object.init();
14641
14982
  const geometry = object.children[0].geometry;
14642
- geometry.applyMatrix4(new import_three36.Matrix4().makeRotationFromEuler(rotation));
14983
+ geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
14643
14984
  object.clear();
14644
14985
  const cullFaces = CUBE_FACES.map((face) => {
14645
14986
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14646
14987
  if (local < 0) return 0;
14647
- const normal = new import_three36.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14988
+ const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14648
14989
  const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
14649
14990
  return 1 << world;
14650
14991
  });
@@ -14674,20 +15015,20 @@ var MineRenderWorld = class {
14674
15015
  }
14675
15016
  getBlockAt(posOrX, y, z) {
14676
15017
  if (typeof posOrX == "number") {
14677
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
15018
+ return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
14678
15019
  }
14679
15020
  if (isTripleArray(posOrX)) {
14680
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15021
+ return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14681
15022
  }
14682
15023
  this.validatePosBounds(posOrX);
14683
15024
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
14684
15025
  }
14685
15026
  async setBlockAt(posOrX, yOrBlock, z, block) {
14686
15027
  if (typeof posOrX == "number") {
14687
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
15028
+ return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
14688
15029
  }
14689
15030
  if (isTripleArray(posOrX)) {
14690
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15031
+ return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14691
15032
  }
14692
15033
  return this.placeBlock(posOrX, yOrBlock);
14693
15034
  }
@@ -14698,10 +15039,10 @@ var MineRenderWorld = class {
14698
15039
  }
14699
15040
  async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
14700
15041
  if (typeof posOrX === "number") {
14701
- return this.setBlockVisibleAt(new import_three37.Vector3(posOrX, yOrVisible, z), visible);
15042
+ return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
14702
15043
  }
14703
15044
  if (isTripleArray(posOrX)) {
14704
- return this.setBlockVisibleAt(new import_three37.Vector3(...posOrX), yOrVisible);
15045
+ return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
14705
15046
  }
14706
15047
  this.validatePosBounds(posOrX);
14707
15048
  await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
@@ -14718,7 +15059,7 @@ var MineRenderWorld = class {
14718
15059
  const collect = async (positions2) => {
14719
15060
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
14720
15061
  };
14721
- const place = (block) => this.placeBlock(new import_three37.Vector3(...block.position), block, collect);
15062
+ const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
14722
15063
  const keys = /* @__PURE__ */ new Map();
14723
15064
  for (const block of multiblock.blocks) {
14724
15065
  if (Chunk.isAir(block)) continue;
@@ -14796,13 +15137,13 @@ var MineRenderWorld = class {
14796
15137
  for (const pos of positions) {
14797
15138
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
14798
15139
  for (const offset of CUBE_FACE_OFFSETS) {
14799
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
15140
+ const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
14800
15141
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14801
15142
  }
14802
15143
  for (let y = -1; y <= 1; y++) {
14803
15144
  for (let z = -1; z <= 1; z++) {
14804
15145
  for (let x = -1; x <= 1; x++) {
14805
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
15146
+ const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
14806
15147
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
14807
15148
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14808
15149
  }
@@ -14826,7 +15167,7 @@ var MineRenderWorld = class {
14826
15167
  }
14827
15168
  if (block.object?.fluidKind) {
14828
15169
  await block.object.updateFluid((x, y, z) => {
14829
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
15170
+ const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
14830
15171
  const section = this.getChunkAt(neighbor);
14831
15172
  const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
14832
15173
  return {
@@ -14838,7 +15179,7 @@ var MineRenderWorld = class {
14838
15179
  }
14839
15180
  let mask = 0;
14840
15181
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
14841
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
15182
+ const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
14842
15183
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
14843
15184
  mask |= 1 << face;
14844
15185
  }
@@ -14872,14 +15213,14 @@ var MineRenderWorld = class {
14872
15213
  return this._chunks.get(this.worldPosToChunkKey(pos));
14873
15214
  }
14874
15215
  static worldToScenePosition(pos) {
14875
- return new import_three37.Vector3(
15216
+ return new import_three39.Vector3(
14876
15217
  pos.x * 16,
14877
15218
  pos.y * 16,
14878
15219
  pos.z * 16
14879
15220
  );
14880
15221
  }
14881
15222
  static sceneToWorldPosition(pos) {
14882
- return new import_three37.Vector3(
15223
+ return new import_three39.Vector3(
14883
15224
  pos.x / 16,
14884
15225
  pos.y / 16,
14885
15226
  pos.z / 16
@@ -14902,10 +15243,10 @@ var MineRenderWorld = class {
14902
15243
  init_Model();
14903
15244
 
14904
15245
  // src/world/SectionMesh.ts
14905
- var import_three38 = require("three");
15246
+ var import_three40 = require("three");
14906
15247
  init_CanvasCompat();
14907
15248
  init_Materials();
14908
- var SectionMesh = class _SectionMesh extends import_three38.Group {
15249
+ var SectionMesh = class _SectionMesh extends import_three40.Group {
14909
15250
  constructor() {
14910
15251
  super(...arguments);
14911
15252
  this.ownedMeshes = [];
@@ -14978,18 +15319,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
14978
15319
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
14979
15320
  }
14980
15321
  }
14981
- const geometry = new import_three38.BufferGeometry();
14982
- geometry.setAttribute("position", new import_three38.Float32BufferAttribute(positions, 3));
14983
- geometry.setAttribute("normal", new import_three38.Float32BufferAttribute(normals, 3));
14984
- geometry.setAttribute("uv", new import_three38.Float32BufferAttribute(uvs, 2));
14985
- geometry.setAttribute("color", new import_three38.Float32BufferAttribute(colors, 3));
15322
+ const geometry = new import_three40.BufferGeometry();
15323
+ geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
15324
+ geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
15325
+ geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
15326
+ geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
14986
15327
  geometry.setIndex(indices);
14987
15328
  geometry.computeBoundingBox();
14988
15329
  geometry.computeBoundingSphere();
14989
15330
  const material = Materials.createShadedCanvasMaterial(canvas, false);
14990
15331
  material.vertexColors = true;
14991
15332
  const texture = material.uniforms?.map?.value ?? material.map;
14992
- const mesh = new import_three38.Mesh(geometry, material);
15333
+ const mesh = new import_three40.Mesh(geometry, material);
14993
15334
  section.add(mesh);
14994
15335
  section.ownedMeshes.push({ mesh, texture });
14995
15336
  }
@@ -15025,10 +15366,10 @@ var Chunk = class _Chunk {
15025
15366
  }
15026
15367
  getBlockAt(posOrX, y, z) {
15027
15368
  if (typeof posOrX == "number") {
15028
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
15369
+ return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
15029
15370
  }
15030
15371
  if (isTripleArray(posOrX)) {
15031
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15372
+ return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15032
15373
  }
15033
15374
  const pos = this.worldPosToChunkPos(posOrX);
15034
15375
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -15036,10 +15377,10 @@ var Chunk = class _Chunk {
15036
15377
  }
15037
15378
  async setBlockAt(posOrX, yOrBlock, z, block) {
15038
15379
  if (typeof posOrX == "number") {
15039
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
15380
+ return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
15040
15381
  }
15041
15382
  if (isTripleArray(posOrX)) {
15042
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15383
+ return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15043
15384
  }
15044
15385
  const worldPos = posOrX;
15045
15386
  const pos = this.worldPosToChunkPos(worldPos);
@@ -15151,7 +15492,7 @@ var Chunk = class _Chunk {
15151
15492
  }
15152
15493
  async clear(onBlocksChanged = this.onBlocksChanged) {
15153
15494
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
15154
- new import_three39.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
15495
+ new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
15155
15496
  ));
15156
15497
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
15157
15498
  this.sectionBlocks.clear();
@@ -15176,14 +15517,14 @@ var Chunk = class _Chunk {
15176
15517
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
15177
15518
  }
15178
15519
  worldPosToChunkPos(pos) {
15179
- return new import_three39.Vector3(
15520
+ return new import_three41.Vector3(
15180
15521
  pos.x - this.x * 16,
15181
15522
  pos.y - this.y * 16,
15182
15523
  pos.z - this.z * 16
15183
15524
  );
15184
15525
  }
15185
15526
  chunkPosToWorldPos(pos) {
15186
- return new import_three39.Vector3(
15527
+ return new import_three41.Vector3(
15187
15528
  this.x * 16 + pos.x,
15188
15529
  this.y * 16 + pos.y,
15189
15530
  this.z * 16 + pos.z