minerender 2.1.0-alpha.32 → 2.1.0-alpha.33
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 +18 -5
- package/dist/browser/index.d.ts +18 -5
- package/dist/browser/index.js +180 -149
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +72 -41
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +72 -41
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +18 -5
- package/dist/node/index.d.ts +18 -5
- package/dist/node/index.js +180 -149
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +72 -41
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -2922,26 +2922,40 @@ var Entities = class {
|
|
|
2922
2922
|
};
|
|
2923
2923
|
return collect("");
|
|
2924
2924
|
}
|
|
2925
|
-
static async
|
|
2925
|
+
static async getModelFile(modelKey) {
|
|
2926
2926
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2927
2927
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2928
|
-
|
|
2928
|
+
return Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
2929
|
+
}
|
|
2930
|
+
static async getLayerList(modelKey) {
|
|
2931
|
+
return Object.keys((await this.getModelFile(modelKey))?.layers ?? {});
|
|
2932
|
+
}
|
|
2933
|
+
static async getEntity(modelKey, textureKey, options) {
|
|
2934
|
+
const model = await this.getModelFile(modelKey);
|
|
2929
2935
|
if (!model) return void 0;
|
|
2930
|
-
const
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2936
|
+
const names = [...new Set(options?.layers ?? [options?.layer ?? "main"])];
|
|
2937
|
+
if (names.length === 0) throw new MineRenderError(`Entity ${model.id} requires at least one layer`);
|
|
2938
|
+
const selected = names.map((name) => {
|
|
2939
|
+
const layer = model.layers[name];
|
|
2940
|
+
if (!layer) {
|
|
2941
|
+
throw new MineRenderError(`Entity ${model.id} has no layer "${name}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2942
|
+
}
|
|
2943
|
+
return { name, layer };
|
|
2944
|
+
});
|
|
2945
|
+
const layers = Object.fromEntries(await Promise.all(selected.map(async ({ name, layer }, index) => {
|
|
2946
|
+
const override = options?.textures?.[name] ?? (index === 0 ? textureKey : void 0);
|
|
2947
|
+
let texture;
|
|
2948
|
+
if (override) {
|
|
2949
|
+
const path = isAssetKey(override) ? override.getFullPath() : override.path;
|
|
2950
|
+
texture = isAssetKey(override) && override.assetType === "textures" && path.startsWith("entity/") ? override : new AssetKey(override.namespace, path, "textures", "entity", "assets", ".png", isAssetKey(override) ? override.root : void 0);
|
|
2951
|
+
} else if (layer.textureLocation !== void 0) {
|
|
2952
|
+
texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
2953
|
+
} else {
|
|
2954
|
+
texture = await this.resolveTexture(modelKey);
|
|
2955
|
+
}
|
|
2956
|
+
return [name, { key: override ?? modelKey, texture, layer }];
|
|
2957
|
+
})));
|
|
2958
|
+
return { ...layers[names[0]], id: model.id, layers };
|
|
2945
2959
|
}
|
|
2946
2960
|
static async resolveTexture(modelKey) {
|
|
2947
2961
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
@@ -3410,9 +3424,21 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
3410
3424
|
dispose() {
|
|
3411
3425
|
super.dispose();
|
|
3412
3426
|
}
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3427
|
+
getLayerGroup(name) {
|
|
3428
|
+
return super.getGroupByName(`layer:${name}`);
|
|
3429
|
+
}
|
|
3430
|
+
getGroupByName(name, layerName) {
|
|
3431
|
+
return layerName === void 0 ? super.getGroupByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`group:${name}`);
|
|
3432
|
+
}
|
|
3433
|
+
getMeshByName(name, layerName) {
|
|
3434
|
+
return layerName === void 0 ? super.getMeshByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`mesh:${name}`);
|
|
3435
|
+
}
|
|
3436
|
+
get entityLayers() {
|
|
3437
|
+
return this.entity.layers ?? { main: this.entity };
|
|
3438
|
+
}
|
|
3439
|
+
getTextureKey(layer) {
|
|
3440
|
+
if (layer.texture) return layer.texture;
|
|
3441
|
+
const key = layer.key;
|
|
3416
3442
|
return new AssetKey(
|
|
3417
3443
|
key.namespace,
|
|
3418
3444
|
isAssetKey(key) ? key.getFullPath() : key.path,
|
|
@@ -3422,18 +3448,22 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
3422
3448
|
".png"
|
|
3423
3449
|
);
|
|
3424
3450
|
}
|
|
3425
|
-
async loadTextures() {
|
|
3426
|
-
|
|
3451
|
+
async loadTextures(layer = this.entity) {
|
|
3452
|
+
return ModelTextures.get(this.getTextureKey(layer));
|
|
3427
3453
|
}
|
|
3428
3454
|
createMeshes(force = false) {
|
|
3429
3455
|
if (this.meshesCreated && !force) return;
|
|
3430
3456
|
const modelRoot = new import_three12.Object3D();
|
|
3431
3457
|
if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
|
|
3432
3458
|
this.add(modelRoot);
|
|
3433
|
-
|
|
3459
|
+
Object.entries(this.entityLayers).forEach(([name, layer], index) => {
|
|
3460
|
+
const group = this.createGroup(`layer:${name}`);
|
|
3461
|
+
modelRoot.add(group);
|
|
3462
|
+
this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index);
|
|
3463
|
+
});
|
|
3434
3464
|
this.meshesCreated = true;
|
|
3435
3465
|
}
|
|
3436
|
-
createPart(name, part, parent, textureSize, material) {
|
|
3466
|
+
createPart(name, part, parent, textureSize, material, renderOrder) {
|
|
3437
3467
|
const anchor = this.createGroup(name);
|
|
3438
3468
|
anchor.position.fromArray(part.pose.offset);
|
|
3439
3469
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
@@ -3453,30 +3483,31 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
3453
3483
|
).clone();
|
|
3454
3484
|
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
3455
3485
|
const mesh = this.createMesh(name, geometry, material);
|
|
3486
|
+
mesh.renderOrder = renderOrder;
|
|
3456
3487
|
anchor.add(mesh);
|
|
3457
3488
|
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
3458
3489
|
}
|
|
3459
3490
|
for (const [childName, child] of Object.entries(part.children)) {
|
|
3460
|
-
this.createPart(childName, child, anchor, size, material);
|
|
3491
|
+
this.createPart(childName, child, anchor, size, material, renderOrder);
|
|
3461
3492
|
}
|
|
3462
3493
|
}
|
|
3463
3494
|
async applyTextures() {
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
});
|
|
3495
|
+
await Promise.all(Object.entries(this.entityLayers).map(async ([name, layer]) => {
|
|
3496
|
+
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
3497
|
+
const keyStr = `entity:${assetKeyStr}`;
|
|
3498
|
+
let mat = Caching.materialCache.getIfPresent(keyStr);
|
|
3499
|
+
if (!mat) {
|
|
3500
|
+
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
3501
|
+
const imageData = await this.loadTextures(layer);
|
|
3502
|
+
if (!imageData) return;
|
|
3503
|
+
const canvas = imageData.data.canvas;
|
|
3504
|
+
const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
|
|
3505
|
+
mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
|
|
3506
|
+
}
|
|
3507
|
+
this.getLayerGroup(name)?.traverse((object) => {
|
|
3508
|
+
if (isMesh(object)) object.material = mat;
|
|
3509
|
+
});
|
|
3510
|
+
}));
|
|
3480
3511
|
this.notifyDirty();
|
|
3481
3512
|
}
|
|
3482
3513
|
};
|
|
@@ -3490,16 +3521,16 @@ var GuiObject = class extends SceneObject {
|
|
|
3490
3521
|
};
|
|
3491
3522
|
|
|
3492
3523
|
// src/inspector/SceneInspector.ts
|
|
3493
|
-
var
|
|
3524
|
+
var import_three14 = require("three");
|
|
3494
3525
|
var p7 = prefix("SceneInspector");
|
|
3495
3526
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3496
3527
|
var SceneInspector = class {
|
|
3497
3528
|
constructor(renderer) {
|
|
3498
3529
|
this.renderer = renderer;
|
|
3499
|
-
this.mouse = new
|
|
3530
|
+
this.mouse = new import_three14.Vector2();
|
|
3500
3531
|
this.objectInfoContainer = document.createElement("div");
|
|
3501
3532
|
this.objectControlsContainer = document.createElement("div");
|
|
3502
|
-
this.raycaster = new
|
|
3533
|
+
this.raycaster = new import_three14.Raycaster();
|
|
3503
3534
|
this.init();
|
|
3504
3535
|
}
|
|
3505
3536
|
init() {
|
|
@@ -4010,10 +4041,10 @@ var BlockTints = class {
|
|
|
4010
4041
|
};
|
|
4011
4042
|
|
|
4012
4043
|
// src/model/scene/ModelObject.ts
|
|
4013
|
-
var
|
|
4044
|
+
var import_three17 = require("three");
|
|
4014
4045
|
|
|
4015
4046
|
// src/three/BufferGeometryUtils.js
|
|
4016
|
-
var
|
|
4047
|
+
var import_three16 = require("three");
|
|
4017
4048
|
function computeTangents(geometry) {
|
|
4018
4049
|
geometry.computeTangents();
|
|
4019
4050
|
console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
|
|
@@ -4025,7 +4056,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4025
4056
|
const attributes = {};
|
|
4026
4057
|
const morphAttributes = {};
|
|
4027
4058
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4028
|
-
const mergedGeometry = new
|
|
4059
|
+
const mergedGeometry = new import_three16.BufferGeometry();
|
|
4029
4060
|
let offset = 0;
|
|
4030
4061
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4031
4062
|
const geometry = geometries[i];
|
|
@@ -4149,7 +4180,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4149
4180
|
array.set(attributes[i].array, offset);
|
|
4150
4181
|
offset += attributes[i].array.length;
|
|
4151
4182
|
}
|
|
4152
|
-
return new
|
|
4183
|
+
return new import_three16.BufferAttribute(array, itemSize, normalized);
|
|
4153
4184
|
}
|
|
4154
4185
|
function interleaveAttributes(attributes) {
|
|
4155
4186
|
let TypedArray;
|
|
@@ -4165,7 +4196,7 @@ function interleaveAttributes(attributes) {
|
|
|
4165
4196
|
arrayLength += attribute.array.length;
|
|
4166
4197
|
stride += attribute.itemSize;
|
|
4167
4198
|
}
|
|
4168
|
-
const interleavedBuffer = new
|
|
4199
|
+
const interleavedBuffer = new import_three16.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4169
4200
|
let offset = 0;
|
|
4170
4201
|
const res = [];
|
|
4171
4202
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4174,7 +4205,7 @@ function interleaveAttributes(attributes) {
|
|
|
4174
4205
|
const attribute = attributes[j];
|
|
4175
4206
|
const itemSize = attribute.itemSize;
|
|
4176
4207
|
const count = attribute.count;
|
|
4177
|
-
const iba = new
|
|
4208
|
+
const iba = new import_three16.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4178
4209
|
res.push(iba);
|
|
4179
4210
|
offset += itemSize;
|
|
4180
4211
|
for (let c = 0; c < count; c++) {
|
|
@@ -4258,13 +4289,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4258
4289
|
const name = attributeNames[i];
|
|
4259
4290
|
const oldAttribute = geometry.getAttribute(name);
|
|
4260
4291
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4261
|
-
const attribute = new
|
|
4292
|
+
const attribute = new import_three16.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4262
4293
|
result.setAttribute(name, attribute);
|
|
4263
4294
|
if (name in morphAttrsArrays) {
|
|
4264
4295
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4265
4296
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4266
4297
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4267
|
-
const morphAttribute = new
|
|
4298
|
+
const morphAttribute = new import_three16.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4268
4299
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4269
4300
|
}
|
|
4270
4301
|
}
|
|
@@ -4273,11 +4304,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4273
4304
|
return result;
|
|
4274
4305
|
}
|
|
4275
4306
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4276
|
-
if (drawMode ===
|
|
4307
|
+
if (drawMode === import_three16.TrianglesDrawMode) {
|
|
4277
4308
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4278
4309
|
return geometry;
|
|
4279
4310
|
}
|
|
4280
|
-
if (drawMode ===
|
|
4311
|
+
if (drawMode === import_three16.TriangleFanDrawMode || drawMode === import_three16.TriangleStripDrawMode) {
|
|
4281
4312
|
let index = geometry.getIndex();
|
|
4282
4313
|
if (index === null) {
|
|
4283
4314
|
const indices = [];
|
|
@@ -4295,7 +4326,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4295
4326
|
}
|
|
4296
4327
|
const numberOfTriangles = index.count - 2;
|
|
4297
4328
|
const newIndices = [];
|
|
4298
|
-
if (drawMode ===
|
|
4329
|
+
if (drawMode === import_three16.TriangleFanDrawMode) {
|
|
4299
4330
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4300
4331
|
newIndices.push(index.getX(0));
|
|
4301
4332
|
newIndices.push(index.getX(i));
|
|
@@ -4331,15 +4362,15 @@ function computeMorphedAttributes(object) {
|
|
|
4331
4362
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4332
4363
|
return null;
|
|
4333
4364
|
}
|
|
4334
|
-
const _vA = new
|
|
4335
|
-
const _vB = new
|
|
4336
|
-
const _vC = new
|
|
4337
|
-
const _tempA = new
|
|
4338
|
-
const _tempB = new
|
|
4339
|
-
const _tempC = new
|
|
4340
|
-
const _morphA = new
|
|
4341
|
-
const _morphB = new
|
|
4342
|
-
const _morphC = new
|
|
4365
|
+
const _vA = new import_three16.Vector3();
|
|
4366
|
+
const _vB = new import_three16.Vector3();
|
|
4367
|
+
const _vC = new import_three16.Vector3();
|
|
4368
|
+
const _tempA = new import_three16.Vector3();
|
|
4369
|
+
const _tempB = new import_three16.Vector3();
|
|
4370
|
+
const _tempC = new import_three16.Vector3();
|
|
4371
|
+
const _morphA = new import_three16.Vector3();
|
|
4372
|
+
const _morphB = new import_three16.Vector3();
|
|
4373
|
+
const _morphC = new import_three16.Vector3();
|
|
4343
4374
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4344
4375
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4345
4376
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4534,8 +4565,8 @@ function computeMorphedAttributes(object) {
|
|
|
4534
4565
|
}
|
|
4535
4566
|
}
|
|
4536
4567
|
}
|
|
4537
|
-
const morphedPositionAttribute = new
|
|
4538
|
-
const morphedNormalAttribute = new
|
|
4568
|
+
const morphedPositionAttribute = new import_three16.Float32BufferAttribute(modifiedPosition, 3);
|
|
4569
|
+
const morphedNormalAttribute = new import_three16.Float32BufferAttribute(modifiedNormal, 3);
|
|
4539
4570
|
return {
|
|
4540
4571
|
positionAttribute,
|
|
4541
4572
|
normalAttribute,
|
|
@@ -4586,7 +4617,7 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4586
4617
|
this.atlas.model.elements?.forEach((el) => {
|
|
4587
4618
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4588
4619
|
if (this.options.uvLockRotation) {
|
|
4589
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4620
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three17.Euler(...this.options.uvLockRotation));
|
|
4590
4621
|
}
|
|
4591
4622
|
if (this.options.tints) {
|
|
4592
4623
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4595,19 +4626,19 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4595
4626
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4596
4627
|
const tint = this.options.tints[tintIndex];
|
|
4597
4628
|
if (tint === void 0) continue;
|
|
4598
|
-
const color = new
|
|
4629
|
+
const color = new import_three17.Color(tint);
|
|
4599
4630
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4600
4631
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4601
4632
|
}
|
|
4602
4633
|
}
|
|
4603
|
-
elGeo.setAttribute("color", new
|
|
4634
|
+
elGeo.setAttribute("color", new import_three17.BufferAttribute(colors, 3));
|
|
4604
4635
|
}
|
|
4605
|
-
elGeo.applyMatrix4(new
|
|
4606
|
-
elGeo.applyMatrix4(new
|
|
4636
|
+
elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4637
|
+
elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4607
4638
|
if (el.rotation) {
|
|
4608
4639
|
applyElementRotation(el.rotation, elGeo);
|
|
4609
4640
|
}
|
|
4610
|
-
elGeo.applyMatrix4(new
|
|
4641
|
+
elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(-8, -8, -8));
|
|
4611
4642
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4612
4643
|
if (this.options.mergeMeshes) {
|
|
4613
4644
|
allGeos.push(elGeo);
|
|
@@ -4629,7 +4660,7 @@ var ModelObject = class _ModelObject extends SceneObject {
|
|
|
4629
4660
|
if (allGeos.length > 0) {
|
|
4630
4661
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4631
4662
|
} else {
|
|
4632
|
-
combinedGeo = new
|
|
4663
|
+
combinedGeo = new import_three17.BoxGeometry(16, 16, 16);
|
|
4633
4664
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4634
4665
|
}
|
|
4635
4666
|
combinedGeo.computeBoundingBox();
|
|
@@ -4682,7 +4713,7 @@ function isModelObject(obj) {
|
|
|
4682
4713
|
|
|
4683
4714
|
// src/model/block/scene/BlockObject.ts
|
|
4684
4715
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4685
|
-
var
|
|
4716
|
+
var import_three18 = require("three");
|
|
4686
4717
|
var p10 = prefix("BlockObject");
|
|
4687
4718
|
function matchesCondition(condition, state) {
|
|
4688
4719
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4744,7 +4775,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4744
4775
|
if (isModelObject(model)) {
|
|
4745
4776
|
model.removeFromScene();
|
|
4746
4777
|
} else if (isInstanceReference(model)) {
|
|
4747
|
-
model.setScale(new
|
|
4778
|
+
model.setScale(new import_three18.Vector3(0, 0, 0));
|
|
4748
4779
|
}
|
|
4749
4780
|
}
|
|
4750
4781
|
super.removeFromScene();
|
|
@@ -4805,7 +4836,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4805
4836
|
}
|
|
4806
4837
|
for (let model of this._models) {
|
|
4807
4838
|
if (isInstanceReference(model)) {
|
|
4808
|
-
model.setScale(new
|
|
4839
|
+
model.setScale(new import_three18.Vector3(0, 0, 0));
|
|
4809
4840
|
} else {
|
|
4810
4841
|
model.dispose();
|
|
4811
4842
|
}
|
|
@@ -4842,7 +4873,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4842
4873
|
await this.createVariant(variant);
|
|
4843
4874
|
}
|
|
4844
4875
|
async createVariant(variant) {
|
|
4845
|
-
const rotation = new
|
|
4876
|
+
const rotation = new import_three18.Euler();
|
|
4846
4877
|
if (typeof variant.x !== "undefined") {
|
|
4847
4878
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4848
4879
|
}
|
|
@@ -4931,7 +4962,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
4931
4962
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4932
4963
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4933
4964
|
}
|
|
4934
|
-
getMatrixAt(index, matrix = new
|
|
4965
|
+
getMatrixAt(index, matrix = new import_three18.Matrix4()) {
|
|
4935
4966
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4936
4967
|
const child = this._models[0];
|
|
4937
4968
|
if (child && isModelObject(child)) {
|
|
@@ -5006,7 +5037,7 @@ var StructureParser = class {
|
|
|
5006
5037
|
};
|
|
5007
5038
|
|
|
5008
5039
|
// src/renderer/MineRenderScene.ts
|
|
5009
|
-
var
|
|
5040
|
+
var import_three20 = require("three");
|
|
5010
5041
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
5011
5042
|
|
|
5012
5043
|
// src/skin/SkinPart.ts
|
|
@@ -5731,7 +5762,7 @@ var slimSkinGeometries = {
|
|
|
5731
5762
|
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
5732
5763
|
|
|
5733
5764
|
// src/skin/SkinTextures.ts
|
|
5734
|
-
var
|
|
5765
|
+
var import_three19 = require("three");
|
|
5735
5766
|
|
|
5736
5767
|
// src/skin/SkinImage.ts
|
|
5737
5768
|
var SkinImage = class {
|
|
@@ -5808,11 +5839,11 @@ var SkinTextures = class {
|
|
|
5808
5839
|
});
|
|
5809
5840
|
}
|
|
5810
5841
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
5811
|
-
const texture = Textures.initTextureProps(new
|
|
5812
|
-
texture.colorSpace =
|
|
5842
|
+
const texture = Textures.initTextureProps(new import_three19.DataTexture(pixels, width, height));
|
|
5843
|
+
texture.colorSpace = import_three19.SRGBColorSpace;
|
|
5813
5844
|
texture.flipY = true;
|
|
5814
5845
|
texture.needsUpdate = true;
|
|
5815
|
-
return new
|
|
5846
|
+
return new import_three19.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three19.DoubleSide : import_three19.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
5816
5847
|
}
|
|
5817
5848
|
static isSlim(image, scale) {
|
|
5818
5849
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -6039,7 +6070,7 @@ var SkinObject = class extends SceneObject {
|
|
|
6039
6070
|
};
|
|
6040
6071
|
|
|
6041
6072
|
// src/renderer/MineRenderScene.ts
|
|
6042
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
6073
|
+
var MineRenderScene = class _MineRenderScene extends import_three20.Scene {
|
|
6043
6074
|
constructor(options) {
|
|
6044
6075
|
super();
|
|
6045
6076
|
this.isMineRenderScene = true;
|
|
@@ -6163,17 +6194,17 @@ function isMineRenderScene(obj) {
|
|
|
6163
6194
|
}
|
|
6164
6195
|
|
|
6165
6196
|
// src/renderer/Renderer.ts
|
|
6166
|
-
var
|
|
6197
|
+
var import_three22 = require("three");
|
|
6167
6198
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
6168
6199
|
var import_stats = __toESM(require("stats.js"));
|
|
6169
6200
|
var import_postprocessing = require("postprocessing");
|
|
6170
6201
|
|
|
6171
6202
|
// src/three/OrbitControls.js
|
|
6172
|
-
var
|
|
6203
|
+
var import_three21 = require("three");
|
|
6173
6204
|
var _changeEvent = { type: "change" };
|
|
6174
6205
|
var _startEvent = { type: "start" };
|
|
6175
6206
|
var _endEvent = { type: "end" };
|
|
6176
|
-
var OrbitControls = class extends
|
|
6207
|
+
var OrbitControls = class extends import_three21.EventDispatcher {
|
|
6177
6208
|
constructor(object, domElement) {
|
|
6178
6209
|
super();
|
|
6179
6210
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -6182,7 +6213,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6182
6213
|
this.domElement = domElement;
|
|
6183
6214
|
this.domElement.style.touchAction = "none";
|
|
6184
6215
|
this.enabled = true;
|
|
6185
|
-
this.target = new
|
|
6216
|
+
this.target = new import_three21.Vector3();
|
|
6186
6217
|
this.minDistance = 0;
|
|
6187
6218
|
this.maxDistance = Infinity;
|
|
6188
6219
|
this.minZoom = 0;
|
|
@@ -6204,8 +6235,8 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6204
6235
|
this.autoRotate = false;
|
|
6205
6236
|
this.autoRotateSpeed = 2;
|
|
6206
6237
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
6207
|
-
this.mouseButtons = { LEFT:
|
|
6208
|
-
this.touches = { ONE:
|
|
6238
|
+
this.mouseButtons = { LEFT: import_three21.MOUSE.ROTATE, MIDDLE: import_three21.MOUSE.DOLLY, RIGHT: import_three21.MOUSE.PAN };
|
|
6239
|
+
this.touches = { ONE: import_three21.TOUCH.ROTATE, TWO: import_three21.TOUCH.DOLLY_PAN };
|
|
6209
6240
|
this.target0 = this.target.clone();
|
|
6210
6241
|
this.position0 = this.object.position.clone();
|
|
6211
6242
|
this.zoom0 = this.object.zoom;
|
|
@@ -6234,11 +6265,11 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6234
6265
|
state = STATE.NONE;
|
|
6235
6266
|
};
|
|
6236
6267
|
this.update = function() {
|
|
6237
|
-
const offset = new
|
|
6238
|
-
const quat = new
|
|
6268
|
+
const offset = new import_three21.Vector3();
|
|
6269
|
+
const quat = new import_three21.Quaternion().setFromUnitVectors(object.up, new import_three21.Vector3(0, 1, 0));
|
|
6239
6270
|
const quatInverse = quat.clone().invert();
|
|
6240
|
-
const lastPosition = new
|
|
6241
|
-
const lastQuaternion = new
|
|
6271
|
+
const lastPosition = new import_three21.Vector3();
|
|
6272
|
+
const lastQuaternion = new import_three21.Quaternion();
|
|
6242
6273
|
const twoPI = 2 * Math.PI;
|
|
6243
6274
|
return function update() {
|
|
6244
6275
|
const position = scope.object.position;
|
|
@@ -6324,20 +6355,20 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6324
6355
|
};
|
|
6325
6356
|
let state = STATE.NONE;
|
|
6326
6357
|
const EPS = 1e-6;
|
|
6327
|
-
const spherical = new
|
|
6328
|
-
const sphericalDelta = new
|
|
6358
|
+
const spherical = new import_three21.Spherical();
|
|
6359
|
+
const sphericalDelta = new import_three21.Spherical();
|
|
6329
6360
|
let scale = 1;
|
|
6330
|
-
const panOffset = new
|
|
6361
|
+
const panOffset = new import_three21.Vector3();
|
|
6331
6362
|
let zoomChanged = false;
|
|
6332
|
-
const rotateStart = new
|
|
6333
|
-
const rotateEnd = new
|
|
6334
|
-
const rotateDelta = new
|
|
6335
|
-
const panStart = new
|
|
6336
|
-
const panEnd = new
|
|
6337
|
-
const panDelta = new
|
|
6338
|
-
const dollyStart = new
|
|
6339
|
-
const dollyEnd = new
|
|
6340
|
-
const dollyDelta = new
|
|
6363
|
+
const rotateStart = new import_three21.Vector2();
|
|
6364
|
+
const rotateEnd = new import_three21.Vector2();
|
|
6365
|
+
const rotateDelta = new import_three21.Vector2();
|
|
6366
|
+
const panStart = new import_three21.Vector2();
|
|
6367
|
+
const panEnd = new import_three21.Vector2();
|
|
6368
|
+
const panDelta = new import_three21.Vector2();
|
|
6369
|
+
const dollyStart = new import_three21.Vector2();
|
|
6370
|
+
const dollyEnd = new import_three21.Vector2();
|
|
6371
|
+
const dollyDelta = new import_three21.Vector2();
|
|
6341
6372
|
const pointers = [];
|
|
6342
6373
|
const pointerPositions = {};
|
|
6343
6374
|
function getAutoRotationAngle() {
|
|
@@ -6353,7 +6384,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6353
6384
|
sphericalDelta.phi -= angle;
|
|
6354
6385
|
}
|
|
6355
6386
|
const panLeft = function() {
|
|
6356
|
-
const v = new
|
|
6387
|
+
const v = new import_three21.Vector3();
|
|
6357
6388
|
return function panLeft2(distance, objectMatrix) {
|
|
6358
6389
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6359
6390
|
v.multiplyScalar(-distance);
|
|
@@ -6361,7 +6392,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6361
6392
|
};
|
|
6362
6393
|
}();
|
|
6363
6394
|
const panUp = function() {
|
|
6364
|
-
const v = new
|
|
6395
|
+
const v = new import_three21.Vector3();
|
|
6365
6396
|
return function panUp2(distance, objectMatrix) {
|
|
6366
6397
|
if (scope.screenSpacePanning === true) {
|
|
6367
6398
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6374,7 +6405,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6374
6405
|
};
|
|
6375
6406
|
}();
|
|
6376
6407
|
const pan = function() {
|
|
6377
|
-
const offset = new
|
|
6408
|
+
const offset = new import_three21.Vector3();
|
|
6378
6409
|
return function pan2(deltaX, deltaY) {
|
|
6379
6410
|
const element = scope.domElement;
|
|
6380
6411
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6623,12 +6654,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6623
6654
|
mouseAction = -1;
|
|
6624
6655
|
}
|
|
6625
6656
|
switch (mouseAction) {
|
|
6626
|
-
case
|
|
6657
|
+
case import_three21.MOUSE.DOLLY:
|
|
6627
6658
|
if (scope.enableZoom === false) return;
|
|
6628
6659
|
handleMouseDownDolly(event);
|
|
6629
6660
|
state = STATE.DOLLY;
|
|
6630
6661
|
break;
|
|
6631
|
-
case
|
|
6662
|
+
case import_three21.MOUSE.ROTATE:
|
|
6632
6663
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6633
6664
|
if (scope.enablePan === false) return;
|
|
6634
6665
|
handleMouseDownPan(event);
|
|
@@ -6639,7 +6670,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6639
6670
|
state = STATE.ROTATE;
|
|
6640
6671
|
}
|
|
6641
6672
|
break;
|
|
6642
|
-
case
|
|
6673
|
+
case import_three21.MOUSE.PAN:
|
|
6643
6674
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6644
6675
|
if (scope.enableRotate === false) return;
|
|
6645
6676
|
handleMouseDownRotate(event);
|
|
@@ -6695,12 +6726,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6695
6726
|
switch (pointers.length) {
|
|
6696
6727
|
case 1:
|
|
6697
6728
|
switch (scope.touches.ONE) {
|
|
6698
|
-
case
|
|
6729
|
+
case import_three21.TOUCH.ROTATE:
|
|
6699
6730
|
if (scope.enableRotate === false) return;
|
|
6700
6731
|
handleTouchStartRotate();
|
|
6701
6732
|
state = STATE.TOUCH_ROTATE;
|
|
6702
6733
|
break;
|
|
6703
|
-
case
|
|
6734
|
+
case import_three21.TOUCH.PAN:
|
|
6704
6735
|
if (scope.enablePan === false) return;
|
|
6705
6736
|
handleTouchStartPan();
|
|
6706
6737
|
state = STATE.TOUCH_PAN;
|
|
@@ -6711,12 +6742,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6711
6742
|
break;
|
|
6712
6743
|
case 2:
|
|
6713
6744
|
switch (scope.touches.TWO) {
|
|
6714
|
-
case
|
|
6745
|
+
case import_three21.TOUCH.DOLLY_PAN:
|
|
6715
6746
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6716
6747
|
handleTouchStartDollyPan();
|
|
6717
6748
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6718
6749
|
break;
|
|
6719
|
-
case
|
|
6750
|
+
case import_three21.TOUCH.DOLLY_ROTATE:
|
|
6720
6751
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6721
6752
|
handleTouchStartDollyRotate();
|
|
6722
6753
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6783,7 +6814,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6783
6814
|
function trackPointer(event) {
|
|
6784
6815
|
let position = pointerPositions[event.pointerId];
|
|
6785
6816
|
if (position === void 0) {
|
|
6786
|
-
position = new
|
|
6817
|
+
position = new import_three21.Vector2();
|
|
6787
6818
|
pointerPositions[event.pointerId] = position;
|
|
6788
6819
|
}
|
|
6789
6820
|
position.set(event.pageX, event.pageY);
|
|
@@ -6803,10 +6834,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6803
6834
|
constructor(object, domElement) {
|
|
6804
6835
|
super(object, domElement);
|
|
6805
6836
|
this.screenSpacePanning = false;
|
|
6806
|
-
this.mouseButtons.LEFT =
|
|
6807
|
-
this.mouseButtons.RIGHT =
|
|
6808
|
-
this.touches.ONE =
|
|
6809
|
-
this.touches.TWO =
|
|
6837
|
+
this.mouseButtons.LEFT = import_three21.MOUSE.PAN;
|
|
6838
|
+
this.mouseButtons.RIGHT = import_three21.MOUSE.ROTATE;
|
|
6839
|
+
this.touches.ONE = import_three21.TOUCH.PAN;
|
|
6840
|
+
this.touches.TWO = import_three21.TOUCH.DOLLY_ROTATE;
|
|
6810
6841
|
}
|
|
6811
6842
|
};
|
|
6812
6843
|
|
|
@@ -6851,8 +6882,8 @@ var Renderer = class _Renderer {
|
|
|
6851
6882
|
top: void 0,
|
|
6852
6883
|
bottom: void 0
|
|
6853
6884
|
},
|
|
6854
|
-
position: new
|
|
6855
|
-
lookingAt: new
|
|
6885
|
+
position: new import_three22.Vector3(50, 50, 50),
|
|
6886
|
+
lookingAt: new import_three22.Vector3(0, 0, 0)
|
|
6856
6887
|
},
|
|
6857
6888
|
render: {
|
|
6858
6889
|
fpsLimit: 60,
|
|
@@ -6882,14 +6913,14 @@ var Renderer = class _Renderer {
|
|
|
6882
6913
|
switch (this.options.camera.type) {
|
|
6883
6914
|
case "perspective":
|
|
6884
6915
|
default:
|
|
6885
|
-
return new
|
|
6916
|
+
return new import_three22.PerspectiveCamera(
|
|
6886
6917
|
this.options.camera.perspective.fov,
|
|
6887
6918
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6888
6919
|
this.options.camera.near,
|
|
6889
6920
|
this.options.camera.far
|
|
6890
6921
|
);
|
|
6891
6922
|
case "orthographic":
|
|
6892
|
-
return new
|
|
6923
|
+
return new import_three22.OrthographicCamera(
|
|
6893
6924
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6894
6925
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6895
6926
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6900,7 +6931,7 @@ var Renderer = class _Renderer {
|
|
|
6900
6931
|
}
|
|
6901
6932
|
}
|
|
6902
6933
|
createRenderer() {
|
|
6903
|
-
const renderer = new
|
|
6934
|
+
const renderer = new import_three22.WebGLRenderer({
|
|
6904
6935
|
antialias: this.options.render.antialias,
|
|
6905
6936
|
alpha: true,
|
|
6906
6937
|
powerPreference: "high-performance",
|
|
@@ -6908,8 +6939,8 @@ var Renderer = class _Renderer {
|
|
|
6908
6939
|
});
|
|
6909
6940
|
renderer.setClearColor(0, 0);
|
|
6910
6941
|
renderer.shadowMap.enabled = true;
|
|
6911
|
-
renderer.shadowMap.type =
|
|
6912
|
-
renderer.outputColorSpace =
|
|
6942
|
+
renderer.shadowMap.type = import_three22.PCFSoftShadowMap;
|
|
6943
|
+
renderer.outputColorSpace = import_three22.SRGBColorSpace;
|
|
6913
6944
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6914
6945
|
return renderer;
|
|
6915
6946
|
}
|
|
@@ -6943,20 +6974,20 @@ var Renderer = class _Renderer {
|
|
|
6943
6974
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6944
6975
|
}
|
|
6945
6976
|
if (this.options.debug.grid) {
|
|
6946
|
-
const gridHelper = new
|
|
6977
|
+
const gridHelper = new import_three22.GridHelper(128, 16);
|
|
6947
6978
|
this._debugHelpers.push(gridHelper);
|
|
6948
6979
|
this.scene.add(gridHelper);
|
|
6949
|
-
const gridHelper2 = new
|
|
6980
|
+
const gridHelper2 = new import_three22.GridHelper(128, 16);
|
|
6950
6981
|
this._debugHelpers.push(gridHelper2);
|
|
6951
6982
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6952
6983
|
this.scene.add(gridHelper2);
|
|
6953
|
-
const gridHelper3 = new
|
|
6984
|
+
const gridHelper3 = new import_three22.GridHelper(128, 16);
|
|
6954
6985
|
this._debugHelpers.push(gridHelper3);
|
|
6955
6986
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6956
6987
|
this.scene.add(gridHelper3);
|
|
6957
6988
|
}
|
|
6958
6989
|
if (this.options.debug.axes) {
|
|
6959
|
-
const axesHelper = new
|
|
6990
|
+
const axesHelper = new import_three22.AxesHelper(64);
|
|
6960
6991
|
this._debugHelpers.push(axesHelper);
|
|
6961
6992
|
this.scene.add(axesHelper);
|
|
6962
6993
|
}
|
|
@@ -7311,10 +7342,10 @@ var Skins = class {
|
|
|
7311
7342
|
};
|
|
7312
7343
|
|
|
7313
7344
|
// src/world/Chunk.ts
|
|
7314
|
-
var
|
|
7345
|
+
var import_three25 = require("three");
|
|
7315
7346
|
|
|
7316
7347
|
// src/world/MineRenderWorld.ts
|
|
7317
|
-
var
|
|
7348
|
+
var import_three24 = require("three");
|
|
7318
7349
|
var MineRenderWorld = class {
|
|
7319
7350
|
constructor(scene) {
|
|
7320
7351
|
this._size = 4;
|
|
@@ -7325,10 +7356,10 @@ var MineRenderWorld = class {
|
|
|
7325
7356
|
}
|
|
7326
7357
|
getBlockAt(posOrX, y, z) {
|
|
7327
7358
|
if (typeof posOrX == "number") {
|
|
7328
|
-
return this.getBlockAt(new
|
|
7359
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
|
|
7329
7360
|
}
|
|
7330
7361
|
if (isTripleArray(posOrX)) {
|
|
7331
|
-
return this.getBlockAt(new
|
|
7362
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7332
7363
|
}
|
|
7333
7364
|
const chunk = this.getChunkAt(posOrX);
|
|
7334
7365
|
if (typeof chunk === "undefined") {
|
|
@@ -7339,10 +7370,10 @@ var MineRenderWorld = class {
|
|
|
7339
7370
|
}
|
|
7340
7371
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7341
7372
|
if (typeof posOrX == "number") {
|
|
7342
|
-
return this.setBlockAt(new
|
|
7373
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
|
|
7343
7374
|
}
|
|
7344
7375
|
if (isTripleArray(posOrX)) {
|
|
7345
|
-
return this.setBlockAt(new
|
|
7376
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7346
7377
|
}
|
|
7347
7378
|
this.validatePosBounds(posOrX);
|
|
7348
7379
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7388,14 +7419,14 @@ var MineRenderWorld = class {
|
|
|
7388
7419
|
return this._chunks[index];
|
|
7389
7420
|
}
|
|
7390
7421
|
static worldToScenePosition(pos) {
|
|
7391
|
-
return new
|
|
7422
|
+
return new import_three24.Vector3(
|
|
7392
7423
|
pos.x * 16,
|
|
7393
7424
|
pos.y * 16,
|
|
7394
7425
|
pos.z * 16
|
|
7395
7426
|
);
|
|
7396
7427
|
}
|
|
7397
7428
|
static sceneToWorldPosition(pos) {
|
|
7398
|
-
return new
|
|
7429
|
+
return new import_three24.Vector3(
|
|
7399
7430
|
pos.x / 16,
|
|
7400
7431
|
pos.y / 16,
|
|
7401
7432
|
pos.z / 16
|
|
@@ -7432,12 +7463,12 @@ var Chunk = class _Chunk {
|
|
|
7432
7463
|
this.x = x;
|
|
7433
7464
|
this.y = y;
|
|
7434
7465
|
this.z = z;
|
|
7435
|
-
let anchor = new
|
|
7466
|
+
let anchor = new import_three25.Object3D();
|
|
7436
7467
|
this._anchor = anchor;
|
|
7437
7468
|
scene.add(anchor);
|
|
7438
7469
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7439
7470
|
addBox3WireframeToObject(
|
|
7440
|
-
new
|
|
7471
|
+
new import_three25.Box3(new import_three25.Vector3(0, 0, 0), new import_three25.Vector3(256, 256, 256)),
|
|
7441
7472
|
anchor,
|
|
7442
7473
|
16776960,
|
|
7443
7474
|
4
|
|
@@ -7445,10 +7476,10 @@ var Chunk = class _Chunk {
|
|
|
7445
7476
|
}
|
|
7446
7477
|
getBlockAt(posOrX, y, z) {
|
|
7447
7478
|
if (typeof posOrX == "number") {
|
|
7448
|
-
return this.getBlockAt(new
|
|
7479
|
+
return this.getBlockAt(new import_three25.Vector3(posOrX, y, z));
|
|
7449
7480
|
}
|
|
7450
7481
|
if (isTripleArray(posOrX)) {
|
|
7451
|
-
return this.getBlockAt(new
|
|
7482
|
+
return this.getBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7452
7483
|
}
|
|
7453
7484
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7454
7485
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7456,10 +7487,10 @@ var Chunk = class _Chunk {
|
|
|
7456
7487
|
}
|
|
7457
7488
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7458
7489
|
if (typeof posOrX == "number") {
|
|
7459
|
-
return this.setBlockAt(new
|
|
7490
|
+
return this.setBlockAt(new import_three25.Vector3(posOrX, yOrBlock, z), block);
|
|
7460
7491
|
}
|
|
7461
7492
|
if (isTripleArray(posOrX)) {
|
|
7462
|
-
return this.setBlockAt(new
|
|
7493
|
+
return this.setBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7463
7494
|
}
|
|
7464
7495
|
const worldPos = posOrX;
|
|
7465
7496
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7505,7 +7536,7 @@ var Chunk = class _Chunk {
|
|
|
7505
7536
|
}
|
|
7506
7537
|
async clear() {
|
|
7507
7538
|
let promises = [];
|
|
7508
|
-
let pos = new
|
|
7539
|
+
let pos = new import_three25.Vector3();
|
|
7509
7540
|
for (let x = 0; x < 16; x++) {
|
|
7510
7541
|
for (let z = 0; z < 16; z++) {
|
|
7511
7542
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7524,14 +7555,14 @@ var Chunk = class _Chunk {
|
|
|
7524
7555
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7525
7556
|
}
|
|
7526
7557
|
worldPosToChunkPos(pos) {
|
|
7527
|
-
return new
|
|
7558
|
+
return new import_three25.Vector3(
|
|
7528
7559
|
pos.x - this.x * 16,
|
|
7529
7560
|
pos.y - this.y * 16,
|
|
7530
7561
|
pos.z - this.z * 16
|
|
7531
7562
|
);
|
|
7532
7563
|
}
|
|
7533
7564
|
chunkPosToWorldPos(pos) {
|
|
7534
|
-
return new
|
|
7565
|
+
return new import_three25.Vector3(
|
|
7535
7566
|
this.x * 16 + pos.x,
|
|
7536
7567
|
this.y * 16 + pos.y,
|
|
7537
7568
|
this.z * 16 + pos.z
|