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/node/index.mjs
CHANGED
|
@@ -1090,7 +1090,7 @@ var Meshes = class _Meshes {
|
|
|
1090
1090
|
};
|
|
1091
1091
|
|
|
1092
1092
|
// src/UVMapper.ts
|
|
1093
|
-
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2 } from "three";
|
|
1093
|
+
import { Float32BufferAttribute as Float32BufferAttribute2, Vector2, Vector3 as Vector33 } from "three";
|
|
1094
1094
|
|
|
1095
1095
|
// src/model/ModelMerger.ts
|
|
1096
1096
|
var import_ts_deepmerge = __toESM(require_dist());
|
|
@@ -1126,6 +1126,7 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1126
1126
|
this.rootType = rootType;
|
|
1127
1127
|
this.extension = extension;
|
|
1128
1128
|
this.root = root;
|
|
1129
|
+
this.isAssetKey = true;
|
|
1129
1130
|
}
|
|
1130
1131
|
static parse(assetType, str, origin) {
|
|
1131
1132
|
let namespace = origin?.namespace || DEFAULT_NAMESPACE;
|
|
@@ -1141,7 +1142,10 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1141
1142
|
split.shift();
|
|
1142
1143
|
}
|
|
1143
1144
|
let path = split.join("/");
|
|
1144
|
-
|
|
1145
|
+
const extension = assetType === "textures" ? ".png" : origin?.extension ?? ".json";
|
|
1146
|
+
if (extension && path.endsWith(extension)) {
|
|
1147
|
+
path = path.slice(0, -extension.length);
|
|
1148
|
+
}
|
|
1145
1149
|
return new _AssetKey(namespace, path, assetType, type, "assets", extension, origin?.root);
|
|
1146
1150
|
}
|
|
1147
1151
|
toString() {
|
|
@@ -1171,10 +1175,10 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1171
1175
|
}
|
|
1172
1176
|
};
|
|
1173
1177
|
function isBasicAssetKey(obj) {
|
|
1174
|
-
return "
|
|
1178
|
+
return obj !== null && typeof obj === "object" && typeof obj.namespace === "string" && typeof obj.path === "string";
|
|
1175
1179
|
}
|
|
1176
1180
|
function isAssetKey(obj) {
|
|
1177
|
-
return isBasicAssetKey(obj) &&
|
|
1181
|
+
return isBasicAssetKey(obj) && obj.isAssetKey === true;
|
|
1178
1182
|
}
|
|
1179
1183
|
|
|
1180
1184
|
// src/model/ModelMerger.ts
|
|
@@ -2087,6 +2091,14 @@ var DEFAULT_UV = [0, 0, 16, 16];
|
|
|
2087
2091
|
var X = 0;
|
|
2088
2092
|
var Y = 1;
|
|
2089
2093
|
var Z = 2;
|
|
2094
|
+
var FACE_UV_AXES = {
|
|
2095
|
+
east: [new Vector33(0, 0, -1), new Vector33(0, -1, 0)],
|
|
2096
|
+
west: [new Vector33(0, 0, 1), new Vector33(0, -1, 0)],
|
|
2097
|
+
up: [new Vector33(1, 0, 0), new Vector33(0, 0, 1)],
|
|
2098
|
+
down: [new Vector33(1, 0, 0), new Vector33(0, 0, -1)],
|
|
2099
|
+
south: [new Vector33(1, 0, 0), new Vector33(0, -1, 0)],
|
|
2100
|
+
north: [new Vector33(-1, 0, 0), new Vector33(0, -1, 0)]
|
|
2101
|
+
};
|
|
2090
2102
|
var UVMapper = class {
|
|
2091
2103
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
2092
2104
|
if (uvCoord === 0) return 0;
|
|
@@ -2184,6 +2196,42 @@ var UVMapper = class {
|
|
|
2184
2196
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2185
2197
|
return new Float32BufferAttribute2(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2186
2198
|
}
|
|
2199
|
+
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2200
|
+
const uv = geometry.getAttribute("uv");
|
|
2201
|
+
for (let faceIndex = 0; faceIndex < CUBE_FACES.length; faceIndex++) {
|
|
2202
|
+
const faceName = CUBE_FACES[faceIndex];
|
|
2203
|
+
const texture = faces[faceName]?.texture?.substring(1);
|
|
2204
|
+
const position = texture && atlas.positions[texture];
|
|
2205
|
+
const size = texture && atlas.sizes[texture];
|
|
2206
|
+
if (!position || !size) continue;
|
|
2207
|
+
const [sourceU, sourceV] = FACE_UV_AXES[faceName];
|
|
2208
|
+
const uAxis = sourceU.clone().applyEuler(rotation);
|
|
2209
|
+
const vAxis = sourceV.clone().applyEuler(rotation);
|
|
2210
|
+
const normal = vAxis.clone().cross(uAxis);
|
|
2211
|
+
const targetFace = CUBE_FACES.find((name) => {
|
|
2212
|
+
const [u, v] = FACE_UV_AXES[name];
|
|
2213
|
+
return v.clone().cross(u).dot(normal) > 0.5;
|
|
2214
|
+
});
|
|
2215
|
+
const [targetU, targetV] = FACE_UV_AXES[targetFace];
|
|
2216
|
+
const uu = Math.round(targetU.dot(uAxis));
|
|
2217
|
+
const uvCross = Math.round(targetU.dot(vAxis));
|
|
2218
|
+
const vu = Math.round(targetV.dot(uAxis));
|
|
2219
|
+
const vv = Math.round(targetV.dot(vAxis));
|
|
2220
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
2221
|
+
const index = faceIndex * 4 + corner;
|
|
2222
|
+
const u = (uv.getX(index) * atlas.image.width - position[0]) / size[0] - 0.5;
|
|
2223
|
+
const v = ((1 - uv.getY(index)) * atlas.image.height - position[1]) / size[1] - 0.5;
|
|
2224
|
+
const lockedU = uu * u + uvCross * v + 0.5;
|
|
2225
|
+
const lockedV = vu * u + vv * v + 0.5;
|
|
2226
|
+
uv.setXY(
|
|
2227
|
+
index,
|
|
2228
|
+
(position[0] + lockedU * size[0]) / atlas.image.width,
|
|
2229
|
+
1 - (position[1] + lockedV * size[1]) / atlas.image.height
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
uv.needsUpdate = true;
|
|
2234
|
+
}
|
|
2187
2235
|
static async getAtlas(model) {
|
|
2188
2236
|
const keyStr = model.key.serialize();
|
|
2189
2237
|
return Caching.modelTextureAtlasCache.get(keyStr, (k) => {
|
|
@@ -2630,7 +2678,7 @@ var BlockEntityModels = class {
|
|
|
2630
2678
|
};
|
|
2631
2679
|
|
|
2632
2680
|
// src/renderer/SceneObject.ts
|
|
2633
|
-
import { Euler, InstancedMesh, MathUtils, Matrix4 as Matrix42, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion2, Vector3 as
|
|
2681
|
+
import { Euler as Euler2, InstancedMesh, MathUtils, Matrix4 as Matrix42, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion2, Vector3 as Vector34 } from "three";
|
|
2634
2682
|
|
|
2635
2683
|
// src/instance/InstanceReference.ts
|
|
2636
2684
|
var InstanceReference = class {
|
|
@@ -2798,6 +2846,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2798
2846
|
}
|
|
2799
2847
|
createInstancedMesh(name, geometry, material, count) {
|
|
2800
2848
|
const mesh = new InstancedMesh(geometry, material, count);
|
|
2849
|
+
mesh.count = 0;
|
|
2801
2850
|
if (name) {
|
|
2802
2851
|
mesh.name = `mesh:${name}`;
|
|
2803
2852
|
}
|
|
@@ -2875,6 +2924,10 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2875
2924
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2876
2925
|
const i = this._instanceCounter++;
|
|
2877
2926
|
this.setMatrixAt(i, new Matrix42());
|
|
2927
|
+
const mesh = this.children[0];
|
|
2928
|
+
if (mesh && isInstancedMesh(mesh)) {
|
|
2929
|
+
mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
|
|
2930
|
+
}
|
|
2878
2931
|
console.debug(p6, "nextInstance " + i);
|
|
2879
2932
|
if (i === this.options.maxInstanceCount) {
|
|
2880
2933
|
console.warn(p6, "Max instance count reached for " + this);
|
|
@@ -2906,9 +2959,9 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2906
2959
|
}
|
|
2907
2960
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2908
2961
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2909
|
-
const oldPosition = new
|
|
2962
|
+
const oldPosition = new Vector34();
|
|
2910
2963
|
const oldRotation = new Quaternion2();
|
|
2911
|
-
const oldScale = new
|
|
2964
|
+
const oldScale = new Vector34();
|
|
2912
2965
|
const matrix = new Matrix42();
|
|
2913
2966
|
if (!scale || !rotation || !position) {
|
|
2914
2967
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
@@ -2924,7 +2977,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2924
2977
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2925
2978
|
this.setPositionRotationScaleAt(index, position);
|
|
2926
2979
|
}
|
|
2927
|
-
getPositionAt(index, vector = new
|
|
2980
|
+
getPositionAt(index, vector = new Vector34()) {
|
|
2928
2981
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2929
2982
|
const matrix = this.getMatrixAt(index);
|
|
2930
2983
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2934,7 +2987,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2934
2987
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2935
2988
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
2936
2989
|
}
|
|
2937
|
-
getRotationAt(index, euler = new
|
|
2990
|
+
getRotationAt(index, euler = new Euler2()) {
|
|
2938
2991
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2939
2992
|
const matrix = this.getMatrixAt(index);
|
|
2940
2993
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -2944,7 +2997,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2944
2997
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2945
2998
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
2946
2999
|
}
|
|
2947
|
-
getScaleAt(index, vector = new
|
|
3000
|
+
getScaleAt(index, vector = new Vector34()) {
|
|
2948
3001
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2949
3002
|
const matrix = this.getMatrixAt(index);
|
|
2950
3003
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3602,7 +3655,7 @@ function isQuadArray(obj) {
|
|
|
3602
3655
|
}
|
|
3603
3656
|
|
|
3604
3657
|
// src/model/scene/ModelObject.ts
|
|
3605
|
-
import { BoxGeometry as BoxGeometry5, Matrix4 as Matrix45 } from "three";
|
|
3658
|
+
import { BoxGeometry as BoxGeometry5, Euler as Euler4, Matrix4 as Matrix45 } from "three";
|
|
3606
3659
|
|
|
3607
3660
|
// src/three/BufferGeometryUtils.js
|
|
3608
3661
|
import {
|
|
@@ -3614,7 +3667,7 @@ import {
|
|
|
3614
3667
|
TriangleFanDrawMode,
|
|
3615
3668
|
TriangleStripDrawMode,
|
|
3616
3669
|
TrianglesDrawMode,
|
|
3617
|
-
Vector3 as
|
|
3670
|
+
Vector3 as Vector36
|
|
3618
3671
|
} from "three";
|
|
3619
3672
|
function computeTangents(geometry) {
|
|
3620
3673
|
geometry.computeTangents();
|
|
@@ -3933,15 +3986,15 @@ function computeMorphedAttributes(object) {
|
|
|
3933
3986
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3934
3987
|
return null;
|
|
3935
3988
|
}
|
|
3936
|
-
const _vA = new
|
|
3937
|
-
const _vB = new
|
|
3938
|
-
const _vC = new
|
|
3939
|
-
const _tempA = new
|
|
3940
|
-
const _tempB = new
|
|
3941
|
-
const _tempC = new
|
|
3942
|
-
const _morphA = new
|
|
3943
|
-
const _morphB = new
|
|
3944
|
-
const _morphC = new
|
|
3989
|
+
const _vA = new Vector36();
|
|
3990
|
+
const _vB = new Vector36();
|
|
3991
|
+
const _vC = new Vector36();
|
|
3992
|
+
const _tempA = new Vector36();
|
|
3993
|
+
const _tempB = new Vector36();
|
|
3994
|
+
const _tempC = new Vector36();
|
|
3995
|
+
const _morphA = new Vector36();
|
|
3996
|
+
const _morphB = new Vector36();
|
|
3997
|
+
const _morphC = new Vector36();
|
|
3945
3998
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3946
3999
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3947
4000
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4185,6 +4238,9 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4185
4238
|
if (this.atlas.model.elements) {
|
|
4186
4239
|
this.atlas.model.elements?.forEach((el) => {
|
|
4187
4240
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4241
|
+
if (this.options.uvLockRotation) {
|
|
4242
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler4(...this.options.uvLockRotation));
|
|
4243
|
+
}
|
|
4188
4244
|
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));
|
|
4189
4245
|
elGeo.applyMatrix4(new Matrix45().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4190
4246
|
if (el.rotation) {
|
|
@@ -4262,7 +4318,7 @@ function isModelObject(obj) {
|
|
|
4262
4318
|
|
|
4263
4319
|
// src/model/block/scene/BlockObject.ts
|
|
4264
4320
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4265
|
-
import { Euler as
|
|
4321
|
+
import { Euler as Euler5, Matrix4 as Matrix46, Vector3 as Vector37 } from "three";
|
|
4266
4322
|
var p10 = prefix("BlockObject");
|
|
4267
4323
|
function matchesCondition(condition, state) {
|
|
4268
4324
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4324,7 +4380,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4324
4380
|
if (isModelObject(model)) {
|
|
4325
4381
|
model.removeFromScene();
|
|
4326
4382
|
} else if (isInstanceReference(model)) {
|
|
4327
|
-
model.setScale(new
|
|
4383
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4328
4384
|
}
|
|
4329
4385
|
}
|
|
4330
4386
|
super.removeFromScene();
|
|
@@ -4385,7 +4441,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4385
4441
|
}
|
|
4386
4442
|
for (let model of this._models) {
|
|
4387
4443
|
if (isInstanceReference(model)) {
|
|
4388
|
-
model.setScale(new
|
|
4444
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4389
4445
|
} else {
|
|
4390
4446
|
model.dispose();
|
|
4391
4447
|
}
|
|
@@ -4422,25 +4478,24 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4422
4478
|
await this.createVariant(variant);
|
|
4423
4479
|
}
|
|
4424
4480
|
async createVariant(variant) {
|
|
4425
|
-
const
|
|
4426
|
-
const obj = await this.scene.addModel(model, this.options);
|
|
4427
|
-
if (isInstanceReference(obj) || obj.isInstanced) {
|
|
4428
|
-
this._isInstanced = true;
|
|
4429
|
-
this._instanceCounter = 1;
|
|
4430
|
-
}
|
|
4431
|
-
let rotation = new Euler3(0, 0, 0);
|
|
4481
|
+
const rotation = new Euler5();
|
|
4432
4482
|
if (typeof variant.x !== "undefined") {
|
|
4433
4483
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4434
4484
|
}
|
|
4435
4485
|
if (typeof variant.y !== "undefined") {
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4486
|
+
rotation.y = toRadians(clampRotationDegrees(typeof variant.x !== "undefined" ? variant.y : 360 - variant.y));
|
|
4487
|
+
}
|
|
4488
|
+
const model = await Models.getMerged(AssetKey.parse("models", variant.model));
|
|
4489
|
+
const options = {
|
|
4490
|
+
...this.options,
|
|
4491
|
+
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
4492
|
+
};
|
|
4493
|
+
const obj = await this.scene.addModel(model, options);
|
|
4494
|
+
if (isInstanceReference(obj) || obj.isInstanced) {
|
|
4495
|
+
this._isInstanced = true;
|
|
4496
|
+
this._instanceCounter = 1;
|
|
4441
4497
|
}
|
|
4442
4498
|
obj.setRotation(rotation);
|
|
4443
|
-
console.log(obj);
|
|
4444
4499
|
return obj;
|
|
4445
4500
|
}
|
|
4446
4501
|
async resetState() {
|
|
@@ -5502,7 +5557,8 @@ var MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5502
5557
|
const obj = await objectSupplier();
|
|
5503
5558
|
if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
|
|
5504
5559
|
console.log("instanceMeshes + key");
|
|
5505
|
-
const
|
|
5560
|
+
const uvLockRotation = isModelObject(obj) ? obj.options.uvLockRotation : void 0;
|
|
5561
|
+
const key = asset.key.serialize() + (uvLockRotation ? `|uvlock:${uvLockRotation.join(",")}` : "");
|
|
5506
5562
|
return this.instanceManager.getOrCreate(key, async () => {
|
|
5507
5563
|
obj.scene = this;
|
|
5508
5564
|
await obj.init();
|
|
@@ -5545,7 +5601,7 @@ function isMineRenderScene(obj) {
|
|
|
5545
5601
|
}
|
|
5546
5602
|
|
|
5547
5603
|
// src/renderer/Renderer.ts
|
|
5548
|
-
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as
|
|
5604
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector39, WebGLRenderer } from "three";
|
|
5549
5605
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5550
5606
|
import Stats from "stats.js";
|
|
5551
5607
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5558,7 +5614,7 @@ import {
|
|
|
5558
5614
|
Spherical,
|
|
5559
5615
|
TOUCH,
|
|
5560
5616
|
Vector2 as Vector23,
|
|
5561
|
-
Vector3 as
|
|
5617
|
+
Vector3 as Vector38
|
|
5562
5618
|
} from "three";
|
|
5563
5619
|
var _changeEvent = { type: "change" };
|
|
5564
5620
|
var _startEvent = { type: "start" };
|
|
@@ -5572,7 +5628,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5572
5628
|
this.domElement = domElement;
|
|
5573
5629
|
this.domElement.style.touchAction = "none";
|
|
5574
5630
|
this.enabled = true;
|
|
5575
|
-
this.target = new
|
|
5631
|
+
this.target = new Vector38();
|
|
5576
5632
|
this.minDistance = 0;
|
|
5577
5633
|
this.maxDistance = Infinity;
|
|
5578
5634
|
this.minZoom = 0;
|
|
@@ -5624,10 +5680,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5624
5680
|
state = STATE.NONE;
|
|
5625
5681
|
};
|
|
5626
5682
|
this.update = function() {
|
|
5627
|
-
const offset = new
|
|
5628
|
-
const quat = new Quaternion3().setFromUnitVectors(object.up, new
|
|
5683
|
+
const offset = new Vector38();
|
|
5684
|
+
const quat = new Quaternion3().setFromUnitVectors(object.up, new Vector38(0, 1, 0));
|
|
5629
5685
|
const quatInverse = quat.clone().invert();
|
|
5630
|
-
const lastPosition = new
|
|
5686
|
+
const lastPosition = new Vector38();
|
|
5631
5687
|
const lastQuaternion = new Quaternion3();
|
|
5632
5688
|
const twoPI = 2 * Math.PI;
|
|
5633
5689
|
return function update() {
|
|
@@ -5717,7 +5773,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5717
5773
|
const spherical = new Spherical();
|
|
5718
5774
|
const sphericalDelta = new Spherical();
|
|
5719
5775
|
let scale = 1;
|
|
5720
|
-
const panOffset = new
|
|
5776
|
+
const panOffset = new Vector38();
|
|
5721
5777
|
let zoomChanged = false;
|
|
5722
5778
|
const rotateStart = new Vector23();
|
|
5723
5779
|
const rotateEnd = new Vector23();
|
|
@@ -5743,7 +5799,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5743
5799
|
sphericalDelta.phi -= angle;
|
|
5744
5800
|
}
|
|
5745
5801
|
const panLeft = function() {
|
|
5746
|
-
const v = new
|
|
5802
|
+
const v = new Vector38();
|
|
5747
5803
|
return function panLeft2(distance, objectMatrix) {
|
|
5748
5804
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5749
5805
|
v.multiplyScalar(-distance);
|
|
@@ -5751,7 +5807,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5751
5807
|
};
|
|
5752
5808
|
}();
|
|
5753
5809
|
const panUp = function() {
|
|
5754
|
-
const v = new
|
|
5810
|
+
const v = new Vector38();
|
|
5755
5811
|
return function panUp2(distance, objectMatrix) {
|
|
5756
5812
|
if (scope.screenSpacePanning === true) {
|
|
5757
5813
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5764,7 +5820,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5764
5820
|
};
|
|
5765
5821
|
}();
|
|
5766
5822
|
const pan = function() {
|
|
5767
|
-
const offset = new
|
|
5823
|
+
const offset = new Vector38();
|
|
5768
5824
|
return function pan2(deltaX, deltaY) {
|
|
5769
5825
|
const element = scope.domElement;
|
|
5770
5826
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6241,8 +6297,8 @@ var Renderer = class _Renderer {
|
|
|
6241
6297
|
top: void 0,
|
|
6242
6298
|
bottom: void 0
|
|
6243
6299
|
},
|
|
6244
|
-
position: new
|
|
6245
|
-
lookingAt: new
|
|
6300
|
+
position: new Vector39(50, 50, 50),
|
|
6301
|
+
lookingAt: new Vector39(0, 0, 0)
|
|
6246
6302
|
},
|
|
6247
6303
|
render: {
|
|
6248
6304
|
fpsLimit: 60,
|
|
@@ -6546,7 +6602,7 @@ var Skins = class {
|
|
|
6546
6602
|
return this.fromUsername(uuidOrUsername);
|
|
6547
6603
|
}
|
|
6548
6604
|
static async fromUuid(uuid) {
|
|
6549
|
-
return this.
|
|
6605
|
+
return this.getMcProxySkinUrl(uuid);
|
|
6550
6606
|
}
|
|
6551
6607
|
static async fromUsername(username) {
|
|
6552
6608
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6573,7 +6629,7 @@ var Skins = class {
|
|
|
6573
6629
|
return this.capeFromUsername(uuidOrUsername);
|
|
6574
6630
|
}
|
|
6575
6631
|
static async capeFromUuid(uuid) {
|
|
6576
|
-
return this.
|
|
6632
|
+
return this.getMcProxyCapeUrl(uuid);
|
|
6577
6633
|
}
|
|
6578
6634
|
static async capeFromUsername(username) {
|
|
6579
6635
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6594,8 +6650,23 @@ var Skins = class {
|
|
|
6594
6650
|
//</editor-fold>
|
|
6595
6651
|
//<editor-fold desc="Helpers">
|
|
6596
6652
|
static async usernameToUuid(username) {
|
|
6597
|
-
return this.
|
|
6653
|
+
return this.usernameToUuidMcProxy(username);
|
|
6654
|
+
}
|
|
6655
|
+
static async usernameToUuidMcProxy(username) {
|
|
6656
|
+
return Requests.genericRequest({
|
|
6657
|
+
baseURL: "https://mcproxy.dev",
|
|
6658
|
+
url: "/uuid/" + username
|
|
6659
|
+
}).then((res) => {
|
|
6660
|
+
if (res.status === 200) {
|
|
6661
|
+
return res.data["data"]["id"];
|
|
6662
|
+
}
|
|
6663
|
+
return void 0;
|
|
6664
|
+
}).catch((err) => {
|
|
6665
|
+
console.warn(err);
|
|
6666
|
+
return void 0;
|
|
6667
|
+
});
|
|
6598
6668
|
}
|
|
6669
|
+
/** @deprecated **/
|
|
6599
6670
|
static async usernameToUuidSkinProxy(username) {
|
|
6600
6671
|
return Requests.genericRequest({
|
|
6601
6672
|
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
@@ -6674,20 +6745,28 @@ var Skins = class {
|
|
|
6674
6745
|
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6675
6746
|
return "https://mineskin.org/skin/player/" + uuid;
|
|
6676
6747
|
}
|
|
6748
|
+
/** @deprecated **/
|
|
6677
6749
|
static getSkinProxySkinUrl(uuid) {
|
|
6678
6750
|
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
6679
6751
|
}
|
|
6752
|
+
/** @deprecated **/
|
|
6680
6753
|
static getSkinProxyCapeUrl(uuid) {
|
|
6681
6754
|
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
6682
6755
|
}
|
|
6756
|
+
static getMcProxySkinUrl(uuid) {
|
|
6757
|
+
return "https://mcproxy.dev/skin/" + uuid;
|
|
6758
|
+
}
|
|
6759
|
+
static getMcProxyCapeUrl(uuid) {
|
|
6760
|
+
return "https://mcproxy.dev/cape/" + uuid;
|
|
6761
|
+
}
|
|
6683
6762
|
//</editor-fold>
|
|
6684
6763
|
};
|
|
6685
6764
|
|
|
6686
6765
|
// src/world/Chunk.ts
|
|
6687
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6766
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector311 } from "three";
|
|
6688
6767
|
|
|
6689
6768
|
// src/world/MineRenderWorld.ts
|
|
6690
|
-
import { Vector3 as
|
|
6769
|
+
import { Vector3 as Vector310 } from "three";
|
|
6691
6770
|
var MineRenderWorld = class {
|
|
6692
6771
|
constructor(scene) {
|
|
6693
6772
|
this._size = 4;
|
|
@@ -6698,10 +6777,10 @@ var MineRenderWorld = class {
|
|
|
6698
6777
|
}
|
|
6699
6778
|
getBlockAt(posOrX, y, z) {
|
|
6700
6779
|
if (typeof posOrX == "number") {
|
|
6701
|
-
return this.getBlockAt(new
|
|
6780
|
+
return this.getBlockAt(new Vector310(posOrX, y, z));
|
|
6702
6781
|
}
|
|
6703
6782
|
if (isTripleArray(posOrX)) {
|
|
6704
|
-
return this.getBlockAt(new
|
|
6783
|
+
return this.getBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]));
|
|
6705
6784
|
}
|
|
6706
6785
|
const chunk = this.getChunkAt(posOrX);
|
|
6707
6786
|
if (typeof chunk === "undefined") {
|
|
@@ -6712,10 +6791,10 @@ var MineRenderWorld = class {
|
|
|
6712
6791
|
}
|
|
6713
6792
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6714
6793
|
if (typeof posOrX == "number") {
|
|
6715
|
-
return this.setBlockAt(new
|
|
6794
|
+
return this.setBlockAt(new Vector310(posOrX, yOrBlock, z), block);
|
|
6716
6795
|
}
|
|
6717
6796
|
if (isTripleArray(posOrX)) {
|
|
6718
|
-
return this.setBlockAt(new
|
|
6797
|
+
return this.setBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6719
6798
|
}
|
|
6720
6799
|
this.validatePosBounds(posOrX);
|
|
6721
6800
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6761,14 +6840,14 @@ var MineRenderWorld = class {
|
|
|
6761
6840
|
return this._chunks[index];
|
|
6762
6841
|
}
|
|
6763
6842
|
static worldToScenePosition(pos) {
|
|
6764
|
-
return new
|
|
6843
|
+
return new Vector310(
|
|
6765
6844
|
pos.x * 16,
|
|
6766
6845
|
pos.y * 16,
|
|
6767
6846
|
pos.z * 16
|
|
6768
6847
|
);
|
|
6769
6848
|
}
|
|
6770
6849
|
static sceneToWorldPosition(pos) {
|
|
6771
|
-
return new
|
|
6850
|
+
return new Vector310(
|
|
6772
6851
|
pos.x / 16,
|
|
6773
6852
|
pos.y / 16,
|
|
6774
6853
|
pos.z / 16
|
|
@@ -6810,7 +6889,7 @@ var Chunk = class _Chunk {
|
|
|
6810
6889
|
scene.add(anchor);
|
|
6811
6890
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
6812
6891
|
addBox3WireframeToObject(
|
|
6813
|
-
new Box32(new
|
|
6892
|
+
new Box32(new Vector311(0, 0, 0), new Vector311(256, 256, 256)),
|
|
6814
6893
|
anchor,
|
|
6815
6894
|
16776960,
|
|
6816
6895
|
4
|
|
@@ -6818,10 +6897,10 @@ var Chunk = class _Chunk {
|
|
|
6818
6897
|
}
|
|
6819
6898
|
getBlockAt(posOrX, y, z) {
|
|
6820
6899
|
if (typeof posOrX == "number") {
|
|
6821
|
-
return this.getBlockAt(new
|
|
6900
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6822
6901
|
}
|
|
6823
6902
|
if (isTripleArray(posOrX)) {
|
|
6824
|
-
return this.getBlockAt(new
|
|
6903
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6825
6904
|
}
|
|
6826
6905
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
6827
6906
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -6829,10 +6908,10 @@ var Chunk = class _Chunk {
|
|
|
6829
6908
|
}
|
|
6830
6909
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6831
6910
|
if (typeof posOrX == "number") {
|
|
6832
|
-
return this.setBlockAt(new
|
|
6911
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6833
6912
|
}
|
|
6834
6913
|
if (isTripleArray(posOrX)) {
|
|
6835
|
-
return this.setBlockAt(new
|
|
6914
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6836
6915
|
}
|
|
6837
6916
|
const worldPos = posOrX;
|
|
6838
6917
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -6878,7 +6957,7 @@ var Chunk = class _Chunk {
|
|
|
6878
6957
|
}
|
|
6879
6958
|
async clear() {
|
|
6880
6959
|
let promises = [];
|
|
6881
|
-
let pos = new
|
|
6960
|
+
let pos = new Vector311();
|
|
6882
6961
|
for (let x = 0; x < 16; x++) {
|
|
6883
6962
|
for (let z = 0; z < 16; z++) {
|
|
6884
6963
|
for (let y = 0; y < 16; y++) {
|
|
@@ -6897,14 +6976,14 @@ var Chunk = class _Chunk {
|
|
|
6897
6976
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
6898
6977
|
}
|
|
6899
6978
|
worldPosToChunkPos(pos) {
|
|
6900
|
-
return new
|
|
6979
|
+
return new Vector311(
|
|
6901
6980
|
pos.x - this.x * 16,
|
|
6902
6981
|
pos.y - this.y * 16,
|
|
6903
6982
|
pos.z - this.z * 16
|
|
6904
6983
|
);
|
|
6905
6984
|
}
|
|
6906
6985
|
chunkPosToWorldPos(pos) {
|
|
6907
|
-
return new
|
|
6986
|
+
return new Vector311(
|
|
6908
6987
|
this.x * 16 + pos.x,
|
|
6909
6988
|
this.y * 16 + pos.y,
|
|
6910
6989
|
this.z * 16 + pos.z
|