minerender 2.1.0-alpha.67 → 2.1.0-alpha.68

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.
@@ -4346,7 +4346,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
4346
4346
  const attributes = {};
4347
4347
  const morphAttributes = {};
4348
4348
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
4349
- const mergedGeometry = new import_three20.BufferGeometry();
4349
+ const mergedGeometry = new import_three21.BufferGeometry();
4350
4350
  let offset = 0;
4351
4351
  for (let i = 0; i < geometries.length; ++i) {
4352
4352
  const geometry = geometries[i];
@@ -4470,7 +4470,7 @@ function mergeBufferAttributes(attributes) {
4470
4470
  array.set(attributes[i].array, offset);
4471
4471
  offset += attributes[i].array.length;
4472
4472
  }
4473
- return new import_three20.BufferAttribute(array, itemSize, normalized);
4473
+ return new import_three21.BufferAttribute(array, itemSize, normalized);
4474
4474
  }
4475
4475
  function interleaveAttributes(attributes) {
4476
4476
  let TypedArray;
@@ -4486,7 +4486,7 @@ function interleaveAttributes(attributes) {
4486
4486
  arrayLength += attribute.array.length;
4487
4487
  stride += attribute.itemSize;
4488
4488
  }
4489
- const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
4489
+ const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
4490
4490
  let offset = 0;
4491
4491
  const res = [];
4492
4492
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -4495,7 +4495,7 @@ function interleaveAttributes(attributes) {
4495
4495
  const attribute = attributes[j];
4496
4496
  const itemSize = attribute.itemSize;
4497
4497
  const count = attribute.count;
4498
- const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4498
+ const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4499
4499
  res.push(iba);
4500
4500
  offset += itemSize;
4501
4501
  for (let c = 0; c < count; c++) {
@@ -4579,13 +4579,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4579
4579
  const name = attributeNames[i];
4580
4580
  const oldAttribute = geometry.getAttribute(name);
4581
4581
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
4582
- const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4582
+ const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4583
4583
  result.setAttribute(name, attribute);
4584
4584
  if (name in morphAttrsArrays) {
4585
4585
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
4586
4586
  const oldMorphAttribute = geometry.morphAttributes[name][j];
4587
4587
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
4588
- const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4588
+ const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4589
4589
  result.morphAttributes[name][j] = morphAttribute;
4590
4590
  }
4591
4591
  }
@@ -4594,11 +4594,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4594
4594
  return result;
4595
4595
  }
4596
4596
  function toTrianglesDrawMode(geometry, drawMode) {
4597
- if (drawMode === import_three20.TrianglesDrawMode) {
4597
+ if (drawMode === import_three21.TrianglesDrawMode) {
4598
4598
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
4599
4599
  return geometry;
4600
4600
  }
4601
- if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
4601
+ if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
4602
4602
  let index = geometry.getIndex();
4603
4603
  if (index === null) {
4604
4604
  const indices = [];
@@ -4616,7 +4616,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
4616
4616
  }
4617
4617
  const numberOfTriangles = index.count - 2;
4618
4618
  const newIndices = [];
4619
- if (drawMode === import_three20.TriangleFanDrawMode) {
4619
+ if (drawMode === import_three21.TriangleFanDrawMode) {
4620
4620
  for (let i = 1; i <= numberOfTriangles; i++) {
4621
4621
  newIndices.push(index.getX(0));
4622
4622
  newIndices.push(index.getX(i));
@@ -4652,15 +4652,15 @@ function computeMorphedAttributes(object) {
4652
4652
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4653
4653
  return null;
4654
4654
  }
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();
4655
+ const _vA = new import_three21.Vector3();
4656
+ const _vB = new import_three21.Vector3();
4657
+ const _vC = new import_three21.Vector3();
4658
+ const _tempA = new import_three21.Vector3();
4659
+ const _tempB = new import_three21.Vector3();
4660
+ const _tempC = new import_three21.Vector3();
4661
+ const _morphA = new import_three21.Vector3();
4662
+ const _morphB = new import_three21.Vector3();
4663
+ const _morphC = new import_three21.Vector3();
4664
4664
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4665
4665
  _vA.fromBufferAttribute(attribute, a2);
4666
4666
  _vB.fromBufferAttribute(attribute, b2);
@@ -4855,8 +4855,8 @@ function computeMorphedAttributes(object) {
4855
4855
  }
4856
4856
  }
4857
4857
  }
4858
- const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4859
- const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4858
+ const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
4859
+ const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
4860
4860
  return {
4861
4861
  positionAttribute,
4862
4862
  normalAttribute,
@@ -4864,24 +4864,24 @@ function computeMorphedAttributes(object) {
4864
4864
  morphedNormalAttribute
4865
4865
  };
4866
4866
  }
4867
- var import_three20;
4867
+ var import_three21;
4868
4868
  var init_BufferGeometryUtils = __esm({
4869
4869
  "src/three/BufferGeometryUtils.js"() {
4870
- import_three20 = require("three");
4870
+ import_three21 = require("three");
4871
4871
  }
4872
4872
  });
4873
4873
 
4874
4874
  // src/model/ModelCulling.ts
4875
- var import_three21, ModelCulling;
4875
+ var import_three22, ModelCulling;
4876
4876
  var init_ModelCulling = __esm({
4877
4877
  "src/model/ModelCulling.ts"() {
4878
- import_three21 = require("three");
4878
+ import_three22 = require("three");
4879
4879
  init_CubeFace();
4880
4880
  ModelCulling = class {
4881
4881
  static toLocalMask(worldMask, rotation) {
4882
4882
  let localMask = 0;
4883
4883
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4884
- const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4884
+ const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
4885
4885
  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
4886
  if (worldFace < 0) return 0;
4887
4887
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4914,10 +4914,10 @@ var init_ModelCulling = __esm({
4914
4914
  });
4915
4915
 
4916
4916
  // src/model/SpecialItems.ts
4917
- var import_three22, SpecialItems;
4917
+ var import_three23, SpecialItems;
4918
4918
  var init_SpecialItems = __esm({
4919
4919
  "src/model/SpecialItems.ts"() {
4920
- import_three22 = require("three");
4920
+ import_three23 = require("three");
4921
4921
  init_AssetKey();
4922
4922
  init_Entities();
4923
4923
  SpecialItems = class {
@@ -4945,7 +4945,7 @@ var init_SpecialItems = __esm({
4945
4945
  case "minecraft:chest":
4946
4946
  case "chest": {
4947
4947
  const angle = -(special.openness ?? 0) * Math.PI / 2;
4948
- const chest = await load("chest", texture(special.texture, "chest"), new import_three22.Matrix4(), {
4948
+ const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
4949
4949
  lid: [angle, 0, 0],
4950
4950
  lock: [angle, 0, 0]
4951
4951
  });
@@ -4954,11 +4954,11 @@ var init_SpecialItems = __esm({
4954
4954
  }
4955
4955
  case "minecraft:bed":
4956
4956
  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));
4957
+ const transform = new import_three23.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three23.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three23.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three23.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
4958
4958
  const key = texture(special.texture, "bed");
4959
4959
  return Promise.all([
4960
4960
  load("bed_head", key, transform),
4961
- load("bed_foot", key, new import_three22.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4961
+ load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4962
4962
  ]);
4963
4963
  }
4964
4964
  case "minecraft:head":
@@ -4983,7 +4983,7 @@ var init_SpecialItems = __esm({
4983
4983
  return [await load(
4984
4984
  id,
4985
4985
  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)),
4986
+ new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
4987
4987
  rotations
4988
4988
  )];
4989
4989
  }
@@ -5111,13 +5111,13 @@ var init_ItemTints = __esm({
5111
5111
  function isModelObject(obj) {
5112
5112
  return obj.isModelObject;
5113
5113
  }
5114
- var import_three23, import_ts_deepmerge5, p7, ModelObject;
5114
+ var import_three24, import_ts_deepmerge5, p7, ModelObject;
5115
5115
  var init_ModelObject = __esm({
5116
5116
  "src/model/scene/ModelObject.ts"() {
5117
5117
  init_SceneObject();
5118
5118
  init_Materials();
5119
5119
  init_UVMapper();
5120
- import_three23 = require("three");
5120
+ import_three24 = require("three");
5121
5121
  init_BufferGeometryUtils();
5122
5122
  init_model();
5123
5123
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -5152,8 +5152,8 @@ var init_ModelObject = __esm({
5152
5152
  const special = this.originalModel.special;
5153
5153
  if (special) {
5154
5154
  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));
5155
+ const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
5156
+ transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
5157
5157
  try {
5158
5158
  for (const part of parts) {
5159
5159
  const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
@@ -5216,7 +5216,7 @@ var init_ModelObject = __esm({
5216
5216
  elGeo.clearGroups();
5217
5217
  }
5218
5218
  if (this.options.uvLockRotation) {
5219
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three23.Euler(...this.options.uvLockRotation));
5219
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
5220
5220
  }
5221
5221
  if (this.options.tints) {
5222
5222
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -5225,19 +5225,19 @@ var init_ModelObject = __esm({
5225
5225
  if (tintIndex === void 0 || tintIndex < 0) continue;
5226
5226
  const tint = this.options.tints[tintIndex];
5227
5227
  if (tint === void 0) continue;
5228
- const color = new import_three23.Color(tint);
5228
+ const color = new import_three24.Color(tint);
5229
5229
  for (let vertex = 0; vertex < 4; vertex++) {
5230
5230
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5231
5231
  }
5232
5232
  }
5233
- elGeo.setAttribute("color", new import_three23.BufferAttribute(colors, 3));
5233
+ elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
5234
5234
  }
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]));
5235
+ elGeo.applyMatrix4(new import_three24.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_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5237
5237
  if (el.rotation) {
5238
5238
  applyElementRotation(el.rotation, elGeo);
5239
5239
  }
5240
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5240
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
5241
5241
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
5242
5242
  if (this.options.mergeMeshes) {
5243
5243
  allGeos.push(elGeo);
@@ -5259,7 +5259,7 @@ var init_ModelObject = __esm({
5259
5259
  if (allGeos.length > 0) {
5260
5260
  combinedGeo = mergeBufferGeometries(allGeos);
5261
5261
  } else {
5262
- combinedGeo = new import_three23.BoxGeometry(16, 16, 16);
5262
+ combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
5263
5263
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
5264
5264
  }
5265
5265
  combinedGeo.computeBoundingBox();
@@ -5369,7 +5369,7 @@ function ownHeight(sample) {
5369
5369
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
5370
5370
  }
5371
5371
  function createFluidGeometry(kind, sample) {
5372
- const geometry = new import_three28.BufferGeometry();
5372
+ const geometry = new import_three29.BufferGeometry();
5373
5373
  const positions = [], normals = [], uvs = [], indices = [];
5374
5374
  const self = sample(0, 0, 0);
5375
5375
  const height = (x, z) => {
@@ -5468,16 +5468,16 @@ function createFluidGeometry(kind, sample) {
5468
5468
  1
5469
5469
  );
5470
5470
  }
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));
5471
+ geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
5472
+ geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
5473
+ geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
5474
5474
  geometry.setIndex(indices);
5475
5475
  return geometry;
5476
5476
  }
5477
- var import_three28, fluidRules, HORIZONTAL, EPSILON;
5477
+ var import_three29, fluidRules, HORIZONTAL, EPSILON;
5478
5478
  var init_FluidGeometry = __esm({
5479
5479
  "src/model/fluid/FluidGeometry.ts"() {
5480
- import_three28 = require("three");
5480
+ import_three29 = require("three");
5481
5481
  init_fluidBlocks();
5482
5482
  fluidRules = fluidBlocks_default;
5483
5483
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -5506,10 +5506,10 @@ function sampleFluid(kind, sample) {
5506
5506
  }
5507
5507
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
5508
5508
  }
5509
- var import_three29, FluidModelObject;
5509
+ var import_three30, FluidModelObject;
5510
5510
  var init_FluidModelObject = __esm({
5511
5511
  "src/model/fluid/FluidModelObject.ts"() {
5512
- import_three29 = require("three");
5512
+ import_three30 = require("three");
5513
5513
  init_AssetKey();
5514
5514
  init_Materials();
5515
5515
  init_ModelObject();
@@ -5542,10 +5542,10 @@ var init_FluidModelObject = __esm({
5542
5542
  }
5543
5543
  }
5544
5544
  geometry.clearGroups();
5545
- const color = new import_three29.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5545
+ const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5546
5546
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5547
5547
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5548
- geometry.setAttribute("color", new import_three29.BufferAttribute(colors, 3));
5548
+ geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
5549
5549
  geometry.computeBoundingBox();
5550
5550
  geometry.computeBoundingSphere();
5551
5551
  if (this.options.instanceMeshes) {
@@ -5559,7 +5559,7 @@ var init_FluidModelObject = __esm({
5559
5559
  super.applyTextures();
5560
5560
  this.iterateAllMeshes((mesh) => {
5561
5561
  const material = mesh.material;
5562
- material.side = import_three29.DoubleSide;
5562
+ material.side = import_three30.DoubleSide;
5563
5563
  material.forceSinglePass = true;
5564
5564
  material.depthWrite = !material.transparent;
5565
5565
  });
@@ -5692,6 +5692,7 @@ __export(index_node_exports, {
5692
5692
  computeTangents: () => computeTangents,
5693
5693
  createCanvas: () => createCanvas2,
5694
5694
  createFluidGeometry: () => createFluidGeometry,
5695
+ createGuiTextureGeometry: () => createGuiTextureGeometry,
5695
5696
  createImage: () => createImage,
5696
5697
  entityAnimationTime: () => entityAnimationTime,
5697
5698
  estimateBytesUsed: () => estimateBytesUsed,
@@ -8973,8 +8974,87 @@ var GuiHelper = class {
8973
8974
  }
8974
8975
  };
8975
8976
 
8977
+ // src/gui/GuiTextureGeometry.ts
8978
+ var import_three20 = require("three");
8979
+ function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
8980
+ if (crop || !scaling || scaling.type === "stretch") {
8981
+ const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
8982
+ const geometry = new import_three20.PlaneGeometry(width, height);
8983
+ const uv = geometry.getAttribute("uv");
8984
+ for (let i = 0; i < uv.count; i++) {
8985
+ uv.setXY(
8986
+ i,
8987
+ (x + uv.getX(i) * w) / imageWidth,
8988
+ 1 - (y + (1 - uv.getY(i)) * h) / imageHeight
8989
+ );
8990
+ }
8991
+ return geometry;
8992
+ }
8993
+ const sw = scaling.width, sh = scaling.height;
8994
+ if (![sw, sh].every((value) => Number.isInteger(value) && value > 0)) {
8995
+ throw new Error("GUI sprite dimensions must be positive integers");
8996
+ }
8997
+ if (![width, height].every((value) => Number.isFinite(value) && value >= 0)) {
8998
+ throw new Error("GUI output dimensions must be finite and nonnegative");
8999
+ }
9000
+ const positions = [], uvs = [], normals = [], indices = [];
9001
+ function quad(x, y, w, h, u, v, uw, vh) {
9002
+ if (w <= 0 || h <= 0) return;
9003
+ const index = positions.length / 3;
9004
+ const left = x - width / 2, top = height / 2 - y;
9005
+ positions.push(left, top, 0, left + w, top, 0, left, top - h, 0, left + w, top - h, 0);
9006
+ uvs.push(
9007
+ u / sw,
9008
+ 1 - v / sh,
9009
+ (u + uw) / sw,
9010
+ 1 - v / sh,
9011
+ u / sw,
9012
+ 1 - (v + vh) / sh,
9013
+ (u + uw) / sw,
9014
+ 1 - (v + vh) / sh
9015
+ );
9016
+ normals.push(0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1);
9017
+ indices.push(index, index + 2, index + 1, index + 2, index + 3, index + 1);
9018
+ }
9019
+ function tile(x, y, w, h, u, v, tw, th) {
9020
+ for (let dy = 0; dy < h; dy += th) {
9021
+ for (let dx = 0; dx < w; dx += tw) {
9022
+ const cw = Math.min(tw, w - dx), ch = Math.min(th, h - dy);
9023
+ quad(x + dx, y + dy, cw, ch, u, v, cw, ch);
9024
+ }
9025
+ }
9026
+ }
9027
+ if (scaling.type === "tile") {
9028
+ tile(0, 0, width, height, 0, 0, sw, sh);
9029
+ } else {
9030
+ let segments = function(size, sourceSize, start, end) {
9031
+ if (size === sourceSize) return [[0, size, 0, sourceSize]];
9032
+ start = Math.min(start, Math.floor(size / 2));
9033
+ end = Math.min(end, Math.floor(size / 2));
9034
+ return [
9035
+ [0, start, 0, start],
9036
+ [start, size - start - end, start, sourceSize - start - end],
9037
+ [size - end, end, sourceSize - end, end]
9038
+ ];
9039
+ };
9040
+ const border = typeof scaling.border === "number" ? { left: scaling.border, top: scaling.border, right: scaling.border, bottom: scaling.border } : scaling.border;
9041
+ 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) {
9042
+ throw new Error("GUI nine-slice borders must be nonnegative integers with a nonempty center");
9043
+ }
9044
+ const columns = segments(width, sw, border.left, border.right);
9045
+ const rows = segments(height, sh, border.top, border.bottom);
9046
+ for (const [y, h, v, vh] of rows) {
9047
+ for (const [x, w, u, uw] of columns) {
9048
+ if (w <= 0 || h <= 0) continue;
9049
+ (scaling.stretch_inner ? quad : tile)(x, y, w, h, u, v, uw, vh);
9050
+ }
9051
+ }
9052
+ }
9053
+ return new import_three20.BufferGeometry().setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3)).setAttribute("normal", new import_three20.Float32BufferAttribute(normals, 3)).setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2)).setIndex(indices);
9054
+ }
9055
+
8976
9056
  // src/gui/scene/GuiObject.ts
8977
- var import_three24 = require("three");
9057
+ var import_three25 = require("three");
8978
9058
  init_AssetKey();
8979
9059
  init_ModelTextures();
8980
9060
  init_Models();
@@ -8990,7 +9070,7 @@ var GuiObject = class extends SceneObject {
8990
9070
  this.textureLayers = textureLayers;
8991
9071
  this.isGuiObject = true;
8992
9072
  /** Local bounds in GUI pixels, with y growing down from the origin. */
8993
- this.bounds = new import_three24.Box2();
9073
+ this.bounds = new import_three25.Box2();
8994
9074
  this.geometries = /* @__PURE__ */ new Set();
8995
9075
  this.ownedMaterials = /* @__PURE__ */ new Set();
8996
9076
  this.initialized = false;
@@ -9008,41 +9088,33 @@ var GuiObject = class extends SceneObject {
9008
9088
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
9009
9089
  item.updateWorldMatrix(true, true);
9010
9090
  const inverse = this.matrixWorld.clone().invert();
9011
- const bounds = new import_three24.Box3();
9091
+ const bounds = new import_three25.Box3();
9012
9092
  item.iterateAllMeshes((mesh2) => {
9013
9093
  mesh2.geometry.computeBoundingBox();
9014
- bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three24.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
9094
+ bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
9015
9095
  });
9016
9096
  item.position.z = depth - bounds.min.z;
9017
9097
  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));
9098
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
9099
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
9100
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
9101
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
9022
9102
  continue;
9023
9103
  }
9024
9104
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
9025
9105
  const material = await this.loadMaterial(key);
9026
9106
  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);
9107
+ const scaling = layer.crop ? void 0 : (await ModelTextures.getMeta(key))?.gui?.scaling;
9108
+ const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
9109
+ const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
9030
9110
  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);
9111
+ const mesh = new import_three25.Mesh(geometry, material);
9040
9112
  mesh.name = `mesh:${layer.name ?? index}`;
9041
9113
  mesh.position.set(x + width / 2, -y - height / 2, depth);
9042
9114
  mesh.renderOrder = index;
9043
9115
  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));
9116
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
9117
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
9046
9118
  depth += 0.01;
9047
9119
  }
9048
9120
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -9117,7 +9189,7 @@ function isGuiObject(obj) {
9117
9189
  init_image();
9118
9190
 
9119
9191
  // src/inspector/SceneInspector.ts
9120
- var import_three25 = require("three");
9192
+ var import_three26 = require("three");
9121
9193
  init_SceneObject();
9122
9194
  init_util();
9123
9195
  init_log();
@@ -9127,11 +9199,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
9127
9199
  var SceneInspector = class {
9128
9200
  constructor(renderer) {
9129
9201
  this.renderer = renderer;
9130
- this.mouse = new import_three25.Vector2();
9202
+ this.mouse = new import_three26.Vector2();
9131
9203
  this.listeners = new AbortController();
9132
9204
  this.objectInfoContainer = document.createElement("div");
9133
9205
  this.objectControlsContainer = document.createElement("div");
9134
- this.raycaster = new import_three25.Raycaster();
9206
+ this.raycaster = new import_three26.Raycaster();
9135
9207
  this.init();
9136
9208
  }
9137
9209
  init() {
@@ -9534,7 +9606,7 @@ init_ModelMerger();
9534
9606
  init_SpecialItems();
9535
9607
 
9536
9608
  // src/model/block/BlockStateResolver.ts
9537
- var import_three27 = require("three");
9609
+ var import_three28 = require("three");
9538
9610
  init_BlockStates();
9539
9611
  init_MineRenderError();
9540
9612
  init_util();
@@ -9612,7 +9684,7 @@ var BlockStateResolver = class {
9612
9684
  return variants[variants.length - 1];
9613
9685
  }
9614
9686
  static rotation(variant) {
9615
- const rotation = new import_three27.Euler();
9687
+ const rotation = new import_three28.Euler();
9616
9688
  if (typeof variant.x !== "undefined") {
9617
9689
  rotation.x = toRadians(clampRotationDegrees(variant.x));
9618
9690
  }
@@ -9704,7 +9776,7 @@ init_SceneObject();
9704
9776
  init_ModelObject();
9705
9777
  init_Models();
9706
9778
  var import_ts_deepmerge6 = __toESM(require_dist());
9707
- var import_three30 = require("three");
9779
+ var import_three31 = require("three");
9708
9780
  init_MineRenderError();
9709
9781
  init_InstanceReference();
9710
9782
  init_AssetKey();
@@ -9726,7 +9798,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9726
9798
  this._models = [];
9727
9799
  this._cullMask = 0;
9728
9800
  this._entities = [];
9729
- this._entityPlacement = new import_three30.Matrix4();
9801
+ this._entityPlacement = new import_three31.Matrix4();
9730
9802
  this._entityGeneration = 0;
9731
9803
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
9732
9804
  }
@@ -9827,7 +9899,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9827
9899
  return true;
9828
9900
  }
9829
9901
  placeEntities() {
9830
- const matrix = new import_three30.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9902
+ const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9831
9903
  for (const entity of this._entities) {
9832
9904
  matrix.decompose(entity.position, entity.quaternion, entity.scale);
9833
9905
  }
@@ -9849,12 +9921,12 @@ var BlockObject = class _BlockObject extends SceneObject {
9849
9921
  getModelCullMask(model, worldMask) {
9850
9922
  const object = isInstanceReference(model) ? model.instanceable : model;
9851
9923
  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();
9924
+ const position = new import_three31.Vector3();
9925
+ const rotation = new import_three31.Quaternion();
9926
+ const scale = new import_three31.Vector3();
9855
9927
  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));
9928
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
9929
+ return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
9858
9930
  }
9859
9931
  async setCullMask(worldMask) {
9860
9932
  worldMask &= 63;
@@ -9920,7 +9992,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9920
9992
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
9921
9993
  );
9922
9994
  const previous = this._fluidModel;
9923
- const matrix = previous ? this.getModelMatrix(previous) : new import_three30.Matrix4().makeTranslation(...this.position.toArray());
9995
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
9924
9996
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
9925
9997
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
9926
9998
  this._models = this._models.filter((model) => model !== previous);
@@ -10062,7 +10134,7 @@ var BlockObject = class _BlockObject extends SceneObject {
10062
10134
  setPositionRotationScaleAt(index, position, rotation, scale) {
10063
10135
  super.setPositionRotationScaleAt(index, position, rotation, scale);
10064
10136
  }
10065
- getMatrixAt(index, matrix = new import_three30.Matrix4()) {
10137
+ getMatrixAt(index, matrix = new import_three31.Matrix4()) {
10066
10138
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
10067
10139
  const child = this._models[0];
10068
10140
  if (child && isModelObject(child)) {
@@ -11934,7 +12006,7 @@ init_ModelObject();
11934
12006
  init_nbt();
11935
12007
 
11936
12008
  // src/renderer/MineRenderScene.ts
11937
- var import_three32 = require("three");
12009
+ var import_three33 = require("three");
11938
12010
  init_SceneObject();
11939
12011
  var import_ts_deepmerge8 = __toESM(require_dist());
11940
12012
  init_ModelObject();
@@ -12667,7 +12739,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
12667
12739
  init_util();
12668
12740
 
12669
12741
  // src/skin/SkinTextures.ts
12670
- var import_three31 = require("three");
12742
+ var import_three32 = require("three");
12671
12743
  init_Caching();
12672
12744
  init_CacheKey();
12673
12745
  init_MineRenderError();
@@ -12751,11 +12823,11 @@ var SkinTextures = class {
12751
12823
  });
12752
12824
  }
12753
12825
  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;
12826
+ const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
12827
+ texture.colorSpace = import_three32.SRGBColorSpace;
12756
12828
  texture.flipY = true;
12757
12829
  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 });
12830
+ return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12759
12831
  }
12760
12832
  static isSlim(image, scale) {
12761
12833
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -12985,7 +13057,7 @@ var SkinObject = class extends SceneObject {
12985
13057
  // src/renderer/MineRenderScene.ts
12986
13058
  init_EntityObject();
12987
13059
  init_ItemTints();
12988
- var MineRenderScene = class _MineRenderScene extends import_three32.Scene {
13060
+ var MineRenderScene = class _MineRenderScene extends import_three33.Scene {
12989
13061
  constructor(options) {
12990
13062
  super();
12991
13063
  this.isMineRenderScene = true;
@@ -13115,7 +13187,7 @@ function isMineRenderScene(obj) {
13115
13187
  }
13116
13188
 
13117
13189
  // src/renderer/Renderer.ts
13118
- var import_three34 = require("three");
13190
+ var import_three35 = require("three");
13119
13191
  var import_ts_deepmerge9 = __toESM(require_dist());
13120
13192
  var import_stats = __toESM(require("stats.js"));
13121
13193
  var import_postprocessing = require("postprocessing");
@@ -13124,11 +13196,11 @@ init_Model();
13124
13196
  init_three();
13125
13197
 
13126
13198
  // src/three/OrbitControls.js
13127
- var import_three33 = require("three");
13199
+ var import_three34 = require("three");
13128
13200
  var _changeEvent = { type: "change" };
13129
13201
  var _startEvent = { type: "start" };
13130
13202
  var _endEvent = { type: "end" };
13131
- var OrbitControls = class extends import_three33.EventDispatcher {
13203
+ var OrbitControls = class extends import_three34.EventDispatcher {
13132
13204
  constructor(object, domElement) {
13133
13205
  super();
13134
13206
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -13137,7 +13209,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13137
13209
  this.domElement = domElement;
13138
13210
  this.domElement.style.touchAction = "none";
13139
13211
  this.enabled = true;
13140
- this.target = new import_three33.Vector3();
13212
+ this.target = new import_three34.Vector3();
13141
13213
  this.minDistance = 0;
13142
13214
  this.maxDistance = Infinity;
13143
13215
  this.minZoom = 0;
@@ -13159,8 +13231,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13159
13231
  this.autoRotate = false;
13160
13232
  this.autoRotateSpeed = 2;
13161
13233
  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 };
13234
+ this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
13235
+ this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
13164
13236
  this.target0 = this.target.clone();
13165
13237
  this.position0 = this.object.position.clone();
13166
13238
  this.zoom0 = this.object.zoom;
@@ -13189,11 +13261,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13189
13261
  state = STATE.NONE;
13190
13262
  };
13191
13263
  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));
13264
+ const offset = new import_three34.Vector3();
13265
+ const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
13194
13266
  const quatInverse = quat.clone().invert();
13195
- const lastPosition = new import_three33.Vector3();
13196
- const lastQuaternion = new import_three33.Quaternion();
13267
+ const lastPosition = new import_three34.Vector3();
13268
+ const lastQuaternion = new import_three34.Quaternion();
13197
13269
  const twoPI = 2 * Math.PI;
13198
13270
  return function update() {
13199
13271
  const position = scope.object.position;
@@ -13279,20 +13351,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13279
13351
  };
13280
13352
  let state = STATE.NONE;
13281
13353
  const EPS = 1e-6;
13282
- const spherical = new import_three33.Spherical();
13283
- const sphericalDelta = new import_three33.Spherical();
13354
+ const spherical = new import_three34.Spherical();
13355
+ const sphericalDelta = new import_three34.Spherical();
13284
13356
  let scale = 1;
13285
- const panOffset = new import_three33.Vector3();
13357
+ const panOffset = new import_three34.Vector3();
13286
13358
  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();
13359
+ const rotateStart = new import_three34.Vector2();
13360
+ const rotateEnd = new import_three34.Vector2();
13361
+ const rotateDelta = new import_three34.Vector2();
13362
+ const panStart = new import_three34.Vector2();
13363
+ const panEnd = new import_three34.Vector2();
13364
+ const panDelta = new import_three34.Vector2();
13365
+ const dollyStart = new import_three34.Vector2();
13366
+ const dollyEnd = new import_three34.Vector2();
13367
+ const dollyDelta = new import_three34.Vector2();
13296
13368
  const pointers = [];
13297
13369
  const pointerPositions = {};
13298
13370
  function getAutoRotationAngle() {
@@ -13308,7 +13380,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13308
13380
  sphericalDelta.phi -= angle;
13309
13381
  }
13310
13382
  const panLeft = function() {
13311
- const v = new import_three33.Vector3();
13383
+ const v = new import_three34.Vector3();
13312
13384
  return function panLeft2(distance, objectMatrix) {
13313
13385
  v.setFromMatrixColumn(objectMatrix, 0);
13314
13386
  v.multiplyScalar(-distance);
@@ -13316,7 +13388,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13316
13388
  };
13317
13389
  }();
13318
13390
  const panUp = function() {
13319
- const v = new import_three33.Vector3();
13391
+ const v = new import_three34.Vector3();
13320
13392
  return function panUp2(distance, objectMatrix) {
13321
13393
  if (scope.screenSpacePanning === true) {
13322
13394
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -13329,7 +13401,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13329
13401
  };
13330
13402
  }();
13331
13403
  const pan = function() {
13332
- const offset = new import_three33.Vector3();
13404
+ const offset = new import_three34.Vector3();
13333
13405
  return function pan2(deltaX, deltaY) {
13334
13406
  const element = scope.domElement;
13335
13407
  if (scope.object.isPerspectiveCamera) {
@@ -13578,12 +13650,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13578
13650
  mouseAction = -1;
13579
13651
  }
13580
13652
  switch (mouseAction) {
13581
- case import_three33.MOUSE.DOLLY:
13653
+ case import_three34.MOUSE.DOLLY:
13582
13654
  if (scope.enableZoom === false) return;
13583
13655
  handleMouseDownDolly(event);
13584
13656
  state = STATE.DOLLY;
13585
13657
  break;
13586
- case import_three33.MOUSE.ROTATE:
13658
+ case import_three34.MOUSE.ROTATE:
13587
13659
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13588
13660
  if (scope.enablePan === false) return;
13589
13661
  handleMouseDownPan(event);
@@ -13594,7 +13666,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13594
13666
  state = STATE.ROTATE;
13595
13667
  }
13596
13668
  break;
13597
- case import_three33.MOUSE.PAN:
13669
+ case import_three34.MOUSE.PAN:
13598
13670
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13599
13671
  if (scope.enableRotate === false) return;
13600
13672
  handleMouseDownRotate(event);
@@ -13650,12 +13722,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13650
13722
  switch (pointers.length) {
13651
13723
  case 1:
13652
13724
  switch (scope.touches.ONE) {
13653
- case import_three33.TOUCH.ROTATE:
13725
+ case import_three34.TOUCH.ROTATE:
13654
13726
  if (scope.enableRotate === false) return;
13655
13727
  handleTouchStartRotate();
13656
13728
  state = STATE.TOUCH_ROTATE;
13657
13729
  break;
13658
- case import_three33.TOUCH.PAN:
13730
+ case import_three34.TOUCH.PAN:
13659
13731
  if (scope.enablePan === false) return;
13660
13732
  handleTouchStartPan();
13661
13733
  state = STATE.TOUCH_PAN;
@@ -13666,12 +13738,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13666
13738
  break;
13667
13739
  case 2:
13668
13740
  switch (scope.touches.TWO) {
13669
- case import_three33.TOUCH.DOLLY_PAN:
13741
+ case import_three34.TOUCH.DOLLY_PAN:
13670
13742
  if (scope.enableZoom === false && scope.enablePan === false) return;
13671
13743
  handleTouchStartDollyPan();
13672
13744
  state = STATE.TOUCH_DOLLY_PAN;
13673
13745
  break;
13674
- case import_three33.TOUCH.DOLLY_ROTATE:
13746
+ case import_three34.TOUCH.DOLLY_ROTATE:
13675
13747
  if (scope.enableZoom === false && scope.enableRotate === false) return;
13676
13748
  handleTouchStartDollyRotate();
13677
13749
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -13738,7 +13810,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13738
13810
  function trackPointer(event) {
13739
13811
  let position = pointerPositions[event.pointerId];
13740
13812
  if (position === void 0) {
13741
- position = new import_three33.Vector2();
13813
+ position = new import_three34.Vector2();
13742
13814
  pointerPositions[event.pointerId] = position;
13743
13815
  }
13744
13816
  position.set(event.pageX, event.pageY);
@@ -13758,10 +13830,10 @@ var MapControls = class extends OrbitControls {
13758
13830
  constructor(object, domElement) {
13759
13831
  super(object, domElement);
13760
13832
  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;
13833
+ this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
13834
+ this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
13835
+ this.touches.ONE = import_three34.TOUCH.PAN;
13836
+ this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
13765
13837
  }
13766
13838
  };
13767
13839
 
@@ -13820,8 +13892,8 @@ var Renderer = class _Renderer {
13820
13892
  top: void 0,
13821
13893
  bottom: void 0
13822
13894
  },
13823
- position: new import_three34.Vector3(50, 50, 50),
13824
- lookingAt: new import_three34.Vector3(0, 0, 0)
13895
+ position: new import_three35.Vector3(50, 50, 50),
13896
+ lookingAt: new import_three35.Vector3(0, 0, 0)
13825
13897
  },
13826
13898
  render: {
13827
13899
  fpsLimit: 60,
@@ -13852,14 +13924,14 @@ var Renderer = class _Renderer {
13852
13924
  switch (this.options.camera.type) {
13853
13925
  case "perspective":
13854
13926
  default:
13855
- return new import_three34.PerspectiveCamera(
13927
+ return new import_three35.PerspectiveCamera(
13856
13928
  this.options.camera.perspective.fov,
13857
13929
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
13858
13930
  this.options.camera.near,
13859
13931
  this.options.camera.far
13860
13932
  );
13861
13933
  case "orthographic":
13862
- return new import_three34.OrthographicCamera(
13934
+ return new import_three35.OrthographicCamera(
13863
13935
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
13864
13936
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
13865
13937
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -13870,7 +13942,7 @@ var Renderer = class _Renderer {
13870
13942
  }
13871
13943
  }
13872
13944
  createRenderer() {
13873
- const renderer = new import_three34.WebGLRenderer({
13945
+ const renderer = new import_three35.WebGLRenderer({
13874
13946
  antialias: this.options.render.antialias,
13875
13947
  alpha: true,
13876
13948
  powerPreference: "high-performance",
@@ -13878,8 +13950,8 @@ var Renderer = class _Renderer {
13878
13950
  });
13879
13951
  renderer.setClearColor(0, 0);
13880
13952
  renderer.shadowMap.enabled = true;
13881
- renderer.shadowMap.type = import_three34.PCFShadowMap;
13882
- renderer.outputColorSpace = import_three34.SRGBColorSpace;
13953
+ renderer.shadowMap.type = import_three35.PCFShadowMap;
13954
+ renderer.outputColorSpace = import_three35.SRGBColorSpace;
13883
13955
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
13884
13956
  renderer.setSize(this.viewWidth, this.viewHeight);
13885
13957
  return renderer;
@@ -13914,20 +13986,20 @@ var Renderer = class _Renderer {
13914
13986
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
13915
13987
  }
13916
13988
  if (this.options.debug.grid) {
13917
- const gridHelper = new import_three34.GridHelper(128, 16);
13989
+ const gridHelper = new import_three35.GridHelper(128, 16);
13918
13990
  this._debugHelpers.push(gridHelper);
13919
13991
  this.scene.add(gridHelper);
13920
- const gridHelper2 = new import_three34.GridHelper(128, 16);
13992
+ const gridHelper2 = new import_three35.GridHelper(128, 16);
13921
13993
  this._debugHelpers.push(gridHelper2);
13922
13994
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
13923
13995
  this.scene.add(gridHelper2);
13924
- const gridHelper3 = new import_three34.GridHelper(128, 16);
13996
+ const gridHelper3 = new import_three35.GridHelper(128, 16);
13925
13997
  this._debugHelpers.push(gridHelper3);
13926
13998
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
13927
13999
  this.scene.add(gridHelper3);
13928
14000
  }
13929
14001
  if (this.options.debug.axes) {
13930
- const axesHelper = new import_three34.AxesHelper(64);
14002
+ const axesHelper = new import_three35.AxesHelper(64);
13931
14003
  this._debugHelpers.push(axesHelper);
13932
14004
  this.scene.add(axesHelper);
13933
14005
  }
@@ -14613,12 +14685,12 @@ var AnvilParser = class {
14613
14685
  };
14614
14686
 
14615
14687
  // src/world/Chunk.ts
14616
- var import_three39 = require("three");
14688
+ var import_three40 = require("three");
14617
14689
  init_BlockStates();
14618
14690
  init_AssetKey();
14619
14691
 
14620
14692
  // src/world/MineRenderWorld.ts
14621
- var import_three37 = require("three");
14693
+ var import_three38 = require("three");
14622
14694
  init_Model();
14623
14695
  init_BatchedExecutor();
14624
14696
  init_AssetKey();
@@ -14626,7 +14698,7 @@ init_BlockStates();
14626
14698
  init_CubeFace();
14627
14699
 
14628
14700
  // src/world/SectionModels.ts
14629
- var import_three36 = require("three");
14701
+ var import_three37 = require("three");
14630
14702
  init_AssetKey();
14631
14703
  init_Models();
14632
14704
  init_CubeFace();
@@ -14692,12 +14764,12 @@ var SectionModels = class {
14692
14764
  });
14693
14765
  await object.init();
14694
14766
  const geometry = object.children[0].geometry;
14695
- geometry.applyMatrix4(new import_three36.Matrix4().makeRotationFromEuler(rotation));
14767
+ geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
14696
14768
  object.clear();
14697
14769
  const cullFaces = CUBE_FACES.map((face) => {
14698
14770
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14699
14771
  if (local < 0) return 0;
14700
- const normal = new import_three36.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14772
+ const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14701
14773
  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
14774
  return 1 << world;
14703
14775
  });
@@ -14727,20 +14799,20 @@ var MineRenderWorld = class {
14727
14799
  }
14728
14800
  getBlockAt(posOrX, y, z) {
14729
14801
  if (typeof posOrX == "number") {
14730
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
14802
+ return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
14731
14803
  }
14732
14804
  if (isTripleArray(posOrX)) {
14733
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14805
+ return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14734
14806
  }
14735
14807
  this.validatePosBounds(posOrX);
14736
14808
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
14737
14809
  }
14738
14810
  async setBlockAt(posOrX, yOrBlock, z, block) {
14739
14811
  if (typeof posOrX == "number") {
14740
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
14812
+ return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
14741
14813
  }
14742
14814
  if (isTripleArray(posOrX)) {
14743
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14815
+ return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14744
14816
  }
14745
14817
  return this.placeBlock(posOrX, yOrBlock);
14746
14818
  }
@@ -14751,10 +14823,10 @@ var MineRenderWorld = class {
14751
14823
  }
14752
14824
  async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
14753
14825
  if (typeof posOrX === "number") {
14754
- return this.setBlockVisibleAt(new import_three37.Vector3(posOrX, yOrVisible, z), visible);
14826
+ return this.setBlockVisibleAt(new import_three38.Vector3(posOrX, yOrVisible, z), visible);
14755
14827
  }
14756
14828
  if (isTripleArray(posOrX)) {
14757
- return this.setBlockVisibleAt(new import_three37.Vector3(...posOrX), yOrVisible);
14829
+ return this.setBlockVisibleAt(new import_three38.Vector3(...posOrX), yOrVisible);
14758
14830
  }
14759
14831
  this.validatePosBounds(posOrX);
14760
14832
  await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
@@ -14771,7 +14843,7 @@ var MineRenderWorld = class {
14771
14843
  const collect = async (positions2) => {
14772
14844
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
14773
14845
  };
14774
- const place = (block) => this.placeBlock(new import_three37.Vector3(...block.position), block, collect);
14846
+ const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
14775
14847
  const keys = /* @__PURE__ */ new Map();
14776
14848
  for (const block of multiblock.blocks) {
14777
14849
  if (Chunk.isAir(block)) continue;
@@ -14849,13 +14921,13 @@ var MineRenderWorld = class {
14849
14921
  for (const pos of positions) {
14850
14922
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
14851
14923
  for (const offset of CUBE_FACE_OFFSETS) {
14852
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14924
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14853
14925
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14854
14926
  }
14855
14927
  for (let y = -1; y <= 1; y++) {
14856
14928
  for (let z = -1; z <= 1; z++) {
14857
14929
  for (let x = -1; x <= 1; x++) {
14858
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14930
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14859
14931
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
14860
14932
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14861
14933
  }
@@ -14879,7 +14951,7 @@ var MineRenderWorld = class {
14879
14951
  }
14880
14952
  if (block.object?.fluidKind) {
14881
14953
  await block.object.updateFluid((x, y, z) => {
14882
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14954
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14883
14955
  const section = this.getChunkAt(neighbor);
14884
14956
  const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
14885
14957
  return {
@@ -14891,7 +14963,7 @@ var MineRenderWorld = class {
14891
14963
  }
14892
14964
  let mask = 0;
14893
14965
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
14894
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14966
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14895
14967
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
14896
14968
  mask |= 1 << face;
14897
14969
  }
@@ -14925,14 +14997,14 @@ var MineRenderWorld = class {
14925
14997
  return this._chunks.get(this.worldPosToChunkKey(pos));
14926
14998
  }
14927
14999
  static worldToScenePosition(pos) {
14928
- return new import_three37.Vector3(
15000
+ return new import_three38.Vector3(
14929
15001
  pos.x * 16,
14930
15002
  pos.y * 16,
14931
15003
  pos.z * 16
14932
15004
  );
14933
15005
  }
14934
15006
  static sceneToWorldPosition(pos) {
14935
- return new import_three37.Vector3(
15007
+ return new import_three38.Vector3(
14936
15008
  pos.x / 16,
14937
15009
  pos.y / 16,
14938
15010
  pos.z / 16
@@ -14955,10 +15027,10 @@ var MineRenderWorld = class {
14955
15027
  init_Model();
14956
15028
 
14957
15029
  // src/world/SectionMesh.ts
14958
- var import_three38 = require("three");
15030
+ var import_three39 = require("three");
14959
15031
  init_CanvasCompat();
14960
15032
  init_Materials();
14961
- var SectionMesh = class _SectionMesh extends import_three38.Group {
15033
+ var SectionMesh = class _SectionMesh extends import_three39.Group {
14962
15034
  constructor() {
14963
15035
  super(...arguments);
14964
15036
  this.ownedMeshes = [];
@@ -15031,18 +15103,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
15031
15103
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
15032
15104
  }
15033
15105
  }
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));
15106
+ const geometry = new import_three39.BufferGeometry();
15107
+ geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
15108
+ geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
15109
+ geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
15110
+ geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
15039
15111
  geometry.setIndex(indices);
15040
15112
  geometry.computeBoundingBox();
15041
15113
  geometry.computeBoundingSphere();
15042
15114
  const material = Materials.createShadedCanvasMaterial(canvas, false);
15043
15115
  material.vertexColors = true;
15044
15116
  const texture = material.uniforms?.map?.value ?? material.map;
15045
- const mesh = new import_three38.Mesh(geometry, material);
15117
+ const mesh = new import_three39.Mesh(geometry, material);
15046
15118
  section.add(mesh);
15047
15119
  section.ownedMeshes.push({ mesh, texture });
15048
15120
  }
@@ -15078,10 +15150,10 @@ var Chunk = class _Chunk {
15078
15150
  }
15079
15151
  getBlockAt(posOrX, y, z) {
15080
15152
  if (typeof posOrX == "number") {
15081
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
15153
+ return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
15082
15154
  }
15083
15155
  if (isTripleArray(posOrX)) {
15084
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15156
+ return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15085
15157
  }
15086
15158
  const pos = this.worldPosToChunkPos(posOrX);
15087
15159
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -15089,10 +15161,10 @@ var Chunk = class _Chunk {
15089
15161
  }
15090
15162
  async setBlockAt(posOrX, yOrBlock, z, block) {
15091
15163
  if (typeof posOrX == "number") {
15092
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
15164
+ return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
15093
15165
  }
15094
15166
  if (isTripleArray(posOrX)) {
15095
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15167
+ return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15096
15168
  }
15097
15169
  const worldPos = posOrX;
15098
15170
  const pos = this.worldPosToChunkPos(worldPos);
@@ -15204,7 +15276,7 @@ var Chunk = class _Chunk {
15204
15276
  }
15205
15277
  async clear(onBlocksChanged = this.onBlocksChanged) {
15206
15278
  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)
15279
+ new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
15208
15280
  ));
15209
15281
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
15210
15282
  this.sectionBlocks.clear();
@@ -15229,14 +15301,14 @@ var Chunk = class _Chunk {
15229
15301
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
15230
15302
  }
15231
15303
  worldPosToChunkPos(pos) {
15232
- return new import_three39.Vector3(
15304
+ return new import_three40.Vector3(
15233
15305
  pos.x - this.x * 16,
15234
15306
  pos.y - this.y * 16,
15235
15307
  pos.z - this.z * 16
15236
15308
  );
15237
15309
  }
15238
15310
  chunkPosToWorldPos(pos) {
15239
- return new import_three39.Vector3(
15311
+ return new import_three40.Vector3(
15240
15312
  this.x * 16 + pos.x,
15241
15313
  this.y * 16 + pos.y,
15242
15314
  this.z * 16 + pos.z
@@ -15361,6 +15433,7 @@ var Chunk = class _Chunk {
15361
15433
  computeTangents,
15362
15434
  createCanvas,
15363
15435
  createFluidGeometry,
15436
+ createGuiTextureGeometry,
15364
15437
  createImage,
15365
15438
  entityAnimationTime,
15366
15439
  estimateBytesUsed,