minerender 2.1.0-alpha.67 → 2.1.0-alpha.68
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 +28 -4
- package/dist/browser/index.d.ts +28 -4
- package/dist/browser/index.js +249 -177
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +100 -28
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +86 -11
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +28 -4
- package/dist/node/index.d.ts +28 -4
- package/dist/node/index.js +250 -177
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +100 -28
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -4258,7 +4258,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4258
4258
|
const attributes = {};
|
|
4259
4259
|
const morphAttributes = {};
|
|
4260
4260
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4261
|
-
const mergedGeometry = new
|
|
4261
|
+
const mergedGeometry = new import_three21.BufferGeometry();
|
|
4262
4262
|
let offset = 0;
|
|
4263
4263
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4264
4264
|
const geometry = geometries[i];
|
|
@@ -4382,7 +4382,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4382
4382
|
array.set(attributes[i].array, offset);
|
|
4383
4383
|
offset += attributes[i].array.length;
|
|
4384
4384
|
}
|
|
4385
|
-
return new
|
|
4385
|
+
return new import_three21.BufferAttribute(array, itemSize, normalized);
|
|
4386
4386
|
}
|
|
4387
4387
|
function interleaveAttributes(attributes) {
|
|
4388
4388
|
let TypedArray;
|
|
@@ -4398,7 +4398,7 @@ function interleaveAttributes(attributes) {
|
|
|
4398
4398
|
arrayLength += attribute.array.length;
|
|
4399
4399
|
stride += attribute.itemSize;
|
|
4400
4400
|
}
|
|
4401
|
-
const interleavedBuffer = new
|
|
4401
|
+
const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4402
4402
|
let offset = 0;
|
|
4403
4403
|
const res = [];
|
|
4404
4404
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4407,7 +4407,7 @@ function interleaveAttributes(attributes) {
|
|
|
4407
4407
|
const attribute = attributes[j];
|
|
4408
4408
|
const itemSize = attribute.itemSize;
|
|
4409
4409
|
const count = attribute.count;
|
|
4410
|
-
const iba = new
|
|
4410
|
+
const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4411
4411
|
res.push(iba);
|
|
4412
4412
|
offset += itemSize;
|
|
4413
4413
|
for (let c = 0; c < count; c++) {
|
|
@@ -4491,13 +4491,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4491
4491
|
const name = attributeNames[i];
|
|
4492
4492
|
const oldAttribute = geometry.getAttribute(name);
|
|
4493
4493
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4494
|
-
const attribute = new
|
|
4494
|
+
const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4495
4495
|
result.setAttribute(name, attribute);
|
|
4496
4496
|
if (name in morphAttrsArrays) {
|
|
4497
4497
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4498
4498
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4499
4499
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4500
|
-
const morphAttribute = new
|
|
4500
|
+
const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4501
4501
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4502
4502
|
}
|
|
4503
4503
|
}
|
|
@@ -4506,11 +4506,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4506
4506
|
return result;
|
|
4507
4507
|
}
|
|
4508
4508
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4509
|
-
if (drawMode ===
|
|
4509
|
+
if (drawMode === import_three21.TrianglesDrawMode) {
|
|
4510
4510
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4511
4511
|
return geometry;
|
|
4512
4512
|
}
|
|
4513
|
-
if (drawMode ===
|
|
4513
|
+
if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
|
|
4514
4514
|
let index = geometry.getIndex();
|
|
4515
4515
|
if (index === null) {
|
|
4516
4516
|
const indices = [];
|
|
@@ -4528,7 +4528,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4528
4528
|
}
|
|
4529
4529
|
const numberOfTriangles = index.count - 2;
|
|
4530
4530
|
const newIndices = [];
|
|
4531
|
-
if (drawMode ===
|
|
4531
|
+
if (drawMode === import_three21.TriangleFanDrawMode) {
|
|
4532
4532
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4533
4533
|
newIndices.push(index.getX(0));
|
|
4534
4534
|
newIndices.push(index.getX(i));
|
|
@@ -4564,15 +4564,15 @@ function computeMorphedAttributes(object) {
|
|
|
4564
4564
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4565
4565
|
return null;
|
|
4566
4566
|
}
|
|
4567
|
-
const _vA = new
|
|
4568
|
-
const _vB = new
|
|
4569
|
-
const _vC = new
|
|
4570
|
-
const _tempA = new
|
|
4571
|
-
const _tempB = new
|
|
4572
|
-
const _tempC = new
|
|
4573
|
-
const _morphA = new
|
|
4574
|
-
const _morphB = new
|
|
4575
|
-
const _morphC = new
|
|
4567
|
+
const _vA = new import_three21.Vector3();
|
|
4568
|
+
const _vB = new import_three21.Vector3();
|
|
4569
|
+
const _vC = new import_three21.Vector3();
|
|
4570
|
+
const _tempA = new import_three21.Vector3();
|
|
4571
|
+
const _tempB = new import_three21.Vector3();
|
|
4572
|
+
const _tempC = new import_three21.Vector3();
|
|
4573
|
+
const _morphA = new import_three21.Vector3();
|
|
4574
|
+
const _morphB = new import_three21.Vector3();
|
|
4575
|
+
const _morphC = new import_three21.Vector3();
|
|
4576
4576
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4577
4577
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4578
4578
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4767,8 +4767,8 @@ function computeMorphedAttributes(object) {
|
|
|
4767
4767
|
}
|
|
4768
4768
|
}
|
|
4769
4769
|
}
|
|
4770
|
-
const morphedPositionAttribute = new
|
|
4771
|
-
const morphedNormalAttribute = new
|
|
4770
|
+
const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
|
|
4771
|
+
const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
|
|
4772
4772
|
return {
|
|
4773
4773
|
positionAttribute,
|
|
4774
4774
|
normalAttribute,
|
|
@@ -4776,24 +4776,24 @@ function computeMorphedAttributes(object) {
|
|
|
4776
4776
|
morphedNormalAttribute
|
|
4777
4777
|
};
|
|
4778
4778
|
}
|
|
4779
|
-
var
|
|
4779
|
+
var import_three21;
|
|
4780
4780
|
var init_BufferGeometryUtils = __esm({
|
|
4781
4781
|
"src/three/BufferGeometryUtils.js"() {
|
|
4782
|
-
|
|
4782
|
+
import_three21 = require("three");
|
|
4783
4783
|
}
|
|
4784
4784
|
});
|
|
4785
4785
|
|
|
4786
4786
|
// src/model/ModelCulling.ts
|
|
4787
|
-
var
|
|
4787
|
+
var import_three22, ModelCulling;
|
|
4788
4788
|
var init_ModelCulling = __esm({
|
|
4789
4789
|
"src/model/ModelCulling.ts"() {
|
|
4790
|
-
|
|
4790
|
+
import_three22 = require("three");
|
|
4791
4791
|
init_CubeFace();
|
|
4792
4792
|
ModelCulling = class {
|
|
4793
4793
|
static toLocalMask(worldMask, rotation) {
|
|
4794
4794
|
let localMask = 0;
|
|
4795
4795
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4796
|
-
const normal = new
|
|
4796
|
+
const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
|
|
4797
4797
|
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);
|
|
4798
4798
|
if (worldFace < 0) return 0;
|
|
4799
4799
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4826,10 +4826,10 @@ var init_ModelCulling = __esm({
|
|
|
4826
4826
|
});
|
|
4827
4827
|
|
|
4828
4828
|
// src/model/SpecialItems.ts
|
|
4829
|
-
var
|
|
4829
|
+
var import_three23, SpecialItems;
|
|
4830
4830
|
var init_SpecialItems = __esm({
|
|
4831
4831
|
"src/model/SpecialItems.ts"() {
|
|
4832
|
-
|
|
4832
|
+
import_three23 = require("three");
|
|
4833
4833
|
init_AssetKey();
|
|
4834
4834
|
init_Entities();
|
|
4835
4835
|
SpecialItems = class {
|
|
@@ -4857,7 +4857,7 @@ var init_SpecialItems = __esm({
|
|
|
4857
4857
|
case "minecraft:chest":
|
|
4858
4858
|
case "chest": {
|
|
4859
4859
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4860
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4860
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
|
|
4861
4861
|
lid: [angle, 0, 0],
|
|
4862
4862
|
lock: [angle, 0, 0]
|
|
4863
4863
|
});
|
|
@@ -4866,11 +4866,11 @@ var init_SpecialItems = __esm({
|
|
|
4866
4866
|
}
|
|
4867
4867
|
case "minecraft:bed":
|
|
4868
4868
|
case "bed": {
|
|
4869
|
-
const transform = new
|
|
4869
|
+
const transform = new import_three23.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three23.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three23.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three23.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
|
|
4870
4870
|
const key = texture(special.texture, "bed");
|
|
4871
4871
|
return Promise.all([
|
|
4872
4872
|
load("bed_head", key, transform),
|
|
4873
|
-
load("bed_foot", key, new
|
|
4873
|
+
load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4874
4874
|
]);
|
|
4875
4875
|
}
|
|
4876
4876
|
case "minecraft:head":
|
|
@@ -4895,7 +4895,7 @@ var init_SpecialItems = __esm({
|
|
|
4895
4895
|
return [await load(
|
|
4896
4896
|
id,
|
|
4897
4897
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4898
|
-
new
|
|
4898
|
+
new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
|
|
4899
4899
|
rotations
|
|
4900
4900
|
)];
|
|
4901
4901
|
}
|
|
@@ -5023,13 +5023,13 @@ var init_ItemTints = __esm({
|
|
|
5023
5023
|
function isModelObject(obj) {
|
|
5024
5024
|
return obj.isModelObject;
|
|
5025
5025
|
}
|
|
5026
|
-
var
|
|
5026
|
+
var import_three24, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
|
|
5027
5027
|
var init_ModelObject = __esm({
|
|
5028
5028
|
"src/model/scene/ModelObject.ts"() {
|
|
5029
5029
|
init_SceneObject();
|
|
5030
5030
|
init_Materials();
|
|
5031
5031
|
init_UVMapper();
|
|
5032
|
-
|
|
5032
|
+
import_three24 = require("three");
|
|
5033
5033
|
init_BufferGeometryUtils();
|
|
5034
5034
|
init_model();
|
|
5035
5035
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -5061,8 +5061,8 @@ var init_ModelObject = __esm({
|
|
|
5061
5061
|
const special = this.originalModel.special;
|
|
5062
5062
|
if (special) {
|
|
5063
5063
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
5064
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
5065
|
-
transform.multiply(new
|
|
5064
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
|
|
5065
|
+
transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
5066
5066
|
try {
|
|
5067
5067
|
for (const part of parts) {
|
|
5068
5068
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -5125,7 +5125,7 @@ var init_ModelObject = __esm({
|
|
|
5125
5125
|
elGeo.clearGroups();
|
|
5126
5126
|
}
|
|
5127
5127
|
if (this.options.uvLockRotation) {
|
|
5128
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5128
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
|
|
5129
5129
|
}
|
|
5130
5130
|
if (this.options.tints) {
|
|
5131
5131
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5134,19 +5134,19 @@ var init_ModelObject = __esm({
|
|
|
5134
5134
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5135
5135
|
const tint = this.options.tints[tintIndex];
|
|
5136
5136
|
if (tint === void 0) continue;
|
|
5137
|
-
const color = new
|
|
5137
|
+
const color = new import_three24.Color(tint);
|
|
5138
5138
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5139
5139
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5140
5140
|
}
|
|
5141
5141
|
}
|
|
5142
|
-
elGeo.setAttribute("color", new
|
|
5142
|
+
elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
|
|
5143
5143
|
}
|
|
5144
|
-
elGeo.applyMatrix4(new
|
|
5145
|
-
elGeo.applyMatrix4(new
|
|
5144
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
5145
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
5146
5146
|
if (el.rotation) {
|
|
5147
5147
|
applyElementRotation(el.rotation, elGeo);
|
|
5148
5148
|
}
|
|
5149
|
-
elGeo.applyMatrix4(new
|
|
5149
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
5150
5150
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
5151
5151
|
if (this.options.mergeMeshes) {
|
|
5152
5152
|
allGeos.push(elGeo);
|
|
@@ -5168,7 +5168,7 @@ var init_ModelObject = __esm({
|
|
|
5168
5168
|
if (allGeos.length > 0) {
|
|
5169
5169
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
5170
5170
|
} else {
|
|
5171
|
-
combinedGeo = new
|
|
5171
|
+
combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
|
|
5172
5172
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
5173
5173
|
}
|
|
5174
5174
|
combinedGeo.computeBoundingBox();
|
|
@@ -5280,7 +5280,7 @@ function ownHeight(sample) {
|
|
|
5280
5280
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5281
5281
|
}
|
|
5282
5282
|
function createFluidGeometry(kind, sample) {
|
|
5283
|
-
const geometry = new
|
|
5283
|
+
const geometry = new import_three29.BufferGeometry();
|
|
5284
5284
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5285
5285
|
const self = sample(0, 0, 0);
|
|
5286
5286
|
const height = (x, z) => {
|
|
@@ -5379,16 +5379,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5379
5379
|
1
|
|
5380
5380
|
);
|
|
5381
5381
|
}
|
|
5382
|
-
geometry.setAttribute("position", new
|
|
5383
|
-
geometry.setAttribute("normal", new
|
|
5384
|
-
geometry.setAttribute("uv", new
|
|
5382
|
+
geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
|
|
5383
|
+
geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
|
|
5384
|
+
geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
|
|
5385
5385
|
geometry.setIndex(indices);
|
|
5386
5386
|
return geometry;
|
|
5387
5387
|
}
|
|
5388
|
-
var
|
|
5388
|
+
var import_three29, fluidRules, HORIZONTAL, EPSILON;
|
|
5389
5389
|
var init_FluidGeometry = __esm({
|
|
5390
5390
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5391
|
-
|
|
5391
|
+
import_three29 = require("three");
|
|
5392
5392
|
init_fluidBlocks();
|
|
5393
5393
|
fluidRules = fluidBlocks_default;
|
|
5394
5394
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5417,10 +5417,10 @@ function sampleFluid(kind, sample) {
|
|
|
5417
5417
|
}
|
|
5418
5418
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5419
5419
|
}
|
|
5420
|
-
var
|
|
5420
|
+
var import_three30, FluidModelObject;
|
|
5421
5421
|
var init_FluidModelObject = __esm({
|
|
5422
5422
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5423
|
-
|
|
5423
|
+
import_three30 = require("three");
|
|
5424
5424
|
init_AssetKey();
|
|
5425
5425
|
init_Materials();
|
|
5426
5426
|
init_ModelObject();
|
|
@@ -5453,10 +5453,10 @@ var init_FluidModelObject = __esm({
|
|
|
5453
5453
|
}
|
|
5454
5454
|
}
|
|
5455
5455
|
geometry.clearGroups();
|
|
5456
|
-
const color = new
|
|
5456
|
+
const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5457
5457
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5458
5458
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5459
|
-
geometry.setAttribute("color", new
|
|
5459
|
+
geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
|
|
5460
5460
|
geometry.computeBoundingBox();
|
|
5461
5461
|
geometry.computeBoundingSphere();
|
|
5462
5462
|
if (this.options.instanceMeshes) {
|
|
@@ -5470,7 +5470,7 @@ var init_FluidModelObject = __esm({
|
|
|
5470
5470
|
super.applyTextures();
|
|
5471
5471
|
this.iterateAllMeshes((mesh) => {
|
|
5472
5472
|
const material = mesh.material;
|
|
5473
|
-
material.side =
|
|
5473
|
+
material.side = import_three30.DoubleSide;
|
|
5474
5474
|
material.forceSinglePass = true;
|
|
5475
5475
|
material.depthWrite = !material.transparent;
|
|
5476
5476
|
});
|
|
@@ -5603,6 +5603,7 @@ __export(index_browser_exports, {
|
|
|
5603
5603
|
computeTangents: () => computeTangents,
|
|
5604
5604
|
createCanvas: () => createCanvas,
|
|
5605
5605
|
createFluidGeometry: () => createFluidGeometry,
|
|
5606
|
+
createGuiTextureGeometry: () => createGuiTextureGeometry,
|
|
5606
5607
|
createImage: () => createImage,
|
|
5607
5608
|
entityAnimationTime: () => entityAnimationTime,
|
|
5608
5609
|
estimateBytesUsed: () => estimateBytesUsed,
|
|
@@ -8923,8 +8924,87 @@ var GuiHelper = class {
|
|
|
8923
8924
|
}
|
|
8924
8925
|
};
|
|
8925
8926
|
|
|
8927
|
+
// src/gui/GuiTextureGeometry.ts
|
|
8928
|
+
var import_three20 = require("three");
|
|
8929
|
+
function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
|
|
8930
|
+
if (crop || !scaling || scaling.type === "stretch") {
|
|
8931
|
+
const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
|
|
8932
|
+
const geometry = new import_three20.PlaneGeometry(width, height);
|
|
8933
|
+
const uv = geometry.getAttribute("uv");
|
|
8934
|
+
for (let i = 0; i < uv.count; i++) {
|
|
8935
|
+
uv.setXY(
|
|
8936
|
+
i,
|
|
8937
|
+
(x + uv.getX(i) * w) / imageWidth,
|
|
8938
|
+
1 - (y + (1 - uv.getY(i)) * h) / imageHeight
|
|
8939
|
+
);
|
|
8940
|
+
}
|
|
8941
|
+
return geometry;
|
|
8942
|
+
}
|
|
8943
|
+
const sw = scaling.width, sh = scaling.height;
|
|
8944
|
+
if (![sw, sh].every((value) => Number.isInteger(value) && value > 0)) {
|
|
8945
|
+
throw new Error("GUI sprite dimensions must be positive integers");
|
|
8946
|
+
}
|
|
8947
|
+
if (![width, height].every((value) => Number.isFinite(value) && value >= 0)) {
|
|
8948
|
+
throw new Error("GUI output dimensions must be finite and nonnegative");
|
|
8949
|
+
}
|
|
8950
|
+
const positions = [], uvs = [], normals = [], indices = [];
|
|
8951
|
+
function quad(x, y, w, h, u, v, uw, vh) {
|
|
8952
|
+
if (w <= 0 || h <= 0) return;
|
|
8953
|
+
const index = positions.length / 3;
|
|
8954
|
+
const left = x - width / 2, top = height / 2 - y;
|
|
8955
|
+
positions.push(left, top, 0, left + w, top, 0, left, top - h, 0, left + w, top - h, 0);
|
|
8956
|
+
uvs.push(
|
|
8957
|
+
u / sw,
|
|
8958
|
+
1 - v / sh,
|
|
8959
|
+
(u + uw) / sw,
|
|
8960
|
+
1 - v / sh,
|
|
8961
|
+
u / sw,
|
|
8962
|
+
1 - (v + vh) / sh,
|
|
8963
|
+
(u + uw) / sw,
|
|
8964
|
+
1 - (v + vh) / sh
|
|
8965
|
+
);
|
|
8966
|
+
normals.push(0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1);
|
|
8967
|
+
indices.push(index, index + 2, index + 1, index + 2, index + 3, index + 1);
|
|
8968
|
+
}
|
|
8969
|
+
function tile(x, y, w, h, u, v, tw, th) {
|
|
8970
|
+
for (let dy = 0; dy < h; dy += th) {
|
|
8971
|
+
for (let dx = 0; dx < w; dx += tw) {
|
|
8972
|
+
const cw = Math.min(tw, w - dx), ch = Math.min(th, h - dy);
|
|
8973
|
+
quad(x + dx, y + dy, cw, ch, u, v, cw, ch);
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8976
|
+
}
|
|
8977
|
+
if (scaling.type === "tile") {
|
|
8978
|
+
tile(0, 0, width, height, 0, 0, sw, sh);
|
|
8979
|
+
} else {
|
|
8980
|
+
let segments = function(size, sourceSize, start, end) {
|
|
8981
|
+
if (size === sourceSize) return [[0, size, 0, sourceSize]];
|
|
8982
|
+
start = Math.min(start, Math.floor(size / 2));
|
|
8983
|
+
end = Math.min(end, Math.floor(size / 2));
|
|
8984
|
+
return [
|
|
8985
|
+
[0, start, 0, start],
|
|
8986
|
+
[start, size - start - end, start, sourceSize - start - end],
|
|
8987
|
+
[size - end, end, sourceSize - end, end]
|
|
8988
|
+
];
|
|
8989
|
+
};
|
|
8990
|
+
const border = typeof scaling.border === "number" ? { left: scaling.border, top: scaling.border, right: scaling.border, bottom: scaling.border } : scaling.border;
|
|
8991
|
+
if (!border || typeof scaling.border === "number" && scaling.border <= 0 || ![border.left, border.top, border.right, border.bottom].every((value) => Number.isInteger(value) && value >= 0) || border.left + border.right >= sw || border.top + border.bottom >= sh) {
|
|
8992
|
+
throw new Error("GUI nine-slice borders must be nonnegative integers with a nonempty center");
|
|
8993
|
+
}
|
|
8994
|
+
const columns = segments(width, sw, border.left, border.right);
|
|
8995
|
+
const rows = segments(height, sh, border.top, border.bottom);
|
|
8996
|
+
for (const [y, h, v, vh] of rows) {
|
|
8997
|
+
for (const [x, w, u, uw] of columns) {
|
|
8998
|
+
if (w <= 0 || h <= 0) continue;
|
|
8999
|
+
(scaling.stretch_inner ? quad : tile)(x, y, w, h, u, v, uw, vh);
|
|
9000
|
+
}
|
|
9001
|
+
}
|
|
9002
|
+
}
|
|
9003
|
+
return new import_three20.BufferGeometry().setAttribute("position", new import_three20.Float32BufferAttribute(positions, 3)).setAttribute("normal", new import_three20.Float32BufferAttribute(normals, 3)).setAttribute("uv", new import_three20.Float32BufferAttribute(uvs, 2)).setIndex(indices);
|
|
9004
|
+
}
|
|
9005
|
+
|
|
8926
9006
|
// src/gui/scene/GuiObject.ts
|
|
8927
|
-
var
|
|
9007
|
+
var import_three25 = require("three");
|
|
8928
9008
|
init_AssetKey();
|
|
8929
9009
|
init_ModelTextures();
|
|
8930
9010
|
init_Models();
|
|
@@ -8940,7 +9020,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8940
9020
|
this.textureLayers = textureLayers;
|
|
8941
9021
|
this.isGuiObject = true;
|
|
8942
9022
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
8943
|
-
this.bounds = new
|
|
9023
|
+
this.bounds = new import_three25.Box2();
|
|
8944
9024
|
this.geometries = /* @__PURE__ */ new Set();
|
|
8945
9025
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
8946
9026
|
this.initialized = false;
|
|
@@ -8958,41 +9038,33 @@ var GuiObject = class extends SceneObject {
|
|
|
8958
9038
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
8959
9039
|
item.updateWorldMatrix(true, true);
|
|
8960
9040
|
const inverse = this.matrixWorld.clone().invert();
|
|
8961
|
-
const bounds = new
|
|
9041
|
+
const bounds = new import_three25.Box3();
|
|
8962
9042
|
item.iterateAllMeshes((mesh2) => {
|
|
8963
9043
|
mesh2.geometry.computeBoundingBox();
|
|
8964
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
9044
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
8965
9045
|
});
|
|
8966
9046
|
item.position.z = depth - bounds.min.z;
|
|
8967
9047
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
8968
|
-
this.bounds.expandByPoint(new
|
|
8969
|
-
this.bounds.expandByPoint(new
|
|
8970
|
-
this.bounds.expandByPoint(new
|
|
8971
|
-
this.bounds.expandByPoint(new
|
|
9048
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
9049
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
|
|
9050
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
|
|
9051
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
|
|
8972
9052
|
continue;
|
|
8973
9053
|
}
|
|
8974
9054
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
8975
9055
|
const material = await this.loadMaterial(key);
|
|
8976
9056
|
const image = material.map.image;
|
|
8977
|
-
const
|
|
8978
|
-
const [width, height] = layer.size ?? [
|
|
8979
|
-
const geometry =
|
|
9057
|
+
const scaling = layer.crop ? void 0 : (await ModelTextures.getMeta(key))?.gui?.scaling;
|
|
9058
|
+
const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
|
|
9059
|
+
const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
|
|
8980
9060
|
this.geometries.add(geometry);
|
|
8981
|
-
const
|
|
8982
|
-
for (let i = 0; i < uv.count; i++) {
|
|
8983
|
-
uv.setXY(
|
|
8984
|
-
i,
|
|
8985
|
-
(cropX + uv.getX(i) * cropWidth) / image.width,
|
|
8986
|
-
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
8987
|
-
);
|
|
8988
|
-
}
|
|
8989
|
-
const mesh = new import_three24.Mesh(geometry, material);
|
|
9061
|
+
const mesh = new import_three25.Mesh(geometry, material);
|
|
8990
9062
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
8991
9063
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
8992
9064
|
mesh.renderOrder = index;
|
|
8993
9065
|
this.add(mesh);
|
|
8994
|
-
this.bounds.expandByPoint(new
|
|
8995
|
-
this.bounds.expandByPoint(new
|
|
9066
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
9067
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
|
|
8996
9068
|
depth += 0.01;
|
|
8997
9069
|
}
|
|
8998
9070
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -9067,7 +9139,7 @@ function isGuiObject(obj) {
|
|
|
9067
9139
|
init_image();
|
|
9068
9140
|
|
|
9069
9141
|
// src/inspector/SceneInspector.ts
|
|
9070
|
-
var
|
|
9142
|
+
var import_three26 = require("three");
|
|
9071
9143
|
init_SceneObject();
|
|
9072
9144
|
init_util();
|
|
9073
9145
|
init_log();
|
|
@@ -9077,11 +9149,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
9077
9149
|
var SceneInspector = class {
|
|
9078
9150
|
constructor(renderer) {
|
|
9079
9151
|
this.renderer = renderer;
|
|
9080
|
-
this.mouse = new
|
|
9152
|
+
this.mouse = new import_three26.Vector2();
|
|
9081
9153
|
this.listeners = new AbortController();
|
|
9082
9154
|
this.objectInfoContainer = document.createElement("div");
|
|
9083
9155
|
this.objectControlsContainer = document.createElement("div");
|
|
9084
|
-
this.raycaster = new
|
|
9156
|
+
this.raycaster = new import_three26.Raycaster();
|
|
9085
9157
|
this.init();
|
|
9086
9158
|
}
|
|
9087
9159
|
init() {
|
|
@@ -9484,7 +9556,7 @@ init_ModelMerger();
|
|
|
9484
9556
|
init_SpecialItems();
|
|
9485
9557
|
|
|
9486
9558
|
// src/model/block/BlockStateResolver.ts
|
|
9487
|
-
var
|
|
9559
|
+
var import_three28 = require("three");
|
|
9488
9560
|
init_BlockStates();
|
|
9489
9561
|
init_MineRenderError();
|
|
9490
9562
|
init_util();
|
|
@@ -9562,7 +9634,7 @@ var BlockStateResolver = class {
|
|
|
9562
9634
|
return variants[variants.length - 1];
|
|
9563
9635
|
}
|
|
9564
9636
|
static rotation(variant) {
|
|
9565
|
-
const rotation = new
|
|
9637
|
+
const rotation = new import_three28.Euler();
|
|
9566
9638
|
if (typeof variant.x !== "undefined") {
|
|
9567
9639
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
9568
9640
|
}
|
|
@@ -9654,7 +9726,7 @@ init_SceneObject();
|
|
|
9654
9726
|
init_ModelObject();
|
|
9655
9727
|
init_Models();
|
|
9656
9728
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9657
|
-
var
|
|
9729
|
+
var import_three31 = require("three");
|
|
9658
9730
|
init_MineRenderError();
|
|
9659
9731
|
init_InstanceReference();
|
|
9660
9732
|
init_AssetKey();
|
|
@@ -9676,7 +9748,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9676
9748
|
this._models = [];
|
|
9677
9749
|
this._cullMask = 0;
|
|
9678
9750
|
this._entities = [];
|
|
9679
|
-
this._entityPlacement = new
|
|
9751
|
+
this._entityPlacement = new import_three31.Matrix4();
|
|
9680
9752
|
this._entityGeneration = 0;
|
|
9681
9753
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9682
9754
|
}
|
|
@@ -9772,7 +9844,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9772
9844
|
return true;
|
|
9773
9845
|
}
|
|
9774
9846
|
placeEntities() {
|
|
9775
|
-
const matrix = new
|
|
9847
|
+
const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9776
9848
|
for (const entity of this._entities) {
|
|
9777
9849
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9778
9850
|
}
|
|
@@ -9794,12 +9866,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9794
9866
|
getModelCullMask(model, worldMask) {
|
|
9795
9867
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9796
9868
|
if (object.options.displayPosition) return 0;
|
|
9797
|
-
const position = new
|
|
9798
|
-
const rotation = new
|
|
9799
|
-
const scale = new
|
|
9869
|
+
const position = new import_three31.Vector3();
|
|
9870
|
+
const rotation = new import_three31.Quaternion();
|
|
9871
|
+
const scale = new import_three31.Vector3();
|
|
9800
9872
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9801
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9802
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9873
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9874
|
+
return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
|
|
9803
9875
|
}
|
|
9804
9876
|
async setCullMask(worldMask) {
|
|
9805
9877
|
worldMask &= 63;
|
|
@@ -9865,7 +9937,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9865
9937
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9866
9938
|
);
|
|
9867
9939
|
const previous = this._fluidModel;
|
|
9868
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9940
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
|
|
9869
9941
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9870
9942
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9871
9943
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -10007,7 +10079,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10007
10079
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
10008
10080
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
10009
10081
|
}
|
|
10010
|
-
getMatrixAt(index, matrix = new
|
|
10082
|
+
getMatrixAt(index, matrix = new import_three31.Matrix4()) {
|
|
10011
10083
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
10012
10084
|
const child = this._models[0];
|
|
10013
10085
|
if (child && isModelObject(child)) {
|
|
@@ -11883,7 +11955,7 @@ init_ModelObject();
|
|
|
11883
11955
|
init_nbt();
|
|
11884
11956
|
|
|
11885
11957
|
// src/renderer/MineRenderScene.ts
|
|
11886
|
-
var
|
|
11958
|
+
var import_three33 = require("three");
|
|
11887
11959
|
init_SceneObject();
|
|
11888
11960
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
11889
11961
|
init_ModelObject();
|
|
@@ -12616,7 +12688,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12616
12688
|
init_util();
|
|
12617
12689
|
|
|
12618
12690
|
// src/skin/SkinTextures.ts
|
|
12619
|
-
var
|
|
12691
|
+
var import_three32 = require("three");
|
|
12620
12692
|
init_Caching();
|
|
12621
12693
|
init_CacheKey();
|
|
12622
12694
|
init_MineRenderError();
|
|
@@ -12700,11 +12772,11 @@ var SkinTextures = class {
|
|
|
12700
12772
|
});
|
|
12701
12773
|
}
|
|
12702
12774
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12703
|
-
const texture = Textures.initTextureProps(new
|
|
12704
|
-
texture.colorSpace =
|
|
12775
|
+
const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
|
|
12776
|
+
texture.colorSpace = import_three32.SRGBColorSpace;
|
|
12705
12777
|
texture.flipY = true;
|
|
12706
12778
|
texture.needsUpdate = true;
|
|
12707
|
-
return new
|
|
12779
|
+
return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12708
12780
|
}
|
|
12709
12781
|
static isSlim(image, scale) {
|
|
12710
12782
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -12934,7 +13006,7 @@ var SkinObject = class extends SceneObject {
|
|
|
12934
13006
|
// src/renderer/MineRenderScene.ts
|
|
12935
13007
|
init_EntityObject();
|
|
12936
13008
|
init_ItemTints();
|
|
12937
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
13009
|
+
var _MineRenderScene = class _MineRenderScene extends import_three33.Scene {
|
|
12938
13010
|
constructor(options) {
|
|
12939
13011
|
super();
|
|
12940
13012
|
this.isMineRenderScene = true;
|
|
@@ -13063,7 +13135,7 @@ function isMineRenderScene(obj) {
|
|
|
13063
13135
|
}
|
|
13064
13136
|
|
|
13065
13137
|
// src/renderer/Renderer.ts
|
|
13066
|
-
var
|
|
13138
|
+
var import_three35 = require("three");
|
|
13067
13139
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
13068
13140
|
var import_stats = __toESM(require("stats.js"));
|
|
13069
13141
|
var import_postprocessing = require("postprocessing");
|
|
@@ -13072,11 +13144,11 @@ init_Model();
|
|
|
13072
13144
|
init_three();
|
|
13073
13145
|
|
|
13074
13146
|
// src/three/OrbitControls.js
|
|
13075
|
-
var
|
|
13147
|
+
var import_three34 = require("three");
|
|
13076
13148
|
var _changeEvent = { type: "change" };
|
|
13077
13149
|
var _startEvent = { type: "start" };
|
|
13078
13150
|
var _endEvent = { type: "end" };
|
|
13079
|
-
var OrbitControls = class extends
|
|
13151
|
+
var OrbitControls = class extends import_three34.EventDispatcher {
|
|
13080
13152
|
constructor(object, domElement) {
|
|
13081
13153
|
super();
|
|
13082
13154
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -13085,7 +13157,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13085
13157
|
this.domElement = domElement;
|
|
13086
13158
|
this.domElement.style.touchAction = "none";
|
|
13087
13159
|
this.enabled = true;
|
|
13088
|
-
this.target = new
|
|
13160
|
+
this.target = new import_three34.Vector3();
|
|
13089
13161
|
this.minDistance = 0;
|
|
13090
13162
|
this.maxDistance = Infinity;
|
|
13091
13163
|
this.minZoom = 0;
|
|
@@ -13107,8 +13179,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13107
13179
|
this.autoRotate = false;
|
|
13108
13180
|
this.autoRotateSpeed = 2;
|
|
13109
13181
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
13110
|
-
this.mouseButtons = { LEFT:
|
|
13111
|
-
this.touches = { ONE:
|
|
13182
|
+
this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
|
|
13183
|
+
this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
|
|
13112
13184
|
this.target0 = this.target.clone();
|
|
13113
13185
|
this.position0 = this.object.position.clone();
|
|
13114
13186
|
this.zoom0 = this.object.zoom;
|
|
@@ -13137,11 +13209,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13137
13209
|
state = STATE.NONE;
|
|
13138
13210
|
};
|
|
13139
13211
|
this.update = function() {
|
|
13140
|
-
const offset = new
|
|
13141
|
-
const quat = new
|
|
13212
|
+
const offset = new import_three34.Vector3();
|
|
13213
|
+
const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
|
|
13142
13214
|
const quatInverse = quat.clone().invert();
|
|
13143
|
-
const lastPosition = new
|
|
13144
|
-
const lastQuaternion = new
|
|
13215
|
+
const lastPosition = new import_three34.Vector3();
|
|
13216
|
+
const lastQuaternion = new import_three34.Quaternion();
|
|
13145
13217
|
const twoPI = 2 * Math.PI;
|
|
13146
13218
|
return function update() {
|
|
13147
13219
|
const position = scope.object.position;
|
|
@@ -13227,20 +13299,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13227
13299
|
};
|
|
13228
13300
|
let state = STATE.NONE;
|
|
13229
13301
|
const EPS = 1e-6;
|
|
13230
|
-
const spherical = new
|
|
13231
|
-
const sphericalDelta = new
|
|
13302
|
+
const spherical = new import_three34.Spherical();
|
|
13303
|
+
const sphericalDelta = new import_three34.Spherical();
|
|
13232
13304
|
let scale = 1;
|
|
13233
|
-
const panOffset = new
|
|
13305
|
+
const panOffset = new import_three34.Vector3();
|
|
13234
13306
|
let zoomChanged = false;
|
|
13235
|
-
const rotateStart = new
|
|
13236
|
-
const rotateEnd = new
|
|
13237
|
-
const rotateDelta = new
|
|
13238
|
-
const panStart = new
|
|
13239
|
-
const panEnd = new
|
|
13240
|
-
const panDelta = new
|
|
13241
|
-
const dollyStart = new
|
|
13242
|
-
const dollyEnd = new
|
|
13243
|
-
const dollyDelta = new
|
|
13307
|
+
const rotateStart = new import_three34.Vector2();
|
|
13308
|
+
const rotateEnd = new import_three34.Vector2();
|
|
13309
|
+
const rotateDelta = new import_three34.Vector2();
|
|
13310
|
+
const panStart = new import_three34.Vector2();
|
|
13311
|
+
const panEnd = new import_three34.Vector2();
|
|
13312
|
+
const panDelta = new import_three34.Vector2();
|
|
13313
|
+
const dollyStart = new import_three34.Vector2();
|
|
13314
|
+
const dollyEnd = new import_three34.Vector2();
|
|
13315
|
+
const dollyDelta = new import_three34.Vector2();
|
|
13244
13316
|
const pointers = [];
|
|
13245
13317
|
const pointerPositions = {};
|
|
13246
13318
|
function getAutoRotationAngle() {
|
|
@@ -13256,7 +13328,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13256
13328
|
sphericalDelta.phi -= angle;
|
|
13257
13329
|
}
|
|
13258
13330
|
const panLeft = function() {
|
|
13259
|
-
const v = new
|
|
13331
|
+
const v = new import_three34.Vector3();
|
|
13260
13332
|
return function panLeft2(distance, objectMatrix) {
|
|
13261
13333
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
13262
13334
|
v.multiplyScalar(-distance);
|
|
@@ -13264,7 +13336,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13264
13336
|
};
|
|
13265
13337
|
}();
|
|
13266
13338
|
const panUp = function() {
|
|
13267
|
-
const v = new
|
|
13339
|
+
const v = new import_three34.Vector3();
|
|
13268
13340
|
return function panUp2(distance, objectMatrix) {
|
|
13269
13341
|
if (scope.screenSpacePanning === true) {
|
|
13270
13342
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -13277,7 +13349,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13277
13349
|
};
|
|
13278
13350
|
}();
|
|
13279
13351
|
const pan = function() {
|
|
13280
|
-
const offset = new
|
|
13352
|
+
const offset = new import_three34.Vector3();
|
|
13281
13353
|
return function pan2(deltaX, deltaY) {
|
|
13282
13354
|
const element = scope.domElement;
|
|
13283
13355
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13526,12 +13598,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13526
13598
|
mouseAction = -1;
|
|
13527
13599
|
}
|
|
13528
13600
|
switch (mouseAction) {
|
|
13529
|
-
case
|
|
13601
|
+
case import_three34.MOUSE.DOLLY:
|
|
13530
13602
|
if (scope.enableZoom === false) return;
|
|
13531
13603
|
handleMouseDownDolly(event);
|
|
13532
13604
|
state = STATE.DOLLY;
|
|
13533
13605
|
break;
|
|
13534
|
-
case
|
|
13606
|
+
case import_three34.MOUSE.ROTATE:
|
|
13535
13607
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13536
13608
|
if (scope.enablePan === false) return;
|
|
13537
13609
|
handleMouseDownPan(event);
|
|
@@ -13542,7 +13614,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13542
13614
|
state = STATE.ROTATE;
|
|
13543
13615
|
}
|
|
13544
13616
|
break;
|
|
13545
|
-
case
|
|
13617
|
+
case import_three34.MOUSE.PAN:
|
|
13546
13618
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13547
13619
|
if (scope.enableRotate === false) return;
|
|
13548
13620
|
handleMouseDownRotate(event);
|
|
@@ -13598,12 +13670,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13598
13670
|
switch (pointers.length) {
|
|
13599
13671
|
case 1:
|
|
13600
13672
|
switch (scope.touches.ONE) {
|
|
13601
|
-
case
|
|
13673
|
+
case import_three34.TOUCH.ROTATE:
|
|
13602
13674
|
if (scope.enableRotate === false) return;
|
|
13603
13675
|
handleTouchStartRotate();
|
|
13604
13676
|
state = STATE.TOUCH_ROTATE;
|
|
13605
13677
|
break;
|
|
13606
|
-
case
|
|
13678
|
+
case import_three34.TOUCH.PAN:
|
|
13607
13679
|
if (scope.enablePan === false) return;
|
|
13608
13680
|
handleTouchStartPan();
|
|
13609
13681
|
state = STATE.TOUCH_PAN;
|
|
@@ -13614,12 +13686,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13614
13686
|
break;
|
|
13615
13687
|
case 2:
|
|
13616
13688
|
switch (scope.touches.TWO) {
|
|
13617
|
-
case
|
|
13689
|
+
case import_three34.TOUCH.DOLLY_PAN:
|
|
13618
13690
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13619
13691
|
handleTouchStartDollyPan();
|
|
13620
13692
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13621
13693
|
break;
|
|
13622
|
-
case
|
|
13694
|
+
case import_three34.TOUCH.DOLLY_ROTATE:
|
|
13623
13695
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13624
13696
|
handleTouchStartDollyRotate();
|
|
13625
13697
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13686,7 +13758,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13686
13758
|
function trackPointer(event) {
|
|
13687
13759
|
let position = pointerPositions[event.pointerId];
|
|
13688
13760
|
if (position === void 0) {
|
|
13689
|
-
position = new
|
|
13761
|
+
position = new import_three34.Vector2();
|
|
13690
13762
|
pointerPositions[event.pointerId] = position;
|
|
13691
13763
|
}
|
|
13692
13764
|
position.set(event.pageX, event.pageY);
|
|
@@ -13706,10 +13778,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13706
13778
|
constructor(object, domElement) {
|
|
13707
13779
|
super(object, domElement);
|
|
13708
13780
|
this.screenSpacePanning = false;
|
|
13709
|
-
this.mouseButtons.LEFT =
|
|
13710
|
-
this.mouseButtons.RIGHT =
|
|
13711
|
-
this.touches.ONE =
|
|
13712
|
-
this.touches.TWO =
|
|
13781
|
+
this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
|
|
13782
|
+
this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
|
|
13783
|
+
this.touches.ONE = import_three34.TOUCH.PAN;
|
|
13784
|
+
this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
|
|
13713
13785
|
}
|
|
13714
13786
|
};
|
|
13715
13787
|
|
|
@@ -13760,14 +13832,14 @@ var _Renderer = class _Renderer {
|
|
|
13760
13832
|
switch (this.options.camera.type) {
|
|
13761
13833
|
case "perspective":
|
|
13762
13834
|
default:
|
|
13763
|
-
return new
|
|
13835
|
+
return new import_three35.PerspectiveCamera(
|
|
13764
13836
|
this.options.camera.perspective.fov,
|
|
13765
13837
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13766
13838
|
this.options.camera.near,
|
|
13767
13839
|
this.options.camera.far
|
|
13768
13840
|
);
|
|
13769
13841
|
case "orthographic":
|
|
13770
|
-
return new
|
|
13842
|
+
return new import_three35.OrthographicCamera(
|
|
13771
13843
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13772
13844
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13773
13845
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13778,7 +13850,7 @@ var _Renderer = class _Renderer {
|
|
|
13778
13850
|
}
|
|
13779
13851
|
}
|
|
13780
13852
|
createRenderer() {
|
|
13781
|
-
const renderer = new
|
|
13853
|
+
const renderer = new import_three35.WebGLRenderer({
|
|
13782
13854
|
antialias: this.options.render.antialias,
|
|
13783
13855
|
alpha: true,
|
|
13784
13856
|
powerPreference: "high-performance",
|
|
@@ -13786,8 +13858,8 @@ var _Renderer = class _Renderer {
|
|
|
13786
13858
|
});
|
|
13787
13859
|
renderer.setClearColor(0, 0);
|
|
13788
13860
|
renderer.shadowMap.enabled = true;
|
|
13789
|
-
renderer.shadowMap.type =
|
|
13790
|
-
renderer.outputColorSpace =
|
|
13861
|
+
renderer.shadowMap.type = import_three35.PCFShadowMap;
|
|
13862
|
+
renderer.outputColorSpace = import_three35.SRGBColorSpace;
|
|
13791
13863
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13792
13864
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13793
13865
|
return renderer;
|
|
@@ -13822,20 +13894,20 @@ var _Renderer = class _Renderer {
|
|
|
13822
13894
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13823
13895
|
}
|
|
13824
13896
|
if (this.options.debug.grid) {
|
|
13825
|
-
const gridHelper = new
|
|
13897
|
+
const gridHelper = new import_three35.GridHelper(128, 16);
|
|
13826
13898
|
this._debugHelpers.push(gridHelper);
|
|
13827
13899
|
this.scene.add(gridHelper);
|
|
13828
|
-
const gridHelper2 = new
|
|
13900
|
+
const gridHelper2 = new import_three35.GridHelper(128, 16);
|
|
13829
13901
|
this._debugHelpers.push(gridHelper2);
|
|
13830
13902
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13831
13903
|
this.scene.add(gridHelper2);
|
|
13832
|
-
const gridHelper3 = new
|
|
13904
|
+
const gridHelper3 = new import_three35.GridHelper(128, 16);
|
|
13833
13905
|
this._debugHelpers.push(gridHelper3);
|
|
13834
13906
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13835
13907
|
this.scene.add(gridHelper3);
|
|
13836
13908
|
}
|
|
13837
13909
|
if (this.options.debug.axes) {
|
|
13838
|
-
const axesHelper = new
|
|
13910
|
+
const axesHelper = new import_three35.AxesHelper(64);
|
|
13839
13911
|
this._debugHelpers.push(axesHelper);
|
|
13840
13912
|
this.scene.add(axesHelper);
|
|
13841
13913
|
}
|
|
@@ -14094,8 +14166,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
14094
14166
|
top: void 0,
|
|
14095
14167
|
bottom: void 0
|
|
14096
14168
|
},
|
|
14097
|
-
position: new
|
|
14098
|
-
lookingAt: new
|
|
14169
|
+
position: new import_three35.Vector3(50, 50, 50),
|
|
14170
|
+
lookingAt: new import_three35.Vector3(0, 0, 0)
|
|
14099
14171
|
},
|
|
14100
14172
|
render: {
|
|
14101
14173
|
fpsLimit: 60,
|
|
@@ -14560,12 +14632,12 @@ var AnvilParser = class {
|
|
|
14560
14632
|
};
|
|
14561
14633
|
|
|
14562
14634
|
// src/world/Chunk.ts
|
|
14563
|
-
var
|
|
14635
|
+
var import_three40 = require("three");
|
|
14564
14636
|
init_BlockStates();
|
|
14565
14637
|
init_AssetKey();
|
|
14566
14638
|
|
|
14567
14639
|
// src/world/MineRenderWorld.ts
|
|
14568
|
-
var
|
|
14640
|
+
var import_three38 = require("three");
|
|
14569
14641
|
init_Model();
|
|
14570
14642
|
init_BatchedExecutor();
|
|
14571
14643
|
init_AssetKey();
|
|
@@ -14573,7 +14645,7 @@ init_BlockStates();
|
|
|
14573
14645
|
init_CubeFace();
|
|
14574
14646
|
|
|
14575
14647
|
// src/world/SectionModels.ts
|
|
14576
|
-
var
|
|
14648
|
+
var import_three37 = require("three");
|
|
14577
14649
|
init_AssetKey();
|
|
14578
14650
|
init_Models();
|
|
14579
14651
|
init_CubeFace();
|
|
@@ -14639,12 +14711,12 @@ var SectionModels = class {
|
|
|
14639
14711
|
});
|
|
14640
14712
|
await object.init();
|
|
14641
14713
|
const geometry = object.children[0].geometry;
|
|
14642
|
-
geometry.applyMatrix4(new
|
|
14714
|
+
geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
|
|
14643
14715
|
object.clear();
|
|
14644
14716
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14645
14717
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14646
14718
|
if (local < 0) return 0;
|
|
14647
|
-
const normal = new
|
|
14719
|
+
const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14648
14720
|
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);
|
|
14649
14721
|
return 1 << world;
|
|
14650
14722
|
});
|
|
@@ -14674,20 +14746,20 @@ var MineRenderWorld = class {
|
|
|
14674
14746
|
}
|
|
14675
14747
|
getBlockAt(posOrX, y, z) {
|
|
14676
14748
|
if (typeof posOrX == "number") {
|
|
14677
|
-
return this.getBlockAt(new
|
|
14749
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
14678
14750
|
}
|
|
14679
14751
|
if (isTripleArray(posOrX)) {
|
|
14680
|
-
return this.getBlockAt(new
|
|
14752
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14681
14753
|
}
|
|
14682
14754
|
this.validatePosBounds(posOrX);
|
|
14683
14755
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14684
14756
|
}
|
|
14685
14757
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14686
14758
|
if (typeof posOrX == "number") {
|
|
14687
|
-
return this.setBlockAt(new
|
|
14759
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
14688
14760
|
}
|
|
14689
14761
|
if (isTripleArray(posOrX)) {
|
|
14690
|
-
return this.setBlockAt(new
|
|
14762
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14691
14763
|
}
|
|
14692
14764
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14693
14765
|
}
|
|
@@ -14698,10 +14770,10 @@ var MineRenderWorld = class {
|
|
|
14698
14770
|
}
|
|
14699
14771
|
async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
|
|
14700
14772
|
if (typeof posOrX === "number") {
|
|
14701
|
-
return this.setBlockVisibleAt(new
|
|
14773
|
+
return this.setBlockVisibleAt(new import_three38.Vector3(posOrX, yOrVisible, z), visible);
|
|
14702
14774
|
}
|
|
14703
14775
|
if (isTripleArray(posOrX)) {
|
|
14704
|
-
return this.setBlockVisibleAt(new
|
|
14776
|
+
return this.setBlockVisibleAt(new import_three38.Vector3(...posOrX), yOrVisible);
|
|
14705
14777
|
}
|
|
14706
14778
|
this.validatePosBounds(posOrX);
|
|
14707
14779
|
await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
|
|
@@ -14718,7 +14790,7 @@ var MineRenderWorld = class {
|
|
|
14718
14790
|
const collect = async (positions2) => {
|
|
14719
14791
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14720
14792
|
};
|
|
14721
|
-
const place = (block) => this.placeBlock(new
|
|
14793
|
+
const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
|
|
14722
14794
|
const keys = /* @__PURE__ */ new Map();
|
|
14723
14795
|
for (const block of multiblock.blocks) {
|
|
14724
14796
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14796,13 +14868,13 @@ var MineRenderWorld = class {
|
|
|
14796
14868
|
for (const pos of positions) {
|
|
14797
14869
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14798
14870
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14799
|
-
const neighbor = pos.clone().add(new
|
|
14871
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14800
14872
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14801
14873
|
}
|
|
14802
14874
|
for (let y = -1; y <= 1; y++) {
|
|
14803
14875
|
for (let z = -1; z <= 1; z++) {
|
|
14804
14876
|
for (let x = -1; x <= 1; x++) {
|
|
14805
|
-
const neighbor = pos.clone().add(new
|
|
14877
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14806
14878
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14807
14879
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14808
14880
|
}
|
|
@@ -14826,7 +14898,7 @@ var MineRenderWorld = class {
|
|
|
14826
14898
|
}
|
|
14827
14899
|
if (block.object?.fluidKind) {
|
|
14828
14900
|
await block.object.updateFluid((x, y, z) => {
|
|
14829
|
-
const neighbor = pos.clone().add(new
|
|
14901
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14830
14902
|
const section = this.getChunkAt(neighbor);
|
|
14831
14903
|
const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
14832
14904
|
return {
|
|
@@ -14838,7 +14910,7 @@ var MineRenderWorld = class {
|
|
|
14838
14910
|
}
|
|
14839
14911
|
let mask = 0;
|
|
14840
14912
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14841
|
-
const neighbor = pos.clone().add(new
|
|
14913
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14842
14914
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14843
14915
|
mask |= 1 << face;
|
|
14844
14916
|
}
|
|
@@ -14872,14 +14944,14 @@ var MineRenderWorld = class {
|
|
|
14872
14944
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14873
14945
|
}
|
|
14874
14946
|
static worldToScenePosition(pos) {
|
|
14875
|
-
return new
|
|
14947
|
+
return new import_three38.Vector3(
|
|
14876
14948
|
pos.x * 16,
|
|
14877
14949
|
pos.y * 16,
|
|
14878
14950
|
pos.z * 16
|
|
14879
14951
|
);
|
|
14880
14952
|
}
|
|
14881
14953
|
static sceneToWorldPosition(pos) {
|
|
14882
|
-
return new
|
|
14954
|
+
return new import_three38.Vector3(
|
|
14883
14955
|
pos.x / 16,
|
|
14884
14956
|
pos.y / 16,
|
|
14885
14957
|
pos.z / 16
|
|
@@ -14902,10 +14974,10 @@ var MineRenderWorld = class {
|
|
|
14902
14974
|
init_Model();
|
|
14903
14975
|
|
|
14904
14976
|
// src/world/SectionMesh.ts
|
|
14905
|
-
var
|
|
14977
|
+
var import_three39 = require("three");
|
|
14906
14978
|
init_CanvasCompat();
|
|
14907
14979
|
init_Materials();
|
|
14908
|
-
var SectionMesh = class _SectionMesh extends
|
|
14980
|
+
var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
14909
14981
|
constructor() {
|
|
14910
14982
|
super(...arguments);
|
|
14911
14983
|
this.ownedMeshes = [];
|
|
@@ -14978,18 +15050,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
|
|
|
14978
15050
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
14979
15051
|
}
|
|
14980
15052
|
}
|
|
14981
|
-
const geometry = new
|
|
14982
|
-
geometry.setAttribute("position", new
|
|
14983
|
-
geometry.setAttribute("normal", new
|
|
14984
|
-
geometry.setAttribute("uv", new
|
|
14985
|
-
geometry.setAttribute("color", new
|
|
15053
|
+
const geometry = new import_three39.BufferGeometry();
|
|
15054
|
+
geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
|
|
15055
|
+
geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
|
|
15056
|
+
geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
|
|
15057
|
+
geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
|
|
14986
15058
|
geometry.setIndex(indices);
|
|
14987
15059
|
geometry.computeBoundingBox();
|
|
14988
15060
|
geometry.computeBoundingSphere();
|
|
14989
15061
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
14990
15062
|
material.vertexColors = true;
|
|
14991
15063
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
14992
|
-
const mesh = new
|
|
15064
|
+
const mesh = new import_three39.Mesh(geometry, material);
|
|
14993
15065
|
section.add(mesh);
|
|
14994
15066
|
section.ownedMeshes.push({ mesh, texture });
|
|
14995
15067
|
}
|
|
@@ -15025,10 +15097,10 @@ var Chunk = class _Chunk {
|
|
|
15025
15097
|
}
|
|
15026
15098
|
getBlockAt(posOrX, y, z) {
|
|
15027
15099
|
if (typeof posOrX == "number") {
|
|
15028
|
-
return this.getBlockAt(new
|
|
15100
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
|
|
15029
15101
|
}
|
|
15030
15102
|
if (isTripleArray(posOrX)) {
|
|
15031
|
-
return this.getBlockAt(new
|
|
15103
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
15032
15104
|
}
|
|
15033
15105
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
15034
15106
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -15036,10 +15108,10 @@ var Chunk = class _Chunk {
|
|
|
15036
15108
|
}
|
|
15037
15109
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
15038
15110
|
if (typeof posOrX == "number") {
|
|
15039
|
-
return this.setBlockAt(new
|
|
15111
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
|
|
15040
15112
|
}
|
|
15041
15113
|
if (isTripleArray(posOrX)) {
|
|
15042
|
-
return this.setBlockAt(new
|
|
15114
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
15043
15115
|
}
|
|
15044
15116
|
const worldPos = posOrX;
|
|
15045
15117
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -15151,7 +15223,7 @@ var Chunk = class _Chunk {
|
|
|
15151
15223
|
}
|
|
15152
15224
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
15153
15225
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
15154
|
-
new
|
|
15226
|
+
new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
15155
15227
|
));
|
|
15156
15228
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
15157
15229
|
this.sectionBlocks.clear();
|
|
@@ -15176,14 +15248,14 @@ var Chunk = class _Chunk {
|
|
|
15176
15248
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
15177
15249
|
}
|
|
15178
15250
|
worldPosToChunkPos(pos) {
|
|
15179
|
-
return new
|
|
15251
|
+
return new import_three40.Vector3(
|
|
15180
15252
|
pos.x - this.x * 16,
|
|
15181
15253
|
pos.y - this.y * 16,
|
|
15182
15254
|
pos.z - this.z * 16
|
|
15183
15255
|
);
|
|
15184
15256
|
}
|
|
15185
15257
|
chunkPosToWorldPos(pos) {
|
|
15186
|
-
return new
|
|
15258
|
+
return new import_three40.Vector3(
|
|
15187
15259
|
this.x * 16 + pos.x,
|
|
15188
15260
|
this.y * 16 + pos.y,
|
|
15189
15261
|
this.z * 16 + pos.z
|