minerender 2.1.0-alpha.48 → 2.1.0-alpha.49

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.
@@ -839,6 +839,31 @@ var init_Materials = __esm({
839
839
  alphaTest: 0.5
840
840
  });
841
841
  }
842
+ static createGuiCanvasMaterial(canvas) {
843
+ const material = new import_three5.MeshBasicMaterial({
844
+ map: Textures.createCanvasTexture(canvas),
845
+ transparent: true,
846
+ depthWrite: false,
847
+ side: import_three5.DoubleSide,
848
+ toneMapped: false
849
+ });
850
+ material.onBeforeCompile = (shader) => {
851
+ for (const [stage, direction] of [["vertex", "out"], ["fragment", "in"]]) {
852
+ const chunk = `uv_pars_${stage}`;
853
+ shader[`${stage}Shader`] = shader[`${stage}Shader`].replace(
854
+ `#include <${chunk}>`,
855
+ import_three5.ShaderChunk[chunk].replace("varying vec2 vMapUv;", `
856
+ #if __VERSION__ >= 300
857
+ centroid ${direction} vec2 vMapUv;
858
+ #else
859
+ varying vec2 vMapUv;
860
+ #endif
861
+ `)
862
+ );
863
+ }
864
+ };
865
+ return material;
866
+ }
842
867
  static createShadedCanvasMaterial(canvas, transparent = false, shade = false) {
843
868
  const vertShader = `
844
869
  uniform bool SHADE;
@@ -2985,6 +3010,10 @@ var init_SceneObject = __esm({
2985
3010
  async init() {
2986
3011
  }
2987
3012
  notifyDirty() {
3013
+ this.traverseAncestors((parent) => {
3014
+ const scene = parent;
3015
+ if (scene.isMineRenderScene) scene.dirty = true;
3016
+ });
2988
3017
  this.dispatchEvent(changeEvent);
2989
3018
  }
2990
3019
  //<editor-fold desc="GROUPS">
@@ -3328,6 +3357,7 @@ var init_SceneObject = __esm({
3328
3357
  } else {
3329
3358
  object.visible = !object.visible;
3330
3359
  }
3360
+ this.notifyDirty();
3331
3361
  return object.visible;
3332
3362
  }
3333
3363
  this.notifyDirty();
@@ -3360,8 +3390,8 @@ var init_SceneObject = __esm({
3360
3390
  this.notifyDirty();
3361
3391
  }
3362
3392
  removeFromScene() {
3363
- this._scene?.remove(this);
3364
3393
  this.notifyDirty();
3394
+ this.removeFromParent();
3365
3395
  }
3366
3396
  //</editor-fold>
3367
3397
  };
@@ -3376,16 +3406,16 @@ var init_SceneObject = __esm({
3376
3406
  });
3377
3407
 
3378
3408
  // src/model/ModelCulling.ts
3379
- var import_three16, ModelCulling;
3409
+ var import_three17, ModelCulling;
3380
3410
  var init_ModelCulling = __esm({
3381
3411
  "src/model/ModelCulling.ts"() {
3382
- import_three16 = require("three");
3412
+ import_three17 = require("three");
3383
3413
  init_CubeFace();
3384
3414
  ModelCulling = class {
3385
3415
  static toLocalMask(worldMask, rotation) {
3386
3416
  let localMask = 0;
3387
3417
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
3388
- const normal = new import_three16.Vector3(...offset).applyEuler(rotation);
3418
+ const normal = new import_three17.Vector3(...offset).applyEuler(rotation);
3389
3419
  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);
3390
3420
  if (worldFace < 0) return 0;
3391
3421
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -3429,7 +3459,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
3429
3459
  const attributes = {};
3430
3460
  const morphAttributes = {};
3431
3461
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
3432
- const mergedGeometry = new import_three18.BufferGeometry();
3462
+ const mergedGeometry = new import_three19.BufferGeometry();
3433
3463
  let offset = 0;
3434
3464
  for (let i = 0; i < geometries.length; ++i) {
3435
3465
  const geometry = geometries[i];
@@ -3553,7 +3583,7 @@ function mergeBufferAttributes(attributes) {
3553
3583
  array.set(attributes[i].array, offset);
3554
3584
  offset += attributes[i].array.length;
3555
3585
  }
3556
- return new import_three18.BufferAttribute(array, itemSize, normalized);
3586
+ return new import_three19.BufferAttribute(array, itemSize, normalized);
3557
3587
  }
3558
3588
  function interleaveAttributes(attributes) {
3559
3589
  let TypedArray;
@@ -3569,7 +3599,7 @@ function interleaveAttributes(attributes) {
3569
3599
  arrayLength += attribute.array.length;
3570
3600
  stride += attribute.itemSize;
3571
3601
  }
3572
- const interleavedBuffer = new import_three18.InterleavedBuffer(new TypedArray(arrayLength), stride);
3602
+ const interleavedBuffer = new import_three19.InterleavedBuffer(new TypedArray(arrayLength), stride);
3573
3603
  let offset = 0;
3574
3604
  const res = [];
3575
3605
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -3578,7 +3608,7 @@ function interleaveAttributes(attributes) {
3578
3608
  const attribute = attributes[j];
3579
3609
  const itemSize = attribute.itemSize;
3580
3610
  const count = attribute.count;
3581
- const iba = new import_three18.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3611
+ const iba = new import_three19.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3582
3612
  res.push(iba);
3583
3613
  offset += itemSize;
3584
3614
  for (let c = 0; c < count; c++) {
@@ -3662,13 +3692,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3662
3692
  const name = attributeNames[i];
3663
3693
  const oldAttribute = geometry.getAttribute(name);
3664
3694
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
3665
- const attribute = new import_three18.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3695
+ const attribute = new import_three19.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3666
3696
  result.setAttribute(name, attribute);
3667
3697
  if (name in morphAttrsArrays) {
3668
3698
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
3669
3699
  const oldMorphAttribute = geometry.morphAttributes[name][j];
3670
3700
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
3671
- const morphAttribute = new import_three18.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3701
+ const morphAttribute = new import_three19.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3672
3702
  result.morphAttributes[name][j] = morphAttribute;
3673
3703
  }
3674
3704
  }
@@ -3677,11 +3707,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3677
3707
  return result;
3678
3708
  }
3679
3709
  function toTrianglesDrawMode(geometry, drawMode) {
3680
- if (drawMode === import_three18.TrianglesDrawMode) {
3710
+ if (drawMode === import_three19.TrianglesDrawMode) {
3681
3711
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
3682
3712
  return geometry;
3683
3713
  }
3684
- if (drawMode === import_three18.TriangleFanDrawMode || drawMode === import_three18.TriangleStripDrawMode) {
3714
+ if (drawMode === import_three19.TriangleFanDrawMode || drawMode === import_three19.TriangleStripDrawMode) {
3685
3715
  let index = geometry.getIndex();
3686
3716
  if (index === null) {
3687
3717
  const indices = [];
@@ -3699,7 +3729,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
3699
3729
  }
3700
3730
  const numberOfTriangles = index.count - 2;
3701
3731
  const newIndices = [];
3702
- if (drawMode === import_three18.TriangleFanDrawMode) {
3732
+ if (drawMode === import_three19.TriangleFanDrawMode) {
3703
3733
  for (let i = 1; i <= numberOfTriangles; i++) {
3704
3734
  newIndices.push(index.getX(0));
3705
3735
  newIndices.push(index.getX(i));
@@ -3735,15 +3765,15 @@ function computeMorphedAttributes(object) {
3735
3765
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
3736
3766
  return null;
3737
3767
  }
3738
- const _vA = new import_three18.Vector3();
3739
- const _vB = new import_three18.Vector3();
3740
- const _vC = new import_three18.Vector3();
3741
- const _tempA = new import_three18.Vector3();
3742
- const _tempB = new import_three18.Vector3();
3743
- const _tempC = new import_three18.Vector3();
3744
- const _morphA = new import_three18.Vector3();
3745
- const _morphB = new import_three18.Vector3();
3746
- const _morphC = new import_three18.Vector3();
3768
+ const _vA = new import_three19.Vector3();
3769
+ const _vB = new import_three19.Vector3();
3770
+ const _vC = new import_three19.Vector3();
3771
+ const _tempA = new import_three19.Vector3();
3772
+ const _tempB = new import_three19.Vector3();
3773
+ const _tempC = new import_three19.Vector3();
3774
+ const _morphA = new import_three19.Vector3();
3775
+ const _morphB = new import_three19.Vector3();
3776
+ const _morphC = new import_three19.Vector3();
3747
3777
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
3748
3778
  _vA.fromBufferAttribute(attribute, a2);
3749
3779
  _vB.fromBufferAttribute(attribute, b2);
@@ -3938,8 +3968,8 @@ function computeMorphedAttributes(object) {
3938
3968
  }
3939
3969
  }
3940
3970
  }
3941
- const morphedPositionAttribute = new import_three18.Float32BufferAttribute(modifiedPosition, 3);
3942
- const morphedNormalAttribute = new import_three18.Float32BufferAttribute(modifiedNormal, 3);
3971
+ const morphedPositionAttribute = new import_three19.Float32BufferAttribute(modifiedPosition, 3);
3972
+ const morphedNormalAttribute = new import_three19.Float32BufferAttribute(modifiedNormal, 3);
3943
3973
  return {
3944
3974
  positionAttribute,
3945
3975
  normalAttribute,
@@ -3947,10 +3977,10 @@ function computeMorphedAttributes(object) {
3947
3977
  morphedNormalAttribute
3948
3978
  };
3949
3979
  }
3950
- var import_three18;
3980
+ var import_three19;
3951
3981
  var init_BufferGeometryUtils = __esm({
3952
3982
  "src/three/BufferGeometryUtils.js"() {
3953
- import_three18 = require("three");
3983
+ import_three19 = require("three");
3954
3984
  }
3955
3985
  });
3956
3986
 
@@ -3958,13 +3988,13 @@ var init_BufferGeometryUtils = __esm({
3958
3988
  function isModelObject(obj) {
3959
3989
  return obj.isModelObject;
3960
3990
  }
3961
- var import_three19, import_ts_deepmerge5, p9, _ModelObject, ModelObject;
3991
+ var import_three20, import_ts_deepmerge5, p9, _ModelObject, ModelObject;
3962
3992
  var init_ModelObject = __esm({
3963
3993
  "src/model/scene/ModelObject.ts"() {
3964
3994
  init_SceneObject();
3965
3995
  init_Materials();
3966
3996
  init_UVMapper();
3967
- import_three19 = require("three");
3997
+ import_three20 = require("three");
3968
3998
  init_BufferGeometryUtils();
3969
3999
  init_model();
3970
4000
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -4019,7 +4049,7 @@ var init_ModelObject = __esm({
4019
4049
  elGeo.clearGroups();
4020
4050
  }
4021
4051
  if (this.options.uvLockRotation) {
4022
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three19.Euler(...this.options.uvLockRotation));
4052
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three20.Euler(...this.options.uvLockRotation));
4023
4053
  }
4024
4054
  if (this.options.tints) {
4025
4055
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -4028,19 +4058,19 @@ var init_ModelObject = __esm({
4028
4058
  if (tintIndex === void 0 || tintIndex < 0) continue;
4029
4059
  const tint = this.options.tints[tintIndex];
4030
4060
  if (tint === void 0) continue;
4031
- const color = new import_three19.Color(tint);
4061
+ const color = new import_three20.Color(tint);
4032
4062
  for (let vertex = 0; vertex < 4; vertex++) {
4033
4063
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
4034
4064
  }
4035
4065
  }
4036
- elGeo.setAttribute("color", new import_three19.BufferAttribute(colors, 3));
4066
+ elGeo.setAttribute("color", new import_three20.BufferAttribute(colors, 3));
4037
4067
  }
4038
- elGeo.applyMatrix4(new import_three19.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4039
- elGeo.applyMatrix4(new import_three19.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4068
+ elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4069
+ elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4040
4070
  if (el.rotation) {
4041
4071
  applyElementRotation(el.rotation, elGeo);
4042
4072
  }
4043
- elGeo.applyMatrix4(new import_three19.Matrix4().makeTranslation(-8, -8, -8));
4073
+ elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation(-8, -8, -8));
4044
4074
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
4045
4075
  if (this.options.mergeMeshes) {
4046
4076
  allGeos.push(elGeo);
@@ -4062,7 +4092,7 @@ var init_ModelObject = __esm({
4062
4092
  if (allGeos.length > 0) {
4063
4093
  combinedGeo = mergeBufferGeometries(allGeos);
4064
4094
  } else {
4065
- combinedGeo = new import_three19.BoxGeometry(16, 16, 16);
4095
+ combinedGeo = new import_three20.BoxGeometry(16, 16, 16);
4066
4096
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
4067
4097
  }
4068
4098
  combinedGeo.computeBoundingBox();
@@ -4172,7 +4202,7 @@ function ownHeight(sample) {
4172
4202
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
4173
4203
  }
4174
4204
  function createFluidGeometry(kind, sample) {
4175
- const geometry = new import_three20.BufferGeometry();
4205
+ const geometry = new import_three21.BufferGeometry();
4176
4206
  const positions = [], normals = [], uvs = [], indices = [];
4177
4207
  const self = sample(0, 0, 0);
4178
4208
  const height = (x, z) => {
@@ -4271,16 +4301,16 @@ function createFluidGeometry(kind, sample) {
4271
4301
  1
4272
4302
  );
4273
4303
  }
4274
- geometry.setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3));
4275
- geometry.setAttribute("normal", new import_three20.Float32BufferAttribute(normals, 3));
4276
- geometry.setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2));
4304
+ geometry.setAttribute("position", new import_three21.Float32BufferAttribute(positions, 3));
4305
+ geometry.setAttribute("normal", new import_three21.Float32BufferAttribute(normals, 3));
4306
+ geometry.setAttribute("uv", new import_three21.Float32BufferAttribute(uvs, 2));
4277
4307
  geometry.setIndex(indices);
4278
4308
  return geometry;
4279
4309
  }
4280
- var import_three20, fluidRules, HORIZONTAL, EPSILON;
4310
+ var import_three21, fluidRules, HORIZONTAL, EPSILON;
4281
4311
  var init_FluidGeometry = __esm({
4282
4312
  "src/model/fluid/FluidGeometry.ts"() {
4283
- import_three20 = require("three");
4313
+ import_three21 = require("three");
4284
4314
  init_fluidBlocks();
4285
4315
  fluidRules = fluidBlocks_default;
4286
4316
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -4309,10 +4339,10 @@ function sampleFluid(kind, sample) {
4309
4339
  }
4310
4340
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
4311
4341
  }
4312
- var import_three21, FluidModelObject;
4342
+ var import_three22, FluidModelObject;
4313
4343
  var init_FluidModelObject = __esm({
4314
4344
  "src/model/fluid/FluidModelObject.ts"() {
4315
- import_three21 = require("three");
4345
+ import_three22 = require("three");
4316
4346
  init_AssetKey();
4317
4347
  init_Materials();
4318
4348
  init_ModelObject();
@@ -4345,10 +4375,10 @@ var init_FluidModelObject = __esm({
4345
4375
  }
4346
4376
  }
4347
4377
  geometry.clearGroups();
4348
- const color = new import_three21.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4378
+ const color = new import_three22.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4349
4379
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
4350
4380
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
4351
- geometry.setAttribute("color", new import_three21.BufferAttribute(colors, 3));
4381
+ geometry.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
4352
4382
  geometry.computeBoundingBox();
4353
4383
  geometry.computeBoundingSphere();
4354
4384
  if (this.options.instanceMeshes) {
@@ -4362,7 +4392,7 @@ var init_FluidModelObject = __esm({
4362
4392
  super.applyTextures();
4363
4393
  this.iterateAllMeshes((mesh) => {
4364
4394
  const material = mesh.material;
4365
- material.side = import_three21.DoubleSide;
4395
+ material.side = import_three22.DoubleSide;
4366
4396
  material.forceSinglePass = true;
4367
4397
  material.depthWrite = !material.transparent;
4368
4398
  });
@@ -4421,6 +4451,7 @@ __export(index_browser_exports, {
4421
4451
  Env: () => Env,
4422
4452
  FluidModelObject: () => FluidModelObject,
4423
4453
  Geometries: () => Geometries,
4454
+ GuiHelper: () => GuiHelper,
4424
4455
  GuiLight: () => GuiLight,
4425
4456
  GuiObject: () => GuiObject,
4426
4457
  HostedAssetSource: () => HostedAssetSource,
@@ -4498,6 +4529,7 @@ __export(index_browser_exports, {
4498
4529
  isDisposable: () => isDisposable,
4499
4530
  isDoubleArray: () => isDoubleArray,
4500
4531
  isEntityObject: () => isEntityObject,
4532
+ isGuiObject: () => isGuiObject,
4501
4533
  isInstanceManager: () => isInstanceManager,
4502
4534
  isInstanceReference: () => isInstanceReference,
4503
4535
  isInstanceable: () => isInstanceable,
@@ -5038,17 +5070,106 @@ function isEntityObject(obj) {
5038
5070
  // src/error/index.ts
5039
5071
  init_MineRenderError();
5040
5072
 
5073
+ // src/gui/GuiHelper.ts
5074
+ var GuiHelper = class {
5075
+ static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
5076
+ const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
5077
+ return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
5078
+ }
5079
+ };
5080
+
5041
5081
  // src/gui/scene/GuiObject.ts
5082
+ var import_three14 = require("three");
5083
+ init_AssetKey();
5084
+ init_ModelTextures();
5085
+ init_Caching();
5042
5086
  init_SceneObject();
5087
+ init_Materials();
5043
5088
  var GuiObject = class extends SceneObject {
5044
- //TODO
5089
+ constructor(textureLayers, options) {
5090
+ super({ ...options, instanceMeshes: false, mergeMeshes: false });
5091
+ this.textureLayers = textureLayers;
5092
+ this.isGuiObject = true;
5093
+ /** Local bounds in GUI pixels, with y growing down from the origin. */
5094
+ this.bounds = new import_three14.Box2();
5095
+ this.geometries = /* @__PURE__ */ new Set();
5096
+ this.ownedMaterials = /* @__PURE__ */ new Set();
5097
+ this.initialized = false;
5098
+ }
5099
+ async init() {
5100
+ if (this.initialized) return;
5101
+ try {
5102
+ for (const [index, layer] of this.textureLayers.entries()) {
5103
+ const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
5104
+ const material = await this.loadMaterial(key);
5105
+ const image = material.map.image;
5106
+ const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
5107
+ const [width, height] = layer.size ?? [cropWidth, cropHeight];
5108
+ const [x, y] = layer.position ?? [0, 0];
5109
+ const geometry = new import_three14.PlaneGeometry(width, height);
5110
+ this.geometries.add(geometry);
5111
+ const uv = geometry.getAttribute("uv");
5112
+ for (let i = 0; i < uv.count; i++) {
5113
+ uv.setXY(
5114
+ i,
5115
+ (cropX + uv.getX(i) * cropWidth) / image.width,
5116
+ 1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
5117
+ );
5118
+ }
5119
+ const mesh = new import_three14.Mesh(geometry, material);
5120
+ mesh.name = `mesh:${layer.name ?? index}`;
5121
+ mesh.position.set(x + width / 2, -y - height / 2, 0);
5122
+ mesh.renderOrder = index;
5123
+ this.add(mesh);
5124
+ this.bounds.expandByPoint(new import_three14.Vector2(x, y));
5125
+ this.bounds.expandByPoint(new import_three14.Vector2(x + width, y + height));
5126
+ }
5127
+ this.initialized = true;
5128
+ this.notifyDirty();
5129
+ } catch (error) {
5130
+ this.disposeAndRemoveAllChildren();
5131
+ throw error;
5132
+ }
5133
+ }
5134
+ async loadMaterial(key) {
5135
+ const assetKey = key.serialize();
5136
+ const materialKey = `gui:${assetKey}`;
5137
+ const cached2 = Caching.materialCache.getIfPresent(materialKey);
5138
+ if (cached2) return cached2;
5139
+ const pending = ModelTextures.get(key);
5140
+ const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKey);
5141
+ const image = await pending;
5142
+ if (!image) throw new Error(`Could not load GUI texture ${key.toNamespacedString()}`);
5143
+ const create = () => Materials.createGuiCanvasMaterial(image.data.canvas);
5144
+ if (cachedAsset && Caching.textureAssetCache.getIfPresent(assetKey) === cachedAsset) {
5145
+ return Caching.materialCache.get(materialKey, create);
5146
+ }
5147
+ const material = create();
5148
+ this.ownedMaterials.add(material);
5149
+ return material;
5150
+ }
5151
+ disposeAndRemoveAllChildren() {
5152
+ for (const geometry of this.geometries) geometry.dispose();
5153
+ this.geometries.clear();
5154
+ for (const material of this.ownedMaterials) {
5155
+ material.map.dispose();
5156
+ material.dispose();
5157
+ }
5158
+ this.ownedMaterials.clear();
5159
+ this.bounds.makeEmpty();
5160
+ this.initialized = false;
5161
+ super.disposeAndRemoveAllChildren();
5162
+ }
5045
5163
  };
5164
+ function isGuiObject(obj) {
5165
+ return obj.isGuiObject;
5166
+ }
5046
5167
 
5047
5168
  // src/index.ts
5048
5169
  init_image();
5049
5170
 
5050
5171
  // src/inspector/SceneInspector.ts
5051
- var import_three14 = require("three");
5172
+ var import_three15 = require("three");
5052
5173
  init_SceneObject();
5053
5174
  init_util();
5054
5175
  init_log();
@@ -5058,11 +5179,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
5058
5179
  var SceneInspector = class {
5059
5180
  constructor(renderer) {
5060
5181
  this.renderer = renderer;
5061
- this.mouse = new import_three14.Vector2();
5182
+ this.mouse = new import_three15.Vector2();
5062
5183
  this.listeners = new AbortController();
5063
5184
  this.objectInfoContainer = document.createElement("div");
5064
5185
  this.objectControlsContainer = document.createElement("div");
5065
- this.raycaster = new import_three14.Raycaster();
5186
+ this.raycaster = new import_three15.Raycaster();
5066
5187
  this.init();
5067
5188
  }
5068
5189
  init() {
@@ -5478,7 +5599,7 @@ init_ModelGenerator();
5478
5599
  init_ModelMerger();
5479
5600
 
5480
5601
  // src/model/block/BlockStateResolver.ts
5481
- var import_three17 = require("three");
5602
+ var import_three18 = require("three");
5482
5603
  init_BlockStates();
5483
5604
  init_MineRenderError();
5484
5605
  init_util();
@@ -5556,7 +5677,7 @@ var BlockStateResolver = class {
5556
5677
  return variants[variants.length - 1];
5557
5678
  }
5558
5679
  static rotation(variant) {
5559
- const rotation = new import_three17.Euler();
5680
+ const rotation = new import_three18.Euler();
5560
5681
  if (typeof variant.x !== "undefined") {
5561
5682
  rotation.x = toRadians(clampRotationDegrees(variant.x));
5562
5683
  }
@@ -5663,7 +5784,7 @@ init_SceneObject();
5663
5784
  init_ModelObject();
5664
5785
  init_Models();
5665
5786
  var import_ts_deepmerge6 = __toESM(require_dist());
5666
- var import_three22 = require("three");
5787
+ var import_three23 = require("three");
5667
5788
  init_MineRenderError();
5668
5789
  init_InstanceReference();
5669
5790
  init_AssetKey();
@@ -5727,12 +5848,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
5727
5848
  getModelCullMask(model, worldMask) {
5728
5849
  const object = isInstanceReference(model) ? model.instanceable : model;
5729
5850
  if (object.options.displayPosition) return 0;
5730
- const position = new import_three22.Vector3();
5731
- const rotation = new import_three22.Quaternion();
5732
- const scale = new import_three22.Vector3();
5851
+ const position = new import_three23.Vector3();
5852
+ const rotation = new import_three23.Quaternion();
5853
+ const scale = new import_three23.Vector3();
5733
5854
  this.getModelMatrix(model).decompose(position, rotation, scale);
5734
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three22.Vector3(1, 1, 1)) > 1e-10) return 0;
5735
- return ModelCulling.toLocalMask(worldMask, new import_three22.Euler().setFromQuaternion(rotation));
5855
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three23.Vector3(1, 1, 1)) > 1e-10) return 0;
5856
+ return ModelCulling.toLocalMask(worldMask, new import_three23.Euler().setFromQuaternion(rotation));
5736
5857
  }
5737
5858
  async setCullMask(worldMask) {
5738
5859
  worldMask &= 63;
@@ -5794,7 +5915,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
5794
5915
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
5795
5916
  );
5796
5917
  const previous = this._fluidModel;
5797
- const matrix = previous ? this.getModelMatrix(previous) : new import_three22.Matrix4().makeTranslation(...this.position.toArray());
5918
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three23.Matrix4().makeTranslation(...this.position.toArray());
5798
5919
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
5799
5920
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
5800
5921
  this._models = this._models.filter((model) => model !== previous);
@@ -5925,7 +6046,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
5925
6046
  setPositionRotationScaleAt(index, position, rotation, scale) {
5926
6047
  super.setPositionRotationScaleAt(index, position, rotation, scale);
5927
6048
  }
5928
- getMatrixAt(index, matrix = new import_three22.Matrix4()) {
6049
+ getMatrixAt(index, matrix = new import_three23.Matrix4()) {
5929
6050
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
5930
6051
  const child = this._models[0];
5931
6052
  if (child && isModelObject(child)) {
@@ -7795,7 +7916,7 @@ init_ModelObject();
7795
7916
  init_nbt();
7796
7917
 
7797
7918
  // src/renderer/MineRenderScene.ts
7798
- var import_three24 = require("three");
7919
+ var import_three25 = require("three");
7799
7920
  init_SceneObject();
7800
7921
  var import_ts_deepmerge8 = __toESM(require_dist());
7801
7922
  init_ModelObject();
@@ -8528,7 +8649,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
8528
8649
  init_util();
8529
8650
 
8530
8651
  // src/skin/SkinTextures.ts
8531
- var import_three23 = require("three");
8652
+ var import_three24 = require("three");
8532
8653
  init_Caching();
8533
8654
  init_CacheKey();
8534
8655
  init_MineRenderError();
@@ -8612,11 +8733,11 @@ var SkinTextures = class {
8612
8733
  });
8613
8734
  }
8614
8735
  static createMaterial(pixels, width, height, transparent = true) {
8615
- const texture = Textures.initTextureProps(new import_three23.DataTexture(pixels, width, height));
8616
- texture.colorSpace = import_three23.SRGBColorSpace;
8736
+ const texture = Textures.initTextureProps(new import_three24.DataTexture(pixels, width, height));
8737
+ texture.colorSpace = import_three24.SRGBColorSpace;
8617
8738
  texture.flipY = true;
8618
8739
  texture.needsUpdate = true;
8619
- return new import_three23.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three23.DoubleSide : import_three23.FrontSide, alphaTest: transparent ? 0.1 : 0 });
8740
+ return new import_three24.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three24.DoubleSide : import_three24.FrontSide, alphaTest: transparent ? 0.1 : 0 });
8620
8741
  }
8621
8742
  static isSlim(image, scale) {
8622
8743
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -8843,7 +8964,7 @@ var SkinObject = class extends SceneObject {
8843
8964
  };
8844
8965
 
8845
8966
  // src/renderer/MineRenderScene.ts
8846
- var _MineRenderScene = class _MineRenderScene extends import_three24.Scene {
8967
+ var _MineRenderScene = class _MineRenderScene extends import_three25.Scene {
8847
8968
  constructor(options) {
8848
8969
  super();
8849
8970
  this.isMineRenderScene = true;
@@ -8959,6 +9080,14 @@ var _MineRenderScene = class _MineRenderScene extends import_three24.Scene {
8959
9080
  async addEntity(entity, options, parent = this) {
8960
9081
  return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
8961
9082
  }
9083
+ async addGui(layers, options, parent = this) {
9084
+ const obj = new GuiObject(layers, options);
9085
+ obj.scene = this;
9086
+ await obj.init();
9087
+ parent.add(obj);
9088
+ this.dirty = true;
9089
+ return obj;
9090
+ }
8962
9091
  };
8963
9092
  _MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
8964
9093
  var MineRenderScene = _MineRenderScene;
@@ -8967,7 +9096,7 @@ function isMineRenderScene(obj) {
8967
9096
  }
8968
9097
 
8969
9098
  // src/renderer/Renderer.ts
8970
- var import_three26 = require("three");
9099
+ var import_three27 = require("three");
8971
9100
  var import_ts_deepmerge9 = __toESM(require_dist());
8972
9101
  var import_stats = __toESM(require("stats.js"));
8973
9102
  var import_postprocessing = require("postprocessing");
@@ -8975,11 +9104,11 @@ init_util();
8975
9104
  init_three();
8976
9105
 
8977
9106
  // src/three/OrbitControls.js
8978
- var import_three25 = require("three");
9107
+ var import_three26 = require("three");
8979
9108
  var _changeEvent = { type: "change" };
8980
9109
  var _startEvent = { type: "start" };
8981
9110
  var _endEvent = { type: "end" };
8982
- var OrbitControls = class extends import_three25.EventDispatcher {
9111
+ var OrbitControls = class extends import_three26.EventDispatcher {
8983
9112
  constructor(object, domElement) {
8984
9113
  super();
8985
9114
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -8988,7 +9117,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
8988
9117
  this.domElement = domElement;
8989
9118
  this.domElement.style.touchAction = "none";
8990
9119
  this.enabled = true;
8991
- this.target = new import_three25.Vector3();
9120
+ this.target = new import_three26.Vector3();
8992
9121
  this.minDistance = 0;
8993
9122
  this.maxDistance = Infinity;
8994
9123
  this.minZoom = 0;
@@ -9010,8 +9139,8 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9010
9139
  this.autoRotate = false;
9011
9140
  this.autoRotateSpeed = 2;
9012
9141
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
9013
- this.mouseButtons = { LEFT: import_three25.MOUSE.ROTATE, MIDDLE: import_three25.MOUSE.DOLLY, RIGHT: import_three25.MOUSE.PAN };
9014
- this.touches = { ONE: import_three25.TOUCH.ROTATE, TWO: import_three25.TOUCH.DOLLY_PAN };
9142
+ this.mouseButtons = { LEFT: import_three26.MOUSE.ROTATE, MIDDLE: import_three26.MOUSE.DOLLY, RIGHT: import_three26.MOUSE.PAN };
9143
+ this.touches = { ONE: import_three26.TOUCH.ROTATE, TWO: import_three26.TOUCH.DOLLY_PAN };
9015
9144
  this.target0 = this.target.clone();
9016
9145
  this.position0 = this.object.position.clone();
9017
9146
  this.zoom0 = this.object.zoom;
@@ -9040,11 +9169,11 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9040
9169
  state = STATE.NONE;
9041
9170
  };
9042
9171
  this.update = function() {
9043
- const offset = new import_three25.Vector3();
9044
- const quat = new import_three25.Quaternion().setFromUnitVectors(object.up, new import_three25.Vector3(0, 1, 0));
9172
+ const offset = new import_three26.Vector3();
9173
+ const quat = new import_three26.Quaternion().setFromUnitVectors(object.up, new import_three26.Vector3(0, 1, 0));
9045
9174
  const quatInverse = quat.clone().invert();
9046
- const lastPosition = new import_three25.Vector3();
9047
- const lastQuaternion = new import_three25.Quaternion();
9175
+ const lastPosition = new import_three26.Vector3();
9176
+ const lastQuaternion = new import_three26.Quaternion();
9048
9177
  const twoPI = 2 * Math.PI;
9049
9178
  return function update() {
9050
9179
  const position = scope.object.position;
@@ -9130,20 +9259,20 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9130
9259
  };
9131
9260
  let state = STATE.NONE;
9132
9261
  const EPS = 1e-6;
9133
- const spherical = new import_three25.Spherical();
9134
- const sphericalDelta = new import_three25.Spherical();
9262
+ const spherical = new import_three26.Spherical();
9263
+ const sphericalDelta = new import_three26.Spherical();
9135
9264
  let scale = 1;
9136
- const panOffset = new import_three25.Vector3();
9265
+ const panOffset = new import_three26.Vector3();
9137
9266
  let zoomChanged = false;
9138
- const rotateStart = new import_three25.Vector2();
9139
- const rotateEnd = new import_three25.Vector2();
9140
- const rotateDelta = new import_three25.Vector2();
9141
- const panStart = new import_three25.Vector2();
9142
- const panEnd = new import_three25.Vector2();
9143
- const panDelta = new import_three25.Vector2();
9144
- const dollyStart = new import_three25.Vector2();
9145
- const dollyEnd = new import_three25.Vector2();
9146
- const dollyDelta = new import_three25.Vector2();
9267
+ const rotateStart = new import_three26.Vector2();
9268
+ const rotateEnd = new import_three26.Vector2();
9269
+ const rotateDelta = new import_three26.Vector2();
9270
+ const panStart = new import_three26.Vector2();
9271
+ const panEnd = new import_three26.Vector2();
9272
+ const panDelta = new import_three26.Vector2();
9273
+ const dollyStart = new import_three26.Vector2();
9274
+ const dollyEnd = new import_three26.Vector2();
9275
+ const dollyDelta = new import_three26.Vector2();
9147
9276
  const pointers = [];
9148
9277
  const pointerPositions = {};
9149
9278
  function getAutoRotationAngle() {
@@ -9159,7 +9288,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9159
9288
  sphericalDelta.phi -= angle;
9160
9289
  }
9161
9290
  const panLeft = function() {
9162
- const v = new import_three25.Vector3();
9291
+ const v = new import_three26.Vector3();
9163
9292
  return function panLeft2(distance, objectMatrix) {
9164
9293
  v.setFromMatrixColumn(objectMatrix, 0);
9165
9294
  v.multiplyScalar(-distance);
@@ -9167,7 +9296,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9167
9296
  };
9168
9297
  }();
9169
9298
  const panUp = function() {
9170
- const v = new import_three25.Vector3();
9299
+ const v = new import_three26.Vector3();
9171
9300
  return function panUp2(distance, objectMatrix) {
9172
9301
  if (scope.screenSpacePanning === true) {
9173
9302
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -9180,7 +9309,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9180
9309
  };
9181
9310
  }();
9182
9311
  const pan = function() {
9183
- const offset = new import_three25.Vector3();
9312
+ const offset = new import_three26.Vector3();
9184
9313
  return function pan2(deltaX, deltaY) {
9185
9314
  const element = scope.domElement;
9186
9315
  if (scope.object.isPerspectiveCamera) {
@@ -9429,12 +9558,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9429
9558
  mouseAction = -1;
9430
9559
  }
9431
9560
  switch (mouseAction) {
9432
- case import_three25.MOUSE.DOLLY:
9561
+ case import_three26.MOUSE.DOLLY:
9433
9562
  if (scope.enableZoom === false) return;
9434
9563
  handleMouseDownDolly(event);
9435
9564
  state = STATE.DOLLY;
9436
9565
  break;
9437
- case import_three25.MOUSE.ROTATE:
9566
+ case import_three26.MOUSE.ROTATE:
9438
9567
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
9439
9568
  if (scope.enablePan === false) return;
9440
9569
  handleMouseDownPan(event);
@@ -9445,7 +9574,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9445
9574
  state = STATE.ROTATE;
9446
9575
  }
9447
9576
  break;
9448
- case import_three25.MOUSE.PAN:
9577
+ case import_three26.MOUSE.PAN:
9449
9578
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
9450
9579
  if (scope.enableRotate === false) return;
9451
9580
  handleMouseDownRotate(event);
@@ -9501,12 +9630,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9501
9630
  switch (pointers.length) {
9502
9631
  case 1:
9503
9632
  switch (scope.touches.ONE) {
9504
- case import_three25.TOUCH.ROTATE:
9633
+ case import_three26.TOUCH.ROTATE:
9505
9634
  if (scope.enableRotate === false) return;
9506
9635
  handleTouchStartRotate();
9507
9636
  state = STATE.TOUCH_ROTATE;
9508
9637
  break;
9509
- case import_three25.TOUCH.PAN:
9638
+ case import_three26.TOUCH.PAN:
9510
9639
  if (scope.enablePan === false) return;
9511
9640
  handleTouchStartPan();
9512
9641
  state = STATE.TOUCH_PAN;
@@ -9517,12 +9646,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9517
9646
  break;
9518
9647
  case 2:
9519
9648
  switch (scope.touches.TWO) {
9520
- case import_three25.TOUCH.DOLLY_PAN:
9649
+ case import_three26.TOUCH.DOLLY_PAN:
9521
9650
  if (scope.enableZoom === false && scope.enablePan === false) return;
9522
9651
  handleTouchStartDollyPan();
9523
9652
  state = STATE.TOUCH_DOLLY_PAN;
9524
9653
  break;
9525
- case import_three25.TOUCH.DOLLY_ROTATE:
9654
+ case import_three26.TOUCH.DOLLY_ROTATE:
9526
9655
  if (scope.enableZoom === false && scope.enableRotate === false) return;
9527
9656
  handleTouchStartDollyRotate();
9528
9657
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -9589,7 +9718,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
9589
9718
  function trackPointer(event) {
9590
9719
  let position = pointerPositions[event.pointerId];
9591
9720
  if (position === void 0) {
9592
- position = new import_three25.Vector2();
9721
+ position = new import_three26.Vector2();
9593
9722
  pointerPositions[event.pointerId] = position;
9594
9723
  }
9595
9724
  position.set(event.pageX, event.pageY);
@@ -9609,10 +9738,10 @@ var MapControls = class extends OrbitControls {
9609
9738
  constructor(object, domElement) {
9610
9739
  super(object, domElement);
9611
9740
  this.screenSpacePanning = false;
9612
- this.mouseButtons.LEFT = import_three25.MOUSE.PAN;
9613
- this.mouseButtons.RIGHT = import_three25.MOUSE.ROTATE;
9614
- this.touches.ONE = import_three25.TOUCH.PAN;
9615
- this.touches.TWO = import_three25.TOUCH.DOLLY_ROTATE;
9741
+ this.mouseButtons.LEFT = import_three26.MOUSE.PAN;
9742
+ this.mouseButtons.RIGHT = import_three26.MOUSE.ROTATE;
9743
+ this.touches.ONE = import_three26.TOUCH.PAN;
9744
+ this.touches.TWO = import_three26.TOUCH.DOLLY_ROTATE;
9616
9745
  }
9617
9746
  };
9618
9747
 
@@ -9653,14 +9782,14 @@ var _Renderer = class _Renderer {
9653
9782
  switch (this.options.camera.type) {
9654
9783
  case "perspective":
9655
9784
  default:
9656
- return new import_three26.PerspectiveCamera(
9785
+ return new import_three27.PerspectiveCamera(
9657
9786
  this.options.camera.perspective.fov,
9658
9787
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
9659
9788
  this.options.camera.near,
9660
9789
  this.options.camera.far
9661
9790
  );
9662
9791
  case "orthographic":
9663
- return new import_three26.OrthographicCamera(
9792
+ return new import_three27.OrthographicCamera(
9664
9793
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
9665
9794
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
9666
9795
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -9671,7 +9800,7 @@ var _Renderer = class _Renderer {
9671
9800
  }
9672
9801
  }
9673
9802
  createRenderer() {
9674
- const renderer = new import_three26.WebGLRenderer({
9803
+ const renderer = new import_three27.WebGLRenderer({
9675
9804
  antialias: this.options.render.antialias,
9676
9805
  alpha: true,
9677
9806
  powerPreference: "high-performance",
@@ -9679,8 +9808,8 @@ var _Renderer = class _Renderer {
9679
9808
  });
9680
9809
  renderer.setClearColor(0, 0);
9681
9810
  renderer.shadowMap.enabled = true;
9682
- renderer.shadowMap.type = import_three26.PCFSoftShadowMap;
9683
- renderer.outputColorSpace = import_three26.SRGBColorSpace;
9811
+ renderer.shadowMap.type = import_three27.PCFSoftShadowMap;
9812
+ renderer.outputColorSpace = import_three27.SRGBColorSpace;
9684
9813
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
9685
9814
  renderer.setSize(this.viewWidth, this.viewHeight);
9686
9815
  return renderer;
@@ -9715,20 +9844,20 @@ var _Renderer = class _Renderer {
9715
9844
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
9716
9845
  }
9717
9846
  if (this.options.debug.grid) {
9718
- const gridHelper = new import_three26.GridHelper(128, 16);
9847
+ const gridHelper = new import_three27.GridHelper(128, 16);
9719
9848
  this._debugHelpers.push(gridHelper);
9720
9849
  this.scene.add(gridHelper);
9721
- const gridHelper2 = new import_three26.GridHelper(128, 16);
9850
+ const gridHelper2 = new import_three27.GridHelper(128, 16);
9722
9851
  this._debugHelpers.push(gridHelper2);
9723
9852
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
9724
9853
  this.scene.add(gridHelper2);
9725
- const gridHelper3 = new import_three26.GridHelper(128, 16);
9854
+ const gridHelper3 = new import_three27.GridHelper(128, 16);
9726
9855
  this._debugHelpers.push(gridHelper3);
9727
9856
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
9728
9857
  this.scene.add(gridHelper3);
9729
9858
  }
9730
9859
  if (this.options.debug.axes) {
9731
- const axesHelper = new import_three26.AxesHelper(64);
9860
+ const axesHelper = new import_three27.AxesHelper(64);
9732
9861
  this._debugHelpers.push(axesHelper);
9733
9862
  this.scene.add(axesHelper);
9734
9863
  }
@@ -9932,8 +10061,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
9932
10061
  top: void 0,
9933
10062
  bottom: void 0
9934
10063
  },
9935
- position: new import_three26.Vector3(50, 50, 50),
9936
- lookingAt: new import_three26.Vector3(0, 0, 0)
10064
+ position: new import_three27.Vector3(50, 50, 50),
10065
+ lookingAt: new import_three27.Vector3(0, 0, 0)
9937
10066
  },
9938
10067
  render: {
9939
10068
  fpsLimit: 60,
@@ -10397,19 +10526,19 @@ var AnvilParser = class {
10397
10526
  };
10398
10527
 
10399
10528
  // src/world/Chunk.ts
10400
- var import_three31 = require("three");
10529
+ var import_three32 = require("three");
10401
10530
  init_BlockStates();
10402
10531
  init_AssetKey();
10403
10532
 
10404
10533
  // src/world/MineRenderWorld.ts
10405
- var import_three29 = require("three");
10534
+ var import_three30 = require("three");
10406
10535
  init_BatchedExecutor();
10407
10536
  init_AssetKey();
10408
10537
  init_BlockStates();
10409
10538
  init_CubeFace();
10410
10539
 
10411
10540
  // src/world/SectionModels.ts
10412
- var import_three28 = require("three");
10541
+ var import_three29 = require("three");
10413
10542
  init_AssetKey();
10414
10543
  init_Models();
10415
10544
  init_CubeFace();
@@ -10475,12 +10604,12 @@ var SectionModels = class {
10475
10604
  });
10476
10605
  await object.init();
10477
10606
  const geometry = object.children[0].geometry;
10478
- geometry.applyMatrix4(new import_three28.Matrix4().makeRotationFromEuler(rotation));
10607
+ geometry.applyMatrix4(new import_three29.Matrix4().makeRotationFromEuler(rotation));
10479
10608
  object.clear();
10480
10609
  const cullFaces = CUBE_FACES.map((face) => {
10481
10610
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
10482
10611
  if (local < 0) return 0;
10483
- const normal = new import_three28.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
10612
+ const normal = new import_three29.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
10484
10613
  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);
10485
10614
  return 1 << world;
10486
10615
  });
@@ -10510,20 +10639,20 @@ var MineRenderWorld = class {
10510
10639
  }
10511
10640
  getBlockAt(posOrX, y, z) {
10512
10641
  if (typeof posOrX == "number") {
10513
- return this.getBlockAt(new import_three29.Vector3(posOrX, y, z));
10642
+ return this.getBlockAt(new import_three30.Vector3(posOrX, y, z));
10514
10643
  }
10515
10644
  if (isTripleArray(posOrX)) {
10516
- return this.getBlockAt(new import_three29.Vector3(posOrX[0], posOrX[1], posOrX[2]));
10645
+ return this.getBlockAt(new import_three30.Vector3(posOrX[0], posOrX[1], posOrX[2]));
10517
10646
  }
10518
10647
  this.validatePosBounds(posOrX);
10519
10648
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
10520
10649
  }
10521
10650
  async setBlockAt(posOrX, yOrBlock, z, block) {
10522
10651
  if (typeof posOrX == "number") {
10523
- return this.setBlockAt(new import_three29.Vector3(posOrX, yOrBlock, z), block);
10652
+ return this.setBlockAt(new import_three30.Vector3(posOrX, yOrBlock, z), block);
10524
10653
  }
10525
10654
  if (isTripleArray(posOrX)) {
10526
- return this.setBlockAt(new import_three29.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
10655
+ return this.setBlockAt(new import_three30.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
10527
10656
  }
10528
10657
  return this.placeBlock(posOrX, yOrBlock);
10529
10658
  }
@@ -10544,7 +10673,7 @@ var MineRenderWorld = class {
10544
10673
  const collect = async (positions2) => {
10545
10674
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
10546
10675
  };
10547
- const place = (block) => this.placeBlock(new import_three29.Vector3(...block.position), block, collect);
10676
+ const place = (block) => this.placeBlock(new import_three30.Vector3(...block.position), block, collect);
10548
10677
  const keys = /* @__PURE__ */ new Map();
10549
10678
  for (const block of multiblock.blocks) {
10550
10679
  if (Chunk.isAir(block)) continue;
@@ -10622,13 +10751,13 @@ var MineRenderWorld = class {
10622
10751
  for (const pos of positions) {
10623
10752
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
10624
10753
  for (const offset of CUBE_FACE_OFFSETS) {
10625
- const neighbor = pos.clone().add(new import_three29.Vector3(...offset));
10754
+ const neighbor = pos.clone().add(new import_three30.Vector3(...offset));
10626
10755
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
10627
10756
  }
10628
10757
  for (let y = -1; y <= 1; y++) {
10629
10758
  for (let z = -1; z <= 1; z++) {
10630
10759
  for (let x = -1; x <= 1; x++) {
10631
- const neighbor = pos.clone().add(new import_three29.Vector3(x, y, z));
10760
+ const neighbor = pos.clone().add(new import_three30.Vector3(x, y, z));
10632
10761
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
10633
10762
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
10634
10763
  }
@@ -10650,7 +10779,7 @@ var MineRenderWorld = class {
10650
10779
  if (!block) continue;
10651
10780
  if (block.object?.fluidKind) {
10652
10781
  await block.object.updateFluid((x, y, z) => {
10653
- const neighbor = pos.clone().add(new import_three29.Vector3(x, y, z));
10782
+ const neighbor = pos.clone().add(new import_three30.Vector3(x, y, z));
10654
10783
  const section = this.getChunkAt(neighbor);
10655
10784
  const object = section?.getBlockAt(neighbor)?.object;
10656
10785
  return {
@@ -10662,7 +10791,7 @@ var MineRenderWorld = class {
10662
10791
  }
10663
10792
  let mask = 0;
10664
10793
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
10665
- const neighbor = pos.clone().add(new import_three29.Vector3(...offset));
10794
+ const neighbor = pos.clone().add(new import_three30.Vector3(...offset));
10666
10795
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
10667
10796
  mask |= 1 << face;
10668
10797
  }
@@ -10696,14 +10825,14 @@ var MineRenderWorld = class {
10696
10825
  return this._chunks.get(this.worldPosToChunkKey(pos));
10697
10826
  }
10698
10827
  static worldToScenePosition(pos) {
10699
- return new import_three29.Vector3(
10828
+ return new import_three30.Vector3(
10700
10829
  pos.x * 16,
10701
10830
  pos.y * 16,
10702
10831
  pos.z * 16
10703
10832
  );
10704
10833
  }
10705
10834
  static sceneToWorldPosition(pos) {
10706
- return new import_three29.Vector3(
10835
+ return new import_three30.Vector3(
10707
10836
  pos.x / 16,
10708
10837
  pos.y / 16,
10709
10838
  pos.z / 16
@@ -10723,10 +10852,10 @@ var MineRenderWorld = class {
10723
10852
  };
10724
10853
 
10725
10854
  // src/world/SectionMesh.ts
10726
- var import_three30 = require("three");
10855
+ var import_three31 = require("three");
10727
10856
  init_CanvasCompat();
10728
10857
  init_Materials();
10729
- var SectionMesh = class _SectionMesh extends import_three30.Group {
10858
+ var SectionMesh = class _SectionMesh extends import_three31.Group {
10730
10859
  constructor() {
10731
10860
  super(...arguments);
10732
10861
  this.ownedMeshes = [];
@@ -10799,18 +10928,18 @@ var SectionMesh = class _SectionMesh extends import_three30.Group {
10799
10928
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
10800
10929
  }
10801
10930
  }
10802
- const geometry = new import_three30.BufferGeometry();
10803
- geometry.setAttribute("position", new import_three30.Float32BufferAttribute(positions, 3));
10804
- geometry.setAttribute("normal", new import_three30.Float32BufferAttribute(normals, 3));
10805
- geometry.setAttribute("uv", new import_three30.Float32BufferAttribute(uvs, 2));
10806
- geometry.setAttribute("color", new import_three30.Float32BufferAttribute(colors, 3));
10931
+ const geometry = new import_three31.BufferGeometry();
10932
+ geometry.setAttribute("position", new import_three31.Float32BufferAttribute(positions, 3));
10933
+ geometry.setAttribute("normal", new import_three31.Float32BufferAttribute(normals, 3));
10934
+ geometry.setAttribute("uv", new import_three31.Float32BufferAttribute(uvs, 2));
10935
+ geometry.setAttribute("color", new import_three31.Float32BufferAttribute(colors, 3));
10807
10936
  geometry.setIndex(indices);
10808
10937
  geometry.computeBoundingBox();
10809
10938
  geometry.computeBoundingSphere();
10810
10939
  const material = Materials.createShadedCanvasMaterial(canvas, false);
10811
10940
  material.vertexColors = true;
10812
10941
  const texture = material.uniforms?.map?.value ?? material.map;
10813
- const mesh = new import_three30.Mesh(geometry, material);
10942
+ const mesh = new import_three31.Mesh(geometry, material);
10814
10943
  section.add(mesh);
10815
10944
  section.ownedMeshes.push({ mesh, texture });
10816
10945
  }
@@ -10844,10 +10973,10 @@ var Chunk = class _Chunk {
10844
10973
  }
10845
10974
  getBlockAt(posOrX, y, z) {
10846
10975
  if (typeof posOrX == "number") {
10847
- return this.getBlockAt(new import_three31.Vector3(posOrX, y, z));
10976
+ return this.getBlockAt(new import_three32.Vector3(posOrX, y, z));
10848
10977
  }
10849
10978
  if (isTripleArray(posOrX)) {
10850
- return this.getBlockAt(new import_three31.Vector3(posOrX[0], posOrX[1], posOrX[2]));
10979
+ return this.getBlockAt(new import_three32.Vector3(posOrX[0], posOrX[1], posOrX[2]));
10851
10980
  }
10852
10981
  const pos = this.worldPosToChunkPos(posOrX);
10853
10982
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -10855,10 +10984,10 @@ var Chunk = class _Chunk {
10855
10984
  }
10856
10985
  async setBlockAt(posOrX, yOrBlock, z, block) {
10857
10986
  if (typeof posOrX == "number") {
10858
- return this.setBlockAt(new import_three31.Vector3(posOrX, yOrBlock, z), block);
10987
+ return this.setBlockAt(new import_three32.Vector3(posOrX, yOrBlock, z), block);
10859
10988
  }
10860
10989
  if (isTripleArray(posOrX)) {
10861
- return this.setBlockAt(new import_three31.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
10990
+ return this.setBlockAt(new import_three32.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
10862
10991
  }
10863
10992
  const worldPos = posOrX;
10864
10993
  const pos = this.worldPosToChunkPos(worldPos);
@@ -10943,7 +11072,7 @@ var Chunk = class _Chunk {
10943
11072
  }
10944
11073
  async clear(onBlocksChanged = this.onBlocksChanged) {
10945
11074
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
10946
- new import_three31.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
11075
+ new import_three32.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
10947
11076
  ));
10948
11077
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
10949
11078
  this.sectionBlocks.clear();
@@ -10967,14 +11096,14 @@ var Chunk = class _Chunk {
10967
11096
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
10968
11097
  }
10969
11098
  worldPosToChunkPos(pos) {
10970
- return new import_three31.Vector3(
11099
+ return new import_three32.Vector3(
10971
11100
  pos.x - this.x * 16,
10972
11101
  pos.y - this.y * 16,
10973
11102
  pos.z - this.z * 16
10974
11103
  );
10975
11104
  }
10976
11105
  chunkPosToWorldPos(pos) {
10977
- return new import_three31.Vector3(
11106
+ return new import_three32.Vector3(
10978
11107
  this.x * 16 + pos.x,
10979
11108
  this.y * 16 + pos.y,
10980
11109
  this.z * 16 + pos.z