minerender 2.1.0-alpha.27 → 2.1.0-alpha.28

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.
@@ -195,6 +195,7 @@ __export(index_browser_exports, {
195
195
  SchematicParser: () => SchematicParser,
196
196
  SkinObject: () => SkinObject,
197
197
  SkinPart: () => SkinPart,
198
+ SkinTextures: () => SkinTextures,
198
199
  Skins: () => Skins,
199
200
  StructureParser: () => StructureParser,
200
201
  TextureAtlas: () => TextureAtlas,
@@ -4913,7 +4914,7 @@ var StructureParser = class {
4913
4914
  };
4914
4915
 
4915
4916
  // src/renderer/MineRenderScene.ts
4916
- var import_three18 = require("three");
4917
+ var import_three19 = require("three");
4917
4918
  var import_ts_deepmerge8 = __toESM(require_dist());
4918
4919
 
4919
4920
  // src/skin/SkinPart.ts
@@ -5680,14 +5681,96 @@ var slimSkinGeometries = {
5680
5681
 
5681
5682
  // src/skin/scene/SkinObject.ts
5682
5683
  var import_ts_deepmerge7 = __toESM(require_dist());
5684
+
5685
+ // src/skin/SkinTextures.ts
5686
+ var import_three18 = require("three");
5687
+ var SkinTextures = class {
5688
+ static async get(src, legacy) {
5689
+ const image = await ImageLoader.getData(src);
5690
+ const scale = image.width / 64;
5691
+ if (!Number.isInteger(scale) || scale < 1 || image.height !== image.width && image.height !== image.width / 2) {
5692
+ throw new MineRenderError(`Invalid skin dimensions ${image.width}x${image.height}; expected 64x64 or 64x32, or an integer-scaled equivalent`);
5693
+ }
5694
+ const isLegacy = legacy ?? image.height === image.width / 2;
5695
+ if (!isLegacy && image.height !== image.width) {
5696
+ throw new MineRenderError(`Invalid skin dimensions ${image.width}x${image.height}; non-legacy skins must be square`);
5697
+ }
5698
+ const slim = !isLegacy && this.isSlim(image, scale);
5699
+ const key = `skin:${serializeImageKey({ src })}:${isLegacy}`;
5700
+ const material = Caching.materialCache.get(key, () => {
5701
+ const pixels = isLegacy ? this.normalizeLegacy(image, scale) : new Uint8Array(image.data);
5702
+ const texture = Textures.initTextureProps(new import_three18.DataTexture(pixels, image.width, image.width));
5703
+ texture.colorSpace = import_three18.SRGBColorSpace;
5704
+ texture.flipY = true;
5705
+ texture.needsUpdate = true;
5706
+ return new import_three18.MeshBasicMaterial({ map: texture, transparent: true, side: import_three18.DoubleSide, alphaTest: 0.5 });
5707
+ });
5708
+ return { material, slim, legacy: isLegacy };
5709
+ }
5710
+ static isSlim(image, scale) {
5711
+ for (const [x, y] of [[46, 52], [54, 20]]) {
5712
+ for (let row = y * scale; row < (y + 12) * scale; row++) {
5713
+ for (let column = x * scale; column < (x + 1) * scale; column++) {
5714
+ if (image.data[(row * image.width + column) * 4 + 3] !== 0) return false;
5715
+ }
5716
+ }
5717
+ }
5718
+ return true;
5719
+ }
5720
+ static normalizeLegacy(image, scale) {
5721
+ const pixels = new Uint8Array(image.width * image.width * 4);
5722
+ pixels.set(image.data.subarray(0, image.width * image.width / 2 * 4));
5723
+ for (const [sx, sy, dx, dy, width, height] of [
5724
+ [4, 16, 20, 48, 4, 4],
5725
+ [8, 16, 24, 48, 4, 4],
5726
+ [0, 20, 24, 52, 4, 12],
5727
+ [4, 20, 20, 52, 4, 12],
5728
+ [8, 20, 16, 52, 4, 12],
5729
+ [12, 20, 28, 52, 4, 12],
5730
+ [44, 16, 36, 48, 4, 4],
5731
+ [48, 16, 40, 48, 4, 4],
5732
+ [40, 20, 40, 52, 4, 12],
5733
+ [44, 20, 36, 52, 4, 12],
5734
+ [48, 20, 32, 52, 4, 12],
5735
+ [52, 20, 44, 52, 4, 12]
5736
+ ]) {
5737
+ for (let y = 0; y < height * scale; y++) {
5738
+ for (let x = 0; x < width * scale; x++) {
5739
+ const source = ((sy * scale + y) * image.width + sx * scale + x) * 4;
5740
+ const target = ((dy * scale + y) * image.width + (dx + width) * scale - 1 - x) * 4;
5741
+ pixels.set(image.data.subarray(source, source + 4), target);
5742
+ }
5743
+ }
5744
+ }
5745
+ let clearHat = true;
5746
+ for (let y = 0; y < 32 * scale; y++) {
5747
+ for (let x = 32 * scale; x < image.width; x++) {
5748
+ if (pixels[(y * image.width + x) * 4 + 3] < 128) clearHat = false;
5749
+ }
5750
+ }
5751
+ for (let y = 0; y < image.width; y++) {
5752
+ for (let x = 0; x < image.width; x++) {
5753
+ const alpha = (y * image.width + x) * 4 + 3;
5754
+ if (x < 32 * scale && y < 16 * scale || y >= 16 * scale && y < 32 * scale || x >= 16 * scale && x < 48 * scale && y >= 48 * scale) {
5755
+ pixels[alpha] = 255;
5756
+ } else if (clearHat && x >= 32 * scale && y < 32 * scale) {
5757
+ pixels[alpha] = 0;
5758
+ }
5759
+ }
5760
+ }
5761
+ return pixels;
5762
+ }
5763
+ };
5764
+
5765
+ // src/skin/scene/SkinObject.ts
5683
5766
  var SkinObject = class extends SceneObject {
5684
5767
  constructor(options) {
5685
5768
  super();
5686
5769
  this.slim = false;
5687
- this.legacy = false;
5688
- this.skinTextureWidth = 64;
5689
- this.skinTextureHeight = 64;
5770
+ this.detectedSlim = false;
5771
+ this.skinLoad = 0;
5690
5772
  this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
5773
+ this.slim = this.options.slim ?? false;
5691
5774
  }
5692
5775
  async init() {
5693
5776
  this.createMeshes();
@@ -5696,15 +5779,13 @@ var SkinObject = class extends SceneObject {
5696
5779
  }
5697
5780
  createMeshes() {
5698
5781
  console.log("#createMeshes");
5699
- const mat = Materials.MISSING_TEXTURE;
5782
+ const mat = this.skinMaterial ?? Materials.MISSING_TEXTURE;
5700
5783
  {
5701
5784
  const headGroup = this.createAndAddGroup("head", 0, 28, 0, "y" /* Y */, -4);
5702
5785
  const headGeo = this.getBoxGeometry("head" /* HEAD */);
5703
5786
  const head = this.createAndAddMesh("head", headGroup, headGeo, mat, "y" /* Y */, 4);
5704
- if (!this.legacy) {
5705
- const hatGeo = this.getBoxGeometry("hat" /* HAT */);
5706
- const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
5707
- }
5787
+ const hatGeo = this.getBoxGeometry("hat" /* HAT */);
5788
+ const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
5708
5789
  }
5709
5790
  {
5710
5791
  const bodyGroup = this.createAndAddGroup("body", 0, 18, 0);
@@ -5747,21 +5828,30 @@ var SkinObject = class extends SceneObject {
5747
5828
  }
5748
5829
  console.log("#createMeshes done");
5749
5830
  }
5750
- setSkinTexture(src) {
5831
+ async setSkinTexture(src) {
5751
5832
  if (typeof src === "undefined") return;
5752
- const mat = Materials.getImage({
5753
- texture: { src },
5754
- transparent: true
5755
- });
5756
- for (let part of SKIN_PARTS) {
5757
- let mesh = this.getMeshByName(part);
5833
+ this.skinTextureSrc = src;
5834
+ const load = ++this.skinLoad;
5835
+ const texture = await SkinTextures.get(src, this.options.legacy);
5836
+ if (load !== this.skinLoad) return;
5837
+ this.skinMaterial = texture.material;
5838
+ this.detectedSlim = texture.slim;
5839
+ this.updateSlim(this.options.slim ?? this.detectedSlim);
5840
+ for (const part of SKIN_PARTS) {
5841
+ const mesh = this.getMeshByName(part);
5758
5842
  if (mesh) {
5759
- mesh.material = mat;
5843
+ mesh.material = texture.material;
5760
5844
  }
5761
5845
  }
5846
+ this.notifyDirty();
5762
5847
  }
5763
5848
  //TODO: cape
5849
+ /** Select the arm model, or pass undefined to use texture detection. */
5764
5850
  setSlim(slim) {
5851
+ this.options.slim = slim;
5852
+ this.updateSlim(slim ?? this.detectedSlim);
5853
+ }
5854
+ updateSlim(slim) {
5765
5855
  if (slim === this.slim) return;
5766
5856
  this.slim = slim;
5767
5857
  for (const part of ["leftArm" /* LEFT_ARM */, "leftSleeve" /* LEFT_SLEEVE */, "rightArm" /* RIGHT_ARM */, "rightSleeve" /* RIGHT_SLEEVE */]) {
@@ -5775,22 +5865,27 @@ var SkinObject = class extends SceneObject {
5775
5865
  if (rightArm) rightArm.position.x -= offset;
5776
5866
  this.notifyDirty();
5777
5867
  }
5778
- setLegacy(legacy) {
5779
- if (legacy !== this.legacy) {
5780
- }
5781
- this.legacy = legacy;
5868
+ /** Select the texture layout, or pass undefined to detect it from image dimensions. */
5869
+ async setLegacy(legacy) {
5870
+ if (legacy === this.options.legacy) return;
5871
+ this.options.legacy = legacy;
5872
+ if (this.skinTextureSrc) await this.setSkinTexture(this.skinTextureSrc);
5873
+ }
5874
+ dispose() {
5875
+ this.skinLoad++;
5876
+ super.dispose();
5782
5877
  }
5783
5878
  //TODO: layer toggles
5784
5879
  getBoxGeometry(part) {
5785
5880
  console.log("slim", this.slim);
5786
5881
  const coordinates = this.slim ? slimSkinTextureCoordinates : classicSkinTextureCoordinates;
5787
5882
  const geometries = this.slim ? slimSkinGeometries : classicSkinGeometries;
5788
- return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [this.skinTextureWidth, this.skinTextureHeight]);
5883
+ return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [64, 64]);
5789
5884
  }
5790
5885
  };
5791
5886
 
5792
5887
  // src/renderer/MineRenderScene.ts
5793
- var _MineRenderScene = class _MineRenderScene extends import_three18.Scene {
5888
+ var _MineRenderScene = class _MineRenderScene extends import_three19.Scene {
5794
5889
  constructor(options) {
5795
5890
  super();
5796
5891
  this.isMineRenderScene = true;
@@ -5895,10 +5990,10 @@ var _MineRenderScene = class _MineRenderScene extends import_three18.Scene {
5895
5990
  this.dirty = true;
5896
5991
  const obj = new SkinObject(options);
5897
5992
  obj.scene = this;
5898
- await obj.init();
5899
5993
  if (skin) {
5900
- obj.setSkinTexture(skin);
5994
+ await obj.setSkinTexture(skin);
5901
5995
  }
5996
+ await obj.init();
5902
5997
  parent.add(obj);
5903
5998
  return obj;
5904
5999
  }
@@ -5913,17 +6008,17 @@ function isMineRenderScene(obj) {
5913
6008
  }
5914
6009
 
5915
6010
  // src/renderer/Renderer.ts
5916
- var import_three20 = require("three");
6011
+ var import_three21 = require("three");
5917
6012
  var import_ts_deepmerge9 = __toESM(require_dist());
5918
6013
  var import_stats = __toESM(require("stats.js"));
5919
6014
  var import_postprocessing = require("postprocessing");
5920
6015
 
5921
6016
  // src/three/OrbitControls.js
5922
- var import_three19 = require("three");
6017
+ var import_three20 = require("three");
5923
6018
  var _changeEvent = { type: "change" };
5924
6019
  var _startEvent = { type: "start" };
5925
6020
  var _endEvent = { type: "end" };
5926
- var OrbitControls = class extends import_three19.EventDispatcher {
6021
+ var OrbitControls = class extends import_three20.EventDispatcher {
5927
6022
  constructor(object, domElement) {
5928
6023
  super();
5929
6024
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -5932,7 +6027,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
5932
6027
  this.domElement = domElement;
5933
6028
  this.domElement.style.touchAction = "none";
5934
6029
  this.enabled = true;
5935
- this.target = new import_three19.Vector3();
6030
+ this.target = new import_three20.Vector3();
5936
6031
  this.minDistance = 0;
5937
6032
  this.maxDistance = Infinity;
5938
6033
  this.minZoom = 0;
@@ -5954,8 +6049,8 @@ var OrbitControls = class extends import_three19.EventDispatcher {
5954
6049
  this.autoRotate = false;
5955
6050
  this.autoRotateSpeed = 2;
5956
6051
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
5957
- this.mouseButtons = { LEFT: import_three19.MOUSE.ROTATE, MIDDLE: import_three19.MOUSE.DOLLY, RIGHT: import_three19.MOUSE.PAN };
5958
- this.touches = { ONE: import_three19.TOUCH.ROTATE, TWO: import_three19.TOUCH.DOLLY_PAN };
6052
+ this.mouseButtons = { LEFT: import_three20.MOUSE.ROTATE, MIDDLE: import_three20.MOUSE.DOLLY, RIGHT: import_three20.MOUSE.PAN };
6053
+ this.touches = { ONE: import_three20.TOUCH.ROTATE, TWO: import_three20.TOUCH.DOLLY_PAN };
5959
6054
  this.target0 = this.target.clone();
5960
6055
  this.position0 = this.object.position.clone();
5961
6056
  this.zoom0 = this.object.zoom;
@@ -5984,11 +6079,11 @@ var OrbitControls = class extends import_three19.EventDispatcher {
5984
6079
  state = STATE.NONE;
5985
6080
  };
5986
6081
  this.update = function() {
5987
- const offset = new import_three19.Vector3();
5988
- const quat = new import_three19.Quaternion().setFromUnitVectors(object.up, new import_three19.Vector3(0, 1, 0));
6082
+ const offset = new import_three20.Vector3();
6083
+ const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
5989
6084
  const quatInverse = quat.clone().invert();
5990
- const lastPosition = new import_three19.Vector3();
5991
- const lastQuaternion = new import_three19.Quaternion();
6085
+ const lastPosition = new import_three20.Vector3();
6086
+ const lastQuaternion = new import_three20.Quaternion();
5992
6087
  const twoPI = 2 * Math.PI;
5993
6088
  return function update() {
5994
6089
  const position = scope.object.position;
@@ -6074,20 +6169,20 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6074
6169
  };
6075
6170
  let state = STATE.NONE;
6076
6171
  const EPS = 1e-6;
6077
- const spherical = new import_three19.Spherical();
6078
- const sphericalDelta = new import_three19.Spherical();
6172
+ const spherical = new import_three20.Spherical();
6173
+ const sphericalDelta = new import_three20.Spherical();
6079
6174
  let scale = 1;
6080
- const panOffset = new import_three19.Vector3();
6175
+ const panOffset = new import_three20.Vector3();
6081
6176
  let zoomChanged = false;
6082
- const rotateStart = new import_three19.Vector2();
6083
- const rotateEnd = new import_three19.Vector2();
6084
- const rotateDelta = new import_three19.Vector2();
6085
- const panStart = new import_three19.Vector2();
6086
- const panEnd = new import_three19.Vector2();
6087
- const panDelta = new import_three19.Vector2();
6088
- const dollyStart = new import_three19.Vector2();
6089
- const dollyEnd = new import_three19.Vector2();
6090
- const dollyDelta = new import_three19.Vector2();
6177
+ const rotateStart = new import_three20.Vector2();
6178
+ const rotateEnd = new import_three20.Vector2();
6179
+ const rotateDelta = new import_three20.Vector2();
6180
+ const panStart = new import_three20.Vector2();
6181
+ const panEnd = new import_three20.Vector2();
6182
+ const panDelta = new import_three20.Vector2();
6183
+ const dollyStart = new import_three20.Vector2();
6184
+ const dollyEnd = new import_three20.Vector2();
6185
+ const dollyDelta = new import_three20.Vector2();
6091
6186
  const pointers = [];
6092
6187
  const pointerPositions = {};
6093
6188
  function getAutoRotationAngle() {
@@ -6103,7 +6198,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6103
6198
  sphericalDelta.phi -= angle;
6104
6199
  }
6105
6200
  const panLeft = function() {
6106
- const v = new import_three19.Vector3();
6201
+ const v = new import_three20.Vector3();
6107
6202
  return function panLeft2(distance, objectMatrix) {
6108
6203
  v.setFromMatrixColumn(objectMatrix, 0);
6109
6204
  v.multiplyScalar(-distance);
@@ -6111,7 +6206,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6111
6206
  };
6112
6207
  }();
6113
6208
  const panUp = function() {
6114
- const v = new import_three19.Vector3();
6209
+ const v = new import_three20.Vector3();
6115
6210
  return function panUp2(distance, objectMatrix) {
6116
6211
  if (scope.screenSpacePanning === true) {
6117
6212
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -6124,7 +6219,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6124
6219
  };
6125
6220
  }();
6126
6221
  const pan = function() {
6127
- const offset = new import_three19.Vector3();
6222
+ const offset = new import_three20.Vector3();
6128
6223
  return function pan2(deltaX, deltaY) {
6129
6224
  const element = scope.domElement;
6130
6225
  if (scope.object.isPerspectiveCamera) {
@@ -6373,12 +6468,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6373
6468
  mouseAction = -1;
6374
6469
  }
6375
6470
  switch (mouseAction) {
6376
- case import_three19.MOUSE.DOLLY:
6471
+ case import_three20.MOUSE.DOLLY:
6377
6472
  if (scope.enableZoom === false) return;
6378
6473
  handleMouseDownDolly(event);
6379
6474
  state = STATE.DOLLY;
6380
6475
  break;
6381
- case import_three19.MOUSE.ROTATE:
6476
+ case import_three20.MOUSE.ROTATE:
6382
6477
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
6383
6478
  if (scope.enablePan === false) return;
6384
6479
  handleMouseDownPan(event);
@@ -6389,7 +6484,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6389
6484
  state = STATE.ROTATE;
6390
6485
  }
6391
6486
  break;
6392
- case import_three19.MOUSE.PAN:
6487
+ case import_three20.MOUSE.PAN:
6393
6488
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
6394
6489
  if (scope.enableRotate === false) return;
6395
6490
  handleMouseDownRotate(event);
@@ -6445,12 +6540,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6445
6540
  switch (pointers.length) {
6446
6541
  case 1:
6447
6542
  switch (scope.touches.ONE) {
6448
- case import_three19.TOUCH.ROTATE:
6543
+ case import_three20.TOUCH.ROTATE:
6449
6544
  if (scope.enableRotate === false) return;
6450
6545
  handleTouchStartRotate();
6451
6546
  state = STATE.TOUCH_ROTATE;
6452
6547
  break;
6453
- case import_three19.TOUCH.PAN:
6548
+ case import_three20.TOUCH.PAN:
6454
6549
  if (scope.enablePan === false) return;
6455
6550
  handleTouchStartPan();
6456
6551
  state = STATE.TOUCH_PAN;
@@ -6461,12 +6556,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6461
6556
  break;
6462
6557
  case 2:
6463
6558
  switch (scope.touches.TWO) {
6464
- case import_three19.TOUCH.DOLLY_PAN:
6559
+ case import_three20.TOUCH.DOLLY_PAN:
6465
6560
  if (scope.enableZoom === false && scope.enablePan === false) return;
6466
6561
  handleTouchStartDollyPan();
6467
6562
  state = STATE.TOUCH_DOLLY_PAN;
6468
6563
  break;
6469
- case import_three19.TOUCH.DOLLY_ROTATE:
6564
+ case import_three20.TOUCH.DOLLY_ROTATE:
6470
6565
  if (scope.enableZoom === false && scope.enableRotate === false) return;
6471
6566
  handleTouchStartDollyRotate();
6472
6567
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -6533,7 +6628,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
6533
6628
  function trackPointer(event) {
6534
6629
  let position = pointerPositions[event.pointerId];
6535
6630
  if (position === void 0) {
6536
- position = new import_three19.Vector2();
6631
+ position = new import_three20.Vector2();
6537
6632
  pointerPositions[event.pointerId] = position;
6538
6633
  }
6539
6634
  position.set(event.pageX, event.pageY);
@@ -6553,10 +6648,10 @@ var MapControls = class extends OrbitControls {
6553
6648
  constructor(object, domElement) {
6554
6649
  super(object, domElement);
6555
6650
  this.screenSpacePanning = false;
6556
- this.mouseButtons.LEFT = import_three19.MOUSE.PAN;
6557
- this.mouseButtons.RIGHT = import_three19.MOUSE.ROTATE;
6558
- this.touches.ONE = import_three19.TOUCH.PAN;
6559
- this.touches.TWO = import_three19.TOUCH.DOLLY_ROTATE;
6651
+ this.mouseButtons.LEFT = import_three20.MOUSE.PAN;
6652
+ this.mouseButtons.RIGHT = import_three20.MOUSE.ROTATE;
6653
+ this.touches.ONE = import_three20.TOUCH.PAN;
6654
+ this.touches.TWO = import_three20.TOUCH.DOLLY_ROTATE;
6560
6655
  }
6561
6656
  };
6562
6657
 
@@ -6593,14 +6688,14 @@ var _Renderer = class _Renderer {
6593
6688
  switch (this.options.camera.type) {
6594
6689
  case "perspective":
6595
6690
  default:
6596
- return new import_three20.PerspectiveCamera(
6691
+ return new import_three21.PerspectiveCamera(
6597
6692
  this.options.camera.perspective.fov,
6598
6693
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
6599
6694
  this.options.camera.near,
6600
6695
  this.options.camera.far
6601
6696
  );
6602
6697
  case "orthographic":
6603
- return new import_three20.OrthographicCamera(
6698
+ return new import_three21.OrthographicCamera(
6604
6699
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
6605
6700
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
6606
6701
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -6611,7 +6706,7 @@ var _Renderer = class _Renderer {
6611
6706
  }
6612
6707
  }
6613
6708
  createRenderer() {
6614
- const renderer = new import_three20.WebGLRenderer({
6709
+ const renderer = new import_three21.WebGLRenderer({
6615
6710
  antialias: this.options.render.antialias,
6616
6711
  alpha: true,
6617
6712
  powerPreference: "high-performance",
@@ -6619,8 +6714,8 @@ var _Renderer = class _Renderer {
6619
6714
  });
6620
6715
  renderer.setClearColor(0, 0);
6621
6716
  renderer.shadowMap.enabled = true;
6622
- renderer.shadowMap.type = import_three20.PCFSoftShadowMap;
6623
- renderer.outputColorSpace = import_three20.SRGBColorSpace;
6717
+ renderer.shadowMap.type = import_three21.PCFSoftShadowMap;
6718
+ renderer.outputColorSpace = import_three21.SRGBColorSpace;
6624
6719
  renderer.setSize(this.viewWidth, this.viewHeight);
6625
6720
  return renderer;
6626
6721
  }
@@ -6654,20 +6749,20 @@ var _Renderer = class _Renderer {
6654
6749
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
6655
6750
  }
6656
6751
  if (this.options.debug.grid) {
6657
- const gridHelper = new import_three20.GridHelper(128, 16);
6752
+ const gridHelper = new import_three21.GridHelper(128, 16);
6658
6753
  this._debugHelpers.push(gridHelper);
6659
6754
  this.scene.add(gridHelper);
6660
- const gridHelper2 = new import_three20.GridHelper(128, 16);
6755
+ const gridHelper2 = new import_three21.GridHelper(128, 16);
6661
6756
  this._debugHelpers.push(gridHelper2);
6662
6757
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
6663
6758
  this.scene.add(gridHelper2);
6664
- const gridHelper3 = new import_three20.GridHelper(128, 16);
6759
+ const gridHelper3 = new import_three21.GridHelper(128, 16);
6665
6760
  this._debugHelpers.push(gridHelper3);
6666
6761
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
6667
6762
  this.scene.add(gridHelper3);
6668
6763
  }
6669
6764
  if (this.options.debug.axes) {
6670
- const axesHelper = new import_three20.AxesHelper(64);
6765
+ const axesHelper = new import_three21.AxesHelper(64);
6671
6766
  this._debugHelpers.push(axesHelper);
6672
6767
  this.scene.add(axesHelper);
6673
6768
  }
@@ -6871,8 +6966,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
6871
6966
  top: void 0,
6872
6967
  bottom: void 0
6873
6968
  },
6874
- position: new import_three20.Vector3(50, 50, 50),
6875
- lookingAt: new import_three20.Vector3(0, 0, 0)
6969
+ position: new import_three21.Vector3(50, 50, 50),
6970
+ lookingAt: new import_three21.Vector3(0, 0, 0)
6876
6971
  },
6877
6972
  render: {
6878
6973
  fpsLimit: 60,
@@ -7066,10 +7161,10 @@ var Skins = class {
7066
7161
  };
7067
7162
 
7068
7163
  // src/world/Chunk.ts
7069
- var import_three23 = require("three");
7164
+ var import_three24 = require("three");
7070
7165
 
7071
7166
  // src/world/MineRenderWorld.ts
7072
- var import_three22 = require("three");
7167
+ var import_three23 = require("three");
7073
7168
  var MineRenderWorld = class {
7074
7169
  constructor(scene) {
7075
7170
  this._size = 4;
@@ -7080,10 +7175,10 @@ var MineRenderWorld = class {
7080
7175
  }
7081
7176
  getBlockAt(posOrX, y, z) {
7082
7177
  if (typeof posOrX == "number") {
7083
- return this.getBlockAt(new import_three22.Vector3(posOrX, y, z));
7178
+ return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
7084
7179
  }
7085
7180
  if (isTripleArray(posOrX)) {
7086
- return this.getBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7181
+ return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7087
7182
  }
7088
7183
  const chunk = this.getChunkAt(posOrX);
7089
7184
  if (typeof chunk === "undefined") {
@@ -7094,10 +7189,10 @@ var MineRenderWorld = class {
7094
7189
  }
7095
7190
  async setBlockAt(posOrX, yOrBlock, z, block) {
7096
7191
  if (typeof posOrX == "number") {
7097
- return this.setBlockAt(new import_three22.Vector3(posOrX, yOrBlock, z), block);
7192
+ return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
7098
7193
  }
7099
7194
  if (isTripleArray(posOrX)) {
7100
- return this.setBlockAt(new import_three22.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7195
+ return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7101
7196
  }
7102
7197
  this.validatePosBounds(posOrX);
7103
7198
  const chunk = this.getOrCreateChunkAt(posOrX);
@@ -7143,14 +7238,14 @@ var MineRenderWorld = class {
7143
7238
  return this._chunks[index];
7144
7239
  }
7145
7240
  static worldToScenePosition(pos) {
7146
- return new import_three22.Vector3(
7241
+ return new import_three23.Vector3(
7147
7242
  pos.x * 16,
7148
7243
  pos.y * 16,
7149
7244
  pos.z * 16
7150
7245
  );
7151
7246
  }
7152
7247
  static sceneToWorldPosition(pos) {
7153
- return new import_three22.Vector3(
7248
+ return new import_three23.Vector3(
7154
7249
  pos.x / 16,
7155
7250
  pos.y / 16,
7156
7251
  pos.z / 16
@@ -7187,12 +7282,12 @@ var Chunk = class _Chunk {
7187
7282
  this.x = x;
7188
7283
  this.y = y;
7189
7284
  this.z = z;
7190
- let anchor = new import_three23.Object3D();
7285
+ let anchor = new import_three24.Object3D();
7191
7286
  this._anchor = anchor;
7192
7287
  scene.add(anchor);
7193
7288
  anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
7194
7289
  addBox3WireframeToObject(
7195
- new import_three23.Box3(new import_three23.Vector3(0, 0, 0), new import_three23.Vector3(256, 256, 256)),
7290
+ new import_three24.Box3(new import_three24.Vector3(0, 0, 0), new import_three24.Vector3(256, 256, 256)),
7196
7291
  anchor,
7197
7292
  16776960,
7198
7293
  4
@@ -7200,10 +7295,10 @@ var Chunk = class _Chunk {
7200
7295
  }
7201
7296
  getBlockAt(posOrX, y, z) {
7202
7297
  if (typeof posOrX == "number") {
7203
- return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
7298
+ return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
7204
7299
  }
7205
7300
  if (isTripleArray(posOrX)) {
7206
- return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7301
+ return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7207
7302
  }
7208
7303
  const pos = this.worldPosToChunkPos(posOrX);
7209
7304
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -7211,10 +7306,10 @@ var Chunk = class _Chunk {
7211
7306
  }
7212
7307
  async setBlockAt(posOrX, yOrBlock, z, block) {
7213
7308
  if (typeof posOrX == "number") {
7214
- return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
7309
+ return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
7215
7310
  }
7216
7311
  if (isTripleArray(posOrX)) {
7217
- return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7312
+ return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7218
7313
  }
7219
7314
  const worldPos = posOrX;
7220
7315
  const pos = this.worldPosToChunkPos(worldPos);
@@ -7260,7 +7355,7 @@ var Chunk = class _Chunk {
7260
7355
  }
7261
7356
  async clear() {
7262
7357
  let promises = [];
7263
- let pos = new import_three23.Vector3();
7358
+ let pos = new import_three24.Vector3();
7264
7359
  for (let x = 0; x < 16; x++) {
7265
7360
  for (let z = 0; z < 16; z++) {
7266
7361
  for (let y = 0; y < 16; y++) {
@@ -7279,14 +7374,14 @@ var Chunk = class _Chunk {
7279
7374
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
7280
7375
  }
7281
7376
  worldPosToChunkPos(pos) {
7282
- return new import_three23.Vector3(
7377
+ return new import_three24.Vector3(
7283
7378
  pos.x - this.x * 16,
7284
7379
  pos.y - this.y * 16,
7285
7380
  pos.z - this.z * 16
7286
7381
  );
7287
7382
  }
7288
7383
  chunkPosToWorldPos(pos) {
7289
- return new import_three23.Vector3(
7384
+ return new import_three24.Vector3(
7290
7385
  this.x * 16 + pos.x,
7291
7386
  this.y * 16 + pos.y,
7292
7387
  this.z * 16 + pos.z