minerender 2.1.0-alpha.26 → 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.
- package/dist/browser/index.d.mts +25 -8
- package/dist/browser/index.d.ts +25 -8
- package/dist/browser/index.js +230 -102
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +165 -37
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +175 -35
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +25 -8
- package/dist/node/index.d.ts +25 -8
- package/dist/node/index.js +231 -102
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +165 -37
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -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
|
|
4917
|
+
var import_three19 = require("three");
|
|
4917
4918
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4918
4919
|
|
|
4919
4920
|
// src/skin/SkinPart.ts
|
|
@@ -5605,7 +5606,41 @@ var baseSkinCoordinates = {
|
|
|
5605
5606
|
var classicSkinTextureCoordinates = {
|
|
5606
5607
|
...baseSkinCoordinates
|
|
5607
5608
|
};
|
|
5608
|
-
var slimSkinTextureCoordinates = {
|
|
5609
|
+
var slimSkinTextureCoordinates = {
|
|
5610
|
+
...baseSkinCoordinates,
|
|
5611
|
+
leftArm: {
|
|
5612
|
+
...baseSkinCoordinates.leftArm,
|
|
5613
|
+
west: { uv: [39, 52, 43, 64] },
|
|
5614
|
+
north: { uv: [36, 52, 39, 64] },
|
|
5615
|
+
south: { uv: [43, 52, 46, 64] },
|
|
5616
|
+
up: { uv: [39, 52, 36, 48] },
|
|
5617
|
+
down: { uv: [42, 48, 39, 52] }
|
|
5618
|
+
},
|
|
5619
|
+
rightArm: {
|
|
5620
|
+
...baseSkinCoordinates.rightArm,
|
|
5621
|
+
west: { uv: [47, 20, 51, 32] },
|
|
5622
|
+
north: { uv: [44, 20, 47, 32] },
|
|
5623
|
+
south: { uv: [51, 20, 54, 32] },
|
|
5624
|
+
up: { uv: [47, 20, 44, 16] },
|
|
5625
|
+
down: { uv: [50, 16, 47, 20] }
|
|
5626
|
+
},
|
|
5627
|
+
leftSleeve: {
|
|
5628
|
+
...baseSkinCoordinates.leftSleeve,
|
|
5629
|
+
west: { uv: [55, 52, 59, 64] },
|
|
5630
|
+
north: { uv: [52, 52, 55, 64] },
|
|
5631
|
+
south: { uv: [59, 52, 62, 64] },
|
|
5632
|
+
up: { uv: [55, 52, 52, 48] },
|
|
5633
|
+
down: { uv: [58, 48, 55, 52], rotation: 180 }
|
|
5634
|
+
},
|
|
5635
|
+
rightSleeve: {
|
|
5636
|
+
...baseSkinCoordinates.rightSleeve,
|
|
5637
|
+
west: { uv: [47, 36, 51, 48] },
|
|
5638
|
+
north: { uv: [44, 36, 47, 48] },
|
|
5639
|
+
south: { uv: [51, 36, 54, 48] },
|
|
5640
|
+
up: { uv: [47, 36, 44, 32] },
|
|
5641
|
+
down: { uv: [50, 32, 47, 36], rotation: 180 }
|
|
5642
|
+
}
|
|
5643
|
+
};
|
|
5609
5644
|
|
|
5610
5645
|
// src/skin/SkinGeometries.ts
|
|
5611
5646
|
var box8inner = [8, 8, 8];
|
|
@@ -5646,14 +5681,96 @@ var slimSkinGeometries = {
|
|
|
5646
5681
|
|
|
5647
5682
|
// src/skin/scene/SkinObject.ts
|
|
5648
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
|
|
5649
5766
|
var SkinObject = class extends SceneObject {
|
|
5650
5767
|
constructor(options) {
|
|
5651
5768
|
super();
|
|
5652
5769
|
this.slim = false;
|
|
5653
|
-
this.
|
|
5654
|
-
this.
|
|
5655
|
-
this.skinTextureHeight = 64;
|
|
5770
|
+
this.detectedSlim = false;
|
|
5771
|
+
this.skinLoad = 0;
|
|
5656
5772
|
this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5773
|
+
this.slim = this.options.slim ?? false;
|
|
5657
5774
|
}
|
|
5658
5775
|
async init() {
|
|
5659
5776
|
this.createMeshes();
|
|
@@ -5662,15 +5779,13 @@ var SkinObject = class extends SceneObject {
|
|
|
5662
5779
|
}
|
|
5663
5780
|
createMeshes() {
|
|
5664
5781
|
console.log("#createMeshes");
|
|
5665
|
-
const mat = Materials.MISSING_TEXTURE;
|
|
5782
|
+
const mat = this.skinMaterial ?? Materials.MISSING_TEXTURE;
|
|
5666
5783
|
{
|
|
5667
5784
|
const headGroup = this.createAndAddGroup("head", 0, 28, 0, "y" /* Y */, -4);
|
|
5668
5785
|
const headGeo = this.getBoxGeometry("head" /* HEAD */);
|
|
5669
5786
|
const head = this.createAndAddMesh("head", headGroup, headGeo, mat, "y" /* Y */, 4);
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5673
|
-
}
|
|
5787
|
+
const hatGeo = this.getBoxGeometry("hat" /* HAT */);
|
|
5788
|
+
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5674
5789
|
}
|
|
5675
5790
|
{
|
|
5676
5791
|
const bodyGroup = this.createAndAddGroup("body", 0, 18, 0);
|
|
@@ -5713,51 +5828,64 @@ var SkinObject = class extends SceneObject {
|
|
|
5713
5828
|
}
|
|
5714
5829
|
console.log("#createMeshes done");
|
|
5715
5830
|
}
|
|
5716
|
-
setSkinTexture(src) {
|
|
5831
|
+
async setSkinTexture(src) {
|
|
5717
5832
|
if (typeof src === "undefined") return;
|
|
5718
5833
|
this.skinTextureSrc = src;
|
|
5719
|
-
const
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
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);
|
|
5725
5842
|
if (mesh) {
|
|
5726
|
-
mesh.material =
|
|
5843
|
+
mesh.material = texture.material;
|
|
5727
5844
|
}
|
|
5728
5845
|
}
|
|
5846
|
+
this.notifyDirty();
|
|
5729
5847
|
}
|
|
5730
5848
|
//TODO: cape
|
|
5849
|
+
/** Select the arm model, or pass undefined to use texture detection. */
|
|
5731
5850
|
setSlim(slim) {
|
|
5732
|
-
|
|
5733
|
-
|
|
5851
|
+
this.options.slim = slim;
|
|
5852
|
+
this.updateSlim(slim ?? this.detectedSlim);
|
|
5853
|
+
}
|
|
5854
|
+
updateSlim(slim) {
|
|
5855
|
+
if (slim === this.slim) return;
|
|
5734
5856
|
this.slim = slim;
|
|
5735
|
-
|
|
5736
|
-
this.
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5857
|
+
for (const part of ["leftArm" /* LEFT_ARM */, "leftSleeve" /* LEFT_SLEEVE */, "rightArm" /* RIGHT_ARM */, "rightSleeve" /* RIGHT_SLEEVE */]) {
|
|
5858
|
+
const mesh = this.getMeshByName(part);
|
|
5859
|
+
if (mesh) mesh.geometry = this.getBoxGeometry(part);
|
|
5860
|
+
}
|
|
5861
|
+
const offset = slim ? 0.5 : -0.5;
|
|
5862
|
+
const leftArm = this.getGroupByName("leftArm" /* LEFT_ARM */);
|
|
5863
|
+
const rightArm = this.getGroupByName("rightArm" /* RIGHT_ARM */);
|
|
5864
|
+
if (leftArm) leftArm.position.x += offset;
|
|
5865
|
+
if (rightArm) rightArm.position.x -= offset;
|
|
5866
|
+
this.notifyDirty();
|
|
5744
5867
|
}
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
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();
|
|
5749
5877
|
}
|
|
5750
5878
|
//TODO: layer toggles
|
|
5751
5879
|
getBoxGeometry(part) {
|
|
5752
5880
|
console.log("slim", this.slim);
|
|
5753
5881
|
const coordinates = this.slim ? slimSkinTextureCoordinates : classicSkinTextureCoordinates;
|
|
5754
5882
|
const geometries = this.slim ? slimSkinGeometries : classicSkinGeometries;
|
|
5755
|
-
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [
|
|
5883
|
+
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [64, 64]);
|
|
5756
5884
|
}
|
|
5757
5885
|
};
|
|
5758
5886
|
|
|
5759
5887
|
// src/renderer/MineRenderScene.ts
|
|
5760
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
5888
|
+
var _MineRenderScene = class _MineRenderScene extends import_three19.Scene {
|
|
5761
5889
|
constructor(options) {
|
|
5762
5890
|
super();
|
|
5763
5891
|
this.isMineRenderScene = true;
|
|
@@ -5862,10 +5990,10 @@ var _MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
|
5862
5990
|
this.dirty = true;
|
|
5863
5991
|
const obj = new SkinObject(options);
|
|
5864
5992
|
obj.scene = this;
|
|
5865
|
-
await obj.init();
|
|
5866
5993
|
if (skin) {
|
|
5867
|
-
obj.setSkinTexture(skin);
|
|
5994
|
+
await obj.setSkinTexture(skin);
|
|
5868
5995
|
}
|
|
5996
|
+
await obj.init();
|
|
5869
5997
|
parent.add(obj);
|
|
5870
5998
|
return obj;
|
|
5871
5999
|
}
|
|
@@ -5880,17 +6008,17 @@ function isMineRenderScene(obj) {
|
|
|
5880
6008
|
}
|
|
5881
6009
|
|
|
5882
6010
|
// src/renderer/Renderer.ts
|
|
5883
|
-
var
|
|
6011
|
+
var import_three21 = require("three");
|
|
5884
6012
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5885
6013
|
var import_stats = __toESM(require("stats.js"));
|
|
5886
6014
|
var import_postprocessing = require("postprocessing");
|
|
5887
6015
|
|
|
5888
6016
|
// src/three/OrbitControls.js
|
|
5889
|
-
var
|
|
6017
|
+
var import_three20 = require("three");
|
|
5890
6018
|
var _changeEvent = { type: "change" };
|
|
5891
6019
|
var _startEvent = { type: "start" };
|
|
5892
6020
|
var _endEvent = { type: "end" };
|
|
5893
|
-
var OrbitControls = class extends
|
|
6021
|
+
var OrbitControls = class extends import_three20.EventDispatcher {
|
|
5894
6022
|
constructor(object, domElement) {
|
|
5895
6023
|
super();
|
|
5896
6024
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5899,7 +6027,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5899
6027
|
this.domElement = domElement;
|
|
5900
6028
|
this.domElement.style.touchAction = "none";
|
|
5901
6029
|
this.enabled = true;
|
|
5902
|
-
this.target = new
|
|
6030
|
+
this.target = new import_three20.Vector3();
|
|
5903
6031
|
this.minDistance = 0;
|
|
5904
6032
|
this.maxDistance = Infinity;
|
|
5905
6033
|
this.minZoom = 0;
|
|
@@ -5921,8 +6049,8 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5921
6049
|
this.autoRotate = false;
|
|
5922
6050
|
this.autoRotateSpeed = 2;
|
|
5923
6051
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5924
|
-
this.mouseButtons = { LEFT:
|
|
5925
|
-
this.touches = { ONE:
|
|
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 };
|
|
5926
6054
|
this.target0 = this.target.clone();
|
|
5927
6055
|
this.position0 = this.object.position.clone();
|
|
5928
6056
|
this.zoom0 = this.object.zoom;
|
|
@@ -5951,11 +6079,11 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5951
6079
|
state = STATE.NONE;
|
|
5952
6080
|
};
|
|
5953
6081
|
this.update = function() {
|
|
5954
|
-
const offset = new
|
|
5955
|
-
const quat = new
|
|
6082
|
+
const offset = new import_three20.Vector3();
|
|
6083
|
+
const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
|
|
5956
6084
|
const quatInverse = quat.clone().invert();
|
|
5957
|
-
const lastPosition = new
|
|
5958
|
-
const lastQuaternion = new
|
|
6085
|
+
const lastPosition = new import_three20.Vector3();
|
|
6086
|
+
const lastQuaternion = new import_three20.Quaternion();
|
|
5959
6087
|
const twoPI = 2 * Math.PI;
|
|
5960
6088
|
return function update() {
|
|
5961
6089
|
const position = scope.object.position;
|
|
@@ -6041,20 +6169,20 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6041
6169
|
};
|
|
6042
6170
|
let state = STATE.NONE;
|
|
6043
6171
|
const EPS = 1e-6;
|
|
6044
|
-
const spherical = new
|
|
6045
|
-
const sphericalDelta = new
|
|
6172
|
+
const spherical = new import_three20.Spherical();
|
|
6173
|
+
const sphericalDelta = new import_three20.Spherical();
|
|
6046
6174
|
let scale = 1;
|
|
6047
|
-
const panOffset = new
|
|
6175
|
+
const panOffset = new import_three20.Vector3();
|
|
6048
6176
|
let zoomChanged = false;
|
|
6049
|
-
const rotateStart = new
|
|
6050
|
-
const rotateEnd = new
|
|
6051
|
-
const rotateDelta = new
|
|
6052
|
-
const panStart = new
|
|
6053
|
-
const panEnd = new
|
|
6054
|
-
const panDelta = new
|
|
6055
|
-
const dollyStart = new
|
|
6056
|
-
const dollyEnd = new
|
|
6057
|
-
const dollyDelta = new
|
|
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();
|
|
6058
6186
|
const pointers = [];
|
|
6059
6187
|
const pointerPositions = {};
|
|
6060
6188
|
function getAutoRotationAngle() {
|
|
@@ -6070,7 +6198,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6070
6198
|
sphericalDelta.phi -= angle;
|
|
6071
6199
|
}
|
|
6072
6200
|
const panLeft = function() {
|
|
6073
|
-
const v = new
|
|
6201
|
+
const v = new import_three20.Vector3();
|
|
6074
6202
|
return function panLeft2(distance, objectMatrix) {
|
|
6075
6203
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6076
6204
|
v.multiplyScalar(-distance);
|
|
@@ -6078,7 +6206,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6078
6206
|
};
|
|
6079
6207
|
}();
|
|
6080
6208
|
const panUp = function() {
|
|
6081
|
-
const v = new
|
|
6209
|
+
const v = new import_three20.Vector3();
|
|
6082
6210
|
return function panUp2(distance, objectMatrix) {
|
|
6083
6211
|
if (scope.screenSpacePanning === true) {
|
|
6084
6212
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6091,7 +6219,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6091
6219
|
};
|
|
6092
6220
|
}();
|
|
6093
6221
|
const pan = function() {
|
|
6094
|
-
const offset = new
|
|
6222
|
+
const offset = new import_three20.Vector3();
|
|
6095
6223
|
return function pan2(deltaX, deltaY) {
|
|
6096
6224
|
const element = scope.domElement;
|
|
6097
6225
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6340,12 +6468,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6340
6468
|
mouseAction = -1;
|
|
6341
6469
|
}
|
|
6342
6470
|
switch (mouseAction) {
|
|
6343
|
-
case
|
|
6471
|
+
case import_three20.MOUSE.DOLLY:
|
|
6344
6472
|
if (scope.enableZoom === false) return;
|
|
6345
6473
|
handleMouseDownDolly(event);
|
|
6346
6474
|
state = STATE.DOLLY;
|
|
6347
6475
|
break;
|
|
6348
|
-
case
|
|
6476
|
+
case import_three20.MOUSE.ROTATE:
|
|
6349
6477
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6350
6478
|
if (scope.enablePan === false) return;
|
|
6351
6479
|
handleMouseDownPan(event);
|
|
@@ -6356,7 +6484,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6356
6484
|
state = STATE.ROTATE;
|
|
6357
6485
|
}
|
|
6358
6486
|
break;
|
|
6359
|
-
case
|
|
6487
|
+
case import_three20.MOUSE.PAN:
|
|
6360
6488
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6361
6489
|
if (scope.enableRotate === false) return;
|
|
6362
6490
|
handleMouseDownRotate(event);
|
|
@@ -6412,12 +6540,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6412
6540
|
switch (pointers.length) {
|
|
6413
6541
|
case 1:
|
|
6414
6542
|
switch (scope.touches.ONE) {
|
|
6415
|
-
case
|
|
6543
|
+
case import_three20.TOUCH.ROTATE:
|
|
6416
6544
|
if (scope.enableRotate === false) return;
|
|
6417
6545
|
handleTouchStartRotate();
|
|
6418
6546
|
state = STATE.TOUCH_ROTATE;
|
|
6419
6547
|
break;
|
|
6420
|
-
case
|
|
6548
|
+
case import_three20.TOUCH.PAN:
|
|
6421
6549
|
if (scope.enablePan === false) return;
|
|
6422
6550
|
handleTouchStartPan();
|
|
6423
6551
|
state = STATE.TOUCH_PAN;
|
|
@@ -6428,12 +6556,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6428
6556
|
break;
|
|
6429
6557
|
case 2:
|
|
6430
6558
|
switch (scope.touches.TWO) {
|
|
6431
|
-
case
|
|
6559
|
+
case import_three20.TOUCH.DOLLY_PAN:
|
|
6432
6560
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6433
6561
|
handleTouchStartDollyPan();
|
|
6434
6562
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6435
6563
|
break;
|
|
6436
|
-
case
|
|
6564
|
+
case import_three20.TOUCH.DOLLY_ROTATE:
|
|
6437
6565
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6438
6566
|
handleTouchStartDollyRotate();
|
|
6439
6567
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6500,7 +6628,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6500
6628
|
function trackPointer(event) {
|
|
6501
6629
|
let position = pointerPositions[event.pointerId];
|
|
6502
6630
|
if (position === void 0) {
|
|
6503
|
-
position = new
|
|
6631
|
+
position = new import_three20.Vector2();
|
|
6504
6632
|
pointerPositions[event.pointerId] = position;
|
|
6505
6633
|
}
|
|
6506
6634
|
position.set(event.pageX, event.pageY);
|
|
@@ -6520,10 +6648,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6520
6648
|
constructor(object, domElement) {
|
|
6521
6649
|
super(object, domElement);
|
|
6522
6650
|
this.screenSpacePanning = false;
|
|
6523
|
-
this.mouseButtons.LEFT =
|
|
6524
|
-
this.mouseButtons.RIGHT =
|
|
6525
|
-
this.touches.ONE =
|
|
6526
|
-
this.touches.TWO =
|
|
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;
|
|
6527
6655
|
}
|
|
6528
6656
|
};
|
|
6529
6657
|
|
|
@@ -6560,14 +6688,14 @@ var _Renderer = class _Renderer {
|
|
|
6560
6688
|
switch (this.options.camera.type) {
|
|
6561
6689
|
case "perspective":
|
|
6562
6690
|
default:
|
|
6563
|
-
return new
|
|
6691
|
+
return new import_three21.PerspectiveCamera(
|
|
6564
6692
|
this.options.camera.perspective.fov,
|
|
6565
6693
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6566
6694
|
this.options.camera.near,
|
|
6567
6695
|
this.options.camera.far
|
|
6568
6696
|
);
|
|
6569
6697
|
case "orthographic":
|
|
6570
|
-
return new
|
|
6698
|
+
return new import_three21.OrthographicCamera(
|
|
6571
6699
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6572
6700
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6573
6701
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6578,7 +6706,7 @@ var _Renderer = class _Renderer {
|
|
|
6578
6706
|
}
|
|
6579
6707
|
}
|
|
6580
6708
|
createRenderer() {
|
|
6581
|
-
const renderer = new
|
|
6709
|
+
const renderer = new import_three21.WebGLRenderer({
|
|
6582
6710
|
antialias: this.options.render.antialias,
|
|
6583
6711
|
alpha: true,
|
|
6584
6712
|
powerPreference: "high-performance",
|
|
@@ -6586,8 +6714,8 @@ var _Renderer = class _Renderer {
|
|
|
6586
6714
|
});
|
|
6587
6715
|
renderer.setClearColor(0, 0);
|
|
6588
6716
|
renderer.shadowMap.enabled = true;
|
|
6589
|
-
renderer.shadowMap.type =
|
|
6590
|
-
renderer.outputColorSpace =
|
|
6717
|
+
renderer.shadowMap.type = import_three21.PCFSoftShadowMap;
|
|
6718
|
+
renderer.outputColorSpace = import_three21.SRGBColorSpace;
|
|
6591
6719
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6592
6720
|
return renderer;
|
|
6593
6721
|
}
|
|
@@ -6621,20 +6749,20 @@ var _Renderer = class _Renderer {
|
|
|
6621
6749
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6622
6750
|
}
|
|
6623
6751
|
if (this.options.debug.grid) {
|
|
6624
|
-
const gridHelper = new
|
|
6752
|
+
const gridHelper = new import_three21.GridHelper(128, 16);
|
|
6625
6753
|
this._debugHelpers.push(gridHelper);
|
|
6626
6754
|
this.scene.add(gridHelper);
|
|
6627
|
-
const gridHelper2 = new
|
|
6755
|
+
const gridHelper2 = new import_three21.GridHelper(128, 16);
|
|
6628
6756
|
this._debugHelpers.push(gridHelper2);
|
|
6629
6757
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6630
6758
|
this.scene.add(gridHelper2);
|
|
6631
|
-
const gridHelper3 = new
|
|
6759
|
+
const gridHelper3 = new import_three21.GridHelper(128, 16);
|
|
6632
6760
|
this._debugHelpers.push(gridHelper3);
|
|
6633
6761
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6634
6762
|
this.scene.add(gridHelper3);
|
|
6635
6763
|
}
|
|
6636
6764
|
if (this.options.debug.axes) {
|
|
6637
|
-
const axesHelper = new
|
|
6765
|
+
const axesHelper = new import_three21.AxesHelper(64);
|
|
6638
6766
|
this._debugHelpers.push(axesHelper);
|
|
6639
6767
|
this.scene.add(axesHelper);
|
|
6640
6768
|
}
|
|
@@ -6838,8 +6966,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6838
6966
|
top: void 0,
|
|
6839
6967
|
bottom: void 0
|
|
6840
6968
|
},
|
|
6841
|
-
position: new
|
|
6842
|
-
lookingAt: new
|
|
6969
|
+
position: new import_three21.Vector3(50, 50, 50),
|
|
6970
|
+
lookingAt: new import_three21.Vector3(0, 0, 0)
|
|
6843
6971
|
},
|
|
6844
6972
|
render: {
|
|
6845
6973
|
fpsLimit: 60,
|
|
@@ -7033,10 +7161,10 @@ var Skins = class {
|
|
|
7033
7161
|
};
|
|
7034
7162
|
|
|
7035
7163
|
// src/world/Chunk.ts
|
|
7036
|
-
var
|
|
7164
|
+
var import_three24 = require("three");
|
|
7037
7165
|
|
|
7038
7166
|
// src/world/MineRenderWorld.ts
|
|
7039
|
-
var
|
|
7167
|
+
var import_three23 = require("three");
|
|
7040
7168
|
var MineRenderWorld = class {
|
|
7041
7169
|
constructor(scene) {
|
|
7042
7170
|
this._size = 4;
|
|
@@ -7047,10 +7175,10 @@ var MineRenderWorld = class {
|
|
|
7047
7175
|
}
|
|
7048
7176
|
getBlockAt(posOrX, y, z) {
|
|
7049
7177
|
if (typeof posOrX == "number") {
|
|
7050
|
-
return this.getBlockAt(new
|
|
7178
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7051
7179
|
}
|
|
7052
7180
|
if (isTripleArray(posOrX)) {
|
|
7053
|
-
return this.getBlockAt(new
|
|
7181
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7054
7182
|
}
|
|
7055
7183
|
const chunk = this.getChunkAt(posOrX);
|
|
7056
7184
|
if (typeof chunk === "undefined") {
|
|
@@ -7061,10 +7189,10 @@ var MineRenderWorld = class {
|
|
|
7061
7189
|
}
|
|
7062
7190
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7063
7191
|
if (typeof posOrX == "number") {
|
|
7064
|
-
return this.setBlockAt(new
|
|
7192
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7065
7193
|
}
|
|
7066
7194
|
if (isTripleArray(posOrX)) {
|
|
7067
|
-
return this.setBlockAt(new
|
|
7195
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7068
7196
|
}
|
|
7069
7197
|
this.validatePosBounds(posOrX);
|
|
7070
7198
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7110,14 +7238,14 @@ var MineRenderWorld = class {
|
|
|
7110
7238
|
return this._chunks[index];
|
|
7111
7239
|
}
|
|
7112
7240
|
static worldToScenePosition(pos) {
|
|
7113
|
-
return new
|
|
7241
|
+
return new import_three23.Vector3(
|
|
7114
7242
|
pos.x * 16,
|
|
7115
7243
|
pos.y * 16,
|
|
7116
7244
|
pos.z * 16
|
|
7117
7245
|
);
|
|
7118
7246
|
}
|
|
7119
7247
|
static sceneToWorldPosition(pos) {
|
|
7120
|
-
return new
|
|
7248
|
+
return new import_three23.Vector3(
|
|
7121
7249
|
pos.x / 16,
|
|
7122
7250
|
pos.y / 16,
|
|
7123
7251
|
pos.z / 16
|
|
@@ -7154,12 +7282,12 @@ var Chunk = class _Chunk {
|
|
|
7154
7282
|
this.x = x;
|
|
7155
7283
|
this.y = y;
|
|
7156
7284
|
this.z = z;
|
|
7157
|
-
let anchor = new
|
|
7285
|
+
let anchor = new import_three24.Object3D();
|
|
7158
7286
|
this._anchor = anchor;
|
|
7159
7287
|
scene.add(anchor);
|
|
7160
7288
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7161
7289
|
addBox3WireframeToObject(
|
|
7162
|
-
new
|
|
7290
|
+
new import_three24.Box3(new import_three24.Vector3(0, 0, 0), new import_three24.Vector3(256, 256, 256)),
|
|
7163
7291
|
anchor,
|
|
7164
7292
|
16776960,
|
|
7165
7293
|
4
|
|
@@ -7167,10 +7295,10 @@ var Chunk = class _Chunk {
|
|
|
7167
7295
|
}
|
|
7168
7296
|
getBlockAt(posOrX, y, z) {
|
|
7169
7297
|
if (typeof posOrX == "number") {
|
|
7170
|
-
return this.getBlockAt(new
|
|
7298
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
|
|
7171
7299
|
}
|
|
7172
7300
|
if (isTripleArray(posOrX)) {
|
|
7173
|
-
return this.getBlockAt(new
|
|
7301
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7174
7302
|
}
|
|
7175
7303
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7176
7304
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7178,10 +7306,10 @@ var Chunk = class _Chunk {
|
|
|
7178
7306
|
}
|
|
7179
7307
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7180
7308
|
if (typeof posOrX == "number") {
|
|
7181
|
-
return this.setBlockAt(new
|
|
7309
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
|
|
7182
7310
|
}
|
|
7183
7311
|
if (isTripleArray(posOrX)) {
|
|
7184
|
-
return this.setBlockAt(new
|
|
7312
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7185
7313
|
}
|
|
7186
7314
|
const worldPos = posOrX;
|
|
7187
7315
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7227,7 +7355,7 @@ var Chunk = class _Chunk {
|
|
|
7227
7355
|
}
|
|
7228
7356
|
async clear() {
|
|
7229
7357
|
let promises = [];
|
|
7230
|
-
let pos = new
|
|
7358
|
+
let pos = new import_three24.Vector3();
|
|
7231
7359
|
for (let x = 0; x < 16; x++) {
|
|
7232
7360
|
for (let z = 0; z < 16; z++) {
|
|
7233
7361
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7246,14 +7374,14 @@ var Chunk = class _Chunk {
|
|
|
7246
7374
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7247
7375
|
}
|
|
7248
7376
|
worldPosToChunkPos(pos) {
|
|
7249
|
-
return new
|
|
7377
|
+
return new import_three24.Vector3(
|
|
7250
7378
|
pos.x - this.x * 16,
|
|
7251
7379
|
pos.y - this.y * 16,
|
|
7252
7380
|
pos.z - this.z * 16
|
|
7253
7381
|
);
|
|
7254
7382
|
}
|
|
7255
7383
|
chunkPosToWorldPos(pos) {
|
|
7256
|
-
return new
|
|
7384
|
+
return new import_three24.Vector3(
|
|
7257
7385
|
this.x * 16 + pos.x,
|
|
7258
7386
|
this.y * 16 + pos.y,
|
|
7259
7387
|
this.z * 16 + pos.z
|