minerender 2.1.0-alpha.17 → 2.1.0-alpha.19
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 +10 -0
- package/dist/browser/index.d.ts +10 -0
- package/dist/browser/index.js +99 -20
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +148 -69
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +99 -20
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +10 -0
- package/dist/node/index.d.ts +10 -0
- package/dist/node/index.js +99 -20
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +148 -69
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1087,7 +1087,7 @@ var Meshes = class _Meshes {
|
|
|
1087
1087
|
};
|
|
1088
1088
|
|
|
1089
1089
|
// src/UVMapper.ts
|
|
1090
|
-
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2 } from "three";
|
|
1090
|
+
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as Vector33 } from "three";
|
|
1091
1091
|
|
|
1092
1092
|
// src/model/ModelMerger.ts
|
|
1093
1093
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1123,6 +1123,7 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1123
1123
|
this.rootType = rootType;
|
|
1124
1124
|
this.extension = extension;
|
|
1125
1125
|
this.root = root;
|
|
1126
|
+
this.isAssetKey = true;
|
|
1126
1127
|
}
|
|
1127
1128
|
static parse(assetType, str, origin) {
|
|
1128
1129
|
let namespace = origin?.namespace || DEFAULT_NAMESPACE;
|
|
@@ -1138,7 +1139,10 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1138
1139
|
split.shift();
|
|
1139
1140
|
}
|
|
1140
1141
|
let path = split.join("/");
|
|
1141
|
-
|
|
1142
|
+
const extension = assetType === "textures" ? ".png" : origin?.extension ?? ".json";
|
|
1143
|
+
if (extension && path.endsWith(extension)) {
|
|
1144
|
+
path = path.slice(0, -extension.length);
|
|
1145
|
+
}
|
|
1142
1146
|
return new _AssetKey(namespace, path, assetType, type, "assets", extension, origin?.root);
|
|
1143
1147
|
}
|
|
1144
1148
|
toString() {
|
|
@@ -1168,10 +1172,10 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1168
1172
|
}
|
|
1169
1173
|
};
|
|
1170
1174
|
function isBasicAssetKey(obj) {
|
|
1171
|
-
return "
|
|
1175
|
+
return obj !== null && typeof obj === "object" && typeof obj.namespace === "string" && typeof obj.path === "string";
|
|
1172
1176
|
}
|
|
1173
1177
|
function isAssetKey(obj) {
|
|
1174
|
-
return isBasicAssetKey(obj) &&
|
|
1178
|
+
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1175
1179
|
}
|
|
1176
1180
|
|
|
1177
1181
|
// src/model/ModelMerger.ts
|
|
@@ -2049,6 +2053,14 @@ var DEFAULT_UV = [0, 0, 16, 16];
|
|
|
2049
2053
|
var X = 0;
|
|
2050
2054
|
var Y = 1;
|
|
2051
2055
|
var Z = 2;
|
|
2056
|
+
var FACE_UV_AXES = {
|
|
2057
|
+
east: [new Vector33(0, 0, -1), new Vector33(0, -1, 0)],
|
|
2058
|
+
west: [new Vector33(0, 0, 1), new Vector33(0, -1, 0)],
|
|
2059
|
+
up: [new Vector33(1, 0, 0), new Vector33(0, 0, 1)],
|
|
2060
|
+
down: [new Vector33(1, 0, 0), new Vector33(0, 0, -1)],
|
|
2061
|
+
south: [new Vector33(1, 0, 0), new Vector33(0, -1, 0)],
|
|
2062
|
+
north: [new Vector33(-1, 0, 0), new Vector33(0, -1, 0)]
|
|
2063
|
+
};
|
|
2052
2064
|
var UVMapper = class {
|
|
2053
2065
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
2054
2066
|
if (uvCoord === 0) return 0;
|
|
@@ -2146,6 +2158,42 @@ var UVMapper = class {
|
|
|
2146
2158
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2147
2159
|
return new Float32BufferAttribute2(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2148
2160
|
}
|
|
2161
|
+
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2162
|
+
const uv = geometry.getAttribute("uv");
|
|
2163
|
+
for (let faceIndex = 0; faceIndex < CUBE_FACES.length; faceIndex++) {
|
|
2164
|
+
const faceName = CUBE_FACES[faceIndex];
|
|
2165
|
+
const texture = faces[faceName]?.texture?.substring(1);
|
|
2166
|
+
const position = texture && atlas.positions[texture];
|
|
2167
|
+
const size = texture && atlas.sizes[texture];
|
|
2168
|
+
if (!position || !size) continue;
|
|
2169
|
+
const [sourceU, sourceV] = FACE_UV_AXES[faceName];
|
|
2170
|
+
const uAxis = sourceU.clone().applyEuler(rotation);
|
|
2171
|
+
const vAxis = sourceV.clone().applyEuler(rotation);
|
|
2172
|
+
const normal = vAxis.clone().cross(uAxis);
|
|
2173
|
+
const targetFace = CUBE_FACES.find((name) => {
|
|
2174
|
+
const [u, v] = FACE_UV_AXES[name];
|
|
2175
|
+
return v.clone().cross(u).dot(normal) > 0.5;
|
|
2176
|
+
});
|
|
2177
|
+
const [targetU, targetV] = FACE_UV_AXES[targetFace];
|
|
2178
|
+
const uu = Math.round(targetU.dot(uAxis));
|
|
2179
|
+
const uvCross = Math.round(targetU.dot(vAxis));
|
|
2180
|
+
const vu = Math.round(targetV.dot(uAxis));
|
|
2181
|
+
const vv = Math.round(targetV.dot(vAxis));
|
|
2182
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
2183
|
+
const index = faceIndex * 4 + corner;
|
|
2184
|
+
const u = (uv.getX(index) * atlas.image.width - position[0]) / size[0] - 0.5;
|
|
2185
|
+
const v = ((1 - uv.getY(index)) * atlas.image.height - position[1]) / size[1] - 0.5;
|
|
2186
|
+
const lockedU = uu * u + uvCross * v + 0.5;
|
|
2187
|
+
const lockedV = vu * u + vv * v + 0.5;
|
|
2188
|
+
uv.setXY(
|
|
2189
|
+
index,
|
|
2190
|
+
(position[0] + lockedU * size[0]) / atlas.image.width,
|
|
2191
|
+
1 - (position[1] + lockedV * size[1]) / atlas.image.height
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
uv.needsUpdate = true;
|
|
2196
|
+
}
|
|
2149
2197
|
static async getAtlas(model) {
|
|
2150
2198
|
const keyStr = model.key.serialize();
|
|
2151
2199
|
return Caching.modelTextureAtlasCache.get(keyStr, (k) => {
|
|
@@ -2592,7 +2640,7 @@ var BlockEntityModels = class {
|
|
|
2592
2640
|
};
|
|
2593
2641
|
|
|
2594
2642
|
// src/renderer/SceneObject.ts
|
|
2595
|
-
import { Euler, InstancedMesh, MathUtils, Matrix4 as Matrix42, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion2, Vector3 as
|
|
2643
|
+
import { Euler as Euler2, InstancedMesh, MathUtils, Matrix4 as Matrix42, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion2, Vector3 as Vector34 } from "three";
|
|
2596
2644
|
|
|
2597
2645
|
// src/instance/InstanceReference.ts
|
|
2598
2646
|
var InstanceReference = class {
|
|
@@ -2752,6 +2800,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2752
2800
|
}
|
|
2753
2801
|
createInstancedMesh(name, geometry, material, count) {
|
|
2754
2802
|
const mesh = new InstancedMesh(geometry, material, count);
|
|
2803
|
+
mesh.count = 0;
|
|
2755
2804
|
if (name) {
|
|
2756
2805
|
mesh.name = `mesh:${name}`;
|
|
2757
2806
|
}
|
|
@@ -2829,6 +2878,10 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2829
2878
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2830
2879
|
const i = this._instanceCounter++;
|
|
2831
2880
|
this.setMatrixAt(i, new Matrix42());
|
|
2881
|
+
const mesh = this.children[0];
|
|
2882
|
+
if (mesh && isInstancedMesh(mesh)) {
|
|
2883
|
+
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
2884
|
+
}
|
|
2832
2885
|
console.debug(p6, "nextInstance " + i);
|
|
2833
2886
|
if (i === this.options.maxInstanceCount) {
|
|
2834
2887
|
console.warn(p6, "Max instance count reached for " + this);
|
|
@@ -2860,9 +2913,9 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2860
2913
|
}
|
|
2861
2914
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2862
2915
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2863
|
-
const oldPosition = new
|
|
2916
|
+
const oldPosition = new Vector34();
|
|
2864
2917
|
const oldRotation = new Quaternion2();
|
|
2865
|
-
const oldScale = new
|
|
2918
|
+
const oldScale = new Vector34();
|
|
2866
2919
|
const matrix = new Matrix42();
|
|
2867
2920
|
if (!scale || !rotation || !position) {
|
|
2868
2921
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
@@ -2878,7 +2931,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2878
2931
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2879
2932
|
this.setPositionRotationScaleAt(index, position);
|
|
2880
2933
|
}
|
|
2881
|
-
getPositionAt(index, vector = new
|
|
2934
|
+
getPositionAt(index, vector = new Vector34()) {
|
|
2882
2935
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2883
2936
|
const matrix = this.getMatrixAt(index);
|
|
2884
2937
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2888,7 +2941,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2888
2941
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2889
2942
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
2890
2943
|
}
|
|
2891
|
-
getRotationAt(index, euler = new
|
|
2944
|
+
getRotationAt(index, euler = new Euler2()) {
|
|
2892
2945
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2893
2946
|
const matrix = this.getMatrixAt(index);
|
|
2894
2947
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -2898,7 +2951,7 @@ var _SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2898
2951
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2899
2952
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
2900
2953
|
}
|
|
2901
|
-
getScaleAt(index, vector = new
|
|
2954
|
+
getScaleAt(index, vector = new Vector34()) {
|
|
2902
2955
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2903
2956
|
const matrix = this.getMatrixAt(index);
|
|
2904
2957
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3561,7 +3614,7 @@ function isQuadArray(obj) {
|
|
|
3561
3614
|
}
|
|
3562
3615
|
|
|
3563
3616
|
// src/model/scene/ModelObject.ts
|
|
3564
|
-
import { BoxGeometry as BoxGeometry5, Matrix4 as Matrix45 } from "three";
|
|
3617
|
+
import { BoxGeometry as BoxGeometry5, Euler as Euler4, Matrix4 as Matrix45 } from "three";
|
|
3565
3618
|
|
|
3566
3619
|
// src/three/BufferGeometryUtils.js
|
|
3567
3620
|
import {
|
|
@@ -3573,7 +3626,7 @@ import {
|
|
|
3573
3626
|
TriangleFanDrawMode,
|
|
3574
3627
|
TriangleStripDrawMode,
|
|
3575
3628
|
TrianglesDrawMode,
|
|
3576
|
-
Vector3 as
|
|
3629
|
+
Vector3 as Vector36
|
|
3577
3630
|
} from "three";
|
|
3578
3631
|
function computeTangents(geometry) {
|
|
3579
3632
|
geometry.computeTangents();
|
|
@@ -3892,15 +3945,15 @@ function computeMorphedAttributes(object) {
|
|
|
3892
3945
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3893
3946
|
return null;
|
|
3894
3947
|
}
|
|
3895
|
-
const _vA = new
|
|
3896
|
-
const _vB = new
|
|
3897
|
-
const _vC = new
|
|
3898
|
-
const _tempA = new
|
|
3899
|
-
const _tempB = new
|
|
3900
|
-
const _tempC = new
|
|
3901
|
-
const _morphA = new
|
|
3902
|
-
const _morphB = new
|
|
3903
|
-
const _morphC = new
|
|
3948
|
+
const _vA = new Vector36();
|
|
3949
|
+
const _vB = new Vector36();
|
|
3950
|
+
const _vC = new Vector36();
|
|
3951
|
+
const _tempA = new Vector36();
|
|
3952
|
+
const _tempB = new Vector36();
|
|
3953
|
+
const _tempC = new Vector36();
|
|
3954
|
+
const _morphA = new Vector36();
|
|
3955
|
+
const _morphB = new Vector36();
|
|
3956
|
+
const _morphC = new Vector36();
|
|
3904
3957
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3905
3958
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3906
3959
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4141,6 +4194,9 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4141
4194
|
if (this.atlas.model.elements) {
|
|
4142
4195
|
this.atlas.model.elements?.forEach((el) => {
|
|
4143
4196
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4197
|
+
if (this.options.uvLockRotation) {
|
|
4198
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler4(...this.options.uvLockRotation));
|
|
4199
|
+
}
|
|
4144
4200
|
elGeo.applyMatrix4(new Matrix45().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4145
4201
|
elGeo.applyMatrix4(new Matrix45().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4146
4202
|
if (el.rotation) {
|
|
@@ -4220,7 +4276,7 @@ function isModelObject(obj) {
|
|
|
4220
4276
|
|
|
4221
4277
|
// src/model/block/scene/BlockObject.ts
|
|
4222
4278
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4223
|
-
import { Euler as
|
|
4279
|
+
import { Euler as Euler5, Matrix4 as Matrix46, Vector3 as Vector37 } from "three";
|
|
4224
4280
|
var p10 = prefix("BlockObject");
|
|
4225
4281
|
function matchesCondition(condition, state) {
|
|
4226
4282
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4277,7 +4333,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4277
4333
|
if (isModelObject(model)) {
|
|
4278
4334
|
model.removeFromScene();
|
|
4279
4335
|
} else if (isInstanceReference(model)) {
|
|
4280
|
-
model.setScale(new
|
|
4336
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4281
4337
|
}
|
|
4282
4338
|
}
|
|
4283
4339
|
super.removeFromScene();
|
|
@@ -4338,7 +4394,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4338
4394
|
}
|
|
4339
4395
|
for (let model of this._models) {
|
|
4340
4396
|
if (isInstanceReference(model)) {
|
|
4341
|
-
model.setScale(new
|
|
4397
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4342
4398
|
} else {
|
|
4343
4399
|
model.dispose();
|
|
4344
4400
|
}
|
|
@@ -4375,25 +4431,24 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4375
4431
|
await this.createVariant(variant);
|
|
4376
4432
|
}
|
|
4377
4433
|
async createVariant(variant) {
|
|
4378
|
-
const
|
|
4379
|
-
const obj = await this.scene.addModel(model, this.options);
|
|
4380
|
-
if (isInstanceReference(obj) || obj.isInstanced) {
|
|
4381
|
-
this._isInstanced = true;
|
|
4382
|
-
this._instanceCounter = 1;
|
|
4383
|
-
}
|
|
4384
|
-
let rotation = new Euler3(0, 0, 0);
|
|
4434
|
+
const rotation = new Euler5();
|
|
4385
4435
|
if (typeof variant.x !== "undefined") {
|
|
4386
4436
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4387
4437
|
}
|
|
4388
4438
|
if (typeof variant.y !== "undefined") {
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4439
|
+
rotation.y = toRadians(clampRotationDegrees(typeof variant.x !== "undefined" ? variant.y : 360 - variant.y));
|
|
4440
|
+
}
|
|
4441
|
+
const model = await Models.getMerged(AssetKey.parse("models", variant.model));
|
|
4442
|
+
const options = {
|
|
4443
|
+
...this.options,
|
|
4444
|
+
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
4445
|
+
};
|
|
4446
|
+
const obj = await this.scene.addModel(model, options);
|
|
4447
|
+
if (isInstanceReference(obj) || obj.isInstanced) {
|
|
4448
|
+
this._isInstanced = true;
|
|
4449
|
+
this._instanceCounter = 1;
|
|
4394
4450
|
}
|
|
4395
4451
|
obj.setRotation(rotation);
|
|
4396
|
-
console.log(obj);
|
|
4397
4452
|
return obj;
|
|
4398
4453
|
}
|
|
4399
4454
|
async resetState() {
|
|
@@ -5456,7 +5511,8 @@ var _MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5456
5511
|
const obj = await objectSupplier();
|
|
5457
5512
|
if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
|
|
5458
5513
|
console.log("instanceMeshes + key");
|
|
5459
|
-
const
|
|
5514
|
+
const uvLockRotation = isModelObject(obj) ? obj.options.uvLockRotation : void 0;
|
|
5515
|
+
const key = asset.key.serialize() + (uvLockRotation ? `|uvlock:${uvLockRotation.join(",")}` : "");
|
|
5460
5516
|
return this.instanceManager.getOrCreate(key, async () => {
|
|
5461
5517
|
obj.scene = this;
|
|
5462
5518
|
await obj.init();
|
|
@@ -5501,7 +5557,7 @@ function isMineRenderScene(obj) {
|
|
|
5501
5557
|
}
|
|
5502
5558
|
|
|
5503
5559
|
// src/renderer/Renderer.ts
|
|
5504
|
-
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as
|
|
5560
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector39, WebGLRenderer } from "three";
|
|
5505
5561
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5506
5562
|
import Stats from "stats.js";
|
|
5507
5563
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5514,7 +5570,7 @@ import {
|
|
|
5514
5570
|
Spherical,
|
|
5515
5571
|
TOUCH,
|
|
5516
5572
|
Vector2 as Vector23,
|
|
5517
|
-
Vector3 as
|
|
5573
|
+
Vector3 as Vector38
|
|
5518
5574
|
} from "three";
|
|
5519
5575
|
var _changeEvent = { type: "change" };
|
|
5520
5576
|
var _startEvent = { type: "start" };
|
|
@@ -5528,7 +5584,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5528
5584
|
this.domElement = domElement;
|
|
5529
5585
|
this.domElement.style.touchAction = "none";
|
|
5530
5586
|
this.enabled = true;
|
|
5531
|
-
this.target = new
|
|
5587
|
+
this.target = new Vector38();
|
|
5532
5588
|
this.minDistance = 0;
|
|
5533
5589
|
this.maxDistance = Infinity;
|
|
5534
5590
|
this.minZoom = 0;
|
|
@@ -5580,10 +5636,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5580
5636
|
state = STATE.NONE;
|
|
5581
5637
|
};
|
|
5582
5638
|
this.update = function() {
|
|
5583
|
-
const offset = new
|
|
5584
|
-
const quat = new Quaternion3().setFromUnitVectors(object.up, new
|
|
5639
|
+
const offset = new Vector38();
|
|
5640
|
+
const quat = new Quaternion3().setFromUnitVectors(object.up, new Vector38(0, 1, 0));
|
|
5585
5641
|
const quatInverse = quat.clone().invert();
|
|
5586
|
-
const lastPosition = new
|
|
5642
|
+
const lastPosition = new Vector38();
|
|
5587
5643
|
const lastQuaternion = new Quaternion3();
|
|
5588
5644
|
const twoPI = 2 * Math.PI;
|
|
5589
5645
|
return function update() {
|
|
@@ -5673,7 +5729,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5673
5729
|
const spherical = new Spherical();
|
|
5674
5730
|
const sphericalDelta = new Spherical();
|
|
5675
5731
|
let scale = 1;
|
|
5676
|
-
const panOffset = new
|
|
5732
|
+
const panOffset = new Vector38();
|
|
5677
5733
|
let zoomChanged = false;
|
|
5678
5734
|
const rotateStart = new Vector23();
|
|
5679
5735
|
const rotateEnd = new Vector23();
|
|
@@ -5699,7 +5755,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5699
5755
|
sphericalDelta.phi -= angle;
|
|
5700
5756
|
}
|
|
5701
5757
|
const panLeft = function() {
|
|
5702
|
-
const v = new
|
|
5758
|
+
const v = new Vector38();
|
|
5703
5759
|
return function panLeft2(distance, objectMatrix) {
|
|
5704
5760
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5705
5761
|
v.multiplyScalar(-distance);
|
|
@@ -5707,7 +5763,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5707
5763
|
};
|
|
5708
5764
|
}();
|
|
5709
5765
|
const panUp = function() {
|
|
5710
|
-
const v = new
|
|
5766
|
+
const v = new Vector38();
|
|
5711
5767
|
return function panUp2(distance, objectMatrix) {
|
|
5712
5768
|
if (scope.screenSpacePanning === true) {
|
|
5713
5769
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5720,7 +5776,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5720
5776
|
};
|
|
5721
5777
|
}();
|
|
5722
5778
|
const pan = function() {
|
|
5723
|
-
const offset = new
|
|
5779
|
+
const offset = new Vector38();
|
|
5724
5780
|
return function pan2(deltaX, deltaY) {
|
|
5725
5781
|
const element = scope.domElement;
|
|
5726
5782
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6467,8 +6523,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
6467
6523
|
top: void 0,
|
|
6468
6524
|
bottom: void 0
|
|
6469
6525
|
},
|
|
6470
|
-
position: new
|
|
6471
|
-
lookingAt: new
|
|
6526
|
+
position: new Vector39(50, 50, 50),
|
|
6527
|
+
lookingAt: new Vector39(0, 0, 0)
|
|
6472
6528
|
},
|
|
6473
6529
|
render: {
|
|
6474
6530
|
fpsLimit: 60,
|
|
@@ -6501,7 +6557,7 @@ var Skins = class {
|
|
|
6501
6557
|
return this.fromUsername(uuidOrUsername);
|
|
6502
6558
|
}
|
|
6503
6559
|
static async fromUuid(uuid) {
|
|
6504
|
-
return this.
|
|
6560
|
+
return this.getMcProxySkinUrl(uuid);
|
|
6505
6561
|
}
|
|
6506
6562
|
static async fromUsername(username) {
|
|
6507
6563
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6528,7 +6584,7 @@ var Skins = class {
|
|
|
6528
6584
|
return this.capeFromUsername(uuidOrUsername);
|
|
6529
6585
|
}
|
|
6530
6586
|
static async capeFromUuid(uuid) {
|
|
6531
|
-
return this.
|
|
6587
|
+
return this.getMcProxyCapeUrl(uuid);
|
|
6532
6588
|
}
|
|
6533
6589
|
static async capeFromUsername(username) {
|
|
6534
6590
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6549,8 +6605,23 @@ var Skins = class {
|
|
|
6549
6605
|
//</editor-fold>
|
|
6550
6606
|
//<editor-fold desc="Helpers">
|
|
6551
6607
|
static async usernameToUuid(username) {
|
|
6552
|
-
return this.
|
|
6608
|
+
return this.usernameToUuidMcProxy(username);
|
|
6609
|
+
}
|
|
6610
|
+
static async usernameToUuidMcProxy(username) {
|
|
6611
|
+
return Requests.genericRequest({
|
|
6612
|
+
baseURL: "https://mcproxy.dev",
|
|
6613
|
+
url: "/uuid/" + username
|
|
6614
|
+
}).then((res) => {
|
|
6615
|
+
if (res.status === 200) {
|
|
6616
|
+
return res.data["data"]["id"];
|
|
6617
|
+
}
|
|
6618
|
+
return void 0;
|
|
6619
|
+
}).catch((err) => {
|
|
6620
|
+
console.warn(err);
|
|
6621
|
+
return void 0;
|
|
6622
|
+
});
|
|
6553
6623
|
}
|
|
6624
|
+
/** @deprecated **/
|
|
6554
6625
|
static async usernameToUuidSkinProxy(username) {
|
|
6555
6626
|
return Requests.genericRequest({
|
|
6556
6627
|
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
@@ -6629,20 +6700,28 @@ var Skins = class {
|
|
|
6629
6700
|
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6630
6701
|
return "https://mineskin.org/skin/player/" + uuid;
|
|
6631
6702
|
}
|
|
6703
|
+
/** @deprecated **/
|
|
6632
6704
|
static getSkinProxySkinUrl(uuid) {
|
|
6633
6705
|
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
6634
6706
|
}
|
|
6707
|
+
/** @deprecated **/
|
|
6635
6708
|
static getSkinProxyCapeUrl(uuid) {
|
|
6636
6709
|
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
6637
6710
|
}
|
|
6711
|
+
static getMcProxySkinUrl(uuid) {
|
|
6712
|
+
return "https://mcproxy.dev/skin/" + uuid;
|
|
6713
|
+
}
|
|
6714
|
+
static getMcProxyCapeUrl(uuid) {
|
|
6715
|
+
return "https://mcproxy.dev/cape/" + uuid;
|
|
6716
|
+
}
|
|
6638
6717
|
//</editor-fold>
|
|
6639
6718
|
};
|
|
6640
6719
|
|
|
6641
6720
|
// src/world/Chunk.ts
|
|
6642
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6721
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector311 } from "three";
|
|
6643
6722
|
|
|
6644
6723
|
// src/world/MineRenderWorld.ts
|
|
6645
|
-
import { Vector3 as
|
|
6724
|
+
import { Vector3 as Vector310 } from "three";
|
|
6646
6725
|
var MineRenderWorld = class {
|
|
6647
6726
|
constructor(scene) {
|
|
6648
6727
|
this._size = 4;
|
|
@@ -6653,10 +6732,10 @@ var MineRenderWorld = class {
|
|
|
6653
6732
|
}
|
|
6654
6733
|
getBlockAt(posOrX, y, z) {
|
|
6655
6734
|
if (typeof posOrX == "number") {
|
|
6656
|
-
return this.getBlockAt(new
|
|
6735
|
+
return this.getBlockAt(new Vector310(posOrX, y, z));
|
|
6657
6736
|
}
|
|
6658
6737
|
if (isTripleArray(posOrX)) {
|
|
6659
|
-
return this.getBlockAt(new
|
|
6738
|
+
return this.getBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]));
|
|
6660
6739
|
}
|
|
6661
6740
|
const chunk = this.getChunkAt(posOrX);
|
|
6662
6741
|
if (typeof chunk === "undefined") {
|
|
@@ -6667,10 +6746,10 @@ var MineRenderWorld = class {
|
|
|
6667
6746
|
}
|
|
6668
6747
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6669
6748
|
if (typeof posOrX == "number") {
|
|
6670
|
-
return this.setBlockAt(new
|
|
6749
|
+
return this.setBlockAt(new Vector310(posOrX, yOrBlock, z), block);
|
|
6671
6750
|
}
|
|
6672
6751
|
if (isTripleArray(posOrX)) {
|
|
6673
|
-
return this.setBlockAt(new
|
|
6752
|
+
return this.setBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6674
6753
|
}
|
|
6675
6754
|
this.validatePosBounds(posOrX);
|
|
6676
6755
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6716,14 +6795,14 @@ var MineRenderWorld = class {
|
|
|
6716
6795
|
return this._chunks[index];
|
|
6717
6796
|
}
|
|
6718
6797
|
static worldToScenePosition(pos) {
|
|
6719
|
-
return new
|
|
6798
|
+
return new Vector310(
|
|
6720
6799
|
pos.x * 16,
|
|
6721
6800
|
pos.y * 16,
|
|
6722
6801
|
pos.z * 16
|
|
6723
6802
|
);
|
|
6724
6803
|
}
|
|
6725
6804
|
static sceneToWorldPosition(pos) {
|
|
6726
|
-
return new
|
|
6805
|
+
return new Vector310(
|
|
6727
6806
|
pos.x / 16,
|
|
6728
6807
|
pos.y / 16,
|
|
6729
6808
|
pos.z / 16
|
|
@@ -6765,7 +6844,7 @@ var Chunk = class _Chunk {
|
|
|
6765
6844
|
scene.add(anchor);
|
|
6766
6845
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
6767
6846
|
addBox3WireframeToObject(
|
|
6768
|
-
new Box32(new
|
|
6847
|
+
new Box32(new Vector311(0, 0, 0), new Vector311(256, 256, 256)),
|
|
6769
6848
|
anchor,
|
|
6770
6849
|
16776960,
|
|
6771
6850
|
4
|
|
@@ -6773,10 +6852,10 @@ var Chunk = class _Chunk {
|
|
|
6773
6852
|
}
|
|
6774
6853
|
getBlockAt(posOrX, y, z) {
|
|
6775
6854
|
if (typeof posOrX == "number") {
|
|
6776
|
-
return this.getBlockAt(new
|
|
6855
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6777
6856
|
}
|
|
6778
6857
|
if (isTripleArray(posOrX)) {
|
|
6779
|
-
return this.getBlockAt(new
|
|
6858
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6780
6859
|
}
|
|
6781
6860
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
6782
6861
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -6784,10 +6863,10 @@ var Chunk = class _Chunk {
|
|
|
6784
6863
|
}
|
|
6785
6864
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6786
6865
|
if (typeof posOrX == "number") {
|
|
6787
|
-
return this.setBlockAt(new
|
|
6866
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6788
6867
|
}
|
|
6789
6868
|
if (isTripleArray(posOrX)) {
|
|
6790
|
-
return this.setBlockAt(new
|
|
6869
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6791
6870
|
}
|
|
6792
6871
|
const worldPos = posOrX;
|
|
6793
6872
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -6833,7 +6912,7 @@ var Chunk = class _Chunk {
|
|
|
6833
6912
|
}
|
|
6834
6913
|
async clear() {
|
|
6835
6914
|
let promises = [];
|
|
6836
|
-
let pos = new
|
|
6915
|
+
let pos = new Vector311();
|
|
6837
6916
|
for (let x = 0; x < 16; x++) {
|
|
6838
6917
|
for (let z = 0; z < 16; z++) {
|
|
6839
6918
|
for (let y = 0; y < 16; y++) {
|
|
@@ -6852,14 +6931,14 @@ var Chunk = class _Chunk {
|
|
|
6852
6931
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
6853
6932
|
}
|
|
6854
6933
|
worldPosToChunkPos(pos) {
|
|
6855
|
-
return new
|
|
6934
|
+
return new Vector311(
|
|
6856
6935
|
pos.x - this.x * 16,
|
|
6857
6936
|
pos.y - this.y * 16,
|
|
6858
6937
|
pos.z - this.z * 16
|
|
6859
6938
|
);
|
|
6860
6939
|
}
|
|
6861
6940
|
chunkPosToWorldPos(pos) {
|
|
6862
|
-
return new
|
|
6941
|
+
return new Vector311(
|
|
6863
6942
|
this.x * 16 + pos.x,
|
|
6864
6943
|
this.y * 16 + pos.y,
|
|
6865
6944
|
this.z * 16 + pos.z
|