minerender 2.1.0-alpha.18 → 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 +9 -0
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.js +92 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +141 -66
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +92 -17
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +9 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +92 -17
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +141 -66
- 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());
|
|
@@ -2091,6 +2091,14 @@ var DEFAULT_UV = [0, 0, 16, 16];
|
|
|
2091
2091
|
var X = 0;
|
|
2092
2092
|
var Y = 1;
|
|
2093
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
|
+
};
|
|
2094
2102
|
var UVMapper = class {
|
|
2095
2103
|
static makeUv(uvCoord, originalTextureSize, actualTextureSize) {
|
|
2096
2104
|
if (uvCoord === 0) return 0;
|
|
@@ -2188,6 +2196,42 @@ var UVMapper = class {
|
|
|
2188
2196
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2189
2197
|
return new Float32BufferAttribute2(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2190
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
|
+
}
|
|
2191
2235
|
static async getAtlas(model) {
|
|
2192
2236
|
const keyStr = model.key.serialize();
|
|
2193
2237
|
return Caching.modelTextureAtlasCache.get(keyStr, (k) => {
|
|
@@ -2634,7 +2678,7 @@ var BlockEntityModels = class {
|
|
|
2634
2678
|
};
|
|
2635
2679
|
|
|
2636
2680
|
// src/renderer/SceneObject.ts
|
|
2637
|
-
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";
|
|
2638
2682
|
|
|
2639
2683
|
// src/instance/InstanceReference.ts
|
|
2640
2684
|
var InstanceReference = class {
|
|
@@ -2802,6 +2846,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2802
2846
|
}
|
|
2803
2847
|
createInstancedMesh(name, geometry, material, count) {
|
|
2804
2848
|
const mesh = new InstancedMesh(geometry, material, count);
|
|
2849
|
+
mesh.count = 0;
|
|
2805
2850
|
if (name) {
|
|
2806
2851
|
mesh.name = `mesh:${name}`;
|
|
2807
2852
|
}
|
|
@@ -2879,6 +2924,10 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2879
2924
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2880
2925
|
const i = this._instanceCounter++;
|
|
2881
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
|
+
}
|
|
2882
2931
|
console.debug(p6, "nextInstance " + i);
|
|
2883
2932
|
if (i === this.options.maxInstanceCount) {
|
|
2884
2933
|
console.warn(p6, "Max instance count reached for " + this);
|
|
@@ -2910,9 +2959,9 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2910
2959
|
}
|
|
2911
2960
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
2912
2961
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2913
|
-
const oldPosition = new
|
|
2962
|
+
const oldPosition = new Vector34();
|
|
2914
2963
|
const oldRotation = new Quaternion2();
|
|
2915
|
-
const oldScale = new
|
|
2964
|
+
const oldScale = new Vector34();
|
|
2916
2965
|
const matrix = new Matrix42();
|
|
2917
2966
|
if (!scale || !rotation || !position) {
|
|
2918
2967
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
@@ -2928,7 +2977,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2928
2977
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2929
2978
|
this.setPositionRotationScaleAt(index, position);
|
|
2930
2979
|
}
|
|
2931
|
-
getPositionAt(index, vector = new
|
|
2980
|
+
getPositionAt(index, vector = new Vector34()) {
|
|
2932
2981
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2933
2982
|
const matrix = this.getMatrixAt(index);
|
|
2934
2983
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -2938,7 +2987,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2938
2987
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2939
2988
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
2940
2989
|
}
|
|
2941
|
-
getRotationAt(index, euler = new
|
|
2990
|
+
getRotationAt(index, euler = new Euler2()) {
|
|
2942
2991
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2943
2992
|
const matrix = this.getMatrixAt(index);
|
|
2944
2993
|
euler.setFromRotationMatrix(matrix);
|
|
@@ -2948,7 +2997,7 @@ var SceneObject = class _SceneObject extends Object3D2 {
|
|
|
2948
2997
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2949
2998
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
2950
2999
|
}
|
|
2951
|
-
getScaleAt(index, vector = new
|
|
3000
|
+
getScaleAt(index, vector = new Vector34()) {
|
|
2952
3001
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2953
3002
|
const matrix = this.getMatrixAt(index);
|
|
2954
3003
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3606,7 +3655,7 @@ function isQuadArray(obj) {
|
|
|
3606
3655
|
}
|
|
3607
3656
|
|
|
3608
3657
|
// src/model/scene/ModelObject.ts
|
|
3609
|
-
import { BoxGeometry as BoxGeometry5, Matrix4 as Matrix45 } from "three";
|
|
3658
|
+
import { BoxGeometry as BoxGeometry5, Euler as Euler4, Matrix4 as Matrix45 } from "three";
|
|
3610
3659
|
|
|
3611
3660
|
// src/three/BufferGeometryUtils.js
|
|
3612
3661
|
import {
|
|
@@ -3618,7 +3667,7 @@ import {
|
|
|
3618
3667
|
TriangleFanDrawMode,
|
|
3619
3668
|
TriangleStripDrawMode,
|
|
3620
3669
|
TrianglesDrawMode,
|
|
3621
|
-
Vector3 as
|
|
3670
|
+
Vector3 as Vector36
|
|
3622
3671
|
} from "three";
|
|
3623
3672
|
function computeTangents(geometry) {
|
|
3624
3673
|
geometry.computeTangents();
|
|
@@ -3937,15 +3986,15 @@ function computeMorphedAttributes(object) {
|
|
|
3937
3986
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3938
3987
|
return null;
|
|
3939
3988
|
}
|
|
3940
|
-
const _vA = new
|
|
3941
|
-
const _vB = new
|
|
3942
|
-
const _vC = new
|
|
3943
|
-
const _tempA = new
|
|
3944
|
-
const _tempB = new
|
|
3945
|
-
const _tempC = new
|
|
3946
|
-
const _morphA = new
|
|
3947
|
-
const _morphB = new
|
|
3948
|
-
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();
|
|
3949
3998
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3950
3999
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3951
4000
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4189,6 +4238,9 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4189
4238
|
if (this.atlas.model.elements) {
|
|
4190
4239
|
this.atlas.model.elements?.forEach((el) => {
|
|
4191
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
|
+
}
|
|
4192
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));
|
|
4193
4245
|
elGeo.applyMatrix4(new Matrix45().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4194
4246
|
if (el.rotation) {
|
|
@@ -4266,7 +4318,7 @@ function isModelObject(obj) {
|
|
|
4266
4318
|
|
|
4267
4319
|
// src/model/block/scene/BlockObject.ts
|
|
4268
4320
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4269
|
-
import { Euler as
|
|
4321
|
+
import { Euler as Euler5, Matrix4 as Matrix46, Vector3 as Vector37 } from "three";
|
|
4270
4322
|
var p10 = prefix("BlockObject");
|
|
4271
4323
|
function matchesCondition(condition, state) {
|
|
4272
4324
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4328,7 +4380,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4328
4380
|
if (isModelObject(model)) {
|
|
4329
4381
|
model.removeFromScene();
|
|
4330
4382
|
} else if (isInstanceReference(model)) {
|
|
4331
|
-
model.setScale(new
|
|
4383
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4332
4384
|
}
|
|
4333
4385
|
}
|
|
4334
4386
|
super.removeFromScene();
|
|
@@ -4389,7 +4441,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4389
4441
|
}
|
|
4390
4442
|
for (let model of this._models) {
|
|
4391
4443
|
if (isInstanceReference(model)) {
|
|
4392
|
-
model.setScale(new
|
|
4444
|
+
model.setScale(new Vector37(0, 0, 0));
|
|
4393
4445
|
} else {
|
|
4394
4446
|
model.dispose();
|
|
4395
4447
|
}
|
|
@@ -4426,25 +4478,24 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4426
4478
|
await this.createVariant(variant);
|
|
4427
4479
|
}
|
|
4428
4480
|
async createVariant(variant) {
|
|
4429
|
-
const
|
|
4430
|
-
const obj = await this.scene.addModel(model, this.options);
|
|
4431
|
-
if (isInstanceReference(obj) || obj.isInstanced) {
|
|
4432
|
-
this._isInstanced = true;
|
|
4433
|
-
this._instanceCounter = 1;
|
|
4434
|
-
}
|
|
4435
|
-
let rotation = new Euler3(0, 0, 0);
|
|
4481
|
+
const rotation = new Euler5();
|
|
4436
4482
|
if (typeof variant.x !== "undefined") {
|
|
4437
4483
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4438
4484
|
}
|
|
4439
4485
|
if (typeof variant.y !== "undefined") {
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
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;
|
|
4445
4497
|
}
|
|
4446
4498
|
obj.setRotation(rotation);
|
|
4447
|
-
console.log(obj);
|
|
4448
4499
|
return obj;
|
|
4449
4500
|
}
|
|
4450
4501
|
async resetState() {
|
|
@@ -5506,7 +5557,8 @@ var MineRenderScene = class _MineRenderScene extends Scene2 {
|
|
|
5506
5557
|
const obj = await objectSupplier();
|
|
5507
5558
|
if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
|
|
5508
5559
|
console.log("instanceMeshes + key");
|
|
5509
|
-
const
|
|
5560
|
+
const uvLockRotation = isModelObject(obj) ? obj.options.uvLockRotation : void 0;
|
|
5561
|
+
const key = asset.key.serialize() + (uvLockRotation ? `|uvlock:${uvLockRotation.join(",")}` : "");
|
|
5510
5562
|
return this.instanceManager.getOrCreate(key, async () => {
|
|
5511
5563
|
obj.scene = this;
|
|
5512
5564
|
await obj.init();
|
|
@@ -5549,7 +5601,7 @@ function isMineRenderScene(obj) {
|
|
|
5549
5601
|
}
|
|
5550
5602
|
|
|
5551
5603
|
// src/renderer/Renderer.ts
|
|
5552
|
-
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";
|
|
5553
5605
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5554
5606
|
import Stats from "stats.js";
|
|
5555
5607
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -5562,7 +5614,7 @@ import {
|
|
|
5562
5614
|
Spherical,
|
|
5563
5615
|
TOUCH,
|
|
5564
5616
|
Vector2 as Vector23,
|
|
5565
|
-
Vector3 as
|
|
5617
|
+
Vector3 as Vector38
|
|
5566
5618
|
} from "three";
|
|
5567
5619
|
var _changeEvent = { type: "change" };
|
|
5568
5620
|
var _startEvent = { type: "start" };
|
|
@@ -5576,7 +5628,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5576
5628
|
this.domElement = domElement;
|
|
5577
5629
|
this.domElement.style.touchAction = "none";
|
|
5578
5630
|
this.enabled = true;
|
|
5579
|
-
this.target = new
|
|
5631
|
+
this.target = new Vector38();
|
|
5580
5632
|
this.minDistance = 0;
|
|
5581
5633
|
this.maxDistance = Infinity;
|
|
5582
5634
|
this.minZoom = 0;
|
|
@@ -5628,10 +5680,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5628
5680
|
state = STATE.NONE;
|
|
5629
5681
|
};
|
|
5630
5682
|
this.update = function() {
|
|
5631
|
-
const offset = new
|
|
5632
|
-
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));
|
|
5633
5685
|
const quatInverse = quat.clone().invert();
|
|
5634
|
-
const lastPosition = new
|
|
5686
|
+
const lastPosition = new Vector38();
|
|
5635
5687
|
const lastQuaternion = new Quaternion3();
|
|
5636
5688
|
const twoPI = 2 * Math.PI;
|
|
5637
5689
|
return function update() {
|
|
@@ -5721,7 +5773,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5721
5773
|
const spherical = new Spherical();
|
|
5722
5774
|
const sphericalDelta = new Spherical();
|
|
5723
5775
|
let scale = 1;
|
|
5724
|
-
const panOffset = new
|
|
5776
|
+
const panOffset = new Vector38();
|
|
5725
5777
|
let zoomChanged = false;
|
|
5726
5778
|
const rotateStart = new Vector23();
|
|
5727
5779
|
const rotateEnd = new Vector23();
|
|
@@ -5747,7 +5799,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5747
5799
|
sphericalDelta.phi -= angle;
|
|
5748
5800
|
}
|
|
5749
5801
|
const panLeft = function() {
|
|
5750
|
-
const v = new
|
|
5802
|
+
const v = new Vector38();
|
|
5751
5803
|
return function panLeft2(distance, objectMatrix) {
|
|
5752
5804
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5753
5805
|
v.multiplyScalar(-distance);
|
|
@@ -5755,7 +5807,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5755
5807
|
};
|
|
5756
5808
|
}();
|
|
5757
5809
|
const panUp = function() {
|
|
5758
|
-
const v = new
|
|
5810
|
+
const v = new Vector38();
|
|
5759
5811
|
return function panUp2(distance, objectMatrix) {
|
|
5760
5812
|
if (scope.screenSpacePanning === true) {
|
|
5761
5813
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -5768,7 +5820,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
5768
5820
|
};
|
|
5769
5821
|
}();
|
|
5770
5822
|
const pan = function() {
|
|
5771
|
-
const offset = new
|
|
5823
|
+
const offset = new Vector38();
|
|
5772
5824
|
return function pan2(deltaX, deltaY) {
|
|
5773
5825
|
const element = scope.domElement;
|
|
5774
5826
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6245,8 +6297,8 @@ var Renderer = class _Renderer {
|
|
|
6245
6297
|
top: void 0,
|
|
6246
6298
|
bottom: void 0
|
|
6247
6299
|
},
|
|
6248
|
-
position: new
|
|
6249
|
-
lookingAt: new
|
|
6300
|
+
position: new Vector39(50, 50, 50),
|
|
6301
|
+
lookingAt: new Vector39(0, 0, 0)
|
|
6250
6302
|
},
|
|
6251
6303
|
render: {
|
|
6252
6304
|
fpsLimit: 60,
|
|
@@ -6550,7 +6602,7 @@ var Skins = class {
|
|
|
6550
6602
|
return this.fromUsername(uuidOrUsername);
|
|
6551
6603
|
}
|
|
6552
6604
|
static async fromUuid(uuid) {
|
|
6553
|
-
return this.
|
|
6605
|
+
return this.getMcProxySkinUrl(uuid);
|
|
6554
6606
|
}
|
|
6555
6607
|
static async fromUsername(username) {
|
|
6556
6608
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6577,7 +6629,7 @@ var Skins = class {
|
|
|
6577
6629
|
return this.capeFromUsername(uuidOrUsername);
|
|
6578
6630
|
}
|
|
6579
6631
|
static async capeFromUuid(uuid) {
|
|
6580
|
-
return this.
|
|
6632
|
+
return this.getMcProxyCapeUrl(uuid);
|
|
6581
6633
|
}
|
|
6582
6634
|
static async capeFromUsername(username) {
|
|
6583
6635
|
return this.usernameToUuid(username).then((uuid) => {
|
|
@@ -6598,8 +6650,23 @@ var Skins = class {
|
|
|
6598
6650
|
//</editor-fold>
|
|
6599
6651
|
//<editor-fold desc="Helpers">
|
|
6600
6652
|
static async usernameToUuid(username) {
|
|
6601
|
-
return this.
|
|
6653
|
+
return this.usernameToUuidMcProxy(username);
|
|
6602
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
|
+
});
|
|
6668
|
+
}
|
|
6669
|
+
/** @deprecated **/
|
|
6603
6670
|
static async usernameToUuidSkinProxy(username) {
|
|
6604
6671
|
return Requests.genericRequest({
|
|
6605
6672
|
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
@@ -6678,20 +6745,28 @@ var Skins = class {
|
|
|
6678
6745
|
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6679
6746
|
return "https://mineskin.org/skin/player/" + uuid;
|
|
6680
6747
|
}
|
|
6748
|
+
/** @deprecated **/
|
|
6681
6749
|
static getSkinProxySkinUrl(uuid) {
|
|
6682
6750
|
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
6683
6751
|
}
|
|
6752
|
+
/** @deprecated **/
|
|
6684
6753
|
static getSkinProxyCapeUrl(uuid) {
|
|
6685
6754
|
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
6686
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
|
+
}
|
|
6687
6762
|
//</editor-fold>
|
|
6688
6763
|
};
|
|
6689
6764
|
|
|
6690
6765
|
// src/world/Chunk.ts
|
|
6691
|
-
import { Box3 as Box32, Object3D as Object3D6, Vector3 as
|
|
6766
|
+
import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector311 } from "three";
|
|
6692
6767
|
|
|
6693
6768
|
// src/world/MineRenderWorld.ts
|
|
6694
|
-
import { Vector3 as
|
|
6769
|
+
import { Vector3 as Vector310 } from "three";
|
|
6695
6770
|
var MineRenderWorld = class {
|
|
6696
6771
|
constructor(scene) {
|
|
6697
6772
|
this._size = 4;
|
|
@@ -6702,10 +6777,10 @@ var MineRenderWorld = class {
|
|
|
6702
6777
|
}
|
|
6703
6778
|
getBlockAt(posOrX, y, z) {
|
|
6704
6779
|
if (typeof posOrX == "number") {
|
|
6705
|
-
return this.getBlockAt(new
|
|
6780
|
+
return this.getBlockAt(new Vector310(posOrX, y, z));
|
|
6706
6781
|
}
|
|
6707
6782
|
if (isTripleArray(posOrX)) {
|
|
6708
|
-
return this.getBlockAt(new
|
|
6783
|
+
return this.getBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]));
|
|
6709
6784
|
}
|
|
6710
6785
|
const chunk = this.getChunkAt(posOrX);
|
|
6711
6786
|
if (typeof chunk === "undefined") {
|
|
@@ -6716,10 +6791,10 @@ var MineRenderWorld = class {
|
|
|
6716
6791
|
}
|
|
6717
6792
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6718
6793
|
if (typeof posOrX == "number") {
|
|
6719
|
-
return this.setBlockAt(new
|
|
6794
|
+
return this.setBlockAt(new Vector310(posOrX, yOrBlock, z), block);
|
|
6720
6795
|
}
|
|
6721
6796
|
if (isTripleArray(posOrX)) {
|
|
6722
|
-
return this.setBlockAt(new
|
|
6797
|
+
return this.setBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6723
6798
|
}
|
|
6724
6799
|
this.validatePosBounds(posOrX);
|
|
6725
6800
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -6765,14 +6840,14 @@ var MineRenderWorld = class {
|
|
|
6765
6840
|
return this._chunks[index];
|
|
6766
6841
|
}
|
|
6767
6842
|
static worldToScenePosition(pos) {
|
|
6768
|
-
return new
|
|
6843
|
+
return new Vector310(
|
|
6769
6844
|
pos.x * 16,
|
|
6770
6845
|
pos.y * 16,
|
|
6771
6846
|
pos.z * 16
|
|
6772
6847
|
);
|
|
6773
6848
|
}
|
|
6774
6849
|
static sceneToWorldPosition(pos) {
|
|
6775
|
-
return new
|
|
6850
|
+
return new Vector310(
|
|
6776
6851
|
pos.x / 16,
|
|
6777
6852
|
pos.y / 16,
|
|
6778
6853
|
pos.z / 16
|
|
@@ -6814,7 +6889,7 @@ var Chunk = class _Chunk {
|
|
|
6814
6889
|
scene.add(anchor);
|
|
6815
6890
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
6816
6891
|
addBox3WireframeToObject(
|
|
6817
|
-
new Box32(new
|
|
6892
|
+
new Box32(new Vector311(0, 0, 0), new Vector311(256, 256, 256)),
|
|
6818
6893
|
anchor,
|
|
6819
6894
|
16776960,
|
|
6820
6895
|
4
|
|
@@ -6822,10 +6897,10 @@ var Chunk = class _Chunk {
|
|
|
6822
6897
|
}
|
|
6823
6898
|
getBlockAt(posOrX, y, z) {
|
|
6824
6899
|
if (typeof posOrX == "number") {
|
|
6825
|
-
return this.getBlockAt(new
|
|
6900
|
+
return this.getBlockAt(new Vector311(posOrX, y, z));
|
|
6826
6901
|
}
|
|
6827
6902
|
if (isTripleArray(posOrX)) {
|
|
6828
|
-
return this.getBlockAt(new
|
|
6903
|
+
return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
|
|
6829
6904
|
}
|
|
6830
6905
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
6831
6906
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -6833,10 +6908,10 @@ var Chunk = class _Chunk {
|
|
|
6833
6908
|
}
|
|
6834
6909
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
6835
6910
|
if (typeof posOrX == "number") {
|
|
6836
|
-
return this.setBlockAt(new
|
|
6911
|
+
return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
|
|
6837
6912
|
}
|
|
6838
6913
|
if (isTripleArray(posOrX)) {
|
|
6839
|
-
return this.setBlockAt(new
|
|
6914
|
+
return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
6840
6915
|
}
|
|
6841
6916
|
const worldPos = posOrX;
|
|
6842
6917
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -6882,7 +6957,7 @@ var Chunk = class _Chunk {
|
|
|
6882
6957
|
}
|
|
6883
6958
|
async clear() {
|
|
6884
6959
|
let promises = [];
|
|
6885
|
-
let pos = new
|
|
6960
|
+
let pos = new Vector311();
|
|
6886
6961
|
for (let x = 0; x < 16; x++) {
|
|
6887
6962
|
for (let z = 0; z < 16; z++) {
|
|
6888
6963
|
for (let y = 0; y < 16; y++) {
|
|
@@ -6901,14 +6976,14 @@ var Chunk = class _Chunk {
|
|
|
6901
6976
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
6902
6977
|
}
|
|
6903
6978
|
worldPosToChunkPos(pos) {
|
|
6904
|
-
return new
|
|
6979
|
+
return new Vector311(
|
|
6905
6980
|
pos.x - this.x * 16,
|
|
6906
6981
|
pos.y - this.y * 16,
|
|
6907
6982
|
pos.z - this.z * 16
|
|
6908
6983
|
);
|
|
6909
6984
|
}
|
|
6910
6985
|
chunkPosToWorldPos(pos) {
|
|
6911
|
-
return new
|
|
6986
|
+
return new Vector311(
|
|
6912
6987
|
this.x * 16 + pos.x,
|
|
6913
6988
|
this.y * 16 + pos.y,
|
|
6914
6989
|
this.z * 16 + pos.z
|