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/node/index.js
CHANGED
|
@@ -195,6 +195,7 @@ __export(index_node_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,
|
|
@@ -4958,7 +4959,7 @@ var StructureParser = class {
|
|
|
4958
4959
|
};
|
|
4959
4960
|
|
|
4960
4961
|
// src/renderer/MineRenderScene.ts
|
|
4961
|
-
var
|
|
4962
|
+
var import_three19 = require("three");
|
|
4962
4963
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4963
4964
|
|
|
4964
4965
|
// src/skin/SkinPart.ts
|
|
@@ -5650,7 +5651,41 @@ var baseSkinCoordinates = {
|
|
|
5650
5651
|
var classicSkinTextureCoordinates = {
|
|
5651
5652
|
...baseSkinCoordinates
|
|
5652
5653
|
};
|
|
5653
|
-
var slimSkinTextureCoordinates = {
|
|
5654
|
+
var slimSkinTextureCoordinates = {
|
|
5655
|
+
...baseSkinCoordinates,
|
|
5656
|
+
leftArm: {
|
|
5657
|
+
...baseSkinCoordinates.leftArm,
|
|
5658
|
+
west: { uv: [39, 52, 43, 64] },
|
|
5659
|
+
north: { uv: [36, 52, 39, 64] },
|
|
5660
|
+
south: { uv: [43, 52, 46, 64] },
|
|
5661
|
+
up: { uv: [39, 52, 36, 48] },
|
|
5662
|
+
down: { uv: [42, 48, 39, 52] }
|
|
5663
|
+
},
|
|
5664
|
+
rightArm: {
|
|
5665
|
+
...baseSkinCoordinates.rightArm,
|
|
5666
|
+
west: { uv: [47, 20, 51, 32] },
|
|
5667
|
+
north: { uv: [44, 20, 47, 32] },
|
|
5668
|
+
south: { uv: [51, 20, 54, 32] },
|
|
5669
|
+
up: { uv: [47, 20, 44, 16] },
|
|
5670
|
+
down: { uv: [50, 16, 47, 20] }
|
|
5671
|
+
},
|
|
5672
|
+
leftSleeve: {
|
|
5673
|
+
...baseSkinCoordinates.leftSleeve,
|
|
5674
|
+
west: { uv: [55, 52, 59, 64] },
|
|
5675
|
+
north: { uv: [52, 52, 55, 64] },
|
|
5676
|
+
south: { uv: [59, 52, 62, 64] },
|
|
5677
|
+
up: { uv: [55, 52, 52, 48] },
|
|
5678
|
+
down: { uv: [58, 48, 55, 52], rotation: 180 }
|
|
5679
|
+
},
|
|
5680
|
+
rightSleeve: {
|
|
5681
|
+
...baseSkinCoordinates.rightSleeve,
|
|
5682
|
+
west: { uv: [47, 36, 51, 48] },
|
|
5683
|
+
north: { uv: [44, 36, 47, 48] },
|
|
5684
|
+
south: { uv: [51, 36, 54, 48] },
|
|
5685
|
+
up: { uv: [47, 36, 44, 32] },
|
|
5686
|
+
down: { uv: [50, 32, 47, 36], rotation: 180 }
|
|
5687
|
+
}
|
|
5688
|
+
};
|
|
5654
5689
|
|
|
5655
5690
|
// src/skin/SkinGeometries.ts
|
|
5656
5691
|
var box8inner = [8, 8, 8];
|
|
@@ -5691,14 +5726,96 @@ var slimSkinGeometries = {
|
|
|
5691
5726
|
|
|
5692
5727
|
// src/skin/scene/SkinObject.ts
|
|
5693
5728
|
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
5729
|
+
|
|
5730
|
+
// src/skin/SkinTextures.ts
|
|
5731
|
+
var import_three18 = require("three");
|
|
5732
|
+
var SkinTextures = class {
|
|
5733
|
+
static async get(src, legacy) {
|
|
5734
|
+
const image = await ImageLoader.getData(src);
|
|
5735
|
+
const scale = image.width / 64;
|
|
5736
|
+
if (!Number.isInteger(scale) || scale < 1 || image.height !== image.width && image.height !== image.width / 2) {
|
|
5737
|
+
throw new MineRenderError(`Invalid skin dimensions ${image.width}x${image.height}; expected 64x64 or 64x32, or an integer-scaled equivalent`);
|
|
5738
|
+
}
|
|
5739
|
+
const isLegacy = legacy ?? image.height === image.width / 2;
|
|
5740
|
+
if (!isLegacy && image.height !== image.width) {
|
|
5741
|
+
throw new MineRenderError(`Invalid skin dimensions ${image.width}x${image.height}; non-legacy skins must be square`);
|
|
5742
|
+
}
|
|
5743
|
+
const slim = !isLegacy && this.isSlim(image, scale);
|
|
5744
|
+
const key = `skin:${serializeImageKey({ src })}:${isLegacy}`;
|
|
5745
|
+
const material = Caching.materialCache.get(key, () => {
|
|
5746
|
+
const pixels = isLegacy ? this.normalizeLegacy(image, scale) : new Uint8Array(image.data);
|
|
5747
|
+
const texture = Textures.initTextureProps(new import_three18.DataTexture(pixels, image.width, image.width));
|
|
5748
|
+
texture.colorSpace = import_three18.SRGBColorSpace;
|
|
5749
|
+
texture.flipY = true;
|
|
5750
|
+
texture.needsUpdate = true;
|
|
5751
|
+
return new import_three18.MeshBasicMaterial({ map: texture, transparent: true, side: import_three18.DoubleSide, alphaTest: 0.5 });
|
|
5752
|
+
});
|
|
5753
|
+
return { material, slim, legacy: isLegacy };
|
|
5754
|
+
}
|
|
5755
|
+
static isSlim(image, scale) {
|
|
5756
|
+
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
5757
|
+
for (let row = y * scale; row < (y + 12) * scale; row++) {
|
|
5758
|
+
for (let column = x * scale; column < (x + 1) * scale; column++) {
|
|
5759
|
+
if (image.data[(row * image.width + column) * 4 + 3] !== 0) return false;
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
return true;
|
|
5764
|
+
}
|
|
5765
|
+
static normalizeLegacy(image, scale) {
|
|
5766
|
+
const pixels = new Uint8Array(image.width * image.width * 4);
|
|
5767
|
+
pixels.set(image.data.subarray(0, image.width * image.width / 2 * 4));
|
|
5768
|
+
for (const [sx, sy, dx, dy, width, height] of [
|
|
5769
|
+
[4, 16, 20, 48, 4, 4],
|
|
5770
|
+
[8, 16, 24, 48, 4, 4],
|
|
5771
|
+
[0, 20, 24, 52, 4, 12],
|
|
5772
|
+
[4, 20, 20, 52, 4, 12],
|
|
5773
|
+
[8, 20, 16, 52, 4, 12],
|
|
5774
|
+
[12, 20, 28, 52, 4, 12],
|
|
5775
|
+
[44, 16, 36, 48, 4, 4],
|
|
5776
|
+
[48, 16, 40, 48, 4, 4],
|
|
5777
|
+
[40, 20, 40, 52, 4, 12],
|
|
5778
|
+
[44, 20, 36, 52, 4, 12],
|
|
5779
|
+
[48, 20, 32, 52, 4, 12],
|
|
5780
|
+
[52, 20, 44, 52, 4, 12]
|
|
5781
|
+
]) {
|
|
5782
|
+
for (let y = 0; y < height * scale; y++) {
|
|
5783
|
+
for (let x = 0; x < width * scale; x++) {
|
|
5784
|
+
const source = ((sy * scale + y) * image.width + sx * scale + x) * 4;
|
|
5785
|
+
const target = ((dy * scale + y) * image.width + (dx + width) * scale - 1 - x) * 4;
|
|
5786
|
+
pixels.set(image.data.subarray(source, source + 4), target);
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
let clearHat = true;
|
|
5791
|
+
for (let y = 0; y < 32 * scale; y++) {
|
|
5792
|
+
for (let x = 32 * scale; x < image.width; x++) {
|
|
5793
|
+
if (pixels[(y * image.width + x) * 4 + 3] < 128) clearHat = false;
|
|
5794
|
+
}
|
|
5795
|
+
}
|
|
5796
|
+
for (let y = 0; y < image.width; y++) {
|
|
5797
|
+
for (let x = 0; x < image.width; x++) {
|
|
5798
|
+
const alpha = (y * image.width + x) * 4 + 3;
|
|
5799
|
+
if (x < 32 * scale && y < 16 * scale || y >= 16 * scale && y < 32 * scale || x >= 16 * scale && x < 48 * scale && y >= 48 * scale) {
|
|
5800
|
+
pixels[alpha] = 255;
|
|
5801
|
+
} else if (clearHat && x >= 32 * scale && y < 32 * scale) {
|
|
5802
|
+
pixels[alpha] = 0;
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
}
|
|
5806
|
+
return pixels;
|
|
5807
|
+
}
|
|
5808
|
+
};
|
|
5809
|
+
|
|
5810
|
+
// src/skin/scene/SkinObject.ts
|
|
5694
5811
|
var SkinObject = class extends SceneObject {
|
|
5695
5812
|
constructor(options) {
|
|
5696
5813
|
super();
|
|
5697
5814
|
this.slim = false;
|
|
5698
|
-
this.
|
|
5699
|
-
this.
|
|
5700
|
-
this.skinTextureHeight = 64;
|
|
5815
|
+
this.detectedSlim = false;
|
|
5816
|
+
this.skinLoad = 0;
|
|
5701
5817
|
this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5818
|
+
this.slim = this.options.slim ?? false;
|
|
5702
5819
|
}
|
|
5703
5820
|
async init() {
|
|
5704
5821
|
this.createMeshes();
|
|
@@ -5707,15 +5824,13 @@ var SkinObject = class extends SceneObject {
|
|
|
5707
5824
|
}
|
|
5708
5825
|
createMeshes() {
|
|
5709
5826
|
console.log("#createMeshes");
|
|
5710
|
-
const mat = Materials.MISSING_TEXTURE;
|
|
5827
|
+
const mat = this.skinMaterial ?? Materials.MISSING_TEXTURE;
|
|
5711
5828
|
{
|
|
5712
5829
|
const headGroup = this.createAndAddGroup("head", 0, 28, 0, "y" /* Y */, -4);
|
|
5713
5830
|
const headGeo = this.getBoxGeometry("head" /* HEAD */);
|
|
5714
5831
|
const head = this.createAndAddMesh("head", headGroup, headGeo, mat, "y" /* Y */, 4);
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5718
|
-
}
|
|
5832
|
+
const hatGeo = this.getBoxGeometry("hat" /* HAT */);
|
|
5833
|
+
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5719
5834
|
}
|
|
5720
5835
|
{
|
|
5721
5836
|
const bodyGroup = this.createAndAddGroup("body", 0, 18, 0);
|
|
@@ -5758,51 +5873,64 @@ var SkinObject = class extends SceneObject {
|
|
|
5758
5873
|
}
|
|
5759
5874
|
console.log("#createMeshes done");
|
|
5760
5875
|
}
|
|
5761
|
-
setSkinTexture(src) {
|
|
5876
|
+
async setSkinTexture(src) {
|
|
5762
5877
|
if (typeof src === "undefined") return;
|
|
5763
5878
|
this.skinTextureSrc = src;
|
|
5764
|
-
const
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5879
|
+
const load = ++this.skinLoad;
|
|
5880
|
+
const texture = await SkinTextures.get(src, this.options.legacy);
|
|
5881
|
+
if (load !== this.skinLoad) return;
|
|
5882
|
+
this.skinMaterial = texture.material;
|
|
5883
|
+
this.detectedSlim = texture.slim;
|
|
5884
|
+
this.updateSlim(this.options.slim ?? this.detectedSlim);
|
|
5885
|
+
for (const part of SKIN_PARTS) {
|
|
5886
|
+
const mesh = this.getMeshByName(part);
|
|
5770
5887
|
if (mesh) {
|
|
5771
|
-
mesh.material =
|
|
5888
|
+
mesh.material = texture.material;
|
|
5772
5889
|
}
|
|
5773
5890
|
}
|
|
5891
|
+
this.notifyDirty();
|
|
5774
5892
|
}
|
|
5775
5893
|
//TODO: cape
|
|
5894
|
+
/** Select the arm model, or pass undefined to use texture detection. */
|
|
5776
5895
|
setSlim(slim) {
|
|
5777
|
-
|
|
5778
|
-
|
|
5896
|
+
this.options.slim = slim;
|
|
5897
|
+
this.updateSlim(slim ?? this.detectedSlim);
|
|
5898
|
+
}
|
|
5899
|
+
updateSlim(slim) {
|
|
5900
|
+
if (slim === this.slim) return;
|
|
5779
5901
|
this.slim = slim;
|
|
5780
|
-
|
|
5781
|
-
this.
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5902
|
+
for (const part of ["leftArm" /* LEFT_ARM */, "leftSleeve" /* LEFT_SLEEVE */, "rightArm" /* RIGHT_ARM */, "rightSleeve" /* RIGHT_SLEEVE */]) {
|
|
5903
|
+
const mesh = this.getMeshByName(part);
|
|
5904
|
+
if (mesh) mesh.geometry = this.getBoxGeometry(part);
|
|
5905
|
+
}
|
|
5906
|
+
const offset = slim ? 0.5 : -0.5;
|
|
5907
|
+
const leftArm = this.getGroupByName("leftArm" /* LEFT_ARM */);
|
|
5908
|
+
const rightArm = this.getGroupByName("rightArm" /* RIGHT_ARM */);
|
|
5909
|
+
if (leftArm) leftArm.position.x += offset;
|
|
5910
|
+
if (rightArm) rightArm.position.x -= offset;
|
|
5911
|
+
this.notifyDirty();
|
|
5789
5912
|
}
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
this.legacy = legacy;
|
|
5913
|
+
/** Select the texture layout, or pass undefined to detect it from image dimensions. */
|
|
5914
|
+
async setLegacy(legacy) {
|
|
5915
|
+
if (legacy === this.options.legacy) return;
|
|
5916
|
+
this.options.legacy = legacy;
|
|
5917
|
+
if (this.skinTextureSrc) await this.setSkinTexture(this.skinTextureSrc);
|
|
5918
|
+
}
|
|
5919
|
+
dispose() {
|
|
5920
|
+
this.skinLoad++;
|
|
5921
|
+
super.dispose();
|
|
5794
5922
|
}
|
|
5795
5923
|
//TODO: layer toggles
|
|
5796
5924
|
getBoxGeometry(part) {
|
|
5797
5925
|
console.log("slim", this.slim);
|
|
5798
5926
|
const coordinates = this.slim ? slimSkinTextureCoordinates : classicSkinTextureCoordinates;
|
|
5799
5927
|
const geometries = this.slim ? slimSkinGeometries : classicSkinGeometries;
|
|
5800
|
-
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [
|
|
5928
|
+
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [64, 64]);
|
|
5801
5929
|
}
|
|
5802
5930
|
};
|
|
5803
5931
|
|
|
5804
5932
|
// src/renderer/MineRenderScene.ts
|
|
5805
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
5933
|
+
var MineRenderScene = class _MineRenderScene extends import_three19.Scene {
|
|
5806
5934
|
constructor(options) {
|
|
5807
5935
|
super();
|
|
5808
5936
|
this.isMineRenderScene = true;
|
|
@@ -5910,10 +6038,10 @@ var MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
|
5910
6038
|
this.dirty = true;
|
|
5911
6039
|
const obj = new SkinObject(options);
|
|
5912
6040
|
obj.scene = this;
|
|
5913
|
-
await obj.init();
|
|
5914
6041
|
if (skin) {
|
|
5915
|
-
obj.setSkinTexture(skin);
|
|
6042
|
+
await obj.setSkinTexture(skin);
|
|
5916
6043
|
}
|
|
6044
|
+
await obj.init();
|
|
5917
6045
|
parent.add(obj);
|
|
5918
6046
|
return obj;
|
|
5919
6047
|
}
|
|
@@ -5926,17 +6054,17 @@ function isMineRenderScene(obj) {
|
|
|
5926
6054
|
}
|
|
5927
6055
|
|
|
5928
6056
|
// src/renderer/Renderer.ts
|
|
5929
|
-
var
|
|
6057
|
+
var import_three21 = require("three");
|
|
5930
6058
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5931
6059
|
var import_stats = __toESM(require("stats.js"));
|
|
5932
6060
|
var import_postprocessing = require("postprocessing");
|
|
5933
6061
|
|
|
5934
6062
|
// src/three/OrbitControls.js
|
|
5935
|
-
var
|
|
6063
|
+
var import_three20 = require("three");
|
|
5936
6064
|
var _changeEvent = { type: "change" };
|
|
5937
6065
|
var _startEvent = { type: "start" };
|
|
5938
6066
|
var _endEvent = { type: "end" };
|
|
5939
|
-
var OrbitControls = class extends
|
|
6067
|
+
var OrbitControls = class extends import_three20.EventDispatcher {
|
|
5940
6068
|
constructor(object, domElement) {
|
|
5941
6069
|
super();
|
|
5942
6070
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5945,7 +6073,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5945
6073
|
this.domElement = domElement;
|
|
5946
6074
|
this.domElement.style.touchAction = "none";
|
|
5947
6075
|
this.enabled = true;
|
|
5948
|
-
this.target = new
|
|
6076
|
+
this.target = new import_three20.Vector3();
|
|
5949
6077
|
this.minDistance = 0;
|
|
5950
6078
|
this.maxDistance = Infinity;
|
|
5951
6079
|
this.minZoom = 0;
|
|
@@ -5967,8 +6095,8 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5967
6095
|
this.autoRotate = false;
|
|
5968
6096
|
this.autoRotateSpeed = 2;
|
|
5969
6097
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5970
|
-
this.mouseButtons = { LEFT:
|
|
5971
|
-
this.touches = { ONE:
|
|
6098
|
+
this.mouseButtons = { LEFT: import_three20.MOUSE.ROTATE, MIDDLE: import_three20.MOUSE.DOLLY, RIGHT: import_three20.MOUSE.PAN };
|
|
6099
|
+
this.touches = { ONE: import_three20.TOUCH.ROTATE, TWO: import_three20.TOUCH.DOLLY_PAN };
|
|
5972
6100
|
this.target0 = this.target.clone();
|
|
5973
6101
|
this.position0 = this.object.position.clone();
|
|
5974
6102
|
this.zoom0 = this.object.zoom;
|
|
@@ -5997,11 +6125,11 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5997
6125
|
state = STATE.NONE;
|
|
5998
6126
|
};
|
|
5999
6127
|
this.update = function() {
|
|
6000
|
-
const offset = new
|
|
6001
|
-
const quat = new
|
|
6128
|
+
const offset = new import_three20.Vector3();
|
|
6129
|
+
const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
|
|
6002
6130
|
const quatInverse = quat.clone().invert();
|
|
6003
|
-
const lastPosition = new
|
|
6004
|
-
const lastQuaternion = new
|
|
6131
|
+
const lastPosition = new import_three20.Vector3();
|
|
6132
|
+
const lastQuaternion = new import_three20.Quaternion();
|
|
6005
6133
|
const twoPI = 2 * Math.PI;
|
|
6006
6134
|
return function update() {
|
|
6007
6135
|
const position = scope.object.position;
|
|
@@ -6087,20 +6215,20 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6087
6215
|
};
|
|
6088
6216
|
let state = STATE.NONE;
|
|
6089
6217
|
const EPS = 1e-6;
|
|
6090
|
-
const spherical = new
|
|
6091
|
-
const sphericalDelta = new
|
|
6218
|
+
const spherical = new import_three20.Spherical();
|
|
6219
|
+
const sphericalDelta = new import_three20.Spherical();
|
|
6092
6220
|
let scale = 1;
|
|
6093
|
-
const panOffset = new
|
|
6221
|
+
const panOffset = new import_three20.Vector3();
|
|
6094
6222
|
let zoomChanged = false;
|
|
6095
|
-
const rotateStart = new
|
|
6096
|
-
const rotateEnd = new
|
|
6097
|
-
const rotateDelta = new
|
|
6098
|
-
const panStart = new
|
|
6099
|
-
const panEnd = new
|
|
6100
|
-
const panDelta = new
|
|
6101
|
-
const dollyStart = new
|
|
6102
|
-
const dollyEnd = new
|
|
6103
|
-
const dollyDelta = new
|
|
6223
|
+
const rotateStart = new import_three20.Vector2();
|
|
6224
|
+
const rotateEnd = new import_three20.Vector2();
|
|
6225
|
+
const rotateDelta = new import_three20.Vector2();
|
|
6226
|
+
const panStart = new import_three20.Vector2();
|
|
6227
|
+
const panEnd = new import_three20.Vector2();
|
|
6228
|
+
const panDelta = new import_three20.Vector2();
|
|
6229
|
+
const dollyStart = new import_three20.Vector2();
|
|
6230
|
+
const dollyEnd = new import_three20.Vector2();
|
|
6231
|
+
const dollyDelta = new import_three20.Vector2();
|
|
6104
6232
|
const pointers = [];
|
|
6105
6233
|
const pointerPositions = {};
|
|
6106
6234
|
function getAutoRotationAngle() {
|
|
@@ -6116,7 +6244,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6116
6244
|
sphericalDelta.phi -= angle;
|
|
6117
6245
|
}
|
|
6118
6246
|
const panLeft = function() {
|
|
6119
|
-
const v = new
|
|
6247
|
+
const v = new import_three20.Vector3();
|
|
6120
6248
|
return function panLeft2(distance, objectMatrix) {
|
|
6121
6249
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6122
6250
|
v.multiplyScalar(-distance);
|
|
@@ -6124,7 +6252,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6124
6252
|
};
|
|
6125
6253
|
}();
|
|
6126
6254
|
const panUp = function() {
|
|
6127
|
-
const v = new
|
|
6255
|
+
const v = new import_three20.Vector3();
|
|
6128
6256
|
return function panUp2(distance, objectMatrix) {
|
|
6129
6257
|
if (scope.screenSpacePanning === true) {
|
|
6130
6258
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6137,7 +6265,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6137
6265
|
};
|
|
6138
6266
|
}();
|
|
6139
6267
|
const pan = function() {
|
|
6140
|
-
const offset = new
|
|
6268
|
+
const offset = new import_three20.Vector3();
|
|
6141
6269
|
return function pan2(deltaX, deltaY) {
|
|
6142
6270
|
const element = scope.domElement;
|
|
6143
6271
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6386,12 +6514,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6386
6514
|
mouseAction = -1;
|
|
6387
6515
|
}
|
|
6388
6516
|
switch (mouseAction) {
|
|
6389
|
-
case
|
|
6517
|
+
case import_three20.MOUSE.DOLLY:
|
|
6390
6518
|
if (scope.enableZoom === false) return;
|
|
6391
6519
|
handleMouseDownDolly(event);
|
|
6392
6520
|
state = STATE.DOLLY;
|
|
6393
6521
|
break;
|
|
6394
|
-
case
|
|
6522
|
+
case import_three20.MOUSE.ROTATE:
|
|
6395
6523
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6396
6524
|
if (scope.enablePan === false) return;
|
|
6397
6525
|
handleMouseDownPan(event);
|
|
@@ -6402,7 +6530,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6402
6530
|
state = STATE.ROTATE;
|
|
6403
6531
|
}
|
|
6404
6532
|
break;
|
|
6405
|
-
case
|
|
6533
|
+
case import_three20.MOUSE.PAN:
|
|
6406
6534
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6407
6535
|
if (scope.enableRotate === false) return;
|
|
6408
6536
|
handleMouseDownRotate(event);
|
|
@@ -6458,12 +6586,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6458
6586
|
switch (pointers.length) {
|
|
6459
6587
|
case 1:
|
|
6460
6588
|
switch (scope.touches.ONE) {
|
|
6461
|
-
case
|
|
6589
|
+
case import_three20.TOUCH.ROTATE:
|
|
6462
6590
|
if (scope.enableRotate === false) return;
|
|
6463
6591
|
handleTouchStartRotate();
|
|
6464
6592
|
state = STATE.TOUCH_ROTATE;
|
|
6465
6593
|
break;
|
|
6466
|
-
case
|
|
6594
|
+
case import_three20.TOUCH.PAN:
|
|
6467
6595
|
if (scope.enablePan === false) return;
|
|
6468
6596
|
handleTouchStartPan();
|
|
6469
6597
|
state = STATE.TOUCH_PAN;
|
|
@@ -6474,12 +6602,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6474
6602
|
break;
|
|
6475
6603
|
case 2:
|
|
6476
6604
|
switch (scope.touches.TWO) {
|
|
6477
|
-
case
|
|
6605
|
+
case import_three20.TOUCH.DOLLY_PAN:
|
|
6478
6606
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6479
6607
|
handleTouchStartDollyPan();
|
|
6480
6608
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6481
6609
|
break;
|
|
6482
|
-
case
|
|
6610
|
+
case import_three20.TOUCH.DOLLY_ROTATE:
|
|
6483
6611
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6484
6612
|
handleTouchStartDollyRotate();
|
|
6485
6613
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6546,7 +6674,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6546
6674
|
function trackPointer(event) {
|
|
6547
6675
|
let position = pointerPositions[event.pointerId];
|
|
6548
6676
|
if (position === void 0) {
|
|
6549
|
-
position = new
|
|
6677
|
+
position = new import_three20.Vector2();
|
|
6550
6678
|
pointerPositions[event.pointerId] = position;
|
|
6551
6679
|
}
|
|
6552
6680
|
position.set(event.pageX, event.pageY);
|
|
@@ -6566,10 +6694,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6566
6694
|
constructor(object, domElement) {
|
|
6567
6695
|
super(object, domElement);
|
|
6568
6696
|
this.screenSpacePanning = false;
|
|
6569
|
-
this.mouseButtons.LEFT =
|
|
6570
|
-
this.mouseButtons.RIGHT =
|
|
6571
|
-
this.touches.ONE =
|
|
6572
|
-
this.touches.TWO =
|
|
6697
|
+
this.mouseButtons.LEFT = import_three20.MOUSE.PAN;
|
|
6698
|
+
this.mouseButtons.RIGHT = import_three20.MOUSE.ROTATE;
|
|
6699
|
+
this.touches.ONE = import_three20.TOUCH.PAN;
|
|
6700
|
+
this.touches.TWO = import_three20.TOUCH.DOLLY_ROTATE;
|
|
6573
6701
|
}
|
|
6574
6702
|
};
|
|
6575
6703
|
|
|
@@ -6614,8 +6742,8 @@ var Renderer = class _Renderer {
|
|
|
6614
6742
|
top: void 0,
|
|
6615
6743
|
bottom: void 0
|
|
6616
6744
|
},
|
|
6617
|
-
position: new
|
|
6618
|
-
lookingAt: new
|
|
6745
|
+
position: new import_three21.Vector3(50, 50, 50),
|
|
6746
|
+
lookingAt: new import_three21.Vector3(0, 0, 0)
|
|
6619
6747
|
},
|
|
6620
6748
|
render: {
|
|
6621
6749
|
fpsLimit: 60,
|
|
@@ -6645,14 +6773,14 @@ var Renderer = class _Renderer {
|
|
|
6645
6773
|
switch (this.options.camera.type) {
|
|
6646
6774
|
case "perspective":
|
|
6647
6775
|
default:
|
|
6648
|
-
return new
|
|
6776
|
+
return new import_three21.PerspectiveCamera(
|
|
6649
6777
|
this.options.camera.perspective.fov,
|
|
6650
6778
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6651
6779
|
this.options.camera.near,
|
|
6652
6780
|
this.options.camera.far
|
|
6653
6781
|
);
|
|
6654
6782
|
case "orthographic":
|
|
6655
|
-
return new
|
|
6783
|
+
return new import_three21.OrthographicCamera(
|
|
6656
6784
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6657
6785
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6658
6786
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6663,7 +6791,7 @@ var Renderer = class _Renderer {
|
|
|
6663
6791
|
}
|
|
6664
6792
|
}
|
|
6665
6793
|
createRenderer() {
|
|
6666
|
-
const renderer = new
|
|
6794
|
+
const renderer = new import_three21.WebGLRenderer({
|
|
6667
6795
|
antialias: this.options.render.antialias,
|
|
6668
6796
|
alpha: true,
|
|
6669
6797
|
powerPreference: "high-performance",
|
|
@@ -6671,8 +6799,8 @@ var Renderer = class _Renderer {
|
|
|
6671
6799
|
});
|
|
6672
6800
|
renderer.setClearColor(0, 0);
|
|
6673
6801
|
renderer.shadowMap.enabled = true;
|
|
6674
|
-
renderer.shadowMap.type =
|
|
6675
|
-
renderer.outputColorSpace =
|
|
6802
|
+
renderer.shadowMap.type = import_three21.PCFSoftShadowMap;
|
|
6803
|
+
renderer.outputColorSpace = import_three21.SRGBColorSpace;
|
|
6676
6804
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6677
6805
|
return renderer;
|
|
6678
6806
|
}
|
|
@@ -6706,20 +6834,20 @@ var Renderer = class _Renderer {
|
|
|
6706
6834
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6707
6835
|
}
|
|
6708
6836
|
if (this.options.debug.grid) {
|
|
6709
|
-
const gridHelper = new
|
|
6837
|
+
const gridHelper = new import_three21.GridHelper(128, 16);
|
|
6710
6838
|
this._debugHelpers.push(gridHelper);
|
|
6711
6839
|
this.scene.add(gridHelper);
|
|
6712
|
-
const gridHelper2 = new
|
|
6840
|
+
const gridHelper2 = new import_three21.GridHelper(128, 16);
|
|
6713
6841
|
this._debugHelpers.push(gridHelper2);
|
|
6714
6842
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6715
6843
|
this.scene.add(gridHelper2);
|
|
6716
|
-
const gridHelper3 = new
|
|
6844
|
+
const gridHelper3 = new import_three21.GridHelper(128, 16);
|
|
6717
6845
|
this._debugHelpers.push(gridHelper3);
|
|
6718
6846
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6719
6847
|
this.scene.add(gridHelper3);
|
|
6720
6848
|
}
|
|
6721
6849
|
if (this.options.debug.axes) {
|
|
6722
|
-
const axesHelper = new
|
|
6850
|
+
const axesHelper = new import_three21.AxesHelper(64);
|
|
6723
6851
|
this._debugHelpers.push(axesHelper);
|
|
6724
6852
|
this.scene.add(axesHelper);
|
|
6725
6853
|
}
|
|
@@ -7080,10 +7208,10 @@ var Skins = class {
|
|
|
7080
7208
|
};
|
|
7081
7209
|
|
|
7082
7210
|
// src/world/Chunk.ts
|
|
7083
|
-
var
|
|
7211
|
+
var import_three24 = require("three");
|
|
7084
7212
|
|
|
7085
7213
|
// src/world/MineRenderWorld.ts
|
|
7086
|
-
var
|
|
7214
|
+
var import_three23 = require("three");
|
|
7087
7215
|
var MineRenderWorld = class {
|
|
7088
7216
|
constructor(scene) {
|
|
7089
7217
|
this._size = 4;
|
|
@@ -7094,10 +7222,10 @@ var MineRenderWorld = class {
|
|
|
7094
7222
|
}
|
|
7095
7223
|
getBlockAt(posOrX, y, z) {
|
|
7096
7224
|
if (typeof posOrX == "number") {
|
|
7097
|
-
return this.getBlockAt(new
|
|
7225
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7098
7226
|
}
|
|
7099
7227
|
if (isTripleArray(posOrX)) {
|
|
7100
|
-
return this.getBlockAt(new
|
|
7228
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7101
7229
|
}
|
|
7102
7230
|
const chunk = this.getChunkAt(posOrX);
|
|
7103
7231
|
if (typeof chunk === "undefined") {
|
|
@@ -7108,10 +7236,10 @@ var MineRenderWorld = class {
|
|
|
7108
7236
|
}
|
|
7109
7237
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7110
7238
|
if (typeof posOrX == "number") {
|
|
7111
|
-
return this.setBlockAt(new
|
|
7239
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7112
7240
|
}
|
|
7113
7241
|
if (isTripleArray(posOrX)) {
|
|
7114
|
-
return this.setBlockAt(new
|
|
7242
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7115
7243
|
}
|
|
7116
7244
|
this.validatePosBounds(posOrX);
|
|
7117
7245
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7157,14 +7285,14 @@ var MineRenderWorld = class {
|
|
|
7157
7285
|
return this._chunks[index];
|
|
7158
7286
|
}
|
|
7159
7287
|
static worldToScenePosition(pos) {
|
|
7160
|
-
return new
|
|
7288
|
+
return new import_three23.Vector3(
|
|
7161
7289
|
pos.x * 16,
|
|
7162
7290
|
pos.y * 16,
|
|
7163
7291
|
pos.z * 16
|
|
7164
7292
|
);
|
|
7165
7293
|
}
|
|
7166
7294
|
static sceneToWorldPosition(pos) {
|
|
7167
|
-
return new
|
|
7295
|
+
return new import_three23.Vector3(
|
|
7168
7296
|
pos.x / 16,
|
|
7169
7297
|
pos.y / 16,
|
|
7170
7298
|
pos.z / 16
|
|
@@ -7201,12 +7329,12 @@ var Chunk = class _Chunk {
|
|
|
7201
7329
|
this.x = x;
|
|
7202
7330
|
this.y = y;
|
|
7203
7331
|
this.z = z;
|
|
7204
|
-
let anchor = new
|
|
7332
|
+
let anchor = new import_three24.Object3D();
|
|
7205
7333
|
this._anchor = anchor;
|
|
7206
7334
|
scene.add(anchor);
|
|
7207
7335
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7208
7336
|
addBox3WireframeToObject(
|
|
7209
|
-
new
|
|
7337
|
+
new import_three24.Box3(new import_three24.Vector3(0, 0, 0), new import_three24.Vector3(256, 256, 256)),
|
|
7210
7338
|
anchor,
|
|
7211
7339
|
16776960,
|
|
7212
7340
|
4
|
|
@@ -7214,10 +7342,10 @@ var Chunk = class _Chunk {
|
|
|
7214
7342
|
}
|
|
7215
7343
|
getBlockAt(posOrX, y, z) {
|
|
7216
7344
|
if (typeof posOrX == "number") {
|
|
7217
|
-
return this.getBlockAt(new
|
|
7345
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
|
|
7218
7346
|
}
|
|
7219
7347
|
if (isTripleArray(posOrX)) {
|
|
7220
|
-
return this.getBlockAt(new
|
|
7348
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7221
7349
|
}
|
|
7222
7350
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7223
7351
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7225,10 +7353,10 @@ var Chunk = class _Chunk {
|
|
|
7225
7353
|
}
|
|
7226
7354
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7227
7355
|
if (typeof posOrX == "number") {
|
|
7228
|
-
return this.setBlockAt(new
|
|
7356
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
|
|
7229
7357
|
}
|
|
7230
7358
|
if (isTripleArray(posOrX)) {
|
|
7231
|
-
return this.setBlockAt(new
|
|
7359
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7232
7360
|
}
|
|
7233
7361
|
const worldPos = posOrX;
|
|
7234
7362
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7274,7 +7402,7 @@ var Chunk = class _Chunk {
|
|
|
7274
7402
|
}
|
|
7275
7403
|
async clear() {
|
|
7276
7404
|
let promises = [];
|
|
7277
|
-
let pos = new
|
|
7405
|
+
let pos = new import_three24.Vector3();
|
|
7278
7406
|
for (let x = 0; x < 16; x++) {
|
|
7279
7407
|
for (let z = 0; z < 16; z++) {
|
|
7280
7408
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7293,14 +7421,14 @@ var Chunk = class _Chunk {
|
|
|
7293
7421
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7294
7422
|
}
|
|
7295
7423
|
worldPosToChunkPos(pos) {
|
|
7296
|
-
return new
|
|
7424
|
+
return new import_three24.Vector3(
|
|
7297
7425
|
pos.x - this.x * 16,
|
|
7298
7426
|
pos.y - this.y * 16,
|
|
7299
7427
|
pos.z - this.z * 16
|
|
7300
7428
|
);
|
|
7301
7429
|
}
|
|
7302
7430
|
chunkPosToWorldPos(pos) {
|
|
7303
|
-
return new
|
|
7431
|
+
return new import_three24.Vector3(
|
|
7304
7432
|
this.x * 16 + pos.x,
|
|
7305
7433
|
this.y * 16 + pos.y,
|
|
7306
7434
|
this.z * 16 + pos.z
|
|
@@ -7380,6 +7508,7 @@ var Chunk = class _Chunk {
|
|
|
7380
7508
|
SchematicParser,
|
|
7381
7509
|
SkinObject,
|
|
7382
7510
|
SkinPart,
|
|
7511
|
+
SkinTextures,
|
|
7383
7512
|
Skins,
|
|
7384
7513
|
StructureParser,
|
|
7385
7514
|
TextureAtlas,
|