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.
- package/dist/browser/index.d.mts +26 -8
- package/dist/browser/index.d.ts +26 -8
- package/dist/browser/index.js +185 -90
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +120 -25
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +130 -23
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +26 -8
- package/dist/node/index.d.ts +26 -8
- package/dist/node/index.js +186 -90
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +120 -25
- 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
|
|
@@ -5725,14 +5726,96 @@ var slimSkinGeometries = {
|
|
|
5725
5726
|
|
|
5726
5727
|
// src/skin/scene/SkinObject.ts
|
|
5727
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
|
|
5728
5811
|
var SkinObject = class extends SceneObject {
|
|
5729
5812
|
constructor(options) {
|
|
5730
5813
|
super();
|
|
5731
5814
|
this.slim = false;
|
|
5732
|
-
this.
|
|
5733
|
-
this.
|
|
5734
|
-
this.skinTextureHeight = 64;
|
|
5815
|
+
this.detectedSlim = false;
|
|
5816
|
+
this.skinLoad = 0;
|
|
5735
5817
|
this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5818
|
+
this.slim = this.options.slim ?? false;
|
|
5736
5819
|
}
|
|
5737
5820
|
async init() {
|
|
5738
5821
|
this.createMeshes();
|
|
@@ -5741,15 +5824,13 @@ var SkinObject = class extends SceneObject {
|
|
|
5741
5824
|
}
|
|
5742
5825
|
createMeshes() {
|
|
5743
5826
|
console.log("#createMeshes");
|
|
5744
|
-
const mat = Materials.MISSING_TEXTURE;
|
|
5827
|
+
const mat = this.skinMaterial ?? Materials.MISSING_TEXTURE;
|
|
5745
5828
|
{
|
|
5746
5829
|
const headGroup = this.createAndAddGroup("head", 0, 28, 0, "y" /* Y */, -4);
|
|
5747
5830
|
const headGeo = this.getBoxGeometry("head" /* HEAD */);
|
|
5748
5831
|
const head = this.createAndAddMesh("head", headGroup, headGeo, mat, "y" /* Y */, 4);
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5752
|
-
}
|
|
5832
|
+
const hatGeo = this.getBoxGeometry("hat" /* HAT */);
|
|
5833
|
+
const hat = this.createAndAddMesh("hat", headGroup, hatGeo, mat, "y" /* Y */, 4);
|
|
5753
5834
|
}
|
|
5754
5835
|
{
|
|
5755
5836
|
const bodyGroup = this.createAndAddGroup("body", 0, 18, 0);
|
|
@@ -5792,21 +5873,30 @@ var SkinObject = class extends SceneObject {
|
|
|
5792
5873
|
}
|
|
5793
5874
|
console.log("#createMeshes done");
|
|
5794
5875
|
}
|
|
5795
|
-
setSkinTexture(src) {
|
|
5876
|
+
async setSkinTexture(src) {
|
|
5796
5877
|
if (typeof src === "undefined") return;
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5878
|
+
this.skinTextureSrc = src;
|
|
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);
|
|
5803
5887
|
if (mesh) {
|
|
5804
|
-
mesh.material =
|
|
5888
|
+
mesh.material = texture.material;
|
|
5805
5889
|
}
|
|
5806
5890
|
}
|
|
5891
|
+
this.notifyDirty();
|
|
5807
5892
|
}
|
|
5808
5893
|
//TODO: cape
|
|
5894
|
+
/** Select the arm model, or pass undefined to use texture detection. */
|
|
5809
5895
|
setSlim(slim) {
|
|
5896
|
+
this.options.slim = slim;
|
|
5897
|
+
this.updateSlim(slim ?? this.detectedSlim);
|
|
5898
|
+
}
|
|
5899
|
+
updateSlim(slim) {
|
|
5810
5900
|
if (slim === this.slim) return;
|
|
5811
5901
|
this.slim = slim;
|
|
5812
5902
|
for (const part of ["leftArm" /* LEFT_ARM */, "leftSleeve" /* LEFT_SLEEVE */, "rightArm" /* RIGHT_ARM */, "rightSleeve" /* RIGHT_SLEEVE */]) {
|
|
@@ -5820,22 +5910,27 @@ var SkinObject = class extends SceneObject {
|
|
|
5820
5910
|
if (rightArm) rightArm.position.x -= offset;
|
|
5821
5911
|
this.notifyDirty();
|
|
5822
5912
|
}
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
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();
|
|
5827
5922
|
}
|
|
5828
5923
|
//TODO: layer toggles
|
|
5829
5924
|
getBoxGeometry(part) {
|
|
5830
5925
|
console.log("slim", this.slim);
|
|
5831
5926
|
const coordinates = this.slim ? slimSkinTextureCoordinates : classicSkinTextureCoordinates;
|
|
5832
5927
|
const geometries = this.slim ? slimSkinGeometries : classicSkinGeometries;
|
|
5833
|
-
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [
|
|
5928
|
+
return this._getBoxGeometryFromDimensions(geometries[part], coordinates[part], [64, 64], [64, 64]);
|
|
5834
5929
|
}
|
|
5835
5930
|
};
|
|
5836
5931
|
|
|
5837
5932
|
// src/renderer/MineRenderScene.ts
|
|
5838
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
5933
|
+
var MineRenderScene = class _MineRenderScene extends import_three19.Scene {
|
|
5839
5934
|
constructor(options) {
|
|
5840
5935
|
super();
|
|
5841
5936
|
this.isMineRenderScene = true;
|
|
@@ -5943,10 +6038,10 @@ var MineRenderScene = class _MineRenderScene extends import_three18.Scene {
|
|
|
5943
6038
|
this.dirty = true;
|
|
5944
6039
|
const obj = new SkinObject(options);
|
|
5945
6040
|
obj.scene = this;
|
|
5946
|
-
await obj.init();
|
|
5947
6041
|
if (skin) {
|
|
5948
|
-
obj.setSkinTexture(skin);
|
|
6042
|
+
await obj.setSkinTexture(skin);
|
|
5949
6043
|
}
|
|
6044
|
+
await obj.init();
|
|
5950
6045
|
parent.add(obj);
|
|
5951
6046
|
return obj;
|
|
5952
6047
|
}
|
|
@@ -5959,17 +6054,17 @@ function isMineRenderScene(obj) {
|
|
|
5959
6054
|
}
|
|
5960
6055
|
|
|
5961
6056
|
// src/renderer/Renderer.ts
|
|
5962
|
-
var
|
|
6057
|
+
var import_three21 = require("three");
|
|
5963
6058
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5964
6059
|
var import_stats = __toESM(require("stats.js"));
|
|
5965
6060
|
var import_postprocessing = require("postprocessing");
|
|
5966
6061
|
|
|
5967
6062
|
// src/three/OrbitControls.js
|
|
5968
|
-
var
|
|
6063
|
+
var import_three20 = require("three");
|
|
5969
6064
|
var _changeEvent = { type: "change" };
|
|
5970
6065
|
var _startEvent = { type: "start" };
|
|
5971
6066
|
var _endEvent = { type: "end" };
|
|
5972
|
-
var OrbitControls = class extends
|
|
6067
|
+
var OrbitControls = class extends import_three20.EventDispatcher {
|
|
5973
6068
|
constructor(object, domElement) {
|
|
5974
6069
|
super();
|
|
5975
6070
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5978,7 +6073,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
5978
6073
|
this.domElement = domElement;
|
|
5979
6074
|
this.domElement.style.touchAction = "none";
|
|
5980
6075
|
this.enabled = true;
|
|
5981
|
-
this.target = new
|
|
6076
|
+
this.target = new import_three20.Vector3();
|
|
5982
6077
|
this.minDistance = 0;
|
|
5983
6078
|
this.maxDistance = Infinity;
|
|
5984
6079
|
this.minZoom = 0;
|
|
@@ -6000,8 +6095,8 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6000
6095
|
this.autoRotate = false;
|
|
6001
6096
|
this.autoRotateSpeed = 2;
|
|
6002
6097
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
6003
|
-
this.mouseButtons = { LEFT:
|
|
6004
|
-
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 };
|
|
6005
6100
|
this.target0 = this.target.clone();
|
|
6006
6101
|
this.position0 = this.object.position.clone();
|
|
6007
6102
|
this.zoom0 = this.object.zoom;
|
|
@@ -6030,11 +6125,11 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6030
6125
|
state = STATE.NONE;
|
|
6031
6126
|
};
|
|
6032
6127
|
this.update = function() {
|
|
6033
|
-
const offset = new
|
|
6034
|
-
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));
|
|
6035
6130
|
const quatInverse = quat.clone().invert();
|
|
6036
|
-
const lastPosition = new
|
|
6037
|
-
const lastQuaternion = new
|
|
6131
|
+
const lastPosition = new import_three20.Vector3();
|
|
6132
|
+
const lastQuaternion = new import_three20.Quaternion();
|
|
6038
6133
|
const twoPI = 2 * Math.PI;
|
|
6039
6134
|
return function update() {
|
|
6040
6135
|
const position = scope.object.position;
|
|
@@ -6120,20 +6215,20 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6120
6215
|
};
|
|
6121
6216
|
let state = STATE.NONE;
|
|
6122
6217
|
const EPS = 1e-6;
|
|
6123
|
-
const spherical = new
|
|
6124
|
-
const sphericalDelta = new
|
|
6218
|
+
const spherical = new import_three20.Spherical();
|
|
6219
|
+
const sphericalDelta = new import_three20.Spherical();
|
|
6125
6220
|
let scale = 1;
|
|
6126
|
-
const panOffset = new
|
|
6221
|
+
const panOffset = new import_three20.Vector3();
|
|
6127
6222
|
let zoomChanged = false;
|
|
6128
|
-
const rotateStart = new
|
|
6129
|
-
const rotateEnd = new
|
|
6130
|
-
const rotateDelta = new
|
|
6131
|
-
const panStart = new
|
|
6132
|
-
const panEnd = new
|
|
6133
|
-
const panDelta = new
|
|
6134
|
-
const dollyStart = new
|
|
6135
|
-
const dollyEnd = new
|
|
6136
|
-
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();
|
|
6137
6232
|
const pointers = [];
|
|
6138
6233
|
const pointerPositions = {};
|
|
6139
6234
|
function getAutoRotationAngle() {
|
|
@@ -6149,7 +6244,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6149
6244
|
sphericalDelta.phi -= angle;
|
|
6150
6245
|
}
|
|
6151
6246
|
const panLeft = function() {
|
|
6152
|
-
const v = new
|
|
6247
|
+
const v = new import_three20.Vector3();
|
|
6153
6248
|
return function panLeft2(distance, objectMatrix) {
|
|
6154
6249
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6155
6250
|
v.multiplyScalar(-distance);
|
|
@@ -6157,7 +6252,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6157
6252
|
};
|
|
6158
6253
|
}();
|
|
6159
6254
|
const panUp = function() {
|
|
6160
|
-
const v = new
|
|
6255
|
+
const v = new import_three20.Vector3();
|
|
6161
6256
|
return function panUp2(distance, objectMatrix) {
|
|
6162
6257
|
if (scope.screenSpacePanning === true) {
|
|
6163
6258
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6170,7 +6265,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6170
6265
|
};
|
|
6171
6266
|
}();
|
|
6172
6267
|
const pan = function() {
|
|
6173
|
-
const offset = new
|
|
6268
|
+
const offset = new import_three20.Vector3();
|
|
6174
6269
|
return function pan2(deltaX, deltaY) {
|
|
6175
6270
|
const element = scope.domElement;
|
|
6176
6271
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6419,12 +6514,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6419
6514
|
mouseAction = -1;
|
|
6420
6515
|
}
|
|
6421
6516
|
switch (mouseAction) {
|
|
6422
|
-
case
|
|
6517
|
+
case import_three20.MOUSE.DOLLY:
|
|
6423
6518
|
if (scope.enableZoom === false) return;
|
|
6424
6519
|
handleMouseDownDolly(event);
|
|
6425
6520
|
state = STATE.DOLLY;
|
|
6426
6521
|
break;
|
|
6427
|
-
case
|
|
6522
|
+
case import_three20.MOUSE.ROTATE:
|
|
6428
6523
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6429
6524
|
if (scope.enablePan === false) return;
|
|
6430
6525
|
handleMouseDownPan(event);
|
|
@@ -6435,7 +6530,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6435
6530
|
state = STATE.ROTATE;
|
|
6436
6531
|
}
|
|
6437
6532
|
break;
|
|
6438
|
-
case
|
|
6533
|
+
case import_three20.MOUSE.PAN:
|
|
6439
6534
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6440
6535
|
if (scope.enableRotate === false) return;
|
|
6441
6536
|
handleMouseDownRotate(event);
|
|
@@ -6491,12 +6586,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6491
6586
|
switch (pointers.length) {
|
|
6492
6587
|
case 1:
|
|
6493
6588
|
switch (scope.touches.ONE) {
|
|
6494
|
-
case
|
|
6589
|
+
case import_three20.TOUCH.ROTATE:
|
|
6495
6590
|
if (scope.enableRotate === false) return;
|
|
6496
6591
|
handleTouchStartRotate();
|
|
6497
6592
|
state = STATE.TOUCH_ROTATE;
|
|
6498
6593
|
break;
|
|
6499
|
-
case
|
|
6594
|
+
case import_three20.TOUCH.PAN:
|
|
6500
6595
|
if (scope.enablePan === false) return;
|
|
6501
6596
|
handleTouchStartPan();
|
|
6502
6597
|
state = STATE.TOUCH_PAN;
|
|
@@ -6507,12 +6602,12 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6507
6602
|
break;
|
|
6508
6603
|
case 2:
|
|
6509
6604
|
switch (scope.touches.TWO) {
|
|
6510
|
-
case
|
|
6605
|
+
case import_three20.TOUCH.DOLLY_PAN:
|
|
6511
6606
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6512
6607
|
handleTouchStartDollyPan();
|
|
6513
6608
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6514
6609
|
break;
|
|
6515
|
-
case
|
|
6610
|
+
case import_three20.TOUCH.DOLLY_ROTATE:
|
|
6516
6611
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6517
6612
|
handleTouchStartDollyRotate();
|
|
6518
6613
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6579,7 +6674,7 @@ var OrbitControls = class extends import_three19.EventDispatcher {
|
|
|
6579
6674
|
function trackPointer(event) {
|
|
6580
6675
|
let position = pointerPositions[event.pointerId];
|
|
6581
6676
|
if (position === void 0) {
|
|
6582
|
-
position = new
|
|
6677
|
+
position = new import_three20.Vector2();
|
|
6583
6678
|
pointerPositions[event.pointerId] = position;
|
|
6584
6679
|
}
|
|
6585
6680
|
position.set(event.pageX, event.pageY);
|
|
@@ -6599,10 +6694,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6599
6694
|
constructor(object, domElement) {
|
|
6600
6695
|
super(object, domElement);
|
|
6601
6696
|
this.screenSpacePanning = false;
|
|
6602
|
-
this.mouseButtons.LEFT =
|
|
6603
|
-
this.mouseButtons.RIGHT =
|
|
6604
|
-
this.touches.ONE =
|
|
6605
|
-
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;
|
|
6606
6701
|
}
|
|
6607
6702
|
};
|
|
6608
6703
|
|
|
@@ -6647,8 +6742,8 @@ var Renderer = class _Renderer {
|
|
|
6647
6742
|
top: void 0,
|
|
6648
6743
|
bottom: void 0
|
|
6649
6744
|
},
|
|
6650
|
-
position: new
|
|
6651
|
-
lookingAt: new
|
|
6745
|
+
position: new import_three21.Vector3(50, 50, 50),
|
|
6746
|
+
lookingAt: new import_three21.Vector3(0, 0, 0)
|
|
6652
6747
|
},
|
|
6653
6748
|
render: {
|
|
6654
6749
|
fpsLimit: 60,
|
|
@@ -6678,14 +6773,14 @@ var Renderer = class _Renderer {
|
|
|
6678
6773
|
switch (this.options.camera.type) {
|
|
6679
6774
|
case "perspective":
|
|
6680
6775
|
default:
|
|
6681
|
-
return new
|
|
6776
|
+
return new import_three21.PerspectiveCamera(
|
|
6682
6777
|
this.options.camera.perspective.fov,
|
|
6683
6778
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6684
6779
|
this.options.camera.near,
|
|
6685
6780
|
this.options.camera.far
|
|
6686
6781
|
);
|
|
6687
6782
|
case "orthographic":
|
|
6688
|
-
return new
|
|
6783
|
+
return new import_three21.OrthographicCamera(
|
|
6689
6784
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6690
6785
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6691
6786
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6696,7 +6791,7 @@ var Renderer = class _Renderer {
|
|
|
6696
6791
|
}
|
|
6697
6792
|
}
|
|
6698
6793
|
createRenderer() {
|
|
6699
|
-
const renderer = new
|
|
6794
|
+
const renderer = new import_three21.WebGLRenderer({
|
|
6700
6795
|
antialias: this.options.render.antialias,
|
|
6701
6796
|
alpha: true,
|
|
6702
6797
|
powerPreference: "high-performance",
|
|
@@ -6704,8 +6799,8 @@ var Renderer = class _Renderer {
|
|
|
6704
6799
|
});
|
|
6705
6800
|
renderer.setClearColor(0, 0);
|
|
6706
6801
|
renderer.shadowMap.enabled = true;
|
|
6707
|
-
renderer.shadowMap.type =
|
|
6708
|
-
renderer.outputColorSpace =
|
|
6802
|
+
renderer.shadowMap.type = import_three21.PCFSoftShadowMap;
|
|
6803
|
+
renderer.outputColorSpace = import_three21.SRGBColorSpace;
|
|
6709
6804
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6710
6805
|
return renderer;
|
|
6711
6806
|
}
|
|
@@ -6739,20 +6834,20 @@ var Renderer = class _Renderer {
|
|
|
6739
6834
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6740
6835
|
}
|
|
6741
6836
|
if (this.options.debug.grid) {
|
|
6742
|
-
const gridHelper = new
|
|
6837
|
+
const gridHelper = new import_three21.GridHelper(128, 16);
|
|
6743
6838
|
this._debugHelpers.push(gridHelper);
|
|
6744
6839
|
this.scene.add(gridHelper);
|
|
6745
|
-
const gridHelper2 = new
|
|
6840
|
+
const gridHelper2 = new import_three21.GridHelper(128, 16);
|
|
6746
6841
|
this._debugHelpers.push(gridHelper2);
|
|
6747
6842
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6748
6843
|
this.scene.add(gridHelper2);
|
|
6749
|
-
const gridHelper3 = new
|
|
6844
|
+
const gridHelper3 = new import_three21.GridHelper(128, 16);
|
|
6750
6845
|
this._debugHelpers.push(gridHelper3);
|
|
6751
6846
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6752
6847
|
this.scene.add(gridHelper3);
|
|
6753
6848
|
}
|
|
6754
6849
|
if (this.options.debug.axes) {
|
|
6755
|
-
const axesHelper = new
|
|
6850
|
+
const axesHelper = new import_three21.AxesHelper(64);
|
|
6756
6851
|
this._debugHelpers.push(axesHelper);
|
|
6757
6852
|
this.scene.add(axesHelper);
|
|
6758
6853
|
}
|
|
@@ -7113,10 +7208,10 @@ var Skins = class {
|
|
|
7113
7208
|
};
|
|
7114
7209
|
|
|
7115
7210
|
// src/world/Chunk.ts
|
|
7116
|
-
var
|
|
7211
|
+
var import_three24 = require("three");
|
|
7117
7212
|
|
|
7118
7213
|
// src/world/MineRenderWorld.ts
|
|
7119
|
-
var
|
|
7214
|
+
var import_three23 = require("three");
|
|
7120
7215
|
var MineRenderWorld = class {
|
|
7121
7216
|
constructor(scene) {
|
|
7122
7217
|
this._size = 4;
|
|
@@ -7127,10 +7222,10 @@ var MineRenderWorld = class {
|
|
|
7127
7222
|
}
|
|
7128
7223
|
getBlockAt(posOrX, y, z) {
|
|
7129
7224
|
if (typeof posOrX == "number") {
|
|
7130
|
-
return this.getBlockAt(new
|
|
7225
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
|
|
7131
7226
|
}
|
|
7132
7227
|
if (isTripleArray(posOrX)) {
|
|
7133
|
-
return this.getBlockAt(new
|
|
7228
|
+
return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7134
7229
|
}
|
|
7135
7230
|
const chunk = this.getChunkAt(posOrX);
|
|
7136
7231
|
if (typeof chunk === "undefined") {
|
|
@@ -7141,10 +7236,10 @@ var MineRenderWorld = class {
|
|
|
7141
7236
|
}
|
|
7142
7237
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7143
7238
|
if (typeof posOrX == "number") {
|
|
7144
|
-
return this.setBlockAt(new
|
|
7239
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
|
|
7145
7240
|
}
|
|
7146
7241
|
if (isTripleArray(posOrX)) {
|
|
7147
|
-
return this.setBlockAt(new
|
|
7242
|
+
return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7148
7243
|
}
|
|
7149
7244
|
this.validatePosBounds(posOrX);
|
|
7150
7245
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7190,14 +7285,14 @@ var MineRenderWorld = class {
|
|
|
7190
7285
|
return this._chunks[index];
|
|
7191
7286
|
}
|
|
7192
7287
|
static worldToScenePosition(pos) {
|
|
7193
|
-
return new
|
|
7288
|
+
return new import_three23.Vector3(
|
|
7194
7289
|
pos.x * 16,
|
|
7195
7290
|
pos.y * 16,
|
|
7196
7291
|
pos.z * 16
|
|
7197
7292
|
);
|
|
7198
7293
|
}
|
|
7199
7294
|
static sceneToWorldPosition(pos) {
|
|
7200
|
-
return new
|
|
7295
|
+
return new import_three23.Vector3(
|
|
7201
7296
|
pos.x / 16,
|
|
7202
7297
|
pos.y / 16,
|
|
7203
7298
|
pos.z / 16
|
|
@@ -7234,12 +7329,12 @@ var Chunk = class _Chunk {
|
|
|
7234
7329
|
this.x = x;
|
|
7235
7330
|
this.y = y;
|
|
7236
7331
|
this.z = z;
|
|
7237
|
-
let anchor = new
|
|
7332
|
+
let anchor = new import_three24.Object3D();
|
|
7238
7333
|
this._anchor = anchor;
|
|
7239
7334
|
scene.add(anchor);
|
|
7240
7335
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7241
7336
|
addBox3WireframeToObject(
|
|
7242
|
-
new
|
|
7337
|
+
new import_three24.Box3(new import_three24.Vector3(0, 0, 0), new import_three24.Vector3(256, 256, 256)),
|
|
7243
7338
|
anchor,
|
|
7244
7339
|
16776960,
|
|
7245
7340
|
4
|
|
@@ -7247,10 +7342,10 @@ var Chunk = class _Chunk {
|
|
|
7247
7342
|
}
|
|
7248
7343
|
getBlockAt(posOrX, y, z) {
|
|
7249
7344
|
if (typeof posOrX == "number") {
|
|
7250
|
-
return this.getBlockAt(new
|
|
7345
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
|
|
7251
7346
|
}
|
|
7252
7347
|
if (isTripleArray(posOrX)) {
|
|
7253
|
-
return this.getBlockAt(new
|
|
7348
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7254
7349
|
}
|
|
7255
7350
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7256
7351
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7258,10 +7353,10 @@ var Chunk = class _Chunk {
|
|
|
7258
7353
|
}
|
|
7259
7354
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7260
7355
|
if (typeof posOrX == "number") {
|
|
7261
|
-
return this.setBlockAt(new
|
|
7356
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
|
|
7262
7357
|
}
|
|
7263
7358
|
if (isTripleArray(posOrX)) {
|
|
7264
|
-
return this.setBlockAt(new
|
|
7359
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7265
7360
|
}
|
|
7266
7361
|
const worldPos = posOrX;
|
|
7267
7362
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7307,7 +7402,7 @@ var Chunk = class _Chunk {
|
|
|
7307
7402
|
}
|
|
7308
7403
|
async clear() {
|
|
7309
7404
|
let promises = [];
|
|
7310
|
-
let pos = new
|
|
7405
|
+
let pos = new import_three24.Vector3();
|
|
7311
7406
|
for (let x = 0; x < 16; x++) {
|
|
7312
7407
|
for (let z = 0; z < 16; z++) {
|
|
7313
7408
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7326,14 +7421,14 @@ var Chunk = class _Chunk {
|
|
|
7326
7421
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7327
7422
|
}
|
|
7328
7423
|
worldPosToChunkPos(pos) {
|
|
7329
|
-
return new
|
|
7424
|
+
return new import_three24.Vector3(
|
|
7330
7425
|
pos.x - this.x * 16,
|
|
7331
7426
|
pos.y - this.y * 16,
|
|
7332
7427
|
pos.z - this.z * 16
|
|
7333
7428
|
);
|
|
7334
7429
|
}
|
|
7335
7430
|
chunkPosToWorldPos(pos) {
|
|
7336
|
-
return new
|
|
7431
|
+
return new import_three24.Vector3(
|
|
7337
7432
|
this.x * 16 + pos.x,
|
|
7338
7433
|
this.y * 16 + pos.y,
|
|
7339
7434
|
this.z * 16 + pos.z
|
|
@@ -7413,6 +7508,7 @@ var Chunk = class _Chunk {
|
|
|
7413
7508
|
SchematicParser,
|
|
7414
7509
|
SkinObject,
|
|
7415
7510
|
SkinPart,
|
|
7511
|
+
SkinTextures,
|
|
7416
7512
|
Skins,
|
|
7417
7513
|
StructureParser,
|
|
7418
7514
|
TextureAtlas,
|