minerender 2.1.0-alpha.47 → 2.1.0-alpha.49
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 +37 -5
- package/dist/browser/index.d.ts +37 -5
- package/dist/browser/index.js +280 -145
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +155 -20
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +249 -3
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +37 -5
- package/dist/node/index.d.ts +37 -5
- package/dist/node/index.js +282 -145
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +155 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -886,6 +886,31 @@ var init_Materials = __esm({
|
|
|
886
886
|
alphaTest: 0.5
|
|
887
887
|
});
|
|
888
888
|
}
|
|
889
|
+
static createGuiCanvasMaterial(canvas) {
|
|
890
|
+
const material = new import_three5.MeshBasicMaterial({
|
|
891
|
+
map: Textures.createCanvasTexture(canvas),
|
|
892
|
+
transparent: true,
|
|
893
|
+
depthWrite: false,
|
|
894
|
+
side: import_three5.DoubleSide,
|
|
895
|
+
toneMapped: false
|
|
896
|
+
});
|
|
897
|
+
material.onBeforeCompile = (shader) => {
|
|
898
|
+
for (const [stage, direction] of [["vertex", "out"], ["fragment", "in"]]) {
|
|
899
|
+
const chunk = `uv_pars_${stage}`;
|
|
900
|
+
shader[`${stage}Shader`] = shader[`${stage}Shader`].replace(
|
|
901
|
+
`#include <${chunk}>`,
|
|
902
|
+
import_three5.ShaderChunk[chunk].replace("varying vec2 vMapUv;", `
|
|
903
|
+
#if __VERSION__ >= 300
|
|
904
|
+
centroid ${direction} vec2 vMapUv;
|
|
905
|
+
#else
|
|
906
|
+
varying vec2 vMapUv;
|
|
907
|
+
#endif
|
|
908
|
+
`)
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
return material;
|
|
913
|
+
}
|
|
889
914
|
static createShadedCanvasMaterial(canvas, transparent = false, shade = false) {
|
|
890
915
|
const vertShader = `
|
|
891
916
|
uniform bool SHADE;
|
|
@@ -3075,6 +3100,10 @@ var init_SceneObject = __esm({
|
|
|
3075
3100
|
async init() {
|
|
3076
3101
|
}
|
|
3077
3102
|
notifyDirty() {
|
|
3103
|
+
this.traverseAncestors((parent) => {
|
|
3104
|
+
const scene = parent;
|
|
3105
|
+
if (scene.isMineRenderScene) scene.dirty = true;
|
|
3106
|
+
});
|
|
3078
3107
|
this.dispatchEvent(changeEvent);
|
|
3079
3108
|
}
|
|
3080
3109
|
//<editor-fold desc="GROUPS">
|
|
@@ -3418,6 +3447,7 @@ var init_SceneObject = __esm({
|
|
|
3418
3447
|
} else {
|
|
3419
3448
|
object.visible = !object.visible;
|
|
3420
3449
|
}
|
|
3450
|
+
this.notifyDirty();
|
|
3421
3451
|
return object.visible;
|
|
3422
3452
|
}
|
|
3423
3453
|
this.notifyDirty();
|
|
@@ -3450,8 +3480,8 @@ var init_SceneObject = __esm({
|
|
|
3450
3480
|
this.notifyDirty();
|
|
3451
3481
|
}
|
|
3452
3482
|
removeFromScene() {
|
|
3453
|
-
this._scene?.remove(this);
|
|
3454
3483
|
this.notifyDirty();
|
|
3484
|
+
this.removeFromParent();
|
|
3455
3485
|
}
|
|
3456
3486
|
//</editor-fold>
|
|
3457
3487
|
};
|
|
@@ -3459,16 +3489,16 @@ var init_SceneObject = __esm({
|
|
|
3459
3489
|
});
|
|
3460
3490
|
|
|
3461
3491
|
// src/model/ModelCulling.ts
|
|
3462
|
-
var
|
|
3492
|
+
var import_three17, ModelCulling;
|
|
3463
3493
|
var init_ModelCulling = __esm({
|
|
3464
3494
|
"src/model/ModelCulling.ts"() {
|
|
3465
|
-
|
|
3495
|
+
import_three17 = require("three");
|
|
3466
3496
|
init_CubeFace();
|
|
3467
3497
|
ModelCulling = class {
|
|
3468
3498
|
static toLocalMask(worldMask, rotation) {
|
|
3469
3499
|
let localMask = 0;
|
|
3470
3500
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
3471
|
-
const normal = new
|
|
3501
|
+
const normal = new import_three17.Vector3(...offset).applyEuler(rotation);
|
|
3472
3502
|
const worldFace = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
3473
3503
|
if (worldFace < 0) return 0;
|
|
3474
3504
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -3512,7 +3542,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3512
3542
|
const attributes = {};
|
|
3513
3543
|
const morphAttributes = {};
|
|
3514
3544
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3515
|
-
const mergedGeometry = new
|
|
3545
|
+
const mergedGeometry = new import_three19.BufferGeometry();
|
|
3516
3546
|
let offset = 0;
|
|
3517
3547
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3518
3548
|
const geometry = geometries[i];
|
|
@@ -3636,7 +3666,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
3636
3666
|
array.set(attributes[i].array, offset);
|
|
3637
3667
|
offset += attributes[i].array.length;
|
|
3638
3668
|
}
|
|
3639
|
-
return new
|
|
3669
|
+
return new import_three19.BufferAttribute(array, itemSize, normalized);
|
|
3640
3670
|
}
|
|
3641
3671
|
function interleaveAttributes(attributes) {
|
|
3642
3672
|
let TypedArray;
|
|
@@ -3652,7 +3682,7 @@ function interleaveAttributes(attributes) {
|
|
|
3652
3682
|
arrayLength += attribute.array.length;
|
|
3653
3683
|
stride += attribute.itemSize;
|
|
3654
3684
|
}
|
|
3655
|
-
const interleavedBuffer = new
|
|
3685
|
+
const interleavedBuffer = new import_three19.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
3656
3686
|
let offset = 0;
|
|
3657
3687
|
const res = [];
|
|
3658
3688
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -3661,7 +3691,7 @@ function interleaveAttributes(attributes) {
|
|
|
3661
3691
|
const attribute = attributes[j];
|
|
3662
3692
|
const itemSize = attribute.itemSize;
|
|
3663
3693
|
const count = attribute.count;
|
|
3664
|
-
const iba = new
|
|
3694
|
+
const iba = new import_three19.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
3665
3695
|
res.push(iba);
|
|
3666
3696
|
offset += itemSize;
|
|
3667
3697
|
for (let c = 0; c < count; c++) {
|
|
@@ -3745,13 +3775,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3745
3775
|
const name = attributeNames[i];
|
|
3746
3776
|
const oldAttribute = geometry.getAttribute(name);
|
|
3747
3777
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
3748
|
-
const attribute = new
|
|
3778
|
+
const attribute = new import_three19.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
3749
3779
|
result.setAttribute(name, attribute);
|
|
3750
3780
|
if (name in morphAttrsArrays) {
|
|
3751
3781
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
3752
3782
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
3753
3783
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
3754
|
-
const morphAttribute = new
|
|
3784
|
+
const morphAttribute = new import_three19.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
3755
3785
|
result.morphAttributes[name][j] = morphAttribute;
|
|
3756
3786
|
}
|
|
3757
3787
|
}
|
|
@@ -3760,11 +3790,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3760
3790
|
return result;
|
|
3761
3791
|
}
|
|
3762
3792
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
3763
|
-
if (drawMode ===
|
|
3793
|
+
if (drawMode === import_three19.TrianglesDrawMode) {
|
|
3764
3794
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
3765
3795
|
return geometry;
|
|
3766
3796
|
}
|
|
3767
|
-
if (drawMode ===
|
|
3797
|
+
if (drawMode === import_three19.TriangleFanDrawMode || drawMode === import_three19.TriangleStripDrawMode) {
|
|
3768
3798
|
let index = geometry.getIndex();
|
|
3769
3799
|
if (index === null) {
|
|
3770
3800
|
const indices = [];
|
|
@@ -3782,7 +3812,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
3782
3812
|
}
|
|
3783
3813
|
const numberOfTriangles = index.count - 2;
|
|
3784
3814
|
const newIndices = [];
|
|
3785
|
-
if (drawMode ===
|
|
3815
|
+
if (drawMode === import_three19.TriangleFanDrawMode) {
|
|
3786
3816
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
3787
3817
|
newIndices.push(index.getX(0));
|
|
3788
3818
|
newIndices.push(index.getX(i));
|
|
@@ -3818,15 +3848,15 @@ function computeMorphedAttributes(object) {
|
|
|
3818
3848
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3819
3849
|
return null;
|
|
3820
3850
|
}
|
|
3821
|
-
const _vA = new
|
|
3822
|
-
const _vB = new
|
|
3823
|
-
const _vC = new
|
|
3824
|
-
const _tempA = new
|
|
3825
|
-
const _tempB = new
|
|
3826
|
-
const _tempC = new
|
|
3827
|
-
const _morphA = new
|
|
3828
|
-
const _morphB = new
|
|
3829
|
-
const _morphC = new
|
|
3851
|
+
const _vA = new import_three19.Vector3();
|
|
3852
|
+
const _vB = new import_three19.Vector3();
|
|
3853
|
+
const _vC = new import_three19.Vector3();
|
|
3854
|
+
const _tempA = new import_three19.Vector3();
|
|
3855
|
+
const _tempB = new import_three19.Vector3();
|
|
3856
|
+
const _tempC = new import_three19.Vector3();
|
|
3857
|
+
const _morphA = new import_three19.Vector3();
|
|
3858
|
+
const _morphB = new import_three19.Vector3();
|
|
3859
|
+
const _morphC = new import_three19.Vector3();
|
|
3830
3860
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3831
3861
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3832
3862
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4021,8 +4051,8 @@ function computeMorphedAttributes(object) {
|
|
|
4021
4051
|
}
|
|
4022
4052
|
}
|
|
4023
4053
|
}
|
|
4024
|
-
const morphedPositionAttribute = new
|
|
4025
|
-
const morphedNormalAttribute = new
|
|
4054
|
+
const morphedPositionAttribute = new import_three19.Float32BufferAttribute(modifiedPosition, 3);
|
|
4055
|
+
const morphedNormalAttribute = new import_three19.Float32BufferAttribute(modifiedNormal, 3);
|
|
4026
4056
|
return {
|
|
4027
4057
|
positionAttribute,
|
|
4028
4058
|
normalAttribute,
|
|
@@ -4030,10 +4060,10 @@ function computeMorphedAttributes(object) {
|
|
|
4030
4060
|
morphedNormalAttribute
|
|
4031
4061
|
};
|
|
4032
4062
|
}
|
|
4033
|
-
var
|
|
4063
|
+
var import_three19;
|
|
4034
4064
|
var init_BufferGeometryUtils = __esm({
|
|
4035
4065
|
"src/three/BufferGeometryUtils.js"() {
|
|
4036
|
-
|
|
4066
|
+
import_three19 = require("three");
|
|
4037
4067
|
}
|
|
4038
4068
|
});
|
|
4039
4069
|
|
|
@@ -4041,13 +4071,13 @@ var init_BufferGeometryUtils = __esm({
|
|
|
4041
4071
|
function isModelObject(obj) {
|
|
4042
4072
|
return obj.isModelObject;
|
|
4043
4073
|
}
|
|
4044
|
-
var
|
|
4074
|
+
var import_three20, import_ts_deepmerge5, p9, ModelObject;
|
|
4045
4075
|
var init_ModelObject = __esm({
|
|
4046
4076
|
"src/model/scene/ModelObject.ts"() {
|
|
4047
4077
|
init_SceneObject();
|
|
4048
4078
|
init_Materials();
|
|
4049
4079
|
init_UVMapper();
|
|
4050
|
-
|
|
4080
|
+
import_three20 = require("three");
|
|
4051
4081
|
init_BufferGeometryUtils();
|
|
4052
4082
|
init_model();
|
|
4053
4083
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4105,7 +4135,7 @@ var init_ModelObject = __esm({
|
|
|
4105
4135
|
elGeo.clearGroups();
|
|
4106
4136
|
}
|
|
4107
4137
|
if (this.options.uvLockRotation) {
|
|
4108
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4138
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three20.Euler(...this.options.uvLockRotation));
|
|
4109
4139
|
}
|
|
4110
4140
|
if (this.options.tints) {
|
|
4111
4141
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4114,19 +4144,19 @@ var init_ModelObject = __esm({
|
|
|
4114
4144
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4115
4145
|
const tint = this.options.tints[tintIndex];
|
|
4116
4146
|
if (tint === void 0) continue;
|
|
4117
|
-
const color = new
|
|
4147
|
+
const color = new import_three20.Color(tint);
|
|
4118
4148
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4119
4149
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4120
4150
|
}
|
|
4121
4151
|
}
|
|
4122
|
-
elGeo.setAttribute("color", new
|
|
4152
|
+
elGeo.setAttribute("color", new import_three20.BufferAttribute(colors, 3));
|
|
4123
4153
|
}
|
|
4124
|
-
elGeo.applyMatrix4(new
|
|
4125
|
-
elGeo.applyMatrix4(new
|
|
4154
|
+
elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4155
|
+
elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4126
4156
|
if (el.rotation) {
|
|
4127
4157
|
applyElementRotation(el.rotation, elGeo);
|
|
4128
4158
|
}
|
|
4129
|
-
elGeo.applyMatrix4(new
|
|
4159
|
+
elGeo.applyMatrix4(new import_three20.Matrix4().makeTranslation(-8, -8, -8));
|
|
4130
4160
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4131
4161
|
if (this.options.mergeMeshes) {
|
|
4132
4162
|
allGeos.push(elGeo);
|
|
@@ -4148,7 +4178,7 @@ var init_ModelObject = __esm({
|
|
|
4148
4178
|
if (allGeos.length > 0) {
|
|
4149
4179
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4150
4180
|
} else {
|
|
4151
|
-
combinedGeo = new
|
|
4181
|
+
combinedGeo = new import_three20.BoxGeometry(16, 16, 16);
|
|
4152
4182
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4153
4183
|
}
|
|
4154
4184
|
combinedGeo.computeBoundingBox();
|
|
@@ -4256,7 +4286,7 @@ function ownHeight(sample) {
|
|
|
4256
4286
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
4257
4287
|
}
|
|
4258
4288
|
function createFluidGeometry(kind, sample) {
|
|
4259
|
-
const geometry = new
|
|
4289
|
+
const geometry = new import_three21.BufferGeometry();
|
|
4260
4290
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
4261
4291
|
const self = sample(0, 0, 0);
|
|
4262
4292
|
const height = (x, z) => {
|
|
@@ -4355,16 +4385,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
4355
4385
|
1
|
|
4356
4386
|
);
|
|
4357
4387
|
}
|
|
4358
|
-
geometry.setAttribute("position", new
|
|
4359
|
-
geometry.setAttribute("normal", new
|
|
4360
|
-
geometry.setAttribute("uv", new
|
|
4388
|
+
geometry.setAttribute("position", new import_three21.Float32BufferAttribute(positions, 3));
|
|
4389
|
+
geometry.setAttribute("normal", new import_three21.Float32BufferAttribute(normals, 3));
|
|
4390
|
+
geometry.setAttribute("uv", new import_three21.Float32BufferAttribute(uvs, 2));
|
|
4361
4391
|
geometry.setIndex(indices);
|
|
4362
4392
|
return geometry;
|
|
4363
4393
|
}
|
|
4364
|
-
var
|
|
4394
|
+
var import_three21, fluidRules, HORIZONTAL, EPSILON;
|
|
4365
4395
|
var init_FluidGeometry = __esm({
|
|
4366
4396
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
4367
|
-
|
|
4397
|
+
import_three21 = require("three");
|
|
4368
4398
|
init_fluidBlocks();
|
|
4369
4399
|
fluidRules = fluidBlocks_default;
|
|
4370
4400
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -4393,10 +4423,10 @@ function sampleFluid(kind, sample) {
|
|
|
4393
4423
|
}
|
|
4394
4424
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
4395
4425
|
}
|
|
4396
|
-
var
|
|
4426
|
+
var import_three22, FluidModelObject;
|
|
4397
4427
|
var init_FluidModelObject = __esm({
|
|
4398
4428
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
4399
|
-
|
|
4429
|
+
import_three22 = require("three");
|
|
4400
4430
|
init_AssetKey();
|
|
4401
4431
|
init_Materials();
|
|
4402
4432
|
init_ModelObject();
|
|
@@ -4429,10 +4459,10 @@ var init_FluidModelObject = __esm({
|
|
|
4429
4459
|
}
|
|
4430
4460
|
}
|
|
4431
4461
|
geometry.clearGroups();
|
|
4432
|
-
const color = new
|
|
4462
|
+
const color = new import_three22.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
4433
4463
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
4434
4464
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
4435
|
-
geometry.setAttribute("color", new
|
|
4465
|
+
geometry.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
|
|
4436
4466
|
geometry.computeBoundingBox();
|
|
4437
4467
|
geometry.computeBoundingSphere();
|
|
4438
4468
|
if (this.options.instanceMeshes) {
|
|
@@ -4446,7 +4476,7 @@ var init_FluidModelObject = __esm({
|
|
|
4446
4476
|
super.applyTextures();
|
|
4447
4477
|
this.iterateAllMeshes((mesh) => {
|
|
4448
4478
|
const material = mesh.material;
|
|
4449
|
-
material.side =
|
|
4479
|
+
material.side = import_three22.DoubleSide;
|
|
4450
4480
|
material.forceSinglePass = true;
|
|
4451
4481
|
material.depthWrite = !material.transparent;
|
|
4452
4482
|
});
|
|
@@ -4503,6 +4533,7 @@ __export(index_node_exports, {
|
|
|
4503
4533
|
Env: () => Env,
|
|
4504
4534
|
FluidModelObject: () => FluidModelObject,
|
|
4505
4535
|
Geometries: () => Geometries,
|
|
4536
|
+
GuiHelper: () => GuiHelper,
|
|
4506
4537
|
GuiLight: () => GuiLight,
|
|
4507
4538
|
GuiObject: () => GuiObject,
|
|
4508
4539
|
HostedAssetSource: () => HostedAssetSource,
|
|
@@ -4582,6 +4613,7 @@ __export(index_node_exports, {
|
|
|
4582
4613
|
isDisposable: () => isDisposable,
|
|
4583
4614
|
isDoubleArray: () => isDoubleArray,
|
|
4584
4615
|
isEntityObject: () => isEntityObject,
|
|
4616
|
+
isGuiObject: () => isGuiObject,
|
|
4585
4617
|
isInstanceManager: () => isInstanceManager,
|
|
4586
4618
|
isInstanceReference: () => isInstanceReference,
|
|
4587
4619
|
isInstanceable: () => isInstanceable,
|
|
@@ -5084,17 +5116,106 @@ function isEntityObject(obj) {
|
|
|
5084
5116
|
// src/error/index.ts
|
|
5085
5117
|
init_MineRenderError();
|
|
5086
5118
|
|
|
5119
|
+
// src/gui/GuiHelper.ts
|
|
5120
|
+
var GuiHelper = class {
|
|
5121
|
+
static inventorySlot(slot, origin = [0, 0], offset = [18, 18], rowSize = 9) {
|
|
5122
|
+
const [column, row] = typeof slot === "number" ? [slot % rowSize, Math.floor(slot / rowSize)] : slot;
|
|
5123
|
+
return [origin[0] + column * offset[0], origin[1] + row * offset[1]];
|
|
5124
|
+
}
|
|
5125
|
+
};
|
|
5126
|
+
|
|
5087
5127
|
// src/gui/scene/GuiObject.ts
|
|
5128
|
+
var import_three14 = require("three");
|
|
5129
|
+
init_AssetKey();
|
|
5130
|
+
init_ModelTextures();
|
|
5131
|
+
init_Caching();
|
|
5088
5132
|
init_SceneObject();
|
|
5133
|
+
init_Materials();
|
|
5089
5134
|
var GuiObject = class extends SceneObject {
|
|
5090
|
-
|
|
5135
|
+
constructor(textureLayers, options) {
|
|
5136
|
+
super({ ...options, instanceMeshes: false, mergeMeshes: false });
|
|
5137
|
+
this.textureLayers = textureLayers;
|
|
5138
|
+
this.isGuiObject = true;
|
|
5139
|
+
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
5140
|
+
this.bounds = new import_three14.Box2();
|
|
5141
|
+
this.geometries = /* @__PURE__ */ new Set();
|
|
5142
|
+
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
5143
|
+
this.initialized = false;
|
|
5144
|
+
}
|
|
5145
|
+
async init() {
|
|
5146
|
+
if (this.initialized) return;
|
|
5147
|
+
try {
|
|
5148
|
+
for (const [index, layer] of this.textureLayers.entries()) {
|
|
5149
|
+
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
5150
|
+
const material = await this.loadMaterial(key);
|
|
5151
|
+
const image = material.map.image;
|
|
5152
|
+
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
5153
|
+
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
5154
|
+
const [x, y] = layer.position ?? [0, 0];
|
|
5155
|
+
const geometry = new import_three14.PlaneGeometry(width, height);
|
|
5156
|
+
this.geometries.add(geometry);
|
|
5157
|
+
const uv = geometry.getAttribute("uv");
|
|
5158
|
+
for (let i = 0; i < uv.count; i++) {
|
|
5159
|
+
uv.setXY(
|
|
5160
|
+
i,
|
|
5161
|
+
(cropX + uv.getX(i) * cropWidth) / image.width,
|
|
5162
|
+
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
5163
|
+
);
|
|
5164
|
+
}
|
|
5165
|
+
const mesh = new import_three14.Mesh(geometry, material);
|
|
5166
|
+
mesh.name = `mesh:${layer.name ?? index}`;
|
|
5167
|
+
mesh.position.set(x + width / 2, -y - height / 2, 0);
|
|
5168
|
+
mesh.renderOrder = index;
|
|
5169
|
+
this.add(mesh);
|
|
5170
|
+
this.bounds.expandByPoint(new import_three14.Vector2(x, y));
|
|
5171
|
+
this.bounds.expandByPoint(new import_three14.Vector2(x + width, y + height));
|
|
5172
|
+
}
|
|
5173
|
+
this.initialized = true;
|
|
5174
|
+
this.notifyDirty();
|
|
5175
|
+
} catch (error) {
|
|
5176
|
+
this.disposeAndRemoveAllChildren();
|
|
5177
|
+
throw error;
|
|
5178
|
+
}
|
|
5179
|
+
}
|
|
5180
|
+
async loadMaterial(key) {
|
|
5181
|
+
const assetKey = key.serialize();
|
|
5182
|
+
const materialKey = `gui:${assetKey}`;
|
|
5183
|
+
const cached2 = Caching.materialCache.getIfPresent(materialKey);
|
|
5184
|
+
if (cached2) return cached2;
|
|
5185
|
+
const pending = ModelTextures.get(key);
|
|
5186
|
+
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKey);
|
|
5187
|
+
const image = await pending;
|
|
5188
|
+
if (!image) throw new Error(`Could not load GUI texture ${key.toNamespacedString()}`);
|
|
5189
|
+
const create = () => Materials.createGuiCanvasMaterial(image.data.canvas);
|
|
5190
|
+
if (cachedAsset && Caching.textureAssetCache.getIfPresent(assetKey) === cachedAsset) {
|
|
5191
|
+
return Caching.materialCache.get(materialKey, create);
|
|
5192
|
+
}
|
|
5193
|
+
const material = create();
|
|
5194
|
+
this.ownedMaterials.add(material);
|
|
5195
|
+
return material;
|
|
5196
|
+
}
|
|
5197
|
+
disposeAndRemoveAllChildren() {
|
|
5198
|
+
for (const geometry of this.geometries) geometry.dispose();
|
|
5199
|
+
this.geometries.clear();
|
|
5200
|
+
for (const material of this.ownedMaterials) {
|
|
5201
|
+
material.map.dispose();
|
|
5202
|
+
material.dispose();
|
|
5203
|
+
}
|
|
5204
|
+
this.ownedMaterials.clear();
|
|
5205
|
+
this.bounds.makeEmpty();
|
|
5206
|
+
this.initialized = false;
|
|
5207
|
+
super.disposeAndRemoveAllChildren();
|
|
5208
|
+
}
|
|
5091
5209
|
};
|
|
5210
|
+
function isGuiObject(obj) {
|
|
5211
|
+
return obj.isGuiObject;
|
|
5212
|
+
}
|
|
5092
5213
|
|
|
5093
5214
|
// src/index.ts
|
|
5094
5215
|
init_image();
|
|
5095
5216
|
|
|
5096
5217
|
// src/inspector/SceneInspector.ts
|
|
5097
|
-
var
|
|
5218
|
+
var import_three15 = require("three");
|
|
5098
5219
|
init_SceneObject();
|
|
5099
5220
|
init_util();
|
|
5100
5221
|
init_log();
|
|
@@ -5104,11 +5225,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
5104
5225
|
var SceneInspector = class {
|
|
5105
5226
|
constructor(renderer) {
|
|
5106
5227
|
this.renderer = renderer;
|
|
5107
|
-
this.mouse = new
|
|
5228
|
+
this.mouse = new import_three15.Vector2();
|
|
5108
5229
|
this.listeners = new AbortController();
|
|
5109
5230
|
this.objectInfoContainer = document.createElement("div");
|
|
5110
5231
|
this.objectControlsContainer = document.createElement("div");
|
|
5111
|
-
this.raycaster = new
|
|
5232
|
+
this.raycaster = new import_three15.Raycaster();
|
|
5112
5233
|
this.init();
|
|
5113
5234
|
}
|
|
5114
5235
|
init() {
|
|
@@ -5524,7 +5645,7 @@ init_ModelGenerator();
|
|
|
5524
5645
|
init_ModelMerger();
|
|
5525
5646
|
|
|
5526
5647
|
// src/model/block/BlockStateResolver.ts
|
|
5527
|
-
var
|
|
5648
|
+
var import_three18 = require("three");
|
|
5528
5649
|
init_BlockStates();
|
|
5529
5650
|
init_MineRenderError();
|
|
5530
5651
|
init_util();
|
|
@@ -5602,7 +5723,7 @@ var BlockStateResolver = class {
|
|
|
5602
5723
|
return variants[variants.length - 1];
|
|
5603
5724
|
}
|
|
5604
5725
|
static rotation(variant) {
|
|
5605
|
-
const rotation = new
|
|
5726
|
+
const rotation = new import_three18.Euler();
|
|
5606
5727
|
if (typeof variant.x !== "undefined") {
|
|
5607
5728
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
5608
5729
|
}
|
|
@@ -5709,7 +5830,7 @@ init_SceneObject();
|
|
|
5709
5830
|
init_ModelObject();
|
|
5710
5831
|
init_Models();
|
|
5711
5832
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
5712
|
-
var
|
|
5833
|
+
var import_three23 = require("three");
|
|
5713
5834
|
init_MineRenderError();
|
|
5714
5835
|
init_InstanceReference();
|
|
5715
5836
|
init_AssetKey();
|
|
@@ -5778,12 +5899,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5778
5899
|
getModelCullMask(model, worldMask) {
|
|
5779
5900
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
5780
5901
|
if (object.options.displayPosition) return 0;
|
|
5781
|
-
const position = new
|
|
5782
|
-
const rotation = new
|
|
5783
|
-
const scale = new
|
|
5902
|
+
const position = new import_three23.Vector3();
|
|
5903
|
+
const rotation = new import_three23.Quaternion();
|
|
5904
|
+
const scale = new import_three23.Vector3();
|
|
5784
5905
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
5785
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
5786
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
5906
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three23.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
5907
|
+
return ModelCulling.toLocalMask(worldMask, new import_three23.Euler().setFromQuaternion(rotation));
|
|
5787
5908
|
}
|
|
5788
5909
|
async setCullMask(worldMask) {
|
|
5789
5910
|
worldMask &= 63;
|
|
@@ -5845,7 +5966,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5845
5966
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
5846
5967
|
);
|
|
5847
5968
|
const previous = this._fluidModel;
|
|
5848
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
5969
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three23.Matrix4().makeTranslation(...this.position.toArray());
|
|
5849
5970
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
5850
5971
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
5851
5972
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -5976,7 +6097,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5976
6097
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
5977
6098
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
5978
6099
|
}
|
|
5979
|
-
getMatrixAt(index, matrix = new
|
|
6100
|
+
getMatrixAt(index, matrix = new import_three23.Matrix4()) {
|
|
5980
6101
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
5981
6102
|
const child = this._models[0];
|
|
5982
6103
|
if (child && isModelObject(child)) {
|
|
@@ -7842,7 +7963,7 @@ init_ModelObject();
|
|
|
7842
7963
|
init_nbt();
|
|
7843
7964
|
|
|
7844
7965
|
// src/renderer/MineRenderScene.ts
|
|
7845
|
-
var
|
|
7966
|
+
var import_three25 = require("three");
|
|
7846
7967
|
init_SceneObject();
|
|
7847
7968
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
7848
7969
|
init_ModelObject();
|
|
@@ -8575,7 +8696,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
8575
8696
|
init_util();
|
|
8576
8697
|
|
|
8577
8698
|
// src/skin/SkinTextures.ts
|
|
8578
|
-
var
|
|
8699
|
+
var import_three24 = require("three");
|
|
8579
8700
|
init_Caching();
|
|
8580
8701
|
init_CacheKey();
|
|
8581
8702
|
init_MineRenderError();
|
|
@@ -8659,11 +8780,11 @@ var SkinTextures = class {
|
|
|
8659
8780
|
});
|
|
8660
8781
|
}
|
|
8661
8782
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
8662
|
-
const texture = Textures.initTextureProps(new
|
|
8663
|
-
texture.colorSpace =
|
|
8783
|
+
const texture = Textures.initTextureProps(new import_three24.DataTexture(pixels, width, height));
|
|
8784
|
+
texture.colorSpace = import_three24.SRGBColorSpace;
|
|
8664
8785
|
texture.flipY = true;
|
|
8665
8786
|
texture.needsUpdate = true;
|
|
8666
|
-
return new
|
|
8787
|
+
return new import_three24.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three24.DoubleSide : import_three24.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
8667
8788
|
}
|
|
8668
8789
|
static isSlim(image, scale) {
|
|
8669
8790
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -8890,7 +9011,7 @@ var SkinObject = class extends SceneObject {
|
|
|
8890
9011
|
};
|
|
8891
9012
|
|
|
8892
9013
|
// src/renderer/MineRenderScene.ts
|
|
8893
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
9014
|
+
var MineRenderScene = class _MineRenderScene extends import_three25.Scene {
|
|
8894
9015
|
constructor(options) {
|
|
8895
9016
|
super();
|
|
8896
9017
|
this.isMineRenderScene = true;
|
|
@@ -9009,13 +9130,21 @@ var MineRenderScene = class _MineRenderScene extends import_three24.Scene {
|
|
|
9009
9130
|
async addEntity(entity, options, parent = this) {
|
|
9010
9131
|
return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
|
|
9011
9132
|
}
|
|
9133
|
+
async addGui(layers, options, parent = this) {
|
|
9134
|
+
const obj = new GuiObject(layers, options);
|
|
9135
|
+
obj.scene = this;
|
|
9136
|
+
await obj.init();
|
|
9137
|
+
parent.add(obj);
|
|
9138
|
+
this.dirty = true;
|
|
9139
|
+
return obj;
|
|
9140
|
+
}
|
|
9012
9141
|
};
|
|
9013
9142
|
function isMineRenderScene(obj) {
|
|
9014
9143
|
return obj.isMineRenderScene;
|
|
9015
9144
|
}
|
|
9016
9145
|
|
|
9017
9146
|
// src/renderer/Renderer.ts
|
|
9018
|
-
var
|
|
9147
|
+
var import_three27 = require("three");
|
|
9019
9148
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
9020
9149
|
var import_stats = __toESM(require("stats.js"));
|
|
9021
9150
|
var import_postprocessing = require("postprocessing");
|
|
@@ -9023,11 +9152,11 @@ init_util();
|
|
|
9023
9152
|
init_three();
|
|
9024
9153
|
|
|
9025
9154
|
// src/three/OrbitControls.js
|
|
9026
|
-
var
|
|
9155
|
+
var import_three26 = require("three");
|
|
9027
9156
|
var _changeEvent = { type: "change" };
|
|
9028
9157
|
var _startEvent = { type: "start" };
|
|
9029
9158
|
var _endEvent = { type: "end" };
|
|
9030
|
-
var OrbitControls = class extends
|
|
9159
|
+
var OrbitControls = class extends import_three26.EventDispatcher {
|
|
9031
9160
|
constructor(object, domElement) {
|
|
9032
9161
|
super();
|
|
9033
9162
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -9036,7 +9165,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9036
9165
|
this.domElement = domElement;
|
|
9037
9166
|
this.domElement.style.touchAction = "none";
|
|
9038
9167
|
this.enabled = true;
|
|
9039
|
-
this.target = new
|
|
9168
|
+
this.target = new import_three26.Vector3();
|
|
9040
9169
|
this.minDistance = 0;
|
|
9041
9170
|
this.maxDistance = Infinity;
|
|
9042
9171
|
this.minZoom = 0;
|
|
@@ -9058,8 +9187,8 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9058
9187
|
this.autoRotate = false;
|
|
9059
9188
|
this.autoRotateSpeed = 2;
|
|
9060
9189
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
9061
|
-
this.mouseButtons = { LEFT:
|
|
9062
|
-
this.touches = { ONE:
|
|
9190
|
+
this.mouseButtons = { LEFT: import_three26.MOUSE.ROTATE, MIDDLE: import_three26.MOUSE.DOLLY, RIGHT: import_three26.MOUSE.PAN };
|
|
9191
|
+
this.touches = { ONE: import_three26.TOUCH.ROTATE, TWO: import_three26.TOUCH.DOLLY_PAN };
|
|
9063
9192
|
this.target0 = this.target.clone();
|
|
9064
9193
|
this.position0 = this.object.position.clone();
|
|
9065
9194
|
this.zoom0 = this.object.zoom;
|
|
@@ -9088,11 +9217,11 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9088
9217
|
state = STATE.NONE;
|
|
9089
9218
|
};
|
|
9090
9219
|
this.update = function() {
|
|
9091
|
-
const offset = new
|
|
9092
|
-
const quat = new
|
|
9220
|
+
const offset = new import_three26.Vector3();
|
|
9221
|
+
const quat = new import_three26.Quaternion().setFromUnitVectors(object.up, new import_three26.Vector3(0, 1, 0));
|
|
9093
9222
|
const quatInverse = quat.clone().invert();
|
|
9094
|
-
const lastPosition = new
|
|
9095
|
-
const lastQuaternion = new
|
|
9223
|
+
const lastPosition = new import_three26.Vector3();
|
|
9224
|
+
const lastQuaternion = new import_three26.Quaternion();
|
|
9096
9225
|
const twoPI = 2 * Math.PI;
|
|
9097
9226
|
return function update() {
|
|
9098
9227
|
const position = scope.object.position;
|
|
@@ -9178,20 +9307,20 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9178
9307
|
};
|
|
9179
9308
|
let state = STATE.NONE;
|
|
9180
9309
|
const EPS = 1e-6;
|
|
9181
|
-
const spherical = new
|
|
9182
|
-
const sphericalDelta = new
|
|
9310
|
+
const spherical = new import_three26.Spherical();
|
|
9311
|
+
const sphericalDelta = new import_three26.Spherical();
|
|
9183
9312
|
let scale = 1;
|
|
9184
|
-
const panOffset = new
|
|
9313
|
+
const panOffset = new import_three26.Vector3();
|
|
9185
9314
|
let zoomChanged = false;
|
|
9186
|
-
const rotateStart = new
|
|
9187
|
-
const rotateEnd = new
|
|
9188
|
-
const rotateDelta = new
|
|
9189
|
-
const panStart = new
|
|
9190
|
-
const panEnd = new
|
|
9191
|
-
const panDelta = new
|
|
9192
|
-
const dollyStart = new
|
|
9193
|
-
const dollyEnd = new
|
|
9194
|
-
const dollyDelta = new
|
|
9315
|
+
const rotateStart = new import_three26.Vector2();
|
|
9316
|
+
const rotateEnd = new import_three26.Vector2();
|
|
9317
|
+
const rotateDelta = new import_three26.Vector2();
|
|
9318
|
+
const panStart = new import_three26.Vector2();
|
|
9319
|
+
const panEnd = new import_three26.Vector2();
|
|
9320
|
+
const panDelta = new import_three26.Vector2();
|
|
9321
|
+
const dollyStart = new import_three26.Vector2();
|
|
9322
|
+
const dollyEnd = new import_three26.Vector2();
|
|
9323
|
+
const dollyDelta = new import_three26.Vector2();
|
|
9195
9324
|
const pointers = [];
|
|
9196
9325
|
const pointerPositions = {};
|
|
9197
9326
|
function getAutoRotationAngle() {
|
|
@@ -9207,7 +9336,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9207
9336
|
sphericalDelta.phi -= angle;
|
|
9208
9337
|
}
|
|
9209
9338
|
const panLeft = function() {
|
|
9210
|
-
const v = new
|
|
9339
|
+
const v = new import_three26.Vector3();
|
|
9211
9340
|
return function panLeft2(distance, objectMatrix) {
|
|
9212
9341
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
9213
9342
|
v.multiplyScalar(-distance);
|
|
@@ -9215,7 +9344,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9215
9344
|
};
|
|
9216
9345
|
}();
|
|
9217
9346
|
const panUp = function() {
|
|
9218
|
-
const v = new
|
|
9347
|
+
const v = new import_three26.Vector3();
|
|
9219
9348
|
return function panUp2(distance, objectMatrix) {
|
|
9220
9349
|
if (scope.screenSpacePanning === true) {
|
|
9221
9350
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -9228,7 +9357,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9228
9357
|
};
|
|
9229
9358
|
}();
|
|
9230
9359
|
const pan = function() {
|
|
9231
|
-
const offset = new
|
|
9360
|
+
const offset = new import_three26.Vector3();
|
|
9232
9361
|
return function pan2(deltaX, deltaY) {
|
|
9233
9362
|
const element = scope.domElement;
|
|
9234
9363
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -9477,12 +9606,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9477
9606
|
mouseAction = -1;
|
|
9478
9607
|
}
|
|
9479
9608
|
switch (mouseAction) {
|
|
9480
|
-
case
|
|
9609
|
+
case import_three26.MOUSE.DOLLY:
|
|
9481
9610
|
if (scope.enableZoom === false) return;
|
|
9482
9611
|
handleMouseDownDolly(event);
|
|
9483
9612
|
state = STATE.DOLLY;
|
|
9484
9613
|
break;
|
|
9485
|
-
case
|
|
9614
|
+
case import_three26.MOUSE.ROTATE:
|
|
9486
9615
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
9487
9616
|
if (scope.enablePan === false) return;
|
|
9488
9617
|
handleMouseDownPan(event);
|
|
@@ -9493,7 +9622,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9493
9622
|
state = STATE.ROTATE;
|
|
9494
9623
|
}
|
|
9495
9624
|
break;
|
|
9496
|
-
case
|
|
9625
|
+
case import_three26.MOUSE.PAN:
|
|
9497
9626
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
9498
9627
|
if (scope.enableRotate === false) return;
|
|
9499
9628
|
handleMouseDownRotate(event);
|
|
@@ -9549,12 +9678,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9549
9678
|
switch (pointers.length) {
|
|
9550
9679
|
case 1:
|
|
9551
9680
|
switch (scope.touches.ONE) {
|
|
9552
|
-
case
|
|
9681
|
+
case import_three26.TOUCH.ROTATE:
|
|
9553
9682
|
if (scope.enableRotate === false) return;
|
|
9554
9683
|
handleTouchStartRotate();
|
|
9555
9684
|
state = STATE.TOUCH_ROTATE;
|
|
9556
9685
|
break;
|
|
9557
|
-
case
|
|
9686
|
+
case import_three26.TOUCH.PAN:
|
|
9558
9687
|
if (scope.enablePan === false) return;
|
|
9559
9688
|
handleTouchStartPan();
|
|
9560
9689
|
state = STATE.TOUCH_PAN;
|
|
@@ -9565,12 +9694,12 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9565
9694
|
break;
|
|
9566
9695
|
case 2:
|
|
9567
9696
|
switch (scope.touches.TWO) {
|
|
9568
|
-
case
|
|
9697
|
+
case import_three26.TOUCH.DOLLY_PAN:
|
|
9569
9698
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
9570
9699
|
handleTouchStartDollyPan();
|
|
9571
9700
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
9572
9701
|
break;
|
|
9573
|
-
case
|
|
9702
|
+
case import_three26.TOUCH.DOLLY_ROTATE:
|
|
9574
9703
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
9575
9704
|
handleTouchStartDollyRotate();
|
|
9576
9705
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -9637,7 +9766,7 @@ var OrbitControls = class extends import_three25.EventDispatcher {
|
|
|
9637
9766
|
function trackPointer(event) {
|
|
9638
9767
|
let position = pointerPositions[event.pointerId];
|
|
9639
9768
|
if (position === void 0) {
|
|
9640
|
-
position = new
|
|
9769
|
+
position = new import_three26.Vector2();
|
|
9641
9770
|
pointerPositions[event.pointerId] = position;
|
|
9642
9771
|
}
|
|
9643
9772
|
position.set(event.pageX, event.pageY);
|
|
@@ -9657,10 +9786,10 @@ var MapControls = class extends OrbitControls {
|
|
|
9657
9786
|
constructor(object, domElement) {
|
|
9658
9787
|
super(object, domElement);
|
|
9659
9788
|
this.screenSpacePanning = false;
|
|
9660
|
-
this.mouseButtons.LEFT =
|
|
9661
|
-
this.mouseButtons.RIGHT =
|
|
9662
|
-
this.touches.ONE =
|
|
9663
|
-
this.touches.TWO =
|
|
9789
|
+
this.mouseButtons.LEFT = import_three26.MOUSE.PAN;
|
|
9790
|
+
this.mouseButtons.RIGHT = import_three26.MOUSE.ROTATE;
|
|
9791
|
+
this.touches.ONE = import_three26.TOUCH.PAN;
|
|
9792
|
+
this.touches.TWO = import_three26.TOUCH.DOLLY_ROTATE;
|
|
9664
9793
|
}
|
|
9665
9794
|
};
|
|
9666
9795
|
|
|
@@ -9676,6 +9805,10 @@ var Renderer = class _Renderer {
|
|
|
9676
9805
|
this._dirty = true;
|
|
9677
9806
|
};
|
|
9678
9807
|
this.options = (0, import_ts_deepmerge9.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
9808
|
+
const pixelRatio = this.options.render.pixelRatio ?? 1;
|
|
9809
|
+
if (!Number.isFinite(pixelRatio) || pixelRatio <= 0) {
|
|
9810
|
+
throw new RangeError("render.pixelRatio must be a finite positive number");
|
|
9811
|
+
}
|
|
9679
9812
|
this._animationLoop = this.animate.bind(this);
|
|
9680
9813
|
this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
9681
9814
|
this._scene = this.createScene();
|
|
@@ -9705,11 +9838,12 @@ var Renderer = class _Renderer {
|
|
|
9705
9838
|
top: void 0,
|
|
9706
9839
|
bottom: void 0
|
|
9707
9840
|
},
|
|
9708
|
-
position: new
|
|
9709
|
-
lookingAt: new
|
|
9841
|
+
position: new import_three27.Vector3(50, 50, 50),
|
|
9842
|
+
lookingAt: new import_three27.Vector3(0, 0, 0)
|
|
9710
9843
|
},
|
|
9711
9844
|
render: {
|
|
9712
9845
|
fpsLimit: 60,
|
|
9846
|
+
pixelRatio: 1,
|
|
9713
9847
|
stats: false,
|
|
9714
9848
|
antialias: true,
|
|
9715
9849
|
shade: true,
|
|
@@ -9736,14 +9870,14 @@ var Renderer = class _Renderer {
|
|
|
9736
9870
|
switch (this.options.camera.type) {
|
|
9737
9871
|
case "perspective":
|
|
9738
9872
|
default:
|
|
9739
|
-
return new
|
|
9873
|
+
return new import_three27.PerspectiveCamera(
|
|
9740
9874
|
this.options.camera.perspective.fov,
|
|
9741
9875
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
9742
9876
|
this.options.camera.near,
|
|
9743
9877
|
this.options.camera.far
|
|
9744
9878
|
);
|
|
9745
9879
|
case "orthographic":
|
|
9746
|
-
return new
|
|
9880
|
+
return new import_three27.OrthographicCamera(
|
|
9747
9881
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
9748
9882
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
9749
9883
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -9754,7 +9888,7 @@ var Renderer = class _Renderer {
|
|
|
9754
9888
|
}
|
|
9755
9889
|
}
|
|
9756
9890
|
createRenderer() {
|
|
9757
|
-
const renderer = new
|
|
9891
|
+
const renderer = new import_three27.WebGLRenderer({
|
|
9758
9892
|
antialias: this.options.render.antialias,
|
|
9759
9893
|
alpha: true,
|
|
9760
9894
|
powerPreference: "high-performance",
|
|
@@ -9762,8 +9896,9 @@ var Renderer = class _Renderer {
|
|
|
9762
9896
|
});
|
|
9763
9897
|
renderer.setClearColor(0, 0);
|
|
9764
9898
|
renderer.shadowMap.enabled = true;
|
|
9765
|
-
renderer.shadowMap.type =
|
|
9766
|
-
renderer.outputColorSpace =
|
|
9899
|
+
renderer.shadowMap.type = import_three27.PCFSoftShadowMap;
|
|
9900
|
+
renderer.outputColorSpace = import_three27.SRGBColorSpace;
|
|
9901
|
+
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
9767
9902
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
9768
9903
|
return renderer;
|
|
9769
9904
|
}
|
|
@@ -9797,20 +9932,20 @@ var Renderer = class _Renderer {
|
|
|
9797
9932
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
9798
9933
|
}
|
|
9799
9934
|
if (this.options.debug.grid) {
|
|
9800
|
-
const gridHelper = new
|
|
9935
|
+
const gridHelper = new import_three27.GridHelper(128, 16);
|
|
9801
9936
|
this._debugHelpers.push(gridHelper);
|
|
9802
9937
|
this.scene.add(gridHelper);
|
|
9803
|
-
const gridHelper2 = new
|
|
9938
|
+
const gridHelper2 = new import_three27.GridHelper(128, 16);
|
|
9804
9939
|
this._debugHelpers.push(gridHelper2);
|
|
9805
9940
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
9806
9941
|
this.scene.add(gridHelper2);
|
|
9807
|
-
const gridHelper3 = new
|
|
9942
|
+
const gridHelper3 = new import_three27.GridHelper(128, 16);
|
|
9808
9943
|
this._debugHelpers.push(gridHelper3);
|
|
9809
9944
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
9810
9945
|
this.scene.add(gridHelper3);
|
|
9811
9946
|
}
|
|
9812
9947
|
if (this.options.debug.axes) {
|
|
9813
|
-
const axesHelper = new
|
|
9948
|
+
const axesHelper = new import_three27.AxesHelper(64);
|
|
9814
9949
|
this._debugHelpers.push(axesHelper);
|
|
9815
9950
|
this.scene.add(axesHelper);
|
|
9816
9951
|
}
|
|
@@ -10440,19 +10575,19 @@ var AnvilParser = class {
|
|
|
10440
10575
|
};
|
|
10441
10576
|
|
|
10442
10577
|
// src/world/Chunk.ts
|
|
10443
|
-
var
|
|
10578
|
+
var import_three32 = require("three");
|
|
10444
10579
|
init_BlockStates();
|
|
10445
10580
|
init_AssetKey();
|
|
10446
10581
|
|
|
10447
10582
|
// src/world/MineRenderWorld.ts
|
|
10448
|
-
var
|
|
10583
|
+
var import_three30 = require("three");
|
|
10449
10584
|
init_BatchedExecutor();
|
|
10450
10585
|
init_AssetKey();
|
|
10451
10586
|
init_BlockStates();
|
|
10452
10587
|
init_CubeFace();
|
|
10453
10588
|
|
|
10454
10589
|
// src/world/SectionModels.ts
|
|
10455
|
-
var
|
|
10590
|
+
var import_three29 = require("three");
|
|
10456
10591
|
init_AssetKey();
|
|
10457
10592
|
init_Models();
|
|
10458
10593
|
init_CubeFace();
|
|
@@ -10518,12 +10653,12 @@ var SectionModels = class {
|
|
|
10518
10653
|
});
|
|
10519
10654
|
await object.init();
|
|
10520
10655
|
const geometry = object.children[0].geometry;
|
|
10521
|
-
geometry.applyMatrix4(new
|
|
10656
|
+
geometry.applyMatrix4(new import_three29.Matrix4().makeRotationFromEuler(rotation));
|
|
10522
10657
|
object.clear();
|
|
10523
10658
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
10524
10659
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
10525
10660
|
if (local < 0) return 0;
|
|
10526
|
-
const normal = new
|
|
10661
|
+
const normal = new import_three29.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
10527
10662
|
const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
10528
10663
|
return 1 << world;
|
|
10529
10664
|
});
|
|
@@ -10553,20 +10688,20 @@ var MineRenderWorld = class {
|
|
|
10553
10688
|
}
|
|
10554
10689
|
getBlockAt(posOrX, y, z) {
|
|
10555
10690
|
if (typeof posOrX == "number") {
|
|
10556
|
-
return this.getBlockAt(new
|
|
10691
|
+
return this.getBlockAt(new import_three30.Vector3(posOrX, y, z));
|
|
10557
10692
|
}
|
|
10558
10693
|
if (isTripleArray(posOrX)) {
|
|
10559
|
-
return this.getBlockAt(new
|
|
10694
|
+
return this.getBlockAt(new import_three30.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
10560
10695
|
}
|
|
10561
10696
|
this.validatePosBounds(posOrX);
|
|
10562
10697
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
10563
10698
|
}
|
|
10564
10699
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
10565
10700
|
if (typeof posOrX == "number") {
|
|
10566
|
-
return this.setBlockAt(new
|
|
10701
|
+
return this.setBlockAt(new import_three30.Vector3(posOrX, yOrBlock, z), block);
|
|
10567
10702
|
}
|
|
10568
10703
|
if (isTripleArray(posOrX)) {
|
|
10569
|
-
return this.setBlockAt(new
|
|
10704
|
+
return this.setBlockAt(new import_three30.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
10570
10705
|
}
|
|
10571
10706
|
return this.placeBlock(posOrX, yOrBlock);
|
|
10572
10707
|
}
|
|
@@ -10587,7 +10722,7 @@ var MineRenderWorld = class {
|
|
|
10587
10722
|
const collect = async (positions2) => {
|
|
10588
10723
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
10589
10724
|
};
|
|
10590
|
-
const place = (block) => this.placeBlock(new
|
|
10725
|
+
const place = (block) => this.placeBlock(new import_three30.Vector3(...block.position), block, collect);
|
|
10591
10726
|
const keys = /* @__PURE__ */ new Map();
|
|
10592
10727
|
for (const block of multiblock.blocks) {
|
|
10593
10728
|
if (Chunk.isAir(block)) continue;
|
|
@@ -10665,13 +10800,13 @@ var MineRenderWorld = class {
|
|
|
10665
10800
|
for (const pos of positions) {
|
|
10666
10801
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
10667
10802
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
10668
|
-
const neighbor = pos.clone().add(new
|
|
10803
|
+
const neighbor = pos.clone().add(new import_three30.Vector3(...offset));
|
|
10669
10804
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
10670
10805
|
}
|
|
10671
10806
|
for (let y = -1; y <= 1; y++) {
|
|
10672
10807
|
for (let z = -1; z <= 1; z++) {
|
|
10673
10808
|
for (let x = -1; x <= 1; x++) {
|
|
10674
|
-
const neighbor = pos.clone().add(new
|
|
10809
|
+
const neighbor = pos.clone().add(new import_three30.Vector3(x, y, z));
|
|
10675
10810
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
10676
10811
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
10677
10812
|
}
|
|
@@ -10693,7 +10828,7 @@ var MineRenderWorld = class {
|
|
|
10693
10828
|
if (!block) continue;
|
|
10694
10829
|
if (block.object?.fluidKind) {
|
|
10695
10830
|
await block.object.updateFluid((x, y, z) => {
|
|
10696
|
-
const neighbor = pos.clone().add(new
|
|
10831
|
+
const neighbor = pos.clone().add(new import_three30.Vector3(x, y, z));
|
|
10697
10832
|
const section = this.getChunkAt(neighbor);
|
|
10698
10833
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
10699
10834
|
return {
|
|
@@ -10705,7 +10840,7 @@ var MineRenderWorld = class {
|
|
|
10705
10840
|
}
|
|
10706
10841
|
let mask = 0;
|
|
10707
10842
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
10708
|
-
const neighbor = pos.clone().add(new
|
|
10843
|
+
const neighbor = pos.clone().add(new import_three30.Vector3(...offset));
|
|
10709
10844
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
10710
10845
|
mask |= 1 << face;
|
|
10711
10846
|
}
|
|
@@ -10739,14 +10874,14 @@ var MineRenderWorld = class {
|
|
|
10739
10874
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
10740
10875
|
}
|
|
10741
10876
|
static worldToScenePosition(pos) {
|
|
10742
|
-
return new
|
|
10877
|
+
return new import_three30.Vector3(
|
|
10743
10878
|
pos.x * 16,
|
|
10744
10879
|
pos.y * 16,
|
|
10745
10880
|
pos.z * 16
|
|
10746
10881
|
);
|
|
10747
10882
|
}
|
|
10748
10883
|
static sceneToWorldPosition(pos) {
|
|
10749
|
-
return new
|
|
10884
|
+
return new import_three30.Vector3(
|
|
10750
10885
|
pos.x / 16,
|
|
10751
10886
|
pos.y / 16,
|
|
10752
10887
|
pos.z / 16
|
|
@@ -10766,10 +10901,10 @@ var MineRenderWorld = class {
|
|
|
10766
10901
|
};
|
|
10767
10902
|
|
|
10768
10903
|
// src/world/SectionMesh.ts
|
|
10769
|
-
var
|
|
10904
|
+
var import_three31 = require("three");
|
|
10770
10905
|
init_CanvasCompat();
|
|
10771
10906
|
init_Materials();
|
|
10772
|
-
var SectionMesh = class _SectionMesh extends
|
|
10907
|
+
var SectionMesh = class _SectionMesh extends import_three31.Group {
|
|
10773
10908
|
constructor() {
|
|
10774
10909
|
super(...arguments);
|
|
10775
10910
|
this.ownedMeshes = [];
|
|
@@ -10842,18 +10977,18 @@ var SectionMesh = class _SectionMesh extends import_three30.Group {
|
|
|
10842
10977
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
10843
10978
|
}
|
|
10844
10979
|
}
|
|
10845
|
-
const geometry = new
|
|
10846
|
-
geometry.setAttribute("position", new
|
|
10847
|
-
geometry.setAttribute("normal", new
|
|
10848
|
-
geometry.setAttribute("uv", new
|
|
10849
|
-
geometry.setAttribute("color", new
|
|
10980
|
+
const geometry = new import_three31.BufferGeometry();
|
|
10981
|
+
geometry.setAttribute("position", new import_three31.Float32BufferAttribute(positions, 3));
|
|
10982
|
+
geometry.setAttribute("normal", new import_three31.Float32BufferAttribute(normals, 3));
|
|
10983
|
+
geometry.setAttribute("uv", new import_three31.Float32BufferAttribute(uvs, 2));
|
|
10984
|
+
geometry.setAttribute("color", new import_three31.Float32BufferAttribute(colors, 3));
|
|
10850
10985
|
geometry.setIndex(indices);
|
|
10851
10986
|
geometry.computeBoundingBox();
|
|
10852
10987
|
geometry.computeBoundingSphere();
|
|
10853
10988
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
10854
10989
|
material.vertexColors = true;
|
|
10855
10990
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
10856
|
-
const mesh = new
|
|
10991
|
+
const mesh = new import_three31.Mesh(geometry, material);
|
|
10857
10992
|
section.add(mesh);
|
|
10858
10993
|
section.ownedMeshes.push({ mesh, texture });
|
|
10859
10994
|
}
|
|
@@ -10887,10 +11022,10 @@ var Chunk = class _Chunk {
|
|
|
10887
11022
|
}
|
|
10888
11023
|
getBlockAt(posOrX, y, z) {
|
|
10889
11024
|
if (typeof posOrX == "number") {
|
|
10890
|
-
return this.getBlockAt(new
|
|
11025
|
+
return this.getBlockAt(new import_three32.Vector3(posOrX, y, z));
|
|
10891
11026
|
}
|
|
10892
11027
|
if (isTripleArray(posOrX)) {
|
|
10893
|
-
return this.getBlockAt(new
|
|
11028
|
+
return this.getBlockAt(new import_three32.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
10894
11029
|
}
|
|
10895
11030
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
10896
11031
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -10898,10 +11033,10 @@ var Chunk = class _Chunk {
|
|
|
10898
11033
|
}
|
|
10899
11034
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
10900
11035
|
if (typeof posOrX == "number") {
|
|
10901
|
-
return this.setBlockAt(new
|
|
11036
|
+
return this.setBlockAt(new import_three32.Vector3(posOrX, yOrBlock, z), block);
|
|
10902
11037
|
}
|
|
10903
11038
|
if (isTripleArray(posOrX)) {
|
|
10904
|
-
return this.setBlockAt(new
|
|
11039
|
+
return this.setBlockAt(new import_three32.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
10905
11040
|
}
|
|
10906
11041
|
const worldPos = posOrX;
|
|
10907
11042
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -10986,7 +11121,7 @@ var Chunk = class _Chunk {
|
|
|
10986
11121
|
}
|
|
10987
11122
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
10988
11123
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
10989
|
-
new
|
|
11124
|
+
new import_three32.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
10990
11125
|
));
|
|
10991
11126
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
10992
11127
|
this.sectionBlocks.clear();
|
|
@@ -11010,14 +11145,14 @@ var Chunk = class _Chunk {
|
|
|
11010
11145
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
11011
11146
|
}
|
|
11012
11147
|
worldPosToChunkPos(pos) {
|
|
11013
|
-
return new
|
|
11148
|
+
return new import_three32.Vector3(
|
|
11014
11149
|
pos.x - this.x * 16,
|
|
11015
11150
|
pos.y - this.y * 16,
|
|
11016
11151
|
pos.z - this.z * 16
|
|
11017
11152
|
);
|
|
11018
11153
|
}
|
|
11019
11154
|
chunkPosToWorldPos(pos) {
|
|
11020
|
-
return new
|
|
11155
|
+
return new import_three32.Vector3(
|
|
11021
11156
|
this.x * 16 + pos.x,
|
|
11022
11157
|
this.y * 16 + pos.y,
|
|
11023
11158
|
this.z * 16 + pos.z
|
|
@@ -11066,6 +11201,7 @@ var Chunk = class _Chunk {
|
|
|
11066
11201
|
Env,
|
|
11067
11202
|
FluidModelObject,
|
|
11068
11203
|
Geometries,
|
|
11204
|
+
GuiHelper,
|
|
11069
11205
|
GuiLight,
|
|
11070
11206
|
GuiObject,
|
|
11071
11207
|
HostedAssetSource,
|
|
@@ -11145,6 +11281,7 @@ var Chunk = class _Chunk {
|
|
|
11145
11281
|
isDisposable,
|
|
11146
11282
|
isDoubleArray,
|
|
11147
11283
|
isEntityObject,
|
|
11284
|
+
isGuiObject,
|
|
11148
11285
|
isInstanceManager,
|
|
11149
11286
|
isInstanceReference,
|
|
11150
11287
|
isInstanceable,
|